[Libreoffice-commits] online.git: loolwsd/Admin.hpp loolwsd/AdminModel.hpp loolwsd/Auth.hpp loolwsd/ChildSession.hpp loolwsd/ClientSession.hpp loolwsd/DocumentBroker.cpp loolwsd/DocumentBroker.hpp loolwsd/Exceptions.hpp loolwsd/FileServer.hpp loolwsd/IoUtil.hpp loolwsd/Log.hpp loolwsd/LOKitHelper.hpp loolwsd/LOOLKit.hpp loolwsd/LOOLProtocol.hpp loolwsd/LOOLSession.hpp loolwsd/LOOLWSD.cpp loolwsd/LOOLWSD.hpp loolwsd/MessageQueue.hpp loolwsd/Png.hpp loolwsd/PrisonerSession.hpp loolwsd/QueueHandler.hpp loolwsd/Storage.hpp loolwsd/test loolwsd/TileCache.hpp loolwsd/TileDesc.hpp loolwsd/Unit.hpp loolwsd/UnitHTTP.hpp loolwsd/Util.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Oct 31 06:06:55 UTC 2016
loolwsd/Admin.hpp | 5 -
loolwsd/AdminModel.hpp | 1
loolwsd/Auth.hpp | 3
loolwsd/ChildSession.hpp | 78 ++++++++---------
loolwsd/ClientSession.hpp | 18 +---
loolwsd/DocumentBroker.cpp | 23 ++---
loolwsd/DocumentBroker.hpp | 15 +--
loolwsd/Exceptions.hpp | 3
loolwsd/FileServer.hpp | 2
loolwsd/IoUtil.hpp | 7 -
loolwsd/LOKitHelper.hpp | 16 +--
loolwsd/LOOLKit.hpp | 3
loolwsd/LOOLProtocol.hpp | 5 -
loolwsd/LOOLSession.hpp | 31 +++----
loolwsd/LOOLWSD.cpp | 178 ++++++++++++++++++++---------------------
loolwsd/LOOLWSD.hpp | 31 ++-----
loolwsd/Log.hpp | 85 ++++++++-----------
loolwsd/MessageQueue.hpp | 4
loolwsd/Png.hpp | 2
loolwsd/PrisonerSession.hpp | 4
loolwsd/QueueHandler.hpp | 6 -
loolwsd/Storage.hpp | 11 +-
loolwsd/TileCache.hpp | 10 +-
loolwsd/TileDesc.hpp | 28 ++----
loolwsd/Unit.hpp | 102 ++++++++++++++---------
loolwsd/UnitHTTP.hpp | 84 ++++++++++++-------
loolwsd/Util.hpp | 25 ++---
loolwsd/test/countloolkits.hpp | 6 -
loolwsd/test/helpers.hpp | 6 -
29 files changed, 393 insertions(+), 399 deletions(-)
New commits:
commit 773c15f7103e85cbe33b897316050841a269c526
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sat Oct 29 21:15:00 2016 -0400
loolwsd: consistent formatting
With the help of clang-format.
For reference, the following command was used,
but not all changes were commited:
clang-format-3.9 -style='{BasedOnStyle: WebKit,
AlignAfterOpenBracket: Align,
AlwaysBreakAfterReturnType: None,
BreakBeforeBraces: Allman,
DerivePointerAlignment: 'true',
ExperimentalAutoDetectBinPacking: 'true',
IndentWrappedFunctionNames: 'true',
UseTab: Never}'
Change-Id: I0f7490c7ee38aeefeefcf9d5d4c3dab380cd63b8
Reviewed-on: https://gerrit.libreoffice.org/30416
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/Admin.hpp b/loolwsd/Admin.hpp
index 699b2e2..e82775d 100644
--- a/loolwsd/Admin.hpp
+++ b/loolwsd/Admin.hpp
@@ -27,7 +27,7 @@
class Admin;
/// Admin requests over HTTP(S) handler.
-class AdminRequestHandler: public Poco::Net::HTTPRequestHandler
+class AdminRequestHandler : public Poco::Net::HTTPRequestHandler
{
public:
AdminRequestHandler(Admin* adminManager);
@@ -87,8 +87,7 @@ public:
void rescheduleCpuTimer(unsigned interval);
- static
- AdminRequestHandler* createRequestHandler()
+ static AdminRequestHandler* createRequestHandler()
{
return new AdminRequestHandler(&instance());
}
diff --git a/loolwsd/AdminModel.hpp b/loolwsd/AdminModel.hpp
index 1fff82c..61286b7 100644
--- a/loolwsd/AdminModel.hpp
+++ b/loolwsd/AdminModel.hpp
@@ -170,7 +170,6 @@ public:
void removeDocument(const std::string& docKey);
private:
-
std::string getMemStats();
std::string getCpuStats();
diff --git a/loolwsd/Auth.hpp b/loolwsd/Auth.hpp
index 664cfc1..87aa54b 100644
--- a/loolwsd/Auth.hpp
+++ b/loolwsd/Auth.hpp
@@ -20,7 +20,6 @@
class AuthBase
{
public:
-
/// Called to acquire an access token.
virtual const std::string getAccessToken() = 0;
@@ -29,7 +28,7 @@ public:
};
/// JWT Authorization.
-class JWTAuth: public AuthBase
+class JWTAuth : public AuthBase
{
public:
JWTAuth(const std::string& keyPath, const std::string& name, const std::string& sub, const std::string& aud)
diff --git a/loolwsd/ChildSession.hpp b/loolwsd/ChildSession.hpp
index 7b0a3ca..4730f72 100644
--- a/loolwsd/ChildSession.hpp
+++ b/loolwsd/ChildSession.hpp
@@ -12,8 +12,8 @@
#include <mutex>
-#include <Poco/Thread.h>
#include <Poco/NotificationQueue.h>
+#include <Poco/Thread.h>
#include "Common.hpp"
#include "LOOLKit.hpp"
@@ -28,32 +28,26 @@ class IDocumentManager
{
public:
/// Reqest loading a document, or a new view, if one exists.
- virtual
- std::shared_ptr<lok::Document> onLoad(const std::string& sessionId,
- const std::string& jailedFilePath,
- const std::string& userName,
- const std::string& docPassword,
- const std::string& renderOpts,
- const bool haveDocPassword) = 0;
+ virtual std::shared_ptr<lok::Document> onLoad(const std::string& sessionId,
+ const std::string& jailedFilePath,
+ const std::string& userName,
+ const std::string& docPassword,
+ const std::string& renderOpts,
+ const bool haveDocPassword)
+ = 0;
/// Unload a client session, which unloads the document
/// if it is the last and only.
- virtual
- void onUnload(const ChildSession& session) = 0;
+ virtual void onUnload(const ChildSession& session) = 0;
/// Send updated view info to all active sessions
- virtual
- void notifyViewInfo(const std::vector<int>& viewIds) = 0;
+ virtual void notifyViewInfo(const std::vector<int>& viewIds) = 0;
/// Get a view ID <-> UserInfo map.
- virtual
- std::map<int, UserInfo> getViewInfo() = 0;
- virtual
- std::mutex& getMutex() = 0;
- virtual
- std::shared_ptr<TileQueue>& getTileQueue() = 0;
-
- virtual
- bool sendTextFrame(const std::string& message) = 0;
+ virtual std::map<int, UserInfo> getViewInfo() = 0;
+ virtual std::mutex& getMutex() = 0;
+ virtual std::shared_ptr<TileQueue>& getTileQueue() = 0;
+
+ virtual bool sendTextFrame(const std::string& message) = 0;
};
/// Represents a session to the WSD process, in a Kit process. Note that this is not a singleton.
@@ -72,8 +66,8 @@ public:
IDocumentManager& docManager);
virtual ~ChildSession();
- bool getStatus(const char *buffer, int length);
- bool getPartPageRectangles(const char *buffer, int length);
+ bool getStatus(const char* buffer, int length);
+ bool getPartPageRectangles(const char* buffer, int length);
int getViewId() const { return _viewId; }
void setViewId(const int viewId) { _viewId = viewId; }
const std::string& getViewUserId() const { return _userId; }
@@ -96,30 +90,30 @@ public:
}
private:
- bool loadDocument(const char *buffer, int length, Poco::StringTokenizer& tokens);
+ bool loadDocument(const char* buffer, int length, Poco::StringTokenizer& tokens);
- bool sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens);
- bool getCommandValues(const char *buffer, int length, Poco::StringTokenizer& tokens);
+ bool sendFontRendering(const char* buffer, int length, Poco::StringTokenizer& tokens);
+ bool getCommandValues(const char* buffer, int length, Poco::StringTokenizer& tokens);
- bool clientZoom(const char *buffer, int length, Poco::StringTokenizer& tokens);
- bool clientVisibleArea(const char *buffer, int length, Poco::StringTokenizer& tokens);
- bool downloadAs(const char *buffer, int length, Poco::StringTokenizer& tokens);
+ bool clientZoom(const char* buffer, int length, Poco::StringTokenizer& tokens);
+ bool clientVisibleArea(const char* buffer, int length, Poco::StringTokenizer& tokens);
+ bool downloadAs(const char* buffer, int length, Poco::StringTokenizer& tokens);
bool getChildId();
- bool getTextSelection(const char *buffer, int length, Poco::StringTokenizer& tokens);
- bool paste(const char *buffer, int length, Poco::StringTokenizer& tokens);
- bool insertFile(const char *buffer, int length, Poco::StringTokenizer& tokens);
- bool keyEvent(const char *buffer, int length, Poco::StringTokenizer& tokens);
- bool mouseEvent(const char *buffer, int length, Poco::StringTokenizer& tokens);
- bool unoCommand(const char *buffer, int length, Poco::StringTokenizer& tokens);
- bool selectText(const char *buffer, int length, Poco::StringTokenizer& tokens);
- bool selectGraphic(const char *buffer, int length, Poco::StringTokenizer& tokens);
- bool resetSelection(const char *buffer, int length, Poco::StringTokenizer& tokens);
- bool saveAs(const char *buffer, int length, Poco::StringTokenizer& tokens);
- bool setClientPart(const char *buffer, int length, Poco::StringTokenizer& tokens);
- bool setPage(const char *buffer, int length, Poco::StringTokenizer& tokens);
+ bool getTextSelection(const char* buffer, int length, Poco::StringTokenizer& tokens);
+ bool paste(const char* buffer, int length, Poco::StringTokenizer& tokens);
+ bool insertFile(const char* buffer, int length, Poco::StringTokenizer& tokens);
+ bool keyEvent(const char* buffer, int length, Poco::StringTokenizer& tokens);
+ bool mouseEvent(const char* buffer, int length, Poco::StringTokenizer& tokens);
+ bool unoCommand(const char* buffer, int length, Poco::StringTokenizer& tokens);
+ bool selectText(const char* buffer, int length, Poco::StringTokenizer& tokens);
+ bool selectGraphic(const char* buffer, int length, Poco::StringTokenizer& tokens);
+ bool resetSelection(const char* buffer, int length, Poco::StringTokenizer& tokens);
+ bool saveAs(const char* buffer, int length, Poco::StringTokenizer& tokens);
+ bool setClientPart(const char* buffer, int length, Poco::StringTokenizer& tokens);
+ bool setPage(const char* buffer, int length, Poco::StringTokenizer& tokens);
virtual void disconnect() override;
- virtual bool _handleInput(const char *buffer, int length) override;
+ virtual bool _handleInput(const char* buffer, int length) override;
private:
const std::string _jailId;
diff --git a/loolwsd/ClientSession.hpp b/loolwsd/ClientSession.hpp
index 8136b00..8713026 100644
--- a/loolwsd/ClientSession.hpp
+++ b/loolwsd/ClientSession.hpp
@@ -62,32 +62,30 @@ public:
const Poco::URI& getPublicUri() const { return _uriPublic; }
private:
+ virtual bool _handleInput(const char* buffer, int length) override;
- virtual bool _handleInput(const char *buffer, int length) override;
-
- bool loadDocument(const char *buffer, int length, Poco::StringTokenizer& tokens,
+ bool loadDocument(const char* buffer, int length, Poco::StringTokenizer& tokens,
const std::shared_ptr<DocumentBroker>& docBroker);
- bool getStatus(const char *buffer, int length,
+ bool getStatus(const char* buffer, int length,
const std::shared_ptr<DocumentBroker>& docBroker);
- bool getCommandValues(const char *buffer, int length, Poco::StringTokenizer& tokens,
+ bool getCommandValues(const char* buffer, int length, Poco::StringTokenizer& tokens,
const std::shared_ptr<DocumentBroker>& docBroker);
- bool getPartPageRectangles(const char *buffer, int length,
+ bool getPartPageRectangles(const char* buffer, int length,
const std::shared_ptr<DocumentBroker>& docBroker);
- bool sendTile(const char *buffer, int length, Poco::StringTokenizer& tokens,
+ bool sendTile(const char* buffer, int length, Poco::StringTokenizer& tokens,
const std::shared_ptr<DocumentBroker>& docBroker);
- bool sendCombinedTiles(const char *buffer, int length, Poco::StringTokenizer& tokens,
+ bool sendCombinedTiles(const char* buffer, int length, Poco::StringTokenizer& tokens,
const std::shared_ptr<DocumentBroker>& docBroker);
- bool sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens,
+ bool sendFontRendering(const char* buffer, int length, Poco::StringTokenizer& tokens,
const std::shared_ptr<DocumentBroker>& docBroker);
bool forwardToChild(const std::string& message,
const std::shared_ptr<DocumentBroker>& docBroker);
private:
-
std::weak_ptr<DocumentBroker> _docBroker;
/// URI with which client made request to us
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 2e24c72..10aef26 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -77,10 +77,9 @@ std::string getCachePath(const std::string& uri)
digestEngine.update(uri.c_str(), uri.size());
- return (LOOLWSD::Cache + "/" +
+ return (LOOLWSD::Cache + '/' +
Poco::DigestEngine::digestToHex(digestEngine.digest()).insert(3, "/").insert(2, "/").insert(1, "/"));
}
-
}
Poco::URI DocumentBroker::sanitizeURI(const std::string& uri)
@@ -169,7 +168,7 @@ DocumentBroker::~DocumentBroker()
Admin::instance().rmDoc(_docKey);
Log::info() << "~DocumentBroker [" << _uriPublic.toString()
- << "] destroyed with " << getSessionsCount()
+ << "] destroyed with " << _sessions.size()
<< " sessions left." << Log::end;
}
@@ -374,7 +373,7 @@ bool DocumentBroker::autoSave(const bool force, const size_t waitTimeoutMs)
{
// Find the most recent activity.
double inactivityTimeMs = std::numeric_limits<double>::max();
- for (auto& sessionIt: _sessions)
+ for (auto& sessionIt : _sessions)
{
inactivityTimeMs = std::min(sessionIt.second->getInactivityMS(), inactivityTimeMs);
}
@@ -413,7 +412,7 @@ bool DocumentBroker::sendUnoSave(const bool dontSaveIfUnmodified)
Util::assertIsLocked(_mutex);
// Save using session holding the edit-lock (or first if multview).
- for (auto& sessionIt: _sessions)
+ for (auto& sessionIt : _sessions)
{
// Invalidate the timestamp to force persisting.
_lastFileModifiedTime.fromEpochTime(0);
@@ -565,7 +564,7 @@ void DocumentBroker::alertAllUsersOfDocument(const std::string& cmd, const std::
std::stringstream ss;
ss << "error: cmd=" << cmd << " kind=" << kind;
- for (auto& it: _sessions)
+ for (auto& it : _sessions)
{
it.second->sendTextFrame(ss.str());
}
@@ -585,7 +584,7 @@ bool DocumentBroker::handleInput(const std::vector<char>& payload)
}
else if (command == "tilecombine:")
{
- handleTileCombinedResponse(payload);
+ handleTileCombinedResponse(payload);
}
else if (LOOLProtocol::getFirstToken(command, '-') == "client")
{
@@ -658,7 +657,8 @@ void DocumentBroker::handleTileRequest(TileDesc& tile,
tileCache().subscribeToTileRendering(tile, session);
// Forward to child to render.
- Log::debug() << "Sending render request for tile (" << tile.getPart() << ',' << tile.getTilePosX() << ',' << tile.getTilePosY() << ")." << Log::end;
+ Log::debug() << "Sending render request for tile (" << tile.getPart() << ','
+ << tile.getTilePosX() << ',' << tile.getTilePosY() << ")." << Log::end;
const std::string request = "tile " + tile.serialize();
_childProcess->sendTextFrame(request);
_debugRenderedTileCount++;
@@ -746,9 +746,8 @@ void DocumentBroker::handleTileResponse(const std::vector<char>& payload)
if (firstLine.size() < static_cast<std::string::size_type>(length) - 1)
{
- tileCache().saveTileAndNotify(
- tile, buffer + firstLine.size() + 1,
- length - firstLine.size() - 1);
+ const auto offset = firstLine.size() + 1;
+ tileCache().saveTileAndNotify(tile, buffer + offset, length - offset);
}
else
{
@@ -814,7 +813,7 @@ bool DocumentBroker::startDestroy(const std::string& id)
_lastEditableSession = !currentSession->second->isReadOnly();
if (_lastEditableSession && !_sessions.empty())
{
- for (const auto& it: _sessions)
+ for (const auto& it : _sessions)
{
if (it.second->getId() != id &&
!it.second->isReadOnly())
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index 39bc19a..f538fc3 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -21,8 +21,8 @@
#include <string>
#include <thread>
-#include <Poco/URI.h>
#include <Poco/Net/WebSocket.h>
+#include <Poco/URI.h>
#include "IoUtil.hpp"
#include "Log.hpp"
@@ -92,7 +92,7 @@ public:
Log::syserror("Cannot terminate lokit [" + std::to_string(_pid) + "]. Abandoning.");
}
- _pid = -1;
+ _pid = -1;
}
}
catch (const std::exception& ex)
@@ -161,13 +161,11 @@ class ClientSession;
class DocumentBroker : public std::enable_shared_from_this<DocumentBroker>
{
public:
-
static Poco::URI sanitizeURI(const std::string& uri);
/// Returns a document-specific key based
/// on the URI of the document.
- static
- std::string getDocKey(const Poco::URI& uri);
+ static std::string getDocKey(const Poco::URI& uri);
/// Dummy document broker that is marked to destroy.
DocumentBroker();
@@ -265,13 +263,16 @@ public:
/// Currently, only makes sense in case storage is WOPI
const std::chrono::duration<double> getStorageLoadDuration() const;
+ /// Called by the ChildProcess object to notify
+ /// that it has terminated on its own.
+ /// This happens either when the child exists
+ /// or upon failing to process an incoming message.
void childSocketTerminated();
/// Get the PID of the associated child process
Poco::Process::PID getPid() const { return _childProcess->getPid(); }
private:
-
/// Sends the .uno:Save command to LoKit.
bool sendUnoSave(const bool dontSaveIfUnmodified);
@@ -292,7 +293,7 @@ private:
std::string _filename;
std::chrono::steady_clock::time_point _lastSaveTime;
Poco::Timestamp _lastFileModifiedTime;
- std::map<std::string, std::shared_ptr<ClientSession>> _sessions;
+ std::map<std::string, std::shared_ptr<ClientSession> > _sessions;
std::unique_ptr<StorageBase> _storage;
std::unique_ptr<TileCache> _tileCache;
std::atomic<bool> _markToDestroy;
diff --git a/loolwsd/Exceptions.hpp b/loolwsd/Exceptions.hpp
index fee8d8b..ae2d1a6 100644
--- a/loolwsd/Exceptions.hpp
+++ b/loolwsd/Exceptions.hpp
@@ -12,8 +12,8 @@
#ifndef INCLUDED_EXCEPTIONS_HPP
#define INCLUDED_EXCEPTIONS_HPP
-#include <stdexcept>
#include <exception>
+#include <stdexcept>
// Generic LOOL errors and base for others.
class LoolException : public std::runtime_error
@@ -67,7 +67,6 @@ public:
using LoolException::LoolException;
};
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/FileServer.hpp b/loolwsd/FileServer.hpp
index 04bf7f1..20a9c8f 100644
--- a/loolwsd/FileServer.hpp
+++ b/loolwsd/FileServer.hpp
@@ -25,7 +25,7 @@
#include "Log.hpp"
/// Handles file requests over HTTP(S).
-class FileServerRequestHandler: public Poco::Net::HTTPRequestHandler
+class FileServerRequestHandler : public Poco::Net::HTTPRequestHandler
{
std::string getRequestPathname(const Poco::Net::HTTPServerRequest& request);
diff --git a/loolwsd/IoUtil.hpp b/loolwsd/IoUtil.hpp
index 69819c2..564cef5 100644
--- a/loolwsd/IoUtil.hpp
+++ b/loolwsd/IoUtil.hpp
@@ -11,13 +11,13 @@
#define INCLUDED_IOUTIL_HPP
#include <functional>
-#include <string>
#include <memory>
+#include <string>
#include <sys/poll.h>
-#include <Poco/Net/WebSocket.h>
#include <Poco/Logger.h>
+#include <Poco/Net/WebSocket.h>
namespace IoUtil
{
@@ -37,8 +37,7 @@ namespace IoUtil
void shutdownWebSocket(const std::shared_ptr<Poco::Net::WebSocket>& ws);
ssize_t writeToPipe(int pipe, const char* buffer, ssize_t size);
- inline
- ssize_t writeToPipe(int pipe, const std::string& message)
+ inline ssize_t writeToPipe(int pipe, const std::string& message)
{
return writeToPipe(pipe, message.c_str(), message.size());
}
diff --git a/loolwsd/LOKitHelper.hpp b/loolwsd/LOKitHelper.hpp
index 2986dc3..f029450 100644
--- a/loolwsd/LOKitHelper.hpp
+++ b/loolwsd/LOKitHelper.hpp
@@ -10,8 +10,8 @@
#ifndef INCLUDED_LOKITHELPER_HPP
#define INCLUDED_LOKITHELPER_HPP
-#include <string>
#include <sstream>
+#include <string>
#define LOK_USE_UNSTABLE_API
#include <LibreOfficeKit/LibreOfficeKit.h>
@@ -19,8 +19,7 @@
namespace LOKitHelper
{
- inline
- std::string documentTypeToString(LibreOfficeKitDocumentType type)
+ inline std::string documentTypeToString(LibreOfficeKitDocumentType type)
{
switch (type)
{
@@ -37,16 +36,14 @@ namespace LOKitHelper
}
}
- inline
- std::string getDocumentTypeAsString(LibreOfficeKitDocument *loKitDocument)
+ inline std::string getDocumentTypeAsString(LibreOfficeKitDocument *loKitDocument)
{
assert(loKitDocument && "null loKitDocument");
const auto type = static_cast<LibreOfficeKitDocumentType>(loKitDocument->pClass->getDocumentType(loKitDocument));
return documentTypeToString(type);
}
- inline
- std::string kitCallbackTypeToString(const int nType)
+ inline std::string kitCallbackTypeToString(const int nType)
{
// Keep in the same order as in LibreOfficeKitEnums.h
switch (nType)
@@ -116,10 +113,9 @@ namespace LOKitHelper
return std::to_string(nType);
}
- inline
- std::string documentStatus(LibreOfficeKitDocument *loKitDocument)
+ inline std::string documentStatus(LibreOfficeKitDocument *loKitDocument)
{
- char* ptrValue;
+ char *ptrValue;
assert(loKitDocument && "null loKitDocument");
const auto type = static_cast<LibreOfficeKitDocumentType>(loKitDocument->pClass->getDocumentType(loKitDocument));
diff --git a/loolwsd/LOOLKit.hpp b/loolwsd/LOOLKit.hpp
index 61196fa..b60ebe2 100644
--- a/loolwsd/LOOLKit.hpp
+++ b/loolwsd/LOOLKit.hpp
@@ -17,7 +17,7 @@ void lokit_main(const std::string& childRoot,
bool queryVersionInfo,
bool displayVersion);
-bool globalPreinit(const std::string &loTemplate);
+bool globalPreinit(const std::string& loTemplate);
/// Wrapper around private Document::ViewCallback().
void documentViewCallback(const int nType, const char* pPayload, void* pData);
@@ -40,7 +40,6 @@ struct UserInfo
std::string username;
};
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/LOOLProtocol.hpp b/loolwsd/LOOLProtocol.hpp
index f8204cc..855ca94 100644
--- a/loolwsd/LOOLProtocol.hpp
+++ b/loolwsd/LOOLProtocol.hpp
@@ -29,11 +29,10 @@ namespace LOOLProtocol
constexpr unsigned ProtocolMajorVersionNumber = 0;
constexpr unsigned ProtocolMinorVersionNumber = 1;
- inline
- std::string GetProtocolVersion()
+ inline std::string GetProtocolVersion()
{
return std::to_string(ProtocolMajorVersionNumber) + '.'
- + std::to_string(ProtocolMinorVersionNumber);
+ + std::to_string(ProtocolMinorVersionNumber);
}
// Parse a string into a version tuple.
diff --git a/loolwsd/LOOLSession.hpp b/loolwsd/LOOLSession.hpp
index 3c14f2d..b875e1d 100644
--- a/loolwsd/LOOLSession.hpp
+++ b/loolwsd/LOOLSession.hpp
@@ -16,17 +16,17 @@
#include <mutex>
#include <ostream>
-#include <Poco/Net/WebSocket.h>
#include <Poco/Buffer.h>
+#include <Poco/Net/WebSocket.h>
#include <Poco/Path.h>
#include <Poco/Process.h>
#include <Poco/StringTokenizer.h>
#include <Poco/Types.h>
-#include "MessageQueue.hpp"
#include "LOOLProtocol.hpp"
-#include "TileCache.hpp"
#include "Log.hpp"
+#include "MessageQueue.hpp"
+#include "TileCache.hpp"
/// Base class of a WebSocket session.
class LOOLSession
@@ -36,22 +36,25 @@ public:
/// 1) Between the master loolwsd server to the end-user LOOL client
/// 2) Between the master loolwsd server and a jailed child process, in the master process
/// 3) Ditto, in the jailed process
- enum class Kind { ToClient, ToPrisoner, ToMaster };
+ enum class Kind
+ {
+ ToClient,
+ ToPrisoner,
+ ToMaster
+ };
const std::string& getId() const { return _id; }
const std::string& getName() const { return _name; }
bool isDisconnected() const { return _disconnected; }
- virtual
- bool sendBinaryFrame(const char *buffer, int length);
- virtual
- bool sendTextFrame(const char* buffer, const int length);
+ virtual bool sendBinaryFrame(const char* buffer, int length);
+ virtual bool sendTextFrame(const char* buffer, const int length);
bool sendTextFrame(const std::string& text)
{
return sendTextFrame(text.data(), text.size());
}
- bool handleInput(const char *buffer, int length);
+ bool handleInput(const char* buffer, int length);
/// Invoked when we want to disconnect a session.
virtual void disconnect();
@@ -92,7 +95,7 @@ protected:
}
template <typename T>
- bool forwardToPeer(T& p, const char *buffer, int length, const bool binary)
+ bool forwardToPeer(T& p, const char* buffer, int length, const bool binary)
{
const auto message = LOOLProtocol::getAbbreviatedMessage(buffer, length);
@@ -126,11 +129,9 @@ protected:
}
private:
-
- virtual bool _handleInput(const char *buffer, int length) = 0;
+ 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;
@@ -185,8 +186,8 @@ protected:
std::string _userName;
};
-template<typename charT, typename traits>
-inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, traits> & stream, LOOLSession::Kind kind)
+template <typename charT, typename traits>
+inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream, LOOLSession::Kind kind)
{
switch (kind)
{
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 235c2b5..26a726e 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -25,8 +25,8 @@
#include <unistd.h>
-#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <sys/wait.h>
#include <cassert>
@@ -175,7 +175,8 @@ static std::mutex DocBrokersMutex;
static int careerSpanSeconds = 0;
#endif
-namespace {
+namespace
+{
static inline
void shutdownLimitReached(WebSocket& ws)
@@ -275,7 +276,7 @@ static bool cleanupChildren()
if (!NewChildren[i]->isAlive())
{
Log::warn() << "Removing unused dead child [" << NewChildren[i]->getPid()
- << "]." << Log::end;
+ << "]." << Log::end;
NewChildren.erase(NewChildren.begin() + i);
removed = true;
}
@@ -344,8 +345,8 @@ static size_t addNewChild(const std::shared_ptr<ChildProcess>& child)
NewChildren.emplace_back(child);
const auto count = NewChildren.size();
Log::info() << "Have " << count << " "
- << (count == 1 ? "child" : "children")
- << "." << Log::end;
+ << (count == 1 ? "child." : "children.")
+ << Log::end;
NewChildrenCV.notify_one();
return count;
@@ -378,7 +379,7 @@ static std::shared_ptr<ChildProcess> getNewChild()
forkChildren(balance);
const auto timeout = chrono::milliseconds(CHILD_TIMEOUT_MS);
- if (NewChildrenCV.wait_for(lock, timeout, [](){ return !NewChildren.empty(); }))
+ if (NewChildrenCV.wait_for(lock, timeout, []() { return !NewChildren.empty(); }))
{
auto child = NewChildren.back();
NewChildren.pop_back();
@@ -441,7 +442,7 @@ public:
};
/// Handle a public connection from a client.
-class ClientRequestHandler: public HTTPRequestHandler
+class ClientRequestHandler : public HTTPRequestHandler
{
private:
static std::string getContentType(const std::string& fileName)
@@ -507,7 +508,7 @@ private:
cleanupDocBrokers();
- //FIXME: What if the same document is already open? Need a fake dockey here?
+ // FIXME: What if the same document is already open? Need a fake dockey here?
Log::debug("New DocumentBroker for docKey [" + docKey + "].");
DocBrokers.emplace(docKey, docBroker);
@@ -525,7 +526,7 @@ private:
const std::string load = "load url=" + encodedFrom;
session->handleInput(load.data(), load.size());
- //FIXME: Check for security violations.
+ // FIXME: Check for security violations.
Path toPath(docBroker->getPublicUri().getPath());
toPath.setExtension(format);
const std::string toJailURL = "file://" + std::string(JAILED_DOCUMENT_ROOT) + toPath.getFileName();
@@ -584,7 +585,7 @@ private:
if (!sent)
{
- //TODO: We should differentiate between bad request and failed conversion.
+ // TODO: We should differentiate between bad request and failed conversion.
throw BadRequestException("Failed to convert and send file.");
}
@@ -636,7 +637,7 @@ private:
else if (tokens.count() >= 6)
{
Log::info("File download request.");
- //TODO: Check that the user in question has access to this file!
+ // TODO: Check that the user in question has access to this file!
// 1. Validate the dockey
std::string decodedUri;
@@ -706,7 +707,7 @@ private:
// indicator to the client that document broker is searching
std::string status("statusindicator: find");
Log::trace("Sending to Client [" + status + "].");
- ws->sendFrame(status.data(), (int) status.size());
+ ws->sendFrame(status.data(), status.size());
const auto uriPublic = DocumentBroker::sanitizeURI(uri);
const auto docKey = DocumentBroker::getDocKey(uriPublic);
@@ -760,11 +761,10 @@ private:
// If this document is going out, wait.
Log::debug("Document [" + docKey + "] is marked to destroy, waiting to reload.");
- const auto timeout = POLL_TIMEOUT_MS;
bool timedOut = true;
- for (size_t i = 0; i < COMMAND_TIMEOUT_MS / timeout; ++i)
+ for (size_t i = 0; i < COMMAND_TIMEOUT_MS / POLL_TIMEOUT_MS; ++i)
{
- std::this_thread::sleep_for(std::chrono::milliseconds(timeout));
+ std::this_thread::sleep_for(std::chrono::milliseconds(POLL_TIMEOUT_MS));
std::unique_lock<std::mutex> lock(DocBrokersMutex);
auto it = DocBrokers.find(docKey);
@@ -790,7 +790,7 @@ private:
if (TerminationFlag)
{
- Log::error("Termination flag set. No loading new session [" + id + "]");
+ Log::error("Termination flag set. Not loading new session [" + id + "]");
return;
}
}
@@ -849,7 +849,7 @@ private:
// Check if readonly session is required
bool isReadOnly = false;
- for (const auto& param: uriPublic.getQueryParameters())
+ for (const auto& param : uriPublic.getQueryParameters())
{
Log::debug("Query param: " + param.first + ", value: " + param.second);
if (param.first == "permission")
@@ -868,12 +868,12 @@ private:
// indicator to a client that is waiting to connect to lokit process
status = "statusindicator: connect";
Log::trace("Sending to Client [" + status + "].");
- ws->sendFrame(status.data(), (int) status.size());
+ ws->sendFrame(status.data(), status.size());
// Now the bridge beetween the client and kit process is connected
status = "statusindicator: ready";
Log::trace("Sending to Client [" + status + "].");
- ws->sendFrame(status.data(), (int) status.size());
+ ws->sendFrame(status.data(), status.size());
Util::checkDiskSpaceOnRegisteredFileSystems();
@@ -951,7 +951,7 @@ private:
Log::error("Error in client request handler: " + exc.toString());
status = "error: cmd=internal kind=unauthorized";
Log::trace("Sending to Client [" + status + "].");
- ws->sendFrame(status.data(), (int) status.size());
+ ws->sendFrame(status.data(), status.size());
}
catch (const std::exception& exc)
{
@@ -1048,7 +1048,7 @@ public:
}
#endif
- handleClientRequest(request,response);
+ handleClientRequest(request, response);
#if MAX_CONNECTIONS > 0
--LOOLWSD::NumConnections;
@@ -1071,7 +1071,9 @@ public:
bool responded = false;
try
{
- if ((request.getMethod() == HTTPRequest::HTTP_GET || request.getMethod() == HTTPRequest::HTTP_HEAD) && request.getURI() == "/")
+ if ((request.getMethod() == HTTPRequest::HTTP_GET ||
+ request.getMethod() == HTTPRequest::HTTP_HEAD) &&
+ request.getURI() == "/")
{
std::string mimeType = "text/plain";
std::string responseString = "OK";
@@ -1185,7 +1187,7 @@ public:
};
/// Handle requests from prisoners (internal).
-class PrisonerRequestHandler: public HTTPRequestHandler
+class PrisonerRequestHandler : public HTTPRequestHandler
{
public:
@@ -1236,7 +1238,7 @@ public:
/// External (client) connection handler factory.
/// Creates handler objects.
-class ClientRequestHandlerFactory: public HTTPRequestHandlerFactory
+class ClientRequestHandlerFactory : public HTTPRequestHandlerFactory
{
public:
ClientRequestHandlerFactory()
@@ -1287,7 +1289,7 @@ public:
/// Internal (prisoner) connection handler factory.
/// Creates handler objects.
-class PrisonerRequestHandlerFactory: public HTTPRequestHandlerFactory
+class PrisonerRequestHandlerFactory : public HTTPRequestHandlerFactory
{
public:
HTTPRequestHandler* createRequestHandler(const HTTPServerRequest& request) override
@@ -1309,18 +1311,18 @@ public:
}
};
-namespace {
+namespace
+{
-static inline
-ServerSocket* getServerSocket(int nClientPortNumber)
+static inline ServerSocket* getServerSocket(int nClientPortNumber)
{
try
{
- ServerSocket *socket = LOOLWSD::isSSLEnabled() ? new SecureServerSocket()
- : new ServerSocket();
+ ServerSocket* socket = LOOLWSD::isSSLEnabled() ? new SecureServerSocket() : new ServerSocket();
socket->bind(nClientPortNumber, false);
- // 64 is the default value for the backlog parameter in Poco when creating a ServerSocket,
- // so use it here, too.
+
+ // 64 is the default value for the backlog parameter in Poco
+ // when creating a ServerSocket, so use it here, too.
socket->listen(64);
return socket;
}
@@ -1331,8 +1333,7 @@ ServerSocket* getServerSocket(int nClientPortNumber)
}
}
-static inline
-ServerSocket* findFreeServerPort(int &nClientPortNumber)
+static inline ServerSocket* findFreeServerPort(int& nClientPortNumber)
{
ServerSocket *socket = NULL;
while (!socket)
@@ -1347,8 +1348,7 @@ ServerSocket* findFreeServerPort(int &nClientPortNumber)
return socket;
}
-static inline
-ServerSocket* getMasterSocket(int nMasterPortNumber)
+static inline ServerSocket* getMasterSocket(int nMasterPortNumber)
{
try
{
@@ -1378,8 +1378,7 @@ ServerSocket* findFreeMasterPort(int &nMasterPortNumber)
return socket;
}
-static inline
-std::string getLaunchURI()
+static inline std::string getLaunchURI()
{
std::string aAbsTopSrcDir = Poco::Path(Application::instance().commandPath()).parent().toString();
aAbsTopSrcDir = Poco::Path(aAbsTopSrcDir).absolute().toString();
@@ -1445,8 +1444,7 @@ void LOOLWSD::initialize(Application& self)
throw std::runtime_error("Do not run as root. Please run as lool user.");
}
- if (!UnitWSD::init(UnitWSD::UnitType::TYPE_WSD,
- UnitTestLibrary))
+ if (!UnitWSD::init(UnitWSD::UnitType::TYPE_WSD, UnitTestLibrary))
{
throw std::runtime_error("Failed to load wsd unit test library.");
}
@@ -1454,41 +1452,40 @@ void LOOLWSD::initialize(Application& self)
auto& conf = config();
// Add default values of new entries here.
- static const std::map<std::string, std::string> DefAppConfig = {
- { "tile_cache_path", LOOLWSD_CACHEDIR },
- { "sys_template_path", "systemplate" },
- { "lo_template_path", "/opt/collaboraoffice5.1" },
- { "child_root_path", "jails" },
- { "lo_jail_subpath", "lo" },
- { "server_name", "" },
- { "file_server_root_path", "../loleaflet/../" },
- { "num_prespawn_children", "1" },
- { "per_document.max_concurrency", "4" },
- { "loleaflet_html", "loleaflet.html" },
- { "logging.color", "true" },
- { "logging.level", "trace" },
- { "ssl.enable", "true" },
- { "ssl.termination", "true" },
- { "ssl.cert_file_path", LOOLWSD_CONFIGDIR "/cert.pem" },
- { "ssl.key_file_path", LOOLWSD_CONFIGDIR "/key.pem" },
- { "ssl.ca_file_path", LOOLWSD_CONFIGDIR "/ca-chain.cert.pem" },
- { "storage.filesystem[@allow]", "false" },
- { "storage.wopi[@allow]", "true" },
- { "storage.wopi.host[0][@allow]", "true" },
- { "storage.wopi.host[0]", "localhost" },
- { "storage.wopi.max_file_size", "0" },
- { "storage.webdav[@allow]", "false" },
- { "logging.file[@enable]", "false" },
- { "logging.file.property[0][@name]", "path" },
- { "logging.file.property[0]", "loolwsd.log" },
- { "logging.file.property[1][@name]", "rotation" },
- { "logging.file.property[1]", "never" },
- { "logging.file.property[2][@name]", "compress" },
- { "logging.file.property[2]", "true" },
- { "logging.file.property[3][@name]", "flush" },
- { "logging.file.property[3]", "false" },
- { "trace[@enable]", "false" }
- };
+ static const std::map<std::string, std::string> DefAppConfig
+ = { { "tile_cache_path", LOOLWSD_CACHEDIR },
+ { "sys_template_path", "systemplate" },
+ { "lo_template_path", "/opt/collaboraoffice5.1" },
+ { "child_root_path", "jails" },
+ { "lo_jail_subpath", "lo" },
+ { "server_name", "" },
+ { "file_server_root_path", "../loleaflet/../" },
+ { "num_prespawn_children", "1" },
+ { "per_document.max_concurrency", "4" },
+ { "loleaflet_html", "loleaflet.html" },
+ { "logging.color", "true" },
+ { "logging.level", "trace" },
+ { "ssl.enable", "true" },
+ { "ssl.termination", "true" },
+ { "ssl.cert_file_path", LOOLWSD_CONFIGDIR "/cert.pem" },
+ { "ssl.key_file_path", LOOLWSD_CONFIGDIR "/key.pem" },
+ { "ssl.ca_file_path", LOOLWSD_CONFIGDIR "/ca-chain.cert.pem" },
+ { "storage.filesystem[@allow]", "false" },
+ { "storage.wopi[@allow]", "true" },
+ { "storage.wopi.host[0][@allow]", "true" },
+ { "storage.wopi.host[0]", "localhost" },
+ { "storage.wopi.max_file_size", "0" },
+ { "storage.webdav[@allow]", "false" },
+ { "logging.file[@enable]", "false" },
+ { "logging.file.property[0][@name]", "path" },
+ { "logging.file.property[0]", "loolwsd.log" },
+ { "logging.file.property[1][@name]", "rotation" },
+ { "logging.file.property[1]", "never" },
+ { "logging.file.property[2][@name]", "compress" },
+ { "logging.file.property[2]", "true" },
+ { "logging.file.property[3][@name]", "flush" },
+ { "logging.file.property[3]", "false" },
+ { "trace[@enable]", "false" } };
// Set default values, in case they are missing from the config file.
AutoPtr<AppConfigMap> pDefConfig(new AppConfigMap(DefAppConfig));
@@ -1586,17 +1583,17 @@ void LOOLWSD::initialize(Application& self)
}
// Otherwise we profile the soft-device at jail creation time.
- setenv ("SAL_DISABLE_OPENCL", "true", 1);
+ setenv("SAL_DISABLE_OPENCL", "true", 1);
// In Trial Versions we might want to set some limits.
LOOLWSD::NumConnections = 0;
- Log::info() << "Open Documents Limit: " << (MAX_DOCUMENTS > 0 ?
- std::to_string(MAX_DOCUMENTS) :
- std::string("unlimited")) << Log::end;
+ Log::info() << "Open Documents Limit: "
+ << (MAX_DOCUMENTS ? std::to_string(MAX_DOCUMENTS) : std::string("unlimited"))
+ << Log::end;
- Log::info() << "Client Connections Limit: " << (MAX_CONNECTIONS > 0 ?
- std::to_string(MAX_CONNECTIONS) :
- std::string("unlimited")) << Log::end;
+ Log::info() << "Client Connections Limit: "
+ << (MAX_CONNECTIONS ? std::to_string(MAX_CONNECTIONS) : std::string("unlimited"))
+ << Log::end;
// Command Tracing.
if (getConfigValue<bool>(conf, "trace[@enable]", false))
@@ -1628,8 +1625,8 @@ void LOOLWSD::initialize(Application& self)
ServerApplication::initialize(self);
#if ENABLE_DEBUG
- std::cerr << "\nLaunch this in your browser:\n\n" <<
- getLaunchURI() << "\n" << std::endl;
+ std::cerr << "\nLaunch this in your browser:\n\n"
+ << getLaunchURI() << '\n' << std::endl;
#endif
}
@@ -1824,7 +1821,7 @@ Process::PID LOOLWSD::createForKit()
args.push_back("--nocaps");
}
- Log::info("Launching forkit process: " + forKitPath + " " +
+ Log::info("Launching forkit process: " + forKitPath + ' ' +
Poco::cat(std::string(" "), args.begin(), args.end()));
LastForkRequestTime = std::chrono::steady_clock::now();
@@ -1854,7 +1851,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
initializeSSL();
- char *locale = setlocale(LC_ALL, nullptr);
+ char* locale = setlocale(LC_ALL, nullptr);
if (locale == nullptr || std::strcmp(locale, "C") == 0)
setlocale(LC_ALL, "en_US.utf8");
@@ -1918,7 +1915,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
if (!psvs)
return Application::EXIT_SOFTWARE;
- ThreadPool threadPool(NumPreSpawnedChildren*6, MAX_SESSIONS * 2);
+ ThreadPool threadPool(NumPreSpawnedChildren * 6, MAX_SESSIONS * 2);
HTTPServer srv(new ClientRequestHandlerFactory(), threadPool, *psvs, params1);
Log::info("Starting master server listening on " + std::to_string(ClientPortNumber));
srv.start();
@@ -1988,8 +1985,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
else if (WIFSTOPPED(status) == true)
{
Log::info() << "Child process [" << pid << "] stopped with "
- << Util::signalName(WSTOPSIG(status))
- << Log::end;
+ << Util::signalName(WSTOPSIG(status)) << Log::end;
}
else if (WIFCONTINUED(status) == true)
{
@@ -2027,9 +2023,9 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
{
std::unique_lock<std::mutex> DocBrokersLock(DocBrokersMutex);
cleanupDocBrokers();
- for (auto& brokerIt : DocBrokers)
+ for (auto& pair : DocBrokers)
{
- brokerIt.second->autoSave(false, 0);
+ pair.second->autoSave(false, 0);
}
}
catch (const std::exception& exc)
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index d1c0301..f1577d9 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -29,7 +29,7 @@ class TraceFileWriter;
/// The Server class which is responsible for all
/// external interactions.
-class LOOLWSD: public Poco::Util::ServerApplication
+class LOOLWSD : public Poco::Util::ServerApplication
{
public:
LOOLWSD();
@@ -51,32 +51,26 @@ public:
static std::atomic<unsigned> NumConnections;
static std::unique_ptr<TraceFileWriter> TraceDumper;
- static
- std::string GenSessionId()
+ static std::string GenSessionId()
{
return Util::encodeId(++NextSessionId, 4);
}
- static
- bool isSSLEnabled()
+ static bool isSSLEnabled()
{
return LOOLWSD::SSLEnabled.get();
}
- static
- bool isSSLTermination()
+ static bool isSSLTermination()
{
return LOOLWSD::SSLTermination.get();
}
- static
- void dumpEventTrace(const std::string& pId, const std::string& sessionId, const std::string& data);
+ static void dumpEventTrace(const std::string& pId, const std::string& sessionId, const std::string& data);
- static
- void dumpIncomingTrace(const std::string& pId, const std::string& sessionId, const std::string& data);
+ static void dumpIncomingTrace(const std::string& pId, const std::string& sessionId, const std::string& data);
- static
- void dumpOutgoingTrace(const std::string& pId, const std::string& sessionId, const std::string& data);
+ static void dumpOutgoingTrace(const std::string& pId, const std::string& sessionId, const std::string& data);
protected:
void initialize(Poco::Util::Application& self) override;
@@ -93,7 +87,6 @@ private:
void displayHelp();
Poco::Process::PID createForKit();
-
class ConfigValueGetter
{
Poco::Util::LayeredConfiguration& _config;
@@ -104,17 +97,17 @@ private:
const std::string& name)
: _config(config)
, _name(name)
- {}
+ {
+ }
void operator()(unsigned int& value) { value = _config.getUInt(_name); }
void operator()(bool& value) { value = _config.getBool(_name); }
void operator()(std::string& value) { value = _config.getString(_name); }
};
- template<typename T>
- static
- bool getSafeConfig(Poco::Util::LayeredConfiguration& config,
- const std::string& name, T& value)
+ template <typename T>
+ static bool getSafeConfig(Poco::Util::LayeredConfiguration& config,
+ const std::string& name, T& value)
{
try
{
diff --git a/loolwsd/Log.hpp b/loolwsd/Log.hpp
index 93724a2..6bded5e 100644
--- a/loolwsd/Log.hpp
+++ b/loolwsd/Log.hpp
@@ -10,9 +10,9 @@
#ifndef INCLUDED_LOG_HPP
#define INCLUDED_LOG_HPP
-#include <string>
-#include <sstream>
#include <functional>
+#include <sstream>
+#include <string>
#include <Poco/Logger.h>
@@ -38,7 +38,7 @@ namespace Log
/// Signal safe prefix logging
void signalLogPrefix();
/// Signal safe logging
- void signalLog(const char *message);
+ void signalLog(const char* message);
/// The following is to write streaming logs.
/// Log::info() << "Value: 0x" << std::hex << value
@@ -54,81 +54,74 @@ namespace Log
/// operator for logging.
class StreamLogger
{
- public:
- StreamLogger(std::function<void(const std::string&)> func)
- : _func(std::move(func))
- {
- }
-
- StreamLogger(StreamLogger&& sl) noexcept
- : _stream(sl._stream.str())
- , _func(std::move(sl._func))
- {
- }
-
- void flush() const
- {
- _func(_stream.str());
- }
-
- std::ostringstream _stream;
-
- private:
- std::function<void(const std::string&)> _func;
+ public:
+ StreamLogger(std::function<void(const std::string&)> func)
+ : _func(std::move(func))
+ {
+ }
+
+ StreamLogger(StreamLogger&& sl) noexcept
+ : _stream(sl._stream.str()),
+ _func(std::move(sl._func))
+ {
+ }
+
+ void flush() const
+ {
+ _func(_stream.str());
+ }
+
+ std::ostringstream _stream;
+
+ private:
+ std::function<void(const std::string&)> _func;
};
- inline
- StreamLogger trace()
+ inline StreamLogger trace()
{
- return StreamLogger([](const std::string& msg) { trace(msg);});
+ return StreamLogger([](const std::string& msg) { trace(msg); });
}
- inline
- StreamLogger debug()
+ inline StreamLogger debug()
{
- return StreamLogger([](const std::string& msg) { debug(msg);});
+ return StreamLogger([](const std::string& msg) { debug(msg); });
}
- inline
- StreamLogger info()
+ inline StreamLogger info()
{
- return StreamLogger([](const std::string& msg) { info(msg);});
+ return StreamLogger([](const std::string& msg) { info(msg); });
}
- inline
- StreamLogger warn()
+ inline StreamLogger warn()
{
- return StreamLogger([](const std::string& msg) { warn(msg);});
+ return StreamLogger([](const std::string& msg) { warn(msg); });
}
- inline
- StreamLogger error()
+ inline StreamLogger error()
{
- return StreamLogger([](const std::string& msg) { error(msg);});
+ return StreamLogger([](const std::string& msg) { error(msg); });
}
- inline
- StreamLogger fatal()
+ inline StreamLogger fatal()
{
- return StreamLogger([](const std::string& msg) { fatal(msg);});
+ return StreamLogger([](const std::string& msg) { fatal(msg); });
}
template <typename U>
- StreamLogger& operator <<(StreamLogger& lhs, const U& rhs)
+ StreamLogger& operator<<(StreamLogger& lhs, const U& rhs)
{
lhs._stream << rhs;
return lhs;
}
template <typename U>
- StreamLogger& operator <<(StreamLogger&& lhs, U&& rhs)
+ StreamLogger& operator<<(StreamLogger&& lhs, U&& rhs)
{
lhs._stream << rhs;
return lhs;
}
- inline
- void operator <<(StreamLogger& lhs, const _end_marker&)
+ inline void operator<<(StreamLogger& lhs, const _end_marker&)
{
(void)end;
lhs.flush();
diff --git a/loolwsd/MessageQueue.hpp b/loolwsd/MessageQueue.hpp
index 95a5654..26fd650 100644
--- a/loolwsd/MessageQueue.hpp
+++ b/loolwsd/MessageQueue.hpp
@@ -75,7 +75,6 @@ class TileQueue : public MessageQueue
friend class TileQueueTests;
private:
-
class CursorPosition
{
public:
@@ -87,10 +86,9 @@ private:
};
public:
-
void updateCursorPosition(int viewId, int part, int x, int y, int width, int height)
{
- auto cursorPosition = CursorPosition({part, x, y, width, height});
+ auto cursorPosition = CursorPosition({ part, x, y, width, height });
auto it = _cursorPositions.find(viewId);
if (it != _cursorPositions.end())
{
diff --git a/loolwsd/Png.hpp b/loolwsd/Png.hpp
index 6796adf..cb05654 100644
--- a/loolwsd/Png.hpp
+++ b/loolwsd/Png.hpp
@@ -62,7 +62,7 @@ extern "C"
static void user_write_fn(png_structp png_ptr, png_bytep data, png_size_t length)
{
- std::vector<char> *outputp = (std::vector<char> *) png_get_io_ptr(png_ptr);
+ std::vector<char>* outputp = (std::vector<char>*)png_get_io_ptr(png_ptr);
const size_t oldsize = outputp->size();
outputp->resize(oldsize + length);
std::memcpy(outputp->data() + oldsize, data, length);
diff --git a/loolwsd/PrisonerSession.hpp b/loolwsd/PrisonerSession.hpp
index 3d6ac6c..87cba16 100644
--- a/loolwsd/PrisonerSession.hpp
+++ b/loolwsd/PrisonerSession.hpp
@@ -28,11 +28,9 @@ public:
bool shutdownPeer(Poco::UInt16 statusCode);
private:
-
- virtual bool _handleInput(const char *buffer, int length) override;
+ virtual bool _handleInput(const char* buffer, int length) override;
private:
-
std::shared_ptr<DocumentBroker> _docBroker;
std::weak_ptr<ClientSession> _peer;
int _curPart;
diff --git a/loolwsd/QueueHandler.hpp b/loolwsd/QueueHandler.hpp
index 8c6cca3..3f330e6 100644
--- a/loolwsd/QueueHandler.hpp
+++ b/loolwsd/QueueHandler.hpp
@@ -9,13 +9,13 @@
#include <Poco/Runnable.h>
-#include "MessageQueue.hpp"
-#include "LOOLSession.hpp"
#include "LOOLProtocol.hpp"
+#include "LOOLSession.hpp"
+#include "MessageQueue.hpp"
#include "Util.hpp"
/// This thread handles incoming messages on a given kit instance.
-class QueueHandler: public Poco::Runnable
+class QueueHandler : public Poco::Runnable
{
public:
QueueHandler(std::shared_ptr<MessageQueue> queue,
diff --git a/loolwsd/Storage.hpp b/loolwsd/Storage.hpp
index b21b19e..a60d42b 100644
--- a/loolwsd/Storage.hpp
+++ b/loolwsd/Storage.hpp
@@ -11,11 +11,11 @@
#ifndef INCLUDED_STORAGE_HPP
#define INCLUDED_STORAGE_HPP
-#include <string>
#include <set>
+#include <string>
-#include <Poco/Util/Application.h>
#include <Poco/URI.h>
+#include <Poco/Util/Application.h>
#include "Auth.hpp"
#include "Log.hpp"
@@ -25,7 +25,6 @@
class StorageBase
{
public:
-
/// Represents basic file's attributes.
/// Used for local and network files.
class FileInfo
@@ -80,8 +79,7 @@ public:
/// Writes the contents of the file back to the source.
virtual bool saveLocalFileToStorage(const Poco::URI& uriPublic) = 0;
- static
- size_t getFileSize(const std::string& filename);
+ static size_t getFileSize(const std::string& filename);
/// Must be called at startup to configure.
static void initialize();
@@ -161,7 +159,8 @@ public:
"], jailPath: [" + jailPath + "], uri: [" + uri.toString() + "].");
}
- class WOPIFileInfo {
+ class WOPIFileInfo
+ {
public:
WOPIFileInfo(const std::string& userid,
const std::string& username,
diff --git a/loolwsd/TileCache.hpp b/loolwsd/TileCache.hpp
index fd44cd0..b9b2f60 100644
--- a/loolwsd/TileCache.hpp
+++ b/loolwsd/TileCache.hpp
@@ -40,14 +40,14 @@ public:
/// Subscribes if no subscription exists and returns the version number.
/// Otherwise returns 0 to signify a subscription exists.
- void subscribeToTileRendering(const TileDesc& tile, const std::shared_ptr<ClientSession> &subscriber);
+ void subscribeToTileRendering(const TileDesc& tile, const std::shared_ptr<ClientSession>& subscriber);
/// Cancels all tile requests by the given subscriber.
- std::string cancelTiles(const std::shared_ptr<ClientSession> &subscriber);
+ std::string cancelTiles(const std::shared_ptr<ClientSession>& subscriber);
std::unique_ptr<std::fstream> lookupTile(const TileDesc& tile);
- void saveTileAndNotify(const TileDesc& tile, const char *data, const size_t size);
+ void saveTileAndNotify(const TileDesc& tile, const char* data, const size_t size);
std::string getTextFile(const std::string& fileName);
@@ -59,7 +59,7 @@ public:
// Saves a font / style / etc rendering
// The dir parameter should be the type of rendering, like "font", "style", etc
- void saveRendering(const std::string& name, const std::string& dir, const char *data, size_t size);
+ void saveRendering(const std::string& name, const std::string& dir, const char* data, size_t size);
std::unique_ptr<std::fstream> lookupCachedFile(const std::string& name, const std::string& dir);
@@ -96,7 +96,7 @@ private:
mutable std::mutex _tilesBeingRenderedMutex;
- std::map<std::string, std::shared_ptr<TileBeingRendered>> _tilesBeingRendered;
+ std::map<std::string, std::shared_ptr<TileBeingRendered> > _tilesBeingRendered;
};
#endif
diff --git a/loolwsd/TileDesc.hpp b/loolwsd/TileDesc.hpp
index 9356c2d..8ba44bd 100644
--- a/loolwsd/TileDesc.hpp
+++ b/loolwsd/TileDesc.hpp
@@ -135,8 +135,7 @@ public:
}
/// Deserialize a TileDesc from a tokenized string.
- static
- TileDesc parse(const Poco::StringTokenizer& tokens)
+ static TileDesc parse(const Poco::StringTokenizer& tokens)
{
// We don't expect undocumented fields and
// assume all values to be int.
@@ -165,12 +164,10 @@ public:
}
/// Deserialize a TileDesc from a string format.
- static
- TileDesc parse(const std::string& message)
+ static TileDesc parse(const std::string& message)
{
Poco::StringTokenizer tokens(message, " ",
- Poco::StringTokenizer::TOK_IGNORE_EMPTY |
- Poco::StringTokenizer::TOK_TRIM);
+ Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
return parse(tokens);
}
@@ -182,8 +179,8 @@ private:
int _tilePosY;
int _tileWidth;
int _tileHeight;
- int _ver; //< Versioning support.
- int _imgSize; //< Used for responses.
+ int _ver; //< Versioning support.
+ int _imgSize; //< Used for responses.
int _id;
};
@@ -251,7 +248,6 @@ private:
}
public:
-
int getPart() const { return _part; }
int getWidth() const { return _width; }
int getHeight() const { return _height; }
@@ -312,8 +308,7 @@ public:
}
/// Deserialize a TileDesc from a tokenized string.
- static
- TileCombined parse(const Poco::StringTokenizer& tokens)
+ static TileCombined parse(const Poco::StringTokenizer& tokens)
{
// We don't expect undocumented fields and
// assume all values to be int.
@@ -363,17 +358,14 @@ public:
}
/// Deserialize a TileDesc from a string format.
- static
- TileCombined parse(const std::string& message)
+ static TileCombined parse(const std::string& message)
{
Poco::StringTokenizer tokens(message, " ",
- Poco::StringTokenizer::TOK_IGNORE_EMPTY |
- Poco::StringTokenizer::TOK_TRIM);
+ Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
return parse(tokens);
}
- static
- TileCombined create(const std::vector<TileDesc>& tiles)
+ static TileCombined create(const std::vector<TileDesc>& tiles)
{
assert(!tiles.empty());
@@ -399,7 +391,7 @@ private:
int _height;
int _tileWidth;
int _tileHeight;
- int _ver; //< Versioning support.
+ int _ver; //< Versioning support.
int _id;
};
diff --git a/loolwsd/Unit.hpp b/loolwsd/Unit.hpp
index fb6a850..97b7103 100644
--- a/loolwsd/Unit.hpp
+++ b/loolwsd/Unit.hpp
@@ -9,10 +9,10 @@
#ifndef INCLUDED_UNIT_HPP
#define INCLUDED_UNIT_HPP
-#include <string>
-#include <memory>
#include <atomic>
#include <cassert>
+#include <memory>
+#include <string>
#include <Poco/Net/WebSocket.h>
@@ -24,13 +24,16 @@ class UnitHTTPServerRequest;
class UnitHTTPServerResponse;
// Forward declaration to avoid pulling the world here.
-namespace Poco {
- namespace Net {
+namespace Poco
+{
+ namespace Net
+ {
class HTTPServerRequest;
class HTTPServerResponse;
}
- namespace Util {
+ namespace Util
+ {
class LayeredConfiguration;
}
}
@@ -50,7 +53,6 @@ class UnitBase
friend UnitKit;
protected:
-
// ---------------- Helper API ----------------
/// After this time we invoke 'timeout' default 30 seconds
void setTimeout(int timeoutMilliSeconds);
@@ -58,33 +60,42 @@ protected:
/// If the test times out this gets invoked, the default just exits.
virtual void timeout();
- enum TestResult { TEST_FAILED, TEST_OK, TEST_TIMED_OUT };
+ enum TestResult
+ {
+ TEST_FAILED,
+ TEST_OK,
+ TEST_TIMED_OUT
+ };
/// Encourages the process to exit with this value (unless hooked)
void exitTest(TestResult result);
- UnitBase();
+ UnitBase();
virtual ~UnitBase();
public:
- enum UnitType { TYPE_WSD, TYPE_KIT };
+ enum UnitType
+ {
+ TYPE_WSD,
+ TYPE_KIT
+ };
/// Load unit test hook shared library from this path
- static bool init(UnitType type, const std::string &unitLibPath);
+ static bool init(UnitType type, const std::string& unitLibPath);
/// Do we have a unit test library hooking things & loaded
static bool isUnitTesting();
/// Tweak the return value from the process.
- virtual void returnValue(int & /* retValue */);
+ virtual void returnValue(int& /* retValue */);
private:
void setHandle(void *dlHandle) { _dlHandle = dlHandle; }
- static UnitBase *linkAndCreateUnit(UnitType type, const std::string &unitLibPath);
+ static UnitBase *linkAndCreateUnit(UnitType type, const std::string& unitLibPath);
void *_dlHandle;
bool _setRetValue;
- int _retValue;
- int _timeoutMilliSeconds;
+ int _retValue;
+ int _timeoutMilliSeconds;
std::atomic<bool> _timeoutShutdown;
static UnitBase *Global;
UnitType _type;
@@ -94,17 +105,22 @@ private:
class UnitWSD : public UnitBase
{
bool _hasKitHooks;
+
public:
- UnitWSD();
+ UnitWSD();
virtual ~UnitWSD();
- static UnitWSD &get()
+ static UnitWSD& get()
{
- assert (Global && Global->_type == UnitType::TYPE_WSD);
+ assert(Global && Global->_type == UnitType::TYPE_WSD);
return *static_cast<UnitWSD *>(Global);
}
- enum TestRequest { TEST_REQ_CLIENT, TEST_REQ_PRISONER };
+ enum TestRequest
+ {
+ TEST_REQ_CLIENT,
+ TEST_REQ_PRISONER
+ };
/// Simulate an incoming request
void testHandleRequest(TestRequest type,
UnitHTTPServerRequest& request,
@@ -117,29 +133,35 @@ public:
// ---------------- WSD hooks ----------------
/// Manipulate and modify the configuration before any usage.
- virtual void configure(Poco::Util::LayeredConfiguration & /* config */);
+ virtual void configure(Poco::Util::LayeredConfiguration& /* config */);
/// Main-loop reached, time for testing
virtual void invokeTest() {}
/// Tweak the count of pre-spawned kits.
- virtual void preSpawnCount(int & /* numPrefork */) {}
+ virtual void preSpawnCount(int& /* numPrefork */) {}
/// When a new child kit process reports
- virtual void newChild(const std::shared_ptr<Poco::Net::WebSocket> & /* socket */) {}
+ virtual void newChild(const std::shared_ptr<Poco::Net::WebSocket>& /* socket */) {}
/// Intercept createStorage
virtual bool createStorage(const Poco::URI& /* uri */,
const std::string& /* jailRoot */,
const std::string& /* jailPath */,
- std::unique_ptr<StorageBase> & /*rStorage */)
- { return false; }
+ std::unique_ptr<StorageBase>& /*rStorage */)
+ {
+ return false;
+ }
/// Intercept incoming requests, so unit tests can silently communicate
virtual bool filterHandleRequest(
- TestRequest /* type */,
- Poco::Net::HTTPServerRequest& /* request */,
- Poco::Net::HTTPServerResponse& /* response */)
- { return false; }
+ TestRequest /* type */,
+ Poco::Net::HTTPServerRequest& /* request */,
+ Poco::Net::HTTPServerResponse& /* response */)
+ {
+ return false;
+ }
/// Child sent a message
virtual bool filterChildMessage(const std::vector<char>& /* payload */)
- { return false; }
+ {
+ return false;
+ }
// ---------------- TileCache hooks ----------------
/// Called before the lookupTile call returns. Should always be called to fire events.
@@ -147,9 +169,9 @@ public:
int tileWidth, int tileHeight, std::unique_ptr<std::fstream>& cacheFile);
// ---------------- DocumentBroker hooks ----------------
- virtual bool filterLoad(const std::string &/* sessionId */,
- const std::string &/* jailId */,
- bool &/* result */)
+ virtual bool filterLoad(const std::string& /* sessionId */,
+ const std::string& /* jailId */,
+ bool& /* result */)
{
return false;
}
@@ -177,11 +199,11 @@ public:
class UnitKit : public UnitBase
{
public:
- UnitKit();
+ UnitKit();
virtual ~UnitKit();
- static UnitKit &get()
+ static UnitKit& get()
{
- assert (Global && Global->_type == UnitType::TYPE_KIT);
+ assert(Global && Global->_type == UnitType::TYPE_KIT);
return *static_cast<UnitKit *>(Global);
}
@@ -199,14 +221,18 @@ public:
virtual void postFork() {}
/// Kit got a message
- virtual bool filterKitMessage(const std::shared_ptr<Poco::Net::WebSocket> & /* ws */,
- std::string &/* message */)
- { return false; }
+ virtual bool filterKitMessage(const std::shared_ptr<Poco::Net::WebSocket>& /* ws */,
+ std::string& /* message */)
+ {
+ return false;
+ }
/// Allow a custom LibreOfficeKit wrapper
virtual LibreOfficeKit *lok_init(const char * /* instdir */,
const char * /* userdir */)
- { return NULL; }
+ {
+ return NULL;
+ }
};
#endif
diff --git a/loolwsd/UnitHTTP.hpp b/loolwsd/UnitHTTP.hpp
index 4b325c7..3c28613 100644
--- a/loolwsd/UnitHTTP.hpp
+++ b/loolwsd/UnitHTTP.hpp
@@ -12,14 +12,14 @@
#include <memory>
#include <sstream>
-#include <Poco/Version.h>
-#include <Poco/Net/WebSocket.h>
+#include <Poco/Net/HTTPClientSession.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPServerParams.h>
-#include <Poco/Net/HTTPClientSession.h>
#include <Poco/Net/HTTPServerRequest.h>
#include <Poco/Net/HTTPServerResponse.h>
#include <Poco/Net/SocketAddress.h>
+#include <Poco/Net/WebSocket.h>
+#include <Poco/Version.h>
#include "Common.hpp"
@@ -31,11 +31,18 @@ class UnitHTTPServerResponse : public Poco::Net::HTTPServerResponse
{
bool _sent;
std::stringstream _dummyStream;
+
public:
- UnitHTTPServerResponse() : _sent (false) {}
+ UnitHTTPServerResponse() :
+ _sent(false)
+ {
+ }
virtual void sendContinue() override {}
virtual std::ostream& send() override
- { _sent = true; return _dummyStream; }
+ {
+ _sent = true;
+ return _dummyStream;
+ }
virtual void sendFile(const std::string& /* path */,
const std::string& /* mediaType */) override {}
virtual void sendBuffer(const void* /* pBuffer */,
@@ -50,56 +57,75 @@ public:
class UnitHTTPServerParams : public Poco::Net::HTTPServerParams
{
public:
- ~UnitHTTPServerParams() { }
+ ~UnitHTTPServerParams() {}
};
/// Unit test stub for a server request
class UnitHTTPServerRequest : public Poco::Net::HTTPServerRequest
{
protected:
- UnitHTTPServerResponse &_response;
+ UnitHTTPServerResponse& _response;
Poco::Net::SocketAddress _clientAddress;
Poco::Net::SocketAddress _serverAddress;
std::stringstream _dummyStream;
UnitHTTPServerParams _dummyParams;
+
public:
- UnitHTTPServerRequest(UnitHTTPServerResponse &inResponse,
- const std::string &uri)
- : _response(inResponse),
- _clientAddress(),
- _serverAddress(MasterPortNumber)
- { setURI(uri); }
+ UnitHTTPServerRequest(UnitHTTPServerResponse& inResponse,
+ const std::string& uri) :
+ _response(inResponse),
+ _clientAddress(),
+ _serverAddress(MasterPortNumber)
+ {
+ setURI(uri);
+ }
virtual std::istream& stream() override
- { return _dummyStream; }
+ {
+ return _dummyStream;
+ }
#if POCO_VERSION < 0x02000000
virtual bool expectContinue() const override
- { return false; }
+ {
+ return false;
+ }
#endif
#if POCO_VERSION >= 0x02000000
virtual bool secure() const override
- { return true; }
+ {
+ return true;
+ }
#endif
- virtual const SocketAddress& clientAddress() const override
- { return _clientAddress; }
- virtual const SocketAddress& serverAddress() const override
- { return _serverAddress; }
- virtual const HTTPServerParams& serverParams() const override
- { return _dummyParams; }
+ virtual const SocketAddress& clientAddress() const override
+ {
+ return _clientAddress;
+ }
+ virtual const SocketAddress& serverAddress() const override
+ {
+ return _serverAddress;
+ }
+ virtual const HTTPServerParams& serverParams() const override
+ {
+ return _dummyParams;
+ }
virtual Poco::Net::HTTPServerResponse& response() const override
- { return _response; }
+ {
+ return _response;
+ }
};
-namespace UnitHTTP {
- Poco::Net::HTTPClientSession *createSession();
+namespace UnitHTTP
+{
+ Poco::Net::HTTPClientSession* createSession();
}
class UnitWebSocket
{
- Poco::Net::HTTPClientSession *_session;
- Poco::Net::WebSocket *_socket;
- public:
+ Poco::Net::HTTPClientSession* _session;
+ Poco::Net::WebSocket* _socket;
+
+public:
/// Get a websocket connected for a given URL
- UnitWebSocket(const std::string &docURL);
+ UnitWebSocket(const std::string& docURL);
~UnitWebSocket()
{
delete _socket;
diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp
index 40f0793..cde7828 100644
--- a/loolwsd/Util.hpp
+++ b/loolwsd/Util.hpp
@@ -35,7 +35,6 @@ extern std::atomic<bool> TerminationFlag;
/// and prevent _Exit while collecting backtrace.
extern std::mutex SigHandlerTrap;
-
namespace Util
{
namespace rng
@@ -59,7 +58,7 @@ namespace Util
// if everything goes well. In case of any error, both the destination file (if it already
// exists) and the temporary file (if was created, or existed already) are removed. Return true
// if everything succeeded.
- bool saveDataToFileSafely(const std::string& fileName, const char *data, size_t size);
+ bool saveDataToFileSafely(const std::string& fileName, const char* data, size_t size);
// We work around some of the mess of using the same sources both on the server side and in unit
// tests with conditional compilation based on BUILDING_TESTS.
@@ -100,8 +99,7 @@ namespace Util
assert(lock.owns_lock());
}
- inline
- void assertIsLocked(std::mutex& mtx)
+ inline void assertIsLocked(std::mutex& mtx)
{
assert(!mtx.try_lock());
}
@@ -110,8 +108,7 @@ namespace Util
/// Supresses exception when the file is already removed.
/// This can happen when there is a race (unavoidable) or when
/// we don't care to check before we remove (when no race exists).
- inline
- void removeFile(const std::string& path, const bool recursive = false)
+ inline void removeFile(const std::string& path, const bool recursive = false)
{
try
{
@@ -123,8 +120,7 @@ namespace Util
}
}
- inline
- void removeFile(const Poco::Path& path, const bool recursive = false)
+ inline void removeFile(const Poco::Path& path, const bool recursive = false)
{
removeFile(path.toString(), recursive);
}
@@ -136,7 +132,7 @@ namespace Util
std::string getTempFilePath(const std::string& srcDir, const std::string& srcFilename);
/// Returns the name of the signal.
- const char *signalName(int signo);
+ const char* signalName(int signo);
/// Trap signals to cleanup and exit the process gracefully.
void setTerminationSignals();
@@ -159,8 +155,7 @@ namespace Util
std::string UniqueId();
/// Trim spaces from the left. Just spaces.
- inline
- std::string& ltrim(std::string& s)
+ inline std::string& ltrim(std::string& s)
{
const auto pos = s.find_first_not_of(' ');
if (pos != std::string::npos)
@@ -172,8 +167,7 @@ namespace Util
}
/// Trim spaces from the left and copy. Just spaces.
- inline
- std::string ltrimmed(const std::string& s)
+ inline std::string ltrimmed(const std::string& s)
{
const auto pos = s.find_first_not_of(' ');
if (pos != std::string::npos)
@@ -237,8 +231,7 @@ namespace Util
bool match(const std::string& subject) const
{
- return (_allowByDefault || match(_allowed, subject)) &&
- !match(_denied, subject);
+ return (_allowByDefault || match(_allowed, subject)) && !match(_denied, subject);
}
private:
@@ -281,7 +274,7 @@ namespace Util
/// A logical constant that is allowed to initialize
/// exactly once and checks usage before initialization.
- template<typename T>
+ template <typename T>
class RuntimeConstant
{
T _value;
diff --git a/loolwsd/test/countloolkits.hpp b/loolwsd/test/countloolkits.hpp
index 275efea..d27ab3b 100644
--- a/loolwsd/test/countloolkits.hpp
+++ b/loolwsd/test/countloolkits.hpp
@@ -14,8 +14,7 @@
#include <Poco/StringTokenizer.h>
/// Counts the number of LoolKit process instances without wiating.
-static
-int getLoolKitProcessCount()
+static int getLoolKitProcessCount()
{
int result = 0;
for (auto i = Poco::DirectoryIterator(std::string("/proc")); i != Poco::DirectoryIterator(); ++i)
@@ -64,8 +63,7 @@ int getLoolKitProcessCount()
return result;
}
-static
-int countLoolKitProcesses(const int expected)
+static int countLoolKitProcesses(const int expected)
{
std::cerr << "Waiting to have " << expected << " loolkit processes. Loolkits: ";
diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp
index 3bbac6a..1a386ba 100644
--- a/loolwsd/test/helpers.hpp
+++ b/loolwsd/test/helpers.hpp
@@ -10,11 +10,11 @@
#include "config.h"
#include <algorithm>
-#include <cstdlib>
#include <condition_variable>
+#include <cstdlib>
#include <mutex>
-#include <thread>
#include <regex>
+#include <thread>
#include <Poco/BinaryReader.h>
#include <Poco/DirectoryIterator.h>
@@ -41,9 +41,9 @@
#include <cppunit/extensions/HelperMacros.h>
#include <Common.hpp>
+#include <LOOLProtocol.hpp>
#include <UserMessages.hpp>
#include <Util.hpp>
-#include <LOOLProtocol.hpp>
#ifndef TDOC
#error TDOC must be defined (see Makefile.am)
More information about the Libreoffice-commits
mailing list