[Libreoffice-commits] online.git: loleaflet/reference.html loleaflet/src loolwsd/bundled loolwsd/ChildProcessSession.cpp loolwsd/LOKitClient.cpp loolwsd/protocol.txt
Jan Holesovsky
kendy at collabora.com
Wed Feb 3 10:25:02 UTC 2016
loleaflet/reference.html | 4 +++
loleaflet/src/core/Socket.js | 3 ++
loleaflet/src/layer/tile/TileLayer.js | 9 ++++++-
loolwsd/ChildProcessSession.cpp | 10 +++++++
loolwsd/LOKitClient.cpp | 1
loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h | 14 +++++++++++
loolwsd/protocol.txt | 5 +++
7 files changed, 44 insertions(+), 2 deletions(-)
New commits:
commit 32ecdb8ab6d28d6e86c6281cfe8cac3ca79fb149
Author: Jan Holesovsky <kendy at collabora.com>
Date: Wed Feb 3 11:15:07 2016 +0100
loolwsd, loleaflet: Handle the ERROR callback.
This introduces a new error id 5 - "document save failed".
diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index 4724e54..bae4e86 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -2105,6 +2105,10 @@ The <code>id</code> property of ErrorEvent can have the following values:
<td><code><b>4</b></code></td>
<td>Socket connection was closed.</td>
</tr>
+ <tr>
+ <td><code><b>5</b></code></td>
+ <td>Document couldn't be saved.</td>
+ </tr>
</table>
<h3 id="hyperlinkclicked-event">HyperlinkClickedEvent</h3>
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index cbfb87c..38895ce 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -236,6 +236,9 @@ L.Socket = L.Class.extend({
else if (tokens[i].substring(0, 4) === 'cmd=') {
command.errorCmd = tokens[i].substring(4);
}
+ else if (tokens[i].substring(0, 5) === 'code=') {
+ command.errorCode = tokens[i].substring(5);
+ }
else if (tokens[i].substring(0, 5) === 'kind=') {
command.errorKind = tokens[i].substring(5);
}
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 220efc8..f776337 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -393,8 +393,15 @@ L.TileLayer = L.GridLayer.extend({
if (command.errorCmd === 'load') {
errorId = 2; // document cannot be loaded
}
+ else if (command.errorCmd === 'save') {
+ errorId = 5; // document cannot be saved
+ }
+
+ var errorCode = -1;
+ if (command.errorCode !== undefined)
+ errorCode = command.errorCode;
- this._map.fire('error', {cmd: command.errorCmd, kind: command.errorKind, id: errorId});
+ this._map.fire('error', {cmd: command.errorCmd, kind: command.errorKind, id: errorId, code: errorCode});
},
_onGetChildIdMsg: function (textMsg) {
diff --git a/loolwsd/ChildProcessSession.cpp b/loolwsd/ChildProcessSession.cpp
index 2ebe1ff..5933856 100644
--- a/loolwsd/ChildProcessSession.cpp
+++ b/loolwsd/ChildProcessSession.cpp
@@ -246,6 +246,16 @@ public:
break;
case LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY:
break;
+ case LOK_CALLBACK_ERROR:
+ {
+ Poco::JSON::Parser parser;
+ Poco::Dynamic::Var var = parser.parse(rPayload);
+ Poco::JSON::Object::Ptr object = var.extract<Poco::JSON::Object::Ptr>();
+
+ _session.sendTextFrame("error: cmd=" + object->get("cmd").toString() +
+ " kind=" + object->get("kind").toString() + " code=" + object->get("code").toString());
+ }
+ break;
}
}
diff --git a/loolwsd/LOKitClient.cpp b/loolwsd/LOKitClient.cpp
index f46136d..0d94115 100644
--- a/loolwsd/LOKitClient.cpp
+++ b/loolwsd/LOKitClient.cpp
@@ -66,6 +66,7 @@ extern "C"
CASE(UNO_COMMAND_RESULT);
CASE(DOCUMENT_PASSWORD);
CASE(DOCUMENT_PASSWORD_TO_MODIFY);
+ CASE(ERROR);
#undef CASE
}
std::cout << " payload: " << pPayload << std::endl;
diff --git a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
index b615bd9..5ce8610 100644
--- a/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -265,6 +265,20 @@ typedef enum
* lok::Office::setDocumentPassword().
*/
LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY,
+
+ /**
+ * An error happened.
+ *
+ * The payload returns information further identifying the error, like:
+ *
+ * {
+ * "classification": "error" | "warning" | "info"
+ * "kind": "network" etc.
+ * "code": 403 | 404 | ...
+ * "message": freeform description
+ * }
+ */
+ LOK_CALLBACK_ERROR,
}
LibreOfficeKitCallbackType;
diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt
index 7bb32d9..c7338cd 100644
--- a/loolwsd/protocol.txt
+++ b/loolwsd/protocol.txt
@@ -153,13 +153,16 @@ downloadas: jail=<jail directory> dir=<a tmp dir> name=<name> port=<port>
The client should then request http://server:port/jail/dir/name in order to download
the document
-error: cmd=<command> kind=<kind>
+error: cmd=<command> kind=<kind> [code=<error_code>]
<freeErrorText>
<command> is the command part of the corresponding client->server
message that caused the error. <kind> is some single-word
classification
+ <code> (when provided) further specifies the error as forwarded from
+ LibreOffice
+
getchildid: id=<id>
Returns the child id
More information about the Libreoffice-commits
mailing list