summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-11-13 13:07:16 +0000
committerCarl Hetherington <cth@carlh.net>2015-11-13 13:07:16 +0000
commitdf89a39cfd34d0d70609daa214d3b618bb6223bd (patch)
tree1629307cc535fc0ea8804ca935022dddf163135d /src/lib
parent43800d83434697a31bdfae62dd377cfc3900986b (diff)
Allow multiple recipients of KDM emails (#745).
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cinema.cc16
-rw-r--r--src/lib/cinema.h8
-rw-r--r--src/lib/cinema_kdms.cc2
-rw-r--r--src/lib/emailer.cc11
-rw-r--r--src/lib/emailer.h7
-rw-r--r--src/lib/send_problem_report_job.cc5
6 files changed, 31 insertions, 18 deletions
diff --git a/src/lib/cinema.cc b/src/lib/cinema.cc
index 11bc888da..ebd716009 100644
--- a/src/lib/cinema.cc
+++ b/src/lib/cinema.cc
@@ -21,15 +21,18 @@
#include "screen.h"
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
+#include <boost/foreach.hpp>
using std::list;
+using std::string;
using boost::shared_ptr;
Cinema::Cinema (cxml::ConstNodePtr node)
: name (node->string_child ("Name"))
- , email (node->string_child ("Email"))
{
-
+ BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Email")) {
+ emails.push_back (i->content ());
+ }
}
/* This is necessary so that we can use shared_from_this in add_screen (which cannot be done from
@@ -48,10 +51,13 @@ void
Cinema::as_xml (xmlpp::Element* parent) const
{
parent->add_child("Name")->add_child_text (name);
- parent->add_child("Email")->add_child_text (email);
- for (list<shared_ptr<Screen> >::const_iterator i = _screens.begin(); i != _screens.end(); ++i) {
- (*i)->as_xml (parent->add_child ("Screen"));
+ BOOST_FOREACH (string i, emails) {
+ parent->add_child("Email")->add_child_text (i);
+ }
+
+ BOOST_FOREACH (shared_ptr<Screen> i, _screens) {
+ i->as_xml (parent->add_child ("Screen"));
}
}
diff --git a/src/lib/cinema.h b/src/lib/cinema.h
index 3bf958d82..aec4c83ec 100644
--- a/src/lib/cinema.h
+++ b/src/lib/cinema.h
@@ -33,15 +33,15 @@ class Screen;
/** @class Cinema
* @brief A description of a Cinema for KDM generation.
*
- * This is a cinema name, contact email address and a list of
+ * This is a cinema name, contact email addresses and a list of
* Screen objects.
*/
class Cinema : public boost::enable_shared_from_this<Cinema>
{
public:
- Cinema (std::string const & n, std::string const & e)
+ Cinema (std::string const & n, std::list<std::string> const & e)
: name (n)
- , email (e)
+ , emails (e)
{}
Cinema (cxml::ConstNodePtr);
@@ -54,7 +54,7 @@ public:
void remove_screen (boost::shared_ptr<Screen>);
std::string name;
- std::string email;
+ std::list<std::string> emails;
std::list<boost::shared_ptr<Screen> > screens () const {
return _screens;
}
diff --git a/src/lib/cinema_kdms.cc b/src/lib/cinema_kdms.cc
index eb71b3202..15aaaa731 100644
--- a/src/lib/cinema_kdms.cc
+++ b/src/lib/cinema_kdms.cc
@@ -152,7 +152,7 @@ CinemaKDMs::email (
}
boost::algorithm::replace_all (body, "$SCREENS", screens.str().substr (0, screens.str().length() - 2));
- Emailer email (config->kdm_from(), i.cinema->email, subject, body);
+ Emailer email (config->kdm_from(), i.cinema->emails, subject, body);
if (!config->kdm_cc().empty ()) {
email.add_cc (config->kdm_cc ());
diff --git a/src/lib/emailer.cc b/src/lib/emailer.cc
index 916d17182..885171e2f 100644
--- a/src/lib/emailer.cc
+++ b/src/lib/emailer.cc
@@ -38,7 +38,7 @@ using std::cout;
using std::pair;
using boost::shared_ptr;
-Emailer::Emailer (string from, string to, string subject, string body)
+Emailer::Emailer (string from, list<string> to, string subject, string body)
: _from (from)
, _to (to)
, _subject (subject)
@@ -106,7 +106,7 @@ Emailer::send (shared_ptr<Job> job)
stringstream email;
email << "Date: " << date_buffer << "\r\n"
- << "To: " << _to << "\r\n"
+ << "To: " << address_list (_to) << "\r\n"
<< "From: " << _from << "\r\n";
if (!_cc.empty ()) {
@@ -194,7 +194,10 @@ Emailer::send (shared_ptr<Job> job)
curl_easy_setopt (curl, CURLOPT_MAIL_FROM, _from.c_str());
- struct curl_slist* recipients = curl_slist_append (0, _to.c_str());
+ struct curl_slist* recipients = 0;
+ BOOST_FOREACH (string i, _to) {
+ curl_slist_append (recipients, i.c_str());
+ }
BOOST_FOREACH (string i, _cc) {
recipients = curl_slist_append (recipients, i.c_str());
}
@@ -251,7 +254,7 @@ Emailer::send (shared_ptr<Job> job)
CURLMcode mc = curl_multi_fdset (mcurl, &fdread, &fdwrite, &fdexcep, &maxfd);
if (mc != CURLM_OK) {
- throw KDMError (String::compose ("Failed to send KDM email to %1", _to));
+ throw KDMError (String::compose ("Failed to send KDM email to %1", address_list (_to)));
}
int rc;
diff --git a/src/lib/emailer.h b/src/lib/emailer.h
index 89993ca48..c8ebac7b6 100644
--- a/src/lib/emailer.h
+++ b/src/lib/emailer.h
@@ -23,7 +23,7 @@
class Emailer
{
public:
- Emailer (std::string from, std::string to, std::string subject, std::string body);
+ Emailer (std::string from, std::list<std::string> to, std::string subject, std::string body);
void add_cc (std::string cc);
void add_bcc (std::string bcc);
@@ -38,11 +38,12 @@ public:
size_t get_data (void* ptr, size_t size, size_t nmemb);
int debug (CURL* curl, curl_infotype type, char* data, size_t size);
-private:
static std::string address_list (std::list<std::string> addresses);
+private:
+
std::string _from;
- std::string _to;
+ std::list<std::string> _to;
std::string _subject;
std::string _body;
std::list<std::string> _cc;
diff --git a/src/lib/send_problem_report_job.cc b/src/lib/send_problem_report_job.cc
index f0c34f590..8142b173c 100644
--- a/src/lib/send_problem_report_job.cc
+++ b/src/lib/send_problem_report_job.cc
@@ -81,7 +81,10 @@ SendProblemReportJob::run ()
add_file (body, "metadata.xml");
}
- Emailer emailer (_from, "carl@dcpomatic.com", "DCP-o-matic problem report", body);
+ list<string> to;
+ to.push_back ("carl@dcpomatic.com");
+
+ Emailer emailer (_from, to, "DCP-o-matic problem report", body);
emailer.send (shared_from_this ());
set_progress (1);