[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-1-0' - 3 commits - loleaflet/dist loleaflet/src loolwsd/ChildProcessSession.cpp loolwsd/ChildProcessSession.hpp loolwsd/DocumentBroker.cpp loolwsd/DocumentBroker.hpp loolwsd/LOOLKit.cpp loolwsd/MasterProcessSession.cpp
Pranav Kant
pranavk at collabora.co.uk
Thu Oct 20 09:00:18 UTC 2016
loleaflet/dist/toolbar.css | 10 +++++++++-
loleaflet/dist/toolbar/toolbar.js | 12 ++++++++++--
loleaflet/src/core/Socket.js | 1 -
loleaflet/src/layer/tile/TileLayer.js | 8 ++++++++
loolwsd/ChildProcessSession.cpp | 13 +++++++++----
loolwsd/ChildProcessSession.hpp | 5 ++++-
loolwsd/DocumentBroker.cpp | 9 +++++++++
loolwsd/DocumentBroker.hpp | 3 ++-
loolwsd/LOOLKit.cpp | 11 ++++++++++-
loolwsd/MasterProcessSession.cpp | 10 ++--------
10 files changed, 63 insertions(+), 19 deletions(-)
New commits:
commit 38bed8ff31ca53422d9a98f2a27289498bc9abf5
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Thu Oct 20 01:38:14 2016 +0530
loleaflet: Listen to editlock info and mark the editor
Change-Id: I674b92f542ed4f825ef5838be42030716c9654f0
diff --git a/loleaflet/dist/toolbar.css b/loleaflet/dist/toolbar.css
index 35badbb..f26ed00 100644
--- a/loleaflet/dist/toolbar.css
+++ b/loleaflet/dist/toolbar.css
@@ -305,7 +305,15 @@ button.leaflet-control-search-next
background: rgba(66, 151, 215, 1);
}
-tr.useritem:hover {
+tr.useritem {
+ color: grey;
+}
+
+tr.editor {
+ color: black;
+}
+
+tr.editor:hover {
cursor: default;
background-color: rgba(67, 172, 232, 0.25);
}
diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 71a884b..44ba7b0 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -1333,8 +1333,9 @@ map.on('statusindicator', function (e) {
function getUserItem(viewId, userName) {
var html = '<tr class="useritem" id="user-' + viewId + '">' +
- '<td class="username">' + userName + '</td>' +
- '</tr>';
+ '<td class="username">' + userName + '</td>' +
+ '<td class="lock"></td>' +
+ '</tr>';
return html;
}
var nUsers = _('%n users');
@@ -1352,6 +1353,13 @@ function updateUserListCount() {
w2ui['toolbar-down'].refresh();
}
+map.on('editlock', function(e) {
+ var userlistItem = w2ui['toolbar-down'].get('userlist');
+ var newhtml = $(userlistItem.html).find('.lock').html('').parent().removeClass('editor').parent().parent().parent()[0].outerHTML;
+ newhtml = $(newhtml).find('#user-' + e.viewid + ' .lock').html(' (Editing)').parent().addClass('editor').parent().parent().parent()[0].outerHTML;
+ userlistItem.html = newhtml;
+});
+
map.on('addview', function(e) {
if (!e.viewId || !e.username)
return;
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 107c97c..46f4265 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -540,6 +540,14 @@ L.TileLayer = L.GridLayer.extend({
this._removeView(parseInt(viewInfoIdx));
}
}
+
+ // Change of lock ?
+ for (viewInfoIdx in viewInfo) {
+ if (viewInfo[viewInfoIdx].editlock) {
+ this._map.fire('editlock', {viewid: parseInt(viewInfo[viewInfoIdx].id)});
+ break;
+ }
+ }
},
_onPartPageRectanglesMsg: function (textMsg) {
commit 0a9a94dacd7b12228fda7ff5690fdeb8c9425ac2
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Thu Oct 20 01:35:48 2016 +0530
loolwsd: Broadcast editlock info with viewinfo message
This tells all connected clients about who currently is in
possession of the editlock.
Note that though the editlock information is now embedded in the
viewinfo message, it is not used to turn the editlock on and off
on the client side (yet). Let the 'editlock' message work as it
used to do.
Change-Id: Iba70fb910bcba2cd8e10037f294dbe245c52d83e
diff --git a/loolwsd/ChildProcessSession.cpp b/loolwsd/ChildProcessSession.cpp
index e4d34e3..6e5dc1a 100644
--- a/loolwsd/ChildProcessSession.cpp
+++ b/loolwsd/ChildProcessSession.cpp
@@ -554,13 +554,18 @@ bool ChildProcessSession::_handleInput(const char *buffer, int length)
}
else if (tokens[0] == "editlock:")
{
- // Nothing for us to do but to let the
- // client know about the edit lock state.
- // Yes, this is echoed back because it's better
+ _editLock = (tokens[1] == "1");
+ // Tell everyone the updated viewinfo with lock given to
+ // current session id
+ if (_editLock)
+ {
+ _docManager.notifyViewInfo(getId());
+ }
+
+ // This is also echoed back because it's better
// to do this on each child's queue and thread
// than for WSD to potentially stall while notifying
// each client with the edit lock state.
- Log::trace("Echoing back [" + firstLine + "].");
sendTextFrame(firstLine);
return true;
}
diff --git a/loolwsd/ChildProcessSession.hpp b/loolwsd/ChildProcessSession.hpp
index b1bacd0..61d5661 100644
--- a/loolwsd/ChildProcessSession.hpp
+++ b/loolwsd/ChildProcessSession.hpp
@@ -43,7 +43,7 @@ public:
/// Send updated view info to all active sessions
virtual
- void notifyViewInfo() = 0;
+ void notifyViewInfo(const std::string& editLockSessionId = "") = 0;
};
class ChildProcessSession final : public LOOLSession
@@ -73,6 +73,7 @@ public:
int getViewId() const { return _viewId; }
const std::string getViewUserName() const { return _userName; }
+ bool isEditLocked() const { return _editLock; }
const std::string& getDocType() const { return _docType; }
@@ -115,6 +116,8 @@ private:
std::string _docType;
const bool _multiView;
const std::string _jailId;
+ // If this session holds the editlock
+ bool _editLock = false;
/// View ID, returned by createView() or 0 by default.
int _viewId;
std::map<int, std::string> _lastDocStates;
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 3f5a421..56b335a 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -418,6 +418,15 @@ bool DocumentBroker::connectPeers(std::shared_ptr<MasterProcessSession>& session
return false;
}
+void DocumentBroker::setLoaded(const std::string& sessionId)
+{
+ if (!_isLoaded)
+ {
+ _isLoaded = true;
+ takeEditLock(sessionId);
+ }
+}
+
size_t DocumentBroker::removeSession(const std::string& id)
{
std::lock_guard<std::mutex> lock(_mutex);
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index f078f21..a63acda 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -148,7 +148,8 @@ public:
/// Loads a document from the public URI into the jail.
bool load(const std::string& jailId);
bool isLoaded() const { return _isLoaded; }
- void setLoaded() { _isLoaded = true; }
+ /// Set this to loaded. sessionId is session id with which it was loaded
+ void setLoaded(const std::string& sessionId);
/// Save the document to Storage if needs persisting.
bool save(bool success, const std::string& result = "");
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index de4f71d..9d7d059 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -993,7 +993,7 @@ private:
}
/// Notify all views of viewId and their associated usernames
- void notifyViewInfo() override
+ void notifyViewInfo(const std::string& editLockSessionId) override
{
std::unique_lock<std::mutex> lock(_mutex);
@@ -1009,6 +1009,15 @@ private:
const auto session = connectionIt.second->getSession();
viewInfoObj->set("id", Util::decodeId(session->getId()));
viewInfoObj->set("username", session->getViewUserName());
+ Log::debug("editLockSessionId:" + editLockSessionId + ": and editlocked : " + std::to_string(session->isEditLocked()));
+ if (editLockSessionId != "")
+ {
+ viewInfoObj->set("editlock", editLockSessionId == session->getId());
+ }
+ else
+ {
+ viewInfoObj->set("editlock", session->isEditLocked());
+ }
viewInfoArray->set(arrayIndex++, viewInfoObj);
}
diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp
index f9b3e43..f312ed8 100644
--- a/loolwsd/MasterProcessSession.cpp
+++ b/loolwsd/MasterProcessSession.cpp
@@ -216,17 +216,11 @@ bool MasterProcessSession::_handleInput(const char *buffer, int length)
}
else if (tokens[0] == "status:")
{
- _docBroker->setLoaded();
+ _docBroker->setLoaded(getId());
_docBroker->tileCache().saveTextFile(std::string(buffer, length), "status.txt");
// Forward the status response to the client.
forwardToPeer(buffer, length);
-
- // And let clients know if they hold the edit lock.
- std::string message = "editlock: ";
- message += std::to_string(peer->isEditLocked());
- Log::debug("Forwarding [" + message + "] in response to status.");
- forwardToPeer(message.c_str(), message.size());
return true;
}
else if (tokens[0] == "commandvalues:")
@@ -443,7 +437,7 @@ bool MasterProcessSession::getStatus(const char *buffer, int length)
void MasterProcessSession::setEditLock(const bool value)
{
- // Update the sate and forward to child.
+ // Update the state and forward to child.
_bEditLock = value;
const auto msg = std::string("editlock: ") + (value ? "1" : "0");
forwardToPeer(msg.data(), msg.size());
commit 9201d836269d455e975d436b88a07c475f555564
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Thu Oct 20 01:36:56 2016 +0530
No need to 'status' message
Change-Id: Ie6db1a2cd6976f8f539578e9668b53cda002af92
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index bc68a6a..e89db5d 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -92,7 +92,6 @@ L.Socket = L.Class.extend({
msg += ' options=' + JSON.stringify(options);
}
this._doSend(msg);
- this._doSend('status');
this._doSend('partpagerectangles');
for (var i = 0; i < this._msgQueue.length; i++) {
this._doSend(this._msgQueue[i].msg, this._msgQueue[i].coords);
More information about the Libreoffice-commits
mailing list