Akonadi

server/notificationsubscriber.h
1/*
2 SPDX-FileCopyrightText: 2015 Daniel Vrátil <dvratil@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QByteArray>
10#include <QMimeDatabase>
11#include <QMutex>
12#include <QObject>
13
14#include "entities.h"
15#include "private/protocol_p.h"
16
17class QLocalSocket;
18
19namespace Akonadi
20{
21namespace Server
22{
24
25class NotificationSubscriber : public QObject
26{
28
29public:
30 explicit NotificationSubscriber(NotificationManager *manager, quintptr socketDescriptor);
31 ~NotificationSubscriber() override;
32
33 [[nodiscard]] inline QByteArray subscriber() const
34 {
35 return mSubscriber;
36 }
37
38 [[nodiscard]] QLocalSocket *socket() const
39 {
40 return mSocket;
41 }
42
43 void handleIncomingData();
44
45public Q_SLOTS:
46 bool notify(const Akonadi::Protocol::ChangeNotificationPtr &notification);
47
48private Q_SLOTS:
49 void socketDisconnected();
50
52 void notificationDebuggingChanged(bool enabled);
53
54protected:
55 void registerSubscriber(const Protocol::CreateSubscriptionCommand &command);
56 void modifySubscription(const Protocol::ModifySubscriptionCommand &command);
57 void disconnectSubscriber();
58
59private:
60 bool acceptsNotification(const Protocol::ChangeNotification &notification) const;
61 bool acceptsItemNotification(const Protocol::ItemChangeNotification &notification) const;
62 bool acceptsCollectionNotification(const Protocol::CollectionChangeNotification &notification) const;
63 bool acceptsTagNotification(const Protocol::TagChangeNotification &notification) const;
64 bool acceptsRelationNotification(const Protocol::RelationChangeNotification &notification) const;
65 bool acceptsSubscriptionNotification(const Protocol::SubscriptionChangeNotification &notification) const;
66 bool acceptsDebugChangeNotification(const Protocol::DebugChangeNotification &notification) const;
67
68 bool isCollectionMonitored(Entity::Id id) const;
69 bool isMimeTypeMonitored(const QString &mimeType) const;
70 bool isMoveDestinationResourceMonitored(const Protocol::ItemChangeNotification &msg) const;
71 bool isMoveDestinationResourceMonitored(const Protocol::CollectionChangeNotification &msg) const;
72
73 Protocol::SubscriptionChangeNotificationPtr toChangeNotification() const;
74
75protected Q_SLOTS:
76 virtual void writeNotification(const Akonadi::Protocol::ChangeNotificationPtr &notification);
77
78protected:
79 explicit NotificationSubscriber(NotificationManager *manager = nullptr);
80
81 void writeCommand(qint64 tag, const Protocol::CommandPtr &cmd);
82
83 mutable QMutex mLock;
84 NotificationManager *mManager = nullptr;
85 QLocalSocket *mSocket = nullptr;
86 QByteArray mSubscriber;
87 QSet<Entity::Id> mMonitoredCollections;
88 QSet<Entity::Id> mMonitoredItems;
89 QSet<Entity::Id> mMonitoredTags;
91 QSet<QString> mMonitoredMimeTypes;
92 QSet<QByteArray> mMonitoredResources;
93 QSet<QByteArray> mIgnoredSessions;
94 QByteArray mSession;
95 Protocol::ItemFetchScope mItemFetchScope;
96 Protocol::CollectionFetchScope mCollectionFetchScope;
97 Protocol::TagFetchScope mTagFetchScope;
98 bool mAllMonitored;
99 bool mExclusive;
100 bool mNotificationDebugging;
101};
102
103} // namespace Server
104} // namespace Akonadi
Helper integration between Akonadi and Qt.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:38 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.