Merge master.
[dcpomatic.git] / src / lib / kdm.cc
index 177dec078a8bc0770f6478b762b06014e6cf651d..108860594e2592144760965a02aeb1220f8cf02c 100644 (file)
 #include <boost/shared_ptr.hpp>
 #include <quickmail.h>
 #include <zip.h>
-#include <libdcp/kdm.h>
+#include <dcp/encrypted_kdm.h>
+#include <dcp/types.h>
 #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<Screen> s, libdcp::KDM k)
+       ScreenKDM (shared_ptr<Screen> s, dcp::EncryptedKDM k)
                : screen (s)
                , kdm (k)
        {}
        
        shared_ptr<Screen> screen;
-       libdcp::KDM kdm;
+       dcp::EncryptedKDM kdm;
 };
 
 static string
@@ -104,17 +105,17 @@ make_screen_kdms (
        shared_ptr<const Film> film,
        list<shared_ptr<Screen> > screens,
        boost::filesystem::path cpl,
-       boost::posix_time::ptime from,
-       boost::posix_time::ptime to,
-       libdcp::KDM::Formulation formulation
+       dcp::LocalTime from,
+       dcp::LocalTime to,
+       dcp::Formulation formulation
        )
 {
-       list<libdcp::KDM> kdms = film->make_kdms (screens, cpl, from, to, formulation);
+       list<dcp::EncryptedKDM> kdms = film->make_kdms (screens, cpl, from, to, formulation);
           
        list<ScreenKDM> screen_kdms;
        
        list<shared_ptr<Screen> >::iterator i = screens.begin ();
-       list<libdcp::KDM>::iterator j = kdms.begin ();
+       list<dcp::EncryptedKDM>::iterator j = kdms.begin ();
        while (i != screens.end() && j != kdms.end ()) {
                screen_kdms.push_back (ScreenKDM (*i, *j));
                ++i;
@@ -129,9 +130,9 @@ make_cinema_kdms (
        shared_ptr<const Film> film,
        list<shared_ptr<Screen> > screens,
        boost::filesystem::path cpl,
-       boost::posix_time::ptime from,
-       boost::posix_time::ptime to,
-       libdcp::KDM::Formulation formulation
+       dcp::LocalTime from,
+       dcp::LocalTime to,
+       dcp::Formulation formulation
        )
 {
        list<ScreenKDM> screen_kdms = make_screen_kdms (film, screens, cpl, from, to, formulation);
@@ -175,9 +176,9 @@ write_kdm_files (
        shared_ptr<const Film> film,
        list<shared_ptr<Screen> > screens,
        boost::filesystem::path cpl,
-       boost::posix_time::ptime from,
-       boost::posix_time::ptime to,
-       libdcp::KDM::Formulation formulation,
+       dcp::LocalTime from,
+       dcp::LocalTime to,
+       dcp::Formulation formulation,
        boost::filesystem::path directory
        )
 {
@@ -196,9 +197,9 @@ write_kdm_zip_files (
        shared_ptr<const Film> film,
        list<shared_ptr<Screen> > screens,
        boost::filesystem::path cpl,
-       boost::posix_time::ptime from,
-       boost::posix_time::ptime to,
-       libdcp::KDM::Formulation formulation,
+       dcp::LocalTime from,
+       dcp::LocalTime to,
+       dcp::Formulation formulation,
        boost::filesystem::path directory
        )
 {
@@ -216,9 +217,9 @@ email_kdms (
        shared_ptr<const Film> film,
        list<shared_ptr<Screen> > screens,
        boost::filesystem::path cpl,
-       boost::posix_time::ptime from,
-       boost::posix_time::ptime to,
-       libdcp::KDM::Formulation formulation
+       dcp::LocalTime from,
+       dcp::LocalTime to,
+       dcp::Formulation formulation
        )
 {
        list<CinemaKDMs> cinema_kdms = make_cinema_kdms (film, screens, cpl, from, to, formulation);
@@ -233,9 +234,9 @@ email_kdms (
                
                quickmail_initialize ();
 
-               stringstream start;
+               SafeStringStream start;
                start << from.date() << " " << from.time_of_day();
-               stringstream end;
+               SafeStringStream end;
                end << to.date() << " " << to.time_of_day();
                
                string subject = Config::instance()->kdm_subject();
@@ -259,7 +260,7 @@ email_kdms (
                boost::algorithm::replace_all (body, "$END_TIME", end.str ());
                boost::algorithm::replace_all (body, "$CINEMA_NAME", i->cinema->name);
                
-               stringstream screens;
+               SafeStringStream screens;
                for (list<ScreenKDM>::const_iterator j = i->screen_kdms.begin(); j != i->screen_kdms.end(); ++j) {
                        screens << j->screen->name << ", ";
                }