[Libreoffice-commits] online.git: 2 commits - android/lib common/Util.cpp common/Util.hpp ios/Mobile kit/ForKit.cpp kit/Kit.cpp kit/Kit.hpp kit/SetupKitEnvironment.hpp Makefile.am wsd/Admin.cpp wsd/ClientSession.cpp wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp
Tor Lillqvist (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jul 3 06:41:08 UTC 2020
Makefile.am | 1
android/lib/src/main/cpp/androidapp.cpp | 1
common/Util.cpp | 19 ++++++++++
common/Util.hpp | 5 ++
ios/Mobile/AppDelegate.mm | 1
kit/ForKit.cpp | 1
kit/Kit.cpp | 40 ----------------------
kit/Kit.hpp | 3 -
kit/SetupKitEnvironment.hpp | 56 ++++++++++++++++++++++++++++++++
wsd/Admin.cpp | 2 -
wsd/ClientSession.cpp | 4 +-
wsd/LOOLWSD.cpp | 24 ++-----------
wsd/LOOLWSD.hpp | 3 -
13 files changed, 93 insertions(+), 67 deletions(-)
New commits:
commit d0672cd2b9d2b50323e099cdc4ce4f85c7f6d96b
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Jul 2 15:36:50 2020 +0300
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Fri Jul 3 08:41:02 2020 +0200
Slight refactoring to make planned re-plumbing of iOS app easier
Change-Id: I274cf167c6593de6f073301f7071f2173b40cbab
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97760
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist <tml at collabora.com>
diff --git a/common/Util.cpp b/common/Util.cpp
index 16681cc56..e0ce00250 100644
--- a/common/Util.cpp
+++ b/common/Util.cpp
@@ -60,6 +60,7 @@
#include "Common.hpp"
#include "Log.hpp"
+#include "Protocol.hpp"
#include "Util.hpp"
using std::size_t;
@@ -640,6 +641,24 @@ namespace Util
hash.resize(std::min(8, (int)hash.length()));
}
+ std::string getProcessIdentifier()
+ {
+ static std::string id = Util::rng::getHexString(8);
+
+ return id;
+ }
+
+ std::string getVersionJSON()
+ {
+ std::string version, hash;
+ Util::getVersionInfo(version, hash);
+ return
+ "{ \"Version\": \"" + version + "\", "
+ "\"Hash\": \"" + hash + "\", "
+ "\"Protocol\": \"" + LOOLProtocol::GetProtocolVersion() + "\", "
+ "\"Id\": \"" + Util::getProcessIdentifier() + "\" }";
+ }
+
std::string UniqueId()
{
static std::atomic_int counter(0);
diff --git a/common/Util.hpp b/common/Util.hpp
index 6dcfa3d48..c634801fb 100644
--- a/common/Util.hpp
+++ b/common/Util.hpp
@@ -176,6 +176,11 @@ namespace Util
/// Get version information
void getVersionInfo(std::string& version, std::string& hash);
+ ///< A random hash that identifies the current process.
+ std::string getProcessIdentifier();
+
+ std::string getVersionJSON();
+
/// Return a string that is unique across processes and calls.
std::string UniqueId();
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index 02be6fcfd..a9b87cba4 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -117,7 +117,7 @@ void AdminSocketHandler::handleMessage(const std::vector<char> &payload)
else if (tokens.equals(0, "version"))
{
// Send LOOL version information
- sendTextFrame("loolserver " + LOOLWSD::getVersionJSON());
+ sendTextFrame("loolserver " + Util::getVersionJSON());
// Send LOKit version information
sendTextFrame("lokitversion " + LOOLWSD::LOKitVersion);
}
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 7762089aa..b313742ec 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -216,7 +216,7 @@ std::string ClientSession::getClipboardURI(bool encode)
std::string meta = _serverURL.getSubURLForEndpoint(
"/lool/clipboard?WOPISrc=" + encodedFrom +
- "&ServerId=" + LOOLWSD::HostIdentifier +
+ "&ServerId=" + Util::getProcessIdentifier() +
"&ViewId=" + std::to_string(getKitViewId()) +
"&Tag=" + _clipboardKeys[0]);
@@ -363,7 +363,7 @@ bool ClientSession::_handleInput(const char *buffer, int length)
}
// Send LOOL version information
- sendTextFrame("loolserver " + LOOLWSD::getVersionJSON());
+ sendTextFrame("loolserver " + Util::getVersionJSON());
// Send LOKit version information
sendTextFrame("lokitversion " + LOOLWSD::LOKitVersion);
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index da8487ddd..90be88646 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -720,7 +720,6 @@ std::string LOOLWSD::FileServerRoot;
std::string LOOLWSD::WelcomeFilesRoot;
std::string LOOLWSD::ServiceRoot;
std::string LOOLWSD::LOKitVersion;
-std::string LOOLWSD::HostIdentifier;
std::string LOOLWSD::ConfigFile = LOOLWSD_CONFIGDIR "/loolwsd.xml";
std::string LOOLWSD::ConfigDir = LOOLWSD_CONFIGDIR "/conf.d";
std::string LOOLWSD::LogLevel = "trace";
@@ -2685,7 +2684,7 @@ private:
if (it != DocBrokers.end())
docBroker = it->second;
}
- if (docBroker && serverId == LOOLWSD::HostIdentifier)
+ if (docBroker && serverId == Util::getProcessIdentifier())
{
std::shared_ptr<std::string> data;
DocumentBroker::ClipboardRequest type;
@@ -2729,8 +2728,8 @@ private:
" and broker: " << (docBroker ? "" : "not ") << "found");
std::string errMsg;
- if (serverId != LOOLWSD::HostIdentifier)
- errMsg = "Cluster configuration error: mis-matching serverid " + serverId + " vs. " + LOOLWSD::HostIdentifier;
+ if (serverId != Util::getProcessIdentifier())
+ errMsg = "Cluster configuration error: mis-matching serverid " + serverId + " vs. " + Util::getProcessIdentifier();
else
errMsg = "Empty clipboard item / session tag " + tag;
@@ -3537,7 +3536,7 @@ public:
<< "\n WelcomeFilesRoot: " << LOOLWSD::WelcomeFilesRoot
<< "\n ServiceRoot: " << LOOLWSD::ServiceRoot
<< "\n LOKitVersion: " << LOOLWSD::LOKitVersion
- << "\n HostIdentifier: " << LOOLWSD::HostIdentifier
+ << "\n HostIdentifier: " << Util::getProcessIdentifier()
<< "\n ConfigFile: " << LOOLWSD::ConfigFile
<< "\n ConfigDir: " << LOOLWSD::ConfigDir
<< "\n LogLevel: " << LOOLWSD::LogLevel
@@ -3699,17 +3698,6 @@ private:
}
};
-std::string LOOLWSD::getVersionJSON()
-{
- std::string version, hash;
- Util::getVersionInfo(version, hash);
- return
- "{ \"Version\": \"" + version + "\", "
- "\"Hash\": \"" + hash + "\", "
- "\"Protocol\": \"" + GetProtocolVersion() + "\", "
- "\"Id\": \"" + HostIdentifier + "\" }";
-}
-
static LOOLWSDServer srv;
#if !MOBILEAPP
@@ -3735,11 +3723,9 @@ int LOOLWSD::innerMain()
setenv("LD_BIND_NOW", "1", 1);
# endif
- HostIdentifier = Util::rng::getHexString(8);
-
std::string version, hash;
Util::getVersionInfo(version, hash);
- LOG_INF("Loolwsd version details: " << version << " - " << hash << " - id " << HostIdentifier << " - on " << Util::getLinuxVersion());
+ LOG_INF("Loolwsd version details: " << version << " - " << hash << " - id " << Util::getProcessIdentifier() << " - on " << Util::getLinuxVersion());
#endif
initializeSSL();
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 654546d30..6f697f28a 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -241,7 +241,6 @@ public:
static std::string WelcomeFilesRoot; ///< From where we should serve the release notes (or otherwise useful content) that is shown on first install or version update.
static std::string ServiceRoot; ///< There are installations that need prefixing every page with some path.
static std::string LOKitVersion;
- static std::string HostIdentifier; ///< A unique random hash that identifies this server
static std::string LogLevel;
static bool AnonymizeUserData;
static bool CheckLoolUser;
@@ -396,8 +395,6 @@ public:
/// get correct server URL with protocol + port number for this running server
static std::string getServerURL();
- static std::string getVersionJSON();
-
int innerMain();
protected:
commit 3edc4d22012e4e6e7b8b4772cac6336909941b42
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Thu Jul 2 16:57:22 2020 +0300
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Fri Jul 3 08:40:49 2020 +0200
Move the setupKitEnvironment() function into a file of its own
A small re-factoring to help planned re-plumbing of the iOS app.
Change-Id: I21f09216a7c5adf965179765a75f5a0d521cd7f3
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97771
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Tor Lillqvist <tml at collabora.com>
diff --git a/Makefile.am b/Makefile.am
index f6dfcfb3d..fbb1edb55 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -275,6 +275,7 @@ kit_headers = kit/ChildSession.hpp \
kit/DummyLibreOfficeKit.hpp \
kit/Kit.hpp \
kit/KitHelper.hpp \
+ kit/SetupKitEnvironment.hpp \
kit/Watermark.hpp
noinst_HEADERS = $(wsd_headers) $(shared_headers) $(kit_headers) \
diff --git a/android/lib/src/main/cpp/androidapp.cpp b/android/lib/src/main/cpp/androidapp.cpp
index e6a3f8a3b..6d196434b 100644
--- a/android/lib/src/main/cpp/androidapp.cpp
+++ b/android/lib/src/main/cpp/androidapp.cpp
@@ -19,6 +19,7 @@
#include <Log.hpp>
#include <LOOLWSD.hpp>
#include <Protocol.hpp>
+#include <SetupKitEnvironment.hpp>
#include <Util.hpp>
#include <osl/detail/android-bootstrap.h>
diff --git a/ios/Mobile/AppDelegate.mm b/ios/Mobile/AppDelegate.mm
index d38f04787..c98211205 100644
--- a/ios/Mobile/AppDelegate.mm
+++ b/ios/Mobile/AppDelegate.mm
@@ -28,6 +28,7 @@
#import "Kit.hpp"
#import "Log.hpp"
#import "LOOLWSD.hpp"
+#import "SetupKitEnvironment.hpp"
#import "Util.hpp"
NSString *app_locale;
diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp
index d1ecb1cdd..721670bd1 100644
--- a/kit/ForKit.cpp
+++ b/kit/ForKit.cpp
@@ -30,6 +30,7 @@
#include <Common.hpp>
#include "Kit.hpp"
+#include "SetupKitEnvironment.hpp"
#include <Log.hpp>
#include <Unit.hpp>
#include <Util.hpp>
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 94241417a..16b2febb6 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -67,6 +67,7 @@
#include <Util.hpp>
#include "Delta.hpp"
#include "Watermark.hpp"
+#include "SetupKitEnvironment.hpp"
#if !MOBILEAPP
#include <common/SigUtil.hpp>
@@ -2475,45 +2476,6 @@ void wakeCallback(void* pData)
#endif
}
-void setupKitEnvironment(const std::string& userInterface)
-{
- // Setup & check environment
- const std::string layers(
- "xcsxcu:${BRAND_BASE_DIR}/share/registry "
- "res:${BRAND_BASE_DIR}/share/registry "
- "bundledext:${${BRAND_BASE_DIR}/program/lounorc:BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
- "sharedext:${${BRAND_BASE_DIR}/program/lounorc:SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
- "userext:${${BRAND_BASE_DIR}/program/lounorc:UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
-#ifdef IOS
- "user:*${BRAND_BASE_DIR}/loolkitconfig.xcu "
-#elif ENABLE_DEBUG && !defined(ANDROID) // '*' denotes non-writable.
- "user:*file://" DEBUG_ABSSRCDIR "/loolkitconfig.xcu "
-#else
- "user:*file://" LOOLWSD_CONFIGDIR "/loolkitconfig.xcu "
-#endif
- );
- ::setenv("CONFIGURATION_LAYERS", layers.c_str(),
- 1 /* override */);
-
-#if !MOBILEAPP
- // No-caps tracing can spawn eg. glxinfo & other oddness.
- unsetenv("DISPLAY");
-#endif
-
- // Set various options we need.
- std::string options = "unipoll";
-#if !MOBILEAPP
- if (Log::logger().trace())
- options += ":profile_events";
-#endif
-
- if (userInterface == "notebookbar")
- options += ":notebookbar";
-
-// options += ":sc_no_grid_bg"; // leave this disabled for now, merged-cells needs more work.
- ::setenv("SAL_LOK_OPTIONS", options.c_str(), 0);
-}
-
#ifndef BUILDING_TESTS
void lokit_main(
diff --git a/kit/Kit.hpp b/kit/Kit.hpp
index 06a03034d..a260a9d11 100644
--- a/kit/Kit.hpp
+++ b/kit/Kit.hpp
@@ -47,9 +47,6 @@ void lokit_main(
void runKitLoopInAThread();
#endif
-/// We need to get several env. vars right
-void setupKitEnvironment(const std::string& userInterface);
-
bool globalPreinit(const std::string& loTemplate);
/// Wrapper around private Document::ViewCallback().
void documentViewCallback(const int type, const char* p, void* data);
diff --git a/kit/SetupKitEnvironment.hpp b/kit/SetupKitEnvironment.hpp
new file mode 100644
index 000000000..a8ef721ad
--- /dev/null
+++ b/kit/SetupKitEnvironment.hpp
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <cstdlib>
+#include <string>
+
+#include <Log.hpp>
+
+inline void setupKitEnvironment(const std::string& userInterface)
+{
+ // Setup & check environment
+ const std::string layers(
+ "xcsxcu:${BRAND_BASE_DIR}/share/registry "
+ "res:${BRAND_BASE_DIR}/share/registry "
+ "bundledext:${${BRAND_BASE_DIR}/program/lounorc:BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
+ "sharedext:${${BRAND_BASE_DIR}/program/lounorc:SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
+ "userext:${${BRAND_BASE_DIR}/program/lounorc:UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
+#ifdef IOS
+ "user:*${BRAND_BASE_DIR}/loolkitconfig.xcu "
+#elif ENABLE_DEBUG && !defined(ANDROID) // '*' denotes non-writable.
+ "user:*file://" DEBUG_ABSSRCDIR "/loolkitconfig.xcu "
+#else
+ "user:*file://" LOOLWSD_CONFIGDIR "/loolkitconfig.xcu "
+#endif
+ );
+ ::setenv("CONFIGURATION_LAYERS", layers.c_str(),
+ 1 /* override */);
+
+#if !MOBILEAPP
+ // No-caps tracing can spawn eg. glxinfo & other oddness.
+ unsetenv("DISPLAY");
+#endif
+
+ // Set various options we need.
+ std::string options = "unipoll";
+#if !MOBILEAPP
+ if (Log::logger().trace())
+ options += ":profile_events";
+#endif
+
+ if (userInterface == "notebookbar")
+ options += ":notebookbar";
+
+// options += ":sc_no_grid_bg"; // leave this disabled for now, merged-cells needs more work.
+ ::setenv("SAL_LOK_OPTIONS", options.c_str(), 0);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list