~libqtelegram-team/telegram-app/telegram-app-dev

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
Copyright 2014 Canonical Ltd.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License, version 3
as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this program.  If not, see
<http://www.gnu.org/licenses/>.
*/

#ifndef PUSHCLIENT_H
#define PUSHCLIENT_H

#include <QObject>
#include <QString>
#include <QStringList>

class QDBusPendingCallWatcher;

class PushClient : public QObject {
    Q_OBJECT

public:
    explicit PushClient(QObject *parent = 0);

    QString getAppId();
    void setAppId(const QString &appId);
    QString getToken();
    QString getStatus() { return this->status; }
    int getCount();
    void setCount(int count);

    void registerApp(const QString &appid);

    Q_PROPERTY(QString appId WRITE setAppId READ getAppId NOTIFY appIdChanged);
    Q_PROPERTY(QString token READ getToken NOTIFY tokenChanged);
    Q_PROPERTY(QStringList notifications NOTIFY notificationsChanged);
    Q_PROPERTY(QString status READ getStatus NOTIFY statusChanged);
    Q_PROPERTY(int count READ getCount WRITE setCount NOTIFY countChanged)

signals:
    void appIdChanged(const QString &appId);
    void tokenChanged(const QString &token);
    void statusChanged(const QString &status);
    void countChanged(int count);
    void notificationsChanged(const QStringList &notifications);
    void persistentChanged(const QStringList &tags);
    void persistentCleared();

    void error(const QString &error);

public slots:
    void emitError();
    void clearPersistent(const QStringList &tags);

private slots:
    void setCounterFinished(QDBusPendingCallWatcher *watcher);
    void clearPersistentFinished(QDBusPendingCallWatcher *watcher);

private:
    QString appId;
    QString pkgname;
    QString token;
    QString status;
    QStringList notifications;
    int counter;
};

#endif // PUSHCLIENT_H