summaryrefslogtreecommitdiff
path: root/saltoqd/notificationmonitor.h
blob: 8ac49c5bad0112316f9b842dc4fdb5251f3cd01d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef NOTIFICATIONMONITOR_H
#define NOTIFICATIONMONITOR_H

#include <QtCore/QObject>
#include <QtCore/QMap>
#include <QtCore/QDateTime>

class IncomingNotification : public QObject
{
	Q_OBJECT
	Q_PROPERTY(QString sender READ sender)
	Q_PROPERTY(QString summary READ summary NOTIFY summaryChanged)

	explicit IncomingNotification(QObject *parent = 0);

public:
	inline QString sender() const { return _sender; }
	inline QString summary() const { return _summary; }

signals:
	void summaryChanged();

private:
	friend class NotificationMonitor;

	QString _sender;
	QString _summary;
};

class NotificationMonitor : public QObject
{
	Q_OBJECT

public:
	~NotificationMonitor();

	static NotificationMonitor *instance();

	void processIncomingNotification(quint32 id, const QVariantHash &content);
	void processCloseNotification(quint32 id, quint32 reason);

signals:
	void notification(IncomingNotification *n);

private:
	explicit NotificationMonitor(QObject *parent = 0);
	QMap<quint32, IncomingNotification*> _notifs;

};

#endif // NOTIFICATIONMONITOR_H