diff options
-rw-r--r-- | wsd/COOLWSD.cpp | 22 | ||||
-rw-r--r-- | wsd/COOLWSD.hpp | 2 | ||||
-rw-r--r-- | wsd/FileServer.cpp | 8 |
3 files changed, 31 insertions, 1 deletions
diff --git a/wsd/COOLWSD.cpp b/wsd/COOLWSD.cpp index 9af021be80..11846ab277 100644 --- a/wsd/COOLWSD.cpp +++ b/wsd/COOLWSD.cpp @@ -199,8 +199,10 @@ ServerSocket::Type ClientListenAddr = ServerSocket::Type::Public; /// UDS address for kits to connect to. std::string MasterLocation; +std::string COOLWSD::BuyProductUrl; std::string COOLWSD::LatestVersion; std::mutex COOLWSD::FetchUpdateMutex; +std::mutex COOLWSD::RemoteConfigMutex; #endif // Tracks the set of prisoners / children waiting to be used. @@ -1207,6 +1209,8 @@ public: #endif HostUtil::parseAliases(_conf); + + handleOptions(remoteJson); } void fetchWopiHostPatterns(std::map<std::string, std::string>& newAppConfig, @@ -1543,6 +1547,24 @@ public: } } + void handleOptions(Poco::JSON::Object::Ptr remoteJson) + { + try + { + std::string buyProduct; + JsonUtil::findJSONValue(remoteJson, "buy_product_url", buyProduct); + Poco::URI buyProductUri(buyProduct); + { + std::lock_guard<std::mutex> lock(COOLWSD::RemoteConfigMutex); + COOLWSD::BuyProductUrl = buyProductUri.toString(); + } + } + catch(const Poco::Exception& exc) + { + LOG_ERR("handleOptions: Exception " << exc.what()); + } + } + //sets property to false if it is missing from JSON //and returns std::string std::string booleanToString(Poco::Dynamic::Var& booleanFlag) diff --git a/wsd/COOLWSD.hpp b/wsd/COOLWSD.hpp index 0f2f66fde9..dc5e3eb76f 100644 --- a/wsd/COOLWSD.hpp +++ b/wsd/COOLWSD.hpp @@ -283,9 +283,11 @@ public: static std::string OverrideWatermark; static std::set<const Poco::Util::AbstractConfiguration*> PluginConfigurations; static std::chrono::steady_clock::time_point StartTime; + static std::string BuyProductUrl; static std::string LatestVersion; static std::mutex FetchUpdateMutex; static bool IsBindMountingEnabled; + static std::mutex RemoteConfigMutex; #if MOBILEAPP #ifndef IOS /// This is used to be able to wait until the lokit main thread has finished (and it is safe to load a new document). diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp index 69da792003..333b0f733a 100644 --- a/wsd/FileServer.cpp +++ b/wsd/FileServer.cpp @@ -896,7 +896,13 @@ void FileServerRequestHandler::preprocessFile(const HTTPRequest& request, LOG_TRC("ui_defaults=" << uiDefaults); const std::string cssVars = form.get("css_variables", ""); LOG_TRC("css_variables=" << cssVars); - const std::string buyProduct = form.get("buy_product", ""); + std::string buyProduct; + { + std::lock_guard<std::mutex> lock(COOLWSD::RemoteConfigMutex); + buyProduct = COOLWSD::BuyProductUrl; + } + if (buyProduct.empty()) + buyProduct = form.get("buy_product", ""); LOG_TRC("buy_product=" << buyProduct); const std::string postMessageOrigin = form.get("postmessage_origin", ""); LOG_TRC("postmessage_origin" << postMessageOrigin); |