Akonadi

notificationcollector.h
1 /*
2  Copyright (c) 2006 - 2007 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #ifndef AKONADI_NOTIFICATIONCOLLECTOR_H
8 #define AKONADI_NOTIFICATIONCOLLECTOR_H
9 
10 #include "entities.h"
11 
12 #include <private/protocol_p.h>
13 
14 #include <QByteArray>
15 #include <QList>
16 #include <QString>
17 
18 namespace Akonadi
19 {
20 namespace Server
21 {
22 
23 class DataStore;
24 class Connection;
25 class AkonadiServer;
26 
33 {
34 public:
39  explicit NotificationCollector(AkonadiServer &akonadi, DataStore *db);
40 
44  virtual ~NotificationCollector() = default;
45 
49  void setConnection(Connection *connection);
50 
56  void itemAdded(const PimItem &item, bool seen,
57  const Collection &collection = Collection(),
58  const QByteArray &resource = QByteArray());
59 
65  void itemChanged(const PimItem &item,
66  const QSet<QByteArray> &changedParts,
67  const Collection &collection = Collection(),
68  const QByteArray &resource = QByteArray());
69 
75  void itemsFlagsChanged(const PimItem::List &items,
76  const QSet<QByteArray> &addedFlags,
77  const QSet<QByteArray> &removedFlags,
78  const Collection &collection = Collection(),
79  const QByteArray &resource = QByteArray());
80 
84  void itemsTagsChanged(const PimItem::List &items,
85  const QSet<qint64> &addedTags,
86  const QSet<qint64> &removedTags,
87  const Collection &collection = Collection(),
88  const QByteArray &resource = QByteArray());
89 
93  void itemsRelationsChanged(const PimItem::List &items,
94  const Relation::List &addedRelations,
95  const Relation::List &removedRelations,
96  const Collection &collection = Collection(),
97  const QByteArray &resource = QByteArray());
98 
104  void itemsMoved(const PimItem::List &items, const Collection &collectionSrc = Collection(),
105  const Collection &collectionDest = Collection(),
106  const QByteArray &sourceResource = QByteArray());
107 
113  void itemsRemoved(const PimItem::List &items, const Collection &collection = Collection(),
114  const QByteArray &resource = QByteArray());
115 
119  void itemsLinked(const PimItem::List &items, const Collection &collection);
120 
124  void itemsUnlinked(const PimItem::List &items, const Collection &collection);
125 
131  void collectionAdded(const Collection &collection,
132  const QByteArray &resource = QByteArray());
133 
139  void collectionChanged(const Collection &collection,
140  const QList<QByteArray> &changes,
141  const QByteArray &resource = QByteArray());
142 
148  void collectionMoved(const Collection &collection,
149  const Collection &source,
150  const QByteArray &resource = QByteArray(),
151  const QByteArray &destResource = QByteArray());
152 
158  void collectionRemoved(const Collection &collection,
159  const QByteArray &resource = QByteArray());
160 
164  void collectionSubscribed(const Collection &collection,
165  const QByteArray &resource = QByteArray());
169  void collectionUnsubscribed(const Collection &collection,
170  const QByteArray &resource = QByteArray());
171 
175  void tagAdded(const Tag &tag);
176 
180  void tagChanged(const Tag &tag);
181 
185  void tagRemoved(const Tag &tag, const QByteArray &resource, const QString &remoteId);
186 
190  void relationAdded(const Relation &relation);
191 
195  void relationRemoved(const Relation &relation);
196 
203  bool dispatchNotifications();
204 
205 private:
206  void itemNotification(Protocol::ItemChangeNotification::Operation op,
207  const PimItem::List &items,
208  const Collection &collection,
209  const Collection &collectionDest,
210  const QByteArray &resource,
211  const QSet<QByteArray> &parts = QSet<QByteArray>(),
212  const QSet<QByteArray> &addedFlags = QSet<QByteArray>(),
213  const QSet<QByteArray> &removedFlags = QSet<QByteArray>(),
214  const QSet<qint64> &addedTags = QSet<qint64>(),
215  const QSet<qint64> &removedTags = QSet<qint64>(),
216  const Relation::List &addedRelations = Relation::List(),
217  const Relation::List &removedRelations = Relation::List());
218  void itemNotification(Protocol::ItemChangeNotification::Operation op,
219  const PimItem &item,
220  const Collection &collection,
221  const Collection &collectionDest,
222  const QByteArray &resource,
223  const QSet<QByteArray> &parts = QSet<QByteArray>());
224  void collectionNotification(Protocol::CollectionChangeNotification::Operation op,
225  const Collection &collection,
226  Collection::Id source, Collection::Id destination,
227  const QByteArray &resource,
228  const QSet<QByteArray> &changes = QSet<QByteArray>(),
229  const QByteArray &destResource = QByteArray());
230  void tagNotification(Protocol::TagChangeNotification::Operation op,
231  const Tag &tag,
232  const QByteArray &resource = QByteArray(),
233  const QString &remoteId = QString());
234  void relationNotification(Protocol::RelationChangeNotification::Operation op,
235  const Relation &relation);
236  void dispatchNotification(const Protocol::ChangeNotificationPtr &msg);
237  void clear();
238 
239  void completeNotification(const Protocol::ChangeNotificationPtr &msg);
240 
241 protected:
242  virtual void notify(Protocol::ChangeNotificationList &&ntfs);
243 
244 private:
245  Q_DISABLE_COPY_MOVE(NotificationCollector)
246 
247  DataStore *mDb;
248  Connection *mConnection = nullptr;
249  AkonadiServer &mAkonadi;
250  bool mIgnoreTransactions = false;
251 
252  Protocol::ChangeNotificationList mNotifications;
253 };
254 
255 } // namespace Server
256 } // namespace Akonadi
257 
258 #endif
void itemsRelationsChanged(const PimItem::List &items, const Relation::List &addedRelations, const Relation::List &removedRelations, const Collection &collection=Collection(), const QByteArray &resource=QByteArray())
Notify about changed items relations.
bool dispatchNotifications()
Trigger sending of collected notifications.
An Akonadi Relation.
Definition: relation.h:39
void collectionAdded(const Collection &collection, const QByteArray &resource=QByteArray())
Notify about a added collection.
void collectionChanged(const Collection &collection, const QList< QByteArray > &changes, const QByteArray &resource=QByteArray())
Notify about a changed collection.
void itemsFlagsChanged(const PimItem::List &items, const QSet< QByteArray > &addedFlags, const QSet< QByteArray > &removedFlags, const Collection &collection=Collection(), const QByteArray &resource=QByteArray())
Notify about changed items flags Provide as many parameters as you have at hand currently, everything that is missing will be looked up in the database later.
void itemsUnlinked(const PimItem::List &items, const Collection &collection)
Notify about unlinked items.
Represents a collection of PIM items.
Definition: collection.h:63
qint64 Id
Describes the unique id type.
Definition: collection.h:69
void itemsLinked(const PimItem::List &items, const Collection &collection)
Notify about linked items.
void tagChanged(const Tag &tag)
Notify about a changed tag.
void collectionMoved(const Collection &collection, const Collection &source, const QByteArray &resource=QByteArray(), const QByteArray &destResource=QByteArray())
Notify about a moved collection.
void itemAdded(const PimItem &item, bool seen, const Collection &collection=Collection(), const QByteArray &resource=QByteArray())
Notify about an added item.
void itemsMoved(const PimItem::List &items, const Collection &collectionSrc=Collection(), const Collection &collectionDest=Collection(), const QByteArray &sourceResource=QByteArray())
Notify about moved items Provide as many parameters as you have at hand currently, everything that is missing will be looked up in the database later.
void itemChanged(const PimItem &item, const QSet< QByteArray > &changedParts, const Collection &collection=Collection(), const QByteArray &resource=QByteArray())
Notify about a changed item.
void collectionUnsubscribed(const Collection &collection, const QByteArray &resource=QByteArray())
Notify about a collection unsubscription.
void itemsTagsChanged(const PimItem::List &items, const QSet< qint64 > &addedTags, const QSet< qint64 > &removedTags, const Collection &collection=Collection(), const QByteArray &resource=QByteArray())
Notify about changed items tags.
void relationAdded(const Relation &relation)
Notify about an added relation.
Part of the DataStore, collects change notifications and emits them after the current transaction has...
void tagAdded(const Tag &tag)
Notify about an added tag.
virtual ~NotificationCollector()=default
Destroys this notification collector.
void collectionRemoved(const Collection &collection, const QByteArray &resource=QByteArray())
Notify about a removed collection.
void relationRemoved(const Relation &relation)
Notify about a removed relation.
NotificationCollector(AkonadiServer &akonadi, DataStore *db)
Create a new notification collector for the given DataStore db.
void itemsRemoved(const PimItem::List &items, const Collection &collection=Collection(), const QByteArray &resource=QByteArray())
Notify about removed items.
void collectionSubscribed(const Collection &collection, const QByteArray &resource=QByteArray())
Notify about a collection subscription.
Helper integration between Akonadi and Qt.
An Akonadi Tag.
Definition: tag.h:26
void setConnection(Connection *connection)
Sets the connection that is causing the changes.
void tagRemoved(const Tag &tag, const QByteArray &resource, const QString &remoteId)
Notify about a removed tag.
This class handles all the database access.
Definition: datastore.h:95
An Connection represents one connection of a client to the server.
Definition: connection.h:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Jul 9 2020 23:15:23 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.