aboutsummaryrefslogtreecommitdiff
path: root/src/scenes/remote_control/remote_control_manager.h
blob: 6f2fbdbd1fadefc3791a31cce5162f51d6e67da1 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef REMOTECONTROLMANAGER_H
#define REMOTECONTROLMANAGER_H

#include <QObject>

#include "../../main_qmladaptor.h"
#include "../../DBusAPI.h"
#include "../../session.h"

class RemoteControlManager : public QObject {

    Q_OBJECT
    // this makes url available as a QML property
    Q_PROPERTY(QString url READ getURL NOTIFY urlChanged)
    // this makes pin available as a QML property
    Q_PROPERTY(QString pin READ getPin NOTIFY pinChanged)
    // this makes session_id available as a QML property
    Q_PROPERTY(QString session_id READ getSessionID NOTIFY sessionIDChanged)

public:
    explicit RemoteControlManager(QQmlApplicationEngine *engine = nullptr,
                                  MainQMLAdaptor *main_gui = nullptr,
                                  DBusAPI *dbus_api = nullptr);

    bool setConnectButtonEnabled(bool enabled);
    bool setConnectButtonChecked(bool checked);
    bool setStatusIndicatorColor(bool active, QColor color = QColor(255,255,255));

    QString translateStatusIndicatorText(QString status_code);
    bool setStatusIndicatorText(QString status_text);

private:
    DBusAPI *_dbus_api;
    MainQMLAdaptor *_main_gui;
    QQmlApplicationEngine *_engine;
    Session *_current_session;
    QSet<Session*> *_sessions;

    void connectSession(Session *session);
    void connectToDBusAPI(Session *session);

    bool refreshTimerIsRunning;

signals:
    void onConnectButtonClick(bool checked);
    void pinChanged(QString pin);
    void urlChanged(QString URL);
    void sessionIDChanged(QString session_id);

public slots:
    void handleCopyToClipboardButtonClick(QString copy_data);
    void handleConnectButtonClick(bool checked);

    void setCurrentSession(Session *session);
    void addSession(Session *session);
    bool removeSession(Session *session);

    void currentSessionStatusChanged(QString);
    void currentSessionPinChanged(QString);
    void currentSessionSessionIDChanged(QString);
    void currentSessionUrlChanged(QString);

    QString getURL();
    QString getPin();
    QString getSessionID();
    Session* getCurrentSession();

    void currentSessionStartFailed(QString error_message);
    void currentSessionStopFailed(QString error_message);
    void currentSessionStatusFailed(QString error_message);
    void currentSessionUnexpectedStop(QString error_message);

    void currentSessionStartSucceeded();
    void currentSessionStopSucceeded();
    void currentSessionStatusSucceeded();
};

#endif // REMOTECONTROLMANAGER_H