[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2' - kit/ChildSession.cpp loleaflet/src test/UnitSession.cpp wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/LOOLWSD.cpp

2020-09-08 Thread Szymon Kłos (via logerrit)
 kit/ChildSession.cpp  |   10 ++-
 loleaflet/src/core/Socket.js  |3 ++
 loleaflet/src/layer/tile/TileLayer.js |2 -
 test/UnitSession.cpp  |   16 
 wsd/DocumentBroker.cpp|   27 
 wsd/DocumentBroker.hpp|9 ++
 wsd/LOOLWSD.cpp   |   45 --
 7 files changed, 71 insertions(+), 41 deletions(-)

New commits:
commit 3a821c2af65505e0ac6d317d7141dc5475f13730
Author: Szymon Kłos 
AuthorDate: Thu Sep 3 11:34:13 2020 +0200
Commit: Andras Timar 
CommitDate: Tue Sep 8 12:31:21 2020 +0200

Simplify download process

Use hash to identify download and pass that to the client.
This allows us to reduce parameters for download requests.
DocBroker maps download ids to URL in the file system.

Change-Id: I254d4f0ccaf3cff9f038a817c8162510ae228bc5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101992
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Tested-by: Michael Meeks 
Reviewed-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/102185
Reviewed-by: Andras Timar 

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 4a5aebcb8..5c7df7272 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -952,7 +952,8 @@ bool ChildSession::downloadAs(const char* /*buffer*/, int 
/*length*/, const Stri
 
 // The file is removed upon downloading.
 const std::string tmpDir = FileUtil::createRandomDir(jailDoc);
-const std::string url = jailDoc + tmpDir + "/" + 
filenameParam.getFileName();
+const std::string urlToSend = tmpDir + "/" + filenameParam.getFileName();
+const std::string url = jailDoc + urlToSend;
 const std::string urlAnonym = jailDoc + tmpDir + "/" + 
Poco::Path(nameAnonym).getFileName();
 
 LOG_DBG("Calling LOK's saveAs with: url='" << urlAnonym << "', format='" <<
@@ -963,7 +964,12 @@ bool ChildSession::downloadAs(const char* /*buffer*/, int 
/*length*/, const Stri
format.empty() ? nullptr : format.c_str(),
filterOptions.empty() ? nullptr : 
filterOptions.c_str());
 
-sendTextFrame("downloadas: jail=" + _jailId + " dir=" + tmpDir + " name=" 
+ name +
+// Register download id -> URL mapping in the DocumentBroker
+std::string docBrokerMessage = "registerdownload: downloadid=" + tmpDir + 
" url=" + urlToSend;
+_docManager->sendFrame(docBrokerMessage.c_str(), 
docBrokerMessage.length());
+
+// Send download id to the client
+sendTextFrame("downloadas: downloadid=" + tmpDir +
   " port=" + std::to_string(ClientPortNumber) + " id=" + id);
 #endif
 return true;
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 95588578e..32a601aca 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -1132,6 +1132,9 @@ L.Socket = L.Class.extend({
else if (tokens[i].substring(0, 4) === 'dir=') {
command.dir = tokens[i].substring(4);
}
+   else if (tokens[i].substring(0, 11) === 'downloadid=') {
+   command.downloadid = tokens[i].substring(11);
+   }
else if (tokens[i].substring(0, 5) === 'name=') {
command.name = tokens[i].substring(5);
}
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index ba0157ac7..7e46e112b 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -914,7 +914,7 @@ L.TileLayer = L.GridLayer.extend({
wopiSrc = '?WOPISrc=' + this._map.options.wopiSrc;
}
var url = this._map.options.webserver + 
this._map.options.serviceRoot + '/' + this._map.options.urlPrefix + '/' +
-   encodeURIComponent(this._map.options.doc) + '/' + 
command.jail + '/' + command.dir + '/' + command.name + wopiSrc;
+   encodeURIComponent(this._map.options.doc) + 
'/download/' + command.downloadid + wopiSrc;
 
this._map.hideBusy();
if (this._map['wopi'].DownloadAsPostMessage) {
diff --git a/test/UnitSession.cpp b/test/UnitSession.cpp
index ec8d1f9bf..bbff4a09e 100644
--- a/test/UnitSession.cpp
+++ b/test/UnitSession.cpp
@@ -185,15 +185,11 @@ UnitBase::TestResult UnitSession::testSlideShow()
!response.empty());
 
 StringVector tokens(Util::tokenize(response.substr(11), ' '));
-// "downloadas: jail= dir= name=slideshow.svg port= id=slideshow"
-const std::string jail = tokens[0].substr(std::string("jail=").size());
-const std::string dir = tokens[1].substr(std::string("dir=").size());
-const std::s

[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2' - kit/ChildSession.cpp loleaflet/src

2020-09-02 Thread Pranam Lashkari (via logerrit)
 kit/ChildSession.cpp  |2 +-
 loleaflet/src/control/Control.PartsPreview.js |3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 36f34129cc2ccd112679b1579965c4c0d70403fe
Author: Pranam Lashkari 
AuthorDate: Wed Aug 26 22:53:37 2020 +0530
Commit: Andras Timar 
CommitDate: Wed Sep 2 10:41:12 2020 +0200

leaflet: wsd: select the page before opening the slide wizard

problem:
In the mobile view taping on the selected slide preview would open the 
wizard
but when some object is selected on the slide
wizard would open for that object
this patch helps us to set the Page as selection and as result
mobile wizard opens for the slide even when some object on slide is selected

Change-Id: Ia4f0d5fe6a4d82d101ee26b75f557a44e0627704
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101363
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 7f6dbaa8b..4a5aebcb8 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -2149,7 +2149,7 @@ bool ChildSession::setClientPart(const char* /*buffer*/, 
int /*length*/, const S
 
 getLOKitDocument()->setView(_viewId);
 
-if (getLOKitDocument()->getDocumentType() != LOK_DOCTYPE_TEXT && part != 
getLOKitDocument()->getPart())
+if (getLOKitDocument()->getDocumentType() != LOK_DOCTYPE_TEXT)
 {
 getLOKitDocument()->setPart(part);
 }
diff --git a/loleaflet/src/control/Control.PartsPreview.js 
b/loleaflet/src/control/Control.PartsPreview.js
index e529fad22..58408b48f 100644
--- a/loleaflet/src/control/Control.PartsPreview.js
+++ b/loleaflet/src/control/Control.PartsPreview.js
@@ -225,7 +225,8 @@ L.Control.PartsPreview = L.Control.extend({
var partId = parseInt(part) - 1; // The first 
part is just a drop-site for reordering.
if (!window.mode.isDesktop() && partId === 
this._map._docLayer._selectedPart) {
// if mobile or tab then second tap will open 
the mobile wizard
-   if (this._map._permission === 'edit') {
+   if (this._map.isPermissionEdit()) {
+   this._setPart(e);
setTimeout(function () {

w2ui['actionbar'].click('mobile_wizard');
}, 0);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2' - kit/ChildSession.cpp loleaflet/src

2020-08-17 Thread Michael Meeks (via logerrit)
 kit/ChildSession.cpp|   32 
 loleaflet/src/layer/marker/TextInput.js |4 +---
 2 files changed, 25 insertions(+), 11 deletions(-)

New commits:
commit bda31ada6962147984f39f2c37c1c7fb4933058e
Author: Michael Meeks 
AuthorDate: Wed Aug 5 17:16:08 2020 +0100
Commit: Andras Timar 
CommitDate: Mon Aug 17 20:20:59 2020 +0200

textinput: use a single input message per key on the wire.

Change-Id: Ibd0f7afb98c8ed278751c4b5b46d7ce2467cd71f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100184
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100663
Reviewed-by: Andras Timar 

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 8d1fef6fb..7f6dbaa8b 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -1245,15 +1245,25 @@ bool ChildSession::insertFile(const char* /*buffer*/, 
int /*length*/, const Stri
 bool ChildSession::extTextInputEvent(const char* /*buffer*/, int /*length*/,
  const StringVector& tokens)
 {
-int id, type;
+int id = -1, type = -1;
 std::string text;
-if (tokens.size() < 4 ||
-!getTokenInteger(tokens[1], "id", id) || id < 0 ||
-!getTokenKeyword(tokens[2], "type",
-{{"input", LOK_EXT_TEXTINPUT}, {"end", 
LOK_EXT_TEXTINPUT_END}},
- type) ||
-!getTokenString(tokens[3], "text", text))
+bool error = false;
+
+if (tokens.size() < 3)
+error = true;
+else if (!getTokenInteger(tokens[1], "id", id) || id < 0)
+error = true;
+else {
+// back-compat 'type'
+if (getTokenKeyword(tokens[2], "type",
+{{"input", LOK_EXT_TEXTINPUT}, {"end", 
LOK_EXT_TEXTINPUT_END}},
+type))
+error = !getTokenString(tokens[3], "text", text);
+else // normal path:
+error = !getTokenString(tokens[2], "text", text);
+}
 
+if (error)
 {
 sendTextFrameAndLogError("error: cmd=" + std::string(tokens[0]) + " 
kind=syntax");
 return false;
@@ -1263,7 +1273,13 @@ bool ChildSession::extTextInputEvent(const char* 
/*buffer*/, int /*length*/,
 URI::decode(text, decodedText);
 
 getLOKitDocument()->setView(_viewId);
-getLOKitDocument()->postWindowExtTextInputEvent(id, type, 
decodedText.c_str());
+if (type >= 0)
+getLOKitDocument()->postWindowExtTextInputEvent(id, type, 
decodedText.c_str());
+else
+{
+getLOKitDocument()->postWindowExtTextInputEvent(id, LOK_EXT_TEXTINPUT, 
decodedText.c_str());
+getLOKitDocument()->postWindowExtTextInputEvent(id, 
LOK_EXT_TEXTINPUT_END, decodedText.c_str());
+}
 
 return true;
 }
diff --git a/loleaflet/src/layer/marker/TextInput.js 
b/loleaflet/src/layer/marker/TextInput.js
index 801c9d368..9fe093ce7 100644
--- a/loleaflet/src/layer/marker/TextInput.js
+++ b/loleaflet/src/layer/marker/TextInput.js
@@ -740,9 +740,7 @@ L.TextInput = L.Layer.extend({
var encodedText = encodeURIComponent(text);
var winId = this._map.getWinId();
this._map._socket.sendMessage(
-   'textinput id=' + winId + ' type=input text=' + 
encodedText);
-   this._map._socket.sendMessage(
-   'textinput id=' + winId + ' type=end text=' + 
encodedText);
+   'textinput id=' + winId + ' text=' + 
encodedText);
}
},
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2' - kit/ChildSession.cpp loleaflet/src

2020-07-28 Thread Szymon Kłos (via logerrit)
 kit/ChildSession.cpp |2 +-
 loleaflet/src/core/Socket.js |   30 +++---
 2 files changed, 24 insertions(+), 8 deletions(-)

New commits:
commit 03ba6537f150793c377ea8781dbd3849b231b507
Author: Szymon Kłos 
AuthorDate: Tue Jul 28 12:45:01 2020 +0200
Commit: Andras Timar 
CommitDate: Wed Jul 29 00:32:03 2020 +0200

Send Action_Save_Resp when notification was requested on save as

Change-Id: Iafe06873fcd8c25e93eb9daa2eea187827e3ac47
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/99610
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 71440c290..8d1fef6fb 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -2116,7 +2116,7 @@ bool ChildSession::saveAs(const char* /*buffer*/, int 
/*length*/, const StringVe
 if (success)
 sendTextFrame("saveas: url=" + encodedURL + " filename=" + 
encodedWopiFilename);
 else
-sendTextFrameAndLogError("error: cmd=storage kind=savefailed");
+sendTextFrameAndLogError("error: cmd=saveas kind=savefailed");
 
 return true;
 }
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index b26fd758b..05490d2bf 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -511,7 +511,19 @@ L.Socket = L.Class.extend({
 
return;
}
-   else if (textMsg.startsWith('error:') && command.errorCmd === 
'storage') {
+   else if (textMsg.startsWith('error:')
+   && (command.errorCmd === 'storage' || command.errorCmd 
=== 'saveas')) {
+
+   if (command.errorCmd === 'saveas') {
+   this._map.fire('postMessage', {
+   msgId: 'Action_Save_Resp',
+   args: {
+   success: false,
+   result: command.errorKind
+   }
+   });
+   }
+
this._map.hideBusy();
var storageError;
if (command.errorKind === 'savediskfull') {
@@ -584,16 +596,16 @@ L.Socket = L.Class.extend({
}
 
// Skip empty errors (and allow for suppressing errors 
by making them blank).
-   if (storageError != '') {
+   if (storageError && storageError != '') {
// Parse the storage url as link
var tmpLink = document.createElement('a');
tmpLink.href = this._map.options.doc;
// Insert the storage server address to be more 
friendly
storageError = 
storageError.replace('%storageserver', tmpLink.host);
this._map.fire('warn', {msg: storageError});
-   }
 
-   return;
+   return;
+   }
}
else if (textMsg.startsWith('error:') && command.errorCmd === 
'internal') {
this._map.hideBusy();
@@ -613,9 +625,6 @@ L.Socket = L.Class.extend({
 
return;
}
-   else if (textMsg.startsWith('error:') && command.errorCmd === 
'saveas') {
-   this._map.hideBusy();
-   }
else if (textMsg.startsWith('error:') && command.errorCmd === 
'load') {
this._map.hideBusy();
this.close();
@@ -756,6 +765,13 @@ L.Socket = L.Class.extend({
NewName: 
command.filename
}
});
+   } else if (textMsg.startsWith('saveas:')) {
+   this._map.fire('postMessage', {
+   msgId: 'Action_Save_Resp',
+   args: {
+   success: true
+   }
+   });
}
}
// var name = command.name; - ignored, we get the new 
name via the wopi's BaseFileName
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits