loolwsd/LOOLKit.cpp | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-)
New commits: commit dafa5d078de76aab9aaf8f0990b066fe476805a3 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Thu Aug 11 20:09:55 2016 -0400 loolwsd: split out per-view LOK callback from default Change-Id: I01c0bb14cabbbe06bc790920d0f74d0f106bbbde Reviewed-on: https://gerrit.libreoffice.org/28118 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp index 7a7b545..6a54fd1 100644 --- a/loolwsd/LOOLKit.cpp +++ b/loolwsd/LOOLKit.cpp @@ -717,9 +717,41 @@ public: private: - static void ViewCallback(int , const char* , void* ) + static void ViewCallback(const int nType, const char* pPayload, void* pData) { - //TODO: Delegate the callback. + Log::trace() << "Document::ViewCallback " + << LOKitHelper::kitCallbackTypeToString(nType) + << " [" << (pPayload ? pPayload : "") << "]." << Log::end; + Document* self = reinterpret_cast<Document*>(pData); + if (self == nullptr) + { + return; + } + + std::unique_lock<std::mutex> lock(self->_mutex); + + if (nType == LOK_CALLBACK_DOCUMENT_PASSWORD_TO_MODIFY || + nType == LOK_CALLBACK_DOCUMENT_PASSWORD) + { + // Mark the document password type. + self->setDocumentPassword(nType); + return; + } + + const auto viewId = self->_loKitDocument->getView(); + + // Forward to the same view only. + for (auto& it: self->_connections) + { + if (it.second->isRunning()) + { + auto session = it.second->getSession(); + if (session && session->getViewId() == viewId) + { + session->loKitCallback(nType, pPayload); + } + } + } } static void DocumentCallback(const int nType, const char* pPayload, void* pData) @@ -848,6 +880,7 @@ private: } auto session = it->second->getSession(); + auto& callback = _multiView ? ViewCallback : DocumentCallback; if (!_loKitDocument) { @@ -858,6 +891,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); const auto flags = LOK_FEATURE_DOCUMENT_PASSWORD | LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY; @@ -943,7 +977,7 @@ private: // registerCallback(), as the previous creates a new view in Impress. _loKitDocument->initializeForRendering(_renderOpts.c_str()); - _loKitDocument->registerCallback(DocumentCallback, this); + _loKitDocument->registerCallback(callback, this); return _loKitDocument; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits