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
=== modified file 'plugins/system-update/download_tracker.cpp'
--- plugins/system-update/download_tracker.cpp 2014-12-11 09:46:36 +0000
+++ plugins/system-update/download_tracker.cpp 2015-01-15 10:11:59 +0000
@@ -18,6 +18,7 @@
18 * Authored by: Diego Sarmentero <diego.sarmentero@canonical.com>18 * Authored by: Diego Sarmentero <diego.sarmentero@canonical.com>
19 */19 */
2020
21#include <QDebug>
21#include <QProcessEnvironment>22#include <QProcessEnvironment>
2223
23#include <ubuntu/download_manager/download_struct.h>24#include <ubuntu/download_manager/download_struct.h>
@@ -74,8 +75,10 @@
74 if (m_manager == nullptr) {75 if (m_manager == nullptr) {
75 m_manager = Manager::createSessionManager("", this);76 m_manager = Manager::createSessionManager("", this);
7677
77 QObject::connect(m_manager, SIGNAL(downloadCreated(Download*)),78 if (!connect(m_manager, &Manager::downloadCreated,
78 this, SLOT(bindDownload(Download*)));79 this, &DownloadTracker::bindDownload)) {
80 qWarning() << "Could not connect to Manager::downloadCreated!";
81 }
79 }82 }
80 QVariantMap vmap;83 QVariantMap vmap;
81 QStringList args;84 QStringList args;
@@ -93,22 +96,40 @@
93void DownloadTracker::bindDownload(Download* download)96void DownloadTracker::bindDownload(Download* download)
94{97{
95 m_download = download;98 m_download = download;
96 connect(m_download, SIGNAL(finished(const QString &)), this,99 if (!connect(m_download, &Download::finished,
97 SLOT(onDownloadFinished(const QString &)));100 this, &DownloadTracker::onDownloadFinished)) {
98 connect(m_download, SIGNAL(canceled(bool)), this,101 qWarning() << "Could not connect to Download::finished";
99 SLOT(onDownloadCanceled(bool)));102 }
100 connect(m_download, SIGNAL(paused(bool)), this,103 if (!connect(m_download, &Download::canceled,
101 SIGNAL(paused(bool)));104 this, &DownloadTracker::onDownloadCanceled)) {
102 connect(m_download, SIGNAL(resumed(bool)), this,105 qWarning() << "Could not connect to Download::canceled";
103 SIGNAL(resumed(bool)));106 }
104 connect(m_download, SIGNAL(started(bool)), this,107 if (!connect(m_download, &Download::paused,
105 SIGNAL(started(bool)));108 this, &DownloadTracker::paused)) {
106 connect(m_download, SIGNAL(error(Error*)), this,109 qWarning() << "Could not connect to Download::paused";
107 SLOT(registerError(Error*)));110 }
108 connect(m_download, SIGNAL(progress(qulonglong, qulonglong)), this,111 if (!connect(m_download, &Download::resumed,
109 SLOT(setProgress(qulonglong, qulonglong)));112 this, &DownloadTracker::resumed)) {
110 connect(m_download, SIGNAL(processing(const QString &)), this,113 qWarning() << "Could not connect to Download::resumed";
111 SIGNAL(processing(const QString &)));114 }
115 if (!connect(m_download, &Download::started,
116 this, &DownloadTracker::started)) {
117 qWarning() << "Could not connect to Download::started";
118 }
119 if (!connect(m_download, static_cast<void(Download::*)(Error*)>(&Download::error),
120 this, &DownloadTracker::registerError)) {
121 qWarning() << "Could not connect to Download::error";
122 }
123
124 if (!connect(m_download, static_cast<void(Download::*)(qulonglong, qulonglong)>(&Download::progress),
125 this, &DownloadTracker::setProgress)) {
126 qWarning() << "Could not connect to Download::progress";
127 }
128
129 if (!connect(m_download, &Download::processing,
130 this, &DownloadTracker::processing)) {
131 qWarning() << "Could not connect to Download::processing";
132 }
112133
113 m_download->start();134 m_download->start();
114}135}
115136
=== modified file 'plugins/system-update/update.cpp'
--- plugins/system-update/update.cpp 2014-09-12 23:47:39 +0000
+++ plugins/system-update/update.cpp 2015-01-15 10:11:59 +0000
@@ -18,10 +18,13 @@
18 *18 *
19*/19*/
2020
21#include "update.h"
22#include <QStringList>
23#include <apt-pkg/debversion.h>21#include <apt-pkg/debversion.h>
22
23#include <QDebug>
24#include <QProcessEnvironment>24#include <QProcessEnvironment>
25#include <QStringList>
26
27#include "update.h"
2528
26namespace UpdatePlugin {29namespace UpdatePlugin {
2730
@@ -64,81 +67,105 @@
6467
65void Update::setRemoteVersion(QString& version)68void Update::setRemoteVersion(QString& version)
66{69{
67 m_remote_version = version;70 if (m_remote_version != version) {
68 if (!getIgnoreUpdates()) {71 m_remote_version = version;
69 int result = debVS.CmpVersion(m_local_version.toUtf8().data(),72 if (!getIgnoreUpdates()) {
70 m_remote_version.toUtf8().data());73 int result = debVS.CmpVersion(m_local_version.toUtf8().data(),
7174 m_remote_version.toUtf8().data());
72 m_update = result < 0;75
73 } else {76 m_update = result < 0;
74 m_update = false;77 } else {
78 m_update = false;
79 }
75 }80 }
76}81}
7782
78void Update::setError(QString error)83void Update::setError(QString error)
79{84{
80 m_error = error;85 if (m_error != error) {
81 if (!m_error.isEmpty()) {86 m_error = error;
82 Q_EMIT errorChanged();87 if (!m_error.isEmpty()) {
88 Q_EMIT errorChanged();
89 }
83 }90 }
84}91}
8592
86void Update::setSystemUpdate(bool isSystem)93void Update::setSystemUpdate(bool isSystem)
87{94{
88 m_systemUpdate = isSystem;95 if (m_systemUpdate != isSystem) {
89 Q_EMIT systemUpdateChanged();96 m_systemUpdate = isSystem;
97 Q_EMIT systemUpdateChanged();
98 }
90}99}
91100
92void Update::setUpdateRequired(bool state)101void Update::setUpdateRequired(bool state)
93{102{
94 m_update = state;103 if (m_update != state) {
95 Q_EMIT updateRequiredChanged();104 m_update = state;
105 Q_EMIT updateRequiredChanged();
106 }
96}107}
97108
98void Update::setUpdateState(bool state)109void Update::setUpdateState(bool state)
99{110{
100 m_update_state = state;111 if (m_update_state != state) {
101 Q_EMIT updateStateChanged();112 m_update_state = state;
113 Q_EMIT updateStateChanged();
114 }
102}115}
103116
104void Update::setUpdateReady(bool ready)117void Update::setUpdateReady(bool ready)
105{118{
106 m_update_ready = ready;119 if (m_update_ready != ready) {
107 Q_EMIT updateReadyChanged();120 m_update_ready = ready;
121 Q_EMIT updateReadyChanged();
122 }
108}123}
109124
110void Update::setSelected(bool value)125void Update::setSelected(bool value)
111{126{
112 m_selected = value;127 if (m_selected != value) {
113 Q_EMIT selectedChanged();128 m_selected = value;
129 Q_EMIT selectedChanged();
130 }
114}131}
115132
116void Update::setBinaryFilesize(int size)133void Update::setBinaryFilesize(int size)
117{134{
118 m_binary_filesize = size;135 if (m_binary_filesize != size) {
119 Q_EMIT binaryFilesizeChanged();136 m_binary_filesize = size;
137 Q_EMIT binaryFilesizeChanged();
138 }
120}139}
121140
122void Update::setIconUrl(QString icon) {141void Update::setIconUrl(QString icon) {
123 m_icon_url = icon;142 if (m_icon_url != icon) {
124 Q_EMIT iconUrlChanged();143 m_icon_url = icon;
144 Q_EMIT iconUrlChanged();
145 }
125}146}
126147
127void Update::setLastUpdateDate(const QString date)148void Update::setLastUpdateDate(const QString date)
128{149{
129 m_lastUpdateDate = date;150 if (m_lastUpdateDate != date) {
130 Q_EMIT lastUpdateDateChanged();151 m_lastUpdateDate = date;
152 Q_EMIT lastUpdateDateChanged();
153 }
131}154}
132155
133void Update::setDownloadProgress(int progress)156void Update::setDownloadProgress(int progress)
134{157{
135 m_download_progress = progress;158 if (m_download_progress != progress) {
136 Q_EMIT downloadProgressChanged();159 m_download_progress = progress;
160 Q_EMIT downloadProgressChanged();
161 }
137}162}
138163
139void Update::setDownloadUrl(const QString &url) {164void Update::setDownloadUrl(const QString &url) {
140 m_downloadUrl = url;165 if (m_downloadUrl != url) {
141 Q_EMIT downloadUrlChanged();166 m_downloadUrl = url;
167 Q_EMIT downloadUrlChanged();
168 }
142}169}
143170
144bool Update::getIgnoreUpdates()171bool Update::getIgnoreUpdates()

Subscribers

People subscribed via source and target branches