Merge.
authorCarl Hetherington <cth@carlh.net>
Tue, 7 Mar 2017 10:18:31 +0000 (10:18 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 7 Mar 2017 10:18:31 +0000 (10:18 +0000)
1  2 
ChangeLog
src/lib/config.cc
src/lib/config.h
src/tools/dcpomatic.cc

diff --combined ChangeLog
index f7e10cc3e7e6fe6547f59e9e16ec3277dcc59015,5e38fc74232130fa8f62681998cd33621caf3560..19cd66c71cb40c4cd8b142352f62a9179c45746d
+++ b/ChangeLog
@@@ -1,7 -1,8 +1,12 @@@
 +2017-03-07  Carl Hetherington  <cth@carlh.net>
 +
 +      * Handle failure to write to cinemas file more nicely.
 +
+ 2017-03-03  Carl Hetherington  <cth@carlh.net>
+       * Add option to write KDMs to separate folders
+       or ZIP files.
  2017-02-28  Carl Hetherington  <cth@carlh.net>
  
        * Updated de_DE translation from Carsten Kurz.
diff --combined src/lib/config.cc
index 6a08125cfef35f08e008c97f46fdc418a02dc6c2,a7ef7d2a5c3384a338115cfb71f18e165758737d..f41d40e0931300ae9a8f648067a18154309a568c
@@@ -111,6 -111,7 +111,7 @@@ Config::set_defaults (
        _cinemas_file = path ("cinemas.xml");
        _show_hints_before_make_dcp = true;
        _confirm_kdm_email = true;
+       _kdm_container_name_format = dcp::NameFormat ("KDM %f %c");
        _kdm_filename_format = dcp::NameFormat ("KDM %f %c %s");
        _dcp_metadata_filename_format = dcp::NameFormat ("%t");
        _dcp_asset_filename_format = dcp::NameFormat ("%t");
@@@ -302,6 -303,7 +303,7 @@@ tr
        _cinemas_file = f.optional_string_child("CinemasFile").get_value_or (path ("cinemas.xml").string ());
        _show_hints_before_make_dcp = f.optional_bool_child("ShowHintsBeforeMakeDCP").get_value_or (true);
        _confirm_kdm_email = f.optional_bool_child("ConfirmKDMEmail").get_value_or (true);
+       _kdm_container_name_format = dcp::NameFormat (f.optional_string_child("KDMContainerNameFormat").get_value_or ("KDM %f %c"));
        _kdm_filename_format = dcp::NameFormat (f.optional_string_child("KDMFilenameFormat").get_value_or ("KDM %f %c %s"));
        _dcp_metadata_filename_format = dcp::NameFormat (f.optional_string_child("DCPMetadataFilenameFormat").get_value_or ("%t"));
        _dcp_asset_filename_format = dcp::NameFormat (f.optional_string_child("DCPAssetFilenameFormat").get_value_or ("%t"));
@@@ -366,12 -368,12 +368,12 @@@ Config::instance (
  void
  Config::write () const
  {
 -      write_config_xml ();
 -      write_cinemas_xml ();
 +      write_config ();
 +      write_cinemas ();
  }
  
  void
 -Config::write_config_xml () const
 +Config::write_config () const
  {
        xmlpp::Document doc;
        xmlpp::Element* root = doc.create_root_node ("Config");
        root->add_child("ShowHintsBeforeMakeDCP")->add_child_text (_show_hints_before_make_dcp ? "1" : "0");
        root->add_child("ConfirmKDMEmail")->add_child_text (_confirm_kdm_email ? "1" : "0");
        root->add_child("KDMFilenameFormat")->add_child_text (_kdm_filename_format.specification ());
+       root->add_child("KDMContainerNameFormat")->add_child_text (_kdm_container_name_format.specification ());
        root->add_child("DCPMetadataFilenameFormat")->add_child_text (_dcp_metadata_filename_format.specification ());
        root->add_child("DCPAssetFilenameFormat")->add_child_text (_dcp_asset_filename_format.specification ());
  
  }
  
  void
 -Config::write_cinemas_xml () const
 +Config::write_cinemas () const
  {
        xmlpp::Document doc;
        xmlpp::Element* root = doc.create_root_node ("Cinemas");
diff --combined src/lib/config.h
index 1bdbcb96e284247f30f2020afd56a5fd2e8e59e4,5bd8df97d455d21a54d6da77ef3e49f56c59b48f..c02b12eb5456ec68ff66b08df9344b8bc9973fb6
@@@ -66,7 -66,6 +66,7 @@@ public
        enum Property {
                USE_ANY_SERVERS,
                SERVERS,
 +              CINEMAS,
                OTHER
        };
  
                return _confirm_kdm_email;
        }
  
+       dcp::NameFormat kdm_container_name_format () const {
+               return _kdm_container_name_format;
+       }
        dcp::NameFormat kdm_filename_format () const {
                return _kdm_filename_format;
        }
  
        void add_cinema (boost::shared_ptr<Cinema> c) {
                _cinemas.push_back (c);
 -              changed ();
 +              changed (CINEMAS);
        }
  
        void remove_cinema (boost::shared_ptr<Cinema> c) {
                _cinemas.remove (c);
 -              changed ();
 +              changed (CINEMAS);
        }
  
        void set_allowed_dcp_frame_rates (std::list<int> const & r) {
                maybe_set (_confirm_kdm_email, s);
        }
  
+       void set_kdm_container_name_format (dcp::NameFormat n) {
+               maybe_set (_kdm_container_name_format, n);
+       }
        void set_kdm_filename_format (dcp::NameFormat n) {
                maybe_set (_kdm_filename_format, n);
        }
        static boost::signals2::signal<void ()> FailedToLoad;
  
        void write () const;
 +      void write_config () const;
 +      void write_cinemas () const;
  
        void save_template (boost::shared_ptr<const Film> film, std::string name) const;
        bool existing_template (std::string name) const;
@@@ -561,6 -566,8 +569,6 @@@ private
        void read ();
        void set_defaults ();
        void set_kdm_email_to_default ();
 -      void write_config_xml () const;
 -      void write_cinemas_xml () const;
        void read_cinemas (cxml::Document const & f);
        boost::shared_ptr<dcp::CertificateChain> create_certificate_chain ();
        boost::filesystem::path directory_or (boost::optional<boost::filesystem::path> dir, boost::filesystem::path a) const;
        bool _show_hints_before_make_dcp;
        bool _confirm_kdm_email;
        dcp::NameFormat _kdm_filename_format;
+       dcp::NameFormat _kdm_container_name_format;
        dcp::NameFormat _dcp_metadata_filename_format;
        dcp::NameFormat _dcp_asset_filename_format;
  
diff --combined src/tools/dcpomatic.cc
index d091512a04a94eed1073d43bf5a99b6570abaaa2,19e7707182d05b5f293da6c54a4ae86174752de8..92de9a1f0a0d3d49d4720abc2a466977a5707f3e
@@@ -61,6 -61,7 +61,7 @@@
  #include "lib/cinema_kdms.h"
  #include "lib/dcpomatic_socket.h"
  #include "lib/hints.h"
+ #include "lib/dcp_content.h"
  #include <dcp/exceptions.h>
  #include <dcp/raw_convert.h>
  #include <wx/generic/aboutdlgg.h>
@@@ -214,8 -215,8 +215,8 @@@ public
                SetIcon (wxIcon (std_to_wx ("id")));
  #endif
  
 -              _config_changed_connection = Config::instance()->Changed.connect (boost::bind (&DOMFrame::config_changed, this));
 -              config_changed ();
 +              _config_changed_connection = Config::instance()->Changed.connect (boost::bind (&DOMFrame::config_changed, this, _1));
 +              config_changed (Config::OTHER);
  
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_new, this),                ID_file_new);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_open, this),               ID_file_open);
                wxAcceleratorTable accel_table (2, accel);
                SetAcceleratorTable (accel_table);
  
 -              /* Instantly save any config changes when using the DCP-o-matic GUI */
 -              Config::instance()->Changed.connect (boost::bind (&Config::write, Config::instance ()));
 -
                UpdateChecker::instance()->StateChanged.connect (boost::bind (&DOMFrame::update_checker_state_changed, this));
        }
  
