Add option to CC a KDM email, and add
authorCarl Hetherington <cth@carlh.net>
Sun, 22 Jun 2014 23:24:07 +0000 (00:24 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 22 Jun 2014 23:24:07 +0000 (00:24 +0100)
$SCREENS and $CINEMA_NAME as variables
in the email.

Suggested-by: Carsten Kurz
ChangeLog
src/lib/config.cc
src/lib/config.h
src/lib/kdm.cc
src/wx/config_dialog.cc

index 0c04645cd5b8fb6353edccc3a67d99fecb3c3de5..818daeec2a92997e9a1c0ca8ccb20bdaab6be210 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-06-23  Carl Hetherington  <cth@carlh.net>
+
+       * Add option to CC a KDM email, and add
+       $SCREENS and $CINEMA_NAME as variables
+       in the email.
+
 2014-06-22  Carl Hetherington  <cth@carlh.net>
 
        * Reset-to-default button for KDM email text.
index 901a6b19ed8e10d05eb45239c3373369058a8d08..8e6dffee73f51d08a42098bd47adecd539922529 100644 (file)
@@ -187,6 +187,7 @@ Config::read ()
        _mail_user = f.optional_string_child("MailUser").get_value_or ("");
        _mail_password = f.optional_string_child("MailPassword").get_value_or ("");
        _kdm_from = f.string_child ("KDMFrom");
+       _kdm_cc = f.optional_string_child ("KDMCC").get_value_or ("");
        _kdm_email = f.string_child ("KDMEmail");
 
        _check_for_updates = f.optional_bool_child("CheckForUpdates").get_value_or (false);
@@ -366,6 +367,7 @@ Config::write () const
        root->add_child("MailUser")->add_child_text (_mail_user);
        root->add_child("MailPassword")->add_child_text (_mail_password);
        root->add_child("KDMFrom")->add_child_text (_kdm_from);
+       root->add_child("KDMCC")->add_child_text (_kdm_cc);
        root->add_child("KDMEmail")->add_child_text (_kdm_email);
 
        root->add_child("CheckForUpdates")->add_child_text (_check_for_updates ? "1" : "0");
@@ -414,6 +416,8 @@ Config::reset_kdm_email ()
        _kdm_email = _(
                "Dear Projectionist\n\n"
                "Please find attached KDMs for $CPL_NAME.\n\n"
+               "Cinema: $CINEMA_NAME\n"
+               "Screen(s): $SCREENS\n\n"
                "The KDMs are valid from $START_TIME until $END_TIME.\n\n"
                "Best regards,\nDCP-o-matic"
                );
index c359901a48f2df2543311c83e1aa2bf4f0a17591..ebcf7e83dd98fa524f839c341e2e4873094c4eac 100644 (file)
@@ -173,6 +173,10 @@ public:
                return _kdm_from;
        }
 
+       std::string kdm_cc () const {
+               return _kdm_cc;
+       }
+       
        std::string kdm_email () const {
                return _kdm_email;
        }
@@ -324,6 +328,11 @@ public:
                changed ();
        }
 
+       void set_kdm_cc (std::string f) {
+               _kdm_cc = f;
+               changed ();
+       }
+       
        void set_kdm_email (std::string e) {
                _kdm_email = e;
                changed ();
@@ -406,6 +415,7 @@ private:
        std::string _mail_user;
        std::string _mail_password;
        std::string _kdm_from;
+       std::string _kdm_cc;
        std::string _kdm_email;
        /** true to check for updates on startup */
        bool _check_for_updates;
index d5d5ec0a0b16d5e503070d09c158b4ff61733ee6..5efea089c1053661d8ad86b6724889886bc58d30 100644 (file)
@@ -32,6 +32,7 @@
 using std::list;
 using std::string;
 using std::stringstream;
+using std::cout;
 using boost::shared_ptr;
 
 struct ScreenKDM
@@ -228,7 +229,9 @@ email_kdms (
                quickmail_initialize ();
                quickmail mail = quickmail_create (Config::instance()->kdm_from().c_str(), "KDM delivery");
                quickmail_add_to (mail, i->cinema->email.c_str ());
-               
+               if (!Config::instance()->kdm_cc().empty ()) {
+                       quickmail_add_cc (mail, Config::instance()->kdm_cc().c_str ());
+               }
                string body = Config::instance()->kdm_email().c_str();
                boost::algorithm::replace_all (body, "$CPL_NAME", film->dcp_name ());
                stringstream start;
@@ -237,6 +240,12 @@ email_kdms (
                stringstream end;
                end << to.date() << " " << to.time_of_day();
                boost::algorithm::replace_all (body, "$END_TIME", end.str ());
+               boost::algorithm::replace_all (body, "$CINEMA_NAME", i->cinema->name);
+               stringstream screens;
+               for (list<ScreenKDM>::const_iterator j = i->screen_kdms.begin(); j != i->screen_kdms.end(); ++j) {
+                       screens << j->screen->name << ", ";
+               }
+               boost::algorithm::replace_all (body, "$SCREENS", screens.str().substr (0, screens.str().length() - 2));
 
                quickmail_set_body (mail, body.c_str());
                quickmail_add_attachment_file (mail, zip_file.string().c_str(), "application/zip");
index 9cd8170b49648338051a17e3fcd1306b9928c3b8..086e1be4ec7e85ab8ef8f0888780cea4aec0f6f6 100644 (file)
@@ -673,6 +673,10 @@ public:
                add_label_to_sizer (table, panel, _("From address"), true);
                _kdm_from = new wxTextCtrl (panel, wxID_ANY);
                table->Add (_kdm_from, 1, wxEXPAND | wxALL);
+
+               add_label_to_sizer (table, panel, _("CC address"), true);
+               _kdm_cc = new wxTextCtrl (panel, wxID_ANY);
+               table->Add (_kdm_cc, 1, wxEXPAND | wxALL);
                
                _kdm_email = new wxTextCtrl (panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize (480, 128), wxTE_MULTILINE);
                s->Add (_kdm_email, 1.5, wxEXPAND | wxALL, _border);
@@ -689,6 +693,8 @@ public:
                _mail_password->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&KDMEmailPage::mail_password_changed, this));
                _kdm_from->SetValue (std_to_wx (config->kdm_from ()));
                _kdm_from->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&KDMEmailPage::kdm_from_changed, this));
+               _kdm_cc->SetValue (std_to_wx (config->kdm_cc ()));
+               _kdm_cc->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&KDMEmailPage::kdm_cc_changed, this));
                _kdm_email->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&KDMEmailPage::kdm_email_changed, this));
                _kdm_email->SetValue (wx_to_std (Config::instance()->kdm_email ()));
                _reset_kdm_email->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&KDMEmailPage::reset_kdm_email, this));
@@ -717,6 +723,11 @@ private:
                Config::instance()->set_kdm_from (wx_to_std (_kdm_from->GetValue ()));
        }
 
+       void kdm_cc_changed ()
+       {
+               Config::instance()->set_kdm_cc (wx_to_std (_kdm_cc->GetValue ()));
+       }
+       
        void kdm_email_changed ()
        {
                Config::instance()->set_kdm_email (wx_to_std (_kdm_email->GetValue ()));
@@ -732,6 +743,7 @@ private:
        wxTextCtrl* _mail_user;
        wxTextCtrl* _mail_password;
        wxTextCtrl* _kdm_from;
+       wxTextCtrl* _kdm_cc;
        wxTextCtrl* _kdm_email;
        wxButton* _reset_kdm_email;
 };