Verified Commit cb075707 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Use Akonadi::ServerManager to get a DBus service name of an agent

parent 5d77cdc7
......@@ -30,6 +30,7 @@
#include <AkonadiCore/AgentInstance>
#include <AkonadiCore/Collection>
#include <AkonadiCore/Item>
#include <AkonadiCore/ServerManager>
#include <QObject>
#include <QDBusConnection>
......@@ -354,8 +355,8 @@ private:
*/
template <class Interface> Interface* AkonadiResource::getAgentInterface(const Akonadi::AgentInstance& agent, QString& errorMessage, QObject* parent)
{
Interface* iface = new Interface(QLatin1String("org.freedesktop.Akonadi.Resource.") + agent.identifier(),
QStringLiteral("/Settings"), QDBusConnection::sessionBus(), parent);
const auto service = Akonadi::ServerManager::agentServiceName(Akonadi::ServerManager::Resource, agent.identifier());
Interface* iface = new Interface(service, QStringLiteral("/Settings"), QDBusConnection::sessionBus(), parent);
if (!iface->isValid())
{
errorMessage = iface->lastError().message();
......
......@@ -30,6 +30,7 @@
#include <AkonadiCore/AgentFilterProxyModel>
#include <AkonadiCore/AgentInstanceCreateJob>
#include <AkonadiCore/AgentManager>
#include <AkonadiCore/ServerManager>
#include <AkonadiWidgets/AgentTypeDialog>
#include <AkonadiWidgets/AgentConfigurationDialog>
......@@ -183,8 +184,8 @@ void AkonadiResourceCreator::slotResourceAdded(Resource& resource)
template <class Settings>
void AkonadiResourceCreator::setResourceAlarmType()
{
Settings iface(QStringLiteral("org.freedesktop.Akonadi.Resource.") + mAgentInstance.identifier(),
QStringLiteral("/Settings"), QDBusConnection::sessionBus(), this);
const auto service = Akonadi::ServerManager::agentServiceName(Akonadi::ServerManager::Resource, mAgentInstance.identifier());
Settings iface(service, QStringLiteral("/Settings"), QDBusConnection::sessionBus(), this);
if (!iface.isValid())
qCCritical(KALARM_LOG) << "AkonadiResourceCreator::setResourceAlarmType: Error creating D-Bus interface for" << mAgentInstance.identifier() << "resource configuration.";
else
......@@ -201,8 +202,8 @@ void AkonadiResourceCreator::setResourceAlarmType()
template <class Settings>
QString AkonadiResourceCreator::getResourcePath()
{
Settings iface(QStringLiteral("org.freedesktop.Akonadi.Resource.") + mAgentInstance.identifier(),
QStringLiteral("/Settings"), QDBusConnection::sessionBus(), this);
const auto service = Akonadi::ServerManager::agentServiceName(Akonadi::ServerManager::Resource, mAgentInstance.identifier());
Settings iface(service, QStringLiteral("/Settings"), QDBusConnection::sessionBus(), this);
if (!iface.isValid())
{
qCCritical(KALARM_LOG) << "AkonadiResourceCreator::getResourcePath: Error creating D-Bus interface for" << mAgentInstance.identifier() << "resource configuration.";
......
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