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"
30 #include "tagfetchscope.h"
32 #include "entitycache_p.h"
33 #include "servermanager.h"
34 #include "changenotificationdependenciesfactory_p.h"
35 #include "notificationsource_p.h"
37 #include <akonadi/private/notificationmessagev3_p.h>
39 #include <kmimetype.h>
41 #include <QtCore/QObject>
42 #include <QtCore/QTimer>
56 delete dependenciesFactory;
57 delete collectionCache;
65 NotificationSource* notificationSource;
67 QSet<QByteArray> resources;
70 QSet<Monitor::Type> types;
71 QSet<QString> mimetypes;
73 QList<QByteArray> sessions;
77 bool mFetchChangedOnly;
80 ItemListCache *itemCache;
81 TagListCache *tagCache;
84 QQueue<NotificationMessageV3> pendingNotifications;
86 QQueue<NotificationMessageV3> pipeline;
94 bool fetchCollectionStatistics;
95 bool collectionMoveTranslationEnabled;
98 virtual void notificationsEnqueued(
int ) {}
99 virtual void notificationsErased() {}
102 virtual bool connectToNotificationManager();
103 bool acceptNotification(
const NotificationMessageV3 &msg )
const;
104 void dispatchNotifications();
105 void flushPipeline();
109 void cleanOldNotifications();
111 bool ensureDataAvailable(
const NotificationMessageV3 &msg );
117 virtual bool emitNotification(
const NotificationMessageV3 &msg );
118 void updatePendingStatistics(
const NotificationMessageV3 &msg );
119 void invalidateCaches(
const NotificationMessageV3 &msg );
124 void invalidateCache(
const Collection &col );
127 virtual int pipelineSize()
const;
130 void dataAvailable();
131 void slotSessionDestroyed( QObject* );
132 void slotStatisticsChangedFinished( KJob* );
133 void slotFlushRecentlyChangedCollections();
138 int translateAndCompress( QQueue<NotificationMessageV3> ¬ificationQueue,
const NotificationMessageV3 &msg );
140 virtual void slotNotify(
const NotificationMessageV3::List &msgs );
146 bool emitItemsNotification(
const NotificationMessageV3 &msg,
const Item::List &items = Item::List(),
152 bool emitCollectionNotification(
const NotificationMessageV3 &msg,
const Collection &col =
Collection(),
155 bool emitTagsNotification(
const NotificationMessageV3 &msg,
const Tag::List &tags );
162 void invalidateCollectionCache( qint64 collectionId );
167 void invalidateItemCache( qint64 itemId );
172 void invalidateTagCache( qint64 tagId );
189 static const int MAXBUFFERSIZE = 10;
209 return m_buffer.contains(
id );
212 static int buffersize();
215 QQueue<Collection::Id> m_buffer;
218 QHash<Collection::Id, int> refCountMap;
236 QSet<Collection::Id> recentlyChangedCollections;
237 QTimer statisticsCompressionTimer;
242 bool isLazilyIgnored(
const NotificationMessageV3 & msg,
bool allowModifyFlagsConversion =
false )
const;
249 void checkBatchSupport(
const NotificationMessageV3 &msg,
bool &needsSplit,
bool &batchSupported )
const;
251 NotificationMessageV3::List splitMessage(
const NotificationMessageV3 &msg,
bool legacy )
const;
257 if ( collections.contains(
Collection( collection ) ) )
264 bool isMimeTypeMonitored(
const QString& mimetype )
const
266 if ( mimetypes.contains( mimetype ) )
269 KMimeType::Ptr mimeType = KMimeType::mimeType( mimetype, KMimeType::ResolveAliases );
270 if ( mimeType.isNull() )
273 foreach (
const QString &mt, mimetypes ) {
274 if ( mimeType->is( mt ) )
281 bool isMoveDestinationResourceMonitored(
const NotificationMessageV3 &msg )
const
283 if ( msg.operation() != NotificationMessageV2::Move )
285 return resources.contains( msg.destinationResource() );
290 CollectionStatisticsJob *job =
new CollectionStatisticsJob( Collection( colId ), session );
291 QObject::connect( job, SIGNAL( result( KJob* ) ), q_ptr, SLOT( slotStatisticsChangedFinished( KJob* ) ) );
294 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. ...
Specifies which parts of a tag 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.