[Libreoffice-commits] online.git: wsd/ClientSession.cpp wsd/DocumentBroker.cpp wsd/Storage.hpp

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Nov 21 08:08:19 UTC 2018


 wsd/ClientSession.cpp  |   16 +++++++-------
 wsd/DocumentBroker.cpp |   54 ++++++++++++++++++++++++-------------------------
 wsd/Storage.hpp        |   47 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+), 35 deletions(-)

New commits:
commit 2751f2aebadf5a69ae0f548c31c51f4e4b4323d6
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Nov 21 09:07:52 2018 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Nov 21 09:08:00 2018 +0100

    WopiStorage::WOPIFileInfo: make members private
    
    Change-Id: I62b709acf856b86a8880a517f45152abfa6e32b2

diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 20819f83c..7d4b0b438 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -196,7 +196,7 @@ bool ClientSession::_handleInput(const char *buffer, int length)
     {
         // If this session is the owner of the file & 'EnableOwnerTermination' feature
         // is turned on by WOPI, let it close all sessions
-        if (_isDocumentOwner && _wopiFileInfo && _wopiFileInfo->_enableOwnerTermination)
+        if (_isDocumentOwner && _wopiFileInfo && _wopiFileInfo->getEnableOwnerTermination())
         {
             LOG_DBG("Session [" << getId() << "] requested owner termination");
             docBroker->closeDocument("ownertermination");
@@ -567,12 +567,12 @@ bool ClientSession::filterMessage(const std::string& message) const
         std::string id;
         if (getTokenString(tokens[2], "id", id))
         {
-            if (id == "print" && _wopiFileInfo && _wopiFileInfo->_disablePrint)
+            if (id == "print" && _wopiFileInfo && _wopiFileInfo->getDisablePrint())
             {
                 allowed = false;
                 LOG_WRN("WOPI host has disabled print for this session");
             }
-            else if (id == "export" && _wopiFileInfo && _wopiFileInfo->_disableExport)
+            else if (id == "export" && _wopiFileInfo && _wopiFileInfo->getDisableExport())
             {
                 allowed = false;
                 LOG_WRN("WOPI host has disabled export for this session");
@@ -586,7 +586,7 @@ bool ClientSession::filterMessage(const std::string& message) const
     }
     else if (tokens[0] == "gettextselection" || tokens[0] == ".uno:Copy")
     {
-        if (_wopiFileInfo && _wopiFileInfo->_disableCopy)
+        if (_wopiFileInfo && _wopiFileInfo->getDisableCopy())
         {
             allowed = false;
             LOG_WRN("WOPI host has disabled copying from the document");
@@ -884,9 +884,9 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt
                 if (unoStatePair.first == ".uno:TrackChanges")
                 {
                     if ((unoStatePair.second == "true" &&
-                         _wopiFileInfo && _wopiFileInfo->_disableChangeTrackingRecord == WopiStorage::WOPIFileInfo::TriState::True) ||
+                         _wopiFileInfo && _wopiFileInfo->getDisableChangeTrackingRecord() == WopiStorage::WOPIFileInfo::TriState::True) ||
                         (unoStatePair.second == "false" &&
-                         _wopiFileInfo && _wopiFileInfo->_disableChangeTrackingRecord == WopiStorage::WOPIFileInfo::TriState::False))
+                         _wopiFileInfo && _wopiFileInfo->getDisableChangeTrackingRecord() == WopiStorage::WOPIFileInfo::TriState::False))
                     {
                         // Toggle the TrackChanges state.
                         LOG_DBG("Forcing " << unoStatePair.first << " toggle per user settings.");
@@ -896,9 +896,9 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt
                 else if (unoStatePair.first == ".uno:ShowTrackedChanges")
                 {
                     if ((unoStatePair.second == "true" &&
-                         _wopiFileInfo && _wopiFileInfo->_disableChangeTrackingShow == WopiStorage::WOPIFileInfo::TriState::True) ||
+                         _wopiFileInfo && _wopiFileInfo->getDisableChangeTrackingShow() == WopiStorage::WOPIFileInfo::TriState::True) ||
                         (unoStatePair.second == "false" &&
-                         _wopiFileInfo && _wopiFileInfo->_disableChangeTrackingShow == WopiStorage::WOPIFileInfo::TriState::False))
+                         _wopiFileInfo && _wopiFileInfo->getDisableChangeTrackingShow() == WopiStorage::WOPIFileInfo::TriState::False))
                     {
                         // Toggle the ShowTrackChanges state.
                         LOG_DBG("Forcing " << unoStatePair.first << " toggle per user settings.");
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index c14e5a111..2b51934e1 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -493,12 +493,12 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s
     if (wopiStorage != nullptr)
     {
         std::unique_ptr<WopiStorage::WOPIFileInfo> wopifileinfo = wopiStorage->getWOPIFileInfo(session->getAuthorization());
-        userId = wopifileinfo->_userId;
-        username = wopifileinfo->_username;
-        userExtraInfo = wopifileinfo->_userExtraInfo;
-        watermarkText = wopifileinfo->_watermarkText;
+        userId = wopifileinfo->getUserId();
+        username = wopifileinfo->getUsername();
+        userExtraInfo = wopifileinfo->getUserExtraInfo();
+        watermarkText = wopifileinfo->getWatermarkText();
 
-        if (!wopifileinfo->_userCanWrite ||
+        if (!wopifileinfo->getUserCanWrite() ||
             LOOLWSD::IsViewFileExtension(wopiStorage->getFileExtension()))
         {
             LOG_DBG("Setting the session as readonly");
@@ -507,38 +507,38 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s
 
         // Construct a JSON containing relevant WOPI host properties
         Object::Ptr wopiInfo = new Object();
-        if (!wopifileinfo->_postMessageOrigin.empty())
+        if (!wopifileinfo->getPostMessageOrigin().empty())
         {
             // Update the scheme to https if ssl or ssl termination is on
-            if (wopifileinfo->_postMessageOrigin.substr(0, 7) == "http://" &&
+            if (wopifileinfo->getPostMessageOrigin().substr(0, 7) == "http://" &&
                 (LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()))
             {
-                wopifileinfo->_postMessageOrigin.replace(0, 4, "https");
-                LOG_DBG("Updating PostMessageOrgin scheme to HTTPS. Updated origin is [" << wopifileinfo->_postMessageOrigin << "].");
+                wopifileinfo->getPostMessageOrigin().replace(0, 4, "https");
+                LOG_DBG("Updating PostMessageOrgin scheme to HTTPS. Updated origin is [" << wopifileinfo->getPostMessageOrigin() << "].");
             }
 
-            wopiInfo->set("PostMessageOrigin", wopifileinfo->_postMessageOrigin);
+            wopiInfo->set("PostMessageOrigin", wopifileinfo->getPostMessageOrigin());
         }
 
         // If print, export are disabled, order client to hide these options in the UI
-        if (wopifileinfo->_disablePrint)
-            wopifileinfo->_hidePrintOption = true;
-        if (wopifileinfo->_disableExport)
-            wopifileinfo->_hideExportOption = true;
+        if (wopifileinfo->getDisablePrint())
+            wopifileinfo->setHidePrintOption(true);
+        if (wopifileinfo->getDisableExport())
+            wopifileinfo->setHideExportOption(true);
 
         wopiInfo->set("BaseFileName", wopiStorage->getFileInfo()._filename);
-        wopiInfo->set("HidePrintOption", wopifileinfo->_hidePrintOption);
-        wopiInfo->set("HideSaveOption", wopifileinfo->_hideSaveOption);
-        wopiInfo->set("HideExportOption", wopifileinfo->_hideExportOption);
-        wopiInfo->set("DisablePrint", wopifileinfo->_disablePrint);
-        wopiInfo->set("DisableExport", wopifileinfo->_disableExport);
-        wopiInfo->set("DisableCopy", wopifileinfo->_disableCopy);
-        wopiInfo->set("DisableInactiveMessages", wopifileinfo->_disableInactiveMessages);
-        wopiInfo->set("UserCanNotWriteRelative", wopifileinfo->_userCanNotWriteRelative);
-        wopiInfo->set("EnableInsertRemoteImage", wopifileinfo->_enableInsertRemoteImage);
-        wopiInfo->set("EnableShare", wopifileinfo->_enableShare);
-        if (wopifileinfo->_hideChangeTrackingControls != WopiStorage::WOPIFileInfo::TriState::Unset)
-            wopiInfo->set("HideChangeTrackingControls", wopifileinfo->_hideChangeTrackingControls == WopiStorage::WOPIFileInfo::TriState::True);
+        wopiInfo->set("HidePrintOption", wopifileinfo->getHidePrintOption());
+        wopiInfo->set("HideSaveOption", wopifileinfo->getHideSaveOption());
+        wopiInfo->set("HideExportOption", wopifileinfo->getHideExportOption());
+        wopiInfo->set("DisablePrint", wopifileinfo->getDisablePrint());
+        wopiInfo->set("DisableExport", wopifileinfo->getDisableExport());
+        wopiInfo->set("DisableCopy", wopifileinfo->getDisableCopy());
+        wopiInfo->set("DisableInactiveMessages", wopifileinfo->getDisableInactiveMessages());
+        wopiInfo->set("UserCanNotWriteRelative", wopifileinfo->getUserCanNotWriteRelative());
+        wopiInfo->set("EnableInsertRemoteImage", wopifileinfo->getEnableInsertRemoteImage());
+        wopiInfo->set("EnableShare", wopifileinfo->getEnableShare());
+        if (wopifileinfo->getHideChangeTrackingControls() != WopiStorage::WOPIFileInfo::TriState::Unset)
+            wopiInfo->set("HideChangeTrackingControls", wopifileinfo->getHideChangeTrackingControls() == WopiStorage::WOPIFileInfo::TriState::True);
 
         std::ostringstream ossWopiInfo;
         wopiInfo->stringify(ossWopiInfo);
@@ -557,7 +557,7 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s
             session->setDocumentOwner(true);
         }
 
-        getInfoCallDuration = wopifileinfo->_callDuration;
+        getInfoCallDuration = wopifileinfo->getCallDuration();
 
         // Pass the ownership to client session
         session->setWopiFileInfo(wopifileinfo);
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index cbb6f9c42..4d546725b 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -317,6 +317,53 @@ public:
                 _userExtraInfo = userExtraInfo;
             }
 
+        const std::string& getUserId() const { return _userId; }
+
+        const std::string& getUsername() const { return _username; }
+
+        const std::string& getUserExtraInfo() const { return _userExtraInfo; }
+
+        const std::string& getWatermarkText() const { return _watermarkText; }
+
+        bool getUserCanWrite() const { return _userCanWrite; }
+
+        std::string& getPostMessageOrigin() { return _postMessageOrigin; }
+
+        void setHidePrintOption(bool hidePrintOption) { _hidePrintOption = hidePrintOption; }
+
+        bool getHidePrintOption() const { return _hidePrintOption; }
+
+        bool getHideSaveOption() const { return _hideSaveOption; }
+
+        void setHideExportOption(bool hideExportOption) { _hideExportOption = hideExportOption; }
+
+        bool getHideExportOption() const { return _hideExportOption; }
+
+        bool getEnableOwnerTermination() const { return _enableOwnerTermination; }
+
+        bool getDisablePrint() const { return _disablePrint; }
+
+        bool getDisableExport() const { return _disableExport; }
+
+        bool getDisableCopy() const { return _disableCopy; }
+
+        bool getDisableInactiveMessages() const { return _disableInactiveMessages; }
+
+        bool getUserCanNotWriteRelative() const { return _userCanNotWriteRelative; }
+
+        bool getEnableInsertRemoteImage() const { return _enableInsertRemoteImage; }
+
+        bool getEnableShare() const { return _enableShare; }
+
+        TriState getDisableChangeTrackingShow() const { return _disableChangeTrackingShow; }
+
+        TriState getDisableChangeTrackingRecord() const { return _disableChangeTrackingRecord; }
+
+        TriState getHideChangeTrackingControls() const { return _hideChangeTrackingControls; }
+
+        std::chrono::duration<double> getCallDuration() const { return _callDuration; }
+
+    private:
         /// User id of the user accessing the file
         std::string _userId;
         /// Obfuscated User id used for logging the UserId.


More information about the Libreoffice-commits mailing list