1 | /* |
2 | SPDX-FileCopyrightText: 2005-2006 Olivier Goffart <ogoffart at kde.org> |
3 | SPDX-FileCopyrightText: 2008 Dmitry Suzdalev <dimsuz@gmail.com> |
4 | SPDX-FileCopyrightText: 2014 Martin Klapetek <mklapetek@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
7 | */ |
8 | |
9 | #ifndef NOTIFYBYPOPUP_H |
10 | #define |
11 | |
12 | #include "knotificationplugin.h" |
13 | |
14 | #include "knotifyconfig.h" |
15 | #include <QStringList> |
16 | |
17 | #include "notifications_interface.h" |
18 | |
19 | class KNotification; |
20 | class QDBusPendingCallWatcher; |
21 | |
22 | class : public KNotificationPlugin |
23 | { |
24 | Q_OBJECT |
25 | public: |
26 | explicit (QObject *parent = nullptr); |
27 | () override; |
28 | |
29 | QString () override |
30 | { |
31 | return QStringLiteral("Popup" ); |
32 | } |
33 | void (KNotification *notification, const KNotifyConfig ¬ifyConfig) override; |
34 | void (KNotification *notification) override; |
35 | void (KNotification *notification, const KNotifyConfig ¬ifyConfig) override; |
36 | |
37 | private Q_SLOTS: |
38 | // slot which gets called when DBus signals that some notification action was invoked |
39 | void (uint notificationId, const QString &actionKey); |
40 | void (uint notificationId, const QString &xdgActionToken); |
41 | // slot which gets called when DBus signals that some notification was closed |
42 | void (uint, uint); |
43 | void (uint notificationId, const QString &text); |
44 | |
45 | private: |
46 | /* |
47 | * Sends notification to DBus "org.freedesktop.notifications" interface. |
48 | * id knotify-sid identifier of notification |
49 | * config notification data |
50 | * update If true, will request the DBus service to update |
51 | the notification with new data from \c notification |
52 | * Otherwise will put new notification on screen |
53 | * Returns true for success or false if there was an error. |
54 | */ |
55 | bool (KNotification *notification, const KNotifyConfig &config, bool update = false); |
56 | |
57 | /* |
58 | * Find the caption and the icon name of the application |
59 | */ |
60 | void getAppCaptionAndIconName(const KNotifyConfig &config, QString *appCaption, QString *iconName); |
61 | /* |
62 | * Query the dbus server for notification capabilities |
63 | */ |
64 | void (); |
65 | |
66 | /* |
67 | * DBus notification daemon capabilities cache. |
68 | */ |
69 | QStringList ; |
70 | |
71 | /*! |
72 | * In case we still don't know notification server capabilities, |
73 | * we need to query those first. That's done in an async way |
74 | * so we queue all notifications while waiting for the capabilities |
75 | * to return, then process them from this queue |
76 | */ |
77 | QList<QPair<KNotification *, KNotifyConfig>> ; |
78 | /* |
79 | * Whether the DBus notification daemon capability cache is up-to-date. |
80 | */ |
81 | bool ; |
82 | |
83 | /* |
84 | * As we communicate with the notification server over dbus |
85 | * we use only ids, this is for fast KNotifications lookup |
86 | */ |
87 | QHash<uint, QPointer<KNotification>> ; |
88 | |
89 | org::freedesktop::Notifications ; |
90 | |
91 | Q_DISABLE_COPY_MOVE() |
92 | }; |
93 | |
94 | #endif |
95 | |