[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - 2 commits - wsd/Admin.cpp wsd/Admin.hpp wsd/AdminModel.cpp

Jérémie Lesage jeremie.lesage at jeci.fr
Tue Jul 3 14:29:17 UTC 2018


 wsd/Admin.cpp      |   35 ++++++++++++++++++++---------------
 wsd/Admin.hpp      |    4 ++++
 wsd/AdminModel.cpp |    1 +
 3 files changed, 25 insertions(+), 15 deletions(-)

New commits:
commit 907601ac5dc61694bdff049113dea656dcc7752b
Author: Jérémie Lesage <jeremie.lesage at jeci.fr>
Date:   Thu Jun 28 21:42:07 2018 +0200

    add docKey in documents response
    
    (cherry picked from commit 238b754f2b459ee1682c3a2ff6b6c7dd36f94fe4)

diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp
index 4b52ab82b..010e7b845 100644
--- a/wsd/AdminModel.cpp
+++ b/wsd/AdminModel.cpp
@@ -662,6 +662,7 @@ std::string AdminModel::getDocuments() const
             Poco::URI::encode(it.second.getFilename(), " ", encodedFilename);
             oss << separator1 << '{' << ' '
                 << "\"pid\"" << ':' << it.second.getPid() << ','
+                << "\"docKey\"" << ':' << '"' << it.second.getDocKey() << '"' << ','
                 << "\"fileName\"" << ':' << '"' << encodedFilename << '"' << ','
                 << "\"activeViews\"" << ':' << it.second.getActiveViews() << ','
                 << "\"memory\"" << ':' << it.second.getMemoryDirty() << ','
commit 70817f86b35cba7feb06d744623dbf640dec58cf
Author: Jérémie Lesage <jeremie.lesage at jeci.fr>
Date:   Thu Jun 21 15:32:53 2018 +0200

    Ensure all sessions have a sessionId and are subscribed.
    
    Simplify constructors, and factor out subscription code.
    
    Change-Id: I4f3ed1eb06abec193d6db1f7c78815ffe1e1b5aa
    (cherry picked from commit f084ea53f6b659316e30af31e898aaf77d622add)

diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index a48040d6a..9c24d2007 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -269,24 +269,23 @@ void AdminSocketHandler::handleMessage(bool /* fin */, WSOpCode /* code */,
     }
 }
 
-/// Connection from remote admin socket
 AdminSocketHandler::AdminSocketHandler(Admin* adminManager,
                                        const std::weak_ptr<StreamSocket>& socket,
                                        const Poco::Net::HTTPRequest& request)
     : WebSocketHandler(socket, request),
       _admin(adminManager),
-      _sessionId(0),
       _isAuthenticated(false)
 {
+    // Different session id pool for admin sessions (?)
+    _sessionId = Util::decodeId(LOOLWSD::GenSessionId());
 }
 
-/// Client connection to remote amdin socket
 AdminSocketHandler::AdminSocketHandler(Admin* adminManager)
     : WebSocketHandler(true),
       _admin(adminManager),
-      _sessionId(0),
       _isAuthenticated(true)
 {
+    _sessionId = Util::decodeId(LOOLWSD::GenSessionId());
 }
 
 void AdminSocketHandler::sendTextFrame(const std::string& message)
@@ -301,6 +300,17 @@ void AdminSocketHandler::sendTextFrame(const std::string& message)
         LOG_TRC("Skip sending message to non-authenticated client: '" << message << "'");
 }
 
+void AdminSocketHandler::subscribeAsync(const std::shared_ptr<AdminSocketHandler> handler)
+{
+    Admin &admin = Admin::instance();
+
+    admin.addCallback([handler]
+        {
+            Admin &adminIn = Admin::instance();
+            adminIn.getModel().subscribe(handler->_sessionId, handler);
+        });
+}
+
 bool AdminSocketHandler::handleInitialRequest(
     const std::weak_ptr<StreamSocket> &socketWeak,
     const Poco::Net::HTTPRequest& request)
@@ -313,9 +323,6 @@ bool AdminSocketHandler::handleInitialRequest(
 
     std::shared_ptr<StreamSocket> socket = socketWeak.lock();
 
-    // Different session id pool for admin sessions (?)
-    const auto sessionId = Util::decodeId(LOOLWSD::GenSessionId());
-
     const std::string& requestURI = request.getURI();
     StringTokenizer pathTokens(requestURI, "/", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
 
@@ -324,13 +331,9 @@ bool AdminSocketHandler::handleInitialRequest(
         Admin &admin = Admin::instance();
         auto handler = std::make_shared<AdminSocketHandler>(&admin, socketWeak, request);
         socket->setHandler(handler);
-        admin.addCallback([handler, sessionId]
-        {
-            Admin &adminIn = Admin::instance();
-            AdminModel& model = adminIn.getModel();
-            handler->_sessionId = sessionId;
-            model.subscribe(sessionId, handler);
-        });
+
+        AdminSocketHandler::subscribeAsync(handler);
+
         return true;
     }
 
@@ -678,7 +681,9 @@ public:
 void Admin::connectToMonitorSync(const std::string &uri)
 {
     LOG_TRC("Add monitor " << uri);
-    insertNewWebSocketSync(Poco::URI(uri), std::make_shared<MonitorSocketHandler>(this, uri));
+    auto handler = std::make_shared<MonitorSocketHandler>(this, uri);
+    insertNewWebSocketSync(Poco::URI(uri), handler);
+    AdminSocketHandler::subscribeAsync(handler);
 }
 
 void Admin::scheduleMonitorConnect(const std::string &uri, std::chrono::steady_clock::time_point when)
diff --git a/wsd/Admin.hpp b/wsd/Admin.hpp
index 64dedbc20..12c866ece 100644
--- a/wsd/Admin.hpp
+++ b/wsd/Admin.hpp
@@ -23,8 +23,10 @@ class Admin;
 class AdminSocketHandler : public WebSocketHandler
 {
 public:
+    /// Client connection to remote amdin socket
     AdminSocketHandler(Admin* adminManager);
 
+    /// Connection from remote admin socket
     AdminSocketHandler(Admin* adminManager,
                        const std::weak_ptr<StreamSocket>& socket,
                        const Poco::Net::HTTPRequest& request);
@@ -34,6 +36,8 @@ public:
     static bool handleInitialRequest(const std::weak_ptr<StreamSocket> &socket,
                                      const Poco::Net::HTTPRequest& request);
 
+    static void subscribeAsync(const std::shared_ptr<AdminSocketHandler> handler);
+
 private:
     /// Sends text frames simply to authenticated clients.
     void sendTextFrame(const std::string& message);


More information about the Libreoffice-commits mailing list