From 8dc9a1295b7c1a5f81c55244b5d2bb3a3bddb30b Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 13 Dec 2015 02:14:50 +0100 Subject: Separate NotificationMonitorPrivate into its own file --- notificationmonitor_p.h | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 notificationmonitor_p.h (limited to 'notificationmonitor_p.h') diff --git a/notificationmonitor_p.h b/notificationmonitor_p.h new file mode 100644 index 0000000..069abc4 --- /dev/null +++ b/notificationmonitor_p.h @@ -0,0 +1,85 @@ +#ifndef WATCHFISH_NOTIFICATIONMONITOR_P_H +#define WATCHFISH_NOTIFICATIONMONITOR_P_H + +#include +#include + +#include "notificationmonitor.h" + +#define CATEGORY_DEFINITION_FILE_DIRECTORY "/usr/share/lipstick/notificationcategories" +#define CATEGORY_REFRESH_CHECK_TIME 120 + +namespace watchfish +{ + +struct NotificationCategoryCacheEntry +{ + QHash data; + QDateTime lastReadTime; + QDateTime lastCheckTime; +}; + +struct ProtoNotification +{ + QString sender; + QString appIcon; + QString summary; + QString body; + QHash hints; + int expireTimeout; + QStringList actions; +}; + +class NotificationMonitorPrivate : public QObject +{ + Q_OBJECT + +public: + NotificationMonitorPrivate(NotificationMonitor *q); + ~NotificationMonitorPrivate(); + +private: + /** Converts a ProtoNotification into a Notification object and raises it. */ + void processIncomingNotification(quint32 id, const ProtoNotification &proto); + /** Raises appropiate notification signal. */ + void processCloseNotification(quint32 id, quint32 reason); + + /** Sends a D-Bus message for a method call with a single string argument. */ + void sendMessageWithString(const char *service, const char *path, const char *iface, const char *method, const char *arg); + /** Adds a D-Bus filter match rule. */ + void addMatchRule(const char *rule); + void removeMatchRule(const char *rule); + + /** Converts a fdo Notification D-Bus message into a ProtoNotification object. */ + ProtoNotification parseNotifyCall(DBusMessage *msg) const; + + QHash getCategoryInfo(const QString &s) const; + + static dbus_bool_t busWatchAdd(DBusWatch *watch, void *data); + static void busWatchRemove(DBusWatch *watch, void *data); + static void busWatchToggle(DBusWatch *watch, void *data); + + static DBusHandlerResult busMessageFilter(DBusConnection *conn, DBusMessage *msg, void *user_data); + +private slots: + void handleBusSocketActivated(); + +private: + NotificationMonitor * const q_ptr; + Q_DECLARE_PUBLIC(NotificationMonitor) + + /** The current set of monitored notifications, indexed by id. */ + QMap _notifs; + /** Low level dbus connection used for sniffing. */ + DBusConnection *_conn; + /** Serials of DBUS method calls of which we are expecting a reply. */ + QHash _pendingConfirmation; + /** Cache of notification category info. */ + mutable QHash _categoryCache; +}; + + +} + +#endif // WATCHFISH_NOTIFICATIONMONITOR_P_H + -- cgit v1.2.3