Back-end support for linked configuration.
authorCarl Hetherington <cth@carlh.net>
Mon, 24 Jul 2017 09:25:38 +0000 (10:25 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 24 Jul 2017 09:25:38 +0000 (10:25 +0100)
src/lib/config.cc
src/lib/config.h

index 8dd4c4e0bb984321f94a5026bb2931a2beb5a24f..b7b7b22421c814f4ec2205f106c042c8e90dae4b 100644 (file)
@@ -162,13 +162,25 @@ Config::create_certificate_chain ()
                );
 }
 
+boost::filesystem::path
+Config::target (boost::filesystem::path file)
+{
+       cxml::Document f ("Config");
+       f.read_file (file);
+       optional<string> link = f.optional_string_child ("Link");
+       if (link) {
+               return target (*link);
+       }
+
+       return file;
+}
+
 void
 Config::read ()
 try
 {
        cxml::Document f ("Config");
-       f.read_file (path ("config.xml"));
-       optional<string> c;
+       f.read_file (target(path("config.xml")));
 
        optional<int> version = f.optional_number_child<int> ("Version");
 
@@ -209,6 +221,7 @@ try
        _tms_user = f.string_child ("TMSUser");
        _tms_password = f.string_child ("TMSPassword");
 
+       optional<string> c;
        c = f.optional_string_child ("SoundProcessor");
        if (c) {
                _cinema_sound_processor = CinemaSoundProcessor::from_id (c.get ());
@@ -535,7 +548,7 @@ Config::write_config () const
        root->add_child("CoverSheet")->add_child_text (_cover_sheet);
 
        try {
-               doc.write_to_file_formatted (path("config.xml").string ());
+               doc.write_to_file_formatted (target(path("config.xml")).string ());
        } catch (xmlpp::exception& e) {
                string s = e.what ();
                trim (s);
index 970810a7734214a68f3ad39a3d0718c54a94a3d6..200857aa9f74be788bbac14089eacda2d41e71c6 100644 (file)
@@ -646,6 +646,7 @@ public:
 private:
        Config ();
        static boost::filesystem::path path (std::string file, bool create_directories = true);
+       static boost::filesystem::path target (boost::filesystem::path file);
        void read ();
        void set_defaults ();
        void set_kdm_email_to_default ();