X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fconfig.cc;h=0de19f70f866d8214529033ebd2e5534e10bf6ac;hb=450602739388811a6378314d6c309b99f7b28b60;hp=abf0eb42bcf6a19d3d2ab4088c618f65c2f9cfc6;hpb=9bda3fda70912d73266a2dbac5470ca23d2ff6fd;p=dcpomatic.git diff --git a/src/lib/config.cc b/src/lib/config.cc index abf0eb42b..0de19f70f 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -33,9 +33,10 @@ #include "compose.hpp" #include "crypto.h" #include "dkdm_recipient.h" -#include -#include +#include "zipper.h" #include +#include +#include #include #include #include @@ -178,6 +179,7 @@ Config::set_defaults () _audio_mapping = boost::none; _custom_languages.clear (); _add_files_path = boost::none; + _use_isdcf_name_by_default = true; _allowed_dcp_frame_rates.clear (); _allowed_dcp_frame_rates.push_back (24); @@ -450,28 +452,14 @@ try } } - optional bad; - - for (auto const& i: _signer_chain->unordered()) { - if (i.has_utf8_strings()) { - bad = BAD_SIGNER_UTF8_STRINGS; - } - } - - if (!_signer_chain->chain_valid() || !_signer_chain->private_key_valid()) { - bad = BAD_SIGNER_INCONSISTENT; - } - - if (!_decryption_chain->chain_valid() || !_decryption_chain->private_key_valid()) { - bad = BAD_DECRYPTION_INCONSISTENT; - } - + auto bad = check_certificates (); if (bad) { auto const remake = Bad(*bad); if (remake && *remake) { switch (*bad) { case BAD_SIGNER_UTF8_STRINGS: case BAD_SIGNER_INCONSISTENT: + case BAD_SIGNER_VALIDITY_TOO_LONG: _signer_chain = create_certificate_chain (); break; case BAD_DECRYPTION_INCONSISTENT: @@ -578,6 +566,7 @@ try } _add_files_path = f.optional_string_child("AddFilesPath"); + _use_isdcf_name_by_default = f.optional_bool_child("UseISDCFNameByDefault").get_value_or(true); if (boost::filesystem::exists (_cinemas_file)) { cxml::Document f ("Cinemas"); @@ -1007,6 +996,7 @@ Config::write_config () const /* [XML] AddFilesPath The default path that will be offered in the picker when adding files to a film. */ root->add_child("AddFilesPath")->add_child_text(_add_files_path->string()); } + root->add_child("UseISDCFNameByDefault")->add_child_text(_use_isdcf_name_by_default ? "1" : "0"); auto target = config_write_file(); @@ -1466,3 +1456,47 @@ Config::add_custom_language (dcp::LanguageTag tag) } } + +optional +Config::check_certificates () const +{ + optional bad; + + for (auto const& i: _signer_chain->unordered()) { + if (i.has_utf8_strings()) { + bad = BAD_SIGNER_UTF8_STRINGS; + } + if ((i.not_after().year() - i.not_before().year()) > 15) { + bad = BAD_SIGNER_VALIDITY_TOO_LONG; + } + } + + if (!_signer_chain->chain_valid() || !_signer_chain->private_key_valid()) { + bad = BAD_SIGNER_INCONSISTENT; + } + + if (!_decryption_chain->chain_valid() || !_decryption_chain->private_key_valid()) { + bad = BAD_DECRYPTION_INCONSISTENT; + } + + return bad; +} + + +void +save_all_config_as_zip (boost::filesystem::path zip_file) +{ + Zipper zipper (zip_file); + + auto config = Config::instance(); + zipper.add ("config.xml", dcp::file_to_string(config->config_read_file())); + if (boost::filesystem::exists(config->cinemas_file())) { + zipper.add ("cinemas.xml", dcp::file_to_string(config->cinemas_file())); + } + if (boost::filesystem::exists(config->dkdm_recipients_file())) { + zipper.add ("dkdm_recipients.xml", dcp::file_to_string(config->dkdm_recipients_file())); + } + + zipper.close (); +} +