Remove use of Film in KDM stuff.
authorCarl Hetherington <cth@carlh.net>
Wed, 7 Oct 2015 11:25:47 +0000 (12:25 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 9 Oct 2015 12:44:54 +0000 (13:44 +0100)
src/lib/cinema_kdms.cc
src/lib/cinema_kdms.h
src/lib/screen_kdm.cc
src/lib/screen_kdm.h
src/lib/send_kdm_email_job.cc
src/tools/dcpomatic.cc
src/tools/dcpomatic_kdm_cli.cc

index aa701cafa75dbfbee86f99853dab5858e21d7b54..d7190b54d917be687cf87a18b124f6616b8bb6df 100644 (file)
@@ -24,7 +24,6 @@
 #include "screen.h"
 #include "config.h"
 #include "util.h"
-#include "film.h"
 #include "compose.hpp"
 #include <zip.h>
 #include <boost/foreach.hpp>
@@ -33,8 +32,11 @@ using std::list;
 using std::string;
 using boost::shared_ptr;
 
+/** @param filename_first_part First part of name of KDM files inside the zip file
+ *  (perhaps the name of the film).
+ */
 void
-CinemaKDMs::make_zip_file (shared_ptr<const Film> film, boost::filesystem::path zip_file) const
+CinemaKDMs::make_zip_file (string filename_first_part, boost::filesystem::path zip_file) const
 {
        int error;
        struct zip* zip = zip_open (zip_file.string().c_str(), ZIP_CREATE | ZIP_EXCL, &error);
@@ -56,7 +58,7 @@ CinemaKDMs::make_zip_file (shared_ptr<const Film> film, boost::filesystem::path
                        throw StringError ("could not create ZIP source");
                }
 
-               if (zip_add (zip, i.filename(film).c_str(), source) == -1) {
+               if (zip_add (zip, i.filename(filename_first_part).c_str(), source) == -1) {
                        throw StringError ("failed to add KDM to ZIP archive");
                }
        }
@@ -102,24 +104,24 @@ CinemaKDMs::collect (list<ScreenKDM> screen_kdms)
 }
 
 void
-CinemaKDMs::write_zip_files (shared_ptr<const Film> film, list<CinemaKDMs> cinema_kdms, boost::filesystem::path directory)
+CinemaKDMs::write_zip_files (string filename_first_part, list<CinemaKDMs> cinema_kdms, boost::filesystem::path directory)
 {
        BOOST_FOREACH (CinemaKDMs const & i, cinema_kdms) {
                boost::filesystem::path path = directory;
                path /= tidy_for_filename (i.cinema->name) + ".zip";
-               i.make_zip_file (film, path);
+               i.make_zip_file (filename_first_part, path);
        }
 }
 
 /* XXX: should probably get from/to from the KDMs themselves */
 void
-CinemaKDMs::email (shared_ptr<const Film> film, list<CinemaKDMs> cinema_kdms, dcp::LocalTime from, dcp::LocalTime to)
+CinemaKDMs::email (string filename_first_part, string cpl_name, list<CinemaKDMs> cinema_kdms, dcp::LocalTime from, dcp::LocalTime to)
 {
        BOOST_FOREACH (CinemaKDMs const & i, cinema_kdms) {
 
                boost::filesystem::path zip_file = boost::filesystem::temp_directory_path ();
                zip_file /= boost::filesystem::unique_path().string() + ".zip";
-               i.make_zip_file (film, zip_file);
+               i.make_zip_file (filename_first_part, zip_file);
 
                /* Send email */
 
@@ -131,7 +133,7 @@ CinemaKDMs::email (shared_ptr<const Film> film, list<CinemaKDMs> cinema_kdms, dc
                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, "$CPL_NAME", cpl_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);
@@ -146,7 +148,7 @@ CinemaKDMs::email (shared_ptr<const Film> film, list<CinemaKDMs> cinema_kdms, dc
                }
 
                string body = Config::instance()->kdm_email().c_str();
-               boost::algorithm::replace_all (body, "$CPL_NAME", film->dcp_name ());
+               boost::algorithm::replace_all (body, "$CPL_NAME", cpl_name);
                boost::algorithm::replace_all (body, "$START_TIME", start.str ());
                boost::algorithm::replace_all (body, "$END_TIME", end.str ());
                boost::algorithm::replace_all (body, "$CINEMA_NAME", i.cinema->name);
index 2a75bfa9fe809fd8c02436e533eb9af8c8b87c07..d0f70328078c2c2dd22b4d8e1e1ed168855edf54 100644 (file)
@@ -24,11 +24,11 @@ class Cinema;
 class CinemaKDMs
 {
 public:
-       void make_zip_file (boost::shared_ptr<const Film> film, boost::filesystem::path zip_file) const;
+       void make_zip_file (std::string name_first_part, boost::filesystem::path zip_file) const;
 
        static std::list<CinemaKDMs> collect (std::list<ScreenKDM> kdms);
-       static void write_zip_files (boost::shared_ptr<const Film> film, std::list<CinemaKDMs> cinema_kdms, boost::filesystem::path directory);
-       static void email (boost::shared_ptr<const Film> film, std::list<CinemaKDMs> cinema_kdms, dcp::LocalTime from, dcp::LocalTime to);
+       static void write_zip_files (std::string filename_first_part, std::list<CinemaKDMs> cinema_kdms, boost::filesystem::path directory);
+       static void email (std::string filename_first_part, std::string cpl_name, std::list<CinemaKDMs> cinema_kdms, dcp::LocalTime from, dcp::LocalTime to);
 
        boost::shared_ptr<Cinema> cinema;
        std::list<ScreenKDM> screen_kdms;
index c295126966c66f2d1f3010ab59df3bd44d26b92b..60a81399d3c79c0714e393230bbf0137ec07d845 100644 (file)
@@ -20,7 +20,6 @@
 #include "screen_kdm.h"
 #include "cinema.h"
 #include "screen.h"
-#include "film.h"
 #include "util.h"
 #include <boost/foreach.hpp>
 
@@ -34,18 +33,19 @@ operator== (ScreenKDM const & a, ScreenKDM const & b)
        return a.screen == b.screen && a.kdm == b.kdm;
 }
 
+/** @param first_part first part of the filename (perhaps the name of the film) */
 string
-ScreenKDM::filename (shared_ptr<const Film> film) const
+ScreenKDM::filename (string first_part) const
 {
-       return tidy_for_filename (film->name()) + "_" + tidy_for_filename (screen->cinema->name) + "_" + tidy_for_filename (screen->name) + ".kdm.xml";
+       return tidy_for_filename (first_part) + "_" + tidy_for_filename (screen->cinema->name) + "_" + tidy_for_filename (screen->name) + ".kdm.xml";
 }
 
 void
-ScreenKDM::write_files (shared_ptr<const Film> film, list<ScreenKDM> screen_kdms, boost::filesystem::path directory)
+ScreenKDM::write_files (string name_first_part, list<ScreenKDM> screen_kdms, boost::filesystem::path directory)
 {
        /* Write KDMs to the specified directory */
        BOOST_FOREACH (ScreenKDM const & i, screen_kdms) {
-               boost::filesystem::path out = directory / i.filename(film);
+               boost::filesystem::path out = directory / i.filename(name_first_part);
                i.kdm.as_xml (out);
        }
 }
index c2928114f649838a04c21ce1115e33c8a8ae3db1..e2a16d3b726cc4501082909c5c71e044d0939743 100644 (file)
@@ -24,7 +24,6 @@
 #include <boost/shared_ptr.hpp>
 
 class Screen;
-class Film;
 
 /** Simple class to collect a screen and an encrypted KDM */
 class ScreenKDM
@@ -35,9 +34,9 @@ public:
                , kdm (k)
        {}
 
-       std::string filename (boost::shared_ptr<const Film> film) const;
+       std::string filename (std::string first_part) const;
 
-       static void write_files (boost::shared_ptr<const Film> film, std::list<ScreenKDM> screen_kdms, boost::filesystem::path directory);
+       static void write_files (std::string name_first_part, std::list<ScreenKDM> screen_kdms, boost::filesystem::path directory);
 
        boost::shared_ptr<Screen> screen;
        dcp::EncryptedKDM kdm;
index 0342acd53105ed50e0948085fb7a27cf9851fd55..9ac5966927b9ed6caccbc3052d7039d14dcbed1b 100644 (file)
@@ -66,7 +66,8 @@ SendKDMEmailJob::run ()
                set_progress_unknown ();
 
                CinemaKDMs::email (
-                       _film,
+                       _film->name(),
+                       _film->dcp_name(),
                        CinemaKDMs::collect (_film->make_kdms (_screens, _cpl, _from, _to, _formulation)),
                        _from,
                        _to
index 36817eb530496473c2861d6ca301f6f3590441a9..c646942cb3313dfc52182a6ea58d86d2979a399d 100644 (file)
@@ -447,7 +447,7 @@ private:
                try {
                        if (d->write_to ()) {
                                ScreenKDM::write_files (
-                                       _film,
+                                       _film->name(),
                                        _film->make_kdms (d->screens(), d->cpl(), d->from(), d->until(), d->formulation()),
                                        d->directory()
                                        );
index 713db3ce558e4982740b01ca43ef6cda47bb1a98..aa3022c30a5c205edb037732b62befc9ee108f46 100644 (file)
@@ -282,13 +282,13 @@ int main (int argc, char* argv[])
                                );
 
                        if (zip) {
-                               CinemaKDMs::write_zip_files (film, CinemaKDMs::collect (screen_kdms), output);
+                               CinemaKDMs::write_zip_files (film->name(), CinemaKDMs::collect (screen_kdms), output);
 
                                if (verbose) {
                                        cout << "Wrote ZIP files to " << output << "\n";
                                }
                        } else {
-                               ScreenKDM::write_files (film, screen_kdms, output);
+                               ScreenKDM::write_files (film->name(), screen_kdms, output);
 
                                if (verbose) {
                                        cout << "Wrote KDM files to " << output << "\n";