loleaflet/dist/errormessages.js         |    1 +
 loleaflet/src/control/Control.Dialog.js |    3 ++-
 loleaflet/src/core/Socket.js            |   11 +++++++++++
 loolwsd/.gitignore                      |    1 +
 loolwsd/LOOLWSD.cpp                     |   20 ++++++--------------
 loolwsd/UserMessages.hpp                |    4 ++--
 loolwsd/protocol.txt                    |    2 +-
 loolwsd/test/httpwserror.cpp            |    8 ++++----
 8 files changed, 28 insertions(+), 22 deletions(-)

New commits:
commit 97fa8e45f9f5648866fe03dfafac57e4986c9bfd
Author: Henry Castro <hcas...@collabora.com>
Date:   Sat Oct 1 11:12:47 2016 -0400

    loleaflet: fix error message localization

diff --git a/loleaflet/dist/errormessages.js b/loleaflet/dist/errormessages.js
index dc99714..625f017 100644
--- a/loleaflet/dist/errormessages.js
+++ b/loleaflet/dist/errormessages.js
@@ -1,3 +1,4 @@
 exports.wrongwopisrc = _('Wrong WOPISrc, usage: WOPISrc=valid encoded URI, or 
file_path, usage: file_path=/path/to/doc/');
 exports.emptyhosturl = _('The host URL is empty. The loolwsd server is 
probably misconfigured, please contact the administrator.');
 exports.diskfull = _('No disk space left on server, please contact the server 
administrator to continue.');
+exports.limitreached = _('This development build is limited to %0 documents, 
and %1 connections - to avoid the impression that it is suitable for deployment 
in large enterprises. To find out more about deploying and scaling %2 checkout: 
<br/><a href=\"%3\">%3</a>.');
diff --git a/loleaflet/src/control/Control.Dialog.js 
b/loleaflet/src/control/Control.Dialog.js
index 9417a8b..41836ae 100644
--- a/loleaflet/src/control/Control.Dialog.js
+++ b/loleaflet/src/control/Control.Dialog.js
@@ -10,7 +10,8 @@ L.Control.Dialog = L.Control.extend({
        },
 
        _onError: function (e) {
-               if (vex.dialogID > 0) {
+               if (vex.dialogID > 0 && !this._map._fatal) {
+                       // TODO. queue message errors and pop-up dialogs
                        // Close other dialogs before presenting a new one.
                        vex.close(vex.dialogID);
                }
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 0ce132c..c4bb43f 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -201,6 +201,14 @@ L.Socket = L.Class.extend({
                }
                else if (textMsg.startsWith('error:') && !this._map._docLayer) {
                        textMsg = textMsg.substring(6);
+                       if (command.errorKind === 'limitreached') {
+                               this._map._fatal = true;
+                               textMsg = errorMessages.limitreached;
+                               textMsg = textMsg.replace(/%0/g, 
command.params[0]);
+                               textMsg = textMsg.replace(/%1/g, 
command.params[1]);
+                               textMsg = textMsg.replace(/%2/g, (typeof 
brandProductName !== 'undefined' ? brandProductName : 'LibreOffice Online'));
+                               textMsg = textMsg.replace(/%3/g, (typeof 
brandProductURL !== 'undefined' ? brandProductURL : 
'https://wiki.documentfoundation.org/Development/LibreOffice_Online'));
+                       }
                        this._map.fire('error', {msg: textMsg});
                }
                else if (textMsg === 'pong' && this._map._docLayer && 
this._map._docLayer._debug) {
@@ -411,6 +419,9 @@ L.Socket = L.Class.extend({
                        else if (tokens[i].substring(0, 7) === 'viewid=') {
                                command.viewid = tokens[i].substring(7);
                        }
+                       else if (tokens[i].substring(0, 7) === 'params=') {
+                               command.params = 
tokens[i].substring(7).split(',');
+                       }
                }
                if (command.tileWidth && command.tileHeight && 
this._map._docLayer) {
                        var defaultZoom = this._map.options.zoom;
commit 2a6a5eab2ea0fddb1eb2bd5c51cf453457e91b83
Author: Henry Castro <hcas...@collabora.com>
Date:   Sat Oct 1 08:45:08 2016 -0400

    loolwsd: error message is localizable

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 1d0d519..a54378a 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -19,12 +19,6 @@
 /* Default document used in the start test URI */
 #define LOOLWSD_TEST_DOCUMENT_RELATIVE_PATH "test/data/hello-world.odt"
 
-/* PRODUCT */
-#define LOOLWSD_PRODUCT "LibreOffice Online"
-
-/* PRODUCT URL */
-#define LOOLWSD_URL 
"https://wiki.documentfoundation.org/Development/LibreOffice_Online";
-
 // This is the main source for the loolwsd program. LOOL uses several loolwsd 
processes: one main
 // parent process that listens on the TCP port and accepts connections from 
LOOL clients, and a
 // number of child processes, each which handles a viewing (editing) session 
for one document.
@@ -185,10 +179,8 @@ namespace {
 static inline
 void lcl_shutdownLimitReached(WebSocket& ws)
 {
-    const std::string msg = std::string("error: ") + 
Poco::format(PAYLOAD_UNAVALABLE_LIMIT_REACHED, MAX_DOCUMENTS, MAX_CONNECTIONS,
-        std::string(LOOLWSD_PRODUCT),
-        std::string(LOOLWSD_URL),
-        std::string(LOOLWSD_URL));
+    const std::string error = Poco::format(PAYLOAD_UNAVALABLE_LIMIT_REACHED, 
MAX_DOCUMENTS, MAX_CONNECTIONS);
+    const std::string close = Poco::format(SERVICE_UNAVALABLE_LIMIT_REACHED, 
static_cast<int>(WebSocket::WS_POLICY_VIOLATION));
 
     /* loleaflet sends loolclient, load and partrectangles message immediately
        after web socket handshake, so closing web socket fails loading page in
@@ -209,16 +201,16 @@ void lcl_shutdownLimitReached(WebSocket& ws)
             ws.receiveFrame(buffer.data(), buffer.capacity(), flags);
             if (--handshake == 0)
             {
-                ws.sendFrame(msg.data(), msg.size());
-                ws.shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, 
Poco::format(SERVICE_UNAVALABLE_LIMIT_REACHED, MAX_DOCUMENTS, MAX_CONNECTIONS));
+                ws.sendFrame(error.data(), error.size());
+                ws.shutdown(WebSocket::WS_POLICY_VIOLATION, close);
             }
         }
         while ((flags & WebSocket::FRAME_OP_BITMASK) != 
WebSocket::FRAME_OP_CLOSE);
     }
     catch (Exception& e)
     {
-        ws.sendFrame(msg.data(), msg.size());
-        ws.shutdown(WebSocket::WS_ENDPOINT_GOING_AWAY, 
Poco::format(SERVICE_UNAVALABLE_LIMIT_REACHED, MAX_DOCUMENTS, MAX_CONNECTIONS));
+        ws.sendFrame(error.data(), error.size());
+        ws.shutdown(WebSocket::WS_POLICY_VIOLATION, close);
     }
 }
 
diff --git a/loolwsd/UserMessages.hpp b/loolwsd/UserMessages.hpp
index 7aa7aa4..36e6ad3 100644
--- a/loolwsd/UserMessages.hpp
+++ b/loolwsd/UserMessages.hpp
@@ -15,8 +15,8 @@
 //NOTE: For whatever reason Poco seems to trim the first character.
 
 constexpr auto SERVICE_UNAVALABLE_INTERNAL_ERROR = " Service is unavailable. 
Please try again later and report to your administrator if the issue persists.";
-constexpr auto SERVICE_UNAVALABLE_LIMIT_REACHED = "This development build is 
limited to %d documents, and %d connections";
-constexpr auto PAYLOAD_UNAVALABLE_LIMIT_REACHED = "This development build is 
limited to %d documents, and %d connections - to avoid the impression that it 
is suitable for deployment in large enterprises. To find out more about 
deploying and scaling %s checkout: <br/><a href=\"%s\">%s</a>.";
+constexpr auto SERVICE_UNAVALABLE_LIMIT_REACHED = "error: cmd=socket 
kind=close code=%d";
+constexpr auto PAYLOAD_UNAVALABLE_LIMIT_REACHED = "error: cmd=socket 
kind=limitreached params=%d,%d";
 
 #endif
 
diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt
index c22babf..65ad0a0 100644
--- a/loolwsd/protocol.txt
+++ b/loolwsd/protocol.txt
@@ -207,7 +207,7 @@ 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> [code=<error_code>]
+error: cmd=<command> kind=<kind> [code=<error_code>] [params=1,2,3,...,N]
 <freeErrorText>
 
     <command> is the command part of the corresponding client->server
diff --git a/loolwsd/test/httpwserror.cpp b/loolwsd/test/httpwserror.cpp
index a7f8385..8e7769d 100644
--- a/loolwsd/test/httpwserror.cpp
+++ b/loolwsd/test/httpwserror.cpp
@@ -102,8 +102,8 @@ void HTTPWSError::testMaxDocuments()
         sendTextFrame(socket, "load ");
         sendTextFrame(socket, "partpagerectangles ");
         statusCode = getErrorCode(socket, message);
-        
CPPUNIT_ASSERT_EQUAL(static_cast<Poco::UInt16>(Poco::Net::WebSocket::WS_ENDPOINT_GOING_AWAY),
 statusCode);
-        CPPUNIT_ASSERT_MESSAGE("Wrong error message ", message.find("This 
development build") != std::string::npos);
+        
CPPUNIT_ASSERT_EQUAL(static_cast<Poco::UInt16>(Poco::Net::WebSocket::WS_POLICY_VIOLATION),
 statusCode);
+        CPPUNIT_ASSERT_MESSAGE("Wrong error message ", message.find("error: 
cmd=socket kind=close") != std::string::npos);
     }
     catch (const Poco::Exception& exc)
     {
@@ -143,8 +143,8 @@ void HTTPWSError::testMaxConnections()
         sendTextFrame(socketN, "load ");
         sendTextFrame(socketN, "partpagerectangles ");
         statusCode = getErrorCode(*socketN, message);
-        
CPPUNIT_ASSERT_EQUAL(static_cast<Poco::UInt16>(Poco::Net::WebSocket::WS_ENDPOINT_GOING_AWAY),
 statusCode);
-        CPPUNIT_ASSERT_MESSAGE("Wrong error message ", message.find("This 
development build") != std::string::npos);
+        
CPPUNIT_ASSERT_EQUAL(static_cast<Poco::UInt16>(Poco::Net::WebSocket::WS_POLICY_VIOLATION),
 statusCode);
+        CPPUNIT_ASSERT_MESSAGE("Wrong error message ", message.find("error: 
cmd=socket kind=close") != std::string::npos);
     }
     catch (const Poco::Exception& exc)
     {
commit ef2a8ee99fe632274d00550bcc5fa47a6e32db9d
Author: Henry Castro <hcas...@collabora.com>
Date:   Sat Oct 1 11:19:20 2016 -0400

    loolwsd: .gitignore unittest

diff --git a/loolwsd/.gitignore b/loolwsd/.gitignore
index 4cdd66b..d98297b 100644
--- a/loolwsd/.gitignore
+++ b/loolwsd/.gitignore
@@ -55,3 +55,4 @@ looltool
 loolstress
 loolforkit-nocaps
 loadtest
+unittest
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to