-
Notifications
You must be signed in to change notification settings - Fork 1
/
TailRunner.h
68 lines (54 loc) · 1.52 KB
/
TailRunner.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
#ifndef TAILRUNNER_H
#define TAILRUNNER_H
#include <memory>
#include <QObject>
#include <QString>
#include <QList>
#include <QProcess>
#include "models.h"
#include "TailSettings.h"
class TailRunner : public QObject
{
Q_OBJECT
public:
explicit TailRunner(const TailSettings& s, QObject* parent = nullptr);
void checkStatus();
void getAccounts();
void switchAccount(const QString& accountId);
void login();
void logout();
void start(bool usePkExec = false);
void stop();
void listDrives();
void addDrive(const TailDriveInfo& drive);
void renameDrive(const TailDriveInfo& drive, const QString& newName);
void removeDrive(const TailDriveInfo& drive);
private:
const TailSettings& settings;
std::unique_ptr<QProcess> pProcess;
enum class Command {
ListAccounts,
SwitchAccount,
Login,
Logout,
Connect,
Disconnect,
SettingsChange,
Status,
Drive,
DriveAdd,
DriveRename,
DriveRemove
};
Command eCommand;
signals:
void accountsListed(const QList<TailAccountInfo>& accounts);
void statusUpdated(TailStatus* newStatus);
void loginFlowCompleted();
void driveListed(const QList<TailDriveInfo>& drives, bool error, const QString& errorMsg);
private:
void runCommand(const QString& cmd, QStringList args, bool jsonResult = false, bool usePkExec = false);
void onProcessCanReadStdOut();
void parseStatusResponse(const QJsonObject& obj);
};
#endif // TAILRUNNER_H