@@@ -922,35 -926,8 +923,35 @@@ private
                m->Append (help, _("&Help"));
        }
  
 -      void config_changed ()
 +      void config_changed (Config::Property what)
        {
 +              /* Instantly save any config changes when using the DCP-o-matic GUI */
 +              if (what == Config::CINEMAS) {
 +                      try {
 +                              Config::instance()->write_cinemas();
 +                      } catch (exception& e) {
 +                              error_dialog (
 +                                      this,
 +                                      wxString::Format (
 +                                              _("Could not write to cinemas file at %s.  Your changes have not been saved."),
 +                                              std_to_wx (Config::instance()->cinemas_file().string()).data()
 +                                              )
 +                                      );
 +                      }
 +              } else {
 +                      try {
 +                              Config::instance()->write_config();
 +                      } catch (exception& e) {
 +                              error_dialog (
 +                                      this,
 +                                      wxString::Format (
 +                                              _("Could not write to config file at %s.  Your changes have not been saved."),
 +                                              std_to_wx (Config::instance()->cinemas_file().string()).data()
 +                                              )
 +                                      );
 +                      }
 +              }
 +
                for (int i = 0; i < _history_items; ++i) {
                        delete _file_menu->Remove (ID_file_history + i);
                }
  
  static const wxCmdLineEntryDesc command_line_description[] = {
        { wxCMD_LINE_SWITCH, "n", "new", "create new film", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
-       { wxCMD_LINE_OPTION, "c", "content", "add content file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
+       { wxCMD_LINE_OPTION, "c", "content", "add content file / directory", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
+       { wxCMD_LINE_OPTION, "d", "dcp", "add content DCP", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
        { wxCMD_LINE_PARAM, 0, 0, "film to load or create", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
        { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
  };
@@@ -1127,6 -1105,9 +1129,9 @@@ private
                                        _frame->film()->examine_and_add_content (i);
                                }
                        }
+                       if (!_dcp_to_add.empty ()) {
+                               _frame->film()->examine_and_add_content (shared_ptr<DCPContent> (new DCPContent (_frame->film(), _dcp_to_add)));
+                       }
                }
  
                signal_manager = new wxSignalManager (this);
                        _content_to_add = wx_to_std (content);
                }
  
+               wxString dcp;
+               if (parser.Found (wxT ("dcp"), &dcp)) {
+                       _dcp_to_add = wx_to_std (dcp);
+               }
                return true;
        }
  
        string _film_to_load;
        string _film_to_create;
        string _content_to_add;
+       string _dcp_to_add;
  };
  
  IMPLEMENT_APP (App)