#include "screen.h"
#include "config.h"
#include "util.h"
-#include "film.h"
#include "compose.hpp"
#include <zip.h>
#include <boost/foreach.hpp>
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);
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");
}
}
}
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 */
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);
}
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);
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;
#include "screen_kdm.h"
#include "cinema.h"
#include "screen.h"
-#include "film.h"
#include "util.h"
#include <boost/foreach.hpp>
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);
}
}