Fix libdcp API changes; fix failure to reload cinema/screen configuration.
authorCarl Hetherington <cth@carlh.net>
Tue, 24 Sep 2013 21:55:17 +0000 (22:55 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 24 Sep 2013 21:55:17 +0000 (22:55 +0100)
src/lib/cinema.cc
src/lib/cinema.h
src/lib/config.cc
src/lib/film.cc

index 7af4372f59981fe2b444a0286a829abf8bc88164..eccd46b8434bd5c19ff107acfc915ec2c64cafe2 100644 (file)
@@ -25,10 +25,18 @@ using std::list;
 using boost::shared_ptr;
 
 Cinema::Cinema (shared_ptr<const cxml::Node> 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<const cxml::Node> node)
+{
        list<shared_ptr<cxml::Node> > s = node->node_children ("Screen");
        for (list<shared_ptr<cxml::Node> >::iterator i = s.begin(); i != s.end(); ++i) {
                add_screen (shared_ptr<Screen> (new Screen (*i)));
index 251bb5d6131e3869d12f7cecfb5b92358a2d1db2..40dc15ae02ebaf66decb9f837ce845b5d40dcc99 100644 (file)
@@ -53,6 +53,8 @@ public:
 
        Cinema (boost::shared_ptr<const cxml::Node>);
 
+       void read_screens (boost::shared_ptr<const cxml::Node>);
+
        void as_xml (xmlpp::Element *) const;
 
        void add_screen (boost::shared_ptr<Screen>);
index a72e1a9e43fa9c91bd9fb6919c542e357ca04450..9d2d9d1bf311284cf28fe61e74a0b7f6b813ee15 100644 (file)
@@ -132,7 +132,12 @@ Config::read ()
 
        list<shared_ptr<cxml::Node> > cin = f.node_children ("Cinema");
        for (list<shared_ptr<cxml::Node> >::iterator i = cin.begin(); i != cin.end(); ++i) {
-               _cinemas.push_back (shared_ptr<Cinema> (new Cinema (*i)));
+               /* Slightly grotty two-part construction of Cinema here so that we can use
+                  shared_from_this.
+               */
+               shared_ptr<Cinema> cinema (new Cinema (*i));
+               cinema->read_screens (*i);
+               _cinemas.push_back (cinema);
        }
 }
 
index 07af46d97c99a36782e51824cce20f6bfde46f7d..069be9b98b533224fae271b6934615a3b66d9cfc 100644 (file)
@@ -34,6 +34,8 @@
 #include <libdcp/signer_chain.h>
 #include <libdcp/cpl.h>
 #include <libdcp/signer.h>
+#include <libdcp/util.h>
+#include <libdcp/kdm.h>
 #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<xmlpp::Document> 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);
        }
 }