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

Use imapresourcemanager

parent 2d8cec9b
...@@ -114,6 +114,7 @@ using KMail::MailServiceImpl; ...@@ -114,6 +114,7 @@ using KMail::MailServiceImpl;
#include "foldercollectionmonitor.h" #include "foldercollectionmonitor.h"
#include "imapresourcesettings.h" #include "imapresourcesettings.h"
#include "util.h" #include "util.h"
#include "pimcommon/util/imapresourcemanager.h"
#include "mailcommon/kernel/mailkernel.h" #include "mailcommon/kernel/mailkernel.h"
#include "searchdialog/searchdescriptionattribute.h" #include "searchdialog/searchdescriptionattribute.h"
...@@ -143,6 +144,7 @@ KMKernel::KMKernel (QObject *parent) : ...@@ -143,6 +144,7 @@ KMKernel::KMKernel (QObject *parent) :
KMail::Util::migrateFromKMail1(); KMail::Util::migrateFromKMail1();
kDebug() << "Starting up..."; kDebug() << "Starting up...";
mImapResourceManager = new PimCommon::ImapResourceManager(this);
mySelf = this; mySelf = this;
the_firstInstance = true; the_firstInstance = true;
...@@ -2082,6 +2084,11 @@ PimCommon::StorageServiceManager *KMKernel::storageServiceManager() const ...@@ -2082,6 +2084,11 @@ PimCommon::StorageServiceManager *KMKernel::storageServiceManager() const
return mStorageManager; return mStorageManager;
} }
PimCommon::ImapResourceManager *KMKernel::imapResourceManager() const
{
return mImapResourceManager;
}
bool KMKernel::allowToDebugBalooSupport() const bool KMKernel::allowToDebugBalooSupport() const
{ {
return mDebugBaloo; return mDebugBaloo;
......
...@@ -44,6 +44,7 @@ class MessageSender; ...@@ -44,6 +44,7 @@ class MessageSender;
namespace PimCommon { namespace PimCommon {
class AutoCorrection; class AutoCorrection;
class StorageServiceManager; class StorageServiceManager;
class ImapResourceManager;
} }
/** The KMail namespace contains classes used for KMail. /** The KMail namespace contains classes used for KMail.
...@@ -426,6 +427,7 @@ public: ...@@ -426,6 +427,7 @@ public:
void toggleSystemTray(); void toggleSystemTray();
FolderArchiveManager *folderArchiveManager() const; FolderArchiveManager *folderArchiveManager() const;
PimCommon::StorageServiceManager *storageServiceManager() const; PimCommon::StorageServiceManager *storageServiceManager() const;
PimCommon::ImapResourceManager *imapResourceManager() const;
bool allowToDebugBalooSupport() const; bool allowToDebugBalooSupport() const;
...@@ -533,6 +535,7 @@ private: ...@@ -533,6 +535,7 @@ private:
PimCommon::AutoCorrection *mAutoCorrection; PimCommon::AutoCorrection *mAutoCorrection;
FolderArchiveManager *mFolderArchiveManager; FolderArchiveManager *mFolderArchiveManager;
PimCommon::StorageServiceManager *mStorageManager; PimCommon::StorageServiceManager *mStorageManager;
PimCommon::ImapResourceManager *mImapResourceManager;
bool mDebugBaloo; bool mDebugBaloo;
}; };
......
...@@ -38,26 +38,31 @@ ImapResourceManager::~ImapResourceManager() ...@@ -38,26 +38,31 @@ ImapResourceManager::~ImapResourceManager()
void ImapResourceManager::slotInstanceAdded(const Akonadi::AgentInstance &instance) void ImapResourceManager::slotInstanceAdded(const Akonadi::AgentInstance &instance)
{ {
searchCapabilities(instance.type().identifier()); searchCapabilities(instance.identifier());
} }
void ImapResourceManager::slotInstanceRemoved(const Akonadi::AgentInstance &instance) void ImapResourceManager::slotInstanceRemoved(const Akonadi::AgentInstance &instance)
{ {
mImapResource.remove(instance.type().identifier()); mImapResource.remove(instance.identifier());
} }
void ImapResourceManager::searchCapabilities(const QString &identifier) void ImapResourceManager::searchCapabilities(const QString &identifier)
{ {
qDebug()<<" void ImapResourceManager::searchCapabilities(const QString &identifier)"<<identifier;
//By default makes it as true. //By default makes it as true.
mImapResource.insert(identifier, true); mImapResource.insert(identifier, true);
QDBusInterface iface( QDBusInterface iface(
QLatin1String( "org.freedesktop.Akonadi.Resource.")+ identifier, QLatin1String( "org.freedesktop.Akonadi.Resource.")+ identifier,
QLatin1String( "/" ), QLatin1String( "org.kde.Akonadi.ImapResourceBase" ), QLatin1String( "/" ), QLatin1String( "org.kde.Akonadi.ImapResourceBase" ),
Akonadi::DBusConnectionPool::threadConnection(), this ); Akonadi::DBusConnectionPool::threadConnection(), this );
QDBusPendingCall call = iface.asyncCall( QLatin1String( "serverCapabilities" ) ); if (iface.isValid()) {
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); QDBusPendingCall call = iface.asyncCall( QLatin1String( "serverCapabilities" ) );
watcher->setProperty("identifier", identifier); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(slotCapabilities(QDBusPendingCallWatcher*))); watcher->setProperty("identifier", identifier);
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(slotCapabilities(QDBusPendingCallWatcher*)));
} else {
qDebug() << "interface not valid";
}
} }
void ImapResourceManager::slotCapabilities(QDBusPendingCallWatcher* watcher) void ImapResourceManager::slotCapabilities(QDBusPendingCallWatcher* watcher)
...@@ -66,6 +71,7 @@ void ImapResourceManager::slotCapabilities(QDBusPendingCallWatcher* watcher) ...@@ -66,6 +71,7 @@ void ImapResourceManager::slotCapabilities(QDBusPendingCallWatcher* watcher)
if ( reply.isValid() ) { if ( reply.isValid() ) {
if (watcher->property("identifier").isValid()) { if (watcher->property("identifier").isValid()) {
const QStringList capabilities = reply.value(); const QStringList capabilities = reply.value();
qDebug()<<" capabilities"<<capabilities<< " for identifier"<<watcher->property("identifier").toString();
mImapResource.insert(watcher->property("identifier").toString(), capabilities.contains(QLatin1String("ANNOTATEMORE"))); mImapResource.insert(watcher->property("identifier").toString(), capabilities.contains(QLatin1String("ANNOTATEMORE")));
} }
} }
...@@ -76,7 +82,7 @@ void ImapResourceManager::slotCapabilities(QDBusPendingCallWatcher* watcher) ...@@ -76,7 +82,7 @@ void ImapResourceManager::slotCapabilities(QDBusPendingCallWatcher* watcher)
void ImapResourceManager::init() void ImapResourceManager::init()
{ {
Q_FOREACH ( const Akonadi::AgentInstance &instance, Akonadi::AgentManager::self()->instances() ) { 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)) { if (PimCommon::Util::isImapResource(identifier)) {
searchCapabilities(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