Merge lp:~mandel/ubuntu-download-manager/wily-add-appid-metadata into lp:ubuntu-download-manager

Proposed by Manuel de la Peña on 2015-08-27
Status: Merged
Approved by: Alfonso Sanchez-Beato on 2015-09-17
Approved revision: 347
Merged at revision: 341
Proposed branch: lp:~mandel/ubuntu-download-manager/wily-add-appid-metadata
Merge into: lp:ubuntu-download-manager
Diff against target: 881 lines (+309/-48)
22 files modified
CMakeLists.txt (+1/-1)
debian/changelog (+8/-0)
debian/libubuntu-download-manager-client1.symbols (+1/-3)
debian/libubuntu-download-manager-common1.symbols (+1/-2)
debian/libudm-common1.symbols (+5/-1)
debian/libudm-common1.symbols.powerpc (+2/-0)
docs/dbus/com.canonical.applications.download.xml (+2/-0)
src/common/public/ubuntu/transfers/metadata.cpp (+33/-0)
src/common/public/ubuntu/transfers/metadata.h (+6/-4)
src/downloads/client/ubuntu/download_manager/download.h (+18/-4)
src/downloads/client/ubuntu/download_manager/download_impl.cpp (+5/-0)
src/downloads/client/ubuntu/download_manager/download_impl.h (+1/-0)
src/downloads/client/ubuntu/download_manager/download_interface.cpp (+1/-1)
src/downloads/client/ubuntu/download_manager/download_interface.h (+22/-18)
src/downloads/priv/ubuntu/downloads/download.h (+14/-3)
src/downloads/priv/ubuntu/downloads/download_adaptor.cpp (+7/-1)
src/downloads/priv/ubuntu/downloads/download_adaptor.h (+7/-3)
src/downloads/priv/ubuntu/downloads/manager.cpp (+19/-0)
src/downloads/priv/ubuntu/downloads/manager.h (+2/-4)
tests/downloads/daemon/test_download_manager.cpp (+54/-0)
tests/downloads/daemon/test_metadata.cpp (+90/-0)
tests/downloads/daemon/test_metadata.h (+10/-3)
To merge this branch: bzr merge lp:~mandel/ubuntu-download-manager/wily-add-appid-metadata
Reviewer Review Type Date Requested Status
Alfonso Sanchez-Beato 2015-09-17 Approve on 2015-09-17
PS Jenkins bot continuous-integration Approve on 2015-09-03
Renato Araujo Oliveira Filho (community) 2015-08-27 Needs Fixing on 2015-08-31
Review via email: mp+269364@code.launchpad.net

Commit Message

Add the app id in the download metadata.

Description of the Change

Add the app id in the download metadata.

To post a comment you must log in.

Most of the coode looks good only a few inline commnents.

And Jenkins still not happy with some libraries symbols.

review: Needs Fixing
Manuel de la Peña (mandel) wrote :

Replied inline, but yes, all comments are valid. Sorry for the qDebug, I though I removed those.

345. By Manuel de la Peña on 2015-09-01

Update branch as per reviews.

346. By Manuel de la Peña on 2015-09-01

Use correct commiter.

347. By Manuel de la Peña on 2015-09-02

Made changes according to reviews.

review: Approve
348. By Manuel de la Peña on 2015-09-21

Rename metadata method as per reviews.

349. By Manuel de la Peña on 2015-09-21

Rename the client lib property.

350. By Manuel de la Peña on 2015-09-22

Update symbol files.

351. By Manuel de la Peña on 2015-09-22

Rename the property correctly.

352. By Manuel de la Peña on 2015-09-22

