/
developermodesettings.h
130 lines (111 loc) · 4.76 KB
2
3
* Copyright (c) 2013 – 2019 Jolla Ltd.
* Copyright (c) 2019 Open Mobile Platform LLC.
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
* Contact: Thomas Perl <thomas.perl@jollamobile.com>
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#ifndef DEVELOPERMODESETTINGS_H
#define DEVELOPERMODESETTINGS_H
#include <QObject>
#include <QDBusInterface>
40
#include <systemsettingsglobal.h>
41
42
#include <daemon.h>
44
45
46
QT_BEGIN_NAMESPACE
class QDBusPendingCallWatcher;
QT_END_NAMESPACE
48
class SYSTEMSETTINGS_EXPORT DeveloperModeSettings : public QObject
49
50
51
52
{
Q_OBJECT
Q_ENUMS(Status)
53
54
55
56
Q_PROPERTY(QString wlanIpAddress READ wlanIpAddress NOTIFY wlanIpAddressChanged)
Q_PROPERTY(QString usbIpAddress READ usbIpAddress NOTIFY usbIpAddressChanged)
Q_PROPERTY(QString username READ username CONSTANT)
Q_PROPERTY(bool developerModeEnabled READ developerModeEnabled NOTIFY developerModeEnabledChanged)
57
58
Q_PROPERTY(enum DeveloperModeSettings::Status workStatus READ workStatus NOTIFY workStatusChanged)
Q_PROPERTY(int workProgress READ workProgress NOTIFY workProgressChanged)
59
Q_PROPERTY(bool repositoryAccessRequired READ repositoryAccessRequired NOTIFY repositoryAccessRequiredChanged)
60
61
62
63
64
65
66
public:
explicit DeveloperModeSettings(QObject *parent = NULL);
virtual ~DeveloperModeSettings();
enum Status {
Idle = 0,
67
68
69
70
Preparing,
DownloadingPackages,
InstallingPackages,
RemovingPackages
71
72
73
74
};
QString wlanIpAddress() const;
QString usbIpAddress() const;
75
QString username() const;
76
bool developerModeEnabled() const;
77
78
enum DeveloperModeSettings::Status workStatus() const;
int workProgress() const;
79
bool repositoryAccessRequired() const;
80
81
82
83
84
85
86
87
88
Q_INVOKABLE void setDeveloperMode(bool enabled);
Q_INVOKABLE void setUsbIpAddress(const QString &usbIpAddress);
Q_INVOKABLE void refresh();
signals:
void wlanIpAddressChanged();
void usbIpAddressChanged();
void developerModeEnabledChanged();
89
90
void workStatusChanged();
void workProgressChanged();
91
void repositoryAccessRequiredChanged();
92
93
private slots:
94
void reportTransactionErrorCode(PackageKit::Transaction::Error code, const QString &details);
95
void updateState(int percentage, PackageKit::Transaction::Status status, PackageKit::Transaction::Role role);
96
97
private:
98
99
100
101
enum Command {
InstallCommand,
RemoveCommand
};
103
104
105
106
void resetState();
void setWorkStatus(Status status);
void refreshPackageCacheAndInstall();
void resolveAndExecute(Command command);
107
void connectCommandSignals(PackageKit::Transaction *transaction);
109
110
111
QString usbModedGetConfig(const QString &key, const QString &fallback);
void usbModedSetConfig(const QString &key, const QString &value);
112
113
114
115
QDBusInterface m_usbModeDaemon;
QString m_wlanIpAddress;
QString m_usbInterface;
QString m_usbIpAddress;
116
QString m_username;
117
QString m_developerModePackageId;
118
bool m_developerModeEnabled;
119
120
DeveloperModeSettings::Status m_workStatus;
int m_workProgress;
121
122
PackageKit::Transaction::Role m_transactionRole;
PackageKit::Transaction::Status m_transactionStatus;
123
bool m_refreshedForInstall;
124
125
bool m_localInstallFailed;
QString m_localDeveloperModePackagePath;
128
Q_DECLARE_METATYPE(DeveloperModeSettings::Status)
129
130
#endif /* DEVELOPERMODESETTINGS_H */