summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-05-27 20:54:06 +0100
committerCarl Hetherington <cth@carlh.net>2018-05-27 23:05:46 +0100
commit1158dd504d0838b0c359b2cf1d63615c4ecb0a53 (patch)
tree026a4bf5c2175d96ed90007bb17d4362850dcefd /src/lib
parentaae000e8a37a494bf20ba0e5dd219ad9f78c6286 (diff)
Add UI for message box / email notifications.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/config.cc69
-rw-r--r--src/lib/config.h72
2 files changed, 141 insertions, 0 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc
index 026c92c83..8f1dd86ff 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -111,6 +111,10 @@ Config::set_defaults ()
_kdm_from = "";
_kdm_cc.clear ();
_kdm_bcc = "";
+ _notification_from = "";
+ _notification_to = "";
+ _notification_cc.clear ();
+ _notification_bcc = "";
_check_for_updates = false;
_check_for_test_updates = false;
_maximum_j2k_bandwidth = 250000000;
@@ -148,6 +152,9 @@ Config::set_defaults ()
_frames_in_memory_multiplier = 3;
_decode_reduction = optional<int>();
_default_notify = false;
+ for (int i = 0; i < NOTIFICATION_COUNT; ++i) {
+ _notification[i] = false;
+ }
_allowed_dcp_frame_rates.clear ();
_allowed_dcp_frame_rates.push_back (24);
@@ -158,6 +165,7 @@ Config::set_defaults ()
_allowed_dcp_frame_rates.push_back (60);
set_kdm_email_to_default ();
+ set_notification_email_to_default ();
set_cover_sheet_to_default ();
}
@@ -306,6 +314,7 @@ try
_mail_port = f.optional_number_child<int> ("MailPort").get_value_or (25);
_mail_user = f.optional_string_child("MailUser").get_value_or ("");
_mail_password = f.optional_string_child("MailPassword").get_value_or ("");
+
_kdm_subject = f.optional_string_child ("KDMSubject").get_value_or (_("KDM delivery: $CPL_NAME"));
_kdm_from = f.string_child ("KDMFrom");
BOOST_FOREACH (cxml::ConstNodePtr i, f.node_children("KDMCC")) {
@@ -316,6 +325,19 @@ try
_kdm_bcc = f.optional_string_child ("KDMBCC").get_value_or ("");
_kdm_email = f.string_child ("KDMEmail");
+ _notification_subject = f.optional_string_child("NotificationSubject").get_value_or(_("DCP-o-matic notification"));
+ _notification_from = f.optional_string_child("NotificationFrom").get_value_or("");
+ _notification_to = f.optional_string_child("NotificationTo").get_value_or("");
+ BOOST_FOREACH (cxml::ConstNodePtr i, f.node_children("NotificationCC")) {
+ if (!i->content().empty()) {
+ _notification_cc.push_back (i->content ());
+ }
+ }
+ _notification_bcc = f.optional_string_child("NotificationBCC").get_value_or("");
+ if (f.optional_string_child("NotificationEmail")) {
+ _notification_email = f.string_child("NotificationEmail");
+ }
+
_check_for_updates = f.optional_bool_child("CheckForUpdates").get_value_or (false);
_check_for_test_updates = f.optional_bool_child("CheckForTestUpdates").get_value_or (false);
@@ -432,6 +454,13 @@ try
_decode_reduction = f.optional_number_child<int>("DecodeReduction");
_default_notify = f.optional_bool_child("DefaultNotify").get_value_or(false);
+ BOOST_FOREACH (cxml::NodePtr i, f.node_children("Notification")) {
+ int const id = i->number_attribute<int>("Id");
+ if (id >= 0 && id < NOTIFICATION_COUNT) {
+ _notification[id] = raw_convert<int>(i->content());
+ }
+ }
+
/* Replace any cinemas from config.xml with those from the configured file */
if (boost::filesystem::exists (_cinemas_file)) {
cxml::Document f ("Cinemas");
@@ -610,6 +639,7 @@ Config::write_config () const
root->add_child("MailUser")->add_child_text (_mail_user);
/* [XML] MailPassword Password to use on SMTP server. */
root->add_child("MailPassword")->add_child_text (_mail_password);
+
/* [XML] KDMSubject Subject to use for KDM emails. */
root->add_child("KDMSubject")->add_child_text (_kdm_subject);
/* [XML] KDMFrom From address to use for KDM emails. */
@@ -623,6 +653,21 @@ Config::write_config () const
/* [XML] KDMEmail Text of KDM email */
root->add_child("KDMEmail")->add_child_text (_kdm_email);
+ /* [XML] NotificationSubject Subject to use for Notification emails. */
+ root->add_child("NotificationSubject")->add_child_text (_notification_subject);
+ /* [XML] NotificationFrom From address to use for Notification emails. */
+ root->add_child("NotificationFrom")->add_child_text (_notification_from);
+ /* [XML] NotificationFrom To address to use for Notification emails. */
+ root->add_child("NotificationTo")->add_child_text (_notification_to);
+ BOOST_FOREACH (string i, _notification_cc) {
+ /* [XML] NotificationCC CC address to use for Notification emails; you can use as many of these tags as you like. */
+ root->add_child("NotificationCC")->add_child_text (i);
+ }
+ /* [XML] NotificationBCC BCC address to use for Notification emails */
+ root->add_child("NotificationBCC")->add_child_text (_notification_bcc);
+ /* [XML] NotificationEmail Text of Notification email */
+ root->add_child("NotificationEmail")->add_child_text (_notification_email);
+
/* [XML] CheckForUpdates 1 to check dcpomatic.com for new versions, 0 to check only on request */
root->add_child("CheckForUpdates")->add_child_text (_check_for_updates ? "1" : "0");
/* [XML] CheckForUpdates 1 to check dcpomatic.com for new text versions, 0 to check only on request */
@@ -750,6 +795,13 @@ Config::write_config () const
/* [XML] DefaultNotify 1 to default jobs to notify when complete, otherwise 0 */
root->add_child("DefaultNotify")->add_child_text(_default_notify ? "1" : "0");
+ /* [XML] Notification 1 if a notification type is enabled, otherwise 0 */
+ for (int i = 0; i < NOTIFICATION_COUNT; ++i) {
+ xmlpp::Element* e = root->add_child ("Notification");
+ e->set_attribute ("Id", raw_convert<string>(i));
+ e->add_child_text (_notification[i] ? "1" : "0");
+ }
+
try {
doc.write_to_file_formatted(config_file().string());
} catch (xmlpp::exception& e) {
@@ -836,6 +888,16 @@ Config::set_kdm_email_to_default ()
}
void
+Config::set_notification_email_to_default ()
+{
+ _notification_subject = _("DCP-o-matic notification");
+
+ _notification_email = _(
+ "$JOB_NAME: $JOB_STATUS"
+ );
+}
+
+void
Config::reset_kdm_email ()
{
set_kdm_email_to_default ();
@@ -843,6 +905,13 @@ Config::reset_kdm_email ()
}
void
+Config::reset_notification_email ()
+{
+ set_notification_email_to_default ();
+ changed ();
+}
+
+void
Config::set_cover_sheet_to_default ()
{
_cover_sheet = _(
diff --git a/src/lib/config.h b/src/lib/config.h
index 1e16fc840..4c24e816b 100644
--- a/src/lib/config.h
+++ b/src/lib/config.h
@@ -244,6 +244,30 @@ public:
return _kdm_email;
}
+ std::string notification_subject () const {
+ return _notification_subject;
+ }
+
+ std::string notification_from () const {
+ return _notification_from;
+ }
+
+ std::string notification_to () const {
+ return _notification_to;
+ }
+
+ std::vector<std::string> notification_cc () const {
+ return _notification_cc;
+ }
+
+ std::string notification_bcc () const {
+ return _notification_bcc;
+ }
+
+ std::string notification_email () const {
+ return _notification_email;
+ }
+
boost::shared_ptr<const dcp::CertificateChain> signer_chain () const {
return _signer_chain;
}
@@ -385,6 +409,16 @@ public:
return _default_notify;
}
+ enum Notification {
+ MESSAGE_BOX,
+ EMAIL,
+ NOTIFICATION_COUNT
+ };
+
+ bool notification (Notification n) const {
+ return _notification[n];
+ }
+
/* SET (mostly) */
void set_master_encoding_threads (int n) {
@@ -557,6 +591,32 @@ public:
void reset_kdm_email ();
+ void set_notification_subject (std::string s) {
+ maybe_set (_notification_subject, s);
+ }
+
+ void set_notification_from (std::string f) {
+ maybe_set (_notification_from, f);
+ }
+
+ void set_notification_to (std::string t) {
+ maybe_set (_notification_to, t);
+ }
+
+ void set_notification_cc (std::vector<std::string> f) {
+ maybe_set (_notification_cc, f);
+ }
+
+ void set_notification_bcc (std::string f) {
+ maybe_set (_notification_bcc, f);
+ }
+
+ void set_notification_email (std::string e) {
+ maybe_set (_notification_email, e);
+ }
+
+ void reset_notification_email ();
+
void set_signer_chain (boost::shared_ptr<const dcp::CertificateChain> s) {
maybe_set (_signer_chain, s);
}
@@ -697,6 +757,10 @@ public:
void reset_cover_sheet ();
+ void set_notification (Notification n, bool v) {
+ maybe_set (_notification[n], v);
+ }
+
void changed (Property p = OTHER);
boost::signals2::signal<void (Property)> Changed;
/** Emitted if read() failed on an existing Config file. There is nothing
@@ -738,6 +802,7 @@ private:
void read ();
void set_defaults ();
void set_kdm_email_to_default ();
+ void set_notification_email_to_default ();
void set_cover_sheet_to_default ();
void read_cinemas (cxml::Document const & f);
boost::shared_ptr<dcp::CertificateChain> create_certificate_chain ();
@@ -821,6 +886,12 @@ private:
std::vector<std::string> _kdm_cc;
std::string _kdm_bcc;
std::string _kdm_email;
+ std::string _notification_subject;
+ std::string _notification_from;
+ std::string _notification_to;
+ std::vector<std::string> _notification_cc;
+ std::string _notification_bcc;
+ std::string _notification_email;
boost::shared_ptr<const dcp::CertificateChain> _signer_chain;
/** Chain used to decrypt KDMs; the leaf of this chain is the target
* certificate for making KDMs given to DCP-o-matic.
@@ -859,6 +930,7 @@ private:
int _frames_in_memory_multiplier;
boost::optional<int> _decode_reduction;
bool _default_notify;
+ bool _notification[NOTIFICATION_COUNT];
static int const _current_version;