ssucli.h 1.7 KB
Newer Older
Aard's avatar
Aard committed
1
/**
2
 * @file ssucli.h
Aard's avatar
Aard committed
3 4 5 6 7
 * @copyright 2012 Jolla Ltd.
 * @author Bernd Wachter <bernd.wachter@jollamobile.com>
 * @date 2012
 */

8 9
#ifndef _SsuCli_H
#define _SsuCli_H
Aard's avatar
Aard committed
10 11 12

#include <QObject>
#include <QSettings>
13
#include <QStringList>
Aard's avatar
Aard committed
14 15
#include <QDebug>

16
#include "libssu/ssu.h"
17
#include "ssu_interface.h"
Aard's avatar
Aard committed
18

19 20
class SsuCli: public QObject
{
Aard's avatar
Aard committed
21 22
    Q_OBJECT

23
public:
24 25
    SsuCli();
    ~SsuCli();
Aard's avatar
Aard committed
26

27
public slots:
Aard's avatar
Aard committed
28 29
    void run();

30
private:
Aard's avatar
Aard committed
31
    Ssu ssu;
32
    SsuProxy *ssuProxy;
Aard's avatar
Aard committed
33
    QSettings settings;
34
    int state;
35
    void usage(const QString &message = QString());
36
    void uidWarning();
37
    void optDomain(QStringList opt);
38 39
    void optFlavour(QStringList opt);
    void optMode(QStringList opt);
40
    void optModel(QStringList opt);
41
    void optRegister(QStringList opt);
42 43
    void optRelease(QStringList opt);
    void optRepos(QStringList opt);
44
    void optSet(QStringList opt);
45
    void optStatus(QStringList opt);
46
    void optUpdateCredentials(QStringList opt);
47
    void optUpdateRepos(QStringList opt);
48 49

    enum Actions {
Pekka Vuorela's avatar
Pekka Vuorela committed
50 51 52 53
        Remove,
        Add,
        Disable,
        Enable
54 55
    };

56 57
    void optModifyRepo(enum Actions action, QStringList opt);

58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
    void optAddRepo(QStringList opt)
    {
        optModifyRepo(Add, opt);
    }
    void optRemoveRepo(QStringList opt)
    {
        optModifyRepo(Remove, opt);
    }
    void optEnableRepo(QStringList opt)
    {
        optModifyRepo(Enable, opt);
    }
    void optDisableRepo(QStringList opt)
    {
        optModifyRepo(Disable, opt);
    }
74

75
    enum State {
76 77 78
        Idle,
        Busy,
        UserError
79
    };
Aard's avatar
Aard committed
80

81 82
    QString fallingBackToDirectUse(const QDBusError &error) const;

83
private slots:
Aard's avatar
Aard committed
84
    void handleResponse();
85
    void handleDBusResponse();
Aard's avatar
Aard committed
86

87
signals:
Aard's avatar
Aard committed
88 89 90 91 92
    void done();

};

#endif