[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4-0' - loleaflet/html loleaflet/reference.html loleaflet/src wsd/ClientSession.cpp wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/Storage.cpp wsd/Storage.hpp
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Mon Nov 25 14:12:55 UTC 2019
loleaflet/html/framed.doc.html | 2 +-
loleaflet/reference.html | 11 +++++++++--
loleaflet/src/control/Toolbar.js | 14 ++++++++++----
loleaflet/src/map/handler/Map.WOPI.js | 3 ++-
wsd/ClientSession.cpp | 9 ++++++++-
wsd/DocumentBroker.cpp | 4 +++-
wsd/DocumentBroker.hpp | 2 +-
wsd/Storage.cpp | 2 ++
wsd/Storage.hpp | 6 ++++++
9 files changed, 42 insertions(+), 11 deletions(-)
New commits:
commit 2976f135e6b9486787c9b1988b381ef1473ab26c
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Jun 16 14:42:11 2019 -0400
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Mon Nov 25 15:12:35 2019 +0100
Pass Extended Data in Action_Save from the client to the WOPI host
Clients often need to communicate with their wopi hosts when
invoking Action_Save to provide more context when storing the
document in question. Action_Save now support passing arbitrary
string as ExtendedData entry that can be used by client to
pass any context or otherwise flags to the WOPI host, which
will receive it via the X-LOOL-WOPI-ExtendedData custom header.
See reference.html for more details.
Change-Id: I1814d1f3d984a553ffa60cec13d23b014ba59eb3
Reviewed-on: https://gerrit.libreoffice.org/74135
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
(cherry picked from commit 3dcc68e6f12a1b0d2e1c586a6d4c8ccdfeb8a15b)
Reviewed-on: https://gerrit.libreoffice.org/82706
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/loleaflet/html/framed.doc.html b/loleaflet/html/framed.doc.html
index 93c606cdc..55e73ab37 100644
--- a/loleaflet/html/framed.doc.html
+++ b/loleaflet/html/framed.doc.html
@@ -48,7 +48,7 @@
function save() {
post({'MessageId': 'Action_Save',
- 'Values': { 'Notify': true, }
+ 'Values': { 'Notify': true, 'ExtendedData': 'CustomFlag=CustomValue;AnotherFlag=AnotherValue' }
});
}
diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index 8350a9fe9..fc9616965 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -2920,6 +2920,7 @@ WOPI host to editor
<nobr>DontTerminateEdit: <boolean></nobr>
<nobr>DontSaveIfUnmodified: <boolean></nobr>
<nobr>Notify: <boolean></nobr>
+ <nobr>ExtendedData: <String></nobr>
</code></td>
<td>Saves the document.<br/>
<code>DontTerminateEdit</code> is relevant for spreadsheets where saving
@@ -2928,10 +2929,16 @@ WOPI host to editor
user's editing session in spreadsheets.<br/>
<code>DontSaveIfUnmodified</code> prevents loolwsd to save the file back to storage if document is
unmodified (only cursor position changed etc.) but still saved. This can be helpful
- to prevent creating unnecessary file revisions.
+ to prevent creating unnecessary file revisions.<br/>
<code>Notify</code> when present and set to true notifies the
host when document is saved. See <code>Action_Save_Resp</code>
- for details.
+ for details.<br/>
+ <code>ExtendedData</code> optional data carried over to the WOPI host if provided
+ in the X-LOOL-WOPI-ExtendedData header. The contents are preserved as-is,
+ however, care must be taken to avoid using anything that HTTP headers do
+ not allow, also, special values such as new-line, null character, non-printable
+ characters, etc. are not allowed. The client can use this to pass multiple values
+ to the WOPI host which can then act on them.<br/>
</td>
</tr>
<tr>
diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js
index a08642b2e..89b0f65e6 100644
--- a/loleaflet/src/control/Toolbar.js
+++ b/loleaflet/src/control/Toolbar.js
@@ -143,10 +143,16 @@ L.Map.include({
}
},
- save: function(dontTerminateEdit, dontSaveIfUnmodified) {
- this._socket.sendMessage('save' +
- ' dontTerminateEdit=' + (dontTerminateEdit ? 1 : 0) +
- ' dontSaveIfUnmodified=' + (dontSaveIfUnmodified ? 1 : 0));
+ save: function(dontTerminateEdit, dontSaveIfUnmodified, extendedData) {
+ var msg = 'save' +
+ ' dontTerminateEdit=' + (dontTerminateEdit ? 1 : 0) +
+ ' dontSaveIfUnmodified=' + (dontSaveIfUnmodified ? 1 : 0);
+
+ if (extendedData !== undefined) {
+ msg += ' extendedData=' + extendedData;
+ }
+
+ this._socket.sendMessage(msg);
},
sendUnoCommand: function (command, json) {
diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js
index 42a84aa7d..43f2f2205 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -268,9 +268,10 @@ L.Map.WOPI = L.Handler.extend({
else if (msg.MessageId === 'Action_Save') {
var dontTerminateEdit = msg.Values && msg.Values['DontTerminateEdit'];
var dontSaveIfUnmodified = msg.Values && msg.Values['DontSaveIfUnmodified'];
+ var extendedData = msg.Values && msg.Values['ExtendedData'];
this._notifySave = msg.Values && msg.Values['Notify'];
- this._map.save(dontTerminateEdit, dontSaveIfUnmodified);
+ this._map.save(dontTerminateEdit, dontSaveIfUnmodified, extendedData);
}
else if (msg.MessageId === 'Action_Print') {
this._map.print();
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 6f65f6fc9..1279cb3ae 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -276,7 +276,14 @@ bool ClientSession::_handleInput(const char *buffer, int length)
if (tokens.size() > 2)
getTokenInteger(tokens[2], "dontSaveIfUnmodified", dontSaveIfUnmodified);
- docBroker->sendUnoSave(getId(), dontTerminateEdit != 0, dontSaveIfUnmodified != 0);
+ std::string extendedData;
+ if (tokens.size() > 3)
+ getTokenString(tokens[3], "extendedData", extendedData);
+
+ constexpr bool isAutosave = false;
+ constexpr bool isExitSave = false;
+ docBroker->sendUnoSave(getId(), dontTerminateEdit != 0, dontSaveIfUnmodified != 0,
+ isAutosave, isExitSave, extendedData);
}
}
else if (tokens[0] == "savetostorage")
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 2fdf4a2fc..30d6d5e8d 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1079,7 +1079,8 @@ bool DocumentBroker::autoSave(const bool force, const bool dontSaveIfUnmodified)
}
bool DocumentBroker::sendUnoSave(const std::string& sessionId, bool dontTerminateEdit,
- bool dontSaveIfUnmodified, bool isAutosave, bool isExitSave)
+ bool dontSaveIfUnmodified, bool isAutosave, bool isExitSave,
+ const std::string& extendedData)
{
assertCorrectThread();
@@ -1123,6 +1124,7 @@ bool DocumentBroker::sendUnoSave(const std::string& sessionId, bool dontTerminat
assert(_storage);
_storage->setIsAutosave(isAutosave || UnitWSD::get().isAutosave());
_storage->setIsExitSave(isExitSave);
+ _storage->setExtendedData(extendedData);
const std::string saveArgs = oss.str();
LOG_TRC(".uno:Save arguments: " << saveArgs);
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 1a8b9c8dd..09a8ad5cc 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -333,7 +333,7 @@ public:
/// Sends the .uno:Save command to LoKit.
bool sendUnoSave(const std::string& sessionId, bool dontTerminateEdit = true,
bool dontSaveIfUnmodified = true, bool isAutosave = false,
- bool isExitSave = false);
+ bool isExitSave = false, const std::string& extendedData = std::string());
/// Sends a message to all sessions
void broadcastMessage(const std::string& message);
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index ce1d38b62..14e797e66 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -800,6 +800,8 @@ StorageBase::SaveResult WopiStorage::saveLocalFileToStorage(const Authorization&
request.set("X-LOOL-WOPI-IsModifiedByUser", isUserModified()? "true": "false");
request.set("X-LOOL-WOPI-IsAutosave", getIsAutosave()? "true": "false");
request.set("X-LOOL-WOPI-IsExitSave", isExitSave()? "true": "false");
+ if (!getExtendedData().empty())
+ request.set("X-LOOL-WOPI-ExtendedData", getExtendedData());
if (!getForceSave())
{
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index a95e772b1..d2049d488 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -179,6 +179,7 @@ public:
bool getIsAutosave() const { return _isAutosave; }
void setIsExitSave(bool exitSave) { _isExitSave = exitSave; }
bool isExitSave() const { return _isExitSave; }
+ void setExtendedData(const std::string& extendedData) { _extendedData = extendedData; }
void setFileInfo(const FileInfo& fileInfo) { _fileInfo = fileInfo; }
@@ -211,6 +212,9 @@ protected:
/// Returns the root path of the jail directory of docs.
std::string getLocalRootPath() const;
+ /// Returns the client-provided extended data to send to the WOPI host.
+ const std::string& getExtendedData() const { return _extendedData; }
+
private:
const Poco::URI _uri;
std::string _localStorePath;
@@ -228,6 +232,8 @@ private:
bool _isAutosave;
/// Saving on exit (when the document is cleaned up from memory)
bool _isExitSave;
+ /// The client-provided saving extended data to send to the WOPI host.
+ std::string _extendedData;
static bool FilesystemEnabled;
static bool WopiEnabled;
More information about the Libreoffice-commits
mailing list