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

Proposed by Manuel de la Peña
Status: Merged
Approved by: Ken VanDine
Approved revision: 1259
Merged at revision: 1258
Proposed branch: lp:~mandel/ubuntu-system-settings/fix-pause
Merge into: lp:ubuntu-system-settings
Diff against target: 238 lines (+99/-51)
2 files modified
plugins/system-update/download_tracker.cpp (+39/-18)
plugins/system-update/update.cpp (+60/-33)
To merge this branch: bzr merge lp:~mandel/ubuntu-system-settings/fix-pause
Reviewer Review Type Date Requested Status
Ken VanDine Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+246367@code.launchpad.net

Commit message

Fix pause issue ensuring that it does pause the download.

Description of the change

Ensure that pause if done correctly.

To post a comment you must log in.
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 :

Please drop the debian/changelog entry. I also added an inline comment, just a style thing, not a must do.

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

Fix code following the reviews.

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 :

Thanks!

review: Approve

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-12-11 09:46:36 +0000
3+++ plugins/system-update/download_tracker.cpp 2015-01-15 10:11:59 +0000
4@@ -18,6 +18,7 @@
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@@ -74,8 +75,10 @@
13 if (m_manager == nullptr) {
14 m_manager = Manager::createSessionManager("", this);
15
16- QObject::connect(m_manager, SIGNAL(downloadCreated(Download*)),
17- this, SLOT(bindDownload(Download*)));
18+ if (!connect(m_manager, &Manager::downloadCreated,
19+ this, &DownloadTracker::bindDownload)) {
20+ qWarning() << "Could not connect to Manager::downloadCreated!";
21+ }
22 }
23 QVariantMap vmap;
24 QStringList args;
25@@ -93,22 +96,40 @@
26 void DownloadTracker::bindDownload(Download* download)
27 {
28 m_download = download;
29- connect(m_download, SIGNAL(finished(const QString &)), this,
30- SLOT(onDownloadFinished(const QString &)));
31- connect(m_download, SIGNAL(canceled(bool)), this,
32- SLOT(onDownloadCanceled(bool)));
33- connect(m_download, SIGNAL(paused(bool)), this,
34- SIGNAL(paused(bool)));
35- connect(m_download, SIGNAL(resumed(bool)), this,
36- SIGNAL(resumed(bool)));
37- connect(m_download, SIGNAL(started(bool)), this,
38- SIGNAL(started(bool)));
39- connect(m_download, SIGNAL(error(Error*)), this,
40- SLOT(registerError(Error*)));
41- connect(m_download, SIGNAL(progress(qulonglong, qulonglong)), this,
42- SLOT(setProgress(qulonglong, qulonglong)));
43- connect(m_download, SIGNAL(processing(const QString &)), this,
44- SIGNAL(processing(const QString &)));
45+ if (!connect(m_download, &Download::finished,
46+ this, &DownloadTracker::onDownloadFinished)) {
47+ qWarning() << "Could not connect to Download::finished";
48+ }
49+ if (!connect(m_download, &Download::canceled,
50+ this, &DownloadTracker::onDownloadCanceled)) {
51+ qWarning() << "Could not connect to Download::canceled";
52+ }
53+ if (!connect(m_download, &Download::paused,
54+ this, &DownloadTracker::paused)) {
55+ qWarning() << "Could not connect to Download::paused";
56+ }
57+ if (!connect(m_download, &Download::resumed,
58+ this, &DownloadTracker::resumed)) {
59+ qWarning() << "Could not connect to Download::resumed";
60+ }
61+ if (!connect(m_download, &Download::started,
62+ this, &DownloadTracker::started)) {
63+ qWarning() << "Could not connect to Download::started";
64+ }
65+ if (!connect(m_download, static_cast<void(Download::*)(Error*)>(&Download::error),
66+ this, &DownloadTracker::registerError)) {
67+ qWarning() << "Could not connect to Download::error";
68+ }
69+
70+ if (!connect(m_download, static_cast<void(Download::*)(qulonglong, qulonglong)>(&Download::progress),
71+ this, &DownloadTracker::setProgress)) {
72+ qWarning() << "Could not connect to Download::progress";
73+ }
74+
75+ if (!connect(m_download, &Download::processing,
76+ this, &DownloadTracker::processing)) {
77+ qWarning() << "Could not connect to Download::processing";
78+ }
79
80 m_download->start();
81 }
82
83=== modified file 'plugins/system-update/update.cpp'
84--- plugins/system-update/update.cpp 2014-09-12 23:47:39 +0000
85+++ plugins/system-update/update.cpp 2015-01-15 10:11:59 +0000
86@@ -18,10 +18,13 @@
87 *
88 */
89
90-#include "update.h"
91-#include <QStringList>
92 #include <apt-pkg/debversion.h>
93+
94+#include <QDebug>
95 #include <QProcessEnvironment>
96+#include <QStringList>
97+
98+#include "update.h"
99
100 namespace UpdatePlugin {
101
102@@ -64,81 +67,105 @@
103
104 void Update::setRemoteVersion(QString& version)
105 {
106- m_remote_version = version;
107- if (!getIgnoreUpdates()) {
108- int result = debVS.CmpVersion(m_local_version.toUtf8().data(),
109- m_remote_version.toUtf8().data());
110-
111- m_update = result < 0;
112- } else {
113- m_update = false;
114+ if (m_remote_version != version) {
115+ m_remote_version = version;
116+ if (!getIgnoreUpdates()) {
117+ int result = debVS.CmpVersion(m_local_version.toUtf8().data(),
118+ m_remote_version.toUtf8().data());
119+
120+ m_update = result < 0;
121+ } else {
122+ m_update = false;
123+ }
124 }
125 }
126
127 void Update::setError(QString error)
128 {
129- m_error = error;
130- if (!m_error.isEmpty()) {
131- Q_EMIT errorChanged();
132+ if (m_error != error) {
133+ m_error = error;
134+ if (!m_error.isEmpty()) {
135+ Q_EMIT errorChanged();
136+ }
137 }
138 }
139
140 void Update::setSystemUpdate(bool isSystem)
141 {
142- m_systemUpdate = isSystem;
143- Q_EMIT systemUpdateChanged();
144+ if (m_systemUpdate != isSystem) {
145+ m_systemUpdate = isSystem;
146+ Q_EMIT systemUpdateChanged();
147+ }
148 }
149
150 void Update::setUpdateRequired(bool state)
151 {
152- m_update = state;
153- Q_EMIT updateRequiredChanged();
154+ if (m_update != state) {
155+ m_update = state;
156+ Q_EMIT updateRequiredChanged();
157+ }
158 }
159
160 void Update::setUpdateState(bool state)
161 {
162- m_update_state = state;
163- Q_EMIT updateStateChanged();
164+ if (m_update_state != state) {
165+ m_update_state = state;
166+ Q_EMIT updateStateChanged();
167+ }
168 }
169
170 void Update::setUpdateReady(bool ready)
171 {
172- m_update_ready = ready;
173- Q_EMIT updateReadyChanged();
174+ if (m_update_ready != ready) {
175+ m_update_ready = ready;
176+ Q_EMIT updateReadyChanged();
177+ }
178 }
179
180 void Update::setSelected(bool value)
181 {
182- m_selected = value;
183- Q_EMIT selectedChanged();
184+ if (m_selected != value) {
185+ m_selected = value;
186+ Q_EMIT selectedChanged();
187+ }
188 }
189
190 void Update::setBinaryFilesize(int size)
191 {
192- m_binary_filesize = size;
193- Q_EMIT binaryFilesizeChanged();
194+ if (m_binary_filesize != size) {
195+ m_binary_filesize = size;
196+ Q_EMIT binaryFilesizeChanged();
197+ }
198 }
199
200 void Update::setIconUrl(QString icon) {
201- m_icon_url = icon;
202- Q_EMIT iconUrlChanged();
203+ if (m_icon_url != icon) {
204+ m_icon_url = icon;
205+ Q_EMIT iconUrlChanged();
206+ }
207 }
208
209 void Update::setLastUpdateDate(const QString date)
210 {
211- m_lastUpdateDate = date;
212- Q_EMIT lastUpdateDateChanged();
213+ if (m_lastUpdateDate != date) {
214+ m_lastUpdateDate = date;
215+ Q_EMIT lastUpdateDateChanged();
216+ }
217 }
218
219 void Update::setDownloadProgress(int progress)
220 {
221- m_download_progress = progress;
222- Q_EMIT downloadProgressChanged();
223+ if (m_download_progress != progress) {
224+ m_download_progress = progress;
225+ Q_EMIT downloadProgressChanged();
226+ }
227 }
228
229 void Update::setDownloadUrl(const QString &url) {
230- m_downloadUrl = url;
231- Q_EMIT downloadUrlChanged();
232+ if (m_downloadUrl != url) {
233+ m_downloadUrl = url;
234+ Q_EMIT downloadUrlChanged();
235+ }
236 }
237
238 bool Update::getIgnoreUpdates()

Subscribers

People subscribed via source and target branches