+ list<list<KDMWithMetadataPtr> > const cinema_kdms = collect (kdms);
+
+ /* Decide whether to proceed */
+
+ bool proceed = true;
+
+ if (_email->GetValue ()) {
+
+ 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 cinemas_with_no_email = false;
+ for (auto i: cinema_kdms) {
+ if (i.front()->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 (proceed && Config::instance()->confirm_kdm_email ()) {
+ list<string> emails;
+ for (auto const& i: cinema_kdms) {
+ for (auto j: i.front()->emails()) {
+ emails.push_back (j);
+ }
+ }
+
+ if (!emails.empty ()) {
+ ConfirmKDMEmailDialog* d = new ConfirmKDMEmailDialog (this, emails);
+ if (d->ShowModal() == wxID_CANCEL) {
+ proceed = false;
+ }
+ }
+ }
+ }
+
+ if (!proceed) {
+ return make_pair (shared_ptr<Job>(), 0);
+ }
+