[Libreoffice-commits] online.git: common/Session.hpp kit/ChildSession.cpp kit/ChildSession.hpp wsd/ClientSession.cpp wsd/ClientSession.hpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Nov 13 08:04:43 UTC 2018
common/Session.hpp | 36 ++++++++++++++++++++++++++++++++++--
kit/ChildSession.cpp | 20 ++++++++++----------
kit/ChildSession.hpp | 7 +++----
wsd/ClientSession.cpp | 36 ++++++++++++++++++------------------
wsd/ClientSession.hpp | 6 ------
5 files changed, 65 insertions(+), 40 deletions(-)
New commits:
commit cd08cbf3850e2eb92ac7b31a448ce3fa46fc53ca
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Nov 13 09:04:19 2018 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Nov 13 09:04:19 2018 +0100
Session: make members private
diff --git a/common/Session.hpp b/common/Session.hpp
index 9fa9833a0..f09af7574 100644
--- a/common/Session.hpp
+++ b/common/Session.hpp
@@ -84,6 +84,40 @@ public:
void getIOStats(uint64_t &sent, uint64_t &recv);
+ void setUserId(const std::string& userId) { _userId = userId; }
+
+ const std::string& getUserId() const { return _userId; }
+
+ void setWatermarkText(const std::string& watermarkText) { _watermarkText = watermarkText; }
+
+ void setUserExtraInfo(const std::string& userExtraInfo) { _userExtraInfo = userExtraInfo; }
+
+ void setUserName(const std::string& userName) { _userName = userName; }
+
+ const std::string& getUserName() const {return _userName; }
+
+ const std::string& getUserNameAnonym() const { return _userNameAnonym; }
+
+ bool isDocPasswordProtected() const { return _isDocPasswordProtected; }
+
+ const std::string& getDocOptions() const { return _docOptions; }
+
+ const std::string& getWatermarkText() const { return _watermarkText; }
+
+ const std::string& getLang() const { return _lang; }
+
+ bool getHaveDocPassword() const { return _haveDocPassword; }
+
+ const std::string& getDocPassword() const { return _docPassword; }
+
+ const std::string& getUserExtraInfo() const { return _userExtraInfo; }
+
+ const std::string& getDocURL() const { return _docURL; }
+
+ const std::string& getJailedFilePath() const { return _jailedFilePath; }
+
+ const std::string& getJailedFilePathAnonym() const { return _jailedFilePathAnonym; }
+
protected:
Session(const std::string& name, const std::string& id, bool readonly);
virtual ~Session();
@@ -108,7 +142,6 @@ protected:
private:
virtual bool _handleInput(const char* buffer, int length) = 0;
-private:
/// A session ID specific to an end-to-end connection (from user to lokit).
const std::string _id;
@@ -131,7 +164,6 @@ private:
/// Whether the session is opened as readonly
bool _isReadOnly;
-protected:
/// The actual URL, also in the child, even if the child never accesses that.
std::string _docURL;
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index da9e7ae36..9462e2adc 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -366,33 +366,33 @@ bool ChildSession::loadDocument(const char * /*buffer*/, int /*length*/, const s
parseDocOptions(tokens, part, timestamp);
std::string renderOpts;
- if (!_docOptions.empty())
+ if (!getDocOptions().empty())
{
Parser parser;
- Poco::Dynamic::Var var = parser.parse(_docOptions);
+ Poco::Dynamic::Var var = parser.parse(getDocOptions());
Object::Ptr object = var.extract<Object::Ptr>();
Poco::Dynamic::Var rendering = object->get("rendering");
if (!rendering.isEmpty())
renderOpts = rendering.toString();
}
- assert(!_docURL.empty());
- assert(!_jailedFilePath.empty());
+ assert(!getDocURL().empty());
+ assert(!getJailedFilePath().empty());
std::unique_lock<std::recursive_mutex> lock(Mutex);
- const bool loaded = _docManager.onLoad(getId(), _jailedFilePath, _jailedFilePathAnonym,
- _userName, _userNameAnonym,
- _docPassword, renderOpts, _haveDocPassword,
- _lang, _watermarkText);
+ const bool loaded = _docManager.onLoad(getId(), getJailedFilePath(), getJailedFilePathAnonym(),
+ getUserName(), getUserNameAnonym(),
+ getDocPassword(), renderOpts, getHaveDocPassword(),
+ getLang(), getWatermarkText());
if (!loaded || _viewId < 0)
{
- LOG_ERR("Failed to get LoKitDocument instance for [" << _jailedFilePathAnonym << "].");
+ LOG_ERR("Failed to get LoKitDocument instance for [" << getJailedFilePathAnonym() << "].");
return false;
}
LOG_INF("Created new view with viewid: [" << _viewId << "] for username: [" <<
- _userNameAnonym << "] in session: [" << getId() << "].");
+ getUserNameAnonym() << "] in session: [" << getId() << "].");
std::unique_lock<std::mutex> lockLokDoc(_docManager.getDocumentMutex());
diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp
index 898d09e22..7b38ec904 100644
--- a/kit/ChildSession.hpp
+++ b/kit/ChildSession.hpp
@@ -209,10 +209,9 @@ public:
bool getStatus(const char* buffer, int length);
int getViewId() const { return _viewId; }
void setViewId(const int viewId) { _viewId = viewId; }
- const std::string& getViewUserId() const { return _userId; }
- const std::string& getViewUserName() const { return _userName; }
- const std::string& getViewUserExtraInfo() const { return _userExtraInfo; }
- const std::string& getWatermarkText() const { return _watermarkText; }
+ const std::string& getViewUserId() const { return getUserId(); }
+ const std::string& getViewUserName() const { return getUserName(); }
+ const std::string& getViewUserExtraInfo() const { return getUserExtraInfo(); }
void updateSpeed();
int getSpeed();
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 896163360..f6625470c 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -126,7 +126,7 @@ bool ClientSession::_handleInput(const char *buffer, int length)
}
else if (tokens[0] == "load")
{
- if (_docURL != "")
+ if (getDocURL() != "")
{
sendTextFrame("error: cmd=load kind=docalreadyloaded");
return false;
@@ -178,7 +178,7 @@ bool ClientSession::_handleInput(const char *buffer, int length)
sendTextFrame("error: cmd=" + tokens[0] + " kind=unknown");
return false;
}
- else if (_docURL == "")
+ else if (getDocURL() == "")
{
sendTextFrame("error: cmd=" + tokens[0] + " kind=nodocloaded");
return false;
@@ -405,23 +405,23 @@ bool ClientSession::loadDocument(const char* /*buffer*/, int /*length*/,
oss << "load";
oss << " url=" << docBroker->getPublicUri().toString();;
- if (!_userId.empty() && !_userName.empty())
+ if (!getUserId().empty() && !getUserName().empty())
{
std::string encodedUserId;
- Poco::URI::encode(_userId, "", encodedUserId);
+ Poco::URI::encode(getUserId(), "", encodedUserId);
oss << " authorid=" << encodedUserId;
- oss << " xauthorid=" << LOOLWSD::anonymizeUsername(_userId);
+ oss << " xauthorid=" << LOOLWSD::anonymizeUsername(getUserId());
std::string encodedUserName;
- Poco::URI::encode(_userName, "", encodedUserName);
+ Poco::URI::encode(getUserName(), "", encodedUserName);
oss << " author=" << encodedUserName;
- oss << " xauthor=" << LOOLWSD::anonymizeUsername(_userName);
+ oss << " xauthor=" << LOOLWSD::anonymizeUsername(getUserName());
}
- if (!_userExtraInfo.empty())
+ if (!getUserExtraInfo().empty())
{
std::string encodedUserExtraInfo;
- Poco::URI::encode(_userExtraInfo, "", encodedUserExtraInfo);
+ Poco::URI::encode(getUserExtraInfo(), "", encodedUserExtraInfo);
oss << " authorextrainfo=" << encodedUserExtraInfo; //TODO: could this include PII?
}
@@ -432,26 +432,26 @@ bool ClientSession::loadDocument(const char* /*buffer*/, int /*length*/,
oss << " part=" << loadPart;
}
- if (_haveDocPassword)
+ if (getHaveDocPassword())
{
- oss << " password=" << _docPassword;
+ oss << " password=" << getDocPassword();
}
- if (!_lang.empty())
+ if (!getLang().empty())
{
- oss << " lang=" << _lang;
+ oss << " lang=" << getLang();
}
- if (!_watermarkText.empty())
+ if (!getWatermarkText().empty())
{
std::string encodedWatermarkText;
- Poco::URI::encode(_watermarkText, "", encodedWatermarkText);
+ Poco::URI::encode(getWatermarkText(), "", encodedWatermarkText);
oss << " watermarkText=" << encodedWatermarkText;
}
- if (!_docOptions.empty())
+ if (!getDocOptions().empty())
{
- oss << " options=" << _docOptions;
+ oss << " options=" << getDocOptions();
}
return forwardToChild(oss.str(), docBroker);
@@ -909,7 +909,7 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt
}
}
- if (!_isDocPasswordProtected)
+ if (!isDocPasswordProtected())
{
if (tokens[0] == "tile:")
{
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index 33c7ca7c2..b701e5568 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -49,12 +49,6 @@ public:
bool isViewLoaded() const { return _isViewLoaded; }
void setViewLoaded() { _isViewLoaded = true; }
- const std::string getUserId() const { return _userId; }
- const std::string getUserName() const {return _userName; }
- void setUserId(const std::string& userId) { _userId = userId; }
- void setUserName(const std::string& userName) { _userName = userName; }
- void setUserExtraInfo(const std::string& userExtraInfo) { _userExtraInfo = userExtraInfo; }
- void setWatermarkText(const std::string& watermarkText) { _watermarkText = watermarkText; }
void setDocumentOwner(const bool documentOwner) { _isDocumentOwner = documentOwner; }
bool isDocumentOwner() const { return _isDocumentOwner; }
More information about the Libreoffice-commits
mailing list