X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fconfig.cc;h=eb13112d2556d101533cdea9e85d5a575be41274;hb=23f2dc3bfb94930b938281c7f1e5663b761fa508;hp=54716d8497afcc75ec4ee57cb30a3f423ee07c39;hpb=ed2731617eb2c3db15cb3c57e880ecd39c375751;p=dcpomatic.git diff --git a/src/lib/config.cc b/src/lib/config.cc index 54716d849..eb13112d2 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -168,6 +168,14 @@ Config::set_defaults () _respect_kdm_validity_periods = true; _player_log_file = boost::none; _player_dcp_directory = boost::none; + _player_kdm_directory = boost::none; +#ifdef DCPOMATIC_VARIANT_SWAROOP + _player_background_image = boost::none; + _kdm_server_url = "http://localhost:8000/{CPL}"; + _player_watermark_theatre = ""; + _player_watermark_period = 1; + _player_watermark_duration = 50; +#endif _allowed_dcp_frame_rates.clear (); _allowed_dcp_frame_rates.push_back (24); @@ -223,6 +231,14 @@ void Config::read () try { +#ifdef DCPOMATIC_VARIANT_SWAROOP + if (geteuid() == 0) { + /* Take ownership of the config file if we're root */ + chown (config_file().string().c_str(), 0, 0); + chmod (config_file().string().c_str(), 0644); + } +#endif + cxml::Document f ("Config"); f.read_file (config_file ()); @@ -499,6 +515,17 @@ try _respect_kdm_validity_periods = f.optional_bool_child("RespectKDMValidityPeriods").get_value_or(true); _player_log_file = f.optional_string_child("PlayerLogFile"); _player_dcp_directory = f.optional_string_child("PlayerDCPDirectory"); + _player_kdm_directory = f.optional_string_child("PlayerKDMDirectory"); +#ifdef DCPOMATIC_VARIANT_SWAROOP + _player_background_image = f.optional_string_child("PlayerBackgroundImage"); + _kdm_server_url = f.optional_string_child("KDMServerURL").get_value_or("http://localhost:8000/{CPL}"); + _player_watermark_theatre = f.optional_string_child("PlayerWatermarkTheatre").get_value_or(""); + _player_watermark_period = f.optional_number_child("PlayerWatermarkPeriod").get_value_or(1); + _player_watermark_duration = f.optional_number_child("PlayerWatermarkDuration").get_value_or(150); + BOOST_FOREACH (cxml::ConstNodePtr i, f.node_children("RequiredMonitor")) { + _required_monitors.push_back(Monitor(i)); + } +#endif /* Replace any cinemas from config.xml with those from the configured file */ if (boost::filesystem::exists (_cinemas_file)) { @@ -893,6 +920,21 @@ Config::write_config () const if (_player_dcp_directory) { root->add_child("PlayerDCPDirectory")->add_child_text(_player_dcp_directory->string()); } + if (_player_kdm_directory) { + root->add_child("PlayerKDMDirectory")->add_child_text(_player_kdm_directory->string()); + } +#ifdef DCPOMATIC_VARIANT_SWAROOP + if (_player_background_image) { + root->add_child("PlayerBackgroundImage")->add_child_text(_player_background_image->string()); + } + root->add_child("KDMServerURL")->add_child_text(_kdm_server_url); + root->add_child("PlayerWatermarkTheatre")->add_child_text(_player_watermark_theatre); + root->add_child("PlayerWatermarkPeriod")->add_child_text(raw_convert(_player_watermark_period)); + root->add_child("PlayerWatermarkDuration")->add_child_text(raw_convert(_player_watermark_duration)); + BOOST_FOREACH (Monitor i, _required_monitors) { + i.as_xml(root->add_child("RequiredMonitor")); + } +#endif try { doc.write_to_file_formatted(config_file().string()); @@ -1041,7 +1083,7 @@ Config::add_to_history_internal (vector& h, boost::file h.pop_back (); } - changed (); + changed (HISTORY); } bool @@ -1177,3 +1219,15 @@ Config::copy_and_link (boost::filesystem::path new_file) const boost::filesystem::copy_file (config_file(), new_file, boost::filesystem::copy_option::overwrite_if_exists); link (new_file); } + +bool +Config::have_write_permission () const +{ + FILE* f = fopen_boost (config_file(), "r+"); + if (!f) { + return false; + } + + fclose (f); + return true; +}