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/notificationmessagev2_p.h>
32 #include "entitycache_p.h"
33 #include "servermanager.h"
34 #include "changenotificationdependenciesfactory_p.h"
35 #include "notificationsource_p.h"
37 #include <kmimetype.h>
39 #include <QtCore/QObject>
40 #include <QtCore/QTimer>
54 delete dependenciesFactory;
55 delete collectionCache;
63 NotificationSource* notificationSource;
65 QSet<QByteArray> resources;
67 QSet<QString> mimetypes;
69 QList<QByteArray> sessions;
72 bool mFetchChangedOnly;
75 ItemListCache *itemCache;
78 QQueue<NotificationMessageV2> pendingNotifications;
80 QQueue<NotificationMessageV2> pipeline;
88 bool fetchCollectionStatistics;
89 bool collectionMoveTranslationEnabled;
92 virtual void notificationsEnqueued(
int ) {}
93 virtual void notificationsErased() {}
96 virtual bool connectToNotificationManager();
97 bool acceptNotification(
const NotificationMessageV2 &msg )
const;
98 void dispatchNotifications();
103 void cleanOldNotifications();
105 bool ensureDataAvailable(
const NotificationMessageV2 &msg );
111 virtual bool emitNotification(
const NotificationMessageV2 &msg );
112 void updatePendingStatistics(
const NotificationMessageV2 &msg );
113 void invalidateCaches(
const NotificationMessageV2 &msg );
118 void invalidateCache(
const Collection &col );
121 virtual int pipelineSize()
const;
124 void dataAvailable();
125 void slotSessionDestroyed( QObject* );
126 void slotStatisticsChangedFinished( KJob* );
127 void slotFlushRecentlyChangedCollections();
132 int translateAndCompress( QQueue<NotificationMessageV2> ¬ificationQueue,
const NotificationMessageV2 &msg );
134 virtual void slotNotify(
const NotificationMessageV2::List &msgs );
140 bool emitItemsNotification(
const NotificationMessageV2 &msg,
const Item::List &items = Item::List(),
146 bool emitCollectionNotification(
const NotificationMessageV2 &msg,
const Collection &col =
Collection(),
154 void invalidateCollectionCache( qint64 collectionId );
159 void invalidateItemCache( qint64 itemId );
176 static const int MAXBUFFERSIZE = 10;
196 return m_buffer.contains(
id );
199 static int buffersize();
202 QQueue<Collection::Id> m_buffer;
205 QHash<Collection::Id, int> refCountMap;
223 QSet<Collection::Id> recentlyChangedCollections;
224 QTimer statisticsCompressionTimer;
229 bool isLazilyIgnored(
const NotificationMessageV2 & msg,
bool allowModifyFlagsConversion =
false )
const;
236 void checkBatchSupport(
const NotificationMessageV2 &msg,
bool &needsSplit,
bool &batchSupported )
const;
238 NotificationMessageV2::List splitMessage(
const NotificationMessageV2 &msg,
bool legacy )
const;
244 if ( collections.contains(
Collection( collection ) ) )
251 bool isMimeTypeMonitored(
const QString& mimetype )
const
253 if ( mimetypes.contains( mimetype ) )
256 KMimeType::Ptr mimeType = KMimeType::mimeType( mimetype, KMimeType::ResolveAliases );
257 if ( mimeType.isNull() )
260 foreach (
const QString &mt, mimetypes ) {
261 if ( mimeType->is( mt ) )
268 bool isMoveDestinationResourceMonitored(
const NotificationMessageV2 &msg )
const
270 if ( msg.operation() != NotificationMessageV2::Move )
272 return resources.contains( msg.destinationResource() );
277 CollectionStatisticsJob *job =
new CollectionStatisticsJob( Collection( colId ), session );
278 QObject::connect( job, SIGNAL( result( KJob* ) ), q_ptr, SLOT( slotStatisticsChangedFinished( KJob* ) ) );
281 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.