table->Add (_type, 1, wxEXPAND);
_type->SetSelection (0);
+ {
+ int flags = wxALIGN_TOP | wxTOP | wxLEFT | wxRIGHT;
+ wxString t = _("Folder / ZIP name format");
+#ifdef __WXOSX__
+ flags |= wxALIGN_RIGHT;
+ t += wxT (":");
+#endif
+ wxStaticText* m = new wxStaticText (this, wxID_ANY, t);
+ table->Add (m, 0, flags, DCPOMATIC_SIZER_Y_GAP);
+ }
+
+ _container_name_format = new NameFormatEditor (this, Config::instance()->kdm_container_name_format(), dcp::NameFormat::Map(), dcp::NameFormat::Map(), "");
+ table->Add (_container_name_format->panel(), 1, wxEXPAND);
+
{
int flags = wxALIGN_TOP | wxTOP | wxLEFT | wxRIGHT;
wxString t = _("Filename format");
table->Add (_folder, 1, wxEXPAND);
+ wxSizer* write_options = new wxBoxSizer(wxVERTICAL);
+ _write_flat = new wxRadioButton (this, wxID_ANY, _("Write all KDMs to the same folder"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
+ write_options->Add (_write_flat);
+ _write_folder = new wxRadioButton (this, wxID_ANY, _("Write a folder for each cinema's KDMs"));
+ write_options->Add (_write_folder);
+ _write_zip = new wxRadioButton (this, wxID_ANY, _("Write a ZIP file for each cinema's KDMs"));
+ write_options->Add (_write_zip);
+ table->AddSpacer (0);
+ table->Add (write_options);
+
_email = new wxCheckBox (this, wxID_ANY, _("Send by email"));
table->Add (_email, 1, wxEXPAND);
table->AddSpacer (0);
void
KDMOutputPanel::setup_sensitivity ()
{
- _folder->Enable (_write_to->GetValue ());
+ bool const write = _write_to->GetValue ();
+ _folder->Enable (write);
+ _write_flat->Enable (write);
+ _write_folder->Enable (write);
+ _write_zip->Enable (write);
}
pair<shared_ptr<Job>, int>
list<ScreenKDM> screen_kdms, string name, KDMTimingPanel* timing, function<bool (boost::filesystem::path)> confirm_overwrite, shared_ptr<Log> log
)
{
- Config::instance()->set_kdm_filename_format (_filename_format->get ());
+ list<CinemaKDMs> const cinema_kdms = CinemaKDMs::collect (screen_kdms);
- int written = 0;
- shared_ptr<Job> job;
+ /* Decide whether to proceed */
- try {
- dcp::NameFormat::Map name_values;
- name_values['f'] = name;
- name_values['b'] = dcp::LocalTime(timing->from()).date() + " " + dcp::LocalTime(timing->from()).time_of_day();
- name_values['e'] = dcp::LocalTime(timing->until()).date() + " " + dcp::LocalTime(timing->until()).time_of_day();
-
- if (_write_to->GetValue ()) {
- written = ScreenKDM::write_files (
- screen_kdms,
- directory(),
- _filename_format->get(),
- name_values,
- confirm_overwrite
- );
- }
+ bool proceed = true;
- if (_email->GetValue ()) {
+ if (_email->GetValue ()) {
- list<CinemaKDMs> const cinema_kdms = CinemaKDMs::collect (screen_kdms);
+ if (Config::instance()->mail_server().empty ()) {
+ proceed = false;
+ error_dialog (this, _("You must set up a mail server in Preferences before you can send emails."));
+ }
- bool ok = true;
+ bool cinemas_with_no_email = false;
+ BOOST_FOREACH (CinemaKDMs i, cinema_kdms) {
+ if (i.cinema->emails.empty ()) {
+ cinemas_with_no_email = true;
+ }
+ }
+
+ if (proceed && cinemas_with_no_email && !confirm_dialog (
+ this,
+ _("You have selected some cinemas that have no configured email address. Do you want to continue?")
+ )) {
+ proceed = false;
+ }
- if (Config::instance()->confirm_kdm_email ()) {
- list<string> emails;
- BOOST_FOREACH (CinemaKDMs i, cinema_kdms) {
- BOOST_FOREACH (string j, i.cinema->emails) {
- emails.push_back (j);
- }
+ if (proceed && Config::instance()->confirm_kdm_email ()) {
+ list<string> emails;
+ BOOST_FOREACH (CinemaKDMs i, cinema_kdms) {
+ BOOST_FOREACH (string j, i.cinema->emails) {
+ emails.push_back (j);
}
+ }
+ if (!emails.empty ()) {
ConfirmKDMEmailDialog* d = new ConfirmKDMEmailDialog (this, emails);
if (d->ShowModal() == wxID_CANCEL) {
- ok = false;
+ proceed = false;
}
}
+ }
+ }
- if (ok) {
- job.reset (
- new SendKDMEmailJob (
- cinema_kdms,
- _filename_format->get(),
- name_values,
- name,
- log
- )
+ if (!proceed) {
+ return make_pair (shared_ptr<Job>(), 0);
+ }
+
+ Config::instance()->set_kdm_filename_format (_filename_format->get ());
+
+ int written = 0;
+ shared_ptr<Job> job;
+
+ try {
+ dcp::NameFormat::Map name_values;
+ name_values['f'] = name;
+ name_values['b'] = dcp::LocalTime(timing->from()).date() + " " + dcp::LocalTime(timing->from()).time_of_day(false, false);
+ name_values['e'] = dcp::LocalTime(timing->until()).date() + " " + dcp::LocalTime(timing->until()).time_of_day(false, false);
+
+ if (_write_to->GetValue()) {
+ if (_write_flat->GetValue()) {
+ written = ScreenKDM::write_files (
+ screen_kdms,
+ directory(),
+ _filename_format->get(),
+ name_values,
+ confirm_overwrite
+ );
+ } else if (_write_folder->GetValue()) {
+ written = CinemaKDMs::write_directories (
+ CinemaKDMs::collect (screen_kdms),
+ directory(),
+ _container_name_format->get(),
+ _filename_format->get(),
+ name_values,
+ confirm_overwrite
+ );
+ } else if (_write_zip->GetValue()) {
+ written = CinemaKDMs::write_zip_files (
+ CinemaKDMs::collect (screen_kdms),
+ directory(),
+ _container_name_format->get(),
+ _filename_format->get(),
+ name_values,
+ confirm_overwrite
);
}
}
+
+ if (_email->GetValue ()) {
+ job.reset (
+ new SendKDMEmailJob (
+ cinema_kdms,
+ _container_name_format->get(),
+ _filename_format->get(),
+ name_values,
+ name,
+ log
+ )
+ );
+ }
+
} catch (dcp::NotEncryptedError& e) {
error_dialog (this, _("CPL's content is not encrypted."));
} catch (exception& e) {