[Libreoffice-commits] online.git: loolwsd/ChildSession.cpp loolwsd/ChildSession.hpp loolwsd/ClientSession.cpp loolwsd/ClientSession.hpp loolwsd/DocumentBroker.cpp loolwsd/LOOLForKit.cpp loolwsd/LOOLKit.cpp loolwsd/PrisonerSession.cpp loolwsd/sysconfig.loolwsd loolwsd/test

Tor Lillqvist tml at collabora.com
Mon Sep 19 09:14:34 UTC 2016


 loolwsd/ChildSession.cpp    |   80 ++++++++---------------
 loolwsd/ChildSession.hpp    |    1 
 loolwsd/ClientSession.cpp   |   13 +--
 loolwsd/ClientSession.hpp   |    9 --
 loolwsd/DocumentBroker.cpp  |   77 ++++++++++------------
 loolwsd/LOOLForKit.cpp      |    3 
 loolwsd/LOOLKit.cpp         |   57 +++++-----------
 loolwsd/PrisonerSession.cpp |    3 
 loolwsd/sysconfig.loolwsd   |    1 
 loolwsd/test/httpwstest.cpp |  149 --------------------------------------------
 10 files changed, 90 insertions(+), 303 deletions(-)

New commits:
commit df3cc99025139e7e47e82d855b520df6a1548224
Author: Tor Lillqvist <tml at collabora.com>
Date:   Mon Sep 19 10:03:31 2016 +0300

    Don't require the LOK_VIEW_CALLLBACK env var any more
    
    Act as if it was always set.
    
    The ChildSession::_multiView field will always be true, so factor it
    out. Ditto for Document::_multiView.
    
    The ClientSession::_haveEditLock will also be always true, so factor
    it out. This means the ClientSession::isEditLocked() will always
    return true, so factor it out, too.
    
    ClientSession::markEditLock() always will always set _haveEditLock to
    true (which it will be from the constructor already anyway) so it can
    be removed.
    
    ClientSession::setEditLock() does not need a parameter as the
    parameter was actually only used for misleading logging. The msg
    variable constructed in the function used isEditLocked(), not the
    parameter.
    
    We still generate and handle editlock messages. Not sure whether that
    makes any sense, though.

diff --git a/loolwsd/ChildSession.cpp b/loolwsd/ChildSession.cpp
index 2e44eeb..a5a7778 100644
--- a/loolwsd/ChildSession.cpp
+++ b/loolwsd/ChildSession.cpp
@@ -39,7 +39,6 @@ ChildSession::ChildSession(const std::string& id,
                            const std::string& jailId,
                            IDocumentManager& docManager) :
     LOOLSession(id, Kind::ToMaster, ws),
-    _multiView(std::getenv("LOK_VIEW_CALLBACK")),
     _jailId(jailId),
     _docManager(docManager),
     _viewId(-1),
@@ -94,8 +93,7 @@ bool ChildSession::_handleInput(const char *buffer, int length)
         // Send invalidation and other sync-up messages.
         std::unique_lock<std::recursive_mutex> lock(Mutex); //TODO: Move to top of function?
 
-        if (_multiView)
-            _loKitDocument->setView(_viewId);
+        _loKitDocument->setView(_viewId);
 
         // Refresh the viewIds.
         sendTextFrame("remallviews:");
@@ -323,20 +321,17 @@ bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, StringT
         return false;
     }
 
-    if (_multiView)
-    {
-        std::ostringstream ossViewInfo;
-        const auto viewId = std::to_string(_viewId);
+    std::ostringstream ossViewInfo;
+    const auto viewId = std::to_string(_viewId);
 
-        // Create a message object
-        Object::Ptr viewInfoObj = new Object();
-        viewInfoObj->set("id", viewId);
-        viewInfoObj->set("username", _userName);
-        viewInfoObj->stringify(ossViewInfo);
+    // Create a message object
+    Object::Ptr viewInfoObj = new Object();
+    viewInfoObj->set("id", viewId);
+    viewInfoObj->set("username", _userName);
+    viewInfoObj->stringify(ossViewInfo);
 
-        Log::info("Created new view with viewid: [" + viewId + "] for username: [" + _userName + "].");
-        _docManager.notifyOtherSessions(getId(), "addview: " + ossViewInfo.str());
-    }
+    Log::info("Created new view with viewid: [" + viewId + "] for username: [" + _userName + "].");
+    _docManager.notifyOtherSessions(getId(), "addview: " + ossViewInfo.str());
 
     _docType = LOKitHelper::getDocumentTypeAsString(_loKitDocument->get());
     if (_docType != "text" && part != -1)
