[Libreoffice-commits] online.git: 3 commits - loolwsd/ChildSession.cpp loolwsd/LOOLKit.cpp
Pranav Kant
pranavk at collabora.co.uk
Sun Aug 21 17:12:49 UTC 2016
loolwsd/ChildSession.cpp | 2 -
loolwsd/LOOLKit.cpp | 48 ++++++++++++++++++++++++++++-------------------
2 files changed, 30 insertions(+), 20 deletions(-)
New commits:
commit df0339422353dc8a75641415e564c1e35d9503d9
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Sun Aug 21 22:35:03 2016 +0530
loolwsd: Don't try to unload if underlying doc pointer is null
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 0b1d87f..2b9117c 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -880,7 +880,7 @@ private:
std::unique_lock<std::mutex> lock(_mutex);
const auto it = _connections.find(intSessionId);
- if (it == _connections.end() || !it->second || !_loKitDocument)
+ if (it == _connections.end() || !it->second || !_loKitDocument || !_loKitDocument->get())
{
// Nothing to do.
Log::error("No [" + sessionId + "] session!");
commit 4fdfa3a1c941ec9bb41a30c73a431f2d81367b51
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Thu Aug 11 18:00:41 2016 +0530
loolwsd: Separate global and document callback
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index e4d33df..0b1d87f 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -753,6 +753,25 @@ public:
private:
+ static void GlobalCallback(const int nType, const char* pPayload, void* pData)
+ {
+ const std::string payload = pPayload ? pPayload : "(nil)";
+ Log::trace() << "Document::GlobalCallback "
+ << LOKitHelper::kitCallbackTypeToString(nType)
+ << " [" << payload << "]." << Log::end;
+ Document* self = reinterpret_cast<Document*>(pData);
+ if (nType == LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY ||
+ nType == LOK_CALLBACK_DOCUMENT_PASSWORD)
+ {
+ // Mark the document password type.
+ self->setDocumentPassword(nType);
+ return;
+ }
+
+ // Broadcast leftover status indicator callbacks to all clients
+ self->broadcastCallbackToClients(nType, payload);
+ }
+
static void ViewCallback(const int nType, const char* pPayload, void* pData)
{
CallbackDescriptor* pDescr = reinterpret_cast<CallbackDescriptor*>(pData);
@@ -788,23 +807,15 @@ private:
<< LOKitHelper::kitCallbackTypeToString(nType)
<< " [" << payload << "]." << Log::end;
Document* self = reinterpret_cast<Document*>(pData);
- if (self == nullptr)
- {
- return;
- }
-
- std::unique_lock<std::mutex> lock(self->_mutex);
+ self->broadcastCallbackToClients(nType, pPayload);
+ }
- if (nType == LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY ||
- nType == LOK_CALLBACK_DOCUMENT_PASSWORD)
- {
- // Mark the document password type.
- self->setDocumentPassword(nType);
- return;
- }
+ /// Helper method to broadcast callback and its payload to all clients
+ void broadcastCallbackToClients(const int nType, const std::string& payload)
+ {
+ std::unique_lock<std::mutex> lock(_mutex);
- // Broadcast to all clients.
- for (auto& it: self->_connections)
+ for (auto& it: _connections)
{
if (it.second->isRunning())
{
@@ -812,7 +823,7 @@ private:
if (session)
{
auto pNotif = new CallbackNotification(session, nType, payload);
- self->_callbackQueue.enqueueNotification(pNotif);
+ _callbackQueue.enqueueNotification(pNotif);
}
}
}
@@ -939,8 +950,7 @@ private:
auto lock(_loKit->getLock());
if (LIBREOFFICEKIT_HAS(_loKit->get(), registerCallback))
{
- //TODO: Use GlobalCallback for Password and statusindicator.
- _loKit->get()->pClass->registerCallback(_loKit->get(), DocumentCallback, this);
+ _loKit->get()->pClass->registerCallback(_loKit->get(), GlobalCallback, this);
const auto flags = LOK_FEATURE_DOCUMENT_PASSWORD
| LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY;
_loKit->setOptionalFeatures(flags);
commit 86891498a97bd216e497a9bdf068b81491214e55
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Mon Aug 15 12:40:45 2016 +0530
loolwsd: fix leftover confusing comment
Call to getStatus is gone in
2744caf97b4c1be26966d04e61518022f9f546a9, so there are no
"arguments" anywhere now.
diff --git a/loolwsd/ChildSession.cpp b/loolwsd/ChildSession.cpp
index 9ac519a..ff4fed2 100644
--- a/loolwsd/ChildSession.cpp
+++ b/loolwsd/ChildSession.cpp
@@ -358,7 +358,7 @@ bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, StringT
_loKitDocument->setPart(part);
}
- // Respond by the document status, which has no arguments.
+ // Respond by the document status
Log::debug("Sending status after loading view " + std::to_string(_viewId) + ".");
const auto status = LOKitHelper::documentStatus(_loKitDocument->get());
if (status.empty() || !sendTextFrame("status: " + status))
More information about the Libreoffice-commits
mailing list