Merge lp:~mandel/ubuntu-system-settings/fix-pause-rtm into lp:ubuntu-system-settings/rtm-14.09

Proposed by Manuel de la Peña
Status: Merged
Approved by: Ken VanDine
Approved revision: 964
Merged at revision: 965
Proposed branch: lp:~mandel/ubuntu-system-settings/fix-pause-rtm
Merge into: lp:ubuntu-system-settings/rtm-14.09
Diff against target: 353 lines (+143/-68)
3 files modified
plugins/system-update/download_tracker.cpp (+75/-29)
plugins/system-update/download_tracker.h (+8/-6)
plugins/system-update/update.cpp (+60/-33)
To merge this branch: bzr merge lp:~mandel/ubuntu-system-settings/fix-pause-rtm
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Jonas G. Drange (community) Needs Fixing
Ken VanDine Approve
Review via email: mp+246410@code.launchpad.net

Commit message

Fix click downloads pause by ensuring that the settings works accordingly.

Description of the change

Fix click downloads pause.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
962. By Manuel de la Peña

Merged with rtm trunk.

963. By Manuel de la Peña

Update the changelog.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
964. By Manuel de la Peña

Fix code according to reviews.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks good, and works great!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

If this is not a real AP failure, maybe it would help merging Ken's AP fixes from trunk?

review: Needs Fixing
965. By Manuel de la Peña

