[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-cd-4' - 2 commits - loleaflet/src wsd/ClientSession.cpp
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Mon Jun 17 11:29:30 UTC 2019
loleaflet/src/map/handler/Map.WOPI.js | 124 +++++++++++++++++-----------------
wsd/ClientSession.cpp | 4 -
2 files changed, 64 insertions(+), 64 deletions(-)
New commits:
commit 35905035a627c8e46c665cb625792f242f2a53ff
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Fri Jun 14 06:05:46 2019 -0400
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Mon Jun 17 13:29:22 2019 +0200
Alow to modify UI before WOPIPostmessageReady
Since UI customization doesn't depend on
the document being fully loaded, while at
the same time we wouldn't want to display
misleading/incomplete UI while the document
loads, only to change it right after.
Change-Id: Ib8178a1d0033659cbeb79bd4827b528e13890095
Reviewed-on: https://gerrit.libreoffice.org/74133
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js
index b51d87c2d..31a4c059f 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -136,29 +136,51 @@ L.Map.WOPI = L.Handler.extend({
},
_postMessageListener: function(e) {
- if (!window.WOPIPostmessageReady) {
- return;
- }
var msg = JSON.parse(e.data);
- if (msg.MessageId === 'Host_PostmessageReady') {
- // We already have a listener for this in loleaflet.html, so ignore it here
- return;
- }
- // allow closing documents before they are completely loaded
- if (msg.MessageId === 'Close_Session') {
- this._map._socket.sendMessage('closedocument');
- return;
+ // Exception: UI modification can be done before WOPIPostmessageReady was fullfiled
+ if (msg.MessageId === 'Show_Button' || msg.MessageId === 'Hide_Button') {
+ if (!msg.Values) {
+ console.error('Property "Values" not set');
+ return;
+ }
+ if (!msg.Values.id) {
+ console.error('Property "Values.id" not set');
+ return;
+ }
+ var toolbar = w2ui['editbar'];
+ if (!toolbar || !toolbar.get(msg.Values.id)) {
+ console.error('Toolbar button with id "' + msg.Values.id + '" not found.');
+ return;
+ }
+ if (msg.MessageId === 'Show_Button') {
+ toolbar.show(msg.Values.id);
+ } else {
+ toolbar.hide(msg.Values.id);
+ }
}
+ else if (msg.MessageId === 'Show_Menu_Item' || msg.MessageId === 'Hide_Menu_Item') {
+ if (!msg.Values) {
+ console.error('Property "Values" not set');
+ return;
+ }
+ if (!msg.Values.id) {
+ console.error('Property "Values.id" not set');
+ return;
+ }
+ if (!this._map.menubar || !this._map.menubar.hasItem(msg.Values.id)) {
+ console.error('Menu item with id "' + msg.Values.id + '" not found.');
+ return;
+ }
- // For all other messages, warn if trying to interact before we are completely loaded
- if (!this._appLoaded) {
- console.error('LibreOffice Online not loaded yet. Listen for App_LoadingStatus (Document_Loaded) event before using PostMessage API. Ignoring post message \'' + msg.MessageId + '\'.');
- return;
+ if (msg.MessageId === 'Show_Menu_Item') {
+ this._map.menubar.showItem(msg.Values.id);
+ } else {
+ this._map.menubar.hideItem(msg.Values.id);
+ }
}
-
- if (msg.MessageId === 'Insert_Button') {
+ else if (msg.MessageId === 'Insert_Button') {
if (msg.Values) {
if (msg.Values.id && !w2ui['editbar'].get(msg.Values.id)
&& msg.Values.imgurl) {
@@ -195,55 +217,33 @@ L.Map.WOPI = L.Handler.extend({
}
}
}
- if (msg.MessageId === 'Show_Button' || msg.MessageId === 'Hide_Button') {
- if (!msg.Values) {
- console.error('Property "Values" not set');
- return;
- }
- if (!msg.Values.id) {
- console.error('Property "Values.id" not set');
- return;
- }
- if (this._map._permission !== 'edit') {
- console.log('No toolbar in readonly mode - ignoring request.');
- return;
- }
- if (!w2ui['editbar'].get(msg.Values.id)) {
- console.error('Toolbar button with id "' + msg.Values.id + '" not found.');
- return;
- }
- if (msg.MessageId === 'Show_Button') {
- w2ui['editbar'].show(msg.Values.id);
- } else {
- w2ui['editbar'].hide(msg.Values.id);
- }
+ if (!window.WOPIPostmessageReady) {
+ return;
}
- else if (msg.MessageId === 'Show_Menu_Item' || msg.MessageId === 'Hide_Menu_Item') {
- if (!msg.Values) {
- console.error('Property "Values" not set');
- return;
- }
- if (!msg.Values.id) {
- console.error('Property "Values.id" not set');
- return;
- }
- if (this._map._permission !== 'edit') {
- console.log('Readonly mode - ignoring Hide_Menu_Item request.');
- return;
- }
- if (!this._map.menubar || !this._map.menubar.hasItem(msg.Values.id)) {
- console.error('Menu item with id "' + msg.Values.id + '" not found.');
- return;
- }
+ if (msg.MessageId === 'Host_PostmessageReady') {
+ // We already have a listener for this in loleaflet.html, so ignore it here
+ return;
+ }
- if (msg.MessageId === 'Show_Menu_Item') {
- this._map.menubar.showItem(msg.Values.id);
- } else {
- this._map.menubar.hideItem(msg.Values.id);
- }
+ if (msg.MessageId === 'Grab_Focus') {
+ this._map.makeActive();
+ return;
}
- else if (msg.MessageId === 'Set_Settings') {
+
+ // allow closing documents before they are completely loaded
+ if (msg.MessageId === 'Close_Session') {
+ this._map._socket.sendMessage('closedocument');
+ return;
+ }
+
+ // For all other messages, warn if trying to interact before we are completely loaded
+ if (!this._appLoaded) {
+ console.error('LibreOffice Online not loaded yet. Listen for App_LoadingStatus (Document_Loaded) event before using PostMessage API. Ignoring post message \'' + msg.MessageId + '\'.');
+ return;
+ }
+
+ if (msg.MessageId === 'Set_Settings') {
if (msg.Values) {
var alwaysActive = msg.Values.AlwaysActive;
this._map.options.alwaysActive = !!alwaysActive;
commit cba106de61771a2da86689f990ff616c99fcefa6
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Jun 16 14:05:33 2019 -0400
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Mon Jun 17 13:29:11 2019 +0200
wsd: don't use DocBrokers marked to be destroyed
There are cases when we do get client-requests
while we are about to unload and destroy
the DocBroker. This protects against the use
of partially-destroyed DocBroker (specifically,
when TileCache is already destroyed).
Change-Id: I963f2239fd62280e70b1938d3c6f653e8af91b1e
Reviewed-on: https://gerrit.libreoffice.org/74132
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index f3b970c79..22f1fd202 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -81,9 +81,9 @@ bool ClientSession::_handleInput(const char *buffer, int length)
const std::vector<std::string> tokens = LOOLProtocol::tokenize(firstLine.data(), firstLine.size());
std::shared_ptr<DocumentBroker> docBroker = getDocumentBroker();
- if (!docBroker)
+ if (!docBroker || docBroker->isMarkedToDestroy())
{
- LOG_ERR("No DocBroker found. Terminating session " << getName());
+ LOG_ERR("No DocBroker found, or DocBroker marked to be destroyed. Terminating session " << getName());
return false;
}
More information about the Libreoffice-commits
mailing list