Some boost::filesystem::path cleanups; tweak for changes to libdcp.
authorCarl Hetherington <cth@carlh.net>
Thu, 19 Sep 2013 14:07:03 +0000 (15:07 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 19 Sep 2013 14:07:03 +0000 (15:07 +0100)
doc/manual/dcpomatic.xml
src/lib/config.cc
src/lib/config.h
src/lib/film.cc
src/lib/writer.cc
src/wx/config_dialog.cc
src/wx/new_film_dialog.cc
src/wx/new_film_dialog.h

index 7d40324e05fd4083533da9d308b89d080f6fd0bf..e91863a4858a5235b5b656419d789416c02108b4 100644 (file)
@@ -949,6 +949,18 @@ most situations.
 
 </chapter>
 
+<chapter xml:id="ch-encryption" xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="en">
+<title>Encryption</title>
+
+<para>
+It is not required that DCPs be encrypted, but they can be.  This
+chapter describes how DCPs are signed and encrypted, and how KDMs
+work.  It also discusses how DCP-o-matic can create encrypted DCPs and
+KDMs for them.
+</para>
+
+</chapter>
+
 
 <chapter xml:id="ch-preferences" xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="en">
 <title>Preferences</title>
index 5b96d108ccdfdd51a9d08595eb1e6c0c9b9d710b..7d945c8979e904a0db44953f8110fefd68645c6a 100644 (file)
@@ -193,7 +193,7 @@ Config::read_old_metadata ()
 }
 
 /** @return Filename to write configuration to */
-string
+boost::filesystem::path
 Config::file (bool old) const
 {
        boost::filesystem::path p;
@@ -205,18 +205,18 @@ Config::file (bool old) const
        } else {
                p /= "dcpomatic.xml";
        }
-       return p.string ();
+       return p;
 }
 
-string
-Config::crypt_chain_directory () const
+boost::filesystem::path
+Config::signer_chain_directory () const
 {
        boost::filesystem::path p;
        p /= g_get_user_config_dir ();
        p /= "dvdomatic";
        p /= "crypt";
        boost::filesystem::create_directories (p);
-       return p.string ();
+       return p;
 }
 
 /** @return Singleton instance */
@@ -245,7 +245,7 @@ Config::write () const
        xmlpp::Element* root = doc.create_root_node ("Config");
 
        root->add_child("NumLocalEncodingThreads")->add_child_text (lexical_cast<string> (_num_local_encoding_threads));
-       root->add_child("DefaultDirectory")->add_child_text (_default_directory);
+       root->add_child("DefaultDirectory")->add_child_text (_default_directory.string ());
        root->add_child("ServerPort")->add_child_text (lexical_cast<string> (_server_port));
        
        for (vector<ServerDescription>::const_iterator i = _servers.begin(); i != _servers.end(); ++i) {
@@ -280,11 +280,11 @@ Config::write () const
                i->as_xml (root->add_child ("ColourConversion"));
        }
 
-       doc.write_to_file_formatted (file (false));
+       doc.write_to_file_formatted (file(false).string ());
 }
 
-string
-Config::default_directory_or (string a) const
+boost::filesystem::path
+Config::default_directory_or (boost::filesystem::path a) const
 {
        if (_default_directory.empty() || !boost::filesystem::exists (_default_directory)) {
                return a;
index 48eabd54ca3dc33b6f395f34c8981256413ce9f0..8c80f96799a202d52a9b83e0e9d5fa83c3603439 100644 (file)
@@ -27,6 +27,7 @@
 #include <vector>
 #include <boost/shared_ptr.hpp>
 #include <boost/signals2.hpp>
+#include <boost/filesystem.hpp>
 #include <libdcp/metadata.h>
 #include "dci_metadata.h"
 #include "colour_conversion.h"
@@ -52,11 +53,11 @@ public:
                return _num_local_encoding_threads;
        }
 
-       std::string default_directory () const {
+       boost::filesystem::path default_directory () const {
                return _default_directory;
        }
 
-       std::string default_directory_or (std::string a) const;
+       boost::filesystem::path default_directory_or (boost::filesystem::path a) const;
 
        /** @return port to use for J2K encoding servers */
        int server_port () const {
@@ -138,7 +139,7 @@ public:
                _num_local_encoding_threads = n;
        }
 
-       void set_default_directory (std::string d) {
+       void set_default_directory (boost::filesystem::path d) {
                _default_directory = d;
        }
 
@@ -230,21 +231,21 @@ public:
        
        void write () const;
 
-       std::string crypt_chain_directory () const;
+       boost::filesystem::path signer_chain_directory () const;
 
        static Config* instance ();
        static void drop ();
 
 private:
        Config ();
-       std::string file (bool) const;
+       boost::filesystem::path file (bool) const;
        void read ();
        void read_old_metadata ();
 
        /** number of threads to use for J2K encoding on the local machine */
        int _num_local_encoding_threads;
        /** default directory to put new films in */
-       std::string _default_directory;
+       boost::filesystem::path _default_directory;
        /** port to use for J2K encoding servers */
        int _server_port;
 
index e885fe5fd350f804fb8e0e8ec489005da6b4501d..4f57f202a5d4c8e02365f54fcf1051c60d20e43d 100644 (file)
@@ -31,8 +31,9 @@
 #include <boost/date_time.hpp>
 #include <libxml++/libxml++.h>
 #include <libcxml/cxml.h>
-#include <libdcp/crypt_chain.h>
+#include <libdcp/signer_chain.h>
 #include <libdcp/cpl.h>
+#include <libdcp/signer.h>
 #include "film.h"
 #include "job.h"
 #include "util.h"
@@ -78,6 +79,7 @@ using boost::ends_with;
 using boost::starts_with;
 using boost::optional;
 using libdcp::Size;
+using libdcp::Signer;
 
 int const Film::state_version = 4;
 
@@ -897,34 +899,36 @@ Film::make_kdms (
        string directory
        ) const
 {
-       string const cd = Config::instance()->crypt_chain_directory ();
-       if (boost::filesystem::is_empty (cd)) {
-               libdcp::make_crypt_chain (cd);
+       boost::filesystem::path const sd = Config::instance()->signer_chain_directory ();
+       if (boost::filesystem::is_empty (sd)) {
+               libdcp::make_signer_chain (sd);
        }
 
        libdcp::CertificateChain chain;
 
        {
-               boost::filesystem::path p (cd);
+               boost::filesystem::path p (sd);
                p /= "ca.self-signed.pem";
                chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p.string ())));
        }
 
        {
-               boost::filesystem::path p (cd);
+               boost::filesystem::path p (sd);
                p /= "intermediate.signed.pem";
                chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p.string ())));
        }
 
        {
-               boost::filesystem::path p (cd);
+               boost::filesystem::path p (sd);
                p /= "leaf.signed.pem";
                chain.add (shared_ptr<libdcp::Certificate> (new libdcp::Certificate (p.string ())));
        }
 
