From 0a45ce1d7f170c86ac955d1277905830f6fb7ed7 Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Sat, 3 Jan 2015 08:48:29 +0100 Subject: [PATCH] Use imapresourcemanager --- kmail/kmkernel.cpp | 7 +++++++ kmail/kmkernel.h | 3 +++ pimcommon/util/imapresourcemanager.cpp | 20 +++++++++++++------- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/kmail/kmkernel.cpp b/kmail/kmkernel.cpp index 4d631c455c..2195e35b88 100644 --- a/kmail/kmkernel.cpp +++ b/kmail/kmkernel.cpp @@ -114,6 +114,7 @@ using KMail::MailServiceImpl; #include "foldercollectionmonitor.h" #include "imapresourcesettings.h" #include "util.h" +#include "pimcommon/util/imapresourcemanager.h" #include "mailcommon/kernel/mailkernel.h" #include "searchdialog/searchdescriptionattribute.h" @@ -143,6 +144,7 @@ KMKernel::KMKernel (QObject *parent) : KMail::Util::migrateFromKMail1(); kDebug() << "Starting up..."; + mImapResourceManager = new PimCommon::ImapResourceManager(this); mySelf = this; the_firstInstance = true; @@ -2082,6 +2084,11 @@ PimCommon::StorageServiceManager *KMKernel::storageServiceManager() const return mStorageManager; } +PimCommon::ImapResourceManager *KMKernel::imapResourceManager() const +{ + return mImapResourceManager; +} + bool KMKernel::allowToDebugBalooSupport() const { return mDebugBaloo; diff --git a/kmail/kmkernel.h b/kmail/kmkernel.h index 1c66223eb4..aa4c611162 100644 --- a/kmail/kmkernel.h +++ b/kmail/kmkernel.h @@ -44,6 +44,7 @@ class MessageSender; namespace PimCommon { class AutoCorrection; class StorageServiceManager; +class ImapResourceManager; } /** The KMail namespace contains classes used for KMail. @@ -426,6 +427,7 @@ public: void toggleSystemTray(); FolderArchiveManager *folderArchiveManager() const; PimCommon::StorageServiceManager *storageServiceManager() const; + PimCommon::ImapResourceManager *imapResourceManager() const; bool allowToDebugBalooSupport() const; @@ -533,6 +535,7 @@ private: PimCommon::AutoCorrection *mAutoCorrection; FolderArchiveManager *mFolderArchiveManager; PimCommon::StorageServiceManager *mStorageManager; + PimCommon::ImapResourceManager *mImapResourceManager; bool mDebugBaloo; }; diff --git a/pimcommon/util/imapresourcemanager.cpp b/pimcommon/util/imapresourcemanager.cpp index 3af288f3ae..521618cfe9 100644 --- a/pimcommon/util/imapresourcemanager.cpp +++ b/pimcommon/util/imapresourcemanager.cpp @@ -38,26 +38,31 @@ ImapResourceManager::~ImapResourceManager() void ImapResourceManager::slotInstanceAdded(const Akonadi::AgentInstance &instance) { - searchCapabilities(instance.type().identifier()); + searchCapabilities(instance.identifier()); } void ImapResourceManager::slotInstanceRemoved(const Akonadi::AgentInstance &instance) { - mImapResource.remove(instance.type().identifier()); + mImapResource.remove(instance.identifier()); } void ImapResourceManager::searchCapabilities(const QString &identifier) { + qDebug()<<" void ImapResourceManager::searchCapabilities(const QString &identifier)"<setProperty("identifier", identifier); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(slotCapabilities(QDBusPendingCallWatcher*))); + if (iface.isValid()) { + QDBusPendingCall call = iface.asyncCall( QLatin1String( "serverCapabilities" ) ); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); + watcher->setProperty("identifier", identifier); + connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(slotCapabilities(QDBusPendingCallWatcher*))); + } else { + qDebug() << "interface not valid"; + } } void ImapResourceManager::slotCapabilities(QDBusPendingCallWatcher* watcher) @@ -66,6 +71,7 @@ void ImapResourceManager::slotCapabilities(QDBusPendingCallWatcher* watcher) if ( reply.isValid() ) { if (watcher->property("identifier").isValid()) { const QStringList capabilities = reply.value(); + qDebug()<<" capabilities"<property("identifier").toString(); mImapResource.insert(watcher->property("identifier").toString(), capabilities.contains(QLatin1String("ANNOTATEMORE"))); } } @@ -76,7 +82,7 @@ void ImapResourceManager::slotCapabilities(QDBusPendingCallWatcher* watcher) void ImapResourceManager::init() { Q_FOREACH ( const Akonadi::AgentInstance &instance, Akonadi::AgentManager::self()->instances() ) { - const QString identifier = instance.type().identifier(); + const QString identifier = instance.identifier(); if (PimCommon::Util::isImapResource(identifier)) { searchCapabilities(identifier); } -- GitLab