/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
#include <libdcp/colour_matrix.h>
+#include <libdcp/raw_convert.h>
#include <libcxml/cxml.h>
#include "config.h"
#include "server.h"
using std::exception;
using std::cerr;
using boost::shared_ptr;
-using boost::lexical_cast;
using boost::optional;
using boost::algorithm::is_any_of;
using boost::algorithm::split;
+using libdcp::raw_convert;
Config* Config::_instance = 0;
, _use_any_servers (true)
, _tms_path (".")
, _sound_processor (SoundProcessor::from_id (N_("dolby_cp750")))
+ , _allow_any_dcp_frame_rate (false)
, _default_still_length (10)
, _default_container (Ratio::from_id ("185"))
, _default_dcp_content_type (DCPContentType::from_dci_name ("TST"))
- , _default_j2k_bandwidth (200000000)
+ , _default_j2k_bandwidth (100000000)
, _default_audio_delay (0)
, _kdm_email (
_("Dear Projectionist\n\nPlease find attached KDMs for $CPL_NAME.\n\nThe KDMs are valid from $START_TIME until $END_TIME.\n\nBest regards,\nDCP-o-matic")
)
+ , _check_for_updates (false)
+ , _check_for_test_updates (false)
+ , _maximum_j2k_bandwidth (250000000)
+ , _log_types (Log::GENERAL | Log::WARNING | Log::ERROR)
{
_allowed_dcp_frame_rates.push_back (24);
_allowed_dcp_frame_rates.push_back (25);
void
Config::read ()
{
- LocaleGuard lg;
-
if (!boost::filesystem::exists (file (false))) {
read_old_metadata ();
return;
_mail_password = f.optional_string_child("MailPassword").get_value_or ("");
_kdm_from = f.string_child ("KDMFrom");
_kdm_email = f.string_child ("KDMEmail");
+
+ _check_for_updates = f.optional_bool_child("CheckForUpdates").get_value_or (false);
+ _check_for_test_updates = f.optional_bool_child("CheckForTestUpdates").get_value_or (false);
+
+ _maximum_j2k_bandwidth = f.optional_number_child<int> ("MaximumJ2KBandwidth").get_value_or (250000000);
+ _allow_any_dcp_frame_rate = f.optional_bool_child ("AllowAnyDCPFrameRate");
+
+ _log_types = f.optional_number_child<int> ("LogTypes").get_value_or (Log::GENERAL | Log::WARNING | Log::ERROR);
}
void
void
Config::write () const
{
- LocaleGuard lg;
-
xmlpp::Document doc;
xmlpp::Element* root = doc.create_root_node ("Config");
root->add_child("Version")->add_child_text ("1");
- root->add_child("NumLocalEncodingThreads")->add_child_text (lexical_cast<string> (_num_local_encoding_threads));
+ root->add_child("NumLocalEncodingThreads")->add_child_text (raw_convert<string> (_num_local_encoding_threads));
root->add_child("DefaultDirectory")->add_child_text (_default_directory.string ());
- root->add_child("ServerPortBase")->add_child_text (lexical_cast<string> (_server_port_base));
+ root->add_child("ServerPortBase")->add_child_text (raw_convert<string> (_server_port_base));
root->add_child("UseAnyServers")->add_child_text (_use_any_servers ? "1" : "0");
for (vector<string>::const_iterator i = _servers.begin(); i != _servers.end(); ++i) {
_default_dci_metadata.as_xml (root->add_child ("DCIMetadata"));
- root->add_child("DefaultStillLength")->add_child_text (lexical_cast<string> (_default_still_length));
- root->add_child("DefaultJ2KBandwidth")->add_child_text (lexical_cast<string> (_default_j2k_bandwidth));
- root->add_child("DefaultAudioDelay")->add_child_text (lexical_cast<string> (_default_audio_delay));
+ root->add_child("DefaultStillLength")->add_child_text (raw_convert<string> (_default_still_length));
+ root->add_child("DefaultJ2KBandwidth")->add_child_text (raw_convert<string> (_default_j2k_bandwidth));
+ root->add_child("DefaultAudioDelay")->add_child_text (raw_convert<string> (_default_audio_delay));
for (vector<PresetColourConversion>::const_iterator i = _colour_conversions.begin(); i != _colour_conversions.end(); ++i) {
i->as_xml (root->add_child ("ColourConversion"));
root->add_child("KDMFrom")->add_child_text (_kdm_from);
root->add_child("KDMEmail")->add_child_text (_kdm_email);
+ root->add_child("CheckForUpdates")->add_child_text (_check_for_updates ? "1" : "0");
+ root->add_child("CheckForTestUpdates")->add_child_text (_check_for_test_updates ? "1" : "0");
+
+ root->add_child("MaximumJ2KBandwidth")->add_child_text (raw_convert<string> (_maximum_j2k_bandwidth));
+ root->add_child("AllowAnyDCPFrameRate")->add_child_text (_allow_any_dcp_frame_rate ? "1" : "0");
+ root->add_child("LogTypes")->add_child_text (raw_convert<string> (_log_types));
+
doc.write_to_file_formatted (file(false).string ());
}
delete _instance;
_instance = 0;
}
+
+void
+Config::changed ()
+{
+ write ();
+ Changed ();
+}