Merge lp:~mandel/click-update-manager/downloader-new-api into lp:~diegosarmentero/click-update-manager/trunk

Proposed by Manuel de la Peña
Status: Approved
Approved by: Diego Sarmentero
Approved revision: 9
Proposed branch: lp:~mandel/click-update-manager/downloader-new-api
Merge into: lp:~diegosarmentero/click-update-manager/trunk
Diff against target: 484 lines (+368/-13)
8 files modified
clickmanager_plugin/clickmanager.pro (+6/-2)
clickmanager_plugin/download/download_struct.cpp (+121/-0)
clickmanager_plugin/download/download_struct.h (+71/-0)
clickmanager_plugin/download/downloader.cpp (+5/-1)
clickmanager_plugin/download/downloadmanager.cpp (+1/-1)
clickmanager_plugin/download/downloadmanager.h (+10/-9)
clickmanager_plugin/download/group_download_struct.cpp (+95/-0)
clickmanager_plugin/download/group_download_struct.h (+59/-0)
To merge this branch: bzr merge lp:~mandel/click-update-manager/downloader-new-api
Reviewer Review Type Date Requested Status
Diego Sarmentero Approve
Review via email: mp+183630@code.launchpad.net

Commit message

Add support for the new download manager api.

Description of the change

Adds support for the download manager API that will be landed in the following branch: lp:~mandel/ubuntu-download-manager/change-api

To post a comment you must log in.
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve

Unmerged revisions

9. By Manuel de la Peña

