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