[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-7' - 3 commits - loleaflet/src loolwsd/LOOLWSD.cpp
Miklos Vajna
vmiklos at collabora.co.uk
Mon Jan 18 06:30:38 PST 2016
loleaflet/src/core/Socket.js | 4 +++-
loleaflet/src/layer/tile/TileLayer.js | 20 ++++++++++----------
loolwsd/LOOLWSD.cpp | 30 +++++++++++++++++++++++++-----
3 files changed, 38 insertions(+), 16 deletions(-)
New commits:
commit dc7ce9354c8354d8ec9409d974667703bc33ef0d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Jan 18 14:37:37 2016 +0100
loleaflet: enable drop of images
(cherry picked from commit 8845679d2f20cb85a41b28d2e0f93e50445a7434)
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 9f6a673..16106ff 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1035,16 +1035,16 @@ L.TileLayer = L.GridLayer.extend({
for (var i = 0; i < files.length; ++i) {
var file = files[i];
if (file.type.match(/image.*/)) {
- // TODO this needs loolwsd fixing, to support multiline data (blob)
- // var reader = new FileReader();
- // reader.onload = (function(aImg) { return function(e) {
- // this._map._socket.sendMessageWithData('paste mimetype=' + file.type + 'length=' + ..., e.target.result);
- // }; })(img);
- //
- // reader.readAsArrayBuffer();
- //
- // handled = true;
- handled = false;
+ var reader = new FileReader();
+ var socket = this._map._socket;
+ reader.onload = (function(aImg) {
+ return function(e) {
+ var blob = new Blob(['paste mimetype=' + file.type + '\n', e.target.result]);
+ socket.sendMessage(blob);
+ };
+ })(file);
+ reader.readAsArrayBuffer(file);
+ handled = true;
}
}
}
commit 4f0e248257ecb5ea91cfc4c840d3932450d6fbd9
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Jan 18 14:36:46 2016 +0100
loleaflet: don't attempt to log binary ws frames
There is no correct encoding to create log strings for e.g. binary image
data.
(cherry picked from commit bcf0e2d81fd38820bb206311ed3bd280abb04412)
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 57f239f..43afc39 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -39,7 +39,9 @@ L.Socket = L.Class.extend({
}
else if (socketState === 1) {
this.socket.send(msg);
- L.Log.log(msg, L.OUTGOING, coords);
+ // Only attempt to log text frames, not binary ones.
+ if (typeof msg === 'string')
+ L.Log.log(msg, L.OUTGOING, coords);
}
},
commit aae619b69a684889ffdeb6f2bd0517a5768c82d3
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Mon Jan 18 11:32:05 2016 +0100
loolwsd: handle 'nextmessage:' in master -> prisoner traffic
ToPrisoner already generated 'nextmessage:' when it was necessary, but
the other side did not handle that message type, since previously
(before multi-line paste) only the prisoner -> master direction needed
'nextmessage:' for tile data.
(cherry picked from commit 201c9fb59053908aea598bf86a240f5aa39706bb)
Conflicts:
loolwsd/LOOLKit.cpp
loolwsd/MasterProcessSession.cpp
Change-Id: I1badbedd792251d7bb6dbb94a05efc1d9fa15e9c
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 375874c..98092ae 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -936,6 +936,19 @@ namespace
}
}
+static void lcl_handle(TileQueue& queue, const std::string& firstLine, char* buffer, int n)
+{
+
+ if (firstLine.find("paste") != 0)
+ {
+ // Everything else is expected to be a single line.
+ assert(firstLine.size() == static_cast<std::string::size_type>(n));
+ queue.put(firstLine);
+ }
+ else
+ queue.put(std::string(buffer, n));
+}
+
// Writer, Impress or Calc
void LOOLWSD::componentMain()
{
@@ -1071,14 +1084,21 @@ void LOOLWSD::componentMain()
std::string firstLine = getFirstLine(buffer, n);
StringTokenizer tokens(firstLine, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
- if (firstLine.find("paste") != 0)
+ // Check if it is a "nextmessage:" and in that case read the large
+ // follow-up message separately, and handle that only.
+ int size;
+ if (tokens.count() == 2 && tokens[0] == "nextmessage:" && getTokenInteger(tokens[1], "size", size) && size > 0)
{
- // Everything else is expected to be a single line.
- assert(firstLine.size() == static_cast<std::string::size_type>(n));
- queue.put(firstLine);
+ char largeBuffer[size];
+ n = ws->receiveFrame(largeBuffer, size, flags);
+ if (n > 0 && (flags & WebSocket::FRAME_OP_BITMASK) != WebSocket::FRAME_OP_CLOSE)
+ {
+ firstLine = getFirstLine(largeBuffer, n);
+ lcl_handle(queue, firstLine, largeBuffer, n);
+ }
}
else
- queue.put(std::string(buffer, n));
+ lcl_handle(queue, firstLine, buffer, n);
}
}
while (n > 0 && (flags & WebSocket::FRAME_OP_BITMASK) != WebSocket::FRAME_OP_CLOSE);
More information about the Libreoffice-commits
mailing list