[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-0' - wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp

László Németh laszlo.nemeth at collabora.com
Wed Feb 1 10:20:38 UTC 2017


 wsd/LOOLWSD.cpp |   20 ++++++++++++++------
 wsd/LOOLWSD.hpp |    1 +
 2 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit c4e9681fd17381c7af2936726262d7357a7dda10
Author: László Németh <laszlo.nemeth at collabora.com>
Date:   Thu Jan 26 09:19:50 2017 +0100

    fix snap support
    
    - add loolwsd option --config-file=path
    
    - search all data files in the actual data directory
      instead of the default one.
    
    Change-Id: I028ff8a696aa6336da55bcac2952f13b12ba8eb8
    Reviewed-on: https://gerrit.libreoffice.org/33504
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 2eb77ae..edc463a 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -503,7 +503,7 @@ private:
         std::string discPath = Path(Application::instance().commandPath()).parent().toString() + "discovery.xml";
         if (!File(discPath).exists())
         {
-            discPath = LOOLWSD_DATADIR "/discovery.xml";
+            discPath = LOOLWSD::FileServerRoot + "/discovery.xml";
         }
 
         InputSource input(discPath);
@@ -1068,7 +1068,7 @@ private:
         std::string discoveryPath = Path(Application::instance().commandPath()).parent().toString() + "discovery.xml";
         if (!File(discoveryPath).exists())
         {
-            discoveryPath = LOOLWSD_DATADIR "/discovery.xml";
+            discoveryPath = LOOLWSD::FileServerRoot + "/discovery.xml";
         }
 
         const std::string mediaType = "text/xml";
@@ -1170,7 +1170,7 @@ public:
                 std::string faviconPath = Path(Application::instance().commandPath()).parent().toString() + "favicon.ico";
                 if (!File(faviconPath).exists())
                 {
-                    faviconPath = LOOLWSD_DATADIR "/favicon.ico";
+                    faviconPath = LOOLWSD::FileServerRoot + "/favicon.ico";
                 }
                 response.setContentType(mimeType);
                 response.sendFile(faviconPath, mimeType);
@@ -1489,6 +1489,7 @@ std::string LOOLWSD::ChildRoot;
 std::string LOOLWSD::ServerName;
 std::string LOOLWSD::FileServerRoot;
 std::string LOOLWSD::LOKitVersion;
+std::string LOOLWSD::ConfigFile = LOOLWSD_CONFIGDIR "/loolwsd.xml";
 Util::RuntimeConstant<bool> LOOLWSD::SSLEnabled;
 Util::RuntimeConstant<bool> LOOLWSD::SSLTermination;
 
@@ -1576,9 +1577,8 @@ void LOOLWSD::initialize(Application& self)
     // Load default configuration files, if present.
     if (loadConfiguration(PRIO_DEFAULT) == 0)
     {
-        // Fallback to the default path.
-        const std::string configPath = LOOLWSD_CONFIGDIR "/loolwsd.xml";
-        loadConfiguration(configPath, PRIO_DEFAULT);
+        // Fallback to the LOOLWSD_CONFIGDIR or --config-file path.
+        loadConfiguration(ConfigFile, PRIO_DEFAULT);
     }
 
     // Override any settings passed on the command-line.
@@ -1655,6 +1655,7 @@ void LOOLWSD::initialize(Application& self)
     LoTemplate = getPathFromConfig("lo_template_path");
     ChildRoot = getPathFromConfig("child_root_path");
     ServerName = config().getString("server_name");
+
     FileServerRoot = getPathFromConfig("file_server_root_path");
     NumPreSpawnedChildren = getConfigValue<unsigned int>(conf, "num_prespawn_children", 1);
 
@@ -1811,6 +1812,11 @@ void LOOLWSD::defineOptions(OptionSet& optionSet)
                         .repeatable(true)
                         .argument("xmlpath"));
 
+    optionSet.addOption(Option("config-file", "", "Override configuration file path.")
+                        .required(false)
+                        .repeatable(false)
+                        .argument("path"));
+
 #if ENABLE_DEBUG
     optionSet.addOption(Option("unitlib", "", "Unit testing library path.")
                         .required(false)
@@ -1851,6 +1857,8 @@ void LOOLWSD::handleOption(const std::string& optionName,
         LOOLProtocol::parseNameValuePair(value, optName, optValue);
         _overrideSettings[optName] = optValue;
     }
+    else if (optionName == "config-file")
+        ConfigFile = value;
 #if ENABLE_DEBUG
     else if (optionName == "unitlib")
         UnitTestLibrary = value;
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index f1577d9..89eee38 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -42,6 +42,7 @@ public:
     static bool NoCapsForKit;
     static int ForKitWritePipe;
     static std::string Cache;
+    static std::string ConfigFile;
     static std::string SysTemplate;
     static std::string LoTemplate;
     static std::string ChildRoot;


More information about the Libreoffice-commits mailing list