diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-10-07 12:25:47 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-10-09 13:44:54 +0100 |
| commit | 7f8fb87610ca3f4106b925a314301c84ed380232 (patch) | |
| tree | acd72014d0274f0dfcfdd0ab9f6c3b525678fdf2 /src/lib | |
| parent | 9d63be286e8bc09dd1cf8deea5c58dda0a534c1e (diff) | |
Remove use of Film in KDM stuff.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/cinema_kdms.cc | 20 | ||||
| -rw-r--r-- | src/lib/cinema_kdms.h | 6 | ||||
| -rw-r--r-- | src/lib/screen_kdm.cc | 10 | ||||
| -rw-r--r-- | src/lib/screen_kdm.h | 5 | ||||
| -rw-r--r-- | src/lib/send_kdm_email_job.cc | 3 |
5 files changed, 23 insertions, 21 deletions
diff --git a/src/lib/cinema_kdms.cc b/src/lib/cinema_kdms.cc index aa701cafa..d7190b54d 100644 --- a/src/lib/cinema_kdms.cc +++ b/src/lib/cinema_kdms.cc @@ -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); diff --git a/src/lib/cinema_kdms.h b/src/lib/cinema_kdms.h index 2a75bfa9f..d0f703280 100644 --- a/src/lib/cinema_kdms.h +++ b/src/lib/cinema_kdms.h @@ -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; diff --git a/src/lib/screen_kdm.cc b/src/lib/screen_kdm.cc index c29512696..60a81399d 100644 --- a/src/lib/screen_kdm.cc +++ b/src/lib/screen_kdm.cc @@ -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); } } diff --git a/src/lib/screen_kdm.h b/src/lib/screen_kdm.h index c2928114f..e2a16d3b7 100644 --- a/src/lib/screen_kdm.h +++ b/src/lib/screen_kdm.h @@ -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; diff --git a/src/lib/send_kdm_email_job.cc b/src/lib/send_kdm_email_job.cc index 0342acd53..9ac596692 100644 --- a/src/lib/send_kdm_email_job.cc +++ b/src/lib/send_kdm_email_job.cc @@ -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 |
