aboutsummaryrefslogtreecommitdiff
path: root/src/qt/workers.hpp
blob: dbc2c7e70a8f1cb47e9ac2e877506d0938d0737e (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef WORKERS_HPP
#define WORKERS_HPP

#include <QObject>
#include <QSettings>
#include <limits.h>
#include <pthread.h>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class Worker : public QObject
{
    Q_OBJECT

private:
    char* of_dir;
    size_t of_dir_len;

    char* remote;
    size_t remote_len;

    bool update_in_progress = false;

    QSettings settings;

public:
    int do_work = 1;
    int progress = -1;
    QString infoText;
    pthread_mutex_t textMutex;

    Worker();
    ~Worker();

    QString getOfDir();
    QString getRemote();
    void setRemote(QString);
    QString getArguments();
    void setArguments(QString);
    void setInfoText(QString);

    int getRevision();
    int getRemoteRevision();
    bool isOutdated();

    void stop_work();

    int update_setup(int, int);

    enum Tasks_t
    {
        TASK_INVALID,

        TASK_IS_INSTALLED,
        TASK_IS_UPTODATE,

        TASK_INIT,
        TASK_INSTALL,
        TASK_UNINSTALL,
        TASK_UPDATE,
        TASK_UPDATE_RUN,
        TASK_RUN,
    };
    Q_ENUM(Tasks_t)

    enum Results_t
    {
        RESULT_NONE,
        RESULT_EXIT,

        RESULT_UPDATE_TEXT,

        RESULT_IS_INSTALLED,
        RESULT_IS_NOT_INSTALLED,
        RESULT_IS_UPTODATE,
        RESULT_IS_OUTDATED,

        RESULT_INIT_COMPLETE,
        RESULT_INIT_FAILURE,
        RESULT_INSTALL_COMPLETE,
        RESULT_INSTALL_FAILURE,
        RESULT_UNINSTALL_COMPLETE,
        RESULT_UNINSTALL_FAILURE,
        RESULT_UPDATE_COMPLETE,
        RESULT_UPDATE_FAILURE,
        RESULT_UPDATE_RUN,

        RESULT_NO_STEAM
    };
    Q_ENUM(Results_t)

public slots:
    void doWork(const Tasks_t &);

signals:
    void resultReady(const Results_t &);

};


#endif