[Libreoffice-commits] online.git: loolwsd/Storage.cpp loolwsd/Storage.hpp loolwsd/test loolwsd/Unit.cpp loolwsd/Unit.hpp
Miklos Vajna
vmiklos at collabora.co.uk
Tue Jun 7 07:19:13 UTC 2016
loolwsd/Storage.cpp | 24 ++++++++++++------------
loolwsd/Storage.hpp | 6 +++---
loolwsd/Unit.cpp | 28 ++++++++++++++--------------
loolwsd/Unit.hpp | 10 +++++-----
loolwsd/test/UnitTimeout.cpp | 8 ++++----
5 files changed, 38 insertions(+), 38 deletions(-)
New commits:
commit f209773f0aae1498e0fc5a65a4b8676d7a63448f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jun 7 09:18:49 2016 +0200
loolwsd: fix naming style of static members
README suggests not using an initial underscore for those. Rename the
few cases which don't respect this recommendation.
Change-Id: If36a36da9374597f6b9090e7f81a1b3fb2f23647
diff --git a/loolwsd/Storage.cpp b/loolwsd/Storage.cpp
index 591f1ec..ed42978 100644
--- a/loolwsd/Storage.cpp
+++ b/loolwsd/Storage.cpp
@@ -35,9 +35,9 @@
///////////////////
// StorageBase Impl
///////////////////
-bool StorageBase::_filesystemEnabled;
-bool StorageBase::_wopiEnabled;
-Util::RegexListMatcher StorageBase::_wopiHosts;
+bool StorageBase::FilesystemEnabled;
+bool StorageBase::WopiEnabled;
+Util::RegexListMatcher StorageBase::WopiHosts;
std::string StorageBase::getLocalRootPath() const
{
@@ -63,12 +63,12 @@ size_t StorageBase::getFileSize(const std::string& filename)
void StorageBase::initialize()
{
const auto& app = Poco::Util::Application::instance();
- _filesystemEnabled = app.config().getBool("storage.filesystem[@allow]", false);
+ FilesystemEnabled = app.config().getBool("storage.filesystem[@allow]", false);
// Parse the WOPI settings.
- _wopiHosts.clear();
- _wopiEnabled = app.config().getBool("storage.wopi[@allow]", false);
- if (_wopiEnabled)
+ WopiHosts.clear();
+ WopiEnabled = app.config().getBool("storage.wopi[@allow]", false);
+ if (WopiEnabled)
{
for (size_t i = 0; ; ++i)
{
@@ -79,12 +79,12 @@ void StorageBase::initialize()
if (app.config().getBool(path + "[@allow]", false))
{
Log::info("Adding trusted WOPI host: [" + host + "].");
- _wopiHosts.allow(host);
+ WopiHosts.allow(host);
}
else
{
Log::info("Adding blocked WOPI host: [" + host + "].");
- _wopiHosts.deny(host);
+ WopiHosts.deny(host);
}
}
else if (!app.config().has(path))
@@ -141,18 +141,18 @@ std::unique_ptr<StorageBase> StorageBase::create(const std::string& jailRoot, co
else if (uri.isRelative() || uri.getScheme() == "file")
{
Log::info("Public URI [" + uri.toString() + "] is a file.");
- if (_filesystemEnabled)
+ if (FilesystemEnabled)
{
return std::unique_ptr<StorageBase>(new LocalStorage(jailRoot, jailPath, uri.getPath()));
}
Log::error("Local Storage is disabled by default. Specify allowlocalstorage on the command-line to enable.");
}
- else if (_wopiEnabled)
+ else if (WopiEnabled)
{
Log::info("Public URI [" + uri.toString() + "] considered WOPI.");
const auto& targetHost = uri.getHost();
- if (_wopiHosts.match(targetHost) || isLocalhost(targetHost))
+ if (WopiHosts.match(targetHost) || isLocalhost(targetHost))
{
return std::unique_ptr<StorageBase>(new WopiStorage(jailRoot, jailPath, uri.toString()));
}
diff --git a/loolwsd/Storage.hpp b/loolwsd/Storage.hpp
index 1ccd1df..493676f 100644
--- a/loolwsd/Storage.hpp
+++ b/loolwsd/Storage.hpp
@@ -86,10 +86,10 @@ protected:
std::string _jailedFilePath;
FileInfo _fileInfo;
- static bool _filesystemEnabled;
- static bool _wopiEnabled;
+ static bool FilesystemEnabled;
+ static bool WopiEnabled;
/// Allowed/denied WOPI hosts, if any and if WOPI is enabled.
- static Util::RegexListMatcher _wopiHosts;
+ static Util::RegexListMatcher WopiHosts;
};
/// Trivial implementation of local storage that does not need do anything.
diff --git a/loolwsd/Unit.cpp b/loolwsd/Unit.cpp
index c0b9f18..c566a08 100644
--- a/loolwsd/Unit.cpp
+++ b/loolwsd/Unit.cpp
@@ -21,7 +21,7 @@
#include "Log.hpp"
#include "Util.hpp"
-UnitBase *UnitBase::_global = nullptr;
+UnitBase *UnitBase::Global = nullptr;
static Poco::Thread TimeoutThread("unit timeout");
@@ -61,18 +61,18 @@ UnitBase *UnitBase::linkAndCreateUnit(UnitType type, const std::string &unitLibP
bool UnitBase::init(UnitType type, const std::string &unitLibPath)
{
- assert(!_global);
+ assert(!Global);
if (!unitLibPath.empty())
{
- _global = linkAndCreateUnit(type, unitLibPath);
- if (_global)
+ Global = linkAndCreateUnit(type, unitLibPath);
+ if (Global)
{
TimeoutThread.startFunc([](){
- TimeoutThread.trySleep(_global->_timeoutMilliSeconds);
- if (!_global->_timeoutShutdown)
+ TimeoutThread.trySleep(Global->_timeoutMilliSeconds);
+ if (!Global->_timeoutShutdown)
{
Log::error("Unit test timeout");
- _global->timeout();
+ Global->timeout();
}
});
}
@@ -82,10 +82,10 @@ bool UnitBase::init(UnitType type, const std::string &unitLibPath)
switch (type)
{
case TYPE_WSD:
- _global = new UnitWSD();
+ Global = new UnitWSD();
break;
case TYPE_KIT:
- _global = new UnitKit();
+ Global = new UnitKit();
break;
default:
assert(false);
@@ -93,10 +93,10 @@ bool UnitBase::init(UnitType type, const std::string &unitLibPath)
}
}
- if (_global)
- _global->_type = type;
+ if (Global)
+ Global->_type = type;
- return _global != NULL;
+ return Global != NULL;
}
void UnitBase::setTimeout(int timeoutMilliSeconds)
@@ -175,8 +175,8 @@ void UnitBase::returnValue(int &retValue)
TimeoutThread.wakeUp();
TimeoutThread.join();
- delete _global;
- _global = nullptr;
+ delete Global;
+ Global = nullptr;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/Unit.hpp b/loolwsd/Unit.hpp
index 9cebfaa..1fdec4c 100644
--- a/loolwsd/Unit.hpp
+++ b/loolwsd/Unit.hpp
@@ -83,7 +83,7 @@ private:
int _retValue;
int _timeoutMilliSeconds;
std::atomic<bool> _timeoutShutdown;
- static UnitBase *_global;
+ static UnitBase *Global;
UnitType _type;
};
@@ -97,8 +97,8 @@ public:
static UnitWSD &get()
{
- assert (_global && _global->_type == UnitType::TYPE_WSD);
- return *static_cast<UnitWSD *>(_global);
+ assert (Global && Global->_type == UnitType::TYPE_WSD);
+ return *static_cast<UnitWSD *>(Global);
}
enum TestRequest { TEST_REQ_CLIENT, TEST_REQ_PRISONER };
@@ -170,8 +170,8 @@ public:
virtual ~UnitKit();
static UnitKit &get()
{
- assert (_global && _global->_type == UnitType::TYPE_KIT);
- return *static_cast<UnitKit *>(_global);
+ assert (Global && Global->_type == UnitType::TYPE_KIT);
+ return *static_cast<UnitKit *>(Global);
}
// ---------------- ForKit hooks ----------------
diff --git a/loolwsd/test/UnitTimeout.cpp b/loolwsd/test/UnitTimeout.cpp
index 6730de2..ad0df80 100644
--- a/loolwsd/test/UnitTimeout.cpp
+++ b/loolwsd/test/UnitTimeout.cpp
@@ -52,12 +52,12 @@ public:
{
bool madeWSD = init(UnitType::TYPE_WSD, std::string());
assert(madeWSD);
- delete UnitBase::_global;
- UnitBase::_global = NULL;
+ delete UnitBase::Global;
+ UnitBase::Global = NULL;
bool madeKit = init(UnitType::TYPE_KIT, std::string());
assert(madeKit);
- delete UnitBase::_global;
- UnitBase::_global = NULL;
+ delete UnitBase::Global;
+ UnitBase::Global = NULL;
}
};
More information about the Libreoffice-commits
mailing list