Rename setters and getters.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2015-07-23 14:02:27 +0000
3+++ CMakeLists.txt 2015-09-22 15:26:07 +0000
4@@ -31,7 +31,7 @@
5 )
6
7 set(UDM_VERSION_MAJOR 1)
8-set(UDM_VERSION_MINOR 0)
9+set(UDM_VERSION_MINOR 1)
10 set(UDM_VERSION_PATCH 0)
11
12 find_package(Gtest REQUIRED)
13
14=== modified file 'debian/changelog'
15--- debian/changelog 2015-07-24 16:44:28 +0000
16+++ debian/changelog 2015-09-22 15:26:07 +0000
17@@ -1,3 +1,11 @@
18+ubuntu-download-manager (1.1) UNRELEASED; urgency=medium
19+
20+ * Ensure that the app id of the application that created the download is
21+ present in the metadata and can be accessed via dbus.
22+ * Update the symbol files.
23+
24+ -- Manuel de la Pena <manuel.delapena@canonical.com> Tue, 01 Sep 2015 17:07:58 +0100
25+
26 ubuntu-download-manager (1.0+15.10.20150724-0ubuntu1) wily; urgency=medium
27
28 [ Manuel de la Pena ]
29
30=== modified file 'debian/libubuntu-download-manager-client1.symbols'
31--- debian/libubuntu-download-manager-client1.symbols 2015-07-24 16:44:28 +0000
32+++ debian/libubuntu-download-manager-client1.symbols 2015-09-22 15:26:07 +0000
33@@ -60,6 +60,7 @@
34 (c++)"Ubuntu::DownloadManager::Download::titleChanged()@Base" 0.9+14.10.20141014.1
35 (c++)"Ubuntu::DownloadManager::Download::clickPackagedChanged()@Base" 0.9+14.10.20141014.1
36 (c++)"Ubuntu::DownloadManager::Download::showInIndicatorChanged()@Base" 0.9+14.10.20141014.1
37+ (c++)"Ubuntu::DownloadManager::Download::destinationAppChanged()@Base" 0replaceme
38 (c++)"Ubuntu::DownloadManager::AuthError::errorString()@Base" 0.4+14.10.20140618
39 (c++)"Ubuntu::DownloadManager::AuthError::qt_metacall(QMetaObject::Call, int, void**)@Base" 0.4+14.10.20140618
40 (c++)"Ubuntu::DownloadManager::AuthError::qt_metacast(char const*)@Base" 0.4+14.10.20140618
41@@ -94,9 +95,6 @@
42 (c++)"Ubuntu::DownloadManager::AuthError::metaObject() const@Base" 0.4+14.10.20140618
43 (c++)"Ubuntu::DownloadManager::DBusError::metaObject() const@Base" 0.4+14.10.20140618
44 (c++)"Ubuntu::DownloadManager::HttpError::metaObject() const@Base" 0.4+14.10.20140618
45- (c++)"std::function<void (Ubuntu::DownloadManager::DownloadsList*)>::operator()(Ubuntu::DownloadManager::DownloadsList*) const@Base" 0.4+14.10.20140618
46- (c++)"std::function<void (Ubuntu::DownloadManager::GroupDownload*)>::operator()(Ubuntu::DownloadManager::GroupDownload*) const@Base" 0.4+14.10.20140618
47- (c++)"std::function<void (Ubuntu::DownloadManager::Download*)>::operator()(Ubuntu::DownloadManager::Download*) const@Base" 0.4+14.10.20140618
48 (c++)"std::function<void (Ubuntu::DownloadManager::DownloadsList*)>::function(std::function<void (Ubuntu::DownloadManager::DownloadsList*)> const&)@Base" 0.4+14.10.20140618
49 (c++)"std::function<void (Ubuntu::DownloadManager::DownloadsList*)>::function(std::function<void (Ubuntu::DownloadManager::DownloadsList*)> const&)@Base" 0.4+14.10.20140618
50 (c++)"std::function<void (Ubuntu::DownloadManager::GroupDownload*)>::function(std::function<void (Ubuntu::DownloadManager::GroupDownload*)> const&)@Base" 0.4+14.10.20140618
51
52=== modified file 'debian/libubuntu-download-manager-common1.symbols'
53--- debian/libubuntu-download-manager-common1.symbols 2015-07-23 14:02:27 +0000
54+++ debian/libubuntu-download-manager-common1.symbols 2015-09-22 15:26:07 +0000
55@@ -21,8 +21,6 @@
56 (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::GroupDownloadStruct(QString const&, QString const&, QString const&)@Base" 0.4+14.10.20140618
57 (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::GroupDownloadStruct(Ubuntu::DownloadManager::GroupDownloadStruct const&)@Base" 0.4+14.10.20140618
58 (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::GroupDownloadStruct()@Base" 0.4+14.10.20140618
59- (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::~GroupDownloadStruct()@Base" 0.4+14.10.20140618
60- (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::~GroupDownloadStruct()@Base" 0.4+14.10.20140618
61 (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::operator=(Ubuntu::DownloadManager::GroupDownloadStruct const&)@Base" 0.4+14.10.20140618
62 (c++)"Ubuntu::DownloadManager::operator<<(QDBusArgument&, Ubuntu::DownloadManager::DownloadStruct const&)@Base" 0.4+14.10.20140618
63 (c++)"Ubuntu::DownloadManager::operator<<(QDBusArgument&, Ubuntu::DownloadManager::GroupDownloadStruct const&)@Base" 0.4+14.10.20140618
64@@ -31,4 +29,5 @@
65 (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::getLocalFile() const@Base" 0.4+14.10.20140618
66 (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::getUrl() const@Base" 0.4+14.10.20140618
67 (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::getHash() const@Base" 0.4+14.10.20140618
68+ (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::~GroupDownloadStruct()@Base" 0replaceme
69 (c++)"operator<<(std::basic_ostream<char, std::char_traits<char> >&, QList<Ubuntu::DownloadManager::GroupDownloadStruct>)@Base" 0.4+14.10.20140618
70
71=== modified file 'debian/libudm-common1.symbols'
72--- debian/libudm-common1.symbols 2015-07-24 16:44:28 +0000
73+++ debian/libudm-common1.symbols 2015-09-22 15:26:07 +0000
74@@ -56,7 +56,7 @@
75 (c++)"Ubuntu::Transfers::System::Logger::qt_metacall(QMetaObject::Call, int, void**)@Base" 0.4+14.10.20140618
76 (c++)"Ubuntu::Transfers::System::Logger::qt_metacast(char const*)@Base" 0.4+14.10.20140618
77 (c++)"Ubuntu::Transfers::System::Logger::setLogLevel(QtMsgType)@Base" 0.4+14.10.20140618
78- (c++)"Ubuntu::Transfers::System::Logger::toStdString(QString const&)@Base" 0.4+14.10.20140618
79+ (c++)"Ubuntu::Transfers::System::Logger::toStdString[abi:cxx11](QString const&)@Base" 0replaceme
80 (c++)"Ubuntu::Transfers::System::Logger::setupLogging(QString)@Base" 0.4+14.10.20140618
81 (c++)"Ubuntu::Transfers::System::Logger::staticMetaObject@Base" 0.4+14.10.20140618
82 (c++)"Ubuntu::Transfers::System::Logger::getLogDir()@Base" 0.4+14.10.20140618
83@@ -121,6 +121,10 @@
84 (c++)"Ubuntu::Transfers::Metadata::EXTRACT_KEY@Base" 0.9+14.10.20141014.1
85 (c++)"Ubuntu::Transfers::Metadata::hasExtract() const@Base" 0.9+14.10.20141014.1
86 (c++)"Ubuntu::Transfers::Metadata::extract() const@Base" 0.9+14.10.20141014.1
87+ (c++)"Ubuntu::Transfers::Metadata::APP_ID@Base" 0replaceme
88+ (c++)"Ubuntu::Transfers::Metadata::setDestinationApp(QString const&)@Base" 0replaceme
89+ (c++)"Ubuntu::Transfers::Metadata::destinationApp() const@Base" 0replaceme
90+ (c++)"Ubuntu::Transfers::Metadata::hasDestinationApp() const@Base" 0replaceme
91 (c++)"Ubuntu::Transfers::Errors::HttpErrorStruct::getCode() const@Base" 0.4+14.10.20140618
92 (c++)"Ubuntu::Transfers::Errors::HttpErrorStruct::getPhrase() const@Base" 0.4+14.10.20140618
93 (c++)"Ubuntu::Transfers::Errors::NetworkErrorStruct::getCode() const@Base" 0.4+14.10.20140618
94
95=== added file 'debian/libudm-common1.symbols.powerpc'
96--- debian/libudm-common1.symbols.powerpc 1970-01-01 00:00:00 +0000
97+++ debian/libudm-common1.symbols.powerpc 2015-09-22 15:26:07 +0000
98@@ -0,0 +1,2 @@
99+libubuntu-download-manager-common.so.1 libubuntu-download-manager-common1 #MINVER#
100+ (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::~GroupDownloadStruct()@Base" 0replaceme
101
102=== modified file 'docs/dbus/com.canonical.applications.download.xml'
103--- docs/dbus/com.canonical.applications.download.xml 2015-02-25 16:24:24 +0000
104+++ docs/dbus/com.canonical.applications.download.xml 2015-09-22 15:26:07 +0000
105@@ -118,5 +118,7 @@
106
107 <property access="read" type="s" name="ClickPackage" />
108
109+ <property access="read" type="s" name="DestinationApp" />
110+
111 </interface>
112 </node>
113
114=== modified file 'src/common/public/ubuntu/transfers/metadata.cpp'
115--- src/common/public/ubuntu/transfers/metadata.cpp 2014-10-09 09:52:34 +0000
116+++ src/common/public/ubuntu/transfers/metadata.cpp 2015-09-22 15:26:07 +0000
117@@ -16,6 +16,8 @@
118 * Boston, MA 02110-1301, USA.
119 */
120
121+#include <QProcessEnvironment>
122+
123 #include "metadata.h"
124
125 namespace Ubuntu {
126@@ -31,12 +33,27 @@
127 const QString Metadata::CLICK_PACKAGE_KEY = "click-package";
128 const QString Metadata::DEFLATE_KEY = "deflate";
129 const QString Metadata::EXTRACT_KEY = "extract";
130+const QString Metadata::APP_ID = "app-id";
131+
132+namespace {
133+ const QString APP_ID_ENV = "APP_ID";
134+}
135
136 Metadata::Metadata() {
137+ auto environment = QProcessEnvironment::systemEnvironment();
138+ if (environment.contains(APP_ID_ENV)) {
139+ setOwner(environment.value(APP_ID_ENV));
140+ }
141 }
142
143 Metadata::Metadata(const QVariantMap map)
144 : QVariantMap(map) {
145+ // check if the app id is present, if not, do it
146+ if (!hasOwner()) {
147+ auto environment = QProcessEnvironment::systemEnvironment();
148+ environment.contains(APP_ID_ENV);
149+ setOwner(environment.value(APP_ID_ENV));
150+ }
151 }
152
153 QString
154@@ -167,6 +184,22 @@
155 return contains(Metadata::EXTRACT_KEY);
156 }
157
158+QString
159+Metadata::destinationApp() const {
160+ return (contains(Metadata::APP_ID))?
161+ value(Metadata::APP_ID).toString():"";
162+}
163+
164+void
165+Metadata::setOwner(const QString &id) {
166+ insert(Metadata::APP_ID, id);
167+}
168+
169+bool
170+Metadata::hasOwner() const {
171+ return contains(Metadata::APP_ID);
172+}
173+
174 } // DownloadManager
175
176 } // Ubuntu
177
178=== modified file 'src/common/public/ubuntu/transfers/metadata.h'
179--- src/common/public/ubuntu/transfers/metadata.h 2014-10-09 09:52:34 +0000
180+++ src/common/public/ubuntu/transfers/metadata.h 2015-09-22 15:26:07 +0000
181@@ -16,8 +16,7 @@
182 * Boston, MA 02110-1301, USA.
183 */
184
185-#ifndef DOWNLOADER_LIB_METADATA_H
186-#define DOWNLOADER_LIB_METADATA_H
187+#pragma once
188
189 #include <QMap>
190 #include <QVariant>
191@@ -41,6 +40,7 @@
192 static const QString CLICK_PACKAGE_KEY;
193 static const QString DEFLATE_KEY;
194 static const QString EXTRACT_KEY;
195+ static const QString APP_ID;
196
197 // accessors to simplify the use of the metadata
198 QString command() const;
199@@ -74,10 +74,12 @@
200 bool extract() const;
201 void setExtract(bool extract);
202 bool hasExtract() const;
203+
204+ QString destinationApp() const;
205+ void setOwner(const QString &id);
206+ bool hasOwner() const;
207 };
208
209 } // DownloadManager
210
211 } // Ubuntu
212-
213-#endif // METADATA_H
214
215=== modified file 'src/downloads/client/ubuntu/download_manager/download.h'
216--- src/downloads/client/ubuntu/download_manager/download.h 2014-09-24 09:10:39 +0000
217+++ src/downloads/client/ubuntu/download_manager/download.h 2015-09-22 15:26:07 +0000
218@@ -16,8 +16,7 @@
219 * Boston, MA 02110-1301, USA.
220 */
221
222-#ifndef UBUNTU_DOWNLOADMANAGER_CLIENT_DOWNLOAD_H
223-#define UBUNTU_DOWNLOADMANAGER_CLIENT_DOWNLOAD_H
224+#pragma once
225
226 #include <QObject>
227 #include <QVariantMap>
228@@ -51,6 +50,7 @@
229 Q_PROPERTY(QString ClickPackage READ clickPackage NOTIFY clickPackagedChanged)
230 Q_PROPERTY(bool ShowInIndicator READ showInIndicator NOTIFY showInIndicatorChanged)
231 Q_PROPERTY(QString Title READ title NOTIFY titleChanged)
232+ Q_PROPERTY(QString DownloadOwner READ destinationApp NOTIFY destinationAppChanged)
233
234 public:
235 explicit Download(QObject* parent = 0)
236@@ -244,6 +244,14 @@
237 */
238 virtual QString title() const = 0;
239
240+ /*!
241+ \fn QString destinationApp() const = 0;
242+
243+ Returns the value of the destinationApp property of the download. The owner of the
244+ download is the application that created the download in the system.
245+ */
246+ virtual QString destinationApp() const = 0;
247+
248 signals:
249
250 /*!
251@@ -346,10 +354,16 @@
252 */
253 void titleChanged();
254
255+ /*!
256+ \fn void Download::destinationAppChanged();
257+
258+ This signal is emitted whenever the download owner property of the download
259+ has been updated.
260+ */
261+ void destinationAppChanged();
262+
263 };
264
265 } // Ubuntu
266
267 } // DownloadManager
268-
269-#endif // UBUNTU_DOWNLOADMANAGER_CLIENT_DOWNLOAD_H
270
271=== modified file 'src/downloads/client/ubuntu/download_manager/download_impl.cpp'
272--- src/downloads/client/ubuntu/download_manager/download_impl.cpp 2015-02-25 16:24:24 +0000
273+++ src/downloads/client/ubuntu/download_manager/download_impl.cpp 2015-09-22 15:26:07 +0000
274@@ -425,6 +425,11 @@
275 return _dbusInterface->title();
276 }
277
278+QString
279+DownloadImpl::destinationApp() const {
280+ return _dbusInterface->destinationApp();
281+}
282+
283 void
284 DownloadImpl::onHttpError(HttpErrorStruct errStruct) {
285 auto err = new HttpError(errStruct, this);
286
287=== modified file 'src/downloads/client/ubuntu/download_manager/download_impl.h'
288--- src/downloads/client/ubuntu/download_manager/download_impl.h 2015-02-25 16:24:24 +0000
289+++ src/downloads/client/ubuntu/download_manager/download_impl.h 2015-09-22 15:26:07 +0000
290@@ -81,6 +81,7 @@
291 QString clickPackage() const;
292 bool showInIndicator() const;
293 QString title() const;
294+ QString destinationApp() const;
295
296 protected:
297 DownloadImpl(const QDBusConnection& conn, Error* err, QObject* parent = 0);
298
299=== modified file 'src/downloads/client/ubuntu/download_manager/download_interface.cpp'
300--- src/downloads/client/ubuntu/download_manager/download_interface.cpp 2015-02-25 16:24:24 +0000
301+++ src/downloads/client/ubuntu/download_manager/download_interface.cpp 2015-09-22 15:26:07 +0000
302@@ -2,7 +2,7 @@
303 * This file was generated by qdbusxml2cpp version 0.8
304 * Command line was: qdbusxml2cpp com.canonical.applications.download.xml -i metatypes.h -p download_interface -c DownloadInterface
305 *
306- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
307+ * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
308 *
309 * This is an auto-generated file.
310 * This file may have been hand-edited. Look for HAND-EDIT comments
311
312=== modified file 'src/downloads/client/ubuntu/download_manager/download_interface.h'
313--- src/downloads/client/ubuntu/download_manager/download_interface.h 2015-02-25 16:24:24 +0000
314+++ src/downloads/client/ubuntu/download_manager/download_interface.h 2015-09-22 15:26:07 +0000
315@@ -2,14 +2,14 @@
316 * This file was generated by qdbusxml2cpp version 0.8
317 * Command line was: qdbusxml2cpp com.canonical.applications.download.xml -i metatypes.h -p download_interface -c DownloadInterface
318 *
319- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
320+ * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
321 *
322 * This is an auto-generated file.
323 * Do not edit! All changes made to it will be lost.
324 */
325
326-#ifndef DOWNLOAD_INTERFACE_H_1392136772
327-#define DOWNLOAD_INTERFACE_H_1392136772
328+#ifndef DOWNLOAD_INTERFACE_H_1442932929
329+#define DOWNLOAD_INTERFACE_H_1442932929
330
331 #include <QtCore/QObject>
332 #include <QtCore/QByteArray>
333@@ -40,6 +40,10 @@
334 inline QString clickPackage() const
335 { return qvariant_cast< QString >(property("ClickPackage")); }
336
337+ Q_PROPERTY(QString DestinationApp READ destinationApp)
338+ inline QString destinationApp() const
339+ { return qvariant_cast< QString >(property("DestinationApp")); }
340+
341 Q_PROPERTY(bool ShowInIndicator READ showInIndicator)
342 inline bool showInIndicator() const
343 { return qvariant_cast< bool >(property("ShowInIndicator")); }
344@@ -53,95 +57,95 @@
345 {
346 QList<QVariant> argumentList;
347 argumentList << QVariant::fromValue(allowed);
348- return asyncCallWithArgumentList(QLatin1String("allowGSMDownload"), argumentList);
349+ return asyncCallWithArgumentList(QStringLiteral("allowGSMDownload"), argumentList);
350 }
351
352 inline QDBusPendingReply<> cancel()
353 {
354 QList<QVariant> argumentList;
355- return asyncCallWithArgumentList(QLatin1String("cancel"), argumentList);
356+ return asyncCallWithArgumentList(QStringLiteral("cancel"), argumentList);
357 }
358
359 inline QDBusPendingReply<StringMap> headers()
360 {
361 QList<QVariant> argumentList;
362- return asyncCallWithArgumentList(QLatin1String("headers"), argumentList);
363+ return asyncCallWithArgumentList(QStringLiteral("headers"), argumentList);
364 }
365
366 inline QDBusPendingReply<bool> isGSMDownloadAllowed()
367 {
368 QList<QVariant> argumentList;
369- return asyncCallWithArgumentList(QLatin1String("isGSMDownloadAllowed"), argumentList);
370+ return asyncCallWithArgumentList(QStringLiteral("isGSMDownloadAllowed"), argumentList);
371 }
372
373 inline QDBusPendingReply<QVariantMap> metadata()
374 {
375 QList<QVariant> argumentList;
376- return asyncCallWithArgumentList(QLatin1String("metadata"), argumentList);
377+ return asyncCallWithArgumentList(QStringLiteral("metadata"), argumentList);
378 }
379
380 inline QDBusPendingReply<> pause()
381 {
382 QList<QVariant> argumentList;
383- return asyncCallWithArgumentList(QLatin1String("pause"), argumentList);
384+ return asyncCallWithArgumentList(QStringLiteral("pause"), argumentList);
385 }
386
387 inline QDBusPendingReply<qulonglong> progress()
388 {
389 QList<QVariant> argumentList;
390- return asyncCallWithArgumentList(QLatin1String("progress"), argumentList);
391+ return asyncCallWithArgumentList(QStringLiteral("progress"), argumentList);
392 }
393
394 inline QDBusPendingReply<> resume()
395 {
396 QList<QVariant> argumentList;
397- return asyncCallWithArgumentList(QLatin1String("resume"), argumentList);
398+ return asyncCallWithArgumentList(QStringLiteral("resume"), argumentList);
399 }
400
401 inline QDBusPendingReply<> setDestinationDir(const QString &path)
402 {
403 QList<QVariant> argumentList;
404 argumentList << QVariant::fromValue(path);
405- return asyncCallWithArgumentList(QLatin1String("setDestinationDir"), argumentList);
406+ return asyncCallWithArgumentList(QStringLiteral("setDestinationDir"), argumentList);
407 }
408
409 inline QDBusPendingReply<> setHeaders(StringMap headers)
410 {
411 QList<QVariant> argumentList;
412 argumentList << QVariant::fromValue(headers);
413- return asyncCallWithArgumentList(QLatin1String("setHeaders"), argumentList);
414+ return asyncCallWithArgumentList(QStringLiteral("setHeaders"), argumentList);
415 }
416
417 inline QDBusPendingReply<> setMetadata(const QVariantMap &data)
418 {
419 QList<QVariant> argumentList;
420 argumentList << QVariant::fromValue(data);
421- return asyncCallWithArgumentList(QLatin1String("setMetadata"), argumentList);
422+ return asyncCallWithArgumentList(QStringLiteral("setMetadata"), argumentList);
423 }
424
425 inline QDBusPendingReply<> setThrottle(qulonglong speed)
426 {
427 QList<QVariant> argumentList;
428 argumentList << QVariant::fromValue(speed);
429- return asyncCallWithArgumentList(QLatin1String("setThrottle"), argumentList);
430+ return asyncCallWithArgumentList(QStringLiteral("setThrottle"), argumentList);
431 }
432
433 inline QDBusPendingReply<> start()
434 {
435 QList<QVariant> argumentList;
436- return asyncCallWithArgumentList(QLatin1String("start"), argumentList);
437+ return asyncCallWithArgumentList(QStringLiteral("start"), argumentList);
438 }
439
440 inline QDBusPendingReply<qulonglong> throttle()
441 {
442 QList<QVariant> argumentList;
443- return asyncCallWithArgumentList(QLatin1String("throttle"), argumentList);
444+ return asyncCallWithArgumentList(QStringLiteral("throttle"), argumentList);
445 }
446
447 inline QDBusPendingReply<qulonglong> totalSize()
448 {
449 QList<QVariant> argumentList;
450- return asyncCallWithArgumentList(QLatin1String("totalSize"), argumentList);
451+ return asyncCallWithArgumentList(QStringLiteral("totalSize"), argumentList);
452 }
453
454 Q_SIGNALS: // SIGNALS
455
456=== modified file 'src/downloads/priv/ubuntu/downloads/download.h'
457--- src/downloads/priv/ubuntu/downloads/download.h 2014-12-01 09:20:00 +0000
458+++ src/downloads/priv/ubuntu/downloads/download.h 2015-09-22 15:26:07 +0000
459@@ -16,8 +16,7 @@
460 * Boston, MA 02110-1301, USA.
461 */
462
463-#ifndef DOWNLOADER_LIB_DOWNLOAD_H
464-#define DOWNLOADER_LIB_DOWNLOAD_H
465+#pragma once
466
467 #include <QNetworkAccessManager>
468 #include <QObject>
469@@ -43,6 +42,7 @@
470 Q_PROPERTY(QString ClickPackage READ clickPackage)
471 Q_PROPERTY(bool ShowInIndicator READ showInIndicator)
472 Q_PROPERTY(QString Title READ title)
473+ Q_PROPERTY(QString DownloadOwner READ destinationApp)
474
475 public:
476 Download(const QString& id,
477@@ -77,12 +77,15 @@
478 // rename the transfer method
479 Transfer::allowGSMData(allowed);
480 }
481+
482 virtual bool isGSMDownloadAllowed() {
483 return Transfer::isGSMDataAllowed();
484 }
485+
486 virtual StringMap headers() const {
487 return _headers;
488 }
489+
490 virtual void setHeaders(StringMap headers) {
491 _headers = headers;
492 }
493@@ -91,6 +94,14 @@
494 _metadata = data;
495 }
496
497+ virtual QString destinationApp() {
498+ return _destinationApp;
499+ }
500+
501+ virtual void setDownloadOwner(const QString& owner) {
502+ _destinationApp = owner;
503+ }
504+
505 // slots to be implemented by the children
506 virtual qulonglong progress() = 0;
507 virtual qulonglong totalSize() = 0;
508@@ -110,6 +121,7 @@
509 QVariantMap _metadata;
510
511 private:
512+ QString _destinationApp = QString::null;
513 QMap<QString, QString> _headers;
514 QMap<QString, QObject*> _adaptors;
515 };
516@@ -120,4 +132,3 @@
517
518 } // Ubuntu
519
520-#endif // DOWNLOADER_LIB_APP_DOWNLOAD_H
521
522=== modified file 'src/downloads/priv/ubuntu/downloads/download_adaptor.cpp'
523--- src/downloads/priv/ubuntu/downloads/download_adaptor.cpp 2014-09-05 15:11:35 +0000
524+++ src/downloads/priv/ubuntu/downloads/download_adaptor.cpp 2015-09-22 15:26:07 +0000
525@@ -2,7 +2,7 @@
526 * This file was generated by qdbusxml2cpp version 0.8
527 * Command line was: qdbusxml2cpp -c DownloadAdaptor -a download_adaptor.h:download_adaptor.cpp com.canonical.applications.download.xml
528 *
529- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
530+ * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
531 *
532 * This is an auto-generated file.
533 * Do not edit! All changes made to it will be lost.
534@@ -39,6 +39,12 @@
535 return qvariant_cast< QString >(parent()->property("ClickPackage"));
536 }
537
538+QString DownloadAdaptor::destinationApp() const
539+{
540+ // get the value of property DownloadOwner
541+ return qvariant_cast< QString >(parent()->property("DownloadOwner"));
542+}
543+
544 bool DownloadAdaptor::showInIndicator() const
545 {
546 // get the value of property ShowInIndicator
547
548=== modified file 'src/downloads/priv/ubuntu/downloads/download_adaptor.h'
549--- src/downloads/priv/ubuntu/downloads/download_adaptor.h 2015-02-25 16:24:24 +0000
550+++ src/downloads/priv/ubuntu/downloads/download_adaptor.h 2015-09-22 15:26:07 +0000
551@@ -2,15 +2,15 @@
552 * This file was generated by qdbusxml2cpp version 0.8
553 * Command line was: qdbusxml2cpp -c DownloadAdaptor -a download_adaptor.h:download_adaptor.cpp com.canonical.applications.download.xml
554 *
555- * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
556+ * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
557 *
558 * This is an auto-generated file.
559 * This file may have been hand-edited. Look for HAND-EDIT comments
560 * before re-generating it.
561 */
562
563-#ifndef DOWNLOAD_ADAPTOR_H_1392117488
564-#define DOWNLOAD_ADAPTOR_H_1392117488
565+#ifndef DOWNLOAD_ADAPTOR_H_1440513488
566+#define DOWNLOAD_ADAPTOR_H_1440513488
567
568 #include <QtCore/QObject>
569 #include <QtDBus/QtDBus>
570@@ -123,6 +123,7 @@
571 " <property access=\"read\" type=\"b\" name=\"ShowInIndicator\"/>\n"
572 " <property access=\"read\" type=\"s\" name=\"Title\"/>\n"
573 " <property access=\"read\" type=\"s\" name=\"ClickPackage\"/>\n"
574+" <property access=\"read\" type=\"s\" name=\"DestinationApp\"/>\n"
575 " </interface>\n"
576 "")
577 public:
578@@ -133,6 +134,9 @@
579 Q_PROPERTY(QString ClickPackage READ clickPackage)
580 QString clickPackage() const;
581
582+ Q_PROPERTY(QString DestinationApp READ destinationApp)
583+ QString destinationApp() const;
584+
585 Q_PROPERTY(bool ShowInIndicator READ showInIndicator)
586 bool showInIndicator() const;
587
588
589=== modified file 'src/downloads/priv/ubuntu/downloads/manager.cpp'
590--- src/downloads/priv/ubuntu/downloads/manager.cpp 2015-02-25 16:24:24 +0000
591+++ src/downloads/priv/ubuntu/downloads/manager.cpp 2015-09-22 15:26:07 +0000
592@@ -133,8 +133,27 @@
593 return caller;
594 }
595
596+QString
597+DownloadManager::getDownloadOwner(const QVariantMap& metadata) {
598+ QScopedPointer<System::AppArmor> appArmor(new System::AppArmor(_conn));
599+ auto owner = getCaller();
600+ auto appId = appArmor->appId(owner);
601+ if(appArmor->isConfined(appId)) {
602+ return appId;
603+ } else {
604+ if (metadata.contains(Metadata::APP_ID)){
605+ return metadata[Metadata::APP_ID].toString();
606+ } else {
607+ return "";
608+ }
609+ }
610+ return "";
611+}
612+
613 QDBusObjectPath
614 DownloadManager::registerDownload(Download* download) {
615+ download->setDownloadOwner(getDownloadOwner(download->metadata()));
616+
617 download->setThrottle(_throttle);
618 download->allowGSMDownload(_allowMobileData);
619 if (!_db->store(download)) {
620
621=== modified file 'src/downloads/priv/ubuntu/downloads/manager.h'
622--- src/downloads/priv/ubuntu/downloads/manager.h 2014-07-30 09:19:10 +0000
623+++ src/downloads/priv/ubuntu/downloads/manager.h 2015-09-22 15:26:07 +0000
624@@ -16,8 +16,7 @@
625 * Boston, MA 02110-1301, USA.
626 */
627
628-#ifndef DOWNLOADER_LIB_DOWNLOADER_H
629-#define DOWNLOADER_LIB_DOWNLOADER_H
630+#pragma once
631
632 #include <QObject>
633 #include <QByteArray>
634@@ -95,7 +94,6 @@
635 virtual QDBusObjectPath registerDownload(Download* download);
636
637 private:
638-
639 typedef std::function<Download*(QString)> DownloadCreationFunc;
640
641 void init();
642@@ -109,6 +107,7 @@
643 StringMap headers);
644 void onDownloadsChanged(QString);
645 QString getCaller();
646+ QString getDownloadOwner(const QVariantMap& metadata);
647
648 private:
649 Application* _app = nullptr;
650@@ -126,4 +125,3 @@
651 } // DownloadManager
652
653 } // Manager
654-#endif // DOWNLOADER_LIB_DOWNLOADER_H
655
656=== modified file 'tests/downloads/daemon/test_download_manager.cpp'
657--- tests/downloads/daemon/test_download_manager.cpp 2014-12-01 09:20:00 +0000
658+++ tests/downloads/daemon/test_download_manager.cpp 2015-09-22 15:26:07 +0000
659@@ -145,6 +145,27 @@
660 SignalBarrier spy(_man, SIGNAL(downloadCreated(QDBusObjectPath)));
661 DownloadStruct downStruct(url, metadata, headers);
662
663+ auto dbusProxy = new MockDBusProxy();
664+ auto reply = new MockPendingReply<QString>();
665+ EXPECT_CALL(*_dbusProxyFactory, createDBusProxy(_conn, _))
666+ .Times(1)
667+ .WillOnce(Return(dbusProxy));
668+
669+ EXPECT_CALL(*dbusProxy, GetConnectionAppArmorSecurityContext(_))
670+ .Times(1)
671+ .WillOnce(Return(reply));
672+
673+ EXPECT_CALL(*reply, waitForFinished())
674+ .Times(1);
675+
676+ EXPECT_CALL(*reply, isError())
677+ .Times(1)
678+ .WillOnce(Return(false));
679+
680+ EXPECT_CALL(*reply, value())
681+ .Times(1)
682+ .WillOnce(Return("TEST_APP_ID"));
683+
684 // set the expectations of the factory since is the one that
685 // creates the downloads. The matchers will ensure that the
686 // correct value is used.
687@@ -157,10 +178,18 @@
688 EXPECT_CALL(*down.data(), setThrottle(_man->defaultThrottle()))
689 .Times(1);
690
691+ EXPECT_CALL(*down.data(), allowGSMDownload(_))
692+ .Times(1);
693+
694+
695 EXPECT_CALL(*down.data(), path())
696 .Times(1)
697 .WillRepeatedly(Return(dbusPath));
698
699+ EXPECT_CALL(*down.data(), metadata())
700+ .Times(1)
701+ .WillRepeatedly(Return(QVariantMap()));
702+
703 // expected actions performed by the db
704 EXPECT_CALL(*_database, store(down.data()))
705 .Times(1)
706@@ -248,6 +277,27 @@
707 .Times(1)
708 .WillRepeatedly(Return(down.data()));
709
710+ auto dbusProxy = new MockDBusProxy();
711+ auto reply = new MockPendingReply<QString>();
712+ EXPECT_CALL(*_dbusProxyFactory, createDBusProxy(_conn, _))
713+ .Times(1)
714+ .WillOnce(Return(dbusProxy));
715+
716+ EXPECT_CALL(*dbusProxy, GetConnectionAppArmorSecurityContext(_))
717+ .Times(1)
718+ .WillOnce(Return(reply));
719+
720+ EXPECT_CALL(*reply, waitForFinished())
721+ .Times(1);
722+
723+ EXPECT_CALL(*reply, isError())
724+ .Times(1)
725+ .WillOnce(Return(false));
726+
727+ EXPECT_CALL(*reply, value())
728+ .Times(1)
729+ .WillOnce(Return("TEST_APP_ID"));
730+
731 // expected actions to be performed on the download
732 EXPECT_CALL(*down.data(), setThrottle(_man->defaultThrottle()))
733 .Times(1);
734@@ -259,6 +309,10 @@
735 .Times(1)
736 .WillRepeatedly(Return(dbusPath));
737
738+ EXPECT_CALL(*down.data(), metadata())
739+ .Times(1)
740+ .WillRepeatedly(Return(QVariantMap()));
741+
742 // expected actions performed by the db
743 EXPECT_CALL(*_database, store(down.data()))
744 .Times(1)
745
746=== modified file 'tests/downloads/daemon/test_metadata.cpp'
747--- tests/downloads/daemon/test_metadata.cpp 2014-09-22 23:24:34 +0000
748+++ tests/downloads/daemon/test_metadata.cpp 2015-09-22 15:26:07 +0000
749@@ -16,6 +16,10 @@
750 * Boston, MA 02110-1301, USA.
751 */
752
753+#include <stdlib.h>
754+
755+#include <QProcessEnvironment>
756+
757 #include "test_metadata.h"
758
759 using namespace Ubuntu::Transfers;
760@@ -348,5 +352,91 @@
761 QVERIFY(!metadata.hasDeflate());
762 }
763
764+void
765+TestMetadata::testDownloadOwner_data() {
766+ QTest::addColumn<QString>("owner");
767+
768+ QTest::newRow("First app") << "First app";
769+ QTest::newRow("Browser") << "Browser";
770+ QTest::newRow("Test") << "Test";
771+}
772+
773+void
774+TestMetadata::testDownloadOwner() {
775+ QFETCH(QString, owner);
776+
777+ Metadata metadata;
778+ metadata[Metadata::APP_ID] = owner;
779+ QCOMPARE(owner, metadata.destinationApp());
780+}
781+
782+void
783+TestMetadata::testSetDownloadDestinationApp_data() {
784+ QTest::addColumn<QString>("owner");
785+
786+ QTest::newRow("First app") << "First app";
787+ QTest::newRow("Browser") << "Browser";
788+ QTest::newRow("Test") << "Test";
789+}
790+
791+void
792+TestMetadata::testSetDownloadDestinationApp() {
793+ QFETCH(QString, owner);
794+
795+ Metadata metadata;
796+ metadata.setOwner(owner);
797+ QCOMPARE(metadata[Metadata::APP_ID].toString(), owner);
798+}
799+
800+void
801+TestMetadata::testHasDownloadDestinationAppTrue() {
802+ Metadata metadata;
803+ metadata.setOwner("pedro");
804+
805+ QVERIFY(metadata.hasOwner());
806+}
807+
808+void
809+TestMetadata::testHasDownloadDestinationAppFalse() {
810+ Metadata metadata;
811+ metadata.clear();
812+
813+ QVERIFY(!metadata.hasOwner());
814+}
815+
816+void
817+TestMetadata::testDestinationAppIsPickedFromEnv_data() {
818+ QTest::addColumn<QString>("appid");
819+
820+ QTest::newRow("First app") << "Chanco";
821+ QTest::newRow("Browser") << "Browser";
822+ QTest::newRow("Test") << "Test";
823+}
824+
825+
826+void
827+TestMetadata::testDestinationAppIsPickedFromEnv() {
828+ QFETCH(QString, appid);
829+
830+ // set the used envar
831+ setenv("APP_ID", appid.toStdString().c_str(), 1);
832+
833+ Metadata metadata;
834+ QVERIFY(metadata.hasOwner());
835+ QCOMPARE(metadata.destinationApp(), appid);
836+}
837+
838+void
839+TestMetadata::testDestinationAppIsAlreadyPresent() {
840+ QString appid("Test");
841+ QVariantMap map;
842+
843+ // set the used envar
844+ setenv("APP_ID", appid.toStdString().c_str(), 1);
845+ Metadata metadata(map);
846+ QVERIFY(metadata.hasOwner());
847+ QCOMPARE(metadata.destinationApp(), appid);
848+}
849+
850 QTEST_MAIN(TestMetadata)
851 #include "moc_test_metadata.cpp"
852
853=== modified file 'tests/downloads/daemon/test_metadata.h'
854--- tests/downloads/daemon/test_metadata.h 2014-09-22 23:24:34 +0000
855+++ tests/downloads/daemon/test_metadata.h 2015-09-22 15:26:07 +0000
856@@ -16,8 +16,7 @@
857 * Boston, MA 02110-1301, USA.
858 */
859
860-#ifndef TEST_METADATA_H
861-#define TEST_METADATA_H
862+#pragma once
863
864 #include <QObject>
865 #include <ubuntu/transfers/metadata.h>
866@@ -71,6 +70,14 @@
867 void testSetDeflate();
868 void testHasDeflateTrue();
869 void testHasDeflateFalse();
870+ void testDownloadOwner_data();
871+ void testDownloadOwner();
872+ void testSetDownloadDestinationApp_data();
873+ void testSetDownloadDestinationApp();
874+ void testHasDownloadDestinationAppTrue();
875+ void testHasDownloadDestinationAppFalse();
876+ void testDestinationAppIsPickedFromEnv_data();
877+ void testDestinationAppIsPickedFromEnv();
878+ void testDestinationAppIsAlreadyPresent();
879 };
880
881-#endif // TEST_METADATA_H

Subscribers

People subscribed via source and target branches