Merge master.
[dcpomatic.git] / src / lib / config.cc
index 7e37625878191a87db0e7bf1cf3959e5b3fb68e3..d624e607045349c9dc21af0d0b29b65f0f2cbd5b 100644 (file)
@@ -67,7 +67,7 @@ Config::Config ()
        , _cinema_sound_processor (CinemaSoundProcessor::from_id (N_("dolby_cp750")))
        , _allow_any_dcp_frame_rate (false)
        , _default_still_length (10)
-       , _default_scale (Ratio::from_id ("185"))
+       , _default_scale (VideoContentScale (Ratio::from_id ("185")))
        , _default_container (Ratio::from_id ("185"))
        , _default_dcp_content_type (DCPContentType::from_isdcf_name ("TST"))
        , _default_j2k_bandwidth (100000000)
@@ -94,7 +94,7 @@ Config::Config ()
 void
 Config::read ()
 {
-       if (!boost::filesystem::exists (file (false))) {
+       if (!boost::filesystem::exists (file ())) {
                /* Make a new set of signing certificates and key */
                _signer.reset (new dcp::Signer (openssl_path ()));
                /* And decryption keys */
@@ -103,7 +103,7 @@ Config::read ()
        }
 
        cxml::Document f ("Config");
-       f.read_file (file (false));
+       f.read_file (file ());
        optional<string> c;
 
        optional<int> version = f.optional_number_child<int> ("Version");
@@ -147,7 +147,7 @@ Config::read ()
 
        c = f.optional_string_child ("DefaultScale");
        if (c) {
-               _default_scale = Ratio::from_id (c.get ());
+               _default_scale = VideoContentScale::from_id (c.get ());
        }
 
        c = f.optional_string_child ("DefaultContainer");
@@ -160,9 +160,12 @@ Config::read ()
                _default_dcp_content_type = DCPContentType::from_isdcf_name (c.get ());
        }
 
-       _dcp_metadata.issuer = f.optional_string_child ("DCPMetadataIssuer").get_value_or ("");
-       _dcp_metadata.creator = f.optional_string_child ("DCPMetadataCreator").get_value_or ("");
-
+       if (f.optional_string_child ("DCPMetadataIssuer")) {
+               _dcp_issuer = f.string_child ("DCPMetadataIssuer");
+       } else if (f.optional_string_child ("DCPIssuer")) {
+               _dcp_issuer = f.string_child ("DCPIssuer");
+       }
+       
        if (version && version.get() >= 2) {
                _default_isdcf_metadata = ISDCFMetadata (f.node_child ("ISDCFMetadata"));
        } else {
@@ -262,19 +265,15 @@ Config::make_decryption_keys ()
 
 /** @return Filename to write configuration to */
 boost::filesystem::path
-Config::file (bool old) const
+Config::file () const
 {
        boost::filesystem::path p;
        p /= g_get_user_config_dir ();
        boost::system::error_code ec;
        boost::filesystem::create_directory (p, ec);
-       if (old) {
-               p /= ".dvdomatic";
-       } else {
-               p /= "dcpomatic";
-               boost::filesystem::create_directory (p, ec);
-               p /= "config.xml";
-       }
+       p /= "dcpomatic2";
+       boost::filesystem::create_directory (p, ec);
+       p /= "config.xml";
        return p;
 }
 
@@ -326,17 +325,14 @@ Config::write () const
        if (_language) {
                root->add_child("Language")->add_child_text (_language.get());
        }
-       if (_default_scale) {
-               root->add_child("DefaultScale")->add_child_text (_default_scale->id ());
-       }
+       root->add_child("DefaultScale")->add_child_text (_default_scale.id ());
        if (_default_container) {
                root->add_child("DefaultContainer")->add_child_text (_default_container->id ());
        }
        if (_default_dcp_content_type) {
                root->add_child("DefaultDCPContentType")->add_child_text (_default_dcp_content_type->isdcf_name ());
        }
-       root->add_child("DCPMetadataIssuer")->add_child_text (_dcp_metadata.issuer);
-       root->add_child("DCPMetadataCreator")->add_child_text (_dcp_metadata.creator);
+       root->add_child("DCPIssuer")->add_child_text (_dcp_issuer);
 
        _default_isdcf_metadata.as_xml (root->add_child ("ISDCFMetadata"));
 
@@ -382,7 +378,7 @@ Config::write () const
                root->add_child("History")->add_child_text (i->string ());
        }
        
-       doc.write_to_file_formatted (file(false).string ());
+       doc.write_to_file_formatted (file().string ());
 }
 
 boost::filesystem::path