summaryrefslogtreecommitdiffstats
path: root/process.h
blob: 3ce5d968f709983aea37f3552e38c700f930109e (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
#include <QObject>
#include <QProcess>
#include <QMap>

class QSocketNotifier;

struct Config {
    enum Flag {
        PrintDebugMessages = 0x01
    };
    Q_DECLARE_FLAGS(Flags, Flag)

    enum DebugInterface{
        LocalDebugInterface,
        PublicDebugInterface
    };

    Config() : flags(0) { }

    QString base;
    QString platform;
    QMap<QString,QString> env;
    QStringList args;
    Flags flags;
    DebugInterface debugInterface;
};

class Process : public QObject
{
    Q_OBJECT
public:
    Process();
    virtual ~Process();
    void start(const QStringList &args);
    void setSocketNotifier(QSocketNotifier*);
    void setDebug();
    void setConfig(const Config &);
public slots:
    void stop();
private slots:
    void readyReadStandardError();
    void readyReadStandardOutput();
    void finished(int, QProcess::ExitStatus);
    void error(QProcess::ProcessError);
    void incomingConnection(int);
private:
    void startup(QStringList);
    QProcess *mProcess;
    int mDebuggee;
    bool mDebug;
    Config mConfig;
    QString mBinary;
};