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
=== modified file 'plugins/system-update/download_tracker.cpp'
--- plugins/system-update/download_tracker.cpp 2014-09-30 02:05:36 +0000
+++ plugins/system-update/download_tracker.cpp 2015-01-20 12:17:55 +0000
@@ -18,22 +18,27 @@
18 * Authored by: Diego Sarmentero <diego.sarmentero@canonical.com>18 * Authored by: Diego Sarmentero <diego.sarmentero@canonical.com>
19 */19 */
2020
21#include <QDebug>
22#include <QProcessEnvironment>
23
24#include <ubuntu/download_manager/download_struct.h>
25#include <ubuntu/download_manager/error.h>
26
21#include "download_tracker.h"27#include "download_tracker.h"
22#include "network/network.h"28#include "network/network.h"
23#include <ubuntu/download_manager/download_struct.h>
24#include <ubuntu/download_manager/error.h>
25#include <QProcessEnvironment>
2629
27#define DOWNLOAD_COMMAND "post-download-command"30namespace {
28#define APP_ID "app_id"31 const QString DOWNLOAD_COMMAND = "post-download-command";
29#define PKCON_COMMAND "pkcon"32 const QString APP_ID = "app_id";
33 const QString PKCON_COMMAND = "pkcon";
34}
3035
31namespace UpdatePlugin {36namespace UpdatePlugin {
3237
33DownloadTracker::DownloadTracker(QObject *parent) :38DownloadTracker::DownloadTracker(QObject *parent) :
34 QObject(parent),39 QObject(parent),
35 m_clickToken(""),40 m_clickToken(QString::null),
36 m_downloadUrl(""),41 m_downloadUrl(QString::null),
37 m_download(nullptr),42 m_download(nullptr),
38 m_manager(nullptr),43 m_manager(nullptr),
39 m_progress(0)44 m_progress(0)
@@ -42,7 +47,7 @@
4247
43void DownloadTracker::setDownload(const QString& url)48void DownloadTracker::setDownload(const QString& url)
44{49{
45 if (url != "") {50 if (!url.isEmpty()) {
46 m_downloadUrl = url;51 m_downloadUrl = url;
47 startService();52 startService();
48 }53 }
@@ -50,7 +55,7 @@
5055
51void DownloadTracker::setClickToken(const QString& token)56void DownloadTracker::setClickToken(const QString& token)
52{57{
53 if (token != "") {58 if (!token.isEmpty()) {
54 m_clickToken = token;59 m_clickToken = token;
55 startService();60 startService();
56 }61 }
@@ -58,7 +63,7 @@
5863
59void DownloadTracker::setPackageName(const QString& package)64void DownloadTracker::setPackageName(const QString& package)
60{65{
61 if (package != "") {66 if (!package.isEmpty()) {
62 m_packageName = package;67 m_packageName = package;
63 startService();68 startService();
64 }69 }
@@ -70,8 +75,10 @@
70 if (m_manager == nullptr) {75 if (m_manager == nullptr) {
71 m_manager = Manager::createSessionManager("", this);76 m_manager = Manager::createSessionManager("", this);
7277
73 QObject::connect(m_manager, SIGNAL(downloadCreated(Download*)),78 if (!connect(m_manager, &Manager::downloadCreated,
74 this, SLOT(bindDownload(Download*)));79 this, &DownloadTracker::bindDownload)) {
80 qWarning() << "Could not connect to Manager::downloadCreated!";
81 }
75 }82 }
76 QVariantMap vmap;83 QVariantMap vmap;
77 QStringList args;84 QStringList args;
@@ -89,22 +96,40 @@
89void DownloadTracker::bindDownload(Download* download)96void DownloadTracker::bindDownload(Download* download)
90{97{
91 m_download = download;98 m_download = download;
92 connect(m_download, SIGNAL(finished(const QString &)), this,99 if (!connect(m_download, &Download::finished,
93 SIGNAL(finished(const QString &)));100 this, &DownloadTracker::onDownloadFinished)) {
94 connect(m_download, SIGNAL(canceled(bool)), this,101 qWarning() << "Could not connect to Download::finished";
95 SIGNAL(canceled(bool)));102 }
96 connect(m_download, SIGNAL(paused(bool)), this,103 if (!connect(m_download, &Download::canceled,
97 SIGNAL(paused(bool)));104 this, &DownloadTracker::onDownloadCanceled)) {
98 connect(m_download, SIGNAL(resumed(bool)), this,105 qWarning() << "Could not connect to Download::canceled";
99 SIGNAL(resumed(bool)));106 }
100 connect(m_download, SIGNAL(started(bool)), this,107 if (!connect(m_download, &Download::paused,
101 SIGNAL(started(bool)));108 this, &DownloadTracker::paused)) {
102 connect(m_download, SIGNAL(error(Error*)), this,109 qWarning() << "Could not connect to Download::paused";
103 SLOT(registerError(Error*)));110 }
104 connect(m_download, SIGNAL(progress(qulonglong, qulonglong)), this,111 if (!connect(m_download, &Download::resumed,
105 SLOT(setProgress(qulonglong, qulonglong)));112 this, &DownloadTracker::resumed)) {
106 connect(m_download, SIGNAL(processing(const QString &)), this,113 qWarning() << "Could not connect to Download::resumed";
107 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 }
108133
109 m_download->start();134 m_download->start();
110}135}
@@ -112,6 +137,27 @@
112void DownloadTracker::registerError(Error* error)137void DownloadTracker::registerError(Error* error)
113{138{
114 Q_EMIT errorFound(error->errorString());139 Q_EMIT errorFound(error->errorString());
140
141 // we need to ensure that the resources are cleaned
142 m_download->deleteLater();
143 m_download = nullptr;
144}
145
146void DownloadTracker::onDownloadFinished(const QString& path)
147{
148 // once a download is finished we need to clean the resources
149 m_download->deleteLater();
150 m_download = nullptr;
151 Q_EMIT finished(path);
152}
153
154void DownloadTracker::onDownloadCanceled(bool wasCanceled)
155{
156 if (wasCanceled) {
157 m_download->deleteLater();
158 m_download = nullptr;
159 }
160 Q_EMIT canceled(wasCanceled);
115}161}
116162
117void DownloadTracker::pause()163void DownloadTracker::pause()
118164
=== modified file 'plugins/system-update/download_tracker.h'
--- plugins/system-update/download_tracker.h 2014-09-30 02:05:36 +0000
+++ plugins/system-update/download_tracker.h 2015-01-20 12:17:55 +0000
@@ -63,6 +63,8 @@
63 void bindDownload(Download* download);63 void bindDownload(Download* download);
64 void setProgress(qulonglong received, qulonglong total);64 void setProgress(qulonglong received, qulonglong total);
65 void registerError(Ubuntu::DownloadManager::Error* error);65 void registerError(Ubuntu::DownloadManager::Error* error);
66 void onDownloadFinished(const QString& path);
67 void onDownloadCanceled(bool wasCanceled);
6668
67Q_SIGNALS:69Q_SIGNALS:
68 void error(const QString &errorMessage);70 void error(const QString &errorMessage);
@@ -76,12 +78,12 @@
76 void errorFound(const QString &error);78 void errorFound(const QString &error);
7779
78private:80private:
79 QString m_clickToken;81 QString m_clickToken = QString::null;
80 QString m_downloadUrl;82 QString m_downloadUrl = QString::null;
81 QString m_packageName;83 QString m_packageName = QString::null;
82 Download* m_download;84 Download* m_download = nullptr;
83 Manager* m_manager;85 Manager* m_manager = nullptr;
84 int m_progress;86 int m_progress = 0;
8587
86 void startService();88 void startService();
87 QString getPkconCommand();89 QString getPkconCommand();
8890
=== 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-20 12:17:55 +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