summaryrefslogtreecommitdiff
path: root/notificationmonitor_p.h
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-12-13 02:14:50 +0100
committerJavier <dev.git@javispedro.com>2015-12-13 02:14:50 +0100
commit8dc9a1295b7c1a5f81c55244b5d2bb3a3bddb30b (patch)
treedb221c4dfe14ba7d248b940c6473a9bbecd25e46 /notificationmonitor_p.h
parent9a3aaa3ded78ece418ac9b8b9576d8a433519034 (diff)
downloadlibwatchfish-8dc9a1295b7c1a5f81c55244b5d2bb3a3bddb30b.tar.gz
libwatchfish-8dc9a1295b7c1a5f81c55244b5d2bb3a3bddb30b.zip
Separate NotificationMonitorPrivate into its own file
Diffstat (limited to 'notificationmonitor_p.h')
-rw-r--r--notificationmonitor_p.h85
1 files changed, 85 insertions, 0 deletions
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 <QtCore/QObject>
+#include <dbus/dbus.h>
+
+#include "notificationmonitor.h"
+
+#define CATEGORY_DEFINITION_FILE_DIRECTORY "/usr/share/lipstick/notificationcategories"
+#define CATEGORY_REFRESH_CHECK_TIME 120
+
+namespace watchfish
+{
+
+struct NotificationCategoryCacheEntry
+{
+ QHash<QString, QString> data;
+ QDateTime lastReadTime;
+ QDateTime lastCheckTime;
+};
+
+struct ProtoNotification
+{
+ QString sender;
+ QString appIcon;
+ QString summary;
+ QString body;
+ QHash<QString, QString> 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<QString,QString> 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<quint32, Notification*> _notifs;
+ /** Low level dbus connection used for sniffing. */
+ DBusConnection *_conn;
+ /** Serials of DBUS method calls of which we are expecting a reply. */
+ QHash<quint32, ProtoNotification> _pendingConfirmation;
+ /** Cache of notification category info. */
+ mutable QHash<QString, NotificationCategoryCacheEntry> _categoryCache;
+};
+
+
+}
+
+#endif // WATCHFISH_NOTIFICATIONMONITOR_P_H
+