X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fkdm.cc;h=108860594e2592144760965a02aeb1220f8cf02c;hb=c6c082c4a8016f85ba4207f4b8ccee1d5770e4a4;hp=2a8e191e7e24719f3031e5c75ffb0e539a805c4b;hpb=e3b80115077e5c473df008fe2345420a547df1d2;p=dcpomatic.git diff --git a/src/lib/kdm.cc b/src/lib/kdm.cc index 2a8e191e7..108860594 100644 --- a/src/lib/kdm.cc +++ b/src/lib/kdm.cc @@ -21,28 +21,30 @@ #include #include #include -#include +#include +#include #include "kdm.h" #include "cinema.h" #include "exceptions.h" #include "util.h" #include "film.h" #include "config.h" +#include "safe_stringstream.h" using std::list; using std::string; -using std::stringstream; +using std::cout; using boost::shared_ptr; struct ScreenKDM { - ScreenKDM (shared_ptr s, libdcp::KDM k) + ScreenKDM (shared_ptr s, dcp::EncryptedKDM k) : screen (s) , kdm (k) {} shared_ptr screen; - libdcp::KDM kdm; + dcp::EncryptedKDM kdm; }; static string @@ -102,17 +104,18 @@ static list make_screen_kdms ( shared_ptr film, list > screens, - boost::filesystem::path dcp, - boost::posix_time::ptime from, - boost::posix_time::ptime to + boost::filesystem::path cpl, + dcp::LocalTime from, + dcp::LocalTime to, + dcp::Formulation formulation ) { - list kdms = film->make_kdms (screens, dcp, from, to); + list kdms = film->make_kdms (screens, cpl, from, to, formulation); list screen_kdms; list >::iterator i = screens.begin (); - list::iterator j = kdms.begin (); + list::iterator j = kdms.begin (); while (i != screens.end() && j != kdms.end ()) { screen_kdms.push_back (ScreenKDM (*i, *j)); ++i; @@ -126,12 +129,13 @@ static list make_cinema_kdms ( shared_ptr film, list > screens, - boost::filesystem::path dcp, - boost::posix_time::ptime from, - boost::posix_time::ptime to + boost::filesystem::path cpl, + dcp::LocalTime from, + dcp::LocalTime to, + dcp::Formulation formulation ) { - list screen_kdms = make_screen_kdms (film, screens, dcp, from, to); + list screen_kdms = make_screen_kdms (film, screens, cpl, from, to, formulation); list cinema_kdms; while (!screen_kdms.empty ()) { @@ -171,13 +175,14 @@ void write_kdm_files ( shared_ptr film, list > screens, - boost::filesystem::path dcp, - boost::posix_time::ptime from, - boost::posix_time::ptime to, + boost::filesystem::path cpl, + dcp::LocalTime from, + dcp::LocalTime to, + dcp::Formulation formulation, boost::filesystem::path directory ) { - list screen_kdms = make_screen_kdms (film, screens, dcp, from, to); + list screen_kdms = make_screen_kdms (film, screens, cpl, from, to, formulation); /* Write KDMs to the specified directory */ for (list::iterator i = screen_kdms.begin(); i != screen_kdms.end(); ++i) { @@ -191,13 +196,14 @@ void write_kdm_zip_files ( shared_ptr film, list > screens, - boost::filesystem::path dcp, - boost::posix_time::ptime from, - boost::posix_time::ptime to, + boost::filesystem::path cpl, + dcp::LocalTime from, + dcp::LocalTime to, + dcp::Formulation formulation, boost::filesystem::path directory ) { - list cinema_kdms = make_cinema_kdms (film, screens, dcp, from, to); + list cinema_kdms = make_cinema_kdms (film, screens, cpl, from, to, formulation); for (list::const_iterator i = cinema_kdms.begin(); i != cinema_kdms.end(); ++i) { boost::filesystem::path path = directory; @@ -210,12 +216,13 @@ void email_kdms ( shared_ptr film, list > screens, - boost::filesystem::path dcp, - boost::posix_time::ptime from, - boost::posix_time::ptime to + boost::filesystem::path cpl, + dcp::LocalTime from, + dcp::LocalTime to, + dcp::Formulation formulation ) { - list cinema_kdms = make_cinema_kdms (film, screens, dcp, from, to); + list cinema_kdms = make_cinema_kdms (film, screens, cpl, from, to, formulation); for (list::const_iterator i = cinema_kdms.begin(); i != cinema_kdms.end(); ++i) { @@ -226,17 +233,38 @@ email_kdms ( /* Send email */ quickmail_initialize (); - quickmail mail = quickmail_create (Config::instance()->kdm_from().c_str(), "KDM delivery"); + + SafeStringStream start; + start << from.date() << " " << from.time_of_day(); + SafeStringStream end; + end << to.date() << " " << to.time_of_day(); + + string subject = Config::instance()->kdm_subject(); + boost::algorithm::replace_all (subject, "$CPL_NAME", film->dcp_name ()); + boost::algorithm::replace_all (subject, "$START_TIME", start.str ()); + boost::algorithm::replace_all (subject, "$END_TIME", end.str ()); + boost::algorithm::replace_all (subject, "$CINEMA_NAME", i->cinema->name); + quickmail mail = quickmail_create (Config::instance()->kdm_from().c_str(), subject.c_str ()); + 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 ()); + } + if (!Config::instance()->kdm_bcc().empty ()) { + quickmail_add_bcc (mail, Config::instance()->kdm_bcc().c_str ()); + } string body = Config::instance()->kdm_email().c_str(); boost::algorithm::replace_all (body, "$CPL_NAME", film->dcp_name ()); - stringstream start; - start << from.date() << " " << from.time_of_day(); boost::algorithm::replace_all (body, "$START_TIME", start.str ()); - 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); + + SafeStringStream screens; + for (list::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");