Confirm sending of KDM emails.
authorCarl Hetherington <cth@carlh.net>
Fri, 26 Aug 2016 10:19:34 +0000 (11:19 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 26 Aug 2016 10:19:34 +0000 (11:19 +0100)
src/lib/config.cc
src/lib/config.h
src/wx/confirm_kdm_email_dialog.cc [new file with mode: 0644]
src/wx/confirm_kdm_email_dialog.h [new file with mode: 0644]
src/wx/kdm_dialog.cc
src/wx/wscript

index 872900a73ec6d3b5730b73b9b9d58d2f28ff4b2e..a009edda8bc6277172335a507f6e426967f0e69b 100644 (file)
@@ -111,6 +111,7 @@ Config::set_defaults ()
 #endif
        _cinemas_file = path ("cinemas.xml");
        _show_hints_before_make_dcp = true;
+       _confirm_kdm_email = true;
        _kdm_filename_format = dcp::NameFormat ("KDM %f %c %s");
        _dcp_metadata_filename_format = dcp::NameFormat ("%t");
        _dcp_asset_filename_format = dcp::NameFormat ("%t");
@@ -296,6 +297,7 @@ try
 
        _cinemas_file = f.optional_string_child("CinemasFile").get_value_or (path ("cinemas.xml").string ());
        _show_hints_before_make_dcp = f.optional_bool_child("ShowHintsBeforeMakeDCP").get_value_or (true);
+       _confirm_kdm_email = f.optional_bool_child("ConfirmKDMEmail").get_value_or (true);
        _kdm_filename_format = dcp::NameFormat (f.optional_string_child("KDMFilenameFormat").get_value_or ("KDM %f %c %s"));
        _dcp_metadata_filename_format = dcp::NameFormat (f.optional_string_child("DCPMetadataFilenameFormat").get_value_or ("%t"));
        _dcp_asset_filename_format = dcp::NameFormat (f.optional_string_child("DCPAssetFilenameFormat").get_value_or ("%t"));
@@ -456,6 +458,7 @@ Config::write_config_xml () const
 
        root->add_child("CinemasFile")->add_child_text (_cinemas_file.string());
        root->add_child("ShowHintsBeforeMakeDCP")->add_child_text (_show_hints_before_make_dcp ? "1" : "0");
+       root->add_child("ConfirmKDMEmail")->add_child_text (_confirm_kdm_email ? "1" : "0");
        root->add_child("KDMFilenameFormat")->add_child_text (_kdm_filename_format.specification ());
        root->add_child("DCPMetadataFilenameFormat")->add_child_text (_dcp_metadata_filename_format.specification ());
        root->add_child("DCPAssetFilenameFormat")->add_child_text (_dcp_asset_filename_format.specification ());
index e18cd33121da70ea46a7429afd832bb17a8ce610..a38fb129cdc5f3bca38e3c83af7fefb18ab85c8a 100644 (file)
@@ -268,6 +268,10 @@ public:
                return _show_hints_before_make_dcp;
        }
 
+       bool confirm_kdm_email () const {
+               return _confirm_kdm_email;
+       }
+
        dcp::NameFormat kdm_filename_format () const {
                return _kdm_filename_format;
        }
@@ -487,6 +491,10 @@ public:
                maybe_set (_show_hints_before_make_dcp, s);
        }
 
+       void set_confirm_kdm_email (bool s) {
+               maybe_set (_confirm_kdm_email, s);
+       }
+
        void set_kdm_filename_format (dcp::NameFormat n) {
                maybe_set (_kdm_filename_format, n);
        }
@@ -617,6 +625,7 @@ private:
        std::vector<dcp::EncryptedKDM> _dkdms;
        boost::filesystem::path _cinemas_file;
        bool _show_hints_before_make_dcp;
+       bool _confirm_kdm_email;
        dcp::NameFormat _kdm_filename_format;
        dcp::NameFormat _dcp_metadata_filename_format;
        dcp::NameFormat _dcp_asset_filename_format;