@@ -373,8 +368,7 @@ bool ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, Str
 
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-       _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     URI::decode(font, decodedFont);
     std::string response = "renderfont: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n";
@@ -403,8 +397,7 @@ bool ChildSession::getStatus(const char* /*buffer*/, int /*length*/)
 {
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-        _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     const auto status = LOKitHelper::documentStatus(_loKitDocument->get());
     if (status.empty())
@@ -429,8 +422,7 @@ bool ChildSession::getCommandValues(const char* /*buffer*/, int /*length*/, Stri
 
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-        _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     if (command == ".uno:DocumentRepair")
     {
@@ -456,8 +448,7 @@ bool ChildSession::getPartPageRectangles(const char* /*buffer*/, int /*length*/)
 {
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-        _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     char* partPage = _loKitDocument->getPartPageRectangles();
     sendTextFrame("partpagerectangles: " + std::string(partPage));
@@ -481,8 +472,7 @@ bool ChildSession::clientZoom(const char* /*buffer*/, int /*length*/, StringToke
 
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-        _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     _loKitDocument->setClientZoom(tilePixelWidth, tilePixelHeight, tileTwipWidth, tileTwipHeight);
     return true;
@@ -507,8 +497,7 @@ bool ChildSession::clientVisibleArea(const char* /*buffer*/, int /*length*/, Str
 
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-        _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     _loKitDocument->setClientVisibleArea(x, y, width, height);
     return true;
@@ -573,8 +562,7 @@ bool ChildSession::getTextSelection(const char* /*buffer*/, int /*length*/, Stri
 
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-        _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     char *textSelection = _loKitDocument->getTextSelection(mimeType.c_str(), nullptr);
 
@@ -600,8 +588,7 @@ bool ChildSession::paste(const char* buffer, int length, StringTokenizer& tokens
 
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-        _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     Log::info("Calling _loKit->paste()");
     _loKitDocument->paste(mimeType.c_str(), data, size);
@@ -633,8 +620,8 @@ bool ChildSession::insertFile(const char* /*buffer*/, int /*length*/, StringToke
                 "\"type\":\"string\","
                 "\"value\":\"" + fileName + "\""
             "}}";
-        if (_multiView)
-            _loKitDocument->setView(_viewId);
+
+        _loKitDocument->setView(_viewId);
 
         _loKitDocument->postUnoCommand(command.c_str(), arguments.c_str(), false);
     }
@@ -675,8 +662,7 @@ bool ChildSession::keyEvent(const char* /*buffer*/, int /*length*/, StringTokeni
 
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-        _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     _loKitDocument->postKeyEvent(type, charcode, keycode);
 
@@ -721,8 +707,7 @@ bool ChildSession::mouseEvent(const char* /*buffer*/, int /*length*/, StringToke
 
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-        _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     _loKitDocument->postMouseEvent(type, x, y, count, buttons, modifier);
 
@@ -739,8 +724,7 @@ bool ChildSession::unoCommand(const char* /*buffer*/, int /*length*/, StringToke
 
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-        _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     // we need to get LOK_CALLBACK_UNO_COMMAND_RESULT callback when saving
     const bool bNotify = (tokens[1] == ".uno:Save");
@@ -778,8 +762,7 @@ bool ChildSession::selectText(const char* /*buffer*/, int /*length*/, StringToke
 
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-        _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     _loKitDocument->setTextSelection(type, x, y);
 
@@ -804,8 +787,7 @@ bool ChildSession::selectGraphic(const char* /*buffer*/, int /*length*/, StringT
 
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-        _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     _loKitDocument->setGraphicSelection(type, x, y);
 
@@ -822,8 +804,7 @@ bool ChildSession::resetSelection(const char* /*buffer*/, int /*length*/, String
 
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-        _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     _loKitDocument->resetSelection();
 
@@ -853,8 +834,7 @@ bool ChildSession::saveAs(const char* /*buffer*/, int /*length*/, StringTokenize
 
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-        _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     bool success = _loKitDocument->saveAs(url.c_str(),
             format.size() == 0 ? nullptr :format.c_str(),
@@ -883,8 +863,7 @@ bool ChildSession::setClientPart(const char* /*buffer*/, int /*length*/, StringT
 
     if (part != _loKitDocument->getPart())
     {
-        if (_multiView)
-            _loKitDocument->setView(_viewId);
+        _loKitDocument->setView(_viewId);
 
         _loKitDocument->setPart(part);
     }
@@ -904,8 +883,7 @@ bool ChildSession::setPage(const char* /*buffer*/, int /*length*/, StringTokeniz
 
     std::unique_lock<std::recursive_mutex> lock(Mutex);
 
-    if (_multiView)
-        _loKitDocument->setView(_viewId);
+    _loKitDocument->setView(_viewId);
 
     _loKitDocument->setPart(page);
     return true;
diff --git a/loolwsd/ChildSession.hpp b/loolwsd/ChildSession.hpp
index 4cb7970..2528ef2 100644
--- a/loolwsd/ChildSession.hpp
+++ b/loolwsd/ChildSession.hpp
@@ -101,7 +101,6 @@ private:
     virtual bool _handleInput(const char *buffer, int length) override;
 
 private:
-    const bool _multiView;
     const std::string _jailId;
     IDocumentManager& _docManager;
 
diff --git a/loolwsd/ClientSession.cpp b/loolwsd/ClientSession.cpp
index 901d138..533844f 100644
--- a/loolwsd/ClientSession.cpp
+++ b/loolwsd/ClientSession.cpp
@@ -42,7 +42,6 @@ ClientSession::ClientSession(const std::string& id,
     LOOLSession(id, Kind::ToClient, ws),
     _docBroker(std::move(docBroker)),
     _queue(std::move(queue)),
-    _haveEditLock(std::getenv("LOK_VIEW_CALLBACK")),
     _isReadOnly(readOnly),
     _loadFailed(false),
     _loadPart(-1)
@@ -187,8 +186,8 @@ bool ClientSession::_handleInput(const char *buffer, int length)
             return false;
         }
 
-        // Allow 'downloadas' for all kinds of views irrespective of editlock
-        if ( (isReadOnly() || !isEditLocked()) && tokens[0] != "downloadas" &&
+        // Allow 'downloadas' for all kinds of views
+        if ( (isReadOnly()) && tokens[0] != "downloadas" &&
              tokens[0] != "userinactive" && tokens[0] != "useractive")
         {
             std::string dummyFrame = "dummymsg";
@@ -260,13 +259,11 @@ bool ClientSession::getStatus(const char *buffer, int length)
     return forwardToPeer(_peer, buffer, length, false);
 }
 
-bool ClientSession::setEditLock(const bool value)
+bool ClientSession::setEditLock()
 {
     // Update the sate and forward to child.
-    markEditLock(value);
-    const auto msg = "editlock: " + std::to_string(isEditLocked());
-    const auto mv = std::getenv("LOK_VIEW_CALLBACK") ? "1" : "0";
-    Log::debug("Forwarding [" + msg + "] to set editlock to " + std::to_string(value) + ". MultiView: " + mv);
+    const std::string msg = "editlock: 1";
+    Log::debug("Forwarding [" + msg + "] to set editlock to 1.");
     return forwardToPeer(_peer, msg.data(), msg.size(), false);
 }
 
diff --git a/loolwsd/ClientSession.hpp b/loolwsd/ClientSession.hpp
index f710088..e6f3098 100644
--- a/loolwsd/ClientSession.hpp
+++ b/loolwsd/ClientSession.hpp
@@ -28,9 +28,7 @@ public:
 
     virtual ~ClientSession();
 
-    bool setEditLock(const bool value);
-    void markEditLock(const bool value) { _haveEditLock = (value || std::getenv("LOK_VIEW_CALLBACK")); }
-    bool isEditLocked() const { return _haveEditLock; }
+    bool setEditLock();
     bool isReadOnly() const { return _isReadOnly; }
 
     void setPeer(const std::shared_ptr<PrisonerSession>& peer) { _peer = peer; }
@@ -88,11 +86,6 @@ private:
     /// The incoming message queue.
     std::shared_ptr<BasicTileQueue> _queue;
 
-    // If this document holds the edit lock.
-    // An edit lock will only allow the current session to make edits,
-    // while other session opening the same document can only see
-    bool _haveEditLock;
-
     // Whether the session is opened as readonly
     bool _isReadOnly;
 
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 3c6c3fb..182a72c 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -334,42 +334,39 @@ bool DocumentBroker::sendUnoSave(const bool dontSaveIfUnmodified)
     // Save using session holding the edit-lock (or first if multview).
     for (auto& sessionIt: _sessions)
     {
-        if (sessionIt.second->isEditLocked())
-        {
-            // Invalidate the timestamp to force persisting.
-            _lastFileModifiedTime.fromEpochTime(0);
+        // Invalidate the timestamp to force persisting.
+        _lastFileModifiedTime.fromEpochTime(0);
+
+        // We do not want save to terminate editing mode if we are in edit mode now
 
-            // We do not want save to terminate editing mode if we are in edit mode now
+        std::ostringstream oss;
+        // arguments init
+        oss << "{";
 
-            std::ostringstream oss;
-            // arguments init
-            oss << "{";
+        // Mention DontTerminateEdit always
+        oss << "\"DontTerminateEdit\":"
+            << "{"
+            << "\"type\":\"boolean\","
+            << "\"value\":true"
+            << "}";
 
-            // Mention DontTerminateEdit always
-            oss << "\"DontTerminateEdit\":"
+        // Mention DontSaveIfUnmodified
+        if (dontSaveIfUnmodified)
+        {
+            oss << ","
+                << "\"DontSaveIfUnmodified\":"
                 << "{"
                 << "\"type\":\"boolean\","
                 << "\"value\":true"
                 << "}";
+        }
 
-            // Mention DontSaveIfUnmodified
-            if (dontSaveIfUnmodified)
-            {
-                oss << ","
-                    << "\"DontSaveIfUnmodified\":"
-                    << "{"
-                    << "\"type\":\"boolean\","
-                    << "\"value\":true"
-                    << "}";
-            }
-
-            // arguments end
-            oss << "}";
+        // arguments end
+        oss << "}";
 
-            Log::debug(".uno:Save arguments: " + oss.str());
-            sessionIt.second->sendToInputQueue("uno .uno:Save " + oss.str());
-            return true;
-        }
+        Log::debug(".uno:Save arguments: " + oss.str());
+        sessionIt.second->sendToInputQueue("uno .uno:Save " + oss.str());
+        return true;
     }
 
     Log::error("Failed to auto-save doc [" + _docKey + "]: No valid sessions.");
@@ -390,7 +387,7 @@ void DocumentBroker::takeEditLock(const std::string& id)
     // Forward to all children.
     for (auto& it: _sessions)
     {
-        it.second->setEditLock(it.first == id);
+        it.second->setEditLock();
     }
 }
 
@@ -418,7 +415,6 @@ size_t DocumentBroker::addSession(std::shared_ptr<ClientSession>& session)
     else if (!_isEditLockHeld)
     {
         Log::debug("Giving editing lock to the first editable session [" + id + "].");
-        _sessions.begin()->second->markEditLock(true);
         _isEditLockHeld = true;
     }
 
@@ -454,26 +450,21 @@ size_t DocumentBroker::removeSession(const std::string& id)
     auto it = _sessions.find(id);
     if (it != _sessions.end())
     {
-        const auto haveEditLock = it->second->isEditLocked();
-        it->second->markEditLock(false);
         _sessions.erase(it);
 
-        if (haveEditLock)
+        // pass the edit lock to first non-readonly session in map
+        bool editLockGiven = false;
+        for (auto& session: _sessions)
         {
-            // pass the edit lock to first non-readonly session in map
-            bool editLockGiven = false;
-            for (auto& session: _sessions)
+            if (!session.second->isReadOnly())
             {
-                if (!session.second->isReadOnly())
-                {
-                    session.second->setEditLock(true);
-                    editLockGiven = true;
-                    break;
-                }
+                session.second->setEditLock();
+                editLockGiven = true;
+                break;
             }
-
-            _isEditLockHeld = editLockGiven;
         }
+
+        _isEditLockHeld = editLockGiven;
     }
 
     return _sessions.size();
diff --git a/loolwsd/LOOLForKit.cpp b/loolwsd/LOOLForKit.cpp
index b1b1068..f1408cd 100644
--- a/loolwsd/LOOLForKit.cpp
+++ b/loolwsd/LOOLForKit.cpp
@@ -285,9 +285,6 @@ int main(int argc, char** argv)
     if (!std::getenv("LD_BIND_NOW"))
         Log::info("Note: LD_BIND_NOW is not set.");
 
-    if (!std::getenv("LOK_VIEW_CALLBACK"))
-        Log::info("Note: LOK_VIEW_CALLBACK is not set.");
-
     // Open read fifo pipe with WSD.
     const Path pipePath = Path::forDirectory(childRoot + "/" + FIFO_PATH);
     const std::string pipeLoolwsd = Path(pipePath, FIFO_LOOLWSD).toString();
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index b8ae37c..2e3fdb9 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -400,8 +400,7 @@ public:
              const std::string& url,
              std::shared_ptr<TileQueue> tileQueue,
              const std::shared_ptr<WebSocket>& ws)
-      : _multiView(std::getenv("LOK_VIEW_CALLBACK")),
-        _loKit(loKit),
+      : _loKit(loKit),
         _jailId(jailId),
         _docKey(docKey),
         _url(url),
@@ -416,8 +415,7 @@ public:
         _tilesThread(tilesThread, this),
         _clientViews(0)
     {
-        Log::info("Document ctor for url [" + _url + "] on child [" + _jailId +
-                  "] LOK_VIEW_CALLBACK=" + std::to_string(_multiView) + ".");
+        Log::info("Document ctor for url [" + _url + "] on child [" + _jailId + "].");
         assert(_loKit && _loKit->get());
 
         _callbackThread.start(*this);
@@ -963,17 +961,14 @@ private:
                     << " view" << (_clientViews != 1 ? "s" : "")
                     << Log::end;
 
-        if (_multiView)
-        {
-            std::unique_lock<std::mutex> lock(_loKitDocument->getLock());
-
-            const auto viewId = session.getViewId();
-            _viewIdToCallbackDescr.erase(viewId);
-            _loKitDocument->setView(viewId);
-            _loKitDocument->registerCallback(nullptr, nullptr);
-            _loKitDocument->destroyView(viewId);
-            Log::debug("Destroyed view " + std::to_string(viewId));
-        }
+        std::unique_lock<std::mutex> lock(_loKitDocument->getLock());
+
+        const auto viewId = session.getViewId();
+        _viewIdToCallbackDescr.erase(viewId);
+        _loKitDocument->setView(viewId);
+        _loKitDocument->registerCallback(nullptr, nullptr);
+        _loKitDocument->destroyView(viewId);
+        Log::debug("Destroyed view " + std::to_string(viewId));
     }
 
     /// Notify all currently active sessions about session with given 'sessionId'
@@ -1137,11 +1132,8 @@ private:
                 }
             }
 
-            if (_multiView)
-            {
-                Log::info("Loading view to document from URI: [" + uri + "] for session [" + sessionId + "].");
-                _loKitDocument->createView();
-            }
+            Log::info("Loading view to document from URI: [" + uri + "] for session [" + sessionId + "].");
+            _loKitDocument->createView();
         }
 
         Object::Ptr renderOptsObj = new Object();
@@ -1173,21 +1165,14 @@ private:
         // registerCallback(), as the previous creates a new view in Impress.
         _loKitDocument->initializeForRendering(ossRenderOpts.str().c_str());
 
-        if (_multiView)
-        {
-            session->setViewId((viewId = _loKitDocument->getView()));
-            _viewIdToCallbackDescr.emplace(viewId,
-                                           std::unique_ptr<CallbackDescriptor>(new CallbackDescriptor({ this, viewId })));
-            _loKitDocument->registerCallback(ViewCallback, _viewIdToCallbackDescr[viewId].get());
-
-            Log::info() << "Document [" << _url << "] view ["
-                        << viewId << "] loaded, leaving "
-                        << (_clientViews + 1) << " views." << Log::end;
-        }
-        else
-        {
-            _loKitDocument->registerCallback(DocumentCallback, this);
-        }
+        session->setViewId((viewId = _loKitDocument->getView()));
+        _viewIdToCallbackDescr.emplace(viewId,
+                                       std::unique_ptr<CallbackDescriptor>(new CallbackDescriptor({ this, viewId })));
+        _loKitDocument->registerCallback(ViewCallback, _viewIdToCallbackDescr[viewId].get());
+
+        Log::info() << "Document [" << _url << "] view ["
+                    << viewId << "] loaded, leaving "
+                    << (_clientViews + 1) << " views." << Log::end;
 
         return _loKitDocument;
     }
@@ -1269,8 +1254,6 @@ private:
     }
 
 private:
-
-    const bool _multiView;
     std::shared_ptr<lok::Office> _loKit;
     const std::string _jailId;
     const std::string _docKey;
diff --git a/loolwsd/PrisonerSession.cpp b/loolwsd/PrisonerSession.cpp
index b7368f9..5a924bc 100644
--- a/loolwsd/PrisonerSession.cpp
+++ b/loolwsd/PrisonerSession.cpp
@@ -188,8 +188,7 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
             forwardToPeer(_peer, buffer, length, isBinary);
 
             // And let clients know if they hold the edit lock.
-            std::string message = "editlock: ";
-            message += std::to_string(peer->isEditLocked());
+            std::string message = "editlock: 1";
             Log::debug("Forwarding [" + message + "] in response to status.");
             return forwardToPeer(_peer, message.c_str(), message.size(), isBinary);
         }
diff --git a/loolwsd/sysconfig.loolwsd b/loolwsd/sysconfig.loolwsd
index e78addc..497d575 100644
--- a/loolwsd/sysconfig.loolwsd
+++ b/loolwsd/sysconfig.loolwsd
@@ -4,4 +4,3 @@
 ## Default:	""
 ## ServiceRestart: loolwsd
 #
-LOK_VIEW_CALLBACK="1"
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index 2fdba45..37e03ec 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -76,7 +76,6 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
     CPPUNIT_TEST(testPasswordProtectedDocumentWithCorrectPassword);
     CPPUNIT_TEST(testPasswordProtectedDocumentWithCorrectPasswordAgain);
     CPPUNIT_TEST(testInsertDelete);
-    CPPUNIT_TEST(testEditLock);
     CPPUNIT_TEST(testSlideShow);
     CPPUNIT_TEST(testInactiveClient);
     CPPUNIT_TEST(testMaxColumn);
@@ -117,7 +116,6 @@ class HTTPWSTest : public CPPUNIT_NS::TestFixture
     void testPasswordProtectedDocumentWithCorrectPasswordAgain();
     void testInsertDelete();
     void testNoExtraLoolKitsLeft();
-    void testEditLock();
     void testSlideShow();
     void testInactiveClient();
     void testMaxColumn();
@@ -943,153 +941,6 @@ void HTTPWSTest::testInsertDelete()
     }
 }
 
-void HTTPWSTest::testEditLock()
-{
-    if (std::getenv("LOK_VIEW_CALLBACK"))
-    {
-        // Editlocking is disabled in multiview.
-        return;
-    }
-
-    const std::string documentPath = Util::getTempFilePath(TDOC, "hello.odt");
-    const std::string documentURL = "lool/ws/file://" + Poco::Path(documentPath).makeAbsolute().toString();
-
-    // This test doesn't really need to be multithreaded.
-    // But it's done this way as an experiment and to serve
-    // as an example for other similar tests (where necessary).
-    // Ultimately, the complexity doesn't justify it.
-    std::mutex mutex;
-    std::condition_variable cv;
-    volatile bool second_client_died = false;
-    volatile bool first_has_editlock = false;
-    volatile bool second_has_editlock = false;
-
-    // The first client loads the document and checks that it has the lock.
-    // It then waits until the lock is taken away.
-    std::thread first_client([&]()
-        {
-            try
-            {
-                std::cerr << "First client loading." << std::endl;
-                auto socket = loadDocAndGetSocket(_uri, documentURL, "editLock-1 ", true);
-                std::string editlock1;
-                std::unique_lock<std::mutex> lock(mutex);
-                SocketProcessor("First ", socket, [&](const std::string& msg)
-                        {
-                            if (msg.find("editlock") == 0)
-                            {
-                                if (editlock1.empty())
-                                {
-                                    std::cerr << "First client has the lock." << std::endl;
-                                    CPPUNIT_ASSERT_EQUAL(std::string("editlock: 1"), msg);
-                                    first_has_editlock = true;
-                                    editlock1 = msg;
-
-                                    // Initial condition met, connect second client.
-                                    std::cerr << "Starting second client." << std::endl;
-                                    lock.unlock();
-                                    cv.notify_one();
-                                }
-                                else if (msg == "editlock: 1")
-                                {
-                                    if (second_client_died)
-                                    {
-                                        // We had lost the lock to the second client,
-                                        // but we should get it back once they die.
-                                        std::cerr << "First client is given the lock." << std::endl;
-                                        CPPUNIT_ASSERT_EQUAL(std::string("editlock: 1"), msg);
-                                        first_has_editlock = true;
-                                        return false; // Done!
-                                    }
-                                    else
-                                    {
-                                        // Normal broadcast when the second client joins.
-                                        std::cerr << "First client still has the lock." << std::endl;
-                                        CPPUNIT_ASSERT_EQUAL(std::string("editlock: 1"), msg);
-                                        CPPUNIT_ASSERT_MESSAGE("First doesn't have the lock", first_has_editlock);
-                                    }
-                                }
-                                else
-                                {
-                                    // Another client took the lock.
-                                    std::cerr << "First client lost the lock." << std::endl;
-                                    CPPUNIT_ASSERT_EQUAL(std::string("editlock: 0"), msg);
-                                    first_has_editlock = false;
-                                    std::cerr << "Allowing the second to die." << std::endl;
-                                    cv.notify_one();
-                                }
-                            }
-
-                            return true;
-                        });
-
-                std::cerr << "First client out." << std::endl;
-                socket->shutdown();
-            }
-            catch (const Poco::Exception& exc)
-            {
-                CPPUNIT_FAIL(exc.displayText());
-            }
-        });
-
-    std::unique_lock<std::mutex> lock(mutex);
-    cv.wait(lock);
-
-    // The second client loads the document and checks that it has no lock.
-    // It then takes the lock and breaks when it gets it.
-    try
-    {
-        std::cerr << "Second client loading." << std::endl;
-        auto socket = loadDocAndGetSocket(_uri, documentURL, "editLock-2 ", true);
-        std::string editlock1;
-        SocketProcessor("Second ", socket, [&](const std::string& msg)
-                {
-                    if (msg.find("editlock") == 0)
-                    {
-                        if (editlock1.empty())
-                        {
-                            // We shouldn't have it.
-                            std::cerr << "Second client doesn't have the lock." << std::endl;
-                            CPPUNIT_ASSERT_EQUAL(std::string("editlock: 0"), msg);
-                            second_has_editlock = false;
-                            editlock1 = msg;
-
-                            // But we will take it.
-                            std::cerr << "Second client taking lock." << std::endl;
-                            sendTextFrame(*socket, "takeedit");
-
-                            // Wait until the first gets the notification that we took it.
-                            cv.wait(lock);
-                        }
-                        else
-                        {
-                            // Now it should be ours.
-                            std::cerr << "Second client took the lock." << std::endl;
-                            CPPUNIT_ASSERT_EQUAL(std::string("editlock: 1"), msg);
-                            second_has_editlock = true;
-                            return false;
-                        }
-                    }
-
-                    return true;
-                });
-
-        std::cerr << "Second client out." << std::endl;
-        second_client_died = true;
-        socket->shutdown();
-        first_client.join();
-
-        // The second will think it had the lock when it died, but it will give it up.
-        CPPUNIT_ASSERT_MESSAGE("Second doesn't have the lock", second_has_editlock);
-        // The first must ultimately have the lock back.
-        CPPUNIT_ASSERT_MESSAGE("First didn't get back the lock", first_has_editlock);
-    }
-    catch (const Poco::Exception& exc)
-    {
-        CPPUNIT_FAIL(exc.displayText());
-    }
-}
-
 void HTTPWSTest::testSlideShow()
 {
     try


More information about the Libreoffice-commits mailing list