+ 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();
+ 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
+ );
+ }
+
+ if (_email->GetValue ()) {
+
+ list<CinemaKDMs> const cinema_kdms = CinemaKDMs::collect (screen_kdms);
+
+ bool ok = true;
+
+ 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);
+ }
+ }
+
+ ConfirmKDMEmailDialog* d = new ConfirmKDMEmailDialog (this, emails);
+ if (d->ShowModal() == wxID_CANCEL) {
+ ok = false;
+ }
+ }
+
+ if (ok) {
+ job.reset (
+ new SendKDMEmailJob (
+ cinema_kdms,
+ _filename_format->get(),
+ name_values,
+ name,
+ log
+ )
+ );
+ }
+ }
+ } catch (dcp::NotEncryptedError& e) {
+ error_dialog (this, _("CPL's content is not encrypted."));
+ } catch (exception& e) {
+ error_dialog (this, e.what ());
+ } catch (...) {
+ error_dialog (this, _("An unknown exception occurred."));
+ }