diff --git a/src/wx/confirm_kdm_email_dialog.cc b/src/wx/confirm_kdm_email_dialog.cc
new file mode 100644 (file)
index 0000000..69ee7fe
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+    Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "confirm_kdm_email_dialog.h"
+#include "wx_util.h"
+#include "lib/config.h"
+#include "lib/cinema_kdms.h"
+#include <boost/foreach.hpp>
+
+using std::list;
+using std::string;
+
+ConfirmKDMEmailDialog::ConfirmKDMEmailDialog (wxWindow* parent, list<string> emails)
+       : wxDialog (parent, wxID_ANY, _("Confirm KDM email"))
+{
+       wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
+
+       wxString message = _("Are you sure you want to send emails to the following addresses?\n\n");
+       BOOST_FOREACH (string i, emails) {
+               message += "\t" + std_to_wx (i) + "\n";
+       }
+
+       sizer->Add (new wxStaticText (this, wxID_ANY, message), 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
+
+       wxCheckBox* shut_up = new wxCheckBox (this, wxID_ANY, _("Don't ask this again"));
+       sizer->Add (shut_up, 0, wxALL, DCPOMATIC_DIALOG_BORDER);
+
+       shut_up->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, bind (&ConfirmKDMEmailDialog::shut_up, this, _1));
+
+       wxStdDialogButtonSizer* buttons = CreateStdDialogButtonSizer (0);
+       sizer->Add (CreateSeparatedSizer(buttons), wxSizerFlags().Expand().DoubleBorder());
+       buttons->SetAffirmativeButton (new wxButton (this, wxID_OK, _("Send emails")));
+       buttons->SetNegativeButton (new wxButton (this, wxID_CANCEL, _("Don't send emails")));
+       buttons->Realize ();
+
+       SetSizer (sizer);
+       sizer->Layout ();
+       sizer->SetSizeHints (this);
+}
+
+void
+ConfirmKDMEmailDialog::shut_up (wxCommandEvent& ev)
+{
+       Config::instance()->set_confirm_kdm_email (!ev.IsChecked ());
+}
diff --git a/src/wx/confirm_kdm_email_dialog.h b/src/wx/confirm_kdm_email_dialog.h
new file mode 100644 (file)
index 0000000..84182ad
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+    Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    DCP-o-matic is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include <wx/wx.h>
+#include <list>
+
+class ConfirmKDMEmailDialog : public wxDialog
+{
+public:
+       ConfirmKDMEmailDialog (wxWindow* parent, std::list<std::string> addresses);
+
+private:
+       void shut_up (wxCommandEvent& ev);
+};
index b5ebd1e968c79dd0e1d11406244e24d5414e3eb3..40efc5411e61bfac248e8a181ecb386552d2e1a4 100644 (file)
 #include "kdm_timing_panel.h"
 #include "kdm_output_panel.h"
 #include "kdm_cpl_panel.h"
+#include "confirm_kdm_email_dialog.h"
 #include "lib/film.h"
 #include "lib/screen.h"
 #include "lib/screen_kdm.h"
 #include "lib/send_kdm_email_job.h"
 #include "lib/job_manager.h"
 #include "lib/cinema_kdms.h"
+#include "lib/config.h"
+#include "lib/cinema.h"
 #include <libcxml/cxml.h>
 #include <dcp/exceptions.h>
 #include <wx/treectrl.h>
@@ -148,15 +151,36 @@ KDMDialog::make_clicked ()
                }
 
                if (_output->email ()) {
-                       JobManager::instance()->add (
-                               shared_ptr<Job> (new SendKDMEmailJob (
-                                                        CinemaKDMs::collect (screen_kdms),
-                                                        _output->name_format(),
-                                                        name_values,
-                                                        film->dcp_name(),
-                                                        film->log()
-                                                        ))
-                               );
+
+                       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) {
+                               JobManager::instance()->add (
+                                       shared_ptr<Job> (new SendKDMEmailJob (
+                                                                cinema_kdms,
+                                                                _output->name_format(),
+                                                                name_values,
+                                                                film->dcp_name(),
+                                                                film->log()
+                                                                ))
+                                       );
+                       }
                }
        } catch (dcp::NotEncryptedError& e) {
                error_dialog (this, _("CPL's content is not encrypted."));
index f89b60c40fc4f707d29a1ff656a6c681eb74ec12..e001c51b7a6f429fbb9246dacd4f7a083461ace0 100644 (file)
@@ -34,6 +34,7 @@ sources = """
           cinema_dialog.cc
           colour_conversion_editor.cc
           config_dialog.cc
+          confirm_kdm_email_dialog.cc
           content_colour_conversion_dialog.cc
           content_menu.cc
           content_panel.cc