-
Notifications
You must be signed in to change notification settings - Fork 0
/
safeclient.h
76 lines (64 loc) · 1.37 KB
/
safeclient.h
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
#ifndef SAFECLIENT_H
#define SAFECLIENT_H
#include <QObject>
#include <QLocalServer>
#include <QLocalSocket>
#include <QFileInfo>
#include <QThread>
#include <QEventLoop>
#include <QTimer>
#include <QDir>
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonValue>
#include <QJsonArray>
#include <QDateTime>
class SafeClient : public QObject
{
Q_OBJECT
public:
enum State {
Offline,
Unauthorized,
Idle,
Sync
};
explicit SafeClient(QObject *parent = 0);
State state(){ return this->m_state; }
bool auth;
QString account;
QString usage;
QString action;
void monitor();
private:
bool stopRequired;
State m_state;
QEventLoop *loop;
QEventLoop *sleep;
QTimer *timeout;
QTimer *sleepy;
void setState(State s){
if(s != this->m_state) {
this->m_state = s;
emit stateChanged();
}
}
signals:
void updateIcon();
void stateChanged();
void showLogin();
void showHome();
void hideAll();
void quit();
private slots:
void handleMessage(const QJsonObject &obj);
void sendCommand(const QJsonObject &obj);
public slots:
void logOut();
void changeDir(const QString &dir);
void logIn(const QString &login, const QString &password);
void chdir();
void stop();
};
#endif // SAFECLIENT_H