[Libreoffice-commits] online.git: 2 commits - loleaflet/js wsd/FileServer.cpp wsd/LOOLWSD.cpp
loleaflet/js/global.js | 16 +--- wsd/FileServer.cpp | 27 +-- wsd/LOOLWSD.cpp|2 +- 3 files changed, 39 insertions(+), 6 deletions(-) New commits: commit 5721f5855094f3408ad7426cf477415c2263fc0b Author: Michael Meeks AuthorDate: Tue Apr 28 15:18:24 2020 +0100 Commit: Michael Meeks CommitDate: Tue Apr 28 16:37:37 2020 +0200 Improve error handling on failure to fetch session id. Change-Id: I8314fad3566f70abab78a6592a99d70597e40706 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93078 Tested-by: Jenkins CollaboraOffice Reviewed-by: Michael Meeks diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js index 1e09a86e0..c3c8343ad 100644 --- a/loleaflet/js/global.js +++ b/loleaflet/js/global.js @@ -311,9 +311,19 @@ req.responseType = 'text'; req.addEventListener('load', function() { console.debug('got session: ' + this.responseText); - that.sessionId = this.responseText; - that.readyState = 1; - that.onopen(); + if (this.responseText.indexOf('\n') >= 0) + { + console.debug('Error: failed to fetch session id!'); + that.onerror(); + that.onclose(); + that.readyState = 3; + } + else + { + that.sessionId = this.responseText; + that.readyState = 1; + that.onopen(); + } }); req.send(''); }; commit c9ed710518725872a583ea31cac3b60178daa540 Author: Michael Meeks AuthorDate: Tue Apr 28 15:17:23 2020 +0100 Commit: Michael Meeks CommitDate: Tue Apr 28 16:37:29 2020 +0200 Proxy: convert ProxyPrefix to a full URL. Thus encoding the actual proxy's http/https state. Change-Id: Ia7d5b8fb9379364b6c10a2c84d609f49e215ccb1 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93077 Tested-by: Jenkins CollaboraOffice Reviewed-by: Michael Meeks diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp index 8073860c2..99ac332b3 100644 --- a/wsd/FileServer.cpp +++ b/wsd/FileServer.cpp @@ -647,15 +647,38 @@ namespace { if (!request.has("ProxyPrefix")) return LOOLWSD::ServiceRoot; std::string proxyPrefix = request.get("ProxyPrefix", ""); + +// skip url to the root path. +size_t pos = proxyPrefix.find("://"); +if (pos != std::string::npos) { +pos = proxyPrefix.find("/", pos + 3); +if (pos != std::string::npos) +proxyPrefix = proxyPrefix.substr(pos); +else +LOG_DBG("Unusual proxy prefix '" << proxyPrefix << "'"); +} else +LOG_DBG("No http[s]:// in unusual proxy prefix '" << proxyPrefix); return proxyPrefix; } + +std::string getWebSocketUrl(const HTTPRequest ) +{ +bool ssl = (LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()); +std::string proxyPrefix = request.get("ProxyPrefix", ""); +std::string serverName = LOOLWSD::ServerName.empty() ? request.getHost() : LOOLWSD::ServerName; +if (proxyPrefix.size() > 0) +{ +ssl = !strcmp(proxyPrefix.c_str(), "https://;); +serverName = request.getHost(); +} +return (ssl ? "wss://" : "ws://") + serverName; +} } void FileServerRequestHandler::preprocessFile(const HTTPRequest& request, Poco::MemoryInputStream& message, const std::shared_ptr& socket) { -const auto host = ((LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()) ? "wss://" : "ws://") -+ (LOOLWSD::ServerName.empty() ? request.getHost() : LOOLWSD::ServerName); +const auto host = getWebSocketUrl(request); const Poco::URI::QueryParameters params = Poco::URI(request.getURI()).getQueryParameters(); // Is this a file we read at startup - if not; its not for serving. diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index b996c9877..329051698 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -2504,7 +2504,7 @@ private: + (LOOLWSD::ServerName.empty() ? request.getHost() : LOOLWSD::ServerName) + LOOLWSD::ServiceRoot; if (request.has("ProxyPrefix")) -srvUrl += request["ProxyPrefix"]; +srvUrl = request["ProxyPrefix"]; Poco::replaceInPlace(xml, std::string("%SRV_URI%"), srvUrl); // TODO: Refactor this to some
[Libreoffice-commits] online.git: 2 commits - loleaflet/js net/WebSocketHandler.hpp tools/WebSocketDump.cpp wsd/Admin.cpp wsd/ClientSession.cpp wsd/LOOLWSD.cpp wsd/TileCache.cpp
loleaflet/js/global.js | 27 net/WebSocketHandler.hpp | 19 tools/WebSocketDump.cpp |6 ++ wsd/Admin.cpp|5 ++ wsd/ClientSession.cpp|4 + wsd/LOOLWSD.cpp | 100 +-- wsd/TileCache.cpp|4 + 7 files changed, 116 insertions(+), 49 deletions(-) New commits: commit 5b9f0927488243b6af8a6d9e0f88c1dcc100b41e Author: Michael Meeks AuthorDate: Fri Mar 20 19:05:48 2020 + Commit: Jan Holesovsky CommitDate: Fri Apr 24 15:39:25 2020 +0200 Proxy: re-write css image URLs to handle the proxy. Change-Id: I09f3dea2f5e3a51869d5b0aa3f473d8f3ba75f44 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92808 Tested-by: Jenkins CollaboraOffice Reviewed-by: Jan Holesovsky diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js index f5c038b91..023a8bf7c 100644 --- a/loleaflet/js/global.js +++ b/loleaflet/js/global.js @@ -335,6 +335,33 @@ }, 250); }; + if (global.socketProxy) + { + // re-write relative URLs in CSS - somewhat grim. + window.addEventListener('load', function() { + var sheets = document.styleSheets; + for (var i = 0; i < sheets.length; ++i) { + var relBases = sheets[i].href.split('/'); + relBases.pop(); // bin last - css name. + var replaceBase = 'url("' + relBases.join('/') + '/images/'; + + var rules = sheets[i].cssRules || sheets[i].rules; + for (var r = 0; r < rules.length; ++r) { + if (!rules[r] || !rules[r].style) + continue; + var img = rules[r].style.backgroundImage; + if (img === '' || img === undefined) + continue; + if (img.startsWith('url("images/')) + { + rules[r].style.backgroundImage = + img.replace('url("images/', replaceBase); + } + } + } + }, false); + } + global.createWebSocket = function(uri) { if (global.socketProxy) { return new global.ProxySocket(uri); commit df6d942d08dfb5e8fffed015edf4c0eb5ce6f65e Author: Ashod Nakashian AuthorDate: Sun Apr 19 14:46:01 2020 -0400 Commit: Ashod Nakashian CommitDate: Fri Apr 24 15:39:17 2020 +0200 wsd: harden socket weakptr Weak pointers can be null and must be checked before using. This fixes at least one segfault and prevents a number of others. Also, minimizes locking of weak pointers in the message handlers. Change-Id: I306501c26c3441d7bd6812d51fa17e7356126f32 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92828 Reviewed-by: Michael Meeks Tested-by: Jenkins CollaboraOffice diff --git a/net/WebSocketHandler.hpp b/net/WebSocketHandler.hpp index 46a2916a7..a329e7711 100644 --- a/net/WebSocketHandler.hpp +++ b/net/WebSocketHandler.hpp @@ -122,7 +122,7 @@ public: void sendCloseFrame(const StatusCodes statusCode = StatusCodes::NORMAL_CLOSE, const std::string& statusMessage = "") { std::shared_ptr socket = _socket.lock(); -if (socket == nullptr) +if (!socket) { LOG_ERR("No socket associated with WebSocketHandler " << this); return; @@ -404,23 +404,21 @@ public: /// Implementation of the ProtocolHandlerInterface. virtual void handleIncomingMessage(SocketDisposition&) override { -// LOG_TRC("* WebSocketHandler::handleIncomingMessage()"); - std::shared_ptr socket = _socket.lock(); #if MOBILEAPP // No separate "upgrade" is going on -if (socket != nullptr && !socket->isWebSocket()) +if (socket && !socket->isWebSocket()) socket->setWebSocket(); #endif -if (socket == nullptr) +if (!socket) { LOG_ERR("No socket associated with WebSocketHandler " << this); } #if !MOBILEAPP else if (_isClient && !socket->isWebSocket()) -handleClientUpgrade(); +handleClientUpgrade(socket); #endif else { @@ -694,7 +692,7 @@ protected: void upgradeToWebSocket(const Poco::Net::HTTPRequest& req) { std::shared_ptr socket = _socket.lock(); -if (socket == nullptr) +if (!socket) throw std::runtime_error("Invalid socket while upgrading to WebSocket. Request: " +
[Libreoffice-commits] online.git: 2 commits - loleaflet/js loleaflet/src
loleaflet/js/global.js|2 +- loleaflet/src/control/Control.Menubar.js | 12 ++-- loleaflet/src/control/Control.PartsPreview.js |6 +++--- loleaflet/src/control/Control.Toolbar.js |4 ++-- loleaflet/src/control/Permission.js |6 +++--- loleaflet/src/layer/AnnotationManager.js |2 +- loleaflet/src/layer/marker/Annotation.js |2 +- loleaflet/src/layer/tile/CalcTileLayer.js |2 +- loleaflet/src/layer/tile/GridLayer.js |2 +- loleaflet/src/layer/tile/ImpressTileLayer.js |2 +- loleaflet/src/layer/tile/WriterTileLayer.js |2 +- loleaflet/src/map/Clipboard.js|2 +- loleaflet/src/map/Map.js | 20 ++-- 13 files changed, 32 insertions(+), 32 deletions(-) New commits: commit f070a0ffd4450932e27b41ef3bdb1d86705cf694 Author: Jan Holesovsky AuthorDate: Wed Apr 8 14:15:22 2020 +0200 Commit: Jan Holesovsky CommitDate: Fri Apr 10 13:12:07 2020 +0200 mobile, tablet: Even the small tablets or large phones should get the phone UI. There is clearly not enough space for the normal sidebar when one of the dimensions is below 768. Change-Id: Iac27f12f837b9e6a64d1cce7b8376009bbe2c15f Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92004 Tested-by: Jenkins CollaboraOffice Reviewed-by: Jan Holesovsky diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js index a4fd77bab..3022d94a3 100644 --- a/loleaflet/js/global.js +++ b/loleaflet/js/global.js @@ -149,7 +149,7 @@ return true; } - return L.Browser.mobile && screen.width < 768; + return L.Browser.mobile && (screen.width < 768 || screen.height < 768); }, // Mobile device with big screen size. isTablet: function() { commit 7725c7f309f343c8db0ed19adfbfd667bf66573f Author: Jan Holesovsky AuthorDate: Wed Apr 8 13:32:59 2020 +0200 Commit: Jan Holesovsky CommitDate: Fri Apr 10 13:11:52 2020 +0200 mobile: Never use L.Browser.mobile, instead use window.mode.isXYZ(). The L.Browser detects the browser capabilities, but the window.mode.isMobile()/isTablet()/isDesktop() is what decides what form factor are we targeting in the particular instance of the Online. This commit tries to kill convert the L.Browser.mobile checks into the appropriate window.mode.isXYZ(), hope I got the intention right on most of the places - it wouldn't be correct to blindly convert everything to (isMobile() || isTablet()). Change-Id: I57430058ec15deb5f67f9c645d234f998fbf539d Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92003 Tested-by: Jenkins CollaboraOffice Reviewed-by: Jan Holesovsky diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js index f7aa69111..dac5d07d2 100644 --- a/loleaflet/src/control/Control.Menubar.js +++ b/loleaflet/src/control/Control.Menubar.js @@ -841,7 +841,7 @@ L.Control.Menubar = L.Control.extend({ var pageStyles = e.commandValues['HeaderFooter']; for (var iterator in pageStyles) { style = pageStyles[iterator]; - if (!L.Browser.mobile) { + if (!window.mode.isMobile()) { $menuHeader.append(this._createUnoMenuItem(_(style), constHeader + encodeURIComponent(style) + constArg, style)); $menuFooter.append(this._createUnoMenuItem(_(style), constFooter + encodeURIComponent(style) + constArg, style)); } else { @@ -897,12 +897,12 @@ L.Control.Menubar = L.Control.extend({ var $nav = $menu.parent(); if (this.checked) { self._map.fire('closesidebar'); - if (!L.Browser.mobile) { + if (!window.mode.isMobile()) { // Surely this code, if it really is related only to the hamburger menu, // will never be invoked on non-mobile browsers? I might be wrong though. // If you notice this logging, please modify this comment to indicate what is // going on. - console.log('==> Assertion failed!? Not L.Browser.mobile? Control.Menubar.js #1'); + console.log('==> Assertion failed!? Not
[Libreoffice-commits] online.git: 2 commits - loleaflet/js
loleaflet/js/jquery.mCustomScrollbar.js | 44 +--- 1 file changed, 24 insertions(+), 20 deletions(-) New commits: commit 59d3c2d20da32049b62293c01a5329e07bac0895 Author: Henry Castro AuthorDate: Fri Nov 15 10:14:25 2019 -0400 Commit: Henry Castro CommitDate: Sat Nov 16 19:28:13 2019 +0100 mCustomScrollbar: remove unnecessary access to Window top property When the frame is null, it is referring to a container frame window that it is always not accessible. Change-Id: Ie96a05327928b2b72ce5577409e368061b2afa1e Reviewed-on: https://gerrit.libreoffice.org/82798 Reviewed-by: Henry Castro Tested-by: Henry Castro diff --git a/loleaflet/js/jquery.mCustomScrollbar.js b/loleaflet/js/jquery.mCustomScrollbar.js index d91b86108..b2c91c88e 100644 --- a/loleaflet/js/jquery.mCustomScrollbar.js +++ b/loleaflet/js/jquery.mCustomScrollbar.js @@ -1544,10 +1544,6 @@ and dependencies (minified). _canAccessIFrame=function(iframe){ var html=null; if(!iframe){ - try{ - var doc=top.document; - html=doc.body.innerHTML; - }catch(err){/* do nothing */} return(html!==null); }else{ try{ commit cb7813ef351fd44b265f96bdb646cb4cfe89fd65 Author: Henry Castro AuthorDate: Fri Nov 15 09:18:32 2019 -0400 Commit: Henry Castro CommitDate: Sat Nov 16 19:28:01 2019 +0100 mCustomScrollbar: reduce the number of _coordinates function calls The _coordinates function is called several times to compute the same coordinate value. Change-Id: I6e187b74709515ddde77d60649e564cb2b484fb4 Reviewed-on: https://gerrit.libreoffice.org/82797 Reviewed-by: Henry Castro Tested-by: Henry Castro diff --git a/loleaflet/js/jquery.mCustomScrollbar.js b/loleaflet/js/jquery.mCustomScrollbar.js index 14bf9d9a2..d91b86108 100644 --- a/loleaflet/js/jquery.mCustomScrollbar.js +++ b/loleaflet/js/jquery.mCustomScrollbar.js @@ -1218,7 +1218,8 @@ and dependencies (minified). _iframe(false); /* enable scrollbar dragging over iframes by disabling their events */ _stop($this); draggable=$(this); - var offset=draggable.offset(),y=_coordinates(e)[0]-offset.top,x=_coordinates(e)[1]-offset.left, + var coordinates = _coordinates(e); + var offset=draggable.offset(),y=coordinates[0]-offset.top,x=coordinates[1]-offset.left, h=draggable.height()+offset.top,w=draggable.width()+offset.left; if(y0 && x0){ dragY=y; @@ -1228,12 +1229,14 @@ and dependencies (minified). }).bind("touchmove."+namespace,function(e){ e.stopImmediatePropagation(); e.preventDefault(); - var offset=draggable.offset(),y=_coordinates(e)[0]-offset.top,x=_coordinates(e)[1]-offset.left; + var coordinates = _coordinates(e); + var offset=draggable.offset(),y=coordinates[0]-offset.top,x=coordinates[1]-offset.left; _drag(dragY,dragX,y,x); }); $(document).add(eds).bind("mousemove."+namespace+" pointermove."+namespace+" MSPointerMove."+namespace,function(e){ if(draggable){ - var offset=draggable.offset(),y=_coordinates(e)[0]-offset.top,x=_coordinates(e)[1]-offset.left; + var coordinates = _coordinates(e); + var offset=draggable.offset(),y=coordinates[0]-offset.top,x=coordinates[1]-offset.left; if(dragY===y && dragX===x){return;} /* has it really moved? */ _drag(dragY,dragX,y,x); } @@ -1313,26 +1316,28 @@ and dependencies (minified). }); } function _onTouchstart(e){ - if(!_pointerTouch(e) || touchActive || _coordinates(e)[2]){touchable=0; return;} + var coordinates = _coordinates(e); + if(!_pointerTouch(e) || touchActive || coordinates[2]){touchable=0; return;} touchable=1; touchDrag=0; docDrag=0; draggable=1; $this.removeClass("mCS_touch_action");
[Libreoffice-commits] online.git: 2 commits - loleaflet/js wsd/ClientSession.cpp wsd/FileServer.cpp wsd/LOOLWSD.cpp
loleaflet/js/global.js | 25 + wsd/ClientSession.cpp |6 ++ wsd/FileServer.cpp | 19 +-- wsd/LOOLWSD.cpp|2 -- 4 files changed, 48 insertions(+), 4 deletions(-) New commits: commit 3c1a130004845c99a159d634eb79474ff3c8d353 Author: Henry Castro AuthorDate: Tue Aug 20 12:21:25 2019 -0400 Commit: Henry Castro CommitDate: Tue Aug 20 18:24:15 2019 +0200 wsd: fix build, with argument "--disable-ssl" wsd/LOOLWSD.cpp:1034:14: error: ‘SSLEnabled’ is not a member of ‘LOOLWSD’ wsd/LOOLWSD.cpp:1049:14: error: ‘SSLTermination’ is not a member of ‘LOOLWSD’ Change-Id: I3e81431ef56f46a844733b797b4c443a77afeb6e Reviewed-on: https://gerrit.libreoffice.org/77850 Reviewed-by: Henry Castro Tested-by: Henry Castro diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index e0518479d..7fa2072e7 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -1030,7 +1030,6 @@ void LOOLWSD::initialize(Application& self) #if ENABLE_SSL LOOLWSD::SSLEnabled.set(getConfigValue(conf, "ssl.enable", true)); -#else LOOLWSD::SSLEnabled.set(false); #endif @@ -1045,7 +1044,6 @@ void LOOLWSD::initialize(Application& self) #if ENABLE_SSL LOOLWSD::SSLTermination.set(getConfigValue(conf, "ssl.termination", true)); -#else LOOLWSD::SSLTermination.set(false); #endif commit 2872bc7be91aabb1bcecbe5f8c761e917115f43d Author: Henry Castro AuthorDate: Mon Jul 1 20:25:10 2019 -0400 Commit: Henry Castro CommitDate: Tue Aug 20 18:24:04 2019 +0200 post logs JavaScript runtime errors to the loolwsd server Change-Id: Ic8ccff52d2f051ea6d31b6d2bfe08fc08ea4d8c2 Reviewed-on: https://gerrit.libreoffice.org/77849 Reviewed-by: Henry Castro Tested-by: Henry Castro diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js index c1d6b9f9e..a8e5eb8f5 100644 --- a/loleaflet/js/global.js +++ b/loleaflet/js/global.js @@ -36,6 +36,31 @@ for (var i = 0; i < methods.length; i++) { console[methods[i]] = function() {}; } + } else { + window.onerror = function (msg, src, row, col, err) { + var data = { + userAgent: navigator.userAgent.toLowerCase(), + vendor: navigator.vendor.toLowerCase(), + message: msg, + source: src, + line: row, + column: col + }, desc = err.message || {}, stack = err.stack || {}; + var log = 'jserror ' + JSON.stringify(data, null, 2) + '\n' + desc + '\n' + stack + '\n'; + if (global.socket && (global.socket instanceof WebSocket) && global.socket.readyState === 1) { + global.socket.send(log); + } else if (global.socket && (global.socket instanceof global.L.Socket) && global.socket.connected()) { + global.socket.sendMessage(log); + } else { + var req = new XMLHttpRequest(); + var url = global.location.protocol + '//' + global.location.host + global.location.pathname.match(/.*\//) + 'logging.html'; + req.open('POST', url, true); + req.setRequestHeader('Content-type','application/json; charset=utf-8'); + req.send(log); + } + + return false; + } } // fix jquery-ui diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index 56f2a3443..00ca2d506 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -361,6 +361,12 @@ bool ClientSession::_handleInput(const char *buffer, int length) return true; } + +if (tokens[0] == "jserror") +{ +LOG_ERR(std::string(buffer, length)); +return true; +} else if (tokens[0] == "load") { if (getDocURL() != "") diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp index f51c67f6c..bfde038c9 100644 --- a/wsd/FileServer.cpp +++ b/wsd/FileServer.cpp @@ -284,13 +284,28 @@ void FileServerRequestHandler::handleRequest(const HTTPRequest& request, Poco::M std::vector requestSegments; requestUri.getPathSegments(requestSegments); const std::string relPath = getRequestPathname(request); +const std::string endPoint = requestSegments[requestSegments.size() - 1]; +const auto& config = Application::instance().config(); + +if (request.getMethod() == HTTPRequest::HTTP_POST && endPoint == "logging.html") +{ +const std::string loleafletLogging = config.getString("loleaflet_logging", "false"); +if (loleafletLogging != "false") +{ +
[Libreoffice-commits] online.git: 2 commits - loleaflet/js loleaflet/src
loleaflet/js/global.js | 11 +++ loleaflet/src/core/Socket.js | 29 + 2 files changed, 12 insertions(+), 28 deletions(-) New commits: commit f5791f9e1f7b4c77cba62158fe342c248f715284 Author: Tor Lillqvist AuthorDate: Wed Mar 6 15:29:17 2019 +0200 Commit: Tor Lillqvist CommitDate: Wed Mar 6 15:30:49 2019 +0200 Send the HULLO message to the mobile app native code already in global.js Apparently the connect() function in Socket.js is now dead code? Now the iOS app seems to work as before. Change-Id: Ib6c2b9a08e818ec8f4b5dbdfbf75f507c4bb7069 diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js index bc1e96e05..3057361af 100644 --- a/loleaflet/js/global.js +++ b/loleaflet/js/global.js @@ -134,5 +134,16 @@ } global.socket.binaryType = 'arraybuffer'; + + if (window.ThisIsAMobileApp) { + // This corresponds to the initial GET request when creating a WebSocket + // connection and tells the app's code that it is OK to start invoking + // TheFakeWebSocket's onmessage handler. The app code that handles this + // special message knows the document to be edited anyway, and can send it + // on as necessary to the Online code. + window.postMobileMessage('HULLO'); + // A FakeWebSocket is immediately open. + this.socket.onopen(); + } } }(window)); commit 9dee58271840f0f6167b9ad1377d60a40097cbf3 Author: Tor Lillqvist AuthorDate: Wed Mar 6 15:28:25 2019 +0200 Commit: Tor Lillqvist CommitDate: Wed Mar 6 15:28:54 2019 +0200 Bin the now duplicate and unnecessary FakeWebSocket things in Socket.js global.js now defines windows.FakeWebSocket. Change-Id: I9a430a684769ab071838e4e3e30372f26f761139 diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js index 3fe3cb2c7..5b0b4 100644 --- a/loleaflet/src/core/Socket.js +++ b/loleaflet/src/core/Socket.js @@ -5,33 +5,6 @@ /* global _ vex $ errorMessages Uint8Array brandProductName brandProductFAQURL */ -window.fakeWebSocketCounter = 0; -function FakeWebSocket() { - this.binaryType = 'arraybuffer'; - this.bufferedAmount = 0; - this.extensions = ''; - this.protocol = ''; - this.readyState = 1; - this.id = window.fakeWebSocketCounter++; - this.sendCounter = 0; - this.onclose = function() { - }; - this.onerror = function() { - }; - this.onmessage = function() { - }; - this.onopen = function() { - }; -} - -FakeWebSocket.prototype.close = function() { -} - -FakeWebSocket.prototype.send = function(data) { - this.sendCounter++; - window.postMobileMessage(data); -} - L.Socket = L.Class.extend({ ProtocolVersionNumber: '0.1', ReconnectCount: 0, @@ -59,7 +32,7 @@ L.Socket = L.Class.extend({ this.close(); } if (window.ThisIsAMobileApp) { - this.socket = new FakeWebSocket(); + this.socket = new window.FakeWebSocket(); window.TheFakeWebSocket = this.socket; } else { var wopiSrc = ''; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] online.git: 2 commits - loleaflet/js loleaflet/src
loleaflet/js/toolbar.js |3 loleaflet/src/control/Signing.js | 207 ++- 2 files changed, 123 insertions(+), 87 deletions(-) New commits: commit 8ddfbead3ca62146a316f1e7959a0c11b4a65075 Author: Tomaž Vajngerl AuthorDate: Tue Jan 1 22:00:52 2019 +0100 Commit: Tomaž Vajngerl CommitDate: Tue Jan 1 23:40:30 2019 +0100 add functions to get API, iframe and WOPI URL for Vereign Change-Id: Ib97b696f5a3965c4bdf6ddc79aa4cab196630ce2 Reviewed-on: https://gerrit.libreoffice.org/65785 Reviewed-by: Tomaž Vajngerl Tested-by: Tomaž Vajngerl diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js index 7c308c482..5f2bc61b8 100644 --- a/loleaflet/src/control/Signing.js +++ b/loleaflet/src/control/Signing.js @@ -29,6 +29,16 @@ function getVereignWopiURL() { return vereignURL + '/wopi/'; } +function getVereignApiURL() { + var vereignURL = window.documentSigningURL == null ? '' : window.documentSigningURL; + return vereignURL + '/api/'; +} + +function getVereignIFrameURL() { + var vereignURL = window.documentSigningURL == null ? '' : window.documentSigningURL; + return vereignURL + '/vcl/js/iframe'; +} + function randomName() { return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36); } @@ -495,8 +505,8 @@ L.Map.include({ } } }, - vereignURL + '/vcl/js/iframe', - vereignURL + '/api/', + getVereignIFrameURL(), + getVereignApiURL(), getVereignWopiURL() ).then(function(lib) { library = lib; commit 4656bdcb38fef68410d4ce62517ccc9732cddba6 Author: Tomaž Vajngerl AuthorDate: Tue Jan 1 21:58:28 2019 +0100 Commit: Tomaž Vajngerl CommitDate: Tue Jan 1 23:40:18 2019 +0100 Combine Sign and Upload to one action First the document is signed, then when the signature status is returned, upload to Vereign. Change-Id: I02a3a3d401cffa295751483ba85bd45c22c7950f Reviewed-on: https://gerrit.libreoffice.org/65784 Reviewed-by: Tomaž Vajngerl Tested-by: Tomaž Vajngerl diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js index 0d7335049..7b42ae28a 100644 --- a/loleaflet/js/toolbar.js +++ b/loleaflet/js/toolbar.js @@ -1096,8 +1096,7 @@ function initNormalToolbar(toolItems) { items: [ {type: 'html', id: 'left'}, {type: 'html', id: 'logo', html: 'Vereign'}, - {type: 'button', id: 'sign', caption: _('Sign'), img: '', hint: _('Sign document')}, - {type: 'button', id: 'upload', caption: _('Upload'), img: '', hint: _('Upload document')}, + {type: 'button', id: 'sign-upload', caption: _('Sign & Upload'), img: '', hint: _('Sign and upload document')}, {type: 'break' }, {type: 'html', id: 'identity-label', html: '' + _('Identity:') + ''}, {type: 'html', id: 'identity', html: _('N/A')}, diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js index 1450d2615..7c308c482 100644 --- a/loleaflet/src/control/Signing.js +++ b/loleaflet/src/control/Signing.js @@ -14,6 +14,8 @@ var oldtoolbarSize = null; var _map = null; var currentDocumentSigningStatus = 'N/A' +var awaitForDocumentStatusToUpload = false; + function isSuccess(result) { return result.code == '200'; } @@ -22,6 +24,22 @@ function haveIdentity() { return identity != null; } +function getVereignWopiURL() { + var vereignURL = window.documentSigningURL == null ? '' : window.documentSigningURL; + return vereignURL + '/wopi/'; +} + +function randomName() { + return Math.random().toString(36).substring(2) + (new Date()).getTime().toString(36); +} + +function getCurrentDocumentFilename(documentType) { + var filename = _map['wopi'].BaseFileName; + if (!filename) + filename = randomName() + '.' + documentType; + return filename; +} + function updateIndentity() { if (library) { if (identity) { @@ -121,8 +139,7 @@ function adjustUIState() { if (currentPassport) { w2ui['document-signing-bar'].show('passport'); w2ui['document-signing-bar'].show('current-passport'); - w2ui['document-signing-bar'].show('sign'); - w2ui['document-signing-bar'].show('upload'); + w2ui['document-signing-bar'].show('sign-upload'); } else {
[Libreoffice-commits] online.git: 2 commits - loleaflet/js loleaflet/src
loleaflet/js/toolbar.js | 12 -- loleaflet/src/control/Signing.js | 46 --- 2 files changed, 48 insertions(+), 10 deletions(-) New commits: commit 77e67f44b968fd91d2e0b97d71f269bc77886cc3 Author: Tomaž Vajngerl AuthorDate: Thu Nov 15 09:47:37 2018 +0100 Commit: Tomaž Vajngerl CommitDate: Thu Nov 29 21:46:57 2018 +0100 separate lib. init. from login, show UI elements on state change It is needed to separate initialization of the library and login (the button) as you may already be logged in if you have credentials in the local storage (already logged in through vereign website for example). So behaviour now is either you get logged in immediately or you get a login button. There is a lot of state changes where various elements of the infobar are show or hidden. To make it easier to track the changes it is necessary to have showing/hiding at one function which is triggered every time a state change may occur. Change-Id: I0f36f342baaf80dc109f608e294b89a955a6572e Reviewed-on: https://gerrit.libreoffice.org/63413 Reviewed-by: Tomaž Vajngerl Tested-by: Tomaž Vajngerl diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js index c4c0ce685..15b91adeb 100644 --- a/loleaflet/js/toolbar.js +++ b/loleaflet/js/toolbar.js @@ -952,8 +952,8 @@ function initNormalToolbar(toolItems) { {type: 'html', id: 'logo', html: 'Vereign'}, {type: 'button', id: 'sign', caption: 'Sign', img: '', hint: _('Sign document')}, {type: 'break' }, - {type: 'html', id: 'user-label', html: 'User:'}, - {type: 'html', id: 'user', html: ''}, + {type: 'html', id: 'identity-label', html: 'Identity:'}, + {type: 'html', id: 'identity', html: 'N/A'}, {type: 'break' }, {type: 'button', id: 'logout', caption: 'Logout', img: '', hint: _('Logout')}, {type: 'button', id: 'login', caption: 'Login', img: '', hint: _('Login')}, @@ -1471,10 +1471,6 @@ function onDocLayerInit() { $('#spreadsheet-toolbar').hide(); $('#presentation-toolbar').hide(); - if (L.DomUtil.get('document-signing-bar') !== null) { - w2ui['document-signing-bar'].hide('logout'); - } - break; case 'presentation': var presentationToolbar = w2ui['presentation-toolbar']; @@ -1513,6 +1509,10 @@ function onDocLayerInit() { break; } + if (L.DomUtil.get('document-signing-bar') !== null) { + map.signingInitializeBar(); + } + if (L.Browser.mobile) { _mobilify(); nUsers = '%n'; diff --git a/loleaflet/src/control/Signing.js b/loleaflet/src/control/Signing.js index 6ee79bba8..ba656565f 100644 --- a/loleaflet/src/control/Signing.js +++ b/loleaflet/src/control/Signing.js @@ -17,22 +17,45 @@ function updateIndentity() { if (identity) { library.getIdentityProfile(identity.authentication.publicKey).then(function(result) { var initials = result.data.initials; - var color = result.data.identityColor; - console.log(initials + ' ' + color); - w2ui['document-signing-bar'].get('user').html = '' + initials + ''; + w2ui['document-signing-bar'].get('identity').html = '' + initials + ''; w2ui['document-signing-bar'].refresh(); }); } else { - w2ui['document-signing-bar'].get('user').html = ''; + w2ui['document-signing-bar'].get('identity').html = ''; w2ui['document-signing-bar'].refresh(); } } } +function adjustUIState() { + if (library && identity) { + w2ui['document-signing-bar'].hide('login'); + w2ui['document-signing-bar'].show('logout'); + w2ui['document-signing-bar'].show('identity-label'); + w2ui['document-signing-bar'].show('identity'); + w2ui['document-signing-bar'].show('sign'); + } + else { + if (library) + w2ui['document-signing-bar'].show('login'); + else + w2ui['document-signing-bar'].hide('login'); + + w2ui['document-signing-bar'].hide('logout'); + w2ui['document-signing-bar'].hide('identity-label'); + w2ui['document-signing-bar'].hide('identity'); +
[Libreoffice-commits] online.git: 2 commits - loleaflet/js loleaflet/src Mobile/Mobile Mobile/Mobile.xcodeproj
Mobile/Mobile.xcodeproj/project.pbxproj | 134 +++ Mobile/Mobile/Document.mm|1 Mobile/Mobile/DocumentViewController.mm | 49 +-- loleaflet/js/toolbar.js |8 + loleaflet/src/control/Control.Menubar.js |8 + 5 files changed, 186 insertions(+), 14 deletions(-) New commits: commit ed348677f22d887d80c76b5dcae22a109e457f72 Author: Tor Lillqvist AuthorDate: Fri Oct 12 17:48:45 2018 +0300 Commit: Tor Lillqvist CommitDate: Fri Oct 12 17:48:45 2018 +0300 Add "Close document" menu entry (or corresponding button) to the iOS app In the JS, send the special "BYE" message to the app code. In the iOS app code, handle that message by closing the fake socket connection to the Online code, which eventually will cause the corresponding thread to exit etc, and the app to return to displaying the DocumentBrowserViewController. (Currently it causes the whole app to exit which is wrong of course; an iOS should never exit intentionally.) diff --git a/Mobile/Mobile/Document.mm b/Mobile/Mobile/Document.mm index eadf653ec..e36b219e0 100644 --- a/Mobile/Mobile/Document.mm +++ b/Mobile/Mobile/Document.mm @@ -38,6 +38,7 @@ NSURL *url = [[NSBundle mainBundle] URLForResource:@"loleaflet" withExtension:@"html"]; NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO]; components.queryItems = @[ [NSURLQueryItem queryItemWithName:@"file_path" value:[NSString stringWithUTF8String:uri.c_str()]], + [NSURLQueryItem queryItemWithName:@"closebutton" value:@"1"], [NSURLQueryItem queryItemWithName:@"permission" value:@"edit"], [NSURLQueryItem queryItemWithName:@"debug" value:@"true"]]; NSURLRequest *request = [[NSURLRequest alloc]initWithURL:components.URL]; diff --git a/Mobile/Mobile/DocumentViewController.mm b/Mobile/Mobile/DocumentViewController.mm index 5f203fdef..fc7f2deee 100644 --- a/Mobile/Mobile/DocumentViewController.mm +++ b/Mobile/Mobile/DocumentViewController.mm @@ -19,7 +19,7 @@ #import "DocumentViewController.h" @interface DocumentViewController() { -BOOL waitingForInitialLoad; +int closeNotificationPipeForForwardingThread[2]; } @end @@ -157,20 +157,42 @@ rc = fakeSocketConnect(self.document->fakeClientFd, loolwsd_server_socket_fd); assert(rc != -1); +// Create a socket pair to notify the below thread when the document has been closed +fakeSocketPipe2(closeNotificationPipeForForwardingThread); + // Start another thread to read responses and forward them to the JavaScript dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ while (true) { - struct pollfd p; - p.fd = self.document->fakeClientFd; - p.events = POLLIN; - if (fakeSocketPoll(, 1, -1) == 1) { - int n = fakeSocketAvailableDataLength(self.document->fakeClientFd); - if (n == 0) + struct pollfd p[2]; + p[0].fd = self.document->fakeClientFd; + p[0].events = POLLIN; + p[1].fd = self->closeNotificationPipeForForwardingThread[1]; + p[1].events = POLLIN; + if (fakeSocketPoll(p, 2, -1) > 0) { + if (p[1].revents == POLLIN) { + // The code below handling the "BYE" fake Websocket + // message has closed the other end of the + // closeNotificationPipeForForwardingThread. Let's close + // the other end too just for cleanliness, even if a + // FakeSocket as such is not a system resource so nothing + // is saved by closing it. + fakeSocketClose(self->closeNotificationPipeForForwardingThread[0]); + + // Close our end of the fake socket connection to the + // ClientSession thread, so that it terminates + fakeSocketClose(self.document->fakeClientFd); + return; - std::vector buf(n); - n =