From ac35bf2a80c9afae9dc5fcb0261929053162f44d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 21 Jul 2014 16:53:58 +0100 Subject: [PATCH] Adapt to changes in libdcp1 wrt shared_ptr and Certificate. --- src/lib/cinema.cc | 8 ++++++-- src/lib/cinema.h | 4 ++-- src/lib/config.cc | 4 ++-- src/lib/film.cc | 6 ++++-- src/lib/film.h | 2 +- src/tools/dcpomatic_kdm.cc | 2 +- src/wx/config_dialog.cc | 4 ++-- src/wx/screen_dialog.cc | 10 +++++----- src/wx/screen_dialog.h | 6 +++--- 9 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/lib/cinema.cc b/src/lib/cinema.cc index c8cb7b66c..620236186 100644 --- a/src/lib/cinema.cc +++ b/src/lib/cinema.cc @@ -70,14 +70,18 @@ Cinema::remove_screen (shared_ptr s) Screen::Screen (cxml::ConstNodePtr node) { name = node->string_child ("Name"); - certificate = shared_ptr (new dcp::Certificate (node->string_child ("Certificate"))); + if (node->optional_string_child ("Certificate")) { + certificate = dcp::Certificate (node->string_child ("Certificate")); + } } void Screen::as_xml (xmlpp::Element* parent) const { parent->add_child("Name")->add_child_text (name); - parent->add_child("Certificate")->add_child_text (certificate->certificate (true)); + if (certificate) { + parent->add_child("Certificate")->add_child_text (certificate->certificate (true)); + } } diff --git a/src/lib/cinema.h b/src/lib/cinema.h index 74357f65d..8421f4687 100644 --- a/src/lib/cinema.h +++ b/src/lib/cinema.h @@ -36,7 +36,7 @@ class Cinema; class Screen { public: - Screen (std::string const & n, boost::shared_ptr cert) + Screen (std::string const & n, boost::optional cert) : name (n) , certificate (cert) {} @@ -47,7 +47,7 @@ public: boost::shared_ptr cinema; std::string name; - boost::shared_ptr certificate; + boost::optional certificate; }; /** @class Cinema diff --git a/src/lib/config.cc b/src/lib/config.cc index 0d6a55054..1fd4792c3 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -217,7 +217,7 @@ Config::read () /* Read the signing certificates and private key in from the config file */ list certificates = signer->node_children ("Certificate"); for (list::const_iterator i = certificates.begin(); i != certificates.end(); ++i) { - signer_chain.add (shared_ptr (new dcp::Certificate ((*i)->content ()))); + signer_chain.add (dcp::Certificate ((*i)->content ())); } _signer.reset (new dcp::Signer (signer_chain, signer->string_child ("PrivateKey"))); @@ -353,7 +353,7 @@ Config::write () const xmlpp::Element* signer = root->add_child ("Signer"); dcp::CertificateChain::List certs = _signer->certificates().root_to_leaf (); for (dcp::CertificateChain::List::const_iterator i = certs.begin(); i != certs.end(); ++i) { - signer->add_child("Certificate")->add_child_text ((*i)->certificate (true)); + signer->add_child("Certificate")->add_child_text (i->certificate (true)); } signer->add_child("PrivateKey")->add_child_text (_signer->key ()); diff --git a/src/lib/film.cc b/src/lib/film.cc index 99a668e37..0de6f2ded 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1076,7 +1076,7 @@ Film::frame_size () const dcp::EncryptedKDM Film::make_kdm ( - shared_ptr target, + dcp::Certificate target, boost::filesystem::path cpl_file, dcp::LocalTime from, dcp::LocalTime until, @@ -1106,7 +1106,9 @@ Film::make_kdms ( list kdms; for (list >::iterator i = screens.begin(); i != screens.end(); ++i) { - kdms.push_back (make_kdm ((*i)->certificate, dcp, from, until, formulation)); + if ((*i)->certificate) { + kdms.push_back (make_kdm ((*i)->certificate.get(), dcp, from, until, formulation)); + } } return kdms; diff --git a/src/lib/film.h b/src/lib/film.h index dea669d98..c9b4602ad 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -121,7 +121,7 @@ public: dcp::EncryptedKDM make_kdm ( - boost::shared_ptr target, + dcp::Certificate target, boost::filesystem::path cpl_file, dcp::LocalTime from, dcp::LocalTime until, diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 4068dc51a..7d8841304 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -248,7 +248,7 @@ int main (int argc, char* argv[]) error ("you must specify --output"); } - shared_ptr certificate (new dcp::Certificate (dcp::file_to_string (certificate_file))); + dcp::Certificate certificate (dcp::file_to_string (certificate_file)); dcp::EncryptedKDM kdm = film->make_kdm (certificate, cpl, valid_from.get(), valid_to.get(), formulation); kdm.as_xml (output); if (verbose) { diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 3775ae1bb..d7d2ad349 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -690,7 +690,7 @@ private: if (d->ShowModal() == wxID_OK) { try { - shared_ptr c (new dcp::Certificate (dcp::file_to_string (wx_to_std (d->GetPath ())))); + dcp::Certificate c (dcp::file_to_string (wx_to_std (d->GetPath ()))); _signer->certificates().add (c); Config::instance()->set_signer (_signer); update_certificate_list (); @@ -727,7 +727,7 @@ private: wxListItem item; item.SetId (n); _certificates->InsertItem (item); - _certificates->SetItem (n, 1, std_to_wx ((*i)->thumbprint ())); + _certificates->SetItem (n, 1, std_to_wx (i->thumbprint ())); if (n == 0) { _certificates->SetItem (n, 0, _("Root")); diff --git a/src/wx/screen_dialog.cc b/src/wx/screen_dialog.cc index 10650263b..503745683 100644 --- a/src/wx/screen_dialog.cc +++ b/src/wx/screen_dialog.cc @@ -29,9 +29,9 @@ using std::string; using std::cout; -using boost::shared_ptr; +using boost::optional; -ScreenDialog::ScreenDialog (wxWindow* parent, string title, string name, shared_ptr certificate) +ScreenDialog::ScreenDialog (wxWindow* parent, string title, string name, optional certificate) : TableDialog (parent, std_to_wx (title), 2, true) , _certificate (certificate) { @@ -79,7 +79,7 @@ ScreenDialog::name () const return wx_to_std (_name->GetValue()); } -shared_ptr +optional ScreenDialog::certificate () const { return _certificate; @@ -89,7 +89,7 @@ void ScreenDialog::load_certificate (boost::filesystem::path file) { try { - _certificate.reset (new dcp::Certificate (dcp::file_to_string (file))); + _certificate = dcp::Certificate (dcp::file_to_string (file)); _certificate_text->SetValue (_certificate->certificate ()); } catch (dcp::MiscError& e) { error_dialog (this, wxString::Format (_("Could not read certificate file (%s)"), e.what())); @@ -128,7 +128,7 @@ void ScreenDialog::setup_sensitivity () { wxButton* ok = dynamic_cast (FindWindowById (wxID_OK, this)); - ok->Enable (_certificate.get ()); + ok->Enable (_certificate); _download_certificate->Enable ( _manufacturer->GetStringSelection() == _("Doremi") || diff --git a/src/wx/screen_dialog.h b/src/wx/screen_dialog.h index 5c6d964b8..3e110d230 100644 --- a/src/wx/screen_dialog.h +++ b/src/wx/screen_dialog.h @@ -27,10 +27,10 @@ class Progress; class ScreenDialog : public TableDialog { public: - ScreenDialog (wxWindow *, std::string, std::string name = "", boost::shared_ptr c = boost::shared_ptr ()); + ScreenDialog (wxWindow *, std::string, std::string name = "", boost::optional c = boost::optional ()); std::string name () const; - boost::shared_ptr certificate () const; + boost::optional certificate () const; private: void select_certificate (); @@ -44,5 +44,5 @@ private: wxButton* _download_certificate; wxTextCtrl* _certificate_text; - boost::shared_ptr _certificate; + boost::optional _certificate; }; -- 2.30.2