2
* Copyright (C) 2013-2016 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
* Didier Roche <didier.roche@canonical.com>
18
* Diego Sarmentero <diego.sarmentero@canonical.com>
19
* Sergio Schvezov <sergio.schvezov@canonical.com>
20
* Jonas G. Drange <jonas.drange@canonical.com>
24
#ifndef QSYSTEMIMAGE_H
25
#define QSYSTEMIMAGE_H
27
#include <QDBusInterface>
28
#include <QDBusServiceWatcher>
33
class QSystemImage : public QObject
36
Q_PROPERTY(int downloadMode READ downloadMode
37
WRITE setDownloadMode NOTIFY downloadModeChanged)
38
Q_PROPERTY(int failuresBeforeWarning READ failuresBeforeWarning
39
NOTIFY failuresBeforeWarningChanged)
40
Q_PROPERTY(bool checkingForUpdates READ checkingForUpdates
41
NOTIFY checkingForUpdatesChanged)
42
Q_PROPERTY(QString channelName READ channelName NOTIFY channelNameChanged)
43
Q_PROPERTY(QString deviceName READ deviceName NOTIFY deviceNameChanged)
44
Q_PROPERTY(int currentBuildNumber READ currentBuildNumber
45
NOTIFY currentBuildNumberChanged)
46
Q_PROPERTY(int targetBuildNumber READ targetBuildNumber
47
NOTIFY targetBuildNumberChanged)
48
Q_PROPERTY(QString currentUbuntuBuildNumber READ currentUbuntuBuildNumber
49
NOTIFY currentUbuntuBuildNumberChanged)
50
Q_PROPERTY(QString currentDeviceBuildNumber READ currentDeviceBuildNumber
51
NOTIFY currentDeviceBuildNumberChanged)
52
Q_PROPERTY(QString currentCustomBuildNumber READ currentCustomBuildNumber
53
NOTIFY currentCustomBuildNumberChanged)
54
Q_PROPERTY(QVariantMap detailedVersionDetails READ detailedVersionDetails
55
NOTIFY detailedVersionDetailsChanged)
56
Q_PROPERTY(QDateTime lastUpdateDate READ lastUpdateDate
57
NOTIFY lastUpdateDateChanged)
58
Q_PROPERTY(QDateTime lastCheckDate READ lastCheckDate
59
NOTIFY lastCheckDateChanged)
60
Q_PROPERTY(bool updateAvailable READ updateAvailable
61
NOTIFY updateAvailableChanged)
62
Q_PROPERTY(bool downloading READ downloading
63
NOTIFY downloadingChanged)
64
Q_PROPERTY(int updateSize READ updateSize
65
NOTIFY updateSizeChanged)
66
Q_PROPERTY(QString errorReason READ errorReason
67
NOTIFY errorReasonChanged)
68
Q_PROPERTY(QString versionTag READ versionTag
69
NOTIFY versionTagChanged)
71
explicit QSystemImage(QObject *parent = nullptr);
72
explicit QSystemImage(const QDBusConnection &dbus, QObject *parent = nullptr);
75
bool checkingForUpdates() const;
77
void setDownloadMode(const int &downloadMode);
78
int failuresBeforeWarning();
80
QString deviceName() const;
81
QString channelName() const;
82
QString currentUbuntuBuildNumber() const;
83
QString currentDeviceBuildNumber() const;
84
QString currentCustomBuildNumber() const;
85
QVariantMap detailedVersionDetails() const;
86
int currentBuildNumber() const;
87
int targetBuildNumber() const;
89
bool updateAvailable();
92
QString errorReason();
94
QDateTime lastUpdateDate() const;
95
QDateTime lastCheckDate() const;
97
Q_INVOKABLE void checkForUpdate();
98
Q_INVOKABLE void downloadUpdate();
99
Q_INVOKABLE void forceAllowGSMDownload();
100
Q_INVOKABLE void applyUpdate();
101
Q_INVOKABLE QString cancelUpdate();
102
Q_INVOKABLE QString pauseDownload();
103
Q_INVOKABLE void productionReset();
104
Q_INVOKABLE void factoryReset();
105
Q_INVOKABLE bool checkTarget() const;
108
void checkingForUpdatesChanged();
109
void currentBuildNumberChanged();
110
void deviceNameChanged();
111
void channelNameChanged();
112
void currentUbuntuBuildNumberChanged();
113
void currentDeviceBuildNumberChanged();
114
void currentCustomBuildNumberChanged();
115
void targetBuildNumberChanged();
116
void detailedVersionDetailsChanged();
117
void lastUpdateDateChanged();
118
void lastCheckDateChanged();
119
void updateAvailableChanged();
120
void downloadingChanged();
121
void failuresBeforeWarningChanged();
122
void updateSizeChanged();
123
void errorReasonChanged();
124
void versionTagChanged();
125
void downloadModeChanged();
126
void updateProcessFailed(const QString &reason);
127
void updateProcessing();
128
void rebooting(const bool status);
129
void updateFailed(const int &consecutiveFailureCount,
130
const QString &lastReason);
131
void updateDownloaded();
132
void downloadStarted();
133
void updatePaused(const int &percentage);
134
void updateAvailableStatus(const bool isAvailable,
135
const bool downloading,
136
const QString &availableVersion,
137
const int &updateSize,
138
const QString &lastUpdateDate,
139
const QString &errorReason);
141
void updateProgress(const int &percentage, const double &eta);
144
void slotNameOwnerChanged(const QString&, const QString&, const QString&);
145
void settingsChanged(const QString &key, const QString &newvalue);
146
void availableStatusChanged(const bool isAvailable,
147
const bool downloading,
148
const QString &availableVersion,
149
const int &updateSize,
150
const QString &lastUpdateDate,
151
const QString &errorReason);
154
void setCheckingForUpdates(const bool checking);
155
void setDeviceName(const QString &deviceName);
156
void setChannelName(const QString &channelName);
157
void setDetailedVersionDetails(const QVariantMap &detailedVersionDetails);
158
void setCurrentBuildNumber(const int ¤tBuildNumber);
159
void setTargetBuildNumber(const int &targetBuildNumber);
160
void setLastUpdateDate(const QDateTime &lastUpdateDate);
161
void setLastCheckDate(const QDateTime &lastCheckDate);
162
void setUpdateAvailable(const bool updateAvailable);
163
void setDownloading(const bool downloading);
164
void setUpdateSize(const int &updateSize);
165
void setErrorReason(const QString &errorReason);
168
// Synchronously initialize properties from the Information call.
169
void initializeProperties();
170
// Sets up connections on the DBus interface.
171
void setUpInterface();
172
int getSetting(const QString &setting, const int &defaultValue);
174
bool m_checkingForUpdates = false;
175
int m_currentBuildNumber = 0;
176
QMap<QString, QVariant> m_detailedVersion;
177
QDateTime m_lastUpdateDate = QDateTime();
178
int m_downloadMode = -1;
179
int m_failuresBeforeWarning = -1;
181
// QDBusConnection m_dbus;
182
QDBusServiceWatcher m_watcher;
183
QDBusInterface m_iface;
185
QDateTime m_lastCheckDate = QDateTime();
186
QString m_channelName = QString::null;
187
int m_targetBuildNumber = -1;
188
QString m_deviceName = QString::null;
190
bool m_updateAvailable = false;
191
bool m_downloading = false;
192
int m_updateSize = 0;
193
QString m_errorReason = QString::null;
196
#endif // QSYSTEMIMAGE_H