Adapt to changes in libdcp1 wrt shared_ptr and Certificate.
authorCarl Hetherington <cth@carlh.net>
Mon, 21 Jul 2014 15:53:58 +0000 (16:53 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 21 Jul 2014 15:53:58 +0000 (16:53 +0100)
src/lib/cinema.cc
src/lib/cinema.h
src/lib/config.cc
src/lib/film.cc
src/lib/film.h
src/tools/dcpomatic_kdm.cc
src/wx/config_dialog.cc
src/wx/screen_dialog.cc
src/wx/screen_dialog.h

index c8cb7b66cc935be866e8049b3a489971fd2712bc..62023618676a6f83de20bfde5f6be6acd651e1b7 100644 (file)
@@ -70,14 +70,18 @@ Cinema::remove_screen (shared_ptr<Screen> s)
 Screen::Screen (cxml::ConstNodePtr node)
 {
        name = node->string_child ("Name");
-       certificate = shared_ptr<dcp::Certificate> (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));
+       }
 }
 
                
index 74357f65d687e0261ded537e94b3b4f95afcfdb2..8421f468751f72548560c9705f27cefa9bb8fcaa 100644 (file)
@@ -36,7 +36,7 @@ class Cinema;
 class Screen
 {
 public:
-       Screen (std::string const & n, boost::shared_ptr<dcp::Certificate> cert)
+       Screen (std::string const & n, boost::optional<dcp::Certificate> cert)
                : name (n)
                , certificate (cert)
        {}
@@ -47,7 +47,7 @@ public:
        
        boost::shared_ptr<Cinema> cinema;
        std::string name;
-       boost::shared_ptr<dcp::Certificate> certificate;
+       boost::optional<dcp::Certificate> certificate;
 };
 
 /** @class Cinema
index 0d6a550549bf544ddc0c6d73a879116cc6265d0d..1fd4792c3bbf80f6d721a190264f4479b7659793 100644 (file)
@@ -217,7 +217,7 @@ Config::read ()
                /* Read the signing certificates and private key in from the config file */
                list<cxml::NodePtr> certificates = signer->node_children ("Certificate");
                for (list<cxml::NodePtr>::const_iterator i = certificates.begin(); i != certificates.end(); ++i) {
-                       signer_chain.add (shared_ptr<dcp::Certificate> (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 ());
 
index 99a668e373b2567a9ac24151fb91db13d3266f5f..0de6f2ded75e9cbf0ae1ad8782b830e968e38d19 100644 (file)
@@ -1076,7 +1076,7 @@ Film::frame_size () const
 
 dcp::EncryptedKDM
 Film::make_kdm (
-       shared_ptr<dcp::Certificate> target,
+       dcp::Certificate target,
        boost::filesystem::path cpl_file,
        dcp::LocalTime from,
        dcp::LocalTime until,
@@ -1106,7 +1106,9 @@ Film::make_kdms (
        list<dcp::EncryptedKDM> kdms;
 
        for (list<shared_ptr<Screen> >::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;
index dea669d981f9088faa6b223ad7ccbc7ffe785f3e..c9b4602ad52b9329c5524dab3e06dd7a95c89f99 100644 (file)
@@ -121,7 +121,7 @@ public:
 
        dcp::EncryptedKDM
        make_kdm (
-               boost::shared_ptr<dcp::Certificate> target,
+               dcp::Certificate target,
                boost::filesystem::path cpl_file,
                dcp::LocalTime from,
                dcp::LocalTime until,
index 4068dc51a0b833449e92b40d1f1e876d885180d8..7d88413041ac1b653f20767a8629ba10c6232add 100644 (file)
@@ -248,7 +248,7 @@ int main (int argc, char* argv[])
                        error ("you must specify --output");
                }
                
-               shared_ptr<dcp::Certificate> 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) {
index 3775ae1bbd57fd9fc0cce79a3b0f3119cedda3c6..d7d2ad34966741c7e4a33ad2420e4f1ac5114404 100644 (file)
@@ -690,7 +690,7 @@ private:
                
                if (d->ShowModal() == wxID_OK) {
                        try {
-                               shared_ptr<dcp::Certificate> 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"));
index 10650263b1a929cfb418e52dd463657baa08a86c..503745683980f3b2a860ec09050c2b80bba01a84 100644 (file)
@@ -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<dcp::Certificate> certificate)
+ScreenDialog::ScreenDialog (wxWindow* parent, string title, string name, optional<dcp::Certificate> 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<dcp::Certificate>
+optional<dcp::Certificate>
 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<wxButton*> (FindWindowById (wxID_OK, this));
-       ok->Enable (_certificate.get ());
+       ok->Enable (_certificate);
 
        _download_certificate->Enable (
                _manufacturer->GetStringSelection() == _("Doremi") ||
index 5c6d964b8297681405d501543c14843f463d5253..3e110d230bb4c48bfa6e9fe16e8de939c12efb33 100644 (file)
@@ -27,10 +27,10 @@ class Progress;
 class ScreenDialog : public TableDialog
 {
 public:
-       ScreenDialog (wxWindow *, std::string, std::string name = "", boost::shared_ptr<dcp::Certificate> c = boost::shared_ptr<dcp::Certificate> ());
+       ScreenDialog (wxWindow *, std::string, std::string name = "", boost::optional<dcp::Certificate> c = boost::optional<dcp::Certificate> ());
 
        std::string name () const;
-       boost::shared_ptr<dcp::Certificate> certificate () const;
+       boost::optional<dcp::Certificate> certificate () const;
        
 private:
        void select_certificate ();
@@ -44,5 +44,5 @@ private:
        wxButton* _download_certificate;
        wxTextCtrl* _certificate_text;
 
-       boost::shared_ptr<dcp::Certificate> _certificate;
+       boost::optional<dcp::Certificate> _certificate;
 };