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
=== modified file 'clickmanager_plugin/clickmanager.pro'
--- clickmanager_plugin/clickmanager.pro 2013-08-28 14:43:05 +0000
+++ clickmanager_plugin/clickmanager.pro 2013-09-03 11:06:52 +0000
@@ -15,7 +15,9 @@
15 download/downloader.cpp \15 download/downloader.cpp \
16 download/downloadmanager.cpp \16 download/downloadmanager.cpp \
17 download/downloadtrackeradaptor.cpp \17 download/downloadtrackeradaptor.cpp \
18 download_tracker.cpp18 download_tracker.cpp \
19 download/download_struct.cpp \
20 download/group_download_struct.cpp
1921
20HEADERS += \22HEADERS += \
21 clickmanager_plugin.h \23 clickmanager_plugin.h \
@@ -26,7 +28,9 @@
26 download/downloadmanager.h \28 download/downloadmanager.h \
27 download/metatypes.h \29 download/metatypes.h \
28 download/downloadtrackeradaptor.h \30 download/downloadtrackeradaptor.h \
29 download_tracker.h31 download_tracker.h \
32 download/download_struct.h \
33 download/group_download_struct.h
3034
31OTHER_FILES = qmldir35OTHER_FILES = qmldir
3236
3337
=== added file 'clickmanager_plugin/download/download_struct.cpp'
--- clickmanager_plugin/download/download_struct.cpp 1970-01-01 00:00:00 +0000
+++ clickmanager_plugin/download/download_struct.cpp 2013-09-03 11:06:52 +0000
@@ -0,0 +1,121 @@
1/*
2 * Copyright 2013 2013 Canonical Ltd.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the GNU Lesser General Public
6 * License as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17 */
18
19#include "./download_struct.h"
20
21DownloadStruct::DownloadStruct()
22 : _url(""),
23 _hash(""),
24 _algorithm(""),
25 _metadata(),
26 _headers() {
27}
28
29DownloadStruct::DownloadStruct(const QString& url,
30 const QVariantMap& metadata,
31 const QMap<QString, QString>& headers)
32 : _url(url),
33 _hash(""),
34 _algorithm(""),
35 _metadata(metadata),
36 _headers(headers) {
37}
38
39DownloadStruct::DownloadStruct(const QString& url,
40 const QString& hash,
41 const QString& algorithm,
42 const QVariantMap& metadata,
43 const QMap<QString, QString>& headers)
44 : _url(url),
45 _hash(hash),
46 _algorithm(algorithm),
47 _metadata(metadata),
48 _headers(headers) {
49}
50
51DownloadStruct::DownloadStruct(const DownloadStruct& other)
52 : _url(other._url),
53 _hash(other._hash),
54 _algorithm(other._algorithm),
55 _metadata(other._metadata),
56 _headers(other._headers) {
57}
58
59DownloadStruct& DownloadStruct::operator=(const DownloadStruct& other) {
60 _url = other._url;
61 _hash = other._hash;
62 _algorithm = other._algorithm;
63 _metadata = other._metadata;
64 _headers = other._headers;
65
66 return *this;
67}
68
69DownloadStruct::~DownloadStruct() {
70}
71
72QDBusArgument &operator<<(QDBusArgument &argument,
73 const DownloadStruct& download) {
74 argument.beginStructure();
75 argument << download._url;
76 argument << download._hash;
77 argument << download._algorithm;
78 argument << download._metadata;
79 argument << download._headers;
80 argument.endStructure();
81
82 return argument;
83}
84
85const QDBusArgument &operator>>(const QDBusArgument &argument,
86 DownloadStruct& download) {
87 argument.beginStructure();
88 argument >> download._url;
89 argument >> download._hash;
90 argument >> download._algorithm;
91 argument >> download._metadata;
92 argument >> download._headers;
93 argument.endStructure();
94
95 return argument;
96}
97
98QString
99DownloadStruct::getUrl() {
100 return _url;
101}
102
103QString
104DownloadStruct::getHash() {
105 return _hash;
106}
107
108QString
109DownloadStruct::getAlgorithm() {
110 return _algorithm;
111}
112
113QVariantMap
114DownloadStruct::getMetadata() {
115 return _metadata;
116}
117
118QMap<QString, QString>
119DownloadStruct::getHeaders() {
120 return _headers;
121}
0122
=== added file 'clickmanager_plugin/download/download_struct.h'
--- clickmanager_plugin/download/download_struct.h 1970-01-01 00:00:00 +0000
+++ clickmanager_plugin/download/download_struct.h 2013-09-03 11:06:52 +0000
@@ -0,0 +1,71 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the GNU Lesser General Public
6 * License as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17 */
18
19#ifndef DOWNLOAD_STRUCT_H
20#define DOWNLOAD_STRUCT_H
21
22#include <QDBusArgument>
23#include <QMap>
24#include <QString>
25#include <QVariantMap>
26
27typedef QMap<QString, QString> StringList;
28class DownloadStruct {
29 Q_PROPERTY(QString url READ getUrl)
30 Q_PROPERTY(QString hash READ getHash)
31 Q_PROPERTY(QString algorithm READ getAlgorithm)
32 Q_PROPERTY(QVariantMap metadata READ getMetadata)
33 Q_PROPERTY(StringList headers READ getHeaders)
34
35 public:
36 DownloadStruct();
37 DownloadStruct(const QString& url,
38 const QVariantMap& metadata,
39 const QMap<QString, QString>& headers);
40 DownloadStruct(const QString& url,
41 const QString& hash,
42 const QString& algorithm,
43 const QVariantMap& metadata,
44 const QMap<QString, QString>& headers);
45 DownloadStruct(const DownloadStruct& other);
46 DownloadStruct& operator=(const DownloadStruct& other);
47 ~DownloadStruct();
48
49 friend QDBusArgument &operator<<(QDBusArgument &argument,
50 const DownloadStruct& download);
51 friend const QDBusArgument &operator>>(const QDBusArgument &argument,
52 DownloadStruct& download);
53
54 // properties getters
55 QString getUrl();
56 QString getHash();
57 QString getAlgorithm();
58 QVariantMap getMetadata();
59 QMap<QString, QString> getHeaders();
60
61 private:
62 QString _url;
63 QString _hash;
64 QString _algorithm;
65 QVariantMap _metadata;
66 QMap<QString, QString> _headers;
67};
68
69Q_DECLARE_METATYPE(GroupDownloadStruct)
70
71#endif // DOWNLOAD_STRUCT_H
072
=== modified file 'clickmanager_plugin/download/downloader.cpp'
--- clickmanager_plugin/download/downloader.cpp 2013-08-28 14:29:54 +0000
+++ clickmanager_plugin/download/downloader.cpp 2013-09-03 11:06:52 +0000
@@ -6,6 +6,9 @@
6 QObject(parent)6 QObject(parent)
7{7{
8 qDBusRegisterMetaType<StringMap>();8 qDBusRegisterMetaType<StringMap>();
9 qDBusRegisterMetaType<DownloadStruct>();
10 qDBusRegisterMetaType<GroupDownloadStruct>();
11 qDBusRegisterMetaType<StructList>();
9 this->manager = new DownloadManager("com.canonical.applications.Downloader", "/", QDBusConnection::sessionBus(), 0);12 this->manager = new DownloadManager("com.canonical.applications.Downloader", "/", QDBusConnection::sessionBus(), 0);
10}13}
1114
@@ -13,7 +16,8 @@
13{16{
14 QVariantMap vmap;17 QVariantMap vmap;
15 StringMap map;18 StringMap map;
16 QDBusPendingReply<QDBusObjectPath> reply = this->manager->createDownload(url, vmap, map);19 DownloadStruct down = DownloadStruct(url, vmap, map);
20 QDBusPendingReply<QDBusObjectPath> reply = this->manager->createDownload(down);
17 reply.waitForFinished();21 reply.waitForFinished();
18 if (reply.isError()) {22 if (reply.isError()) {
19 emit this->downloadNotCreated(packagename);23 emit this->downloadNotCreated(packagename);
2024
=== modified file 'clickmanager_plugin/download/downloadmanager.cpp'
--- clickmanager_plugin/download/downloadmanager.cpp 2013-08-28 14:29:54 +0000
+++ clickmanager_plugin/download/downloadmanager.cpp 2013-09-03 11:06:52 +0000
@@ -1,6 +1,6 @@
1/*1/*
2 * This file was generated by qdbusxml2cpp version 0.82 * This file was generated by qdbusxml2cpp version 0.8
3 * Command line was: qdbusxml2cpp -v -c DownloadManager -p downloadmanager.h:downloadmanager.cpp -i metatypes.h com.canonical.applications.download_manager.xml3 * 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
4 *4 *
5 * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).5 * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
6 *6 *
77
=== modified file 'clickmanager_plugin/download/downloadmanager.h'
--- clickmanager_plugin/download/downloadmanager.h 2013-08-28 14:29:54 +0000
+++ clickmanager_plugin/download/downloadmanager.h 2013-09-03 11:06:52 +0000
@@ -1,6 +1,6 @@
1/*1/*
2 * This file was generated by qdbusxml2cpp version 0.82 * This file was generated by qdbusxml2cpp version 0.8
3 * Command line was: qdbusxml2cpp -v -c DownloadManager -p downloadmanager.h:downloadmanager.cpp -i metatypes.h com.canonical.applications.download_manager.xml3 * 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
4 *4 *
5 * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).5 * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
6 *6 *
@@ -8,8 +8,8 @@
8 * Do not edit! All changes made to it will be lost.8 * Do not edit! All changes made to it will be lost.
9 */9 */
1010
11#ifndef DOWNLOADMANAGER_H_137769189511#ifndef DOWNLOADMANAGER_H_1378205505
12#define DOWNLOADMANAGER_H_137769189512#define DOWNLOADMANAGER_H_1378205505
1313
14#include <QtCore/QObject>14#include <QtCore/QObject>
15#include <QtCore/QByteArray>15#include <QtCore/QByteArray>
@@ -19,7 +19,8 @@
19#include <QtCore/QStringList>19#include <QtCore/QStringList>
20#include <QtCore/QVariant>20#include <QtCore/QVariant>
21#include <QtDBus/QtDBus>21#include <QtDBus/QtDBus>
22#include "metatypes.h"22#include "download_struct.h"
23#include "group_download_struct.h"
2324
24/*25/*
25 * Proxy class for interface com.canonical.applications.DownloaderManager26 * Proxy class for interface com.canonical.applications.DownloaderManager
@@ -44,18 +45,18 @@
44 return asyncCallWithArgumentList(QLatin1String("allowGSMDownload"), argumentList);45 return asyncCallWithArgumentList(QLatin1String("allowGSMDownload"), argumentList);
45 }46 }
4647
47 inline QDBusPendingReply<QDBusObjectPath> createDownload(const QString &url, const QVariantMap &metadata, StringMap headers)48 inline QDBusPendingReply<QDBusObjectPath> createDownload(DownloadStruct download)
48 {49 {
49 QList<QVariant> argumentList;50 QList<QVariant> argumentList;
50 argumentList << QVariant::fromValue(url) << QVariant::fromValue(metadata) << QVariant::fromValue(headers);51 argumentList << QVariant::fromValue(download);
51 return asyncCallWithArgumentList(QLatin1String("createDownload"), argumentList);52 return asyncCallWithArgumentList(QLatin1String("createDownload"), argumentList);
52 }53 }
5354
54 inline QDBusPendingReply<QDBusObjectPath> createDownloadWithHash(const QString &url, const QString &algorithm, const QString &hash, const QVariantMap &metadata, StringMap headers)55 inline QDBusPendingReply<QDBusObjectPath> createDownloadGroup(StructList downloads, const QString &algorithm, bool allowed3G, const QVariantMap &metadata, StringMap headers)
55 {56 {
56 QList<QVariant> argumentList;57 QList<QVariant> argumentList;
57 argumentList << QVariant::fromValue(url) << QVariant::fromValue(algorithm) << QVariant::fromValue(hash) << QVariant::fromValue(metadata) << QVariant::fromValue(headers);58 argumentList << QVariant::fromValue(downloads) << QVariant::fromValue(algorithm) << QVariant::fromValue(allowed3G) << QVariant::fromValue(metadata) << QVariant::fromValue(headers);
58 return asyncCallWithArgumentList(QLatin1String("createDownloadWithHash"), argumentList);59 return asyncCallWithArgumentList(QLatin1String("createDownloadGroup"), argumentList);
59 }60 }
6061
61 inline QDBusPendingReply<qulonglong> defaultThrottle()62 inline QDBusPendingReply<qulonglong> defaultThrottle()
6263
=== added file 'clickmanager_plugin/download/group_download_struct.cpp'
--- clickmanager_plugin/download/group_download_struct.cpp 1970-01-01 00:00:00 +0000
+++ clickmanager_plugin/download/group_download_struct.cpp 2013-09-03 11:06:52 +0000
@@ -0,0 +1,95 @@
1/*
2 * copyright 2013 2013 canonical ltd.
3 *
4 * this library is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the gnu lesser general public
6 * license as published by the free software foundation.
7 *
8 * this program is distributed in the hope that it will be useful,
9 * but without any warranty; without even the implied warranty of
10 * merchantability or fitness for a particular purpose. see the gnu
11 * general public license for more details.
12 *
13 * you should have received a copy of the gnu lesser general public
14 * license along with this library; if not, write to the
15 * free software foundation, inc., 51 franklin street, fifth floor,
16 * boston, ma 02110-1301, usa.
17 */
18
19#include <QDBusMetaType>
20#include "./hash_algorithm.h"
21#include "./group_download_struct.h"
22
23GroupDownloadStruct::GroupDownloadStruct()
24 : _url(""),
25 _hash("") {
26}
27
28GroupDownloadStruct::GroupDownloadStruct(const QString& url,
29 const QString& localFile,
30 const QString& hash)
31 : _url(url),
32 _localFile(localFile),
33 _hash(hash) {
34}
35
36GroupDownloadStruct::GroupDownloadStruct(const GroupDownloadStruct& other)
37 : _url(other._url),
38 _localFile(other._localFile),
39 _hash(other._hash) {
40}
41
42GroupDownloadStruct& GroupDownloadStruct::operator=(
43 const GroupDownloadStruct& other) {
44 _url = other._url;
45 _localFile = other._localFile;
46 _hash = other._hash;
47
48 return *this;
49}
50
51GroupDownloadStruct::~GroupDownloadStruct() {
52}
53
54
55QDBusArgument &operator<<(QDBusArgument& argument,
56 const GroupDownloadStruct& group) {
57 argument.beginStructure();
58 argument << group._url;
59 argument << group._localFile;
60 argument << group._hash;
61 argument.endStructure();
62
63 return argument;
64}
65
66const QDBusArgument &operator>>(const QDBusArgument& argument,
67 GroupDownloadStruct& group) {
68 argument.beginStructure();
69 argument >> group._url;
70 argument >> group._localFile;
71 argument >> group._hash;
72 argument.endStructure();
73
74 return argument;
75}
76
77void GroupDownloadStruct::registerMetaType() {
78 qRegisterMetaType<GroupDownloadStruct>("GroupDownloadStruct");
79 qDBusRegisterMetaType<GroupDownloadStruct>();
80}
81
82QString
83GroupDownloadStruct::getUrl() {
84 return _url;
85}
86
87QString
88GroupDownloadStruct::getHash() {
89 return _hash;
90}
91
92QString
93GroupDownloadStruct::getLocalFile() {
94 return _localFile;
95}
096
=== added file 'clickmanager_plugin/download/group_download_struct.h'
--- clickmanager_plugin/download/group_download_struct.h 1970-01-01 00:00:00 +0000
+++ clickmanager_plugin/download/group_download_struct.h 2013-09-03 11:06:52 +0000
@@ -0,0 +1,59 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of version 3 of the GNU Lesser General Public
6 * License as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the
15 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 * Boston, MA 02110-1301, USA.
17 */
18
19#ifndef GROUP_DOWNLOAD_STRUCT_H
20#define GROUP_DOWNLOAD_STRUCT_H
21
22#include <QDBusArgument>
23
24typedef QList<GroupDownloadStruct> StructList;
25class GroupDownloadStruct {
26 Q_PROPERTY(QString url READ getUrl)
27 Q_PROPERTY(QString hash READ getHash)
28 Q_PROPERTY(QString localFile READ getLocalFile)
29
30 public:
31 GroupDownloadStruct();
32 GroupDownloadStruct(const QString& url, const QString& localFile,
33 const QString& hash);
34 GroupDownloadStruct(const GroupDownloadStruct& other);
35 GroupDownloadStruct& operator=(const GroupDownloadStruct& other);
36 ~GroupDownloadStruct();
37
38 friend QDBusArgument &operator<<(QDBusArgument &argument,
39 const GroupDownloadStruct& group);
40 friend const QDBusArgument &operator>>(const QDBusArgument &argument,
41 GroupDownloadStruct& group);
42
43 // register Secret with the Qt type system
44 static void registerMetaType();
45
46 // property getters
47 QString getUrl();
48 QString getHash();
49 QString getLocalFile();
50
51 private:
52 QString _url;
53 QString _localFile;
54 QString _hash;
55};
56
57Q_DECLARE_METATYPE(GroupDownloadStruct)
58
59#endif //GROUP_DOWNLOAD_STRUCT_H

Subscribers

People subscribed via source and target branches