aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vrátil <dvratil@kde.org>2016-08-13 19:48:35 (GMT)
committerDaniel Vrátil <dvratil@kde.org>2016-08-13 19:48:35 (GMT)
commitbc674b405eadf1514defc135e60373e98927b012 (patch)
tree43502d0766c476beeb79f286e90aad066032790c
parent6886c5d7c462329998980c5dfa0e9d9344112147 (diff)
Add API to get and set server config path
This introduced a new DBus call on Server to get path to its config path. This is useful when one wants to figure out the config path of a Server running via testrunner, i.e. having XDG_CONFIG_DIRS randomly set in /tmp. Secondly it introduced an API in XdgBaseDirs which allows overriding the config dir path - this is useful when you want to connect to a server which is running with different XDG_CONFIG_DIRS than yours, e.g. in AkonadiConsole.
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/core/servermanager.cpp7
-rw-r--r--src/interfaces/org.freedesktop.Akonadi.Server.xml3
-rw-r--r--src/private/xdgbasedirs.cpp13
-rw-r--r--src/private/xdgbasedirs_p.h17
-rw-r--r--src/server/akonadi.cpp5
-rw-r--r--src/server/akonadi.h2
7 files changed, 41 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4df0cc6..e1b21b4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,7 +20,7 @@ include(ECMQtDeclareLoggingCategory)
include(AkonadiMacros)
-set(PIM_VERSION "5.3.41")
+set(PIM_VERSION "5.3.42")
set(QT_REQUIRED_VERSION "5.5.0")
set(AKONADI_VERSION ${PIM_VERSION})
diff --git a/src/core/servermanager.cpp b/src/core/servermanager.cpp
index 5325dab..219a7df 100644
--- a/src/core/servermanager.cpp
+++ b/src/core/servermanager.cpp
@@ -323,9 +323,14 @@ QString ServerManager::agentServiceName(ServiceAgentType agentType, const QStrin
QString ServerManager::serverConfigFilePath(OpenMode openMode)
{
+ QString relPath;
+ if (hasInstanceIdentifier()) {
+ relPath = QStringLiteral("instance/%1").arg(ServerManager::instanceIdentifier());
+ }
return XdgBaseDirs::akonadiServerConfigFile(openMode == Akonadi::ServerManager::ReadOnly
? XdgBaseDirs::ReadOnly
- : XdgBaseDirs::ReadWrite);
+ : XdgBaseDirs::ReadWrite,
+ relPath);
}
QString ServerManager::agentConfigFilePath(const QString &identifier)
diff --git a/src/interfaces/org.freedesktop.Akonadi.Server.xml b/src/interfaces/org.freedesktop.Akonadi.Server.xml
index 7c6da49..9f2788d 100644
--- a/src/interfaces/org.freedesktop.Akonadi.Server.xml
+++ b/src/interfaces/org.freedesktop.Akonadi.Server.xml
@@ -2,5 +2,8 @@
<node>
<interface name="org.freedesktop.Akonadi.Server">
<method name="quit"/>
+ <method name="serverPath">
+ <arg name="path" type="s" direction="out"/>
+ </method>
</interface>
</node>
diff --git a/src/private/xdgbasedirs.cpp b/src/private/xdgbasedirs.cpp
index e903acc..7d9d314 100644
--- a/src/private/xdgbasedirs.cpp
+++ b/src/private/xdgbasedirs.cpp
@@ -513,14 +513,14 @@ QString XdgBaseDirs::saveDir(const char *resource, const QString &relPath)
return QString();
}
-QString XdgBaseDirs::akonadiServerConfigFile(FileAccessMode openMode)
+QString XdgBaseDirs::akonadiServerConfigFile(FileAccessMode openMode, const QString &relPath)
{
- return akonadiConfigFile(QStringLiteral("akonadiserverrc"), openMode);
+ return akonadiConfigFile(QStringLiteral("%1/akonadiserverrc").arg(relPath), openMode);
}
-QString XdgBaseDirs::akonadiConnectionConfigFile(FileAccessMode openMode)
+QString XdgBaseDirs::akonadiConnectionConfigFile(FileAccessMode openMode, const QString &relPath)
{
- return akonadiConfigFile(QStringLiteral("akonadiconnectionrc"), openMode);
+ return akonadiConfigFile(QStringLiteral("%1/akonadiconnectionrc").arg(relPath), openMode);
}
QString XdgBaseDirs::akonadiConfigFile(const QString &file, FileAccessMode openMode)
@@ -583,3 +583,8 @@ QStringList XdgBaseDirsSingleton::systemPathList(const char *variable, const cha
return splitPathList(xdgDirList);
}
+
+void XdgBaseDirs::overrideConfigPath(const QString &configFile)
+{
+ instance()->mConfigHome = configFile;
+}
diff --git a/src/private/xdgbasedirs_p.h b/src/private/xdgbasedirs_p.h
index e666916..61b6d01 100644
--- a/src/private/xdgbasedirs_p.h
+++ b/src/private/xdgbasedirs_p.h
@@ -289,10 +289,12 @@ public:
* since this is an often needed procedure in several parts of the code.
*
* @param openMode how the application wants to use the config file
+ * @param relPath Relative path within the akonadi config directory
*
* @return the path of the server config file, suitable for \p openMode
*/
- static QString akonadiServerConfigFile(FileAccessMode openMode = ReadOnly);
+ static QString akonadiServerConfigFile(FileAccessMode openMode = ReadOnly,
+ const QString &relPath = QString());
/**
* @brief Returns the path of the Akonadi data connection config file
@@ -301,10 +303,21 @@ public:
* since this is an often needed procedure in several parts of the code.
*
* @param openMode how the application wants to use the config file
+ * @relPath Relative path within the akonadi config directory
*
* @return the path of the data connection config file, suitable for \p openMode
*/
- static QString akonadiConnectionConfigFile(FileAccessMode openMode = ReadOnly);
+ static QString akonadiConnectionConfigFile(FileAccessMode openMode = ReadOnly,
+ const QString &relPath = QString());
+
+
+ /**
+ * @brief Overrides the lookup path to the "config" resource
+ *
+ * This is useful for testing purposes and when connecting to Akonadi
+ * instance that is not running in the default user path.
+ */
+ static void overrideConfigPath(const QString &configFile);
private:
XdgBaseDirsPrivate *const d;
diff --git a/src/server/akonadi.cpp b/src/server/akonadi.cpp
index 98a5b59..f660b59 100644
--- a/src/server/akonadi.cpp
+++ b/src/server/akonadi.cpp
@@ -437,3 +437,8 @@ IntervalCheck *AkonadiServer::intervalChecker()
return Q_NULLPTR;
}
+
+QString AkonadiServer::serverPath() const
+{
+ return XdgBaseDirs::homePath("config");
+}
diff --git a/src/server/akonadi.h b/src/server/akonadi.h
index 9438da0..5ea7112 100644
--- a/src/server/akonadi.h
+++ b/src/server/akonadi.h
@@ -57,6 +57,8 @@ public:
*/
IntervalCheck *intervalChecker();
+ QString serverPath() const;
+
public Q_SLOTS:
/**
* Triggers a clean server shutdown.