diff --git a/common/Util.cpp b/common/Util.cpp
index 3697e07cead65..4fdb424cfd9a2 100644
--- a/common/Util.cpp
+++ b/common/Util.cpp
@@ -388,7 +388,7 @@ namespace Util
return id;
}
- std::string getVersionJSON(bool enableExperimental, bool geolocationSetup)
+ std::string getVersionJSON(bool enableExperimental, const std::string& timezone)
{
std::string version, hash;
Util::getVersionInfo(version, hash);
@@ -415,13 +415,10 @@ namespace Util
"\"Id\": \"" +
Util::getProcessIdentifier() + "\", ";
- if (geolocationSetup)
- json += "\"TimeZone\": \"" + getIANATimezone() +
- "\", "
- "\"Options\": \"" +
- std::string(enableExperimental ? " (E)" : "") + "\" }";
- else
- json += "\"Options\": \"" + std::string(enableExperimental ? " (E)" : "") + "\" }";
+ if (!timezone.empty())
+ json += "\"TimeZone\": \"" + timezone + "\", ";
+
+ json += "\"Options\": \"" + std::string(enableExperimental ? " (E)" : "") + "\" }";
return json;
}
@@ -963,26 +960,6 @@ namespace Util
}
}
- std::string getIANATimezone()
- {
- const char* tzfile = "/etc/localtime";
- char buf[PATH_MAX];
-
- ssize_t len = readlink(tzfile, buf, sizeof(buf) - 1);
- if (len != -1)
- {
- buf[len] = '\0';
- std::string fullPath(buf);
-
- std::string prefix = "../usr/share/zoneinfo/";
- if (fullPath.substr(0, prefix.size()) == prefix)
- {
- return fullPath.substr(prefix.size());
- }
- }
- return std::string();
- }
-
std::string Backtrace::Symbol::toString() const
{
std::string s;
diff --git a/common/Util.hpp b/common/Util.hpp
index cec20cb34515e..645c877f1eadf 100644
--- a/common/Util.hpp
+++ b/common/Util.hpp
@@ -332,7 +332,7 @@ namespace Util
///< A random hex string that identifies the current process.
const std::string& getProcessIdentifier();
- std::string getVersionJSON(bool enableExperimental, bool geolocationSetup);
+ std::string getVersionJSON(bool enableExperimental, const std::string& timezone);
/// Return a string that is unique across processes and calls.
std::string UniqueId();
@@ -1553,9 +1553,6 @@ int main(int argc, char**argv)
return oss.str();
}
- /// Get IANA timezone name
- std::string getIANATimezone();
-
/// Asserts in the debug builds, otherwise just logs.
void assertCorrectThread(std::thread::id owner, const char* fileName, int lineNo);
diff --git a/coolwsd.xml.in b/coolwsd.xml.in
index 9c5d59fc31eb4..5d42e398c103b 100644
--- a/coolwsd.xml.in
+++ b/coolwsd.xml.in
@@ -324,8 +324,9 @@
false
+
-
+
@LOCK_CONFIGURATION@
diff --git a/wsd/Admin.cpp b/wsd/Admin.cpp
index c6a2586ec044c..9b7da26e8a68c 100644
--- a/wsd/Admin.cpp
+++ b/wsd/Admin.cpp
@@ -13,6 +13,7 @@
#include
#include
+#include
#include
#include
@@ -22,6 +23,7 @@
#include "Admin.hpp"
#include "AdminModel.hpp"
#include "Auth.hpp"
+#include "ConfigUtil.hpp"
#include
#include
#include
@@ -131,9 +133,11 @@ void AdminSocketHandler::handleMessage(const std::vector &payload)
else if (tokens.equals(0, "version"))
{
// Send COOL version information
- sendTextFrame("coolserver " +
- Util::getVersionJSON(EnableExperimental, COOLWSD::IndirectionServerEnabled &&
- COOLWSD::GeolocationSetup));
+ std::string timezoneName;
+ if (COOLWSD::IndirectionServerEnabled && COOLWSD::GeolocationSetup)
+ timezoneName = config::getString("indirection_endpoint.geolocation_setup.timezone", "");
+
+ sendTextFrame("coolserver " + Util::getVersionJSON(EnableExperimental, timezoneName));
// Send LOKit version information
sendTextFrame("lokitversion " + COOLWSD::LOKitVersion);
diff --git a/wsd/COOLWSD.cpp b/wsd/COOLWSD.cpp
index c3189e757362a..efad6f83aea74 100644
--- a/wsd/COOLWSD.cpp
+++ b/wsd/COOLWSD.cpp
@@ -2195,6 +2195,7 @@ void COOLWSD::innerInitialize(Application& self)
{ "deepl.enabled", "false" },
{ "zotero.enable", "true" },
{ "indirection_endpoint.geolocation_setup.enable", "false" },
+ { "indirection_endpoint.geolocation_setup.timezone", "" },
{ "indirection_endpoint.server_name", "" },
{ "indirection_endpoint.url", "" },
#if !MOBILEAPP
diff --git a/wsd/ClientRequestDispatcher.cpp b/wsd/ClientRequestDispatcher.cpp
index a7ee28fc35abc..7f13fff33bddb 100644
--- a/wsd/ClientRequestDispatcher.cpp
+++ b/wsd/ClientRequestDispatcher.cpp
@@ -2050,7 +2050,8 @@ static std::string getCapabilitiesJson(bool convertToAvailable)
if (COOLWSD::IndirectionServerEnabled && COOLWSD::GeolocationSetup)
{
- std::string timezoneName = Util::getIANATimezone();
+ std::string timezoneName =
+ config::getString("indirection_endpoint.geolocation_setup.timezone", "");
if (!timezoneName.empty())
capabilities->set("timezone", std::string(timezoneName));
}
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 2a72bec880883..2a3f38a9ce9af 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -25,6 +25,7 @@
#include
#include
+#include "ConfigUtil.hpp"
#include "DocumentBroker.hpp"
#include "COOLWSD.hpp"
#include "FileServer.hpp"
@@ -635,10 +636,12 @@ bool ClientSession::_handleInput(const char *buffer, int length)
}
}
+ std::string timezoneName;
+ if (COOLWSD::IndirectionServerEnabled && COOLWSD::GeolocationSetup)
+ timezoneName = config::getString("indirection_endpoint.geolocation_setup.timezone", "");
+
// Send COOL version information
- sendTextFrame("coolserver " +
- Util::getVersionJSON(EnableExperimental, COOLWSD::IndirectionServerEnabled &&
- COOLWSD::GeolocationSetup));
+ sendTextFrame("coolserver " + Util::getVersionJSON(EnableExperimental, timezoneName));
// Send LOKit version information
sendTextFrame("lokitversion " + COOLWSD::LOKitVersion);