- dcp::NameFormat::Map name_values;
- name_values["film_name"] = film->name();
- name_values["from"] = dcp::LocalTime(_timing->from()).date() + " " + dcp::LocalTime(_timing->from()).time_of_day();
- name_values["to"] = dcp::LocalTime(_timing->until()).date() + " " + dcp::LocalTime(_timing->until()).time_of_day();
-
- if (_output->write_to ()) {
- ScreenKDM::write_files (
- screen_kdms,
- _output->directory(),
- _output->name_format(),
- name_values
- );
- } else {
- JobManager::instance()->add (
- shared_ptr<Job> (new SendKDMEmailJob (
- CinemaKDMs::collect (screen_kdms),
- _output->name_format(),
- name_values,
- film->dcp_name(),
- film->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."));
+ } catch (runtime_error& e) {
+ error_dialog (this, std_to_wx(e.what()));
+ return;
+ }
+
+ pair<shared_ptr<Job>, int> result = _output->make (screen_kdms, film->name(), _timing, bind (&KDMDialog::confirm_overwrite, this, _1));
+ if (result.first) {
+ JobManager::instance()->add (result.first);
+ }
+
+ if (result.second > 0) {
+ /* XXX: proper plural form support in wxWidgets? */
+ wxString s = result.second == 1 ? _("%d KDM written to %s") : _("%d KDMs written to %s");
+ message_dialog (
+ this,
+ wxString::Format (s, result.second, std_to_wx(_output->directory().string()).data())
+ );