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 acceptsSubscriptionNotification(const Protocol::SubscriptionChangeNotification &notification) const;
65 bool acceptsDebugChangeNotification(const Protocol::DebugChangeNotification &notification) const;
66
67 bool isCollectionMonitored(Entity::Id id) const;
68 bool isMimeTypeMonitored(const QString &mimeType) const;
69 bool isMoveDestinationResourceMonitored(const Protocol::ItemChangeNotification &msg) const;
70 bool isMoveDestinationResourceMonitored(const Protocol::CollectionChangeNotification &msg) const;
71
72 Protocol::SubscriptionChangeNotificationPtr toChangeNotification() const;
73
74protected Q_SLOTS:
75 virtual void writeNotification(const Akonadi::Protocol::ChangeNotificationPtr &notification);
76
77protected:
78 explicit NotificationSubscriber(NotificationManager *manager = nullptr);
79
80 void writeCommand(qint64 tag, const Protocol::CommandPtr &cmd);
81
82 mutable QMutex mLock;
83 NotificationManager *mManager = nullptr;
84 QLocalSocket *mSocket = nullptr;
85 QByteArray mSubscriber;
86 QSet<Entity::Id> mMonitoredCollections;
87 QSet<Entity::Id> mMonitoredItems;
88 QSet<Entity::Id> mMonitoredTags;
90 QSet<QString> mMonitoredMimeTypes;
91 QSet<QByteArray> mMonitoredResources;
92 QSet<QByteArray> mIgnoredSessions;
93 QByteArray mSession;
94 Protocol::ItemFetchScope mItemFetchScope;
95 Protocol::CollectionFetchScope mCollectionFetchScope;
96 Protocol::TagFetchScope mTagFetchScope;
97 bool mAllMonitored;
98 bool mExclusive;
99 bool mNotificationDebugging;
100};
101
102} // namespace Server
103} // namespace Akonadi
Helper integration between Akonadi and Qt.
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.