summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2018-11-29 19:15:58 +0100
committerAndras Timar <andras.timar@collabora.com>2018-11-30 13:34:46 +0100
commit9168040a4dc133e3688ed31bc02a74f9459b5087 (patch)
tree1677073d99280e94fca48b19fadea811c3073f43
parentc57a1fbef0c846c01abc5bbbedcae81acad891c3 (diff)
capabilities: Don't rely on existence of the file, compose it completely.
Change-Id: I41588afa9f26b4a2575ee8cf7d9837cc79b31b3e
-rw-r--r--capabilities.json5
-rw-r--r--wsd/LOOLWSD.cpp28
2 files changed, 7 insertions, 26 deletions
diff --git a/capabilities.json b/capabilities.json
deleted file mode 100644
index 32ed3801f..000000000
--- a/capabilities.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "convert-to": {
- "available": false
- }
-}
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index c91791d15..446db4e4b 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2769,31 +2769,17 @@ private:
{
std::shared_ptr<StreamSocket> socket = _socket.lock();
- // http://server/hosting/capabilities
-#if defined __linux && defined MOBILEAPP
- std::string capabilitiesPath = Path(Application::instance().commandPath()).parent().parent().toString() + "capabilities.json";
-#else
- std::string capabilitiesPath = Path(Application::instance().commandPath()).parent().toString() + "capabilities.json";
-#endif
- if (!File(capabilitiesPath).exists())
- {
- capabilitiesPath = LOOLWSD::FileServerRoot + "/capabilities.json";
- }
- std::ifstream ifs (capabilitiesPath.c_str(), std::ifstream::in);
-
- if(!ifs.is_open())
- return "";
-
- Poco::JSON::Parser parser;
- Poco::Dynamic::Var jsonFile = parser.parse(ifs);
- Poco::JSON::Object::Ptr features = jsonFile.extract<Poco::JSON::Object::Ptr>();
- Poco::JSON::Object::Ptr convert_to = features->get("convert-to").extract<Poco::JSON::Object::Ptr>();
-
+ // Can the convert-to be used?
+ Poco::JSON::Object::Ptr convert_to = new Poco::JSON::Object;
Poco::Dynamic::Var available = allowConvertTo(socket->clientAddress(), request);
convert_to->set("available", available);
+ // Compose the content of http://server/hosting/capabilities
+ Poco::JSON::Object::Ptr capabilities = new Poco::JSON::Object;
+ capabilities->set("convert-to", convert_to);
+
std::ostringstream ostrJSON;
- features->stringify(ostrJSON);
+ capabilities->stringify(ostrJSON);
return ostrJSON.str();
}