blob: c7d331351b6199885f968b70a95e08d4be174d57 (
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
|
#include <QProcess>
#include <QQueue>
#include <QMap>
#include <QVector>
#ifndef BACKEND_H
#define BACKEND_H
class Backend : public QObject
{
Q_OBJECT
public:
static Backend* instance() {if(!_instance) _instance = new Backend(); return(_instance);}
~Backend();
void init();
void runBackend();
void exec(QString command);
void exitBackend();
QString encryptPassword(QString password);
QString cleanUsername(const QString &username);
QString sizeToString(qlonglong size);
bool isBusy();
bool flag(QString flag);
void flag(QString flag, bool set);
QString cfg(QString var);
void cfg(QString var, QString value);
protected:
QProcess* _process;
private slots:
void slotProcessExited();
void slotReceiveOutput();
private:
static Backend *_instance;
Backend();
void processOutput(QString line);
void _flag(QString flag, bool set);
void _cfg(QString var, QString value);
void dequeue();
QMap<QString,QString> data;
QString currentData;
QMap<QString,QString> cfgMap;
QVector<QString> flags;
QQueue<QString> commandQueue;
QString currentCommand;
bool busy;
signals:
void processExited();
void receivedDataLine(QString data, QString line);
void receivedProgress(int percent);
void receivedCommand(QString command, QString args);
void finishedCommand(QString command);
void isBusy(bool busy);
};
#endif
|