Merged with trunk.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/system-update/download_tracker.cpp'
2--- plugins/system-update/download_tracker.cpp 2014-09-30 02:05:36 +0000
3+++ plugins/system-update/download_tracker.cpp 2015-01-20 12:17:55 +0000
4@@ -18,22 +18,27 @@
5 * Authored by: Diego Sarmentero <diego.sarmentero@canonical.com>
6 */
7
8+#include <QDebug>
9+#include <QProcessEnvironment>
10+
11+#include <ubuntu/download_manager/download_struct.h>
12+#include <ubuntu/download_manager/error.h>
13+
14 #include "download_tracker.h"
15 #include "network/network.h"
16-#include <ubuntu/download_manager/download_struct.h>
17-#include <ubuntu/download_manager/error.h>
18-#include <QProcessEnvironment>
19
20-#define DOWNLOAD_COMMAND "post-download-command"
21-#define APP_ID "app_id"
22-#define PKCON_COMMAND "pkcon"
23+namespace {
24+ const QString DOWNLOAD_COMMAND = "post-download-command";
25+ const QString APP_ID = "app_id";
26+ const QString PKCON_COMMAND = "pkcon";
27+}
28
29 namespace UpdatePlugin {
30
31 DownloadTracker::DownloadTracker(QObject *parent) :
32 QObject(parent),
33- m_clickToken(""),
34- m_downloadUrl(""),
35+ m_clickToken(QString::null),
36+ m_downloadUrl(QString::null),
37 m_download(nullptr),
38 m_manager(nullptr),
39 m_progress(0)
40@@ -42,7 +47,7 @@
41
42 void DownloadTracker::setDownload(const QString& url)
43 {
44- if (url != "") {
45+ if (!url.isEmpty()) {
46 m_downloadUrl = url;
47 startService();
48 }
49@@ -50,7 +55,7 @@
50
51 void DownloadTracker::setClickToken(const QString& token)
52 {
53- if (token != "") {
54+ if (!token.isEmpty()) {
55 m_clickToken = token;
56 startService();
57 }
58@@ -58,7 +63,7 @@
59
60 void DownloadTracker::setPackageName(const QString& package)
61 {
62- if (package != "") {
63+ if (!package.isEmpty()) {
64 m_packageName = package;
65 startService();
66 }
67@@ -70,8 +75,10 @@
68 if (m_manager == nullptr) {
69 m_manager = Manager::createSessionManager("", this);
70
71- QObject::connect(m_manager, SIGNAL(downloadCreated(Download*)),
72- this, SLOT(bindDownload(Download*)));
73+ if (!connect(m_manager, &Manager::downloadCreated,
74+ this, &DownloadTracker::bindDownload)) {
75+ qWarning() << "Could not connect to Manager::downloadCreated!";
76+ }
77 }
78 QVariantMap vmap;
79 QStringList args;
80@@ -89,22 +96,40 @@
81 void DownloadTracker::bindDownload(Download* download)
82 {
83 m_download = download;
84- connect(m_download, SIGNAL(finished(const QString &)), this,
85- SIGNAL(finished(const QString &)));
86- connect(m_download, SIGNAL(canceled(bool)), this,
87- SIGNAL(canceled(bool)));
88- connect(m_download, SIGNAL(paused(bool)), this,
89- SIGNAL(paused(bool)));
90- connect(m_download, SIGNAL(resumed(bool)), this,
91- SIGNAL(resumed(bool)));
92- connect(m_download, SIGNAL(started(bool)), this,
93- SIGNAL(started(bool)));
94- connect(m_download, SIGNAL(error(Error*)), this,
95- SLOT(registerError(Error*)));
96- connect(m_download, SIGNAL(progress(qulonglong, qulonglong)), this,
97- SLOT(setProgress(qulonglong, qulonglong)));
98- connect(m_download, SIGNAL(processing(const QString &)), this,
99- SIGNAL(processing(const QString &)));
100+ if (!connect(m_download, &Download::finished,
101+ this, &DownloadTracker::onDownloadFinished)) {
102+ qWarning() << "Could not connect to Download::finished";
103+ }
104+ if (!connect(m_download, &Download::canceled,
105+ this, &DownloadTracker::onDownloadCanceled)) {
106+ qWarning() << "Could not connect to Download::canceled";
107+ }
108+ if (!connect(m_download, &Download::paused,
109+ this, &DownloadTracker::paused)) {
110+ qWarning() << "Could not connect to Download::paused";
111+ }
112+ if (!connect(m_download, &Download::resumed,
113+ this, &DownloadTracker::resumed)) {
114+ qWarning() << "Could not connect to Download::resumed";
115+ }
116+ if (!connect(m_download, &Download::started,
117+ this, &DownloadTracker::started)) {
118+ qWarning() << "Could not connect to Download::started";
119+ }
120+ if (!connect(m_download, static_cast<void(Download::*)(Error*)>(&Download::error),
121+ this, &DownloadTracker::registerError)) {
122+ qWarning() << "Could not connect to Download::error";
123+ }
124+
125+ if (!connect(m_download, static_cast<void(Download::*)(qulonglong, qulonglong)>(&Download::progress),
126+ this, &DownloadTracker::setProgress)) {
127+ qWarning() << "Could not connect to Download::progress";
128+ }
129+
130+ if (!connect(m_download, &Download::processing,
131+ this, &DownloadTracker::processing)) {
132+ qWarning() << "Could not connect to Download::processing";
133+ }
134
135 m_download->start();
136 }
137@@ -112,6 +137,27 @@
138 void DownloadTracker::registerError(Error* error)
139 {
140 Q_EMIT errorFound(error->errorString());
141+
142+ // we need to ensure that the resources are cleaned
143+ m_download->deleteLater();
144+ m_download = nullptr;
145+}
146+
147+void DownloadTracker::onDownloadFinished(const QString& path)
148+{
149+ // once a download is finished we need to clean the resources
150+ m_download->deleteLater();
151+ m_download = nullptr;
152+ Q_EMIT finished(path);
153+}
154+
155+void DownloadTracker::onDownloadCanceled(bool wasCanceled)
156+{
157+ if (wasCanceled) {
158+ m_download->deleteLater();
159+ m_download = nullptr;
160+ }
161+ Q_EMIT canceled(wasCanceled);
162 }
163
164 void DownloadTracker::pause()
165
166=== modified file 'plugins/system-update/download_tracker.h'
167--- plugins/system-update/download_tracker.h 2014-09-30 02:05:36 +0000
168+++ plugins/system-update/download_tracker.h 2015-01-20 12:17:55 +0000
169@@ -63,6 +63,8 @@
170 void bindDownload(Download* download);
171 void setProgress(qulonglong received, qulonglong total);
172 void registerError(Ubuntu::DownloadManager::Error* error);
173+ void onDownloadFinished(const QString& path);
174+ void onDownloadCanceled(bool wasCanceled);
175
176 Q_SIGNALS:
177 void error(const QString &errorMessage);
178@@ -76,12 +78,12 @@
179 void errorFound(const QString &error);
180
181 private:
182- QString m_clickToken;
183- QString m_downloadUrl;
184- QString m_packageName;
185- Download* m_download;
186- Manager* m_manager;
187- int m_progress;
188+ QString m_clickToken = QString::null;
189+ QString m_downloadUrl = QString::null;
190+ QString m_packageName = QString::null;
191+ Download* m_download = nullptr;
192+ Manager* m_manager = nullptr;
193+ int m_progress = 0;
194
195 void startService();
196 QString getPkconCommand();
197
198=== modified file 'plugins/system-update/update.cpp'
199--- plugins/system-update/update.cpp 2014-09-12 23:47:39 +0000
200+++ plugins/system-update/update.cpp 2015-01-20 12:17:55 +0000
201@@ -18,10 +18,13 @@
202 *
203 */
204
205-#include "update.h"
206-#include <QStringList>
207 #include <apt-pkg/debversion.h>
208+
209+#include <QDebug>
210 #include <QProcessEnvironment>
211+#include <QStringList>
212+
213+#include "update.h"
214
215 namespace UpdatePlugin {
216
217@@ -64,81 +67,105 @@
218
219 void Update::setRemoteVersion(QString& version)
220 {
221- m_remote_version = version;
222- if (!getIgnoreUpdates()) {
223- int result = debVS.CmpVersion(m_local_version.toUtf8().data(),
224- m_remote_version.toUtf8().data());
225-
226- m_update = result < 0;
227- } else {
228- m_update = false;
229+ if (m_remote_version != version) {
230+ m_remote_version = version;
231+ if (!getIgnoreUpdates()) {
232+ int result = debVS.CmpVersion(m_local_version.toUtf8().data(),
233+ m_remote_version.toUtf8().data());
234+
235+ m_update = result < 0;
236+ } else {
237+ m_update = false;
238+ }
239 }
240 }
241
242 void Update::setError(QString error)
243 {
244- m_error = error;
245- if (!m_error.isEmpty()) {
246- Q_EMIT errorChanged();
247+ if (m_error != error) {
248+ m_error = error;
249+ if (!m_error.isEmpty()) {
250+ Q_EMIT errorChanged();
251+ }
252 }
253 }
254
255 void Update::setSystemUpdate(bool isSystem)
256 {
257- m_systemUpdate = isSystem;
258- Q_EMIT systemUpdateChanged();
259+ if (m_systemUpdate != isSystem) {
260+ m_systemUpdate = isSystem;
261+ Q_EMIT systemUpdateChanged();
262+ }
263 }
264
265 void Update::setUpdateRequired(bool state)
266 {
267- m_update = state;
268- Q_EMIT updateRequiredChanged();
269+ if (m_update != state) {
270+ m_update = state;
271+ Q_EMIT updateRequiredChanged();
272+ }
273 }
274
275 void Update::setUpdateState(bool state)
276 {
277- m_update_state = state;
278- Q_EMIT updateStateChanged();
279+ if (m_update_state != state) {
280+ m_update_state = state;
281+ Q_EMIT updateStateChanged();
282+ }
283 }
284
285 void Update::setUpdateReady(bool ready)
286 {
287- m_update_ready = ready;
288- Q_EMIT updateReadyChanged();
289+ if (m_update_ready != ready) {
290+ m_update_ready = ready;
291+ Q_EMIT updateReadyChanged();
292+ }
293 }
294
295 void Update::setSelected(bool value)
296 {
297- m_selected = value;
298- Q_EMIT selectedChanged();
299+ if (m_selected != value) {
300+ m_selected = value;
301+ Q_EMIT selectedChanged();
302+ }
303 }
304
305 void Update::setBinaryFilesize(int size)
306 {
307- m_binary_filesize = size;
308- Q_EMIT binaryFilesizeChanged();
309+ if (m_binary_filesize != size) {
310+ m_binary_filesize = size;
311+ Q_EMIT binaryFilesizeChanged();
312+ }
313 }
314
315 void Update::setIconUrl(QString icon) {
316- m_icon_url = icon;
317- Q_EMIT iconUrlChanged();
318+ if (m_icon_url != icon) {
319+ m_icon_url = icon;
320+ Q_EMIT iconUrlChanged();
321+ }
322 }
323
324 void Update::setLastUpdateDate(const QString date)
325 {
326- m_lastUpdateDate = date;
327- Q_EMIT lastUpdateDateChanged();
328+ if (m_lastUpdateDate != date) {
329+ m_lastUpdateDate = date;
330+ Q_EMIT lastUpdateDateChanged();
331+ }
332 }
333
334 void Update::setDownloadProgress(int progress)
335 {
336- m_download_progress = progress;
337- Q_EMIT downloadProgressChanged();
338+ if (m_download_progress != progress) {
339+ m_download_progress = progress;
340+ Q_EMIT downloadProgressChanged();
341+ }
342 }
343
344 void Update::setDownloadUrl(const QString &url) {
345- m_downloadUrl = url;
346- Q_EMIT downloadUrlChanged();
347+ if (m_downloadUrl != url) {
348+ m_downloadUrl = url;
349+ Q_EMIT downloadUrlChanged();
350+ }
351 }
352
353 bool Update::getIgnoreUpdates()

Subscribers

People subscribed via source and target branches