[Libreoffice-commits] online.git: 4 commits - loolwsd/ChildProcessSession.cpp loolwsd/Common.hpp loolwsd/DocumentBroker.cpp loolwsd/LOOLBroker.cpp loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp loolwsd/LOOLWSD.hpp loolwsd/test
Tor Lillqvist
tml at collabora.com
Mon Mar 28 11:34:06 UTC 2016
loolwsd/ChildProcessSession.cpp | 6 +++---
loolwsd/Common.hpp | 10 +++++-----
loolwsd/DocumentBroker.cpp | 2 +-
loolwsd/LOOLBroker.cpp | 1 -
loolwsd/LOOLKit.cpp | 3 +--
loolwsd/LOOLWSD.cpp | 17 +++++++----------
loolwsd/LOOLWSD.hpp | 6 ------
loolwsd/test/httpposttest.cpp | 1 +
8 files changed, 18 insertions(+), 28 deletions(-)
New commits:
commit a219819ebfdede7be4bf5ee993fa320121002d33
Author: Tor Lillqvist <tml at collabora.com>
Date: Mon Mar 28 14:01:19 2016 +0300
Avoid defining constant strings in multiple places
It is not a good idea to have the same string somewhat arbitrarily
both as a static const members of the LOOLWSD class and then as a
file-local static const in another file. Or defined as a separate
local const static in each compilation unit that includes
Common.hpp. Use constexpr instead, in Common.hpp.
diff --git a/loolwsd/ChildProcessSession.cpp b/loolwsd/ChildProcessSession.cpp
index 1922e93..3c74b15 100644
--- a/loolwsd/ChildProcessSession.cpp
+++ b/loolwsd/ChildProcessSession.cpp
@@ -907,8 +907,8 @@ bool ChildProcessSession::downloadAs(const char* /*buffer*/, int /*length*/, Str
}
}
- const auto tmpDir = Util::createRandomDir(JailedDocumentRoot);
- const auto url = JailedDocumentRoot + tmpDir + "/" + name;
+ const auto tmpDir = Util::createRandomDir(JAILED_DOCUMENT_ROOT);
+ const auto url = JAILED_DOCUMENT_ROOT + tmpDir + "/" + name;
std::unique_lock<std::recursive_mutex> lock(Mutex);
@@ -994,7 +994,7 @@ bool ChildProcessSession::insertFile(const char* /*buffer*/, int /*length*/, Str
if (type == "graphic")
{
- std::string fileName = "file://" + JailedDocumentRoot + "insertfile/" + name;
+ std::string fileName = "file://" + std::string(JAILED_DOCUMENT_ROOT) + "insertfile/" + name;
std::string command = ".uno:InsertGraphic";
std::string arguments = "{"
"\"FileName\":{"
diff --git a/loolwsd/Common.hpp b/loolwsd/Common.hpp
index 2f44df2..40613e3 100644
--- a/loolwsd/Common.hpp
+++ b/loolwsd/Common.hpp
@@ -33,11 +33,11 @@ constexpr int READ_BUFFER_SIZE = 2048;
/// size are considered small messages.
constexpr int SMALL_MESSAGE_SIZE = READ_BUFFER_SIZE / 2;
-static const std::string JailedDocumentRoot = "/user/docs/";
-static const std::string CHILD_URI = "/loolws/child?";
-static const std::string LOLEAFLET_PATH = "/loleaflet/dist/loleaflet.html?";
-static const std::string SSL_CERT_FILE = "cert.pem";
-static const std::string SSL_KEY_FILE = "key.pem";
+constexpr auto CHILD_URI = "/loolws/child?";
+constexpr auto FIFO_LOOLWSD = "loolwsdfifo";
+constexpr auto FIFO_PATH = "pipe";
+constexpr auto JAILED_DOCUMENT_ROOT = "/user/docs/";
+constexpr auto SSL_KEY_FILE = "key.pem";
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index d36998f..5390f67 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -99,7 +99,7 @@ bool DocumentBroker::load(const std::string& jailId)
// We need to map it to a jailed path and copy the file there.
// user/doc/jailId
- const auto jailPath = Poco::Path(JailedDocumentRoot, jailId);
+ const auto jailPath = Poco::Path(JAILED_DOCUMENT_ROOT, jailId);
const std::string jailRoot = getJailRoot();
Log::info("jailPath: " + jailPath.toString() + ", jailRoot: " + jailRoot);
diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp
index e2ac062..88682e6 100644
--- a/loolwsd/LOOLBroker.cpp
+++ b/loolwsd/LOOLBroker.cpp
@@ -30,7 +30,6 @@ typedef int (LokHookPreInit) ( const char *install_path, const char *user_profi
using Poco::ProcessHandle;
-const std::string FIFO_LOOLWSD = "loolwsdfifo";
const std::string BROKER_SUFIX = ".fifo";
const std::string BROKER_PREFIX = "lokit";
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 3831390..aeb1618 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -70,7 +70,6 @@ using Poco::Thread;
using Poco::ThreadLocal;
using Poco::Util::Application;
-const std::string FIFO_PATH = "pipe";
const std::string FIFO_BROKER = "loolbroker.fifo";
const std::string FIFO_NOTIFY = "loolnotify.fifo";
@@ -407,7 +406,7 @@ public:
HTTPClientSession cs("127.0.0.1", MASTER_PORT_NUMBER);
cs.setTimeout(0);
- HTTPRequest request(HTTPRequest::HTTP_GET, CHILD_URI + "sessionId=" + sessionId + "&jailId=" + _jailId + "&docKey=" + _docKey);
+ HTTPRequest request(HTTPRequest::HTTP_GET, std::string(CHILD_URI) + "sessionId=" + sessionId + "&jailId=" + _jailId + "&docKey=" + _docKey);
HTTPResponse response;
auto ws = std::make_shared<WebSocket>(cs, request, response);
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 85d1e69..ce23783 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -398,7 +398,7 @@ private:
// Convert it to the requested format.
Path toPath(docBroker->getPublicUri().getPath());
toPath.setExtension(format);
- const std::string toJailURL = "file://" + JailedDocumentRoot + toPath.getFileName();
+ const std::string toJailURL = "file://" + std::string(JAILED_DOCUMENT_ROOT) + toPath.getFileName();
std::string encodedTo;
URI::encode(toJailURL, "", encodedTo);
std::string saveas = "saveas url=" + encodedTo + " format=" + format + " options=";
@@ -459,7 +459,7 @@ private:
{
Log::info() << "Perform insertfile: " << formChildid << ", " << formName << Log::end;
const std::string dirPath = LOOLWSD::ChildRoot + formChildid
- + JailedDocumentRoot + "insertfile";
+ + JAILED_DOCUMENT_ROOT + "insertfile";
File(dirPath).createDirectories();
std::string fileName = dirPath + Path::separator() + form.get("name");
File(tmpPath).moveTo(fileName);
@@ -485,7 +485,7 @@ private:
Log::info("File download request.");
// The user might request a file to download
const std::string dirPath = LOOLWSD::ChildRoot + tokens[1]
- + JailedDocumentRoot + tokens[2];
+ + JAILED_DOCUMENT_ROOT + tokens[2];
std::string fileName;
URI::decode(tokens[3], fileName);
const std::string filePath = dirPath + Path::separator() + fileName;
@@ -672,7 +672,7 @@ private:
const std::string mediaType = "text/xml";
const std::string action = "action";
const std::string urlsrc = "urlsrc";
- const std::string uriValue = "https://" + uri.getHost() + ":" + std::to_string(uri.getPort()) + LOLEAFLET_PATH;
+ const std::string uriValue = "https://" + uri.getHost() + ":" + std::to_string(uri.getPort()) + "/loleaflet/dist/loleaflet.html?";
InputSource inputSrc(discoveryPath);
AutoPtr<Poco::XML::Document> docXML = parser.parse(&inputSrc);
@@ -1020,8 +1020,6 @@ std::string LOOLWSD::FileServerRoot;
int LOOLWSD::NumPreSpawnedChildren = 10;
bool LOOLWSD::DoTest = false;
static const std::string pidLog = "/tmp/loolwsd.pid";
-const std::string LOOLWSD::FIFO_PATH = "pipe";
-const std::string LOOLWSD::FIFO_LOOLWSD = "loolwsdfifo";
// Demo Site Verification URL.
static const std::string DemoAuthVerificationUrl = "http://ec2-54-216-97-44.eu-west-1.compute.amazonaws.com/cloudsuite-demo/verify.php?type&token=";
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index c288bf4..59d7111 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -47,10 +47,6 @@ public:
static std::string FileServerRoot;
//static Auth AuthAgent;
- static const std::string FIFO_PATH;
- static const std::string FIFO_LOOLWSD;
- static const std::string LOKIT_PIDLOG;
-
static
std::string GenSessionId()
{
commit 45fc60d42881de9c6e49ee797ba75343dd92ade1
Author: Tor Lillqvist <tml at collabora.com>
Date: Mon Mar 28 13:42:07 2016 +0300
No need to have PIDLOG as a static const class member
This is C++, not Java. Or is there a school of thought for C++ style
that says one should avoid plain "C-style" file-local static
variables, and instead put everything always in a class, even as
static members? Do we want to follow that?
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 077b2e7..85d1e69 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1019,7 +1019,7 @@ std::string LOOLWSD::FileServerRoot;
int LOOLWSD::NumPreSpawnedChildren = 10;
bool LOOLWSD::DoTest = false;
-const std::string LOOLWSD::PIDLOG = "/tmp/loolwsd.pid";
+static const std::string pidLog = "/tmp/loolwsd.pid";
const std::string LOOLWSD::FIFO_PATH = "pipe";
const std::string LOOLWSD::FIFO_LOOLWSD = "loolwsdfifo";
@@ -1274,7 +1274,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
// log pid information
{
- FileOutputStream filePID(LOOLWSD::PIDLOG);
+ FileOutputStream filePID(pidLog);
if (filePID.good())
filePID << Process::id();
}
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index f2a498e..c288bf4 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -47,7 +47,6 @@ public:
static std::string FileServerRoot;
//static Auth AuthAgent;
- static const std::string PIDLOG;
static const std::string FIFO_PATH;
static const std::string FIFO_LOOLWSD;
static const std::string LOKIT_PIDLOG;
commit af1973eea8a1f3e63c0cca0a81a846a9de64471a
Author: Tor Lillqvist <tml at collabora.com>
Date: Mon Mar 28 13:38:36 2016 +0300
No need to have Config as a static member in the class
Its value is already available as a macro from config.h even.
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index bec5a1d..077b2e7 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1011,7 +1011,6 @@ private:
std::atomic<unsigned> LOOLWSD::NextSessionId;
int LOOLWSD::BrokerWritePipe = -1;
std::string LOOLWSD::Cache = LOOLWSD_CACHEDIR;
-std::string LOOLWSD::Config = LOOLWSD_CONFIGDIR;
std::string LOOLWSD::SysTemplate;
std::string LOOLWSD::LoTemplate;
std::string LOOLWSD::ChildRoot;
@@ -1040,7 +1039,7 @@ void LOOLWSD::initialize(Application& self)
// load default configuration files, if present
if (loadConfiguration() == 0)
{
- std::string configPath = LOOLWSD::Config + "/loolwsd.xml";
+ std::string configPath = LOOLWSD_CONFIGDIR "/loolwsd.xml";
loadConfiguration(configPath);
}
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index 92a3682..f2a498e 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -40,7 +40,6 @@ public:
static int BrokerWritePipe;
static bool DoTest;
static std::string Cache;
- static std::string Config;
static std::string SysTemplate;
static std::string LoTemplate;
static std::string ChildRoot;
commit 2604824d5fcc7371a628f1e28abe2e1b27e032c3
Author: Tor Lillqvist <tml at collabora.com>
Date: Mon Mar 28 13:26:37 2016 +0300
Need to #include <Poco/Net/PrivateKeyPassphraseHandler.h> to avoid warning
diff --git a/loolwsd/test/httpposttest.cpp b/loolwsd/test/httpposttest.cpp
index 5f43061..aafdbd1 100644
--- a/loolwsd/test/httpposttest.cpp
+++ b/loolwsd/test/httpposttest.cpp
@@ -15,6 +15,7 @@
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPResponse.h>
#include <Poco/Net/InvalidCertificateHandler.h>
+#include <Poco/Net/PrivateKeyPassphraseHandler.h>
#include <Poco/Net/SSLManager.h>
#include <Poco/StreamCopier.h>
#include <Poco/URI.h>
More information about the Libreoffice-commits
mailing list