summaryrefslogtreecommitdiff
path: root/src/lib/xdgstatusnotifierwatcher.h
blob: 1c3f51313a81b84077bce3052aa07f8fce2a918b (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
#ifndef XDGSTATUSNOTIFIERWATCHER_H
#define XDGSTATUSNOTIFIERWATCHER_H

#include <QObject>

class QDBusServiceWatcher;
#define XDG_STATUS_NOTIFIER_WATCHER_PROTOCOL_VERSION 1

namespace KaZoe {

    class StatusNotifierWatcher: public QObject
    {
        Q_OBJECT

        Q_PROPERTY(QStringList RegisteredStatusNotifierItems READ RegisteredStatusNotifierItems NOTIFY RegisteredStatusNotifierItemsChanged)
        Q_PROPERTY(bool IsStatusNotifierHostRegistered READ IsStatusNotifierHostRegistered NOTIFY IsStatusNotifierHostRegisteredChanged)
        Q_PROPERTY(int ProtocolVersion READ ProtocolVersion CONSTANT)

    public:
        StatusNotifierWatcher(QObject *parent = nullptr);
        virtual ~StatusNotifierWatcher();

        void RegisterStatusNotifierItem(const QString &service);
        void RegisterStatusNotifierHost(const QString &service);

        QStringList RegisteredStatusNotifierItems() const;
        bool IsStatusNotifierHostRegistered() const;
        int ProtocolVersion() const;

    signals:
        void StatusNotifierItemRegistered(QString id);
        void StatusNotifierItemUnregistered(QString id);
        void StatusNotifierHostRegistered();
        void StatusNotifierHostUnregistered();
        void RegisteredStatusNotifierItemsChanged();
        void IsStatusNotifierHostRegisteredChanged();

    private:
        QStringList m_hosts;
        QStringList m_items;
        QDBusServiceWatcher *m_serviceWatcher = nullptr;

    private slots:
        void _serviceUnregistered(const QString &name);
    };
};

#endif // XDGSTATUSNOTIFIERWATCHER_H