Fix subtitle colouring (#152).
[dcpomatic.git] / src / lib / config.cc
index 4b6455f51412ed378633f487217918676cbe156c..454b03e3a9f849f0044a21892dde7b543017d365 100644 (file)
@@ -41,7 +41,6 @@
 using std::vector;
 using std::ifstream;
 using std::string;
-using std::ofstream;
 using std::list;
 using std::max;
 using std::exception;
@@ -65,8 +64,9 @@ Config::Config ()
        , _default_container (Ratio::from_id ("185"))
        , _default_dcp_content_type (DCPContentType::from_dci_name ("TST"))
        , _default_j2k_bandwidth (200000000)
+       , _default_audio_delay (0)
        , _kdm_email (
-               "Dear Projectionist\n\nPlease find attached KDMs for $CPL_NAME.\n\nBest regards,\nDCP-o-matic"
+               _("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")
                )
 {
        _allowed_dcp_frame_rates.push_back (24);
@@ -146,6 +146,7 @@ Config::read ()
        _default_dci_metadata = DCIMetadata (f.node_child ("DCIMetadata"));
        _default_still_length = f.optional_number_child<int>("DefaultStillLength").get_value_or (10);
        _default_j2k_bandwidth = f.optional_number_child<int>("DefaultJ2KBandwidth").get_value_or (200000000);
+       _default_audio_delay = f.optional_number_child<int>("DefaultAudioDelay").get_value_or (0);
 
        list<cxml::NodePtr> cc = f.node_children ("ColourConversion");
 
@@ -175,6 +176,8 @@ Config::read ()
        }
 
        _mail_server = f.string_child ("MailServer");
+       _mail_user = f.optional_string_child("MailUser").get_value_or ("");
+       _mail_password = f.optional_string_child("MailPassword").get_value_or ("");
        _kdm_from = f.string_child ("KDMFrom");
        _kdm_email = f.string_child ("KDMEmail");
 }
@@ -182,6 +185,7 @@ Config::read ()
 void
 Config::read_old_metadata ()
 {
+       /* XXX: this won't work with non-Latin filenames */
        ifstream f (file(true).string().c_str ());
        string line;
 
@@ -334,6 +338,7 @@ Config::write () const
 
        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));
 
        for (vector<PresetColourConversion>::const_iterator i = _colour_conversions.begin(); i != _colour_conversions.end(); ++i) {
                i->as_xml (root->add_child ("ColourConversion"));
@@ -344,6 +349,8 @@ Config::write () const
        }
 
        root->add_child("MailServer")->add_child_text (_mail_server);
+       root->add_child("MailUser")->add_child_text (_mail_user);
+       root->add_child("MailPassword")->add_child_text (_mail_password);
        root->add_child("KDMFrom")->add_child_text (_kdm_from);
        root->add_child("KDMEmail")->add_child_text (_kdm_email);
 
@@ -353,7 +360,13 @@ Config::write () const
 boost::filesystem::path
 Config::default_directory_or (boost::filesystem::path a) const
 {
-       if (_default_directory.empty() || !boost::filesystem::exists (_default_directory)) {
+       if (_default_directory.empty()) {
+               return a;
+       }
+
+       boost::system::error_code ec;
+       bool const e = boost::filesystem::exists (_default_directory, ec);
+       if (ec || !e) {
                return a;
        }