Warn if there is no mail server configured when one is needed (#1046).
authorCarl Hetherington <cth@carlh.net>
Fri, 5 May 2017 12:35:50 +0000 (13:35 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 5 May 2017 12:35:50 +0000 (13:35 +0100)
ChangeLog
src/wx/kdm_output_panel.cc

index dc1f3f7a04285c65c95637441c181c8721754ca4..2c9c96b662a6a211ce87d5e8197dddd23a0de0b7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-05-05  Carl Hetherington  <cth@carlh.net>
+
+       * Warn user if they try to send KDM emails without a configured mail server (#1046).
+
 2017-05-04  Carl Hetherington  <cth@carlh.net>
 
        * Nag users to backup config.xml if they make a DKDM.
index f9078eac45729a9f249d62996bda5738b61078e3..bbfc1a01d4bf53ff6b7bca07742d9adda1d29661 100644 (file)
@@ -155,6 +155,54 @@ KDMOutputPanel::make (
        list<ScreenKDM> screen_kdms, string name, KDMTimingPanel* timing, function<bool (boost::filesystem::path)> confirm_overwrite, shared_ptr<Log> log
        )
 {
+       list<CinemaKDMs> const cinema_kdms = CinemaKDMs::collect (screen_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;
+               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 (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) {
+                                       proceed = false;
+                               }
+                       }
+               }
+       }
+
+       if (!proceed) {
+               return make_pair (shared_ptr<Job>(), 0);
+       }
+
        Config::instance()->set_kdm_filename_format (_filename_format->get ());
 
        int written = 0;
@@ -197,37 +245,17 @@ KDMOutputPanel::make (
                }
 
                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
-                                               )
-                                       );
-                       }
+                       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) {