Changeset View
Changeset View
Standalone View
Standalone View
akonadi/monitor_p.cpp
Show All 26 Lines | |||||
#include "itemfetchjob.h" | #include "itemfetchjob.h" | ||||
#include "notificationmessagev2_p.h" | #include "notificationmessagev2_p.h" | ||||
#include "notificationmanagerinterface.h" | #include "notificationmanagerinterface.h" | ||||
#include "session.h" | #include "session.h" | ||||
#include "changemediator_p.h" | #include "changemediator_p.h" | ||||
#include <kdebug.h> | #include <kdebug.h> | ||||
#include <kcomponentdata.h> | #include <kcomponentdata.h> | ||||
#include <qdbusextratypes.h> | |||||
using namespace Akonadi; | using namespace Akonadi; | ||||
static const int PipelineSize = 5; | static const int PipelineSize = 5; | ||||
MonitorPrivate::MonitorPrivate(ChangeNotificationDependenciesFactory *dependenciesFactory_, Monitor *parent) | MonitorPrivate::MonitorPrivate(ChangeNotificationDependenciesFactory *dependenciesFactory_, Monitor *parent) | ||||
: q_ptr(parent) | : q_ptr(parent) | ||||
, dependenciesFactory(dependenciesFactory_ ? dependenciesFactory_ : new ChangeNotificationDependenciesFactory) | , dependenciesFactory(dependenciesFactory_ ? dependenciesFactory_ : new ChangeNotificationDependenciesFactory) | ||||
, notificationSource(0) | , notificationSource(0) | ||||
, monitorAll(false) | , monitorAll(false) | ||||
, exclusive(false) | , exclusive(false) | ||||
, mFetchChangedOnly(false) | , mFetchChangedOnly(false) | ||||
, session(Session::defaultSession()) | , session(Session::defaultSession()) | ||||
, collectionCache(0) | , collectionCache(0) | ||||
, itemCache(0) | , itemCache(0) | ||||
, tagCache(0) | , tagCache(0) | ||||
, fetchCollection(false) | , fetchCollection(false) | ||||
, fetchCollectionStatistics(false) | , fetchCollectionStatistics(false) | ||||
, collectionMoveTranslationEnabled(true) | , collectionMoveTranslationEnabled(true) | ||||
, useRefCounting(false) | , useRefCounting(false) | ||||
{ | { | ||||
} | } | ||||
MonitorPrivate::~MonitorPrivate() { | |||||
unregisterNotificationSource(); | |||||
delete dependenciesFactory; | |||||
delete collectionCache; | |||||
delete itemCache; | |||||
} | |||||
void MonitorPrivate::unregisterNotificationSource() | |||||
{ | |||||
if (!notificationSource) { | |||||
return; | |||||
} | |||||
const QString &name = notificationSource->name(); | |||||
delete notificationSource; | |||||
notificationSource = 0; | |||||
if (!Akonadi::ServerManager::self()->isRunning()) { | |||||
return; | |||||
} | |||||
org::freedesktop::Akonadi::NotificationManager *manager = | |||||
new org::freedesktop::Akonadi::NotificationManager( | |||||
ServerManager::serviceName(Akonadi::ServerManager::Server), | |||||
QLatin1String("/notifications"), | |||||
DBusConnectionPool::threadConnection()); | |||||
if (!manager) { | |||||
return; | |||||
} | |||||
manager->unsubscribe(name); | |||||
} | |||||
void MonitorPrivate::init() | void MonitorPrivate::init() | ||||
{ | { | ||||
// needs to be at least 3x pipeline size for the collection move case | // needs to be at least 3x pipeline size for the collection move case | ||||
collectionCache = dependenciesFactory->createCollectionCache(3 * PipelineSize, session); | collectionCache = dependenciesFactory->createCollectionCache(3 * PipelineSize, session); | ||||
// needs to be at least 1x pipeline size | // needs to be at least 1x pipeline size | ||||
itemCache = dependenciesFactory->createItemListCache(PipelineSize, session); | itemCache = dependenciesFactory->createItemListCache(PipelineSize, session); | ||||
// 20 tags looks like a reasonable mount to keep around | // 20 tags looks like a reasonable mount to keep around | ||||
Show All 10 Lines | void MonitorPrivate::init() | ||||
statisticsCompressionTimer.setSingleShot(true); | statisticsCompressionTimer.setSingleShot(true); | ||||
statisticsCompressionTimer.setInterval(500); | statisticsCompressionTimer.setInterval(500); | ||||
QObject::connect(&statisticsCompressionTimer, SIGNAL(timeout()), q_ptr, SLOT(slotFlushRecentlyChangedCollections())); | QObject::connect(&statisticsCompressionTimer, SIGNAL(timeout()), q_ptr, SLOT(slotFlushRecentlyChangedCollections())); | ||||
} | } | ||||
bool MonitorPrivate::connectToNotificationManager() | bool MonitorPrivate::connectToNotificationManager() | ||||
{ | { | ||||
delete notificationSource; | unregisterNotificationSource(); | ||||
notificationSource = 0; | |||||
notificationSource = dependenciesFactory->createNotificationSource(q_ptr); | notificationSource = dependenciesFactory->createNotificationSource(q_ptr); | ||||
if (!notificationSource) { | if (!notificationSource) { | ||||
return false; | return false; | ||||
} | } | ||||
QObject::connect(notificationSource, SIGNAL(notifyV3(Akonadi::NotificationMessageV3::List)), | QObject::connect(notificationSource, SIGNAL(notifyV3(Akonadi::NotificationMessageV3::List)), | ||||
▲ Show 20 Lines • Show All 1,174 Lines • Show Last 20 Lines |