[Libreoffice-commits] online.git: loolwsd/ChildProcessSession.cpp loolwsd/ChildProcessSession.hpp loolwsd/LOOLKit.cpp loolwsd/LOOLSession.cpp loolwsd/LOOLSession.hpp loolwsd/MasterProcessSession.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Fri Apr 29 01:06:06 UTC 2016
loolwsd/ChildProcessSession.cpp | 12 ++++++------
loolwsd/ChildProcessSession.hpp | 10 ++++++----
loolwsd/LOOLKit.cpp | 30 +++++++++++++++---------------
loolwsd/LOOLSession.cpp | 4 ++--
loolwsd/LOOLSession.hpp | 2 +-
loolwsd/MasterProcessSession.cpp | 2 +-
6 files changed, 31 insertions(+), 29 deletions(-)
New commits:
commit 1dd88e68ea6e39c5785b61001e2388a886bfeb7b
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Wed Apr 27 20:51:54 2016 -0400
loolwsd: shortened some long identifiers
Change-Id: I87809f5ad2a6d8f546cf3abaf646672d2d8168dc
Reviewed-on: https://gerrit.libreoffice.org/24471
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/ChildProcessSession.cpp b/loolwsd/ChildProcessSession.cpp
index d727cfd..cc7b603 100644
--- a/loolwsd/ChildProcessSession.cpp
+++ b/loolwsd/ChildProcessSession.cpp
@@ -277,8 +277,8 @@ ChildProcessSession::ChildProcessSession(const std::string& id,
std::shared_ptr<WebSocket> ws,
LibreOfficeKitDocument * loKitDocument,
const std::string& jailId,
- std::function<LibreOfficeKitDocument*(const std::string&, const std::string&, const std::string&, const std::string&, bool)> onLoad,
- std::function<void(const std::string&)> onUnload) :
+ OnLoadCallback onLoad,
+ OnUnloadCallback onUnload) :
LOOLSession(id, Kind::ToMaster, ws),
_loKitDocument(loKitDocument),
_multiView(std::getenv("LOK_VIEW_CALLBACK")),
@@ -554,19 +554,19 @@ bool ChildProcessSession::loadDocument(const char * /*buffer*/, int /*length*/,
std::string timestamp;
parseDocOptions(tokens, part, timestamp);
- std::string renderingOptions;
+ std::string renderOpts;
if (!_docOptions.empty())
{
Parser parser;
Poco::Dynamic::Var var = parser.parse(_docOptions);
Object::Ptr object = var.extract<Object::Ptr>();
- renderingOptions = object->get("rendering").toString();
+ renderOpts = object->get("rendering").toString();
}
assert(!_docURL.empty());
assert(!_jailedFilePath.empty());
- _loKitDocument = _onLoad(getId(), _jailedFilePath, _docPassword, renderingOptions, _isDocPasswordProvided);
+ _loKitDocument = _onLoad(getId(), _jailedFilePath, _docPassword, renderOpts, _haveDocPassword);
if (!_loKitDocument)
{
Log::error("Failed to get LoKitDocument instance.");
@@ -578,7 +578,7 @@ bool ChildProcessSession::loadDocument(const char * /*buffer*/, int /*length*/,
if (_multiView)
{
_viewId = _loKitDocument->pClass->getView(_loKitDocument);
- _loKitDocument->pClass->initializeForRendering(_loKitDocument, (renderingOptions.empty() ? nullptr : renderingOptions.c_str()));
+ _loKitDocument->pClass->initializeForRendering(_loKitDocument, (renderOpts.empty() ? nullptr : renderOpts.c_str()));
}
if (_docType != "text" && part != -1)
diff --git a/loolwsd/ChildProcessSession.hpp b/loolwsd/ChildProcessSession.hpp
index b614195..77710fe 100644
--- a/loolwsd/ChildProcessSession.hpp
+++ b/loolwsd/ChildProcessSession.hpp
@@ -23,6 +23,8 @@
#include "LOOLSession.hpp"
class CallbackWorker;
+typedef std::function<LibreOfficeKitDocument*(const std::string&, const std::string&, const std::string&, const std::string&, bool)> OnLoadCallback;
+typedef std::function<void(const std::string&)> OnUnloadCallback;
class ChildProcessSession final : public LOOLSession
{
@@ -38,8 +40,8 @@ public:
std::shared_ptr<Poco::Net::WebSocket> ws,
LibreOfficeKitDocument * loKitDocument,
const std::string& jailId,
- std::function<LibreOfficeKitDocument*(const std::string&, const std::string&, const std::string&, const std::string&, bool)> onLoad,
- std::function<void(const std::string&)> onUnload);
+ OnLoadCallback onLoad,
+ OnUnloadCallback onUnload);
virtual ~ChildProcessSession();
virtual bool getStatus(const char *buffer, int length) override;
@@ -100,8 +102,8 @@ private:
/// View ID, returned by createView() or 0 by default.
int _viewId;
std::map<int, std::string> _lastDocStates;
- std::function<LibreOfficeKitDocument*(const std::string&, const std::string&, const std::string&, const std::string&, bool)> _onLoad;
- std::function<void(const std::string&)> _onUnload;
+ OnLoadCallback _onLoad;
+ OnUnloadCallback _onUnload;
std::unique_ptr<CallbackWorker> _callbackWorker;
Poco::Thread _callbackThread;
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 624eb98..cb3446a 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -360,7 +360,7 @@ public:
_url(url),
_loKitDocument(nullptr),
_docPassword(""),
- _isDocPasswordProvided(false),
+ _haveDocPassword(false),
_isDocPasswordProtected(false),
_docPasswordType(PasswordType::ToView),
_isLoading(0),
@@ -465,7 +465,7 @@ public:
auto session = std::make_shared<ChildProcessSession>(sessionId, ws, _loKitDocument, _jailId,
[this](const std::string& id, const std::string& uri, const std::string& docPassword,
- const std::string& renderingOptions, bool isDocPasswordProvided) { return onLoad(id, uri, docPassword, renderingOptions, isDocPasswordProvided); },
+ const std::string& renderOpts, bool haveDocPassword) { return onLoad(id, uri, docPassword, renderOpts, haveDocPassword); },
[this](const std::string& id) { onUnload(id); });
auto thread = std::make_shared<Connection>(session, ws);
@@ -549,10 +549,10 @@ public:
void setDocumentPassword(int nPasswordType)
{
Log::info() << "setDocumentPassword: passwordProtected=" << _isDocPasswordProtected
- << " passwordProvided=" << _isDocPasswordProvided
+ << " passwordProvided=" << _haveDocPassword
<< " password='" << _docPassword << "'" << Log::end;
- if (_isDocPasswordProtected && _isDocPasswordProvided)
+ if (_isDocPasswordProtected && _haveDocPassword)
{
// it means this is the second attempt with the wrong password; abort the load operation
_loKit->pClass->setDocumentPassword(_loKit, _jailedUrl.c_str(), nullptr);
@@ -567,7 +567,7 @@ public:
_docPasswordType = PasswordType::ToModify;
Log::info("Caling _loKit->pClass->setDocumentPassword");
- if (_isDocPasswordProvided)
+ if (_haveDocPassword)
_loKit->pClass->setDocumentPassword(_loKit, _jailedUrl.c_str(), _docPassword.c_str());
else
_loKit->pClass->setDocumentPassword(_loKit, _jailedUrl.c_str(), nullptr);
@@ -651,8 +651,8 @@ private:
LibreOfficeKitDocument* onLoad(const std::string& sessionId,
const std::string& uri,
const std::string& docPassword,
- const std::string& renderingOptions,
- bool isDocPasswordProvided)
+ const std::string& renderOpts,
+ bool haveDocPassword)
{
Log::info("Session " + sessionId + " is loading. " + std::to_string(_clientViews) + " views loaded.");
@@ -668,7 +668,7 @@ private:
try
{
- load(sessionId, uri, docPassword, renderingOptions, isDocPasswordProvided);
+ load(sessionId, uri, docPassword, renderOpts, haveDocPassword);
}
catch (const std::exception& exc)
{
@@ -720,8 +720,8 @@ private:
LibreOfficeKitDocument* load(const std::string& sessionId,
const std::string& uri,
const std::string& docPassword,
- const std::string& renderingOptions,
- bool isDocPasswordProvided)
+ const std::string& renderOpts,
+ bool haveDocPassword)
{
const unsigned intSessionId = Util::decodeId(sessionId);
const auto it = _connections.find(intSessionId);
@@ -746,7 +746,7 @@ private:
}
// Save the provided password with us and the jailed url
- _isDocPasswordProvided = isDocPasswordProvided;
+ _haveDocPassword = haveDocPassword;
_docPassword = docPassword;
_jailedUrl = uri;
_isDocPasswordProtected = false;
@@ -762,7 +762,7 @@ private:
// Checking if wrong password or no password was reason for failure.
if (_isDocPasswordProtected)
{
- if (!_isDocPasswordProvided)
+ if (!_haveDocPassword)
{
std::string passwordFrame = "passwordrequired:";
if (_docPasswordType == PasswordType::ToView)
@@ -794,14 +794,14 @@ private:
_loKitDocument->pClass->registerCallback(_loKitDocument, DocumentCallback, this);
}
- _loKitDocument->pClass->initializeForRendering(_loKitDocument, (renderingOptions.empty() ? nullptr : renderingOptions.c_str()));
+ _loKitDocument->pClass->initializeForRendering(_loKitDocument, (renderOpts.empty() ? nullptr : renderOpts.c_str()));
}
else
{
// Check if this document requires password
if (_isDocPasswordProtected)
{
- if (!isDocPasswordProvided)
+ if (!haveDocPassword)
{
std::string passwordFrame = "passwordrequired:";
if (_docPasswordType == PasswordType::ToView)
@@ -836,7 +836,7 @@ private:
// Document password provided
std::string _docPassword;
// Whether password was provided or not
- bool _isDocPasswordProvided;
+ bool _haveDocPassword;
// Whether document is password protected
bool _isDocPasswordProtected;
// Whether password is required to view the document, or modify it
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index d755ef8..8a7e633 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -53,7 +53,7 @@ LOOLSession::LOOLSession(const std::string& id, const Kind kind,
kind == Kind::ToMaster ? "ToMaster" : "ToPrisoner"),
_ws(ws),
_docPassword(""),
- _isDocPasswordProvided(false),
+ _haveDocPassword(false),
_isDocLoaded(false),
_isDocPasswordProtected(false),
_isCloseFrame(false),
@@ -163,7 +163,7 @@ void LOOLSession::parseDocOptions(const StringTokenizer& tokens, int& part, std:
else if (tokens[i].find("password=") == 0)
{
_docPassword = tokens[i].substr(strlen("password="));
- _isDocPasswordProvided = true;
+ _haveDocPassword = true;
++offset;
}
}
diff --git a/loolwsd/LOOLSession.hpp b/loolwsd/LOOLSession.hpp
index 95d1fc8..575dcf3 100644
--- a/loolwsd/LOOLSession.hpp
+++ b/loolwsd/LOOLSession.hpp
@@ -121,7 +121,7 @@ protected:
std::string _docPassword;
// If password is provided or not
- bool _isDocPasswordProvided;
+ bool _haveDocPassword;
// Whether document has been opened succesfuly
bool _isDocLoaded;
diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp
index ee74bd0..f8e321f 100644
--- a/loolwsd/MasterProcessSession.cpp
+++ b/loolwsd/MasterProcessSession.cpp
@@ -718,7 +718,7 @@ void MasterProcessSession::dispatchChild()
if (_loadPart >= 0)
oss << " part=" + std::to_string(_loadPart);
- if (_isDocPasswordProvided)
+ if (_haveDocPassword)
oss << " password=" << _docPassword;
if (!_docOptions.empty())
More information about the Libreoffice-commits
mailing list