diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2016-11-10 17:25:38 +0530 |
---|---|---|
committer | Pranav Kant <pranavk@collabora.co.uk> | 2016-11-10 22:03:17 +0530 |
commit | 9c5928a87b91a58f37b8960453e9553c6020e1e8 (patch) | |
tree | 48498d58da9a7aae31b961ab97dd932f1c79dd6f | |
parent | 7cacabad40f2253b65f9485607691571577672cf (diff) |
tdf#103641: Convert 'wopi:' message to JSON formatted message
... to accomdate other WOPI properties easily in future.
Change-Id: Ic92364f06f4f16ebe8f9f128cd49087f6d72a4d1
-rw-r--r-- | loleaflet/src/core/Socket.js | 6 | ||||
-rw-r--r-- | loolwsd/DocumentBroker.cpp | 11 | ||||
-rw-r--r-- | loolwsd/protocol.txt | 7 |
3 files changed, 20 insertions, 4 deletions
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js index 87ffe91cb..77d643bf1 100644 --- a/loleaflet/src/core/Socket.js +++ b/loleaflet/src/core/Socket.js @@ -179,10 +179,10 @@ L.Socket = L.Class.extend({ } else if (textMsg.startsWith('wopi: ')) { // Handle WOPI related messages - textMsg = textMsg.substring('wopi: '.length); + var wopiInfo = JSON.parse(textMsg.substring(textMsg.indexOf('{'))); // Store postmessageorigin property in our WOPI handler, if it exists - if (this._map['wopi'] && textMsg.startsWith('postmessageorigin ')) { - this._map['wopi'].PostMessageOrigin = textMsg.substring('postmessageorigin '.length); + if (this._map['wopi'] && !!wopiInfo['PostMessageOrigin']) { + this._map['wopi'].PostMessageOrigin = wopiInfo['PostMessageOrigin']; this._map['wopi'].DocumentLoadedTime = Date.now(); // Tell the host that we are ready now this._map.fire('postMessage', {msgId: 'App_LoadingStatus', args: {'DocumentLoadedTime': this._map['wopi'].DocumentLoadedTime}}); diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp index edc453e27..179b2e5c5 100644 --- a/loolwsd/DocumentBroker.cpp +++ b/loolwsd/DocumentBroker.cpp @@ -12,7 +12,9 @@ #include <cassert> #include <fstream> +#include <sstream> +#include <Poco/JSON/Object.h> #include <Poco/Path.h> #include <Poco/SHA1Engine.h> #include <Poco/StringTokenizer.h> @@ -30,6 +32,7 @@ using namespace LOOLProtocol; +using Poco::JSON::Object; using Poco::StringTokenizer; void ChildProcess::socketProcessor() @@ -238,7 +241,13 @@ bool DocumentBroker::load(std::shared_ptr<ClientSession>& session, const std::st if (!wopifileinfo._postMessageOrigin.empty()) { - session->sendTextFrame("wopi: postmessageorigin " + wopifileinfo._postMessageOrigin); + // Construct a JSON containing relevant WOPI host properties + Object::Ptr wopiInfo = new Object(); + wopiInfo->set("PostMessageOrigin", wopifileinfo._postMessageOrigin); + std::ostringstream ossWopiInfo; + wopiInfo->stringify(ossWopiInfo); + + session->sendTextFrame("wopi: " + ossWopiInfo.str()); } // Mark the session as 'Document owner' if WOPI hosts supports it diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt index 7fea7869e..9de16062e 100644 --- a/loolwsd/protocol.txt +++ b/loolwsd/protocol.txt @@ -363,6 +363,13 @@ perm: <permission> <permission> can be one of 'edit', 'view', 'readonly'. Client must change the UI accordingly (disabling buttons etc.) +wopi: <JSON> + + Sent only in case storage is WOPI. Contains WOPI related + capabilities/information for loleaflet to act accordingly. + + Properties mentioned: + PostMessageOrigin: See WOPI specs for more information child -> parent =============== |