From 07cab16dec83785163e09d668e10692cd8abed0d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 24 Sep 2013 22:55:17 +0100 Subject: [PATCH] Fix libdcp API changes; fix failure to reload cinema/screen configuration. --- src/lib/cinema.cc | 12 ++++++++++-- src/lib/cinema.h | 2 ++ src/lib/config.cc | 7 ++++++- src/lib/film.cc | 12 +++++++++--- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/lib/cinema.cc b/src/lib/cinema.cc index 7af4372f5..eccd46b84 100644 --- a/src/lib/cinema.cc +++ b/src/lib/cinema.cc @@ -25,10 +25,18 @@ using std::list; using boost::shared_ptr; Cinema::Cinema (shared_ptr node) + : name (node->string_child ("Name")) + , email (node->string_child ("Email")) { - name = node->string_child ("Name"); - email = node->string_child ("Email"); +} + +/* This is necessary so that we can use shared_from_this in add_screen (which cannot be done from + a constructor) +*/ +void +Cinema::read_screens (shared_ptr node) +{ list > s = node->node_children ("Screen"); for (list >::iterator i = s.begin(); i != s.end(); ++i) { add_screen (shared_ptr (new Screen (*i))); diff --git a/src/lib/cinema.h b/src/lib/cinema.h index 251bb5d61..40dc15ae0 100644 --- a/src/lib/cinema.h +++ b/src/lib/cinema.h @@ -53,6 +53,8 @@ public: Cinema (boost::shared_ptr); + void read_screens (boost::shared_ptr); + void as_xml (xmlpp::Element *) const; void add_screen (boost::shared_ptr); diff --git a/src/lib/config.cc b/src/lib/config.cc index a72e1a9e4..9d2d9d1bf 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -132,7 +132,12 @@ Config::read () list > cin = f.node_children ("Cinema"); for (list >::iterator i = cin.begin(); i != cin.end(); ++i) { - _cinemas.push_back (shared_ptr (new Cinema (*i))); + /* Slightly grotty two-part construction of Cinema here so that we can use + shared_from_this. + */ + shared_ptr cinema (new Cinema (*i)); + cinema->read_screens (*i); + _cinemas.push_back (cinema); } } diff --git a/src/lib/film.cc b/src/lib/film.cc index 07af46d97..069be9b98 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include "film.h" #include "job.h" #include "util.h" @@ -955,14 +957,18 @@ Film::make_kdms ( } catch (...) { throw KDMError (_("Could not read DCP to make KDM for")); } + + time_t now = time (0); + struct tm* tm = localtime (&now); + string const issue_date = libdcp::tm_to_string (tm); - shared_ptr kdm = dcp.cpls().front()->make_kdm ( - signer, (*i)->certificate, key (), from, until, _interop, libdcp::MXFMetadata (), Config::instance()->dcp_metadata () + libdcp::KDM kdm ( + dcp.cpls().front(), signer, (*i)->certificate, from, until, "DCP-o-matic", issue_date ); boost::filesystem::path out = directory; out /= tidy_for_filename ((*i)->cinema->name) + "_" + tidy_for_filename ((*i)->name) + ".kdm.xml"; - kdm->write_to_file_formatted (out.string()); + kdm.as_xml (out); } } -- 2.30.2