Changeset View
Changeset View
Standalone View
Standalone View
dataengines/notifications/notificationsengine.h
Show All 19 Lines | |||||
20 | 20 | | |||
21 | #ifndef NOTIFICATIONSENGINE_H | 21 | #ifndef NOTIFICATIONSENGINE_H | ||
22 | #define NOTIFICATIONSENGINE_H | 22 | #define NOTIFICATIONSENGINE_H | ||
23 | 23 | | |||
24 | #include <Plasma/DataEngine> | 24 | #include <Plasma/DataEngine> | ||
25 | #include <QSet> | 25 | #include <QSet> | ||
26 | #include <QHash> | 26 | #include <QHash> | ||
27 | 27 | | |||
28 | namespace NotificationManager | ||||
29 | { | ||||
30 | class Notification; | ||||
31 | } | ||||
32 | | ||||
28 | struct NotificationInhibiton | 33 | struct NotificationInhibiton | ||
29 | { | 34 | { | ||
30 | QString hint; | 35 | QString hint; | ||
31 | QString value; | 36 | QString value; | ||
32 | }; | 37 | }; | ||
33 | 38 | | |||
34 | typedef QSharedPointer<NotificationInhibiton> NotificationInhibitonPtr; | 39 | typedef QSharedPointer<NotificationInhibiton> NotificationInhibitonPtr; | ||
35 | 40 | | |||
Show All 12 Lines | 49 | public: | |||
48 | virtual void init(); | 53 | virtual void init(); | ||
49 | 54 | | |||
50 | /** | 55 | /** | ||
51 | * This function implements part of Notifications DBus interface. | 56 | * This function implements part of Notifications DBus interface. | ||
52 | * Once called, will add notification source to the engine | 57 | * Once called, will add notification source to the engine | ||
53 | */ | 58 | */ | ||
54 | uint Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int timeout); | 59 | uint Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int timeout); | ||
55 | 60 | | |||
56 | void CloseNotification( uint id ); | | |||
57 | | ||||
58 | Plasma::Service* serviceForSource(const QString& source) override; | 61 | Plasma::Service* serviceForSource(const QString& source) override; | ||
59 | 62 | | |||
60 | QStringList GetCapabilities(); | | |||
61 | | ||||
62 | QString GetServerInformation(QString& vendor, QString& version, QString& specVersion); | | |||
63 | | ||||
64 | int createNotification(const QString &appName, const QString &appIcon, const QString &summary, | 63 | int createNotification(const QString &appName, const QString &appIcon, const QString &summary, | ||
65 | const QString &body, int timeout, const QStringList &actions, const QVariantMap &hints); | 64 | const QString &body, int timeout, const QStringList &actions, const QVariantMap &hints); | ||
66 | 65 | | |||
67 | void configureNotification(const QString &appName, const QString &eventId = QString()); | 66 | void configureNotification(const QString &appName, const QString &eventId = QString()); | ||
68 | 67 | | |||
69 | /* | 68 | /* | ||
70 | * Block all notification where a given notification hint matches a given value. | 69 | * Block all notification where a given notification hint matches a given value. | ||
71 | * | 70 | * | ||
72 | * Inhibition is dropped when dereferenced. | 71 | * Inhibition is dropped when dereferenced. | ||
73 | */ | 72 | */ | ||
74 | NotificationInhibitonPtr createInhibition(const QString &hint, const QString &value); | 73 | NotificationInhibitonPtr createInhibition(const QString &hint, const QString &value); | ||
75 | 74 | | |||
76 | public Q_SLOTS: | 75 | public Q_SLOTS: | ||
77 | void removeNotification(uint id, uint closeReason); | 76 | void removeNotification(uint id, uint closeReason); | ||
78 | bool registerDBusService(); | | |||
79 | | ||||
80 | void onBroadcastNotification(const QMap<QString, QVariant> &properties); | | |||
81 | | ||||
82 | Q_SIGNALS: | | |||
83 | void NotificationClosed( uint id, uint reason ); | | |||
84 | void ActionInvoked( uint id, const QString& actionKey ); | | |||
85 | 77 | | |||
86 | private: | 78 | private: | ||
87 | /** | 79 | void notificationAdded(const NotificationManager::Notification ¬ification); | ||
88 | * Holds the id that will be assigned to the next notification source | | |||
89 | * that will be created | | |||
90 | */ | | |||
91 | uint m_nextId; | | |||
92 | 80 | | |||
93 | QHash<QString, QString> m_activeNotifications; | 81 | QHash<QString, QString> m_activeNotifications; | ||
94 | 82 | | |||
95 | QHash<QString, bool> m_configurableApplications; | | |||
96 | | ||||
97 | /** | | |||
98 | * A "blacklist" of apps for which always the previous notification from this app | | |||
99 | * is replaced by the newer one. This is the case for eg. media players | | |||
100 | * as we simply want to update the notification, not get spammed by tens | | |||
101 | * of notifications for quickly changing songs in playlist | | |||
102 | */ | | |||
103 | QSet<QString> m_alwaysReplaceAppsList; | | |||
104 | /** | | |||
105 | * This holds the notifications sent from apps from the list above | | |||
106 | * for fast lookup | | |||
107 | */ | | |||
108 | QHash<QString, uint> m_notificationsFromReplaceableApp; | | |||
109 | | ||||
110 | QList<NotificationInhibiton*> m_inhibitions; | 83 | QList<NotificationInhibiton*> m_inhibitions; | ||
111 | 84 | | |||
112 | friend class NotificationAction; | 85 | friend class NotificationAction; | ||
113 | }; | 86 | }; | ||
114 | 87 | | |||
115 | Q_DECLARE_METATYPE(NotificationInhibitonPtr); | 88 | Q_DECLARE_METATYPE(NotificationInhibitonPtr); | ||
116 | 89 | | |||
117 | #endif | 90 | #endif |