Commit 0a45ce1d authored by Laurent Montel's avatar Laurent Montel 😁

Use imapresourcemanager

parent 2d8cec9b
......@@ -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;
......
......@@ -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;
};
......
......@@ -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)"<<identifier;
//By default makes it as true.
mImapResource.insert(identifier, true);
QDBusInterface iface(
QLatin1String( "org.freedesktop.Akonadi.Resource.")+ identifier,
QLatin1String( "/" ), QLatin1String( "org.kde.Akonadi.ImapResourceBase" ),
Akonadi::DBusConnectionPool::threadConnection(), this );
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*)));
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"<<capabilities<< " for identifier"<<watcher->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);
}
......
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