loleaflet/reference.html | 4 +++ loleaflet/src/core/Socket.js | 3 ++ loleaflet/src/layer/tile/TileLayer.js | 9 ++++++- loolwsd/LOKitClient.cpp | 1 loolwsd/LOOLSession.cpp | 10 +++++++ loolwsd/bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h | 14 +++++++++++ loolwsd/protocol.txt | 5 +++ 7 files changed, 44 insertions(+), 2 deletions(-)
New commits: commit de0a21e9fddefba7d5591e5aedee561fe5448229 Author: Jan Holesovsky <[email protected]> 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 7499773..7efcaed 100644 --- a/loleaflet/src/core/Socket.js +++ b/loleaflet/src/core/Socket.js @@ -220,6 +220,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/LOKitClient.cpp b/loolwsd/LOKitClient.cpp index 58c7e78..9542942 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/LOOLSession.cpp b/loolwsd/LOOLSession.cpp index 8643196..cce38df 100644 --- a/loolwsd/LOOLSession.cpp +++ b/loolwsd/LOOLSession.cpp @@ -1075,6 +1075,16 @@ extern "C" break; case LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY: break; + case LOK_CALLBACK_ERROR: + { + Poco::JSON::Parser parser; + Poco::Dynamic::Var var = parser.parse(pPayload); + Poco::JSON::Object::Ptr object = var.extract<Poco::JSON::Object::Ptr>(); + + srv->sendTextFrame("error: cmd=" + object->get("cmd").toString() + + " kind=" + object->get("kind").toString() + " code=" + object->get("code").toString()); + } + break; } } } 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 d3071c6..9f6366d 100644 --- a/loolwsd/protocol.txt +++ b/loolwsd/protocol.txt @@ -119,13 +119,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 _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
