summaryrefslogtreecommitdiff
path: root/libsowatch/watchserver.h
blob: 0ca1f4f9c1fff643ab7e34771ec0e9b9ced97ff1 (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
52
53
#ifndef SOWATCH_WATCHSERVER_H
#define SOWATCH_WATCHSERVER_H

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

#include "sowatch_global.h"
#include "notification.h"

namespace sowatch
{

class Watch;
class Watchlet;
class NotificationProvider;

class SOWATCH_EXPORT WatchServer : public QObject
{
    Q_OBJECT
	Q_PROPERTY(Watch* watch READ watch CONSTANT)

public:
	explicit WatchServer(Watch* watch, QObject* parent = 0);

	Watch* watch();

	void addProvider(NotificationProvider* provider);

	void runWatchlet(const QString& id);
	void closeWatchlet();

protected:
	Watch* _watch;
	Watchlet* _currentWatchlet;

	QMap<QString, Watchlet*> _watchlets;
	QList<NotificationProvider*> _providers;

	void registerWatchlet(Watchlet *watchlet);

protected slots:
	void watchConnected();
	void watchDisconnected();
	void notificationEmitted(const Notification& notification);
	void unreadCountUpdated(Notification::Type type);

friend class Watchlet;
};

}

#endif // SOWATCH_WATCHSERVER_H