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 | * @param id knotify-sid identifier of notification |
49 | * @param config notification data |
50 | * @param 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 | * @return 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 | * Do not use this variable. Use #popupServerCapabilities() instead. |
69 | * @see popupServerCapabilities |
70 | */ |
71 | QStringList ; |
72 | |
73 | /** |
74 | * In case we still don't know notification server capabilities, |
75 | * we need to query those first. That's done in an async way |
76 | * so we queue all notifications while waiting for the capabilities |
77 | * to return, then process them from this queue |
78 | */ |
79 | QList<QPair<KNotification *, KNotifyConfig>> ; |
80 | /** |
81 | * Whether the DBus notification daemon capability cache is up-to-date. |
82 | */ |
83 | bool ; |
84 | |
85 | /* |
86 | * As we communicate with the notification server over dbus |
87 | * we use only ids, this is for fast KNotifications lookup |
88 | */ |
89 | QHash<uint, QPointer<KNotification>> ; |
90 | |
91 | org::freedesktop::Notifications ; |
92 | |
93 | Q_DISABLE_COPY_MOVE() |
94 | }; |
95 | |
96 | #endif |
97 | |