/*
- Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
#include "dkdm_wrapper.h"
#include "compose.hpp"
#include "crypto.h"
+#include "dkdm_recipient.h"
#include <dcp/raw_convert.h>
#include <dcp/name_format.h>
#include <dcp/certificate_chain.h>
_win32_console = false;
#endif
_cinemas_file = path ("cinemas.xml");
+ _dkdm_recipients_file = path ("dkdm_recipients.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");
+ _dkdm_filename_format = dcp::NameFormat ("DKDM %f %c %s");
_dcp_metadata_filename_format = dcp::NameFormat ("%t");
_dcp_asset_filename_format = dcp::NameFormat ("%t");
_jump_to_selected = true;
boost::filesystem::copy_file(path("config.xml", false), path(String::compose("config.xml.%1", n), false));
boost::filesystem::copy_file(path("cinemas.xml", false), path(String::compose("cinemas.xml.%1", n), false));
+ boost::filesystem::copy_file(path("dkdm_recipients.xml", false), path(String::compose("dkdm_recipients.xml.%1", n), false));
} catch (...) {}
}
_default_interop = f.optional_bool_child("DefaultInterop").get_value_or (false);
_default_kdm_directory = f.optional_string_child("DefaultKDMDirectory");
- /* Load any cinemas from config.xml */
+ /* Read any cinemas that are still lying around in the config file
+ * from an old version.
+ */
read_cinemas (f);
_mail_server = f.string_child ("MailServer");
}
}
_cinemas_file = f.optional_string_child("CinemasFile").get_value_or (path ("cinemas.xml").string ());
+ _dkdm_recipients_file = f.optional_string_child("DKDMRecipientsFile").get_value_or (path("dkdm_recipients.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"));
+ _dkdm_filename_format = dcp::NameFormat (f.optional_string_child("DKDMFilenameFormat").get_value_or("DKDM %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"));
_jump_to_selected = f.optional_bool_child("JumpToSelected").get_value_or (true);
_player_lock_file = f.optional_string_child("PlayerLockFile");
#endif
- /* Replace any cinemas from config.xml with those from the configured file */
if (boost::filesystem::exists (_cinemas_file)) {
cxml::Document f ("Cinemas");
f.read_file (_cinemas_file);
read_cinemas (f);
}
+
+ if (boost::filesystem::exists (_dkdm_recipients_file)) {
+ cxml::Document f ("DKDMRecipients");
+ f.read_file (_dkdm_recipients_file);
+ read_dkdm_recipients (f);
+ }
}
catch (...) {
if (have_existing ("config.xml")) {
{
write_config ();
write_cinemas ();
+ write_dkdm_recipients ();
}
void
/* [XML] CinemasFile Filename of cinemas list file. */
root->add_child("CinemasFile")->add_child_text (_cinemas_file.string());
+ /* [XML] DKDMRecipientsFile Filename of DKDM recipients list file. */
+ root->add_child("DKDMRecipientsFile")->add_child_text (_dkdm_recipients_file.string());
/* [XML] ShowHintsBeforeMakeDCP 1 to show hints in the GUI before making a DCP, otherwise 0. */
root->add_child("ShowHintsBeforeMakeDCP")->add_child_text (_show_hints_before_make_dcp ? "1" : "0");
/* [XML] ConfirmKDMEmail 1 to confirm before sending KDM emails in the GUI, otherwise 0. */
root->add_child("ConfirmKDMEmail")->add_child_text (_confirm_kdm_email ? "1" : "0");
/* [XML] KDMFilenameFormat Format for KDM filenames. */
root->add_child("KDMFilenameFormat")->add_child_text (_kdm_filename_format.specification ());
+ /* [XML] KDMFilenameFormat Format for DKDM filenames. */
+ root->add_child("DKDMFilenameFormat")->add_child_text(_dkdm_filename_format.specification());
/* [XML] KDMContainerNameFormat Format for KDM containers (directories or ZIP files). */
root->add_child("KDMContainerNameFormat")->add_child_text (_kdm_container_name_format.specification ());
/* [XML] DCPMetadataFilenameFormat Format for DCP metadata filenames. */
}
}
+
+template <class T>
void
-Config::write_cinemas () const
+write_file (string root_node, string node, string version, list<shared_ptr<T> > things, boost::filesystem::path file)
{
xmlpp::Document doc;
- xmlpp::Element* root = doc.create_root_node ("Cinemas");
- root->add_child("Version")->add_child_text ("1");
+ xmlpp::Element* root = doc.create_root_node (root_node);
+ root->add_child("Version")->add_child_text(version);
- BOOST_FOREACH (shared_ptr<Cinema> i, _cinemas) {
- i->as_xml (root->add_child ("Cinema"));
+ BOOST_FOREACH (shared_ptr<T> i, things) {
+ i->as_xml (root->add_child(node));
}
try {
- doc.write_to_file_formatted (_cinemas_file.string() + ".tmp");
- boost::filesystem::remove (_cinemas_file);
- boost::filesystem::rename (_cinemas_file.string() + ".tmp", _cinemas_file);
+ doc.write_to_file_formatted (file.string() + ".tmp");
+ boost::filesystem::remove (file);
+ boost::filesystem::rename (file.string() + ".tmp", file);
} catch (xmlpp::exception& e) {
string s = e.what ();
trim (s);
- throw FileError (s, _cinemas_file);
+ throw FileError (s, file);
}
}
+
+void
+Config::write_cinemas () const
+{
+ write_file ("Cinemas", "Cinema", "1", _cinemas, _cinemas_file);
+}
+
+
+void
+Config::write_dkdm_recipients () const
+{
+ write_file ("DKDMRecipients", "DKDMRecipient", "1", _dkdm_recipients, _dkdm_recipients_file);
+}
+
+
boost::filesystem::path
Config::default_directory_or (boost::filesystem::path a) const
{
changed (OTHER);
}
+
+void
+Config::read_dkdm_recipients (cxml::Document const & f)
+{
+ _dkdm_recipients.clear ();
+ list<cxml::NodePtr> cin = f.node_children ("DKDMRecipient");
+ BOOST_FOREACH (cxml::ConstNodePtr i, f.node_children("DKDMRecipient")) {
+ _dkdm_recipients.push_back (shared_ptr<DKDMRecipient>(new DKDMRecipient(i)));
+ }
+}
+
+void
+Config::set_dkdm_recipients_file (boost::filesystem::path file)
+{
+ if (file == _dkdm_recipients_file) {
+ return;
+ }
+
+ _dkdm_recipients_file = file;
+
+ if (boost::filesystem::exists (_dkdm_recipients_file)) {
+ /* Existing file; read it in */
+ cxml::Document f ("DKDMRecipients");
+ f.read_file (_dkdm_recipients_file);
+ read_dkdm_recipients (f);
+ }
+
+ changed (OTHER);
+}
+
+
void
Config::save_template (shared_ptr<const Film> film, string name) const
{
class Cinema;
class Film;
class DKDMGroup;
+class DKDMRecipient;
/** @class Config
* @brief A singleton class holding configuration.
USE_ANY_SERVERS,
SERVERS,
CINEMAS,
+ DKDM_RECIPIENTS,
SOUND,
SOUND_OUTPUT,
INTERFACE_COMPLEXITY,
return _cinemas;
}
+ std::list<boost::shared_ptr<DKDMRecipient> > dkdm_recipients () const {
+ return _dkdm_recipients;
+ }
+
std::list<int> allowed_dcp_frame_rates () const {
return _allowed_dcp_frame_rates;
}
return _cinemas_file;
}
+ boost::filesystem::path dkdm_recipients_file () const {
+ return _dkdm_recipients_file;
+ }
+
bool show_hints_before_make_dcp () const {
return _show_hints_before_make_dcp;
}
return _kdm_filename_format;
}
+ dcp::NameFormat dkdm_filename_format () const {
+ return _dkdm_filename_format;
+ }
+
dcp::NameFormat dcp_metadata_filename_format () const {
return _dcp_metadata_filename_format;
}
changed (CINEMAS);
}
+ void add_dkdm_recipient (boost::shared_ptr<DKDMRecipient> c) {
+ _dkdm_recipients.push_back (c);
+ changed (DKDM_RECIPIENTS);
+ }
+
+ void remove_dkdm_recipient (boost::shared_ptr<DKDMRecipient> c) {
+ _dkdm_recipients.remove (c);
+ changed (DKDM_RECIPIENTS);
+ }
+
void set_allowed_dcp_frame_rates (std::list<int> const & r) {
maybe_set (_allowed_dcp_frame_rates, r);
}
void set_cinemas_file (boost::filesystem::path file);
+ void set_dkdm_recipients_file (boost::filesystem::path file);
+
void set_show_hints_before_make_dcp (bool s) {
maybe_set (_show_hints_before_make_dcp, s);
}
maybe_set (_kdm_filename_format, n);
}
+ void set_dkdm_filename_format (dcp::NameFormat n) {
+ maybe_set (_dkdm_filename_format, n);
+ }
+
void set_dcp_metadata_filename_format (dcp::NameFormat n) {
maybe_set (_dcp_metadata_filename_format, n);
}
void write () const;
void write_config () const;
void write_cinemas () const;
+ void write_dkdm_recipients () const;
void link (boost::filesystem::path new_file) const;
void copy_and_link (boost::filesystem::path new_file) const;
bool have_write_permission () const;
void set_notification_email_to_default ();
void set_cover_sheet_to_default ();
void read_cinemas (cxml::Document const & f);
+ void read_dkdm_recipients (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;
void add_to_history_internal (std::vector<boost::filesystem::path>& h, boost::filesystem::path p);
boost::optional<boost::filesystem::path> _default_kdm_directory;
bool _default_upload_after_make_dcp;
std::list<boost::shared_ptr<Cinema> > _cinemas;
+ std::list<boost::shared_ptr<DKDMRecipient> > _dkdm_recipients;
std::string _mail_server;
int _mail_port;
EmailProtocol _mail_protocol;
std::vector<boost::filesystem::path> _player_history;
boost::shared_ptr<DKDMGroup> _dkdms;
boost::filesystem::path _cinemas_file;
+ boost::filesystem::path _dkdm_recipients_file;
bool _show_hints_before_make_dcp;
bool _confirm_kdm_email;
dcp::NameFormat _kdm_filename_format;
+ dcp::NameFormat _dkdm_filename_format;
dcp::NameFormat _kdm_container_name_format;
dcp::NameFormat _dcp_metadata_filename_format;
dcp::NameFormat _dcp_asset_filename_format;