-       boost::filesystem::path signer_key (cd);
+       boost::filesystem::path signer_key (sd);
        signer_key /= "leaf.key";
 
+       shared_ptr<const Signer> signer (new Signer (chain, signer_key));
+
        /* Find the DCP to make the KDM for */
        string const dir = this->directory ();
        list<string> dcps;
@@ -947,7 +951,7 @@ Film::make_kdms (
                
                /* XXX: single CPL only */
                shared_ptr<xmlpp::Document> kdm = dcp.cpls().front()->make_kdm (
-                       chain, signer_key.string(), (*i)->certificate, from, until, _interop, libdcp::MXFMetadata (), Config::instance()->dcp_metadata ()
+                       signer, (*i)->certificate, from, until, _interop, libdcp::MXFMetadata (), Config::instance()->dcp_metadata ()
                        );
 
                boost::filesystem::path out = directory;
index 5f94d5d6bc65e1f95f13ee730a5af12c579ee286..4f93373f7d6094659a75a0600c395a7154e9c689 100644 (file)
@@ -73,13 +73,14 @@ Writer::Writer (shared_ptr<const Film> f, shared_ptr<Job> j)
           it into the DCP later.
        */
 
-       if (f->three_d ()) {
+       if (_film->three_d ()) {
                _picture_asset.reset (
                        new libdcp::StereoPictureAsset (
                                _film->internal_video_mxf_dir (),
                                _film->internal_video_mxf_filename (),
                                _film->video_frame_rate (),
-                               _film->container()->size (_film->full_frame ())
+                               _film->container()->size (_film->full_frame ()),
+                               _film->encrypted ()
                                )
                        );
                
@@ -89,7 +90,8 @@ Writer::Writer (shared_ptr<const Film> f, shared_ptr<Job> j)
                                _film->internal_video_mxf_dir (),
                                _film->internal_video_mxf_filename (),
                                _film->video_frame_rate (),
-                               _film->container()->size (_film->full_frame ())
+                               _film->container()->size (_film->full_frame ()),
+                               _film->encrypted ()
                                )
                        );
 
@@ -103,7 +105,8 @@ Writer::Writer (shared_ptr<const Film> f, shared_ptr<Job> j)
                        _film->audio_mxf_filename (),
                        _film->video_frame_rate (),
                        _film->audio_channels (),
-                       _film->audio_frame_rate ()
+                       _film->audio_frame_rate (),
+                       _film->encrypted ()
                        )
                );
        
index 7f1efa52f6082df074ec0e049c263c46843a1aa5..dba83804e557670534786bba8d9593d3078dd6ff 100644 (file)
@@ -179,7 +179,7 @@ ConfigDialog::make_misc_panel ()
        _default_still_length->SetValue (config->default_still_length ());
        _default_still_length->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&ConfigDialog::default_still_length_changed, this));
 
-       _default_directory->SetPath (std_to_wx (config->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir()))));
+       _default_directory->SetPath (std_to_wx (config->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())).string ()));
        _default_directory->Bind (wxEVT_COMMAND_DIRPICKER_CHANGED, boost::bind (&ConfigDialog::default_directory_changed, this));
 
        _default_dci_metadata_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ConfigDialog::edit_default_dci_metadata_clicked, this));
index 6a8935232234add7736bc7dfc263d5da060465a2..2612a6afe9afabc987847dcbc0a1547ca6c43850 100644 (file)
@@ -29,7 +29,7 @@
 using namespace std;
 using namespace boost;
 
-boost::optional<string> NewFilmDialog::_directory;
+boost::optional<boost::filesystem::path> NewFilmDialog::_directory;
 
 NewFilmDialog::NewFilmDialog (wxWindow* parent)
        : wxDialog (parent, wxID_ANY, _("New Film"))
@@ -57,7 +57,7 @@ NewFilmDialog::NewFilmDialog (wxWindow* parent)
                _directory = Config::instance()->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir()));
        }
        
-       _folder->SetPath (std_to_wx (_directory.get()));
+       _folder->SetPath (std_to_wx (_directory.get().string()));
        table->Add (_folder, 1, wxEXPAND);
 
        wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
index f8f3aa08dd1ca5f360afaa495299afd1d8470346..4176b060df1dc9081c4afa80c39f11bbff35da35 100644 (file)
@@ -38,5 +38,5 @@ private:
 #else  
        wxDirPickerCtrl* _folder;
 #endif 
-       static boost::optional<std::string> _directory;
+       static boost::optional<boost::filesystem::path> _directory;
 };