Commit 8497c0cf authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Use ServerManager::agentServiceName() to get agent DBus service name

ServerManager automatically handles Akonadi instances and includes it in
the service name.
parent 63fe3c32
......@@ -152,8 +152,8 @@ void Firstrun::instanceCreated(KJob *job)
instance.setName(agentName);
}
QDBusInterface *iface = new QDBusInterface(QStringLiteral("org.freedesktop.Akonadi.Agent.%1").arg(instance.identifier()),
QStringLiteral("/Settings"), QString(),
const auto service = ServerManager::agentServiceName(ServerManager::Agent, instance.identifier());
QDBusInterface *iface = new QDBusInterface(service, QStringLiteral("/Settings"), QString(),
KDBusConnectionPool::threadConnection(), this);
if (!iface->isValid()) {
qCCritical(AKONADICORE_LOG) << "Unable to obtain the KConfigXT D-Bus interface of " << instance.identifier();
......
......@@ -332,8 +332,8 @@ void DefaultResourceJobPrivate::resourceCreateResult(KJob *job)
{
agent.setName(mDefaultResourceOptions.value(QStringLiteral("Name")).toString());
QDBusInterface conf(QLatin1String("org.freedesktop.Akonadi.Resource.") + defaultId,
QStringLiteral("/Settings"), QString());
const auto service = ServerManager::agentServiceName(ServerManager::Resource, defaultId);
QDBusInterface conf(service, QStringLiteral("/Settings"), QString());
if (!conf.isValid()) {
q->setError(-1);
......
......@@ -55,11 +55,7 @@ public:
//Don't allow to reindex twice.
ui.reindexButton->setEnabled(false);
QString service = QStringLiteral("org.freedesktop.Akonadi.Agent.akonadi_indexing_agent");
if (Akonadi::ServerManager::hasInstanceIdentifier()) {
service += QLatin1Char('.') + Akonadi::ServerManager::instanceIdentifier();
}
const auto service = ServerManager::agentServiceName(ServerManager::Agent, QStringLiteral("akonadi_indexing_agent"));
QDBusInterface indexingAgentIface(service,
QStringLiteral("/"),
QStringLiteral("org.freedesktop.Akonadi.Indexer"));
......@@ -146,11 +142,7 @@ void CollectionMaintenancePage::load(const Collection &col)
if (!indexingWasEnabled) {
d->ui.indexedCountLbl->hide();
} else {
QString service = QStringLiteral("org.freedesktop.Akonadi.Agent.akonadi_indexing_agent");
if (Akonadi::ServerManager::hasInstanceIdentifier()) {
service += QLatin1Char('.') + Akonadi::ServerManager::instanceIdentifier();
}
const auto service = ServerManager::agentServiceName(ServerManager::Agent, QStringLiteral("akonadi_indexing_agent"));
QDBusInterface indexingAgentIface(service,
QStringLiteral("/"),
QStringLiteral("org.freedesktop.Akonadi.Indexer"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment