X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fconfig.cc;h=eeb009594a0d1db48b905d78cb9331cdaa3aafd7;hb=dba7e1137282b52a1bd6ad1d56fe6371a8c97e30;hp=c9b42857149a665da7fdc901c8fdfeb41751bf21;hpb=85be674b29dd61fe08a50f0b84c8402e9df61d94;p=dcpomatic.git diff --git a/src/lib/config.cc b/src/lib/config.cc index c9b428571..eeb009594 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -69,7 +69,7 @@ using dcp::raw_convert; Config* Config::_instance = 0; int const Config::_current_version = 3; -boost::signals2::signal Config::FailedToLoad; +boost::signals2::signal Config::FailedToLoad; boost::signals2::signal Config::Warning; boost::signals2::signal Config::Bad; @@ -270,6 +270,15 @@ Config::backup () void Config::read () +{ + read_config(); + read_cinemas(); + read_dkdm_recipients(); +} + + +void +Config::read_config() try { cxml::Document f ("Config"); @@ -597,33 +606,56 @@ try _last_release_notes_version = f.optional_string_child("LastReleaseNotesVersion"); _export.read(f.optional_node_child("Export")); - - 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") || have_existing("cinemas.xml") || have_existing("dkdm_recipients.xml")) { + if (have_existing("config.xml")) { backup (); /* We have a config file but it didn't load */ - FailedToLoad (); + FailedToLoad(LoadFailure::CONFIG); } set_defaults (); /* Make a new set of signing certificates and key */ _signer_chain = create_certificate_chain (); /* And similar for decryption of KDMs */ _decryption_chain = create_certificate_chain (); - write (); + write_config(); +} + + +void +Config::read_cinemas() +{ + if (boost::filesystem::exists (_cinemas_file)) { + try { + cxml::Document f("Cinemas"); + f.read_file(_cinemas_file); + read_cinemas(f); + } catch (...) { + backup(); + FailedToLoad(LoadFailure::CINEMAS); + write_cinemas(); + } + } +} + + +void +Config::read_dkdm_recipients() +{ + if (boost::filesystem::exists (_dkdm_recipients_file)) { + try { + cxml::Document f("DKDMRecipients"); + f.read_file(_dkdm_recipients_file); + read_dkdm_recipients(f); + } catch (...) { + backup(); + FailedToLoad(LoadFailure::DKDM_RECIPIENTS); + write_dkdm_recipients(); + } + } } + /** @return Singleton instance */ Config * Config::instance () @@ -702,7 +734,7 @@ Config::write_config () const root->add_child("DefaultContainer")->add_child_text (_default_container->id ()); } if (_default_dcp_content_type) { - /* [XML:opt] DefaultDCPContentType Default content type ot use when creating new films (FTR, SHR, + /* [XML:opt] DefaultDCPContentType Default content type to use when creating new films (FTR, SHR, TLR, TST, XSN, RTG, TSR, POL, PSA or ADV). */ root->add_child("DefaultDCPContentType")->add_child_text (_default_dcp_content_type->isdcf_name ()); @@ -1203,7 +1235,7 @@ Config::add_to_history (boost::filesystem::path p) add_to_history_internal (_history, p); } -/** Remove non-existant items from the history */ +/** Remove non-existent items from the history */ void Config::clean_history () {