20 #ifndef AKONADI_MONITOR_P_H
21 #define AKONADI_MONITOR_P_H
23 #include "akonadiprivate_export.h"
25 #include "collection.h"
26 #include "collectionstatisticsjob.h"
27 #include "collectionfetchscope.h"
29 #include "itemfetchscope.h"
31 #include <akonadi/private/notificationmessage_p.h>
32 #include "notificationsourceinterface.h"
33 #include "entitycache_p.h"
34 #include "servermanager.h"
35 #include "changenotificationdependenciesfactory_p.h"
37 #include <kmimetype.h>
39 #include <QtCore/QObject>
40 #include <QtCore/QTimer>
54 delete dependenciesFactory;
55 delete collectionCache;
63 QObject* notificationSource;
65 QSet<QByteArray> resources;
67 QSet<QString> mimetypes;
69 QList<QByteArray> sessions;
72 bool mFetchChangedOnly;
78 QQueue<NotificationMessage> pendingNotifications;
80 QQueue<NotificationMessage> pipeline;
88 bool fetchCollectionStatistics;
89 bool collectionMoveTranslationEnabled;
92 virtual void notificationsEnqueued(
int ) {}
93 virtual void notificationsErased() {}
96 virtual bool connectToNotificationManager();
97 bool acceptNotification(
const NotificationMessage &msg )
const;
98 void dispatchNotifications();
103 void cleanOldNotifications();
105 bool ensureDataAvailable(
const NotificationMessage &msg );
110 virtual bool emitNotification(
const NotificationMessage &msg );
111 void updatePendingStatistics(
const NotificationMessage &msg );
112 void invalidateCaches(
const NotificationMessage &msg );
117 void invalidateCache(
const Collection &col );
120 virtual int pipelineSize()
const;
123 void dataAvailable();
124 void slotSessionDestroyed( QObject* );
125 void slotStatisticsChangedFinished( KJob* );
126 void slotFlushRecentlyChangedCollections();
131 bool translateAndCompress( QQueue<NotificationMessage> ¬ificationQueue,
const NotificationMessage &msg );
133 virtual void slotNotify(
const NotificationMessage::List &msgs );
139 bool emitItemNotification(
const NotificationMessage &msg,
const Item &item = Item(),
145 bool emitCollectionNotification(
const NotificationMessage &msg,
const Collection &col =
Collection(),
153 void invalidateCollectionCache( qint64 collectionId );
158 void invalidateItemCache( qint64 itemId );
175 static const int MAXBUFFERSIZE = 10;
195 return m_buffer.contains(
id );
199 QQueue<Collection::Id> m_buffer;
203 QHash<Collection::Id, int> refCountMap;
210 QSet<Collection::Id> recentlyChangedCollections;
211 QTimer statisticsCompressionTimer;
216 bool isLazilyIgnored(
const NotificationMessage & msg )
const;
222 if ( collections.contains(
Collection( collection ) ) )
229 bool isMimeTypeMonitored(
const QString& mimetype )
const
231 if ( mimetypes.contains( mimetype ) )
234 KMimeType::Ptr mimeType = KMimeType::mimeType( mimetype, KMimeType::ResolveAliases );
235 if ( mimeType.isNull() )
238 foreach (
const QString &mt, mimetypes ) {
239 if ( mimeType->is( mt ) )
246 bool isMoveDestinationResourceMonitored(
const NotificationMessage &msg )
const
248 if ( msg.operation() != NotificationMessage::Move )
250 return resources.contains( msg.destinationResource() );
255 CollectionStatisticsJob *job =
new CollectionStatisticsJob( Collection( colId ), session );
256 QObject::connect( job, SIGNAL( result( KJob* ) ), q_ptr, SLOT( slotStatisticsChangedFinished( KJob* ) ) );
259 void notifyCollectionStatisticsWatchers(
Collection::Id collection,
const QByteArray &resource );
This class exists so that we can create a fake notification source in unit tests. ...
Specifies which parts of a collection should be fetched from the Akonadi storage. ...
Represents a collection of PIM items.
qint64 Id
Describes the unique id type.
static Collection root()
Returns the root collection.
A communication session with the Akonadi storage.
Specifies which parts of an item should be fetched from the Akonadi storage.
Monitors an item or collection for changes.
Class used to determine when to purge items in a Collection.
State
Enum for the various states the server can be in.
QList< Collection > List
Describes a list of collections.