Akonadi

notificationcollector.h
1/*
2 SPDX-FileCopyrightText: 2006-2007 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "entities.h"
10
11#include "private/protocol_p.h"
12
13#include <QByteArray>
14#include <QList>
15#include <QString>
16
17namespace Akonadi
18{
19namespace Server
20{
21class DataStore;
22class Connection;
23class AkonadiServer;
24
25/**
26 Part of the DataStore, collects change notifications and emits
27 them after the current transaction has been successfully committed.
28 Where possible, notifications are compressed.
29*/
31{
32public:
33 /**
34 Create a new notification collector for the given DataStore @p db.
35 @param db The datastore using this notification collector.
36 */
37 explicit NotificationCollector(AkonadiServer &akonadi, DataStore *db);
38
39 /**
40 Destroys this notification collector.
41 */
42 virtual ~NotificationCollector() = default;
43
44 /**
45 * Sets the connection that is causing the changes.
46 */
47 void setConnection(Connection *connection);
48
49 /**
50 Notify about an added item.
51 Provide as many parameters as you have at hand currently, everything
52 that is missing will be looked up in the database later.
53 */
54 void itemAdded(const PimItem &item, bool seen, const Collection &collection = Collection(), const QByteArray &resource = QByteArray());
55
56 /**
57 Notify about a changed item.
58 Provide as many parameters as you have at hand currently, everything
59 that is missing will be looked up in the database later.
60 */
61 void itemChanged(const PimItem &item,
62 const QSet<QByteArray> &changedParts,
63 const Collection &collection = Collection(),
64 const QByteArray &resource = QByteArray());
65
66 /**
67 Notify about changed items flags
68 Provide as many parameters as you have at hand currently, everything
69 that is missing will be looked up in the database later.
70 */
71 void itemsFlagsChanged(const PimItem::List &items,
72 const QSet<QByteArray> &addedFlags,
73 const QSet<QByteArray> &removedFlags,
74 const Collection &collection = Collection(),
75 const QByteArray &resource = QByteArray());
76
77 /**
78 Notify about changed items tags
79 **/
80 void itemsTagsChanged(const PimItem::List &items,
81 const QSet<qint64> &addedTags,
82 const QSet<qint64> &removedTags,
83 const Collection &collection = Collection(),
84 const QByteArray &resource = QByteArray());
85
86 /**
87 Notify about changed items relations
88 **/
89 void itemsRelationsChanged(const PimItem::List &items,
90 const Relation::List &addedRelations,
91 const Relation::List &removedRelations,
92 const Collection &collection = Collection(),
93 const QByteArray &resource = QByteArray());
94
95 /**
96 Notify about moved items
97 Provide as many parameters as you have at hand currently, everything
98 that is missing will be looked up in the database later.
99 */
100 void itemsMoved(const PimItem::List &items,
101 const Collection &collectionSrc = Collection(),
102 const Collection &collectionDest = Collection(),
103 const QByteArray &sourceResource = QByteArray());
104
105 /**
106 Notify about removed items.
107 Make sure you either provide all parameters or call this function before
108 actually removing the item from database.
109 */
110 void itemsRemoved(const PimItem::List &items, const Collection &collection = Collection(), const QByteArray &resource = QByteArray());
111
112 /**
113 * Notify about linked items
114 */
115 void itemsLinked(const PimItem::List &items, const Collection &collection);
116
117 /**
118 * Notify about unlinked items.
119 */
120 void itemsUnlinked(const PimItem::List &items, const Collection &collection);
121
122 /**
123 Notify about a added collection.
124 Provide as many parameters as you have at hand currently, everything
125 that is missing will be looked up in the database later.
126 */
127 void collectionAdded(const Collection &collection, const QByteArray &resource = QByteArray());
128
129 /**
130 Notify about a changed collection.
131 Provide as many parameters as you have at hand currently, everything
132 that is missing will be looked up in the database later.
133 */
134 void collectionChanged(const Collection &collection, const QList<QByteArray> &changes, const QByteArray &resource = QByteArray());
135
136 /**
137 Notify about a moved collection.
138 Provide as many parameters as you have at hand currently, everything
139 missing will be looked up on demand in the database later.
140 */
141 void collectionMoved(const Collection &collection,
142 const Collection &source,
143 const QByteArray &resource = QByteArray(),
144 const QByteArray &destResource = QByteArray());
145
146 /**
147 Notify about a removed collection.
148 Make sure you either provide all parameters or call this function before
149 actually removing the item from database.
150 */
151 void collectionRemoved(const Collection &collection, const QByteArray &resource = QByteArray());
152
153 /**
154 * Notify about a collection subscription.
155 */
156 void collectionSubscribed(const Collection &collection, const QByteArray &resource = QByteArray());
157 /**
158 * Notify about a collection unsubscription
159 */
160 void collectionUnsubscribed(const Collection &collection, const QByteArray &resource = QByteArray());
161
162 /**
163 Notify about an added tag.
164 */
165 void tagAdded(const Tag &tag);
166
167 /**
168 Notify about a changed tag.
169 */
170 void tagChanged(const Tag &tag);
171
172 /**
173 Notify about a removed tag.
174 */
175 void tagRemoved(const Tag &tag, const QByteArray &resource, const QString &remoteId);
176
177 /**
178 Notify about an added relation.
179 */
180 void relationAdded(const Relation &relation);
181
182 /**
183 Notify about a removed relation.
184 */
185 void relationRemoved(const Relation &relation);
186
187 /**
188 Trigger sending of collected notifications.
189
190 @returns Returns true when any notifications were dispatched, false if there
191 were no pending notifications.
192 */
194
195private:
196 void itemNotification(Protocol::ItemChangeNotification::Operation op,
197 const PimItem::List &items,
198 const Collection &collection,
199 const Collection &collectionDest,
200 const QByteArray &resource,
201 const QSet<QByteArray> &parts = QSet<QByteArray>(),
202 const QSet<QByteArray> &addedFlags = QSet<QByteArray>(),
203 const QSet<QByteArray> &removedFlags = QSet<QByteArray>(),
204 const QSet<qint64> &addedTags = QSet<qint64>(),
205 const QSet<qint64> &removedTags = QSet<qint64>(),
206 const Relation::List &addedRelations = Relation::List(),
207 const Relation::List &removedRelations = Relation::List());
208 void itemNotification(Protocol::ItemChangeNotification::Operation op,
209 const PimItem &item,
210 const Collection &collection,
211 const Collection &collectionDest,
212 const QByteArray &resource,
213 const QSet<QByteArray> &parts = QSet<QByteArray>());
214 void collectionNotification(Protocol::CollectionChangeNotification::Operation op,
215 const Collection &collection,
216 Collection::Id source,
217 Collection::Id destination,
218 const QByteArray &resource,
219 const QSet<QByteArray> &changes = QSet<QByteArray>(),
220 const QByteArray &destResource = QByteArray());
221 void tagNotification(Protocol::TagChangeNotification::Operation op,
222 const Tag &tag,
223 const QByteArray &resource = QByteArray(),
224 const QString &remoteId = QString());
225 void relationNotification(Protocol::RelationChangeNotification::Operation op, const Relation &relation);
226 void dispatchNotification(const Protocol::ChangeNotificationPtr &msg);
227 void clear();
228
229 void completeNotification(const Protocol::ChangeNotificationPtr &msg);
230
231protected:
232 virtual void notify(Protocol::ChangeNotificationList &&ntfs);
233
234private:
235 Q_DISABLE_COPY_MOVE(NotificationCollector)
236
237 DataStore *mDb;
238 Connection *mConnection = nullptr;
239 AkonadiServer &mAkonadi;
240 bool mIgnoreTransactions = false;
241
242 Protocol::ChangeNotificationList mNotifications;
243};
244
245} // namespace Server
246} // namespace Akonadi
Represents a collection of PIM items.
Definition collection.h:62
qint64 Id
Describes the unique id type.
Definition collection.h:79
An Akonadi Relation.
Definition relation.h:41
An Connection represents one connection of a client to the server.
Definition connection.h:39
This class handles all the database access.
Definition datastore.h:95
Part of the DataStore, collects change notifications and emits them after the current transaction has...
void collectionRemoved(const Collection &collection, const QByteArray &resource=QByteArray())
Notify about a removed collection.
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,...
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.
void tagRemoved(const Tag &tag, const QByteArray &resource, const QString &remoteId)
Notify about a removed tag.
void itemsUnlinked(const PimItem::List &items, const Collection &collection)
Notify about unlinked items.
void collectionMoved(const Collection &collection, const Collection &source, const QByteArray &resource=QByteArray(), const QByteArray &destResource=QByteArray())
Notify about a moved collection.
void tagAdded(const Tag &tag)
Notify about an added tag.
void tagChanged(const Tag &tag)
Notify about a changed tag.
bool dispatchNotifications()
Trigger sending of collected notifications.
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.
NotificationCollector(AkonadiServer &akonadi, DataStore *db)
Create a new notification collector for the given DataStore db.
void collectionChanged(const Collection &collection, const QList< QByteArray > &changes, const QByteArray &resource=QByteArray())
Notify about a changed collection.
void setConnection(Connection *connection)
Sets the connection that is causing the changes.
void itemsLinked(const PimItem::List &items, const Collection &collection)
Notify about linked items.
void relationRemoved(const Relation &relation)
Notify about a removed relation.
void itemsRemoved(const PimItem::List &items, const Collection &collection=Collection(), const QByteArray &resource=QByteArray())
Notify about removed items.
void relationAdded(const Relation &relation)
Notify about an added relation.
virtual ~NotificationCollector()=default
Destroys this notification collector.
void collectionUnsubscribed(const Collection &collection, const QByteArray &resource=QByteArray())
Notify about a collection unsubscription.
void collectionAdded(const Collection &collection, const QByteArray &resource=QByteArray())
Notify about a added 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,...
void itemChanged(const PimItem &item, const QSet< QByteArray > &changedParts, const Collection &collection=Collection(), const QByteArray &resource=QByteArray())
Notify about a changed item.
void collectionSubscribed(const Collection &collection, const QByteArray &resource=QByteArray())
Notify about a collection subscription.
void itemAdded(const PimItem &item, bool seen, const Collection &collection=Collection(), const QByteArray &resource=QByteArray())
Notify about an added item.
An Akonadi Tag.
Definition tag.h:26
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:51:45 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.