diff --git a/agents/archivemailagent/archivemailagent.cpp b/agents/archivemailagent/archivemailagent.cpp index eba4a33f5..84b4f1700 100644 --- a/agents/archivemailagent/archivemailagent.cpp +++ b/agents/archivemailagent/archivemailagent.cpp @@ -106,20 +106,6 @@ void ArchiveMailAgent::mailCollectionRemoved(const Akonadi::Collection &collecti mArchiveManager->removeCollection(collection); } -void ArchiveMailAgent::showConfigureDialog(qlonglong windowId) -{ - QPointer dialog = new ArchiveMailDialog(); - if (windowId) { - KWindowSystem::setMainWindow(dialog, windowId); - } - connect(dialog.data(), &ArchiveMailDialog::archiveNow, mArchiveManager, &ArchiveMailManager::slotArchiveNow); - connect(this, &ArchiveMailAgent::needUpdateConfigDialogBox, dialog.data(), &ArchiveMailDialog::slotNeedReloadConfig); - if (dialog->exec()) { - mArchiveManager->load(); - } - delete dialog; -} - void ArchiveMailAgent::doSetOnline(bool online) { if (online) { @@ -139,7 +125,16 @@ void ArchiveMailAgent::reload() void ArchiveMailAgent::configure(WId windowId) { - showConfigureDialog(static_cast(windowId)); + QPointer dialog = new ArchiveMailDialog(); + if (windowId) { + KWindowSystem::setMainWindow(dialog, windowId); + } + connect(dialog.data(), &ArchiveMailDialog::archiveNow, mArchiveManager, &ArchiveMailManager::slotArchiveNow); + connect(this, &ArchiveMailAgent::needUpdateConfigDialogBox, dialog.data(), &ArchiveMailDialog::slotNeedReloadConfig); + if (dialog->exec()) { + mArchiveManager->load(); + } + delete dialog; } void ArchiveMailAgent::pause() diff --git a/agents/archivemailagent/archivemailagent.h b/agents/archivemailagent/archivemailagent.h index 2a51f8f1b..723916dc2 100644 --- a/agents/archivemailagent/archivemailagent.h +++ b/agents/archivemailagent/archivemailagent.h @@ -36,7 +36,6 @@ public: explicit ArchiveMailAgent(const QString &id); ~ArchiveMailAgent() override; - void showConfigureDialog(qlonglong windowId = 0); QString printArchiveListInfo(); void setEnableAgent(bool b); diff --git a/agents/archivemailagent/org.freedesktop.Akonadi.ArchiveMailAgent.xml b/agents/archivemailagent/org.freedesktop.Akonadi.ArchiveMailAgent.xml index a5a6e4abf..128636742 100644 --- a/agents/archivemailagent/org.freedesktop.Akonadi.ArchiveMailAgent.xml +++ b/agents/archivemailagent/org.freedesktop.Akonadi.ArchiveMailAgent.xml @@ -1,9 +1,6 @@ - - - diff --git a/agents/followupreminderagent/followupreminderagent.cpp b/agents/followupreminderagent/followupreminderagent.cpp index fdfd23c1c..e084f81c4 100644 --- a/agents/followupreminderagent/followupreminderagent.cpp +++ b/agents/followupreminderagent/followupreminderagent.cpp @@ -52,7 +52,6 @@ FollowUpReminderAgent::FollowUpReminderAgent(const QString &id) if (Akonadi::ServerManager::hasInstanceIdentifier()) { service += QLatin1Char('.') + Akonadi::ServerManager::instanceIdentifier(); } - KDBusConnectionPool::threadConnection().registerService(service); mManager = new FollowUpReminderManager(this); setNeedsNetwork(true); @@ -101,7 +100,7 @@ bool FollowUpReminderAgent::enabledAgent() const return FollowUpReminderAgentSettings::self()->enabled(); } -void FollowUpReminderAgent::showConfigureDialog(qlonglong windowId) +void FollowUpReminderAgent::configure(WId windowId) { QPointer dialog = new FollowUpReminderInfoDialog(); dialog->load(); @@ -117,11 +116,6 @@ void FollowUpReminderAgent::showConfigureDialog(qlonglong windowId) delete dialog; } -void FollowUpReminderAgent::configure(WId windowId) -{ - showConfigureDialog(static_cast(windowId)); -} - void FollowUpReminderAgent::itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection) { if (!enabledAgent()) { diff --git a/agents/followupreminderagent/followupreminderagent.h b/agents/followupreminderagent/followupreminderagent.h index 6182a922f..9a22dd19c 100644 --- a/agents/followupreminderagent/followupreminderagent.h +++ b/agents/followupreminderagent/followupreminderagent.h @@ -32,8 +32,6 @@ public: void setEnableAgent(bool b); bool enabledAgent() const; - void showConfigureDialog(qlonglong windowId = 0); - QString printDebugInfo(); public Q_SLOTS: diff --git a/agents/followupreminderagent/org.freedesktop.Akonadi.FollowUpReminder.xml b/agents/followupreminderagent/org.freedesktop.Akonadi.FollowUpReminder.xml index dd6f73867..435279db7 100644 --- a/agents/followupreminderagent/org.freedesktop.Akonadi.FollowUpReminder.xml +++ b/agents/followupreminderagent/org.freedesktop.Akonadi.FollowUpReminder.xml @@ -1,9 +1,6 @@ - - - diff --git a/agents/sendlateragent/org.freedesktop.Akonadi.SendLaterAgent.xml b/agents/sendlateragent/org.freedesktop.Akonadi.SendLaterAgent.xml index fef029564..9ce96d88d 100644 --- a/agents/sendlateragent/org.freedesktop.Akonadi.SendLaterAgent.xml +++ b/agents/sendlateragent/org.freedesktop.Akonadi.SendLaterAgent.xml @@ -1,9 +1,6 @@ - - - diff --git a/agents/sendlateragent/sendlateragent.cpp b/agents/sendlateragent/sendlateragent.cpp index 5da9b3b1f..ac25b410c 100644 --- a/agents/sendlateragent/sendlateragent.cpp +++ b/agents/sendlateragent/sendlateragent.cpp @@ -137,16 +137,6 @@ bool SendLaterAgent::enabledAgent() const } void SendLaterAgent::configure(WId windowId) -{ - showConfigureDialog(static_cast(windowId)); -} - -void SendLaterAgent::slotSendNow(Akonadi::Item::Id id) -{ - mManager->sendNow(id); -} - -void SendLaterAgent::showConfigureDialog(qlonglong windowId) { QPointer dialog = new SendLaterConfigureDialog(); if (windowId) { @@ -166,6 +156,11 @@ void SendLaterAgent::showConfigureDialog(qlonglong windowId) delete dialog; } +void SendLaterAgent::slotSendNow(Akonadi::Item::Id id) +{ + mManager->sendNow(id); +} + void SendLaterAgent::itemsRemoved(const Akonadi::Item::List &items) { for (const Akonadi::Item &item : items) { diff --git a/agents/sendlateragent/sendlateragent.h b/agents/sendlateragent/sendlateragent.h index 7d6dce068..fa9f090b3 100644 --- a/agents/sendlateragent/sendlateragent.h +++ b/agents/sendlateragent/sendlateragent.h @@ -32,8 +32,6 @@ public: explicit SendLaterAgent(const QString &id); ~SendLaterAgent() override; - void showConfigureDialog(qlonglong windowId = 0); - QString printDebugInfo(); void setEnableAgent(bool b); diff --git a/src/configuredialog/configureplugins/configurepluginslistwidget.cpp b/src/configuredialog/configureplugins/configurepluginslistwidget.cpp index c3b1929a9..9d00425aa 100644 --- a/src/configuredialog/configureplugins/configurepluginslistwidget.cpp +++ b/src/configuredialog/configureplugins/configurepluginslistwidget.cpp @@ -335,12 +335,9 @@ void ConfigurePluginsListWidget::slotConfigureClicked(const QString &configureGr } else if (configureGroupName == agentAkonadiGroupName()) { for (const PimCommon::PluginUtilData &data : qAsConst(mPluginUtilDataList)) { if (data.mIdentifier == identifier) { - const QString service = Akonadi::ServerManager::agentServiceName(Akonadi::ServerManager::Agent, data.mExtraInfo.at(0)); - QDBusInterface interface(service, data.mExtraInfo.at(1)); - if (interface.isValid()) { - interface.call(QStringLiteral("showConfigureDialog"), static_cast(winId())); - } else { - qCDebug(KMAIL_LOG) << " interface does not exist when trying to configure the plugin"; + auto instance = Akonadi::AgentManager::self()->instance(identifier); + if (instance.isValid()) { + instance.configure(this); } break; } diff --git a/src/kmlaunchexternalcomponent.cpp b/src/kmlaunchexternalcomponent.cpp index ee9261308..b2d08eade 100644 --- a/src/kmlaunchexternalcomponent.cpp +++ b/src/kmlaunchexternalcomponent.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "util.h" #include "archivemailagentinterface.h" @@ -44,21 +45,11 @@ KMLaunchExternalComponent::~KMLaunchExternalComponent() { } -QString KMLaunchExternalComponent::akonadiPath(QString service) -{ - if (Akonadi::ServerManager::hasInstanceIdentifier()) { - service += QLatin1Char('.') + Akonadi::ServerManager::instanceIdentifier(); - } - return service; -} - void KMLaunchExternalComponent::slotConfigureAutomaticArchiving() { - const QString service = akonadiPath(QStringLiteral("org.freedesktop.Akonadi.ArchiveMailAgent")); - OrgFreedesktopAkonadiArchiveMailAgentInterface archiveMailInterface(service, QStringLiteral("/ArchiveMailAgent"), - QDBusConnection::sessionBus(), this); - if (archiveMailInterface.isValid()) { - archiveMailInterface.showConfigureDialog(static_cast(mParentWidget->winId())); + auto agent = Akonadi::AgentManager::self()->instance(QStringLiteral("akonadi_archivemail_agent")); + if (agent.isValid()) { + agent.configure(mParentWidget); } else { KMessageBox::error(mParentWidget, i18n("Archive Mail Agent was not registered.")); } @@ -66,10 +57,9 @@ void KMLaunchExternalComponent::slotConfigureAutomaticArchiving() void KMLaunchExternalComponent::slotConfigureSendLater() { - const QString service = akonadiPath(QStringLiteral("org.freedesktop.Akonadi.SendLaterAgent")); - OrgFreedesktopAkonadiSendLaterAgentInterface sendLaterInterface(service, QStringLiteral("/SendLaterAgent"), QDBusConnection::sessionBus(), this); - if (sendLaterInterface.isValid()) { - sendLaterInterface.showConfigureDialog(static_cast(mParentWidget->winId())); + auto agent = Akonadi::AgentManager::self()->instance(QStringLiteral("akonadi_sendlater_agent")); + if (agent.isValid()) { + agent.configure(mParentWidget); } else { KMessageBox::error(mParentWidget, i18n("Send Later Agent was not registered.")); } @@ -77,12 +67,9 @@ void KMLaunchExternalComponent::slotConfigureSendLater() void KMLaunchExternalComponent::slotConfigureFollowupReminder() { - const QString service = akonadiPath(QStringLiteral("org.freedesktop.Akonadi.FollowUpReminder")); - - OrgFreedesktopAkonadiFollowUpReminderAgentInterface followUpInterface(service, QStringLiteral("/FollowUpReminder"), - QDBusConnection::sessionBus(), this); - if (followUpInterface.isValid()) { - followUpInterface.showConfigureDialog(static_cast(mParentWidget->winId())); + auto agent = Akonadi::AgentManager::self()->instance(QStringLiteral("akonadi_followupreminder_agent")); + if (agent.isValid()) { + agent.configure(mParentWidget); } else { KMessageBox::error(mParentWidget, i18n("Followup Reminder Agent was not registered.")); }