#include "filter.h"
#include "ratio.h"
#include "types.h"
+#include "log.h"
#include "dcp_content_type.h"
#include "cinema_sound_processor.h"
#include "colour_conversion.h"
#include <glib.h>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
+#include <boost/foreach.hpp>
#include <cstdlib>
#include <fstream>
_server_port_base = 6192;
_use_any_servers = true;
_servers.clear ();
+ _only_servers_encode = false;
_tms_protocol = PROTOCOL_SCP;
_tms_ip = "";
_tms_path = ".";
void
Config::read ()
{
- if (!boost::filesystem::exists (file ())) {
+ if (!have_existing ()) {
/* Make a new set of signing certificates and key */
_signer_chain.reset (new dcp::CertificateChain (openssl_path ()));
- /* And decryption keys */
- make_decryption_keys ();
+ /* And similar for decryption of KDMs */
+ _decryption_chain.reset (new dcp::CertificateChain (openssl_path ()));
+ write ();
return;
}
}
}
+ _only_servers_encode = f.optional_bool_child ("OnlyServersEncode").get_value_or (false);
_tms_protocol = static_cast<Protocol> (f.optional_number_child<int> ("TMSProtocol").get_value_or (static_cast<int> (PROTOCOL_SCP)));
_tms_ip = f.string_child ("TMSIP");
_tms_path = f.string_child ("TMSPath");
_dcp_issuer = f.string_child ("DCPIssuer");
}
+ _dcp_creator = f.optional_string_child ("DCPCreator").get_value_or ("");
+
if (version && version.get() >= 2) {
_default_isdcf_metadata = ISDCFMetadata (f.node_child ("ISDCFMetadata"));
} else {
if (signer) {
shared_ptr<dcp::CertificateChain> c (new dcp::CertificateChain ());
/* 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) {
- c->add (dcp::Certificate ((*i)->content ()));
+ BOOST_FOREACH (cxml::NodePtr i, signer->node_children ("Certificate")) {
+ c->add (dcp::Certificate (i->content ()));
}
c->set_key (signer->string_child ("PrivateKey"));
_signer_chain = c;
_signer_chain.reset (new dcp::CertificateChain (openssl_path ()));
}
- if (f.optional_string_child ("DecryptionCertificate")) {
- _decryption_certificate = dcp::Certificate (f.string_child ("DecryptionCertificate"));
- }
-
- if (f.optional_string_child ("DecryptionPrivateKey")) {
- _decryption_private_key = f.string_child ("DecryptionPrivateKey");
- }
-
- if (!f.optional_string_child ("DecryptionCertificate") || !f.optional_string_child ("DecryptionPrivateKey")) {
- /* Generate our own decryption certificate and key if either is not present in config */
- make_decryption_keys ();
+ cxml::NodePtr decryption = f.optional_node_child ("Decryption");
+ if (decryption) {
+ shared_ptr<dcp::CertificateChain> c (new dcp::CertificateChain ());
+ BOOST_FOREACH (cxml::NodePtr i, decryption->node_children ("Certificate")) {
+ c->add (dcp::Certificate (i->content ()));
+ }
+ c->set_key (signer->string_child ("PrivateKey"));
+ _decryption_chain = c;
+ } else {
+ _decryption_chain.reset (new dcp::CertificateChain (openssl_path ()));
}
}
-void
-Config::make_decryption_keys ()
-{
- dcp::CertificateChain c (openssl_path ());
- _decryption_certificate = c.leaf ();
- _decryption_private_key = c.key().get ();
-}
-
/** @return Filename to write configuration to */
boost::filesystem::path
-Config::file () const
+Config::file ()
{
boost::filesystem::path p;
#ifdef DCPOMATIC_OSX
/* configuration load failed; never mind, just
stick with the default.
*/
- cerr << "dcpomatic: failed to load configuration (" << e.what() << ")\n";
+ cerr << "dcpomatic: warning: configuration did not load (" << e.what() << "); using defaults\n";
} catch (...) {
- cerr << "dcpomatic: failed to load configuration\n";
+ cerr << "dcpomatic: warning: configuration did not load; using defaults\n";
}
}
root->add_child("Server")->add_child_text (*i);
}
+ root->add_child("OnlyServersEncode")->add_child_text (_only_servers_encode ? "1" : "0");
root->add_child("TMSProtocol")->add_child_text (raw_convert<string> (_tms_protocol));
root->add_child("TMSIP")->add_child_text (_tms_ip);
root->add_child("TMSPath")->add_child_text (_tms_path);
root->add_child("DefaultDCPContentType")->add_child_text (_default_dcp_content_type->isdcf_name ());
}
root->add_child("DCPIssuer")->add_child_text (_dcp_issuer);
+ root->add_child("DCPCreator")->add_child_text (_dcp_creator);
_default_isdcf_metadata.as_xml (root->add_child ("ISDCFMetadata"));
#endif
xmlpp::Element* signer = root->add_child ("Signer");
- dcp::CertificateChain::List certs = _signer_chain->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));
+ BOOST_FOREACH (dcp::Certificate const & i, _signer_chain->root_to_leaf ()) {
+ signer->add_child("Certificate")->add_child_text (i.certificate (true));
}
signer->add_child("PrivateKey")->add_child_text (_signer_chain->key().get ());
- root->add_child("DecryptionCertificate")->add_child_text (_decryption_certificate.certificate (true));
- root->add_child("DecryptionPrivateKey")->add_child_text (_decryption_private_key);
+ xmlpp::Element* decryption = root->add_child ("Decryption");
+ BOOST_FOREACH (dcp::Certificate const & i, _decryption_chain->root_to_leaf ()) {
+ decryption->add_child("Certificate")->add_child_text (i.certificate (true));
+ }
+ decryption->add_child("PrivateKey")->add_child_text (_decryption_chain->key().get ());
for (vector<boost::filesystem::path>::const_iterator i = _history.begin(); i != _history.end(); ++i) {
root->add_child("History")->add_child_text (i->string ());
changed ();
}
+
+bool
+Config::have_existing ()
+{
+ return boost::filesystem::exists (file ());
+}