X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fconfig.cc;h=a74c36f73c66e1c0d42ab25e88ae0d6ced9c0cd0;hb=048f9b6b5569f03d1342a04f75c83a2bad340996;hp=7c52dc17047775bc5498f91d2a03d3698147fee0;hpb=42410ff820cf885a4b26c24c6c5c9d759dadbf2f;p=dcpomatic.git diff --git a/src/lib/config.cc b/src/lib/config.cc index 7c52dc170..a74c36f73 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -25,14 +25,15 @@ #include "config.h" #include "server.h" #include "scaler.h" -#include "screen.h" #include "filter.h" #include "sound_processor.h" +#include "cinema.h" using std::vector; using std::ifstream; using std::string; using std::ofstream; +using std::list; using boost::shared_ptr; Config* Config::_instance = 0; @@ -41,14 +42,16 @@ Config* Config::_instance = 0; Config::Config () : _num_local_encoding_threads (2) , _server_port (6192) - , _colour_lut_index (0) - , _j2k_bandwidth (250000000) , _reference_scaler (Scaler::from_id ("bicubic")) , _tms_path (".") , _sound_processor (SoundProcessor::from_id ("dolby_cp750")) { - ifstream f (file().c_str ()); + ifstream f (read_file().c_str ()); string line; + + shared_ptr cinema; + shared_ptr screen; + while (getline (f, line)) { if (line.empty ()) { continue; @@ -72,18 +75,12 @@ Config::Config () _default_directory = v; } else if (k == "server_port") { _server_port = atoi (v.c_str ()); - } else if (k == "colour_lut_index") { - _colour_lut_index = atoi (v.c_str ()); - } else if (k == "j2k_bandwidth") { - _j2k_bandwidth = atoi (v.c_str ()); } else if (k == "reference_scaler") { _reference_scaler = Scaler::from_id (v); } else if (k == "reference_filter") { _reference_filters.push_back (Filter::from_id (v)); } else if (k == "server") { _servers.push_back (ServerDescription::create_from_metadata (v)); - } else if (k == "screen") { - _screens.push_back (Screen::create_from_metadata (v)); } else if (k == "tms_ip") { _tms_ip = v; } else if (k == "tms_path") { @@ -94,20 +91,68 @@ Config::Config () _tms_password = v; } else if (k == "sound_processor") { _sound_processor = SoundProcessor::from_id (v); + } else if (k == "cinema") { + if (cinema) { + _cinemas.push_back (cinema); + } + cinema.reset (new Cinema (v, "")); + } else if (k == "cinema_email") { + assert (cinema); + cinema->email = v; + } else if (k == "screen") { + assert (cinema); + if (screen) { + cinema->screens.push_back (screen); + } + screen.reset (new Screen (v, shared_ptr ())); + } else if (k == "screen_certificate") { + assert (screen); + shared_ptr c (new libdcp::Certificate); + c->set_from_string (v); } } + + if (cinema) { + _cinemas.push_back (cinema); + } } /** @return Filename to write configuration to */ string -Config::file () const +Config::write_file () const { + boost::filesystem::path p; + p /= g_get_user_config_dir (); + p /= "dvdomatic"; + boost::filesystem::create_directory (p); + p /= "config"; + return p.string (); +} + +string +Config::read_file () const +{ + if (boost::filesystem::exists (write_file ())) { + return write_file (); + } + boost::filesystem::path p; p /= g_get_user_config_dir (); p /= ".dvdomatic"; return p.string (); } +string +Config::crypt_chain_directory () const +{ + boost::filesystem::path p; + p /= g_get_user_config_dir (); + p /= "dvdomatic"; + p /= "crypt"; + boost::filesystem::create_directories (p); + return p.string (); +} + /** @return Singleton instance */ Config * Config::instance () @@ -123,12 +168,10 @@ Config::instance () void Config::write () const { - ofstream f (file().c_str ()); + ofstream f (write_file().c_str ()); f << "num_local_encoding_threads " << _num_local_encoding_threads << "\n" << "default_directory " << _default_directory << "\n" << "server_port " << _server_port << "\n" - << "colour_lut_index " << _colour_lut_index << "\n" - << "j2k_bandwidth " << _j2k_bandwidth << "\n" << "reference_scaler " << _reference_scaler->id () << "\n"; for (vector::const_iterator i = _reference_filters.begin(); i != _reference_filters.end(); ++i) { @@ -139,15 +182,19 @@ Config::write () const f << "server " << (*i)->as_metadata () << "\n"; } - for (vector >::const_iterator i = _screens.begin(); i != _screens.end(); ++i) { - f << "screen " << (*i)->as_metadata () << "\n"; - } - f << "tms_ip " << _tms_ip << "\n"; f << "tms_path " << _tms_path << "\n"; f << "tms_user " << _tms_user << "\n"; f << "tms_password " << _tms_password << "\n"; - f << "sound_processor " << _sound_processor->id (); + f << "sound_processor " << _sound_processor->id () << "\n"; + + for (list >::const_iterator i = _cinemas.begin(); i != _cinemas.end(); ++i) { + f << "cinema " << (*i)->name << "\n"; + f << "cinema_email " << (*i)->email << "\n"; + for (list >::iterator j = (*i)->screens.begin(); j != (*i)->screens.end(); ++j) { + f << "screen " << (*j)->name << "\n"; + } + } } string