Added support for the new download manager api.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'clickmanager_plugin/clickmanager.pro'
2--- clickmanager_plugin/clickmanager.pro 2013-08-28 14:43:05 +0000
3+++ clickmanager_plugin/clickmanager.pro 2013-09-03 11:06:52 +0000
4@@ -15,7 +15,9 @@
5 download/downloader.cpp \
6 download/downloadmanager.cpp \
7 download/downloadtrackeradaptor.cpp \
8- download_tracker.cpp
9+ download_tracker.cpp \
10+ download/download_struct.cpp \
11+ download/group_download_struct.cpp
12
13 HEADERS += \
14 clickmanager_plugin.h \
15@@ -26,7 +28,9 @@
16 download/downloadmanager.h \
17 download/metatypes.h \
18 download/downloadtrackeradaptor.h \
19- download_tracker.h
20+ download_tracker.h \
21+ download/download_struct.h \
22+ download/group_download_struct.h
23
24 OTHER_FILES = qmldir
25
26
27=== added file 'clickmanager_plugin/download/download_struct.cpp'
28--- clickmanager_plugin/download/download_struct.cpp 1970-01-01 00:00:00 +0000
29+++ clickmanager_plugin/download/download_struct.cpp 2013-09-03 11:06:52 +0000
30@@ -0,0 +1,121 @@
31+/*
32+ * Copyright 2013 2013 Canonical Ltd.
33+ *
34+ * This library is free software; you can redistribute it and/or
35+ * modify it under the terms of version 3 of the GNU Lesser General Public
36+ * License as published by the Free Software Foundation.
37+ *
38+ * This program is distributed in the hope that it will be useful,
39+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
40+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41+ * General Public License for more details.
42+ *
43+ * You should have received a copy of the GNU Lesser General Public
44+ * License along with this library; if not, write to the
45+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
46+ * Boston, MA 02110-1301, USA.
47+ */
48+
49+#include "./download_struct.h"
50+
51+DownloadStruct::DownloadStruct()
52+ : _url(""),
53+ _hash(""),
54+ _algorithm(""),
55+ _metadata(),
56+ _headers() {
57+}
58+
59+DownloadStruct::DownloadStruct(const QString& url,
60+ const QVariantMap& metadata,
61+ const QMap<QString, QString>& headers)
62+ : _url(url),
63+ _hash(""),
64+ _algorithm(""),
65+ _metadata(metadata),
66+ _headers(headers) {
67+}
68+
69+DownloadStruct::DownloadStruct(const QString& url,
70+ const QString& hash,
71+ const QString& algorithm,
72+ const QVariantMap& metadata,
73+ const QMap<QString, QString>& headers)
74+ : _url(url),
75+ _hash(hash),
76+ _algorithm(algorithm),
77+ _metadata(metadata),
78+ _headers(headers) {
79+}
80+
81+DownloadStruct::DownloadStruct(const DownloadStruct& other)
82+ : _url(other._url),
83+ _hash(other._hash),
84+ _algorithm(other._algorithm),
85+ _metadata(other._metadata),
86+ _headers(other._headers) {
87+}
88+
89+DownloadStruct& DownloadStruct::operator=(const DownloadStruct& other) {
90+ _url = other._url;
91+ _hash = other._hash;
92+ _algorithm = other._algorithm;
93+ _metadata = other._metadata;
94+ _headers = other._headers;
95+
96+ return *this;
97+}
98+
99+DownloadStruct::~DownloadStruct() {
100+}
101+
102+QDBusArgument &operator<<(QDBusArgument &argument,
103+ const DownloadStruct& download) {
104+ argument.beginStructure();
105+ argument << download._url;
106+ argument << download._hash;
107+ argument << download._algorithm;
108+ argument << download._metadata;
109+ argument << download._headers;
110+ argument.endStructure();
111+
112+ return argument;
113+}
114+
115+const QDBusArgument &operator>>(const QDBusArgument &argument,
116+ DownloadStruct& download) {
117+ argument.beginStructure();
118+ argument >> download._url;
119+ argument >> download._hash;
120+ argument >> download._algorithm;
121+ argument >> download._metadata;
122+ argument >> download._headers;
123+ argument.endStructure();
124+
125+ return argument;
126+}
127+
128+QString
129+DownloadStruct::getUrl() {
130+ return _url;
131+}
132+
133+QString
134+DownloadStruct::getHash() {
135+ return _hash;
136+}
137+
138+QString
139+DownloadStruct::getAlgorithm() {
140+ return _algorithm;
141+}
142+
143+QVariantMap
144+DownloadStruct::getMetadata() {
145+ return _metadata;
146+}
147+
148+QMap<QString, QString>
149+DownloadStruct::getHeaders() {
150+ return _headers;
151+}
152
153=== added file 'clickmanager_plugin/download/download_struct.h'
154--- clickmanager_plugin/download/download_struct.h 1970-01-01 00:00:00 +0000
155+++ clickmanager_plugin/download/download_struct.h 2013-09-03 11:06:52 +0000
156@@ -0,0 +1,71 @@
157+/*
158+ * Copyright 2013 Canonical Ltd.
159+ *
160+ * This library is free software; you can redistribute it and/or
161+ * modify it under the terms of version 3 of the GNU Lesser General Public
162+ * License as published by the Free Software Foundation.
163+ *
164+ * This program is distributed in the hope that it will be useful,
165+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
166+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
167+ * General Public License for more details.
168+ *
169+ * You should have received a copy of the GNU Lesser General Public
170+ * License along with this library; if not, write to the
171+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
172+ * Boston, MA 02110-1301, USA.
173+ */
174+
175+#ifndef DOWNLOAD_STRUCT_H
176+#define DOWNLOAD_STRUCT_H
177+
178+#include <QDBusArgument>
179+#include <QMap>
180+#include <QString>
181+#include <QVariantMap>
182+
183+typedef QMap<QString, QString> StringList;
184+class DownloadStruct {
185+ Q_PROPERTY(QString url READ getUrl)
186+ Q_PROPERTY(QString hash READ getHash)
187+ Q_PROPERTY(QString algorithm READ getAlgorithm)
188+ Q_PROPERTY(QVariantMap metadata READ getMetadata)
189+ Q_PROPERTY(StringList headers READ getHeaders)
190+
191+ public:
192+ DownloadStruct();
193+ DownloadStruct(const QString& url,
194+ const QVariantMap& metadata,
195+ const QMap<QString, QString>& headers);
196+ DownloadStruct(const QString& url,
197+ const QString& hash,
198+ const QString& algorithm,
199+ const QVariantMap& metadata,
200+ const QMap<QString, QString>& headers);
201+ DownloadStruct(const DownloadStruct& other);
202+ DownloadStruct& operator=(const DownloadStruct& other);
203+ ~DownloadStruct();
204+
205+ friend QDBusArgument &operator<<(QDBusArgument &argument,
206+ const DownloadStruct& download);
207+ friend const QDBusArgument &operator>>(const QDBusArgument &argument,
208+ DownloadStruct& download);
209+
210+ // properties getters
211+ QString getUrl();
212+ QString getHash();
213+ QString getAlgorithm();
214+ QVariantMap getMetadata();
215+ QMap<QString, QString> getHeaders();
216+
217+ private:
218+ QString _url;
219+ QString _hash;
220+ QString _algorithm;
221+ QVariantMap _metadata;
222+ QMap<QString, QString> _headers;
223+};
224+
225+Q_DECLARE_METATYPE(GroupDownloadStruct)
226+
227+#endif // DOWNLOAD_STRUCT_H
228
229=== modified file 'clickmanager_plugin/download/downloader.cpp'
230--- clickmanager_plugin/download/downloader.cpp 2013-08-28 14:29:54 +0000
231+++ clickmanager_plugin/download/downloader.cpp 2013-09-03 11:06:52 +0000
232@@ -6,6 +6,9 @@
233 QObject(parent)
234 {
235 qDBusRegisterMetaType<StringMap>();
236+ qDBusRegisterMetaType<DownloadStruct>();
237+ qDBusRegisterMetaType<GroupDownloadStruct>();
238+ qDBusRegisterMetaType<StructList>();
239 this->manager = new DownloadManager("com.canonical.applications.Downloader", "/", QDBusConnection::sessionBus(), 0);
240 }
241
242@@ -13,7 +16,8 @@
243 {
244 QVariantMap vmap;
245 StringMap map;
246- QDBusPendingReply<QDBusObjectPath> reply = this->manager->createDownload(url, vmap, map);
247+ DownloadStruct down = DownloadStruct(url, vmap, map);
248+ QDBusPendingReply<QDBusObjectPath> reply = this->manager->createDownload(down);
249 reply.waitForFinished();
250 if (reply.isError()) {
251 emit this->downloadNotCreated(packagename);
252
253=== modified file 'clickmanager_plugin/download/downloadmanager.cpp'
254--- clickmanager_plugin/download/downloadmanager.cpp 2013-08-28 14:29:54 +0000
255+++ clickmanager_plugin/download/downloadmanager.cpp 2013-09-03 11:06:52 +0000
256@@ -1,6 +1,6 @@
257 /*
258 * This file was generated by qdbusxml2cpp version 0.8
259- * Command line was: qdbusxml2cpp -v -c DownloadManager -p downloadmanager.h:downloadmanager.cpp -i metatypes.h com.canonical.applications.download_manager.xml
260+ * Command line was: qdbusxml2cpp -c DownloadManager -p downloadmanager.h:downloadmanager.cpp -i download_struct.h -i group_download_struct.h com.canonical.applications.download_manager.xml
261 *
262 * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
263 *
264
265=== modified file 'clickmanager_plugin/download/downloadmanager.h'
266--- clickmanager_plugin/download/downloadmanager.h 2013-08-28 14:29:54 +0000
267+++ clickmanager_plugin/download/downloadmanager.h 2013-09-03 11:06:52 +0000
268@@ -1,6 +1,6 @@
269 /*
270 * This file was generated by qdbusxml2cpp version 0.8
271- * Command line was: qdbusxml2cpp -v -c DownloadManager -p downloadmanager.h:downloadmanager.cpp -i metatypes.h com.canonical.applications.download_manager.xml
272+ * Command line was: qdbusxml2cpp -c DownloadManager -p downloadmanager.h:downloadmanager.cpp -i download_struct.h -i group_download_struct.h com.canonical.applications.download_manager.xml
273 *
274 * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
275 *
276@@ -8,8 +8,8 @@
277 * Do not edit! All changes made to it will be lost.
278 */
279
280-#ifndef DOWNLOADMANAGER_H_1377691895
281-#define DOWNLOADMANAGER_H_1377691895
282+#ifndef DOWNLOADMANAGER_H_1378205505
283+#define DOWNLOADMANAGER_H_1378205505
284
285 #include <QtCore/QObject>
286 #include <QtCore/QByteArray>
287@@ -19,7 +19,8 @@
288 #include <QtCore/QStringList>
289 #include <QtCore/QVariant>
290 #include <QtDBus/QtDBus>
291-#include "metatypes.h"
292+#include "download_struct.h"
293+#include "group_download_struct.h"
294
295 /*
296 * Proxy class for interface com.canonical.applications.DownloaderManager
297@@ -44,18 +45,18 @@
298 return asyncCallWithArgumentList(QLatin1String("allowGSMDownload"), argumentList);
299 }
300
301- inline QDBusPendingReply<QDBusObjectPath> createDownload(const QString &url, const QVariantMap &metadata, StringMap headers)
302+ inline QDBusPendingReply<QDBusObjectPath> createDownload(DownloadStruct download)
303 {
304 QList<QVariant> argumentList;
305- argumentList << QVariant::fromValue(url) << QVariant::fromValue(metadata) << QVariant::fromValue(headers);
306+ argumentList << QVariant::fromValue(download);
307 return asyncCallWithArgumentList(QLatin1String("createDownload"), argumentList);
308 }
309
310- inline QDBusPendingReply<QDBusObjectPath> createDownloadWithHash(const QString &url, const QString &algorithm, const QString &hash, const QVariantMap &metadata, StringMap headers)
311+ inline QDBusPendingReply<QDBusObjectPath> createDownloadGroup(StructList downloads, const QString &algorithm, bool allowed3G, const QVariantMap &metadata, StringMap headers)
312 {
313 QList<QVariant> argumentList;
314- argumentList << QVariant::fromValue(url) << QVariant::fromValue(algorithm) << QVariant::fromValue(hash) << QVariant::fromValue(metadata) << QVariant::fromValue(headers);
315- return asyncCallWithArgumentList(QLatin1String("createDownloadWithHash"), argumentList);
316+ argumentList << QVariant::fromValue(downloads) << QVariant::fromValue(algorithm) << QVariant::fromValue(allowed3G) << QVariant::fromValue(metadata) << QVariant::fromValue(headers);
317+ return asyncCallWithArgumentList(QLatin1String("createDownloadGroup"), argumentList);
318 }
319
320 inline QDBusPendingReply<qulonglong> defaultThrottle()
321
322=== added file 'clickmanager_plugin/download/group_download_struct.cpp'
323--- clickmanager_plugin/download/group_download_struct.cpp 1970-01-01 00:00:00 +0000
324+++ clickmanager_plugin/download/group_download_struct.cpp 2013-09-03 11:06:52 +0000
325@@ -0,0 +1,95 @@
326+/*
327+ * copyright 2013 2013 canonical ltd.
328+ *
329+ * this library is free software; you can redistribute it and/or
330+ * modify it under the terms of version 3 of the gnu lesser general public
331+ * license as published by the free software foundation.
332+ *
333+ * this program is distributed in the hope that it will be useful,
334+ * but without any warranty; without even the implied warranty of
335+ * merchantability or fitness for a particular purpose. see the gnu
336+ * general public license for more details.
337+ *
338+ * you should have received a copy of the gnu lesser general public
339+ * license along with this library; if not, write to the
340+ * free software foundation, inc., 51 franklin street, fifth floor,
341+ * boston, ma 02110-1301, usa.
342+ */
343+
344+#include <QDBusMetaType>
345+#include "./hash_algorithm.h"
346+#include "./group_download_struct.h"
347+
348+GroupDownloadStruct::GroupDownloadStruct()
349+ : _url(""),
350+ _hash("") {
351+}
352+
353+GroupDownloadStruct::GroupDownloadStruct(const QString& url,
354+ const QString& localFile,
355+ const QString& hash)
356+ : _url(url),
357+ _localFile(localFile),
358+ _hash(hash) {
359+}
360+
361+GroupDownloadStruct::GroupDownloadStruct(const GroupDownloadStruct& other)
362+ : _url(other._url),
363+ _localFile(other._localFile),
364+ _hash(other._hash) {
365+}
366+
367+GroupDownloadStruct& GroupDownloadStruct::operator=(
368+ const GroupDownloadStruct& other) {
369+ _url = other._url;
370+ _localFile = other._localFile;
371+ _hash = other._hash;
372+
373+ return *this;
374+}
375+
376+GroupDownloadStruct::~GroupDownloadStruct() {
377+}
378+
379+
380+QDBusArgument &operator<<(QDBusArgument& argument,
381+ const GroupDownloadStruct& group) {
382+ argument.beginStructure();
383+ argument << group._url;
384+ argument << group._localFile;
385+ argument << group._hash;
386+ argument.endStructure();
387+
388+ return argument;
389+}
390+
391+const QDBusArgument &operator>>(const QDBusArgument& argument,
392+ GroupDownloadStruct& group) {
393+ argument.beginStructure();
394+ argument >> group._url;
395+ argument >> group._localFile;
396+ argument >> group._hash;
397+ argument.endStructure();
398+
399+ return argument;
400+}
401+
402+void GroupDownloadStruct::registerMetaType() {
403+ qRegisterMetaType<GroupDownloadStruct>("GroupDownloadStruct");
404+ qDBusRegisterMetaType<GroupDownloadStruct>();
405+}
406+
407+QString
408+GroupDownloadStruct::getUrl() {
409+ return _url;
410+}
411+
412+QString
413+GroupDownloadStruct::getHash() {
414+ return _hash;
415+}
416+
417+QString
418+GroupDownloadStruct::getLocalFile() {
419+ return _localFile;
420+}
421
422=== added file 'clickmanager_plugin/download/group_download_struct.h'
423--- clickmanager_plugin/download/group_download_struct.h 1970-01-01 00:00:00 +0000
424+++ clickmanager_plugin/download/group_download_struct.h 2013-09-03 11:06:52 +0000
425@@ -0,0 +1,59 @@
426+/*
427+ * Copyright 2013 Canonical Ltd.
428+ *
429+ * This library is free software; you can redistribute it and/or
430+ * modify it under the terms of version 3 of the GNU Lesser General Public
431+ * License as published by the Free Software Foundation.
432+ *
433+ * This program is distributed in the hope that it will be useful,
434+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
435+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
436+ * General Public License for more details.
437+ *
438+ * You should have received a copy of the GNU Lesser General Public
439+ * License along with this library; if not, write to the
440+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
441+ * Boston, MA 02110-1301, USA.
442+ */
443+
444+#ifndef GROUP_DOWNLOAD_STRUCT_H
445+#define GROUP_DOWNLOAD_STRUCT_H
446+
447+#include <QDBusArgument>
448+
449+typedef QList<GroupDownloadStruct> StructList;
450+class GroupDownloadStruct {
451+ Q_PROPERTY(QString url READ getUrl)
452+ Q_PROPERTY(QString hash READ getHash)
453+ Q_PROPERTY(QString localFile READ getLocalFile)
454+
455+ public:
456+ GroupDownloadStruct();
457+ GroupDownloadStruct(const QString& url, const QString& localFile,
458+ const QString& hash);
459+ GroupDownloadStruct(const GroupDownloadStruct& other);
460+ GroupDownloadStruct& operator=(const GroupDownloadStruct& other);
461+ ~GroupDownloadStruct();
462+
463+ friend QDBusArgument &operator<<(QDBusArgument &argument,
464+ const GroupDownloadStruct& group);
465+ friend const QDBusArgument &operator>>(const QDBusArgument &argument,
466+ GroupDownloadStruct& group);
467+
468+ // register Secret with the Qt type system
469+ static void registerMetaType();
470+
471+ // property getters
472+ QString getUrl();
473+ QString getHash();
474+ QString getLocalFile();
475+
476+ private:
477+ QString _url;
478+ QString _localFile;
479+ QString _hash;
480+};
481+
482+Q_DECLARE_METATYPE(GroupDownloadStruct)
483+
484+#endif //GROUP_DOWNLOAD_STRUCT_H

Subscribers

People subscribed via source and target branches