loleaflet/reference.html | 66 +++++++++++++++++++++++++++++----- loleaflet/src/core/Socket.js | 12 ++++++ loleaflet/src/map/handler/Map.WOPI.js | 15 +++++++ wsd/ClientSession.cpp | 8 ++++ wsd/protocol.txt | 18 +++++++++ 5 files changed, 109 insertions(+), 10 deletions(-)
New commits: commit 804acd2adea6b944da709086a42915d81d479a12 Author: Pranav Kant <pran...@collabora.co.uk> Date: Fri Feb 2 11:35:29 2018 +0530 Version restore states See documentation Change-Id: Ica3cd3744643157c5a2c6c1e42e0858ad641da16 Reviewed-on: https://gerrit.libreoffice.org/49754 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/loleaflet/reference.html b/loleaflet/reference.html index 7894f2a7..51516b44 100644 --- a/loleaflet/reference.html +++ b/loleaflet/reference.html @@ -33,7 +33,7 @@ <h2>API Reference</h2> <div id="toc" class="clearfix"> - <div class="toc-col map-col"> + <div class="toc-col map-col"> <h4>Map</h4> <ul> <li><a href="#map-usage">Usage example</a></li> @@ -2759,17 +2759,20 @@ Editor to WOPI host <td><code> <nobr>Status: <String></nobr> <nobr>DocumentLoadedTime: <Timestamp></nobr> - </code></td> - <td>If Status is Frame_Ready, loleaflet frame is loaded and UI - can be shown. <br/> - When Status is Document_Loaded, document has been completely - loaded and host can also start sending document-specific query - messages using post message API such as Get_Views, - Get_Export_Formats etc. DocumentLoadedTime is specified - only in this case. + <nobr>Features: <Dict></nobr> + </code></td> + <td>If Status is <i>Frame_Ready</i>, loleaflet frame is loaded and UI + can be shown. <br/> + Accompanying keys: <i>Features</i>: This client's capabilities. + Supported values are: <i>VersionStates</i>. Tells the host that client supports different version states. See <a href="#loleaflet-postmessage-versioning">Version Restore</a> for more details.<br/> + When Status is Document_Loaded, document has been completely + loaded and host can also start using PostMessage API.<br/> + Accompanying keys: + <i>DocumentLoadedTime</i> </td> </tr> </table> + WOPI host to editor <table data-id='postmessage-initialization-to-editor'> <tr> @@ -2986,6 +2989,51 @@ Actions response </tr> </table> +<h3 id="loleaflet-postmessage-versioning">Version Restore</h3> +WOPI host to editor +<table data-id="postmessage-versioning-to-editor"> + <tr> + <th>MessageId</th> + <th>Values</th> + <th>Description</th> + </tr> + <tr> + <td><code><b>Host_VersionRestore</b></code></td> + <td><code> + <nobr>Status: <string></nobr> + </code></td> + <td> + Only possible value of Status (for now) is <code>Pre_Restore</code>. + This message is sent by the host <b>before</b> actually restoring the document + and <b>after</b> user showed the intent to restore the document. This is so such + that if there are any unsaved changes, Online can save them to storage before + document is restored. + </td> + </tr> +</table> +Editor to WOPI host +<table data-id="postmessage-versioning-to-host"> + <tr> + <th>MessageId</th> + <th>Values</th> + <th>Description</th> + </tr> + <tr> + <td><code><b>App_VersionRestore</b></code></td> + <td><code> + <nobr>Status: <string></nobr> + </code></td> + <td> + This is the reply for the Host_VersionRestore message. Possible values for <code>Status</code> + (for now) is: <code>Pre_Restore_Ack</code>. It means that host can go ahead with restoring the + document to an earlier revision. + </td> + </tr> +</table> + +<h4>Note</h4> +<p>These messages are only emitted if <i>App_LoadingStatus</i> contains <i>VersionStates</i> in <i>Features</i>. Otherwise, host can immediately restore the version to earlier revision.</p> + <h3 id='loleaflet-postmessage-misc'>Miscellaneous</h3> WOPI host to editor <table data-id='postmessage-misc-to-editor'> diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js index 33330d1b..068edc9a 100644 --- a/loleaflet/src/core/Socket.js +++ b/loleaflet/src/core/Socket.js @@ -258,6 +258,7 @@ L.Socket = L.Class.extend({ textMsg = textMsg.substring('close: '.length); msg = ''; var postMsgData = {}; + var showMsgAndReload = false; // This is due to document owner terminating the session if (textMsg === 'ownertermination') { msg = _('Session terminated by document owner'); @@ -310,7 +311,18 @@ L.Socket = L.Class.extend({ } else if (textMsg.startsWith('documentconflict')) { msg = _('Document has changed in storage. Loading the new document. Your version is available as revision.'); + showMsgAndReload = true; + } + else if (textMsg.startsWith('versionrestore:')) { + textMsg = textMsg.substring('versionrestore:'.length).trim(); + if (textMsg === 'prerestore_ack') { + msg = _('Restoring older revision. Any unsaved changes will be available in version history'); + this._map.fire('postMessage', {msgId: 'App_VersionRestore', args: {Status: 'Pre_Restore_Ack'}}); + showMsgAndReload = true; + } + } + if (showMsgAndReload) { if (this._map._docLayer) { this._map._docLayer.removeAllViews(); } diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js index 54278376..c7055c44 100644 --- a/loleaflet/src/map/handler/Map.WOPI.js +++ b/loleaflet/src/map/handler/Map.WOPI.js @@ -72,7 +72,15 @@ L.Map.WOPI = L.Handler.extend({ this.DisableInactiveMessages = !!wopiInfo['DisableInactiveMessages']; this.UserCanNotWriteRelative = !!wopiInfo['UserCanNotWriteRelative']; - this._map.fire('postMessage', {msgId: 'App_LoadingStatus', args: {Status: 'Frame_Ready'}}); + this._map.fire('postMessage', { + msgId: 'App_LoadingStatus', + args: { + Status: 'Frame_Ready', + Features: { + VersionStates: true + } + } + }); }, resetAppLoaded: function() { @@ -231,6 +239,11 @@ L.Map.WOPI = L.Handler.extend({ } } } + else if (msg.MessageId === 'Host_VersionRestore') { + if (msg.Values.Status === 'Pre_Restore') { + this._map._socket.sendMessage('versionrestore prerestore'); + } + } }, _postMessage: function(e) { diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index e23ec418..70d73c71 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -129,6 +129,7 @@ bool ClientSession::_handleInput(const char *buffer, int length) tokens[0] != "outlinestate" && tokens[0] != "commandvalues" && tokens[0] != "closedocument" && + tokens[0] != "versionrestore" && tokens[0] != "downloadas" && tokens[0] != "getchildid" && tokens[0] != "gettextselection" && @@ -195,6 +196,13 @@ bool ClientSession::_handleInput(const char *buffer, int length) return true; } + else if (tokens[0] == "versionrestore") { + if (tokens[1] == "prerestore") { + // green signal to WOPI host to restore the version *after* saving + // any unsaved changes, if any, to the storage + docBroker->closeDocument("versionrestore: prerestore_ack"); + } + } else if (tokens[0] == "partpagerectangles") { // We don't support partpagerectangles any more, will be removed in the diff --git a/wsd/protocol.txt b/wsd/protocol.txt index bb871d81..1f5f2bb9 100644 --- a/wsd/protocol.txt +++ b/wsd/protocol.txt @@ -204,6 +204,14 @@ closedocument having that document opened. This functionality is enabled only in case WOPI host mentions 'EnableOwnerTermination' flag in its CheckFileInfo response +versionrestore <action> + + Version restore related messages. + + <action> can take following values: + - prerestore: The storage is about restore the document to an earlier + revision. + server -> client ================ @@ -292,6 +300,9 @@ close: <reason> because file was changed in storage and we want to load the new document from the storage. + * versionrestore payload - Version restore message is also sent as part of + the close frame. See `versionrestore:` message for details. + getchildid: id=<id> Returns the child id @@ -444,6 +455,13 @@ wopi: <JSON> + HideExportOption: (boolean): If loleaflet should hide the export options this implies 'Download as' options in file menu +versionrestore: <action> + + Possible values for <action>: + + - prerestore_ack: The host can go ahead with restoring the document to an + earlier revision. + child -> parent =============== _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits