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 moved items
88 Provide as many parameters as you have at hand currently, everything
89 that is missing will be looked up in the database later.
90 */
91 void itemsMoved(const PimItem::List &items,
92 const Collection &collectionSrc = Collection(),
93 const Collection &collectionDest = Collection(),
94 const QByteArray &sourceResource = QByteArray());
95
96 /**
97 Notify about removed items.
98 Make sure you either provide all parameters or call this function before
99 actually removing the item from database.
100 */
101 void itemsRemoved(const PimItem::List &items, const Collection &collection = Collection(), const QByteArray &resource = QByteArray());
102
103 /**
104 * Notify about linked items
105 */
106 void itemsLinked(const PimItem::List &items, const Collection &collection);
107
108 /**
109 * Notify about unlinked items.
110 */
111 void itemsUnlinked(const PimItem::List &items, const Collection &collection);
112
113 /**
114 Notify about a added collection.
115 Provide as many parameters as you have at hand currently, everything
116 that is missing will be looked up in the database later.
117 */
118 void collectionAdded(const Collection &collection, const QByteArray &resource = QByteArray());
119
120 /**
121 Notify about a changed collection.
122 Provide as many parameters as you have at hand currently, everything
123 that is missing will be looked up in the database later.
124 */
125 void collectionChanged(const Collection &collection, const QList<QByteArray> &changes, const QByteArray &resource = QByteArray());
126
127 /**
128 Notify about a moved collection.
129 Provide as many parameters as you have at hand currently, everything
130 missing will be looked up on demand in the database later.
131 */
132 void collectionMoved(const Collection &collection,
133 const Collection &source,
134 const QByteArray &resource = QByteArray(),
135 const QByteArray &destResource = QByteArray());
136
137 /**
138 Notify about a removed collection.
139 Make sure you either provide all parameters or call this function before
140 actually removing the item from database.
141 */
142 void collectionRemoved(const Collection &collection, const QByteArray &resource = QByteArray());
143
144 /**
145 * Notify about a collection subscription.
146 */
147 void collectionSubscribed(const Collection &collection, const QByteArray &resource = QByteArray());
148 /**
149 * Notify about a collection unsubscription
150 */
151 void collectionUnsubscribed(const Collection &collection, const QByteArray &resource = QByteArray());
152
153 /**
154 Notify about an added tag.
155 */
156 void tagAdded(const Tag &tag);
157
158 /**
159 Notify about a changed tag.
160 */
161 void tagChanged(const Tag &tag);
162
163 /**
164 Notify about a removed tag.
165 */
166 void tagRemoved(const Tag &tag, const QByteArray &resource, const QString &remoteId);
167
168 /**
169 Trigger sending of collected notifications.
170
171 @returns Returns true when any notifications were dispatched, false if there
172 were no pending notifications.
173 */
175
176private:
177 void itemNotification(Protocol::ItemChangeNotification::Operation op,
178 const PimItem::List &items,
179 const Collection &collection,
180 const Collection &collectionDest,
181 const QByteArray &resource,
182 const QSet<QByteArray> &parts = QSet<QByteArray>(),
183 const QSet<QByteArray> &addedFlags = QSet<QByteArray>(),
184 const QSet<QByteArray> &removedFlags = QSet<QByteArray>(),
185 const QSet<qint64> &addedTags = QSet<qint64>(),
186 const QSet<qint64> &removedTags = QSet<qint64>());
187 void itemNotification(Protocol::ItemChangeNotification::Operation op,
188 const PimItem &item,
189 const Collection &collection,
190 const Collection &collectionDest,
191 const QByteArray &resource,
192 const QSet<QByteArray> &parts = QSet<QByteArray>());
193 void collectionNotification(Protocol::CollectionChangeNotification::Operation op,
194 const Collection &collection,
195 Collection::Id source,
196 Collection::Id destination,
197 const QByteArray &resource,
198 const QSet<QByteArray> &changes = QSet<QByteArray>(),
199 const QByteArray &destResource = QByteArray());
200 void tagNotification(Protocol::TagChangeNotification::Operation op,
201 const Tag &tag,
202 const QByteArray &resource = QByteArray(),
203 const QString &remoteId = QString());
204 void dispatchNotification(const Protocol::ChangeNotificationPtr &msg);
205 void clear();
206
207 void completeNotification(const Protocol::ChangeNotificationPtr &msg);
208
209protected:
210 virtual void notify(Protocol::ChangeNotificationList &&ntfs);
211
212private:
213 Q_DISABLE_COPY_MOVE(NotificationCollector)
214
215 DataStore *mDb;
216 Connection *mConnection = nullptr;
217 AkonadiServer &mAkonadi;
218 bool mIgnoreTransactions = false;
219
220 Protocol::ChangeNotificationList mNotifications;
221};
222
223} // namespace Server
224} // namespace Akonadi
Represents a collection of PIM items.
Definition collection.h:62
qint64 Id
Describes the unique id type.
Definition collection.h:79
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 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 itemsRemoved(const PimItem::List &items, const Collection &collection=Collection(), const QByteArray &resource=QByteArray())
Notify about removed items.
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 Mon Nov 4 2024 16:31:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.