using boost::algorithm::trim;
Config* Config::_instance = 0;
+boost::signals2::signal<void ()> Config::FailedToLoad;
/** Construct default configuration */
Config::Config ()
void
Config::read ()
+try
{
- if (!have_existing ("config.xml")) {
- /* 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 ();
- return;
- }
-
cxml::Document f ("Config");
f.read_file (path ("config.xml"));
optional<string> c;
read_cinemas (f);
}
}
+catch (...) {
+ if (have_existing ("config.xml")) {
+ /* We have a config file but it didn't load */
+ FailedToLoad ();
+ }
+ 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 ();
+}
+
/** @return Filename to write configuration to */
boost::filesystem::path