Merge lp:~michael-sheldon/ubuntu-download-manager/persistent-download-model-vivid into lp:ubuntu-download-manager/vivid
- persistent-download-model-vivid
- Merge into vivid
Proposed by
Michael Sheldon
Status: | Rejected |
---|---|
Rejected by: | Adam Collard |
Proposed branch: | lp:~michael-sheldon/ubuntu-download-manager/persistent-download-model-vivid |
Merge into: | lp:ubuntu-download-manager/vivid |
Diff against target: |
2419 lines (+1238/-115) 55 files modified
.bzrignore (+2/-0) CMakeLists.txt (+1/-1) debian/changelog (+16/-0) debian/libubuntu-download-manager-client1.symbols (+11/-11) debian/libubuntu-download-manager-common-dev.install (+1/-0) debian/libubuntu-download-manager-common1.symbols (+23/-8) debian/libudm-common1.symbols (+1/-1) docs/dbus/com.canonical.applications.download.xml (+9/-0) docs/dbus/com.canonical.applications.download_manager.xml (+11/-0) docs/qml/pages/mainpage.qdoc (+3/-3) docs/qml/pages/moduledef.qdoc (+1/-1) src/common/priv/ubuntu/transfers/queue.cpp (+4/-0) src/common/priv/ubuntu/transfers/transfer.cpp (+7/-0) src/common/priv/ubuntu/transfers/transfer.h (+3/-4) src/common/public/ubuntu/transfers/metadata.cpp (+8/-0) src/downloads/client/ubuntu/download_manager/download.h (+35/-0) src/downloads/client/ubuntu/download_manager/download_impl.cpp (+61/-2) src/downloads/client/ubuntu/download_manager/download_impl.h (+4/-0) src/downloads/client/ubuntu/download_manager/download_interface.h (+18/-0) src/downloads/client/ubuntu/download_manager/manager.h (+27/-0) src/downloads/client/ubuntu/download_manager/manager_impl.cpp (+23/-0) src/downloads/client/ubuntu/download_manager/manager_impl.h (+4/-0) src/downloads/client/ubuntu/download_manager/manager_interface.h (+7/-0) src/downloads/common/CMakeLists.txt (+2/-0) src/downloads/common/ubuntu/download_manager/download_state_struct.cpp (+119/-0) src/downloads/common/ubuntu/download_manager/download_state_struct.h (+149/-0) src/downloads/common/ubuntu/download_manager/metatypes.h (+2/-0) src/downloads/priv/CMakeLists.txt (+2/-2) src/downloads/priv/ubuntu/downloads/download.h (+1/-0) src/downloads/priv/ubuntu/downloads/download_adaptor.cpp (+22/-0) src/downloads/priv/ubuntu/downloads/download_adaptor.h (+12/-2) src/downloads/priv/ubuntu/downloads/download_manager_adaptor.cpp (+17/-1) src/downloads/priv/ubuntu/downloads/download_manager_adaptor.h (+12/-1) src/downloads/priv/ubuntu/downloads/downloads_db.cpp (+105/-0) src/downloads/priv/ubuntu/downloads/downloads_db.h (+9/-5) src/downloads/priv/ubuntu/downloads/factory.cpp (+7/-1) src/downloads/priv/ubuntu/downloads/file_download.cpp (+13/-1) src/downloads/priv/ubuntu/downloads/file_download.h (+3/-4) src/downloads/priv/ubuntu/downloads/group_download.cpp (+7/-0) src/downloads/priv/ubuntu/downloads/group_download.h (+1/-0) src/downloads/priv/ubuntu/downloads/manager.cpp (+39/-0) src/downloads/priv/ubuntu/downloads/manager.h (+9/-3) src/downloads/priv/ubuntu/downloads/state_machines/download_sm.h (+1/-0) src/downloads/qml/CMakeLists.txt (+2/-0) src/downloads/qml/backend.cpp (+4/-0) src/downloads/qml/download_history.cpp (+143/-0) src/downloads/qml/download_history.h (+69/-0) src/downloads/qml/single_download.cpp (+36/-12) src/downloads/qml/single_download.h (+1/-0) src/downloads/qml/ubuntu_download_manager.cpp (+78/-36) src/downloads/qml/ubuntu_download_manager.h (+8/-4) tests/downloads/daemon/download.h (+1/-1) tests/downloads/daemon/test_download.cpp (+7/-7) tests/downloads/daemon/test_downloads_db.cpp (+73/-0) tests/downloads/daemon/test_downloads_db.h (+4/-4) |
To merge this branch: | bzr merge lp:~michael-sheldon/ubuntu-download-manager/persistent-download-model-vivid |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu One hackers | Pending | ||
Review via email: mp+278698@code.launchpad.net |
Commit message
Provide a persistent download model available between application restarts
Description of the change
Provide a persistent download model available between application restarts
To post a comment you must log in.
Unmerged revisions
- 341. By Michael Sheldon
-
Provide a persistent download model available between application restarts
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2013-11-12 12:30:18 +0000 | |||
3 | +++ .bzrignore 2015-11-26 12:58:55 +0000 | |||
4 | @@ -12,3 +12,5 @@ | |||
5 | 12 | libubuntudownloadmanager-common/libubuntudownloadmanager-common.so.1 | 12 | libubuntudownloadmanager-common/libubuntudownloadmanager-common.so.1 |
6 | 13 | libubuntudownloadmanager-common/libubuntudownloadmanager-common.so.1.0 | 13 | libubuntudownloadmanager-common/libubuntudownloadmanager-common.so.1.0 |
7 | 14 | libubuntudownloadmanager-common/libubuntudownloadmanager-common.so.1.0.0 | 14 | libubuntudownloadmanager-common/libubuntudownloadmanager-common.so.1.0.0 |
8 | 15 | .idea | ||
9 | 16 | build | ||
10 | 15 | 17 | ||
11 | === modified file 'CMakeLists.txt' | |||
12 | --- CMakeLists.txt 2015-09-22 14:14:06 +0000 | |||
13 | +++ CMakeLists.txt 2015-11-26 12:58:55 +0000 | |||
14 | @@ -31,7 +31,7 @@ | |||
15 | 31 | ) | 31 | ) |
16 | 32 | 32 | ||
17 | 33 | set(UDM_VERSION_MAJOR 1) | 33 | set(UDM_VERSION_MAJOR 1) |
19 | 34 | set(UDM_VERSION_MINOR 1) | 34 | set(UDM_VERSION_MINOR 2) |
20 | 35 | set(UDM_VERSION_PATCH 0) | 35 | set(UDM_VERSION_PATCH 0) |
21 | 36 | 36 | ||
22 | 37 | find_package(Gtest REQUIRED) | 37 | find_package(Gtest REQUIRED) |
23 | 38 | 38 | ||
24 | === modified file 'debian/changelog' | |||
25 | --- debian/changelog 2015-09-22 15:27:25 +0000 | |||
26 | +++ debian/changelog 2015-11-26 12:58:55 +0000 | |||
27 | @@ -1,3 +1,11 @@ | |||
28 | 1 | ubuntu-download-manager (1.2) UNRELEASED; urgency=medium | ||
29 | 2 | |||
30 | 3 | * Provide a shared download history for the downloads model that presents | ||
31 | 4 | all uncollected downloads from previous app launches. | ||
32 | 5 | * Update symbol files | ||
33 | 6 | |||
34 | 7 | -- Michael Sheldon <michael.sheldon@canonical.com> Wed, 21 Oct 2015 10:03:21 +0100 | ||
35 | 8 | |||
36 | 1 | ubuntu-download-manager (1.1+15.04.20150922.4-0ubuntu1) vivid; urgency=medium | 9 | ubuntu-download-manager (1.1+15.04.20150922.4-0ubuntu1) vivid; urgency=medium |
37 | 2 | 10 | ||
38 | 3 | [ Manuel de la Pena ] | 11 | [ Manuel de la Pena ] |
39 | @@ -11,6 +19,14 @@ | |||
40 | 11 | 19 | ||
41 | 12 | -- Bill Filler <ci-train-bot@canonical.com> Tue, 22 Sep 2015 15:27:25 +0000 | 20 | -- Bill Filler <ci-train-bot@canonical.com> Tue, 22 Sep 2015 15:27:25 +0000 |
42 | 13 | 21 | ||
43 | 22 | ubuntu-download-manager (1.1) UNRELEASED; urgency=medium | ||
44 | 23 | |||
45 | 24 | * Ensure that the app id of the application that created the download is | ||
46 | 25 | present in the metadata and can be accessed via dbus. | ||
47 | 26 | * Update the symbol files. | ||
48 | 27 | |||
49 | 28 | -- Manuel de la Pena <manuel.delapena@canonical.com> Tue, 01 Sep 2015 17:07:58 +0100 | ||
50 | 29 | |||
51 | 14 | ubuntu-download-manager (1.0+15.04-0ubuntu1) wily; urgency=medium | 30 | ubuntu-download-manager (1.0+15.04-0ubuntu1) wily; urgency=medium |
52 | 15 | 31 | ||
53 | 16 | [ Manuel de la Pena ] | 32 | [ Manuel de la Pena ] |
54 | 17 | 33 | ||
55 | === modified file 'debian/libubuntu-download-manager-client1.symbols' | |||
56 | --- debian/libubuntu-download-manager-client1.symbols 2015-09-22 15:27:25 +0000 | |||
57 | +++ debian/libubuntu-download-manager-client1.symbols 2015-11-26 12:58:55 +0000 | |||
58 | @@ -95,17 +95,17 @@ | |||
59 | 95 | (c++)"Ubuntu::DownloadManager::AuthError::metaObject() const@Base" 0.4+14.10.20140618 | 95 | (c++)"Ubuntu::DownloadManager::AuthError::metaObject() const@Base" 0.4+14.10.20140618 |
60 | 96 | (c++)"Ubuntu::DownloadManager::DBusError::metaObject() const@Base" 0.4+14.10.20140618 | 96 | (c++)"Ubuntu::DownloadManager::DBusError::metaObject() const@Base" 0.4+14.10.20140618 |
61 | 97 | (c++)"Ubuntu::DownloadManager::HttpError::metaObject() const@Base" 0.4+14.10.20140618 | 97 | (c++)"Ubuntu::DownloadManager::HttpError::metaObject() const@Base" 0.4+14.10.20140618 |
73 | 98 | (c++)"std::function<void (Ubuntu::DownloadManager::DownloadsList*)>::operator()(Ubuntu::DownloadManager::DownloadsList*) const@Base" 0.4+14.10.20140618 | 98 | (c++)"std::function<void (Ubuntu::DownloadManager::DownloadsList*)>::function(std::function<void (Ubuntu::DownloadManager::DownloadsList*)> const&)@Base" 0.4+14.10.20140618 |
74 | 99 | (c++)"std::function<void (Ubuntu::DownloadManager::GroupDownload*)>::operator()(Ubuntu::DownloadManager::GroupDownload*) const@Base" 0.4+14.10.20140618 | 99 | (c++)"std::function<void (Ubuntu::DownloadManager::DownloadsList*)>::function(std::function<void (Ubuntu::DownloadManager::DownloadsList*)> const&)@Base" 0.4+14.10.20140618 |
75 | 100 | (c++)"std::function<void (Ubuntu::DownloadManager::Download*)>::operator()(Ubuntu::DownloadManager::Download*) const@Base" 0.4+14.10.20140618 | 100 | (c++)"std::function<void (Ubuntu::DownloadManager::GroupDownload*)>::function(std::function<void (Ubuntu::DownloadManager::GroupDownload*)> const&)@Base" 0.4+14.10.20140618 |
76 | 101 | (c++)"std::function<void (Ubuntu::DownloadManager::DownloadsList*)>::function(std::function<void (Ubuntu::DownloadManager::DownloadsList*)> const&)@Base" 0.4+14.10.20140618 | 101 | (c++)"std::function<void (Ubuntu::DownloadManager::GroupDownload*)>::function(std::function<void (Ubuntu::DownloadManager::GroupDownload*)> const&)@Base" 0.4+14.10.20140618 |
77 | 102 | (c++)"std::function<void (Ubuntu::DownloadManager::DownloadsList*)>::function(std::function<void (Ubuntu::DownloadManager::DownloadsList*)> const&)@Base" 0.4+14.10.20140618 | 102 | (c++)"std::function<void (Ubuntu::DownloadManager::Download*)>::function(std::function<void (Ubuntu::DownloadManager::Download*)> const&)@Base" 0.4+14.10.20140618 |
78 | 103 | (c++)"std::function<void (Ubuntu::DownloadManager::GroupDownload*)>::function(std::function<void (Ubuntu::DownloadManager::GroupDownload*)> const&)@Base" 0.4+14.10.20140618 | 103 | (c++)"std::function<void (Ubuntu::DownloadManager::Download*)>::function(std::function<void (Ubuntu::DownloadManager::Download*)> const&)@Base" 0.4+14.10.20140618 |
79 | 104 | (c++)"std::function<void (Ubuntu::DownloadManager::GroupDownload*)>::function(std::function<void (Ubuntu::DownloadManager::GroupDownload*)> const&)@Base" 0.4+14.10.20140618 | 104 | (c++)"std::function<void (QString const&, QString const&, Ubuntu::DownloadManager::DownloadsList*)>::function(std::function<void (QString const&, QString const&, Ubuntu::DownloadManager::DownloadsList*)> const&)@Base" 0.4+14.10.20140618 |
80 | 105 | (c++)"std::function<void (Ubuntu::DownloadManager::Download*)>::function(std::function<void (Ubuntu::DownloadManager::Download*)> const&)@Base" 0.4+14.10.20140618 | 105 | (c++)"std::function<void (QString const&, QString const&, Ubuntu::DownloadManager::DownloadsList*)>::function(std::function<void (QString const&, QString const&, Ubuntu::DownloadManager::DownloadsList*)> const&)@Base" 0.4+14.10.20140618 |
81 | 106 | (c++)"std::function<void (Ubuntu::DownloadManager::Download*)>::function(std::function<void (Ubuntu::DownloadManager::Download*)> const&)@Base" 0.4+14.10.20140618 | 106 | (c++)"std::function<void (Ubuntu::DownloadManager::DownloadsList*)>::operator()(Ubuntu::DownloadManager::DownloadsList*) const@Base" 1.2 |
82 | 107 | (c++)"std::function<void (QString const&, QString const&, Ubuntu::DownloadManager::DownloadsList*)>::function(std::function<void (QString const&, QString const&, Ubuntu::DownloadManager::DownloadsList*)> const&)@Base" 0.4+14.10.20140618 | 107 | (c++)"std::function<void (Ubuntu::DownloadManager::GroupDownload*)>::operator()(Ubuntu::DownloadManager::GroupDownload*) const@Base" 1.2 |
83 | 108 | (c++)"std::function<void (QString const&, QString const&, Ubuntu::DownloadManager::DownloadsList*)>::function(std::function<void (QString const&, QString const&, Ubuntu::DownloadManager::DownloadsList*)> const&)@Base" 0.4+14.10.20140618 | 108 | (c++)"std::function<void (Ubuntu::DownloadManager::Download*)>::operator()(Ubuntu::DownloadManager::Download*) const@Base" 1.2 |
84 | 109 | (c++)"typeinfo for Ubuntu::DownloadManager::NetworkError@Base" 0.4+14.10.20140618 | 109 | (c++)"typeinfo for Ubuntu::DownloadManager::NetworkError@Base" 0.4+14.10.20140618 |
85 | 110 | (c++)"typeinfo for Ubuntu::DownloadManager::ProcessError@Base" 0.4+14.10.20140618 | 110 | (c++)"typeinfo for Ubuntu::DownloadManager::ProcessError@Base" 0.4+14.10.20140618 |
86 | 111 | (c++)"typeinfo for Ubuntu::DownloadManager::DownloadsList@Base" 0.4+14.10.20140618 | 111 | (c++)"typeinfo for Ubuntu::DownloadManager::DownloadsList@Base" 0.4+14.10.20140618 |
87 | 112 | 112 | ||
88 | === modified file 'debian/libubuntu-download-manager-common-dev.install' | |||
89 | --- debian/libubuntu-download-manager-common-dev.install 2014-06-06 10:05:15 +0000 | |||
90 | +++ debian/libubuntu-download-manager-common-dev.install 2015-11-26 12:58:55 +0000 | |||
91 | @@ -1,4 +1,5 @@ | |||
92 | 1 | usr/include/ubuntu/download_manager/metatypes.h | 1 | usr/include/ubuntu/download_manager/metatypes.h |
93 | 2 | usr/include/ubuntu/download_manager/download_state_struct.h | ||
94 | 2 | usr/include/ubuntu/download_manager/download_struct.h | 3 | usr/include/ubuntu/download_manager/download_struct.h |
95 | 3 | usr/include/ubuntu/download_manager/group_download_struct.h | 4 | usr/include/ubuntu/download_manager/group_download_struct.h |
96 | 4 | usr/lib/*/pkgconfig/ubuntu-download-manager-common.pc | 5 | usr/lib/*/pkgconfig/ubuntu-download-manager-common.pc |
97 | 5 | 6 | ||
98 | === modified file 'debian/libubuntu-download-manager-common1.symbols' | |||
99 | --- debian/libubuntu-download-manager-common1.symbols 2015-07-23 14:02:27 +0000 | |||
100 | +++ debian/libubuntu-download-manager-common1.symbols 2015-11-26 12:58:55 +0000 | |||
101 | @@ -15,14 +15,29 @@ | |||
102 | 15 | (c++)"Ubuntu::DownloadManager::DownloadStruct::DownloadStruct(Ubuntu::DownloadManager::DownloadStruct const&)@Base" 0.4+14.10.20140618 | 15 | (c++)"Ubuntu::DownloadManager::DownloadStruct::DownloadStruct(Ubuntu::DownloadManager::DownloadStruct const&)@Base" 0.4+14.10.20140618 |
103 | 16 | (c++)"Ubuntu::DownloadManager::DownloadStruct::DownloadStruct()@Base" 0.4+14.10.20140618 | 16 | (c++)"Ubuntu::DownloadManager::DownloadStruct::DownloadStruct()@Base" 0.4+14.10.20140618 |
104 | 17 | (c++)"Ubuntu::DownloadManager::DownloadStruct::operator=(Ubuntu::DownloadManager::DownloadStruct const&)@Base" 0.4+14.10.20140618 | 17 | (c++)"Ubuntu::DownloadManager::DownloadStruct::operator=(Ubuntu::DownloadManager::DownloadStruct const&)@Base" 0.4+14.10.20140618 |
113 | 18 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::GroupDownloadStruct(QString const&, QString const&, QString const&)@Base" 0.4+14.10.20140618 | 18 | (c++)"Ubuntu::DownloadManager::DownloadStateStruct::isValid()@Base" 1.2 |
114 | 19 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::GroupDownloadStruct(Ubuntu::DownloadManager::GroupDownloadStruct const&)@Base" 0.4+14.10.20140618 | 19 | (c++)"Ubuntu::DownloadManager::DownloadStateStruct::DownloadStateStruct(Ubuntu::DownloadManager::DownloadStateStruct const&)@Base" 1.2 |
115 | 20 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::GroupDownloadStruct()@Base" 0.4+14.10.20140618 | 20 | (c++)"Ubuntu::DownloadManager::DownloadStateStruct::DownloadStateStruct(int, QString const&, QString const&)@Base" 1.2 |
116 | 21 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::GroupDownloadStruct(QString const&, QString const&, QString const&)@Base" 0.4+14.10.20140618 | 21 | (c++)"Ubuntu::DownloadManager::DownloadStateStruct::DownloadStateStruct(int, QString const&, QString const&, QString const&)@Base" 1.2 |
117 | 22 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::GroupDownloadStruct(Ubuntu::DownloadManager::GroupDownloadStruct const&)@Base" 0.4+14.10.20140618 | 22 | (c++)"Ubuntu::DownloadManager::DownloadStateStruct::DownloadStateStruct()@Base" 1.2 |
118 | 23 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::GroupDownloadStruct()@Base" 0.4+14.10.20140618 | 23 | (c++)"Ubuntu::DownloadManager::DownloadStateStruct::DownloadStateStruct(Ubuntu::DownloadManager::DownloadStateStruct const&)@Base" 1.2 |
119 | 24 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::~GroupDownloadStruct()@Base" 0.4+14.10.20140618 | 24 | (c++)"Ubuntu::DownloadManager::DownloadStateStruct::DownloadStateStruct(int, QString const&, QString const&)@Base" 1.2 |
120 | 25 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::~GroupDownloadStruct()@Base" 0.4+14.10.20140618 | 25 | (c++)"Ubuntu::DownloadManager::DownloadStateStruct::DownloadStateStruct(int, QString const&, QString const&, QString const&)@Base" 1.2 |
121 | 26 | (c++)"Ubuntu::DownloadManager::DownloadStateStruct::operator=(Ubuntu::DownloadManager::DownloadStateStruct const&)@Base" 1.2 | ||
122 | 27 | (c++)"Ubuntu::DownloadManager::operator<<(QDBusArgument&, Ubuntu::DownloadManager::DownloadStateStruct const&)@Base" 1.2 | ||
123 | 28 | (c++)"Ubuntu::DownloadManager::operator>>(QDBusArgument const&, Ubuntu::DownloadManager::DownloadStateStruct&)@Base" 1.2 | ||
124 | 29 | (c++)"Ubuntu::DownloadManager::DownloadStateStruct::getFilePath() const@Base" 1.2 | ||
125 | 30 | (c++)"Ubuntu::DownloadManager::DownloadStateStruct::getUrl() const@Base" 1.2 | ||
126 | 31 | (c++)"Ubuntu::DownloadManager::DownloadStateStruct::getHash() const@Base" 1.2 | ||
127 | 32 | (c++)"Ubuntu::DownloadManager::DownloadStateStruct::getState() const@Base" 1.2 | ||
128 | 33 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::~GroupDownloadStruct()@Base" 1.2 | ||
129 | 34 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::~GroupDownloadStruct()@Base" 1.2 | ||
130 | 35 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::GroupDownloadStruct(QString const&, QString const&, QString const&)@Base" 0.4+14.10.20140618 | ||
131 | 36 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::GroupDownloadStruct(Ubuntu::DownloadManager::GroupDownloadStruct const&)@Base" 0.4+14.10.20140618 | ||
132 | 37 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::GroupDownloadStruct()@Base" 0.4+14.10.20140618 | ||
133 | 38 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::GroupDownloadStruct(QString const&, QString const&, QString const&)@Base" 0.4+14.10.20140618 | ||
134 | 39 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::GroupDownloadStruct(Ubuntu::DownloadManager::GroupDownloadStruct const&)@Base" 0.4+14.10.20140618 | ||
135 | 40 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::GroupDownloadStruct()@Base" 0.4+14.10.20140618 | ||
136 | 26 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::operator=(Ubuntu::DownloadManager::GroupDownloadStruct const&)@Base" 0.4+14.10.20140618 | 41 | (c++)"Ubuntu::DownloadManager::GroupDownloadStruct::operator=(Ubuntu::DownloadManager::GroupDownloadStruct const&)@Base" 0.4+14.10.20140618 |
137 | 27 | (c++)"Ubuntu::DownloadManager::operator<<(QDBusArgument&, Ubuntu::DownloadManager::DownloadStruct const&)@Base" 0.4+14.10.20140618 | 42 | (c++)"Ubuntu::DownloadManager::operator<<(QDBusArgument&, Ubuntu::DownloadManager::DownloadStruct const&)@Base" 0.4+14.10.20140618 |
138 | 28 | (c++)"Ubuntu::DownloadManager::operator<<(QDBusArgument&, Ubuntu::DownloadManager::GroupDownloadStruct const&)@Base" 0.4+14.10.20140618 | 43 | (c++)"Ubuntu::DownloadManager::operator<<(QDBusArgument&, Ubuntu::DownloadManager::GroupDownloadStruct const&)@Base" 0.4+14.10.20140618 |
139 | 29 | 44 | ||
140 | === modified file 'debian/libudm-common1.symbols' | |||
141 | --- debian/libudm-common1.symbols 2015-09-22 15:27:25 +0000 | |||
142 | +++ debian/libudm-common1.symbols 2015-11-26 12:58:55 +0000 | |||
143 | @@ -56,7 +56,7 @@ | |||
144 | 56 | (c++)"Ubuntu::Transfers::System::Logger::qt_metacall(QMetaObject::Call, int, void**)@Base" 0.4+14.10.20140618 | 56 | (c++)"Ubuntu::Transfers::System::Logger::qt_metacall(QMetaObject::Call, int, void**)@Base" 0.4+14.10.20140618 |
145 | 57 | (c++)"Ubuntu::Transfers::System::Logger::qt_metacast(char const*)@Base" 0.4+14.10.20140618 | 57 | (c++)"Ubuntu::Transfers::System::Logger::qt_metacast(char const*)@Base" 0.4+14.10.20140618 |
146 | 58 | (c++)"Ubuntu::Transfers::System::Logger::setLogLevel(QtMsgType)@Base" 0.4+14.10.20140618 | 58 | (c++)"Ubuntu::Transfers::System::Logger::setLogLevel(QtMsgType)@Base" 0.4+14.10.20140618 |
148 | 59 | (c++)"Ubuntu::Transfers::System::Logger::toStdString(QString const&)@Base" 0.4+14.10.20140618 | 59 | (c++)"Ubuntu::Transfers::System::Logger::toStdString(QString const&)@Base" 0replaceme |
149 | 60 | (c++)"Ubuntu::Transfers::System::Logger::setupLogging(QString)@Base" 0.4+14.10.20140618 | 60 | (c++)"Ubuntu::Transfers::System::Logger::setupLogging(QString)@Base" 0.4+14.10.20140618 |
150 | 61 | (c++)"Ubuntu::Transfers::System::Logger::staticMetaObject@Base" 0.4+14.10.20140618 | 61 | (c++)"Ubuntu::Transfers::System::Logger::staticMetaObject@Base" 0.4+14.10.20140618 |
151 | 62 | (c++)"Ubuntu::Transfers::System::Logger::getLogDir()@Base" 0.4+14.10.20140618 | 62 | (c++)"Ubuntu::Transfers::System::Logger::getLogDir()@Base" 0.4+14.10.20140618 |
152 | 63 | 63 | ||
153 | === modified file 'docs/dbus/com.canonical.applications.download.xml' | |||
154 | --- docs/dbus/com.canonical.applications.download.xml 2015-09-22 15:25:33 +0000 | |||
155 | +++ docs/dbus/com.canonical.applications.download.xml 2015-11-26 12:58:55 +0000 | |||
156 | @@ -49,10 +49,19 @@ | |||
157 | 49 | <arg name="allowed" type="b" direction="out"/> | 49 | <arg name="allowed" type="b" direction="out"/> |
158 | 50 | </method> | 50 | </method> |
159 | 51 | 51 | ||
160 | 52 | <method name="filePath"> | ||
161 | 53 | <arg name="filepath" type="s" direction="out"/> | ||
162 | 54 | </method> | ||
163 | 55 | |||
164 | 56 | <method name="state"> | ||
165 | 57 | <arg name="state" type="i" direction="out"/> | ||
166 | 58 | </method> | ||
167 | 59 | |||
168 | 52 | <method name="start" /> | 60 | <method name="start" /> |
169 | 53 | <method name="pause" /> | 61 | <method name="pause" /> |
170 | 54 | <method name="resume" /> | 62 | <method name="resume" /> |
171 | 55 | <method name="cancel" /> | 63 | <method name="cancel" /> |
172 | 64 | <method name="collected" /> | ||
173 | 56 | 65 | ||
174 | 57 | <signal name="started"> | 66 | <signal name="started"> |
175 | 58 | <arg name="success" type="b" direction="out"/> | 67 | <arg name="success" type="b" direction="out"/> |
176 | 59 | 68 | ||
177 | === modified file 'docs/dbus/com.canonical.applications.download_manager.xml' | |||
178 | --- docs/dbus/com.canonical.applications.download_manager.xml 2014-04-30 14:47:38 +0000 | |||
179 | +++ docs/dbus/com.canonical.applications.download_manager.xml 2015-11-26 12:58:55 +0000 | |||
180 | @@ -35,6 +35,17 @@ | |||
181 | 35 | <arg name="downloads" type="ao" direction="out" /> | 35 | <arg name="downloads" type="ao" direction="out" /> |
182 | 36 | </method> | 36 | </method> |
183 | 37 | 37 | ||
184 | 38 | <method name="getUncollectedDownloads"> | ||
185 | 39 | <arg name="appId" type="s" direction="in"/> | ||
186 | 40 | <arg name="downloads" type="ao" direction="out"/> | ||
187 | 41 | </method> | ||
188 | 42 | |||
189 | 43 | <method name="getDownloadState"> | ||
190 | 44 | <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="DownloadStateStruct"/> | ||
191 | 45 | <arg name="downloadId" type="s" direction="in"/> | ||
192 | 46 | <arg name="state" type="(issss)" direction="out"/> | ||
193 | 47 | </method> | ||
194 | 48 | |||
195 | 38 | <method name="setDefaultThrottle"> | 49 | <method name="setDefaultThrottle"> |
196 | 39 | <arg name="speed" type="t" direction="in"/> | 50 | <arg name="speed" type="t" direction="in"/> |
197 | 40 | </method> | 51 | </method> |
198 | 41 | 52 | ||
199 | === modified file 'docs/qml/pages/mainpage.qdoc' | |||
200 | --- docs/qml/pages/mainpage.qdoc 2014-06-20 10:10:50 +0000 | |||
201 | +++ docs/qml/pages/mainpage.qdoc 2015-11-26 12:58:55 +0000 | |||
202 | @@ -35,7 +35,7 @@ | |||
203 | 35 | \section1 Components | 35 | \section1 Components |
204 | 36 | Available through: | 36 | Available through: |
205 | 37 | \code | 37 | \code |
207 | 38 | import Ubuntu.DownloadManager 0.1 | 38 | import Ubuntu.DownloadManager 1.2 |
208 | 39 | \endcode | 39 | \endcode |
209 | 40 | 40 | ||
210 | 41 | \list | 41 | \list |
211 | @@ -47,8 +47,8 @@ | |||
212 | 47 | 47 | ||
213 | 48 | \qml | 48 | \qml |
214 | 49 | import QtQuick 2.0 | 49 | import QtQuick 2.0 |
217 | 50 | import Ubuntu.Components 0.1 | 50 | import Ubuntu.Components 1.2 |
218 | 51 | import Ubuntu.DownloadManager 0.1 | 51 | import Ubuntu.DownloadManager 1.2 |
219 | 52 | 52 | ||
220 | 53 | Rectangle { | 53 | Rectangle { |
221 | 54 | width: units.gu(100) | 54 | width: units.gu(100) |
222 | 55 | 55 | ||
223 | === modified file 'docs/qml/pages/moduledef.qdoc' | |||
224 | --- docs/qml/pages/moduledef.qdoc 2014-06-20 10:10:50 +0000 | |||
225 | +++ docs/qml/pages/moduledef.qdoc 2015-11-26 12:58:55 +0000 | |||
226 | @@ -1,3 +1,3 @@ | |||
227 | 1 | /*! | 1 | /*! |
229 | 2 | \qmlmodule Ubuntu.DownloadManager 0.1 | 2 | \qmlmodule Ubuntu.DownloadManager 1.2 |
230 | 3 | */ | 3 | */ |
231 | 4 | 4 | ||
232 | === modified file 'src/common/priv/ubuntu/transfers/queue.cpp' | |||
233 | --- src/common/priv/ubuntu/transfers/queue.cpp 2014-11-24 16:39:17 +0000 | |||
234 | +++ src/common/priv/ubuntu/transfers/queue.cpp 2015-11-26 12:58:55 +0000 | |||
235 | @@ -127,6 +127,7 @@ | |||
236 | 127 | break; | 127 | break; |
237 | 128 | case Transfer::ERROR: | 128 | case Transfer::ERROR: |
238 | 129 | case Transfer::FINISH: | 129 | case Transfer::FINISH: |
239 | 130 | case Transfer::UNCOLLECTED: | ||
240 | 130 | // remove the registered object in dbus, remove the transfer | 131 | // remove the registered object in dbus, remove the transfer |
241 | 131 | // and the adapter from the list | 132 | // and the adapter from the list |
242 | 132 | if (!_current.isEmpty() && _current == transfer->path()) | 133 | if (!_current.isEmpty() && _current == transfer->path()) |
243 | @@ -177,6 +178,9 @@ | |||
244 | 177 | LOG(INFO) << "State is CANCEL || FINISH || ERROR"; | 178 | LOG(INFO) << "State is CANCEL || FINISH || ERROR"; |
245 | 178 | remove(_current); | 179 | remove(_current); |
246 | 179 | _current = ""; | 180 | _current = ""; |
247 | 181 | } else if (state == Transfer::UNCOLLECTED) { | ||
248 | 182 | LOG(INFO) << "State is UNCOLLECTED"; | ||
249 | 183 | _current = ""; | ||
250 | 180 | } else if (!currentTransfer->canTransfer() | 184 | } else if (!currentTransfer->canTransfer() |
251 | 181 | || state == Transfer::PAUSE) { | 185 | || state == Transfer::PAUSE) { |
252 | 182 | LOG(INFO) << "States is Cannot Transfer || PAUSE"; | 186 | LOG(INFO) << "States is Cannot Transfer || PAUSE"; |
253 | 183 | 187 | ||
254 | === modified file 'src/common/priv/ubuntu/transfers/transfer.cpp' | |||
255 | --- src/common/priv/ubuntu/transfers/transfer.cpp 2014-11-26 12:21:53 +0000 | |||
256 | +++ src/common/priv/ubuntu/transfers/transfer.cpp 2015-11-26 12:58:55 +0000 | |||
257 | @@ -194,6 +194,13 @@ | |||
258 | 194 | startTransfer(); | 194 | startTransfer(); |
259 | 195 | } | 195 | } |
260 | 196 | 196 | ||
261 | 197 | void | ||
262 | 198 | Transfer::collected() { | ||
263 | 199 | if (state() == Transfer::UNCOLLECTED) { | ||
264 | 200 | setState(Transfer::FINISH); | ||
265 | 201 | } | ||
266 | 202 | } | ||
267 | 203 | |||
268 | 197 | } // General | 204 | } // General |
269 | 198 | 205 | ||
270 | 199 | } // Ubuntu | 206 | } // Ubuntu |
271 | 200 | 207 | ||
272 | === modified file 'src/common/priv/ubuntu/transfers/transfer.h' | |||
273 | --- src/common/priv/ubuntu/transfers/transfer.h 2015-02-02 11:05:15 +0000 | |||
274 | +++ src/common/priv/ubuntu/transfers/transfer.h 2015-11-26 12:58:55 +0000 | |||
275 | @@ -16,8 +16,7 @@ | |||
276 | 16 | * Boston, MA 02110-1301, USA. | 16 | * Boston, MA 02110-1301, USA. |
277 | 17 | */ | 17 | */ |
278 | 18 | 18 | ||
281 | 19 | #ifndef UBUNTU_GENERAL_LIB_TRANSFER_H | 19 | #pragma once |
280 | 20 | #define UBUNTU_GENERAL_LIB_TRANSFER_H | ||
282 | 21 | 20 | ||
283 | 22 | #include <QObject> | 21 | #include <QObject> |
284 | 23 | #include "ubuntu/transfers/system/network_session.h" | 22 | #include "ubuntu/transfers/system/network_session.h" |
285 | @@ -36,6 +35,7 @@ | |||
286 | 36 | PAUSE, | 35 | PAUSE, |
287 | 37 | RESUME, | 36 | RESUME, |
288 | 38 | CANCEL, | 37 | CANCEL, |
289 | 38 | UNCOLLECTED, | ||
290 | 39 | FINISH, | 39 | FINISH, |
291 | 40 | ERROR | 40 | ERROR |
292 | 41 | }; | 41 | }; |
293 | @@ -78,6 +78,7 @@ | |||
294 | 78 | virtual void pause(); | 78 | virtual void pause(); |
295 | 79 | virtual void resume(); | 79 | virtual void resume(); |
296 | 80 | virtual void start(); | 80 | virtual void start(); |
297 | 81 | virtual void collected(); | ||
298 | 81 | 82 | ||
299 | 82 | signals: | 83 | signals: |
300 | 83 | void canceled(bool success); | 84 | void canceled(bool success); |
301 | @@ -112,5 +113,3 @@ | |||
302 | 112 | } // Transfers | 113 | } // Transfers |
303 | 113 | 114 | ||
304 | 114 | } // Ubuntu | 115 | } // Ubuntu |
305 | 115 | |||
306 | 116 | #endif | ||
307 | 117 | 116 | ||
308 | === modified file 'src/common/public/ubuntu/transfers/metadata.cpp' | |||
309 | --- src/common/public/ubuntu/transfers/metadata.cpp 2015-09-22 15:25:33 +0000 | |||
310 | +++ src/common/public/ubuntu/transfers/metadata.cpp 2015-11-26 12:58:55 +0000 | |||
311 | @@ -17,6 +17,7 @@ | |||
312 | 17 | */ | 17 | */ |
313 | 18 | 18 | ||
314 | 19 | #include <QProcessEnvironment> | 19 | #include <QProcessEnvironment> |
315 | 20 | #include <QCoreApplication> | ||
316 | 20 | 21 | ||
317 | 21 | #include "metadata.h" | 22 | #include "metadata.h" |
318 | 22 | 23 | ||
319 | @@ -43,6 +44,8 @@ | |||
320 | 43 | auto environment = QProcessEnvironment::systemEnvironment(); | 44 | auto environment = QProcessEnvironment::systemEnvironment(); |
321 | 44 | if (environment.contains(APP_ID_ENV)) { | 45 | if (environment.contains(APP_ID_ENV)) { |
322 | 45 | setDestinationApp(environment.value(APP_ID_ENV)); | 46 | setDestinationApp(environment.value(APP_ID_ENV)); |
323 | 47 | } else { | ||
324 | 48 | setDestinationApp(QCoreApplication::applicationFilePath()); | ||
325 | 46 | } | 49 | } |
326 | 47 | } | 50 | } |
327 | 48 | 51 | ||
328 | @@ -53,6 +56,11 @@ | |||
329 | 53 | auto environment = QProcessEnvironment::systemEnvironment(); | 56 | auto environment = QProcessEnvironment::systemEnvironment(); |
330 | 54 | environment.contains(APP_ID_ENV); | 57 | environment.contains(APP_ID_ENV); |
331 | 55 | setDestinationApp(environment.value(APP_ID_ENV)); | 58 | setDestinationApp(environment.value(APP_ID_ENV)); |
332 | 59 | if (environment.contains(APP_ID_ENV)) { | ||
333 | 60 | setDestinationApp(environment.value(APP_ID_ENV)); | ||
334 | 61 | } else { | ||
335 | 62 | setDestinationApp(QCoreApplication::applicationFilePath()); | ||
336 | 63 | } | ||
337 | 56 | } | 64 | } |
338 | 57 | } | 65 | } |
339 | 58 | 66 | ||
340 | 59 | 67 | ||
341 | === modified file 'src/downloads/client/ubuntu/download_manager/download.h' | |||
342 | --- src/downloads/client/ubuntu/download_manager/download.h 2015-09-22 14:54:32 +0000 | |||
343 | +++ src/downloads/client/ubuntu/download_manager/download.h 2015-11-26 12:58:55 +0000 | |||
344 | @@ -56,6 +56,17 @@ | |||
345 | 56 | explicit Download(QObject* parent = 0) | 56 | explicit Download(QObject* parent = 0) |
346 | 57 | : QObject(parent) {} | 57 | : QObject(parent) {} |
347 | 58 | 58 | ||
348 | 59 | enum State { | ||
349 | 60 | IDLE, | ||
350 | 61 | START, | ||
351 | 62 | PAUSE, | ||
352 | 63 | RESUME, | ||
353 | 64 | CANCEL, | ||
354 | 65 | UNCOLLECTED, | ||
355 | 66 | FINISH, | ||
356 | 67 | ERROR | ||
357 | 68 | }; | ||
358 | 69 | |||
359 | 59 | /*! | 70 | /*! |
360 | 60 | \fn void Download::start() | 71 | \fn void Download::start() |
361 | 61 | 72 | ||
362 | @@ -97,6 +108,15 @@ | |||
363 | 97 | virtual void cancel() = 0; | 108 | virtual void cancel() = 0; |
364 | 98 | 109 | ||
365 | 99 | /*! | 110 | /*! |
366 | 111 | \fn void Download::collected() | ||
367 | 112 | |||
368 | 113 | Notifies the download manager that the finished signal for this | ||
369 | 114 | download object has been received by the client. This allows UDM | ||
370 | 115 | to report downloads that have finished while a client isn't running. | ||
371 | 116 | */ | ||
372 | 117 | virtual void collected() = 0; | ||
373 | 118 | |||
374 | 119 | /*! | ||
375 | 100 | \fn void Download::allowMobileDownload(bool allowed) | 120 | \fn void Download::allowMobileDownload(bool allowed) |
376 | 101 | 121 | ||
377 | 102 | Notifies the download manager that the download represented by this | 122 | Notifies the download manager that the download represented by this |
378 | @@ -201,6 +221,21 @@ | |||
379 | 201 | virtual qulonglong totalSize() = 0; | 221 | virtual qulonglong totalSize() = 0; |
380 | 202 | 222 | ||
381 | 203 | /*! | 223 | /*! |
382 | 224 | \fn QString filePath() | ||
383 | 225 | |||
384 | 226 | Returns the value of the downloaded file's location. This is only set once | ||
385 | 227 | the download is complete. | ||
386 | 228 | */ | ||
387 | 229 | virtual QString filePath() = 0; | ||
388 | 230 | |||
389 | 231 | /*! | ||
390 | 232 | \fn State state() | ||
391 | 233 | |||
392 | 234 | Returns the current state of the download. | ||
393 | 235 | */ | ||
394 | 236 | virtual State state() = 0; | ||
395 | 237 | |||
396 | 238 | /*! | ||
397 | 204 | \fn bool isError() const | 239 | \fn bool isError() const |
398 | 205 | 240 | ||
399 | 206 | Returns if the download represented by the object has had an error. | 241 | Returns if the download represented by the object has had an error. |
400 | 207 | 242 | ||
401 | === modified file 'src/downloads/client/ubuntu/download_manager/download_impl.cpp' | |||
402 | --- src/downloads/client/ubuntu/download_manager/download_impl.cpp 2015-09-22 14:54:32 +0000 | |||
403 | +++ src/downloads/client/ubuntu/download_manager/download_impl.cpp 2015-11-26 12:58:55 +0000 | |||
404 | @@ -62,6 +62,13 @@ | |||
405 | 62 | "Could not connect to signal &DownloadInterface::finished"); | 62 | "Could not connect to signal &DownloadInterface::finished"); |
406 | 63 | } | 63 | } |
407 | 64 | 64 | ||
408 | 65 | connected = connect(_dbusInterface, &DownloadInterface::finished, | ||
409 | 66 | this, &DownloadImpl::onFinished); | ||
410 | 67 | if (!connected) { | ||
411 | 68 | Logger::log(Logger::Critical, | ||
412 | 69 | "Could not connect to signal &DownloadInterface::finished"); | ||
413 | 70 | } | ||
414 | 71 | |||
415 | 65 | connected = connect(_dbusInterface, &DownloadInterface::paused, | 72 | connected = connect(_dbusInterface, &DownloadInterface::paused, |
416 | 66 | this, &Download::paused); | 73 | this, &Download::paused); |
417 | 67 | if (!connected) { | 74 | if (!connected) { |
418 | @@ -216,6 +223,19 @@ | |||
419 | 216 | } | 223 | } |
420 | 217 | 224 | ||
421 | 218 | void | 225 | void |
422 | 226 | DownloadImpl::collected() { | ||
423 | 227 | Logger::log(Logger::Debug, QString("Download{%1} collected()").arg(_id)); | ||
424 | 228 | QDBusPendingReply<> reply = | ||
425 | 229 | _dbusInterface->collected(); | ||
426 | 230 | // block, the call should be fast enough | ||
427 | 231 | reply.waitForFinished(); | ||
428 | 232 | if (reply.isError()) { | ||
429 | 233 | Logger::log(Logger::Error, "Error when setting download collected"); | ||
430 | 234 | setLastError(reply.error()); | ||
431 | 235 | } | ||
432 | 236 | } | ||
433 | 237 | |||
434 | 238 | void | ||
435 | 219 | DownloadImpl::allowMobileDownload(bool allowed) { | 239 | DownloadImpl::allowMobileDownload(bool allowed) { |
436 | 220 | Logger::log(Logger::Debug, | 240 | Logger::log(Logger::Debug, |
437 | 221 | QString("Download{%1} allowMobileDownload%2())").arg(_id).arg(allowed)); | 241 | QString("Download{%1} allowMobileDownload%2())").arg(_id).arg(allowed)); |
438 | @@ -304,9 +324,7 @@ | |||
439 | 304 | // block, the call should be fast enough | 324 | // block, the call should be fast enough |
440 | 305 | reply.waitForFinished(); | 325 | reply.waitForFinished(); |
441 | 306 | if (reply.isError()) { | 326 | if (reply.isError()) { |
442 | 307 | qDebug() << "Error setting metadata"; | ||
443 | 308 | Logger::log(Logger::Error, "Error setting the download metadata"); | 327 | Logger::log(Logger::Error, "Error setting the download metadata"); |
444 | 309 | qDebug() << reply.error(); | ||
445 | 310 | setLastError(reply.error()); | 328 | setLastError(reply.error()); |
446 | 311 | } | 329 | } |
447 | 312 | } | 330 | } |
448 | @@ -362,6 +380,40 @@ | |||
449 | 362 | } | 380 | } |
450 | 363 | 381 | ||
451 | 364 | QString | 382 | QString |
452 | 383 | DownloadImpl::filePath() { | ||
453 | 384 | Logger::log(Logger::Debug, QString("Download{%1} filePath()").arg(_id)); | ||
454 | 385 | QDBusPendingReply<QString> reply = | ||
455 | 386 | _dbusInterface->filePath(); | ||
456 | 387 | // block, the call is fast enough | ||
457 | 388 | reply.waitForFinished(); | ||
458 | 389 | if (reply.isError()) { | ||
459 | 390 | Logger::log(Logger::Error, "Error querying the download file path"); | ||
460 | 391 | setLastError(reply.error()); | ||
461 | 392 | return ""; | ||
462 | 393 | } else { | ||
463 | 394 | auto result = reply.value(); | ||
464 | 395 | return result; | ||
465 | 396 | } | ||
466 | 397 | } | ||
467 | 398 | |||
468 | 399 | Download::State | ||
469 | 400 | DownloadImpl::state() { | ||
470 | 401 | Logger::log(Logger::Debug, QString("Download{%1} state()").arg(_id)); | ||
471 | 402 | QDBusPendingReply<int> reply = | ||
472 | 403 | _dbusInterface->state(); | ||
473 | 404 | // block, the call is fast enough | ||
474 | 405 | reply.waitForFinished(); | ||
475 | 406 | if (reply.isError()) { | ||
476 | 407 | Logger::log(Logger::Error, "Error querying the download state"); | ||
477 | 408 | setLastError(reply.error()); | ||
478 | 409 | return Download::ERROR; | ||
479 | 410 | } else { | ||
480 | 411 | auto result = static_cast<Download::State>(reply.value()); | ||
481 | 412 | return result; | ||
482 | 413 | } | ||
483 | 414 | } | ||
484 | 415 | |||
485 | 416 | QString | ||
486 | 365 | DownloadImpl::id() const { | 417 | DownloadImpl::id() const { |
487 | 366 | return _id; | 418 | return _id; |
488 | 367 | } | 419 | } |
489 | @@ -481,6 +533,13 @@ | |||
490 | 481 | } | 533 | } |
491 | 482 | } | 534 | } |
492 | 483 | 535 | ||
493 | 536 | void DownloadImpl::onFinished(const QString &path) { | ||
494 | 537 | Q_UNUSED(path); | ||
495 | 538 | // Inform UDM that we've received the finished signal, so the download | ||
496 | 539 | // can be considered completely finished. | ||
497 | 540 | collected(); | ||
498 | 541 | } | ||
499 | 542 | |||
500 | 484 | } // DownloadManager | 543 | } // DownloadManager |
501 | 485 | 544 | ||
502 | 486 | } // Ubuntu | 545 | } // Ubuntu |
503 | 487 | 546 | ||
504 | === modified file 'src/downloads/client/ubuntu/download_manager/download_impl.h' | |||
505 | --- src/downloads/client/ubuntu/download_manager/download_impl.h 2015-09-22 14:14:06 +0000 | |||
506 | +++ src/downloads/client/ubuntu/download_manager/download_impl.h 2015-11-26 12:58:55 +0000 | |||
507 | @@ -59,6 +59,7 @@ | |||
508 | 59 | void pause(); | 59 | void pause(); |
509 | 60 | void resume(); | 60 | void resume(); |
510 | 61 | void cancel(); | 61 | void cancel(); |
511 | 62 | void collected(); | ||
512 | 62 | 63 | ||
513 | 63 | void allowMobileDownload(bool allowed); | 64 | void allowMobileDownload(bool allowed); |
514 | 64 | bool isMobileDownloadAllowed(); | 65 | bool isMobileDownloadAllowed(); |
515 | @@ -70,6 +71,8 @@ | |||
516 | 70 | void setMetadata(QVariantMap map); | 71 | void setMetadata(QVariantMap map); |
517 | 71 | void setThrottle(qulonglong speed); | 72 | void setThrottle(qulonglong speed); |
518 | 72 | qulonglong throttle(); | 73 | qulonglong throttle(); |
519 | 74 | QString filePath(); | ||
520 | 75 | Download::State state(); | ||
521 | 73 | 76 | ||
522 | 74 | QString id() const; | 77 | QString id() const; |
523 | 75 | qulonglong progress(); | 78 | qulonglong progress(); |
524 | @@ -101,6 +104,7 @@ | |||
525 | 101 | void onPropertiesChanged(const QString& interfaceName, | 104 | void onPropertiesChanged(const QString& interfaceName, |
526 | 102 | const QVariantMap& changedProperties, | 105 | const QVariantMap& changedProperties, |
527 | 103 | const QStringList& invalidatedProperties); | 106 | const QStringList& invalidatedProperties); |
528 | 107 | void onFinished(const QString& path); | ||
529 | 104 | 108 | ||
530 | 105 | private: | 109 | private: |
531 | 106 | QString _id; | 110 | QString _id; |
532 | 107 | 111 | ||
533 | === modified file 'src/downloads/client/ubuntu/download_manager/download_interface.h' | |||
534 | --- src/downloads/client/ubuntu/download_manager/download_interface.h 2015-09-22 14:54:32 +0000 | |||
535 | +++ src/downloads/client/ubuntu/download_manager/download_interface.h 2015-11-26 12:58:55 +0000 | |||
536 | @@ -66,6 +66,18 @@ | |||
537 | 66 | return asyncCallWithArgumentList(QStringLiteral("cancel"), argumentList); | 66 | return asyncCallWithArgumentList(QStringLiteral("cancel"), argumentList); |
538 | 67 | } | 67 | } |
539 | 68 | 68 | ||
540 | 69 | inline QDBusPendingReply<> collected() | ||
541 | 70 | { | ||
542 | 71 | QList<QVariant> argumentList; | ||
543 | 72 | return asyncCallWithArgumentList(QStringLiteral("collected"), argumentList); | ||
544 | 73 | } | ||
545 | 74 | |||
546 | 75 | inline QDBusPendingReply<QString> filePath() | ||
547 | 76 | { | ||
548 | 77 | QList<QVariant> argumentList; | ||
549 | 78 | return asyncCallWithArgumentList(QStringLiteral("filePath"), argumentList); | ||
550 | 79 | } | ||
551 | 80 | |||
552 | 69 | inline QDBusPendingReply<StringMap> headers() | 81 | inline QDBusPendingReply<StringMap> headers() |
553 | 70 | { | 82 | { |
554 | 71 | QList<QVariant> argumentList; | 83 | QList<QVariant> argumentList; |
555 | @@ -136,6 +148,12 @@ | |||
556 | 136 | return asyncCallWithArgumentList(QStringLiteral("start"), argumentList); | 148 | return asyncCallWithArgumentList(QStringLiteral("start"), argumentList); |
557 | 137 | } | 149 | } |
558 | 138 | 150 | ||
559 | 151 | inline QDBusPendingReply<int> state() | ||
560 | 152 | { | ||
561 | 153 | QList<QVariant> argumentList; | ||
562 | 154 | return asyncCallWithArgumentList(QStringLiteral("state"), argumentList); | ||
563 | 155 | } | ||
564 | 156 | |||
565 | 139 | inline QDBusPendingReply<qulonglong> throttle() | 157 | inline QDBusPendingReply<qulonglong> throttle() |
566 | 140 | { | 158 | { |
567 | 141 | QList<QVariant> argumentList; | 159 | QList<QVariant> argumentList; |
568 | 142 | 160 | ||
569 | === modified file 'src/downloads/client/ubuntu/download_manager/manager.h' | |||
570 | --- src/downloads/client/ubuntu/download_manager/manager.h 2014-06-06 10:05:15 +0000 | |||
571 | +++ src/downloads/client/ubuntu/download_manager/manager.h 2015-11-26 12:58:55 +0000 | |||
572 | @@ -216,6 +216,33 @@ | |||
573 | 216 | MetadataDownloadsListCb errCb) = 0; | 216 | MetadataDownloadsListCb errCb) = 0; |
574 | 217 | 217 | ||
575 | 218 | /*! | 218 | /*! |
576 | 219 | \fn void getUncollectedDownloads(const QString &appId) | ||
577 | 220 | |||
578 | 221 | Returns uncollected downloads in the download manager that can be accessed | ||
579 | 222 | by the calling client. If the client is not confined then the downloads | ||
580 | 223 | returned will be those belonging to the app specified via the appId | ||
581 | 224 | parameter, on the other hand if the client is confined the result will | ||
582 | 225 | be only those downloads created by the client. The result of the method | ||
583 | 226 | is returned via the downloadsFound signal. | ||
584 | 227 | */ | ||
585 | 228 | virtual void getUncollectedDownloads(const QString &appId) = 0; | ||
586 | 229 | |||
587 | 230 | /*! | ||
588 | 231 | \fn void getUncollectedDownloads(const QString &appId) | ||
589 | 232 | |||
590 | 233 | Returns uncollected downloads in the download manager that can be accessed | ||
591 | 234 | by the calling client. If the client is not confined then the downloads | ||
592 | 235 | returned will be those belonging to the app specified via the appId | ||
593 | 236 | parameter, on the other hand if the client is confined the result will | ||
594 | 237 | be only those downloads created by the client. . If the method is a | ||
595 | 238 | success the \a cb is executed else \a errCb is executed. | ||
596 | 239 | */ | ||
597 | 240 | |||
598 | 241 | virtual void getUncollectedDownloads(const QString &appId, | ||
599 | 242 | DownloadsListCb cb, | ||
600 | 243 | DownloadsListCb errCb) = 0; | ||
601 | 244 | |||
602 | 245 | /*! | ||
603 | 219 | \fn bool isError() const | 246 | \fn bool isError() const |
604 | 220 | Returns if the manager received an error during the execution | 247 | Returns if the manager received an error during the execution |
605 | 221 | of a command. | 248 | of a command. |
606 | 222 | 249 | ||
607 | === modified file 'src/downloads/client/ubuntu/download_manager/manager_impl.cpp' | |||
608 | --- src/downloads/client/ubuntu/download_manager/manager_impl.cpp 2015-02-25 16:24:24 +0000 | |||
609 | +++ src/downloads/client/ubuntu/download_manager/manager_impl.cpp 2015-11-26 12:58:55 +0000 | |||
610 | @@ -193,6 +193,29 @@ | |||
611 | 193 | } | 193 | } |
612 | 194 | } | 194 | } |
613 | 195 | 195 | ||
614 | 196 | void | ||
615 | 197 | ManagerImpl::getUncollectedDownloads(const QString &appId) { | ||
616 | 198 | Logger::log(Logger::Debug, "Manager getUncollectedDownloads()"); | ||
617 | 199 | DownloadsListCb cb = [](DownloadsList*){}; | ||
618 | 200 | getUncollectedDownloads(appId, cb, cb); | ||
619 | 201 | } | ||
620 | 202 | |||
621 | 203 | void | ||
622 | 204 | ManagerImpl::getUncollectedDownloads(const QString &appId, | ||
623 | 205 | DownloadsListCb cb, | ||
624 | 206 | DownloadsListCb errCb) { | ||
625 | 207 | Logger::log(Logger::Debug, "Manager getUncollectedDownloads()"); | ||
626 | 208 | QDBusPendingCall call = _dbusInterface->getUncollectedDownloads(appId); | ||
627 | 209 | auto watcher = new DownloadsListManagerPCW( | ||
628 | 210 | _conn, _servicePath, call, cb, errCb, this); | ||
629 | 211 | auto connected = connect(watcher, &GroupManagerPCW::callbackExecuted, | ||
630 | 212 | this, &ManagerImpl::onWatcherDone); | ||
631 | 213 | if (!connected) { | ||
632 | 214 | Logger::log(Logger::Critical, | ||
633 | 215 | "Could not connect to signal"); | ||
634 | 216 | } | ||
635 | 217 | } | ||
636 | 218 | |||
637 | 196 | bool | 219 | bool |
638 | 197 | ManagerImpl::isError() const { | 220 | ManagerImpl::isError() const { |
639 | 198 | return _isError; | 221 | return _isError; |
640 | 199 | 222 | ||
641 | === modified file 'src/downloads/client/ubuntu/download_manager/manager_impl.h' | |||
642 | --- src/downloads/client/ubuntu/download_manager/manager_impl.h 2014-06-29 12:45:29 +0000 | |||
643 | +++ src/downloads/client/ubuntu/download_manager/manager_impl.h 2015-11-26 12:58:55 +0000 | |||
644 | @@ -81,6 +81,10 @@ | |||
645 | 81 | const QString &value, | 81 | const QString &value, |
646 | 82 | MetadataDownloadsListCb cb, | 82 | MetadataDownloadsListCb cb, |
647 | 83 | MetadataDownloadsListCb errCb); | 83 | MetadataDownloadsListCb errCb); |
648 | 84 | virtual void getUncollectedDownloads(const QString &appId); | ||
649 | 85 | virtual void getUncollectedDownloads(const QString &appId, | ||
650 | 86 | DownloadsListCb cb, | ||
651 | 87 | DownloadsListCb errCb); | ||
652 | 84 | 88 | ||
653 | 85 | bool isError() const; | 89 | bool isError() const; |
654 | 86 | Error* lastError() const; | 90 | Error* lastError() const; |
655 | 87 | 91 | ||
656 | === modified file 'src/downloads/client/ubuntu/download_manager/manager_interface.h' | |||
657 | --- src/downloads/client/ubuntu/download_manager/manager_interface.h 2014-02-26 19:54:31 +0000 | |||
658 | +++ src/downloads/client/ubuntu/download_manager/manager_interface.h 2015-11-26 12:58:55 +0000 | |||
659 | @@ -89,6 +89,13 @@ | |||
660 | 89 | return asyncCallWithArgumentList(QLatin1String("getAllDownloadsWithMetadata"), argumentList); | 89 | return asyncCallWithArgumentList(QLatin1String("getAllDownloadsWithMetadata"), argumentList); |
661 | 90 | } | 90 | } |
662 | 91 | 91 | ||
663 | 92 | inline QDBusPendingReply<QList<QDBusObjectPath> > getUncollectedDownloads(const QString &appId) | ||
664 | 93 | { | ||
665 | 94 | QList<QVariant> argumentList; | ||
666 | 95 | argumentList << QVariant::fromValue(appId); | ||
667 | 96 | return asyncCallWithArgumentList(QLatin1String("getUncollectedDownloads"), argumentList); | ||
668 | 97 | } | ||
669 | 98 | |||
670 | 92 | inline QDBusPendingReply<bool> isGSMDownloadAllowed() | 99 | inline QDBusPendingReply<bool> isGSMDownloadAllowed() |
671 | 93 | { | 100 | { |
672 | 94 | QList<QVariant> argumentList; | 101 | QList<QVariant> argumentList; |
673 | 95 | 102 | ||
674 | === modified file 'src/downloads/common/CMakeLists.txt' | |||
675 | --- src/downloads/common/CMakeLists.txt 2014-06-16 12:38:08 +0000 | |||
676 | +++ src/downloads/common/CMakeLists.txt 2015-11-26 12:58:55 +0000 | |||
677 | @@ -1,12 +1,14 @@ | |||
678 | 1 | set(TARGET ubuntu-download-manager-common) | 1 | set(TARGET ubuntu-download-manager-common) |
679 | 2 | 2 | ||
680 | 3 | set(SOURCES | 3 | set(SOURCES |
681 | 4 | ubuntu/download_manager/download_state_struct.cpp | ||
682 | 4 | ubuntu/download_manager/download_struct.cpp | 5 | ubuntu/download_manager/download_struct.cpp |
683 | 5 | ubuntu/download_manager/group_download_struct.cpp | 6 | ubuntu/download_manager/group_download_struct.cpp |
684 | 6 | ubuntu/download_manager/system/logger.cpp | 7 | ubuntu/download_manager/system/logger.cpp |
685 | 7 | ) | 8 | ) |
686 | 8 | 9 | ||
687 | 9 | set(PUBLIC_HEADERS | 10 | set(PUBLIC_HEADERS |
688 | 11 | ubuntu/download_manager/download_state_struct.h | ||
689 | 10 | ubuntu/download_manager/download_struct.h | 12 | ubuntu/download_manager/download_struct.h |
690 | 11 | ubuntu/download_manager/group_download_struct.h | 13 | ubuntu/download_manager/group_download_struct.h |
691 | 12 | ubuntu/download_manager/metatypes.h | 14 | ubuntu/download_manager/metatypes.h |
692 | 13 | 15 | ||
693 | === added file 'src/downloads/common/ubuntu/download_manager/download_state_struct.cpp' | |||
694 | --- src/downloads/common/ubuntu/download_manager/download_state_struct.cpp 1970-01-01 00:00:00 +0000 | |||
695 | +++ src/downloads/common/ubuntu/download_manager/download_state_struct.cpp 2015-11-26 12:58:55 +0000 | |||
696 | @@ -0,0 +1,119 @@ | |||
697 | 1 | /* | ||
698 | 2 | * Copyright 2013-2014 Canonical Ltd. | ||
699 | 3 | * | ||
700 | 4 | * This library is free software; you can redistribute it and/or | ||
701 | 5 | * modify it under the terms of version 3 of the GNU Lesser General Public | ||
702 | 6 | * License as published by the Free Software Foundation. | ||
703 | 7 | * | ||
704 | 8 | * This program is distributed in the hope that it will be useful, | ||
705 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
706 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
707 | 11 | * General Public License for more details. | ||
708 | 12 | * | ||
709 | 13 | * You should have received a copy of the GNU Lesser General Public | ||
710 | 14 | * License along with this library; if not, write to the | ||
711 | 15 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
712 | 16 | * Boston, MA 02110-1301, USA. | ||
713 | 17 | */ | ||
714 | 18 | |||
715 | 19 | #include <QDBusArgument> | ||
716 | 20 | #include "download_state_struct.h" | ||
717 | 21 | |||
718 | 22 | namespace Ubuntu { | ||
719 | 23 | |||
720 | 24 | namespace DownloadManager { | ||
721 | 25 | |||
722 | 26 | DownloadStateStruct::DownloadStateStruct() | ||
723 | 27 | : _state(-1), | ||
724 | 28 | _url(QString::null), | ||
725 | 29 | _filePath(QString::null), | ||
726 | 30 | _hash(QString::null) { | ||
727 | 31 | |||
728 | 32 | } | ||
729 | 33 | |||
730 | 34 | DownloadStateStruct::DownloadStateStruct(int state, const QString& url, const QString& hash) | ||
731 | 35 | : _state(state), | ||
732 | 36 | _url(url), | ||
733 | 37 | _filePath(QString::null), | ||
734 | 38 | _hash(hash) { | ||
735 | 39 | |||
736 | 40 | } | ||
737 | 41 | |||
738 | 42 | DownloadStateStruct::DownloadStateStruct(int state, const QString& url, const QString& filePath, | ||
739 | 43 | const QString& hash) | ||
740 | 44 | : _state(state), | ||
741 | 45 | _url(url), | ||
742 | 46 | _filePath(filePath), | ||
743 | 47 | _hash(hash) { | ||
744 | 48 | |||
745 | 49 | } | ||
746 | 50 | |||
747 | 51 | DownloadStateStruct::DownloadStateStruct(const DownloadStateStruct& other) | ||
748 | 52 | : _state(other._state), | ||
749 | 53 | _url(other._url), | ||
750 | 54 | _filePath(other._filePath), | ||
751 | 55 | _hash(other._hash) { | ||
752 | 56 | } | ||
753 | 57 | |||
754 | 58 | DownloadStateStruct& DownloadStateStruct::operator=(const DownloadStateStruct& other) { | ||
755 | 59 | _state = other._state; | ||
756 | 60 | _url = other._url; | ||
757 | 61 | _filePath= other._filePath; | ||
758 | 62 | _hash = other._hash; | ||
759 | 63 | |||
760 | 64 | return *this; | ||
761 | 65 | } | ||
762 | 66 | |||
763 | 67 | QDBusArgument &operator<<(QDBusArgument &argument, | ||
764 | 68 | const DownloadStateStruct& download) { | ||
765 | 69 | argument.beginStructure(); | ||
766 | 70 | argument << download._state; | ||
767 | 71 | argument << download._url; | ||
768 | 72 | argument << download._filePath; | ||
769 | 73 | argument << download._hash; | ||
770 | 74 | argument.endStructure(); | ||
771 | 75 | |||
772 | 76 | return argument; | ||
773 | 77 | } | ||
774 | 78 | |||
775 | 79 | const QDBusArgument &operator>>(const QDBusArgument &argument, | ||
776 | 80 | DownloadStateStruct& download) { | ||
777 | 81 | argument.beginStructure(); | ||
778 | 82 | argument >> download._state; | ||
779 | 83 | argument >> download._url; | ||
780 | 84 | argument >> download._filePath; | ||
781 | 85 | argument >> download._hash; | ||
782 | 86 | argument.endStructure(); | ||
783 | 87 | |||
784 | 88 | return argument; | ||
785 | 89 | } | ||
786 | 90 | |||
787 | 91 | int | ||
788 | 92 | DownloadStateStruct::getState() const { | ||
789 | 93 | return _state; | ||
790 | 94 | } | ||
791 | 95 | |||
792 | 96 | QString | ||
793 | 97 | DownloadStateStruct::getUrl() const { | ||
794 | 98 | return _url; | ||
795 | 99 | } | ||
796 | 100 | |||
797 | 101 | QString | ||
798 | 102 | DownloadStateStruct::getFilePath() const { | ||
799 | 103 | return _filePath; | ||
800 | 104 | } | ||
801 | 105 | |||
802 | 106 | QString | ||
803 | 107 | DownloadStateStruct::getHash() const { | ||
804 | 108 | return _hash; | ||
805 | 109 | } | ||
806 | 110 | |||
807 | 111 | bool | ||
808 | 112 | DownloadStateStruct::isValid() { | ||
809 | 113 | return _url != QString::null; | ||
810 | 114 | } | ||
811 | 115 | |||
812 | 116 | } // DownloadManager | ||
813 | 117 | |||
814 | 118 | } // Ubuntu | ||
815 | 119 | |||
816 | 0 | 120 | ||
817 | === added file 'src/downloads/common/ubuntu/download_manager/download_state_struct.h' | |||
818 | --- src/downloads/common/ubuntu/download_manager/download_state_struct.h 1970-01-01 00:00:00 +0000 | |||
819 | +++ src/downloads/common/ubuntu/download_manager/download_state_struct.h 2015-11-26 12:58:55 +0000 | |||
820 | @@ -0,0 +1,149 @@ | |||
821 | 1 | /* | ||
822 | 2 | * Copyright 2015 Canonical Ltd. | ||
823 | 3 | * | ||
824 | 4 | * This library is free software; you can redistribute it and/or | ||
825 | 5 | * modify it under the terms of version 3 of the GNU Lesser General Public | ||
826 | 6 | * License as published by the Free Software Foundation. | ||
827 | 7 | * | ||
828 | 8 | * This program is distributed in the hope that it will be useful, | ||
829 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
830 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
831 | 11 | * General Public License for more details. | ||
832 | 12 | * | ||
833 | 13 | * You should have received a copy of the GNU Lesser General Public | ||
834 | 14 | * License along with this library; if not, write to the | ||
835 | 15 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
836 | 16 | * Boston, MA 02110-1301, USA. | ||
837 | 17 | */ | ||
838 | 18 | |||
839 | 19 | #pragma once | ||
840 | 20 | |||
841 | 21 | #include <QString> | ||
842 | 22 | |||
843 | 23 | class QDBusArgument; | ||
844 | 24 | namespace Ubuntu { | ||
845 | 25 | |||
846 | 26 | namespace DownloadManager { | ||
847 | 27 | |||
848 | 28 | namespace Daemon { | ||
849 | 29 | class DownloadsDb; | ||
850 | 30 | } | ||
851 | 31 | |||
852 | 32 | /*! | ||
853 | 33 | \class DownloadStateStruct | ||
854 | 34 | \brief The DownloadStateStruct represents the dbus structure that is used | ||
855 | 35 | to communicate the download manager the details of a past or | ||
856 | 36 | current download. | ||
857 | 37 | \since 1.1 | ||
858 | 38 | |||
859 | 39 | The DownloadStateStruct allows to get the basic information of a download that | ||
860 | 40 | was created by an application in the download manager. | ||
861 | 41 | */ | ||
862 | 42 | class DownloadStateStruct { | ||
863 | 43 | Q_PROPERTY(int state READ getState) | ||
864 | 44 | Q_PROPERTY(QString url READ getUrl) | ||
865 | 45 | Q_PROPERTY(QString filePath READ getFilePath) | ||
866 | 46 | Q_PROPERTY(QString hash READ getHash) | ||
867 | 47 | |||
868 | 48 | friend class Ubuntu::DownloadManager::Daemon::DownloadsDb; | ||
869 | 49 | |||
870 | 50 | public: | ||
871 | 51 | |||
872 | 52 | /* | ||
873 | 53 | Default constructor. | ||
874 | 54 | */ | ||
875 | 55 | DownloadStateStruct(); | ||
876 | 56 | |||
877 | 57 | /* | ||
878 | 58 | Copy constructor. | ||
879 | 59 | */ | ||
880 | 60 | DownloadStateStruct(const DownloadStateStruct& other); | ||
881 | 61 | |||
882 | 62 | /* | ||
883 | 63 | Assign operator. | ||
884 | 64 | */ | ||
885 | 65 | DownloadStateStruct& operator=(const DownloadStateStruct& other); | ||
886 | 66 | |||
887 | 67 | /* | ||
888 | 68 | \internal | ||
889 | 69 | */ | ||
890 | 70 | friend QDBusArgument &operator<<(QDBusArgument &argument, const DownloadStateStruct& download); | ||
891 | 71 | |||
892 | 72 | /* | ||
893 | 73 | \internal | ||
894 | 74 | */ | ||
895 | 75 | friend const QDBusArgument &operator>>(const QDBusArgument &argument, DownloadStateStruct& download); | ||
896 | 76 | |||
897 | 77 | /* | ||
898 | 78 | \fn QString getUrl() | ||
899 | 79 | |||
900 | 80 | Returns the url that points to the file that will be downloaded. | ||
901 | 81 | */ | ||
902 | 82 | int getState() const; | ||
903 | 83 | |||
904 | 84 | /* | ||
905 | 85 | \fn QString getUrl() | ||
906 | 86 | |||
907 | 87 | Returns the url that points to the file that will be downloaded. | ||
908 | 88 | */ | ||
909 | 89 | QString getUrl() const; | ||
910 | 90 | |||
911 | 91 | /* | ||
912 | 92 | \fn QString getUrl() | ||
913 | 93 | |||
914 | 94 | Returns the url that points to the file that will be downloaded. | ||
915 | 95 | */ | ||
916 | 96 | QString getFilePath() const; | ||
917 | 97 | |||
918 | 98 | /* | ||
919 | 99 | \fn QString getUrl() | ||
920 | 100 | |||
921 | 101 | Returns the url that points to the file that will be downloaded. | ||
922 | 102 | */ | ||
923 | 103 | QString getHash() const; | ||
924 | 104 | |||
925 | 105 | /* | ||
926 | 106 | \fn bool isValid(); | ||
927 | 107 | |||
928 | 108 | Returns if the download state if valid. | ||
929 | 109 | */ | ||
930 | 110 | bool isValid(); | ||
931 | 111 | |||
932 | 112 | protected: | ||
933 | 113 | |||
934 | 114 | /* | ||
935 | 115 | \internal | ||
936 | 116 | */ | ||
937 | 117 | DownloadStateStruct(int state, const QString& url, const QString& hash=QString::null); | ||
938 | 118 | |||
939 | 119 | /* | ||
940 | 120 | \internal | ||
941 | 121 | */ | ||
942 | 122 | DownloadStateStruct(int state, const QString& url, const QString& filePath, const QString& hash=QString::null); | ||
943 | 123 | |||
944 | 124 | private: | ||
945 | 125 | |||
946 | 126 | /* | ||
947 | 127 | \internal | ||
948 | 128 | */ | ||
949 | 129 | int _state = -1; | ||
950 | 130 | |||
951 | 131 | /* | ||
952 | 132 | \internal | ||
953 | 133 | */ | ||
954 | 134 | QString _url = QString::null; | ||
955 | 135 | |||
956 | 136 | /* | ||
957 | 137 | \internal | ||
958 | 138 | */ | ||
959 | 139 | QString _filePath = QString::null; | ||
960 | 140 | |||
961 | 141 | /* | ||
962 | 142 | \internal | ||
963 | 143 | */ | ||
964 | 144 | QString _hash = QString::null; | ||
965 | 145 | }; | ||
966 | 146 | |||
967 | 147 | } | ||
968 | 148 | |||
969 | 149 | } | ||
970 | 0 | \ No newline at end of file | 150 | \ No newline at end of file |
971 | 1 | 151 | ||
972 | === modified file 'src/downloads/common/ubuntu/download_manager/metatypes.h' | |||
973 | --- src/downloads/common/ubuntu/download_manager/metatypes.h 2015-02-25 16:24:24 +0000 | |||
974 | +++ src/downloads/common/ubuntu/download_manager/metatypes.h 2015-11-26 12:58:55 +0000 | |||
975 | @@ -25,6 +25,7 @@ | |||
976 | 25 | #include <ubuntu/transfers/errors/http_error_struct.h> | 25 | #include <ubuntu/transfers/errors/http_error_struct.h> |
977 | 26 | #include <ubuntu/transfers/errors/network_error_struct.h> | 26 | #include <ubuntu/transfers/errors/network_error_struct.h> |
978 | 27 | #include <ubuntu/transfers/errors/process_error_struct.h> | 27 | #include <ubuntu/transfers/errors/process_error_struct.h> |
979 | 28 | #include "download_state_struct.h" | ||
980 | 28 | #include "download_struct.h" | 29 | #include "download_struct.h" |
981 | 29 | #include "group_download_struct.h" | 30 | #include "group_download_struct.h" |
982 | 30 | 31 | ||
983 | @@ -40,6 +41,7 @@ | |||
984 | 40 | Q_DECLARE_METATYPE(NetworkErrorStruct) | 41 | Q_DECLARE_METATYPE(NetworkErrorStruct) |
985 | 41 | Q_DECLARE_METATYPE(ProcessErrorStruct) | 42 | Q_DECLARE_METATYPE(ProcessErrorStruct) |
986 | 42 | Q_DECLARE_METATYPE(DownloadStruct) | 43 | Q_DECLARE_METATYPE(DownloadStruct) |
987 | 44 | Q_DECLARE_METATYPE(DownloadStateStruct) | ||
988 | 43 | Q_DECLARE_METATYPE(StringMap) | 45 | Q_DECLARE_METATYPE(StringMap) |
989 | 44 | Q_DECLARE_METATYPE(StructList) | 46 | Q_DECLARE_METATYPE(StructList) |
990 | 45 | 47 | ||
991 | 46 | 48 | ||
992 | === modified file 'src/downloads/priv/CMakeLists.txt' | |||
993 | --- src/downloads/priv/CMakeLists.txt 2014-11-17 23:07:13 +0000 | |||
994 | +++ src/downloads/priv/CMakeLists.txt 2015-11-26 12:58:55 +0000 | |||
995 | @@ -12,7 +12,7 @@ | |||
996 | 12 | ubuntu/downloads/file_download.cpp | 12 | ubuntu/downloads/file_download.cpp |
997 | 13 | ubuntu/downloads/group_download.cpp | 13 | ubuntu/downloads/group_download.cpp |
998 | 14 | ubuntu/downloads/group_download_adaptor.cpp | 14 | ubuntu/downloads/group_download_adaptor.cpp |
1000 | 15 | ubuntu/downloads/header_parser.cpp | 15 | ubuntu/downloads/header_parser.cpp |
1001 | 16 | ubuntu/downloads/manager.cpp | 16 | ubuntu/downloads/manager.cpp |
1002 | 17 | ubuntu/downloads/mms_file_download.cpp | 17 | ubuntu/downloads/mms_file_download.cpp |
1003 | 18 | ubuntu/downloads/sm_file_download.cpp | 18 | ubuntu/downloads/sm_file_download.cpp |
1004 | @@ -33,7 +33,7 @@ | |||
1005 | 33 | ubuntu/downloads/file_download.h | 33 | ubuntu/downloads/file_download.h |
1006 | 34 | ubuntu/downloads/group_download.h | 34 | ubuntu/downloads/group_download.h |
1007 | 35 | ubuntu/downloads/group_download_adaptor.h | 35 | ubuntu/downloads/group_download_adaptor.h |
1009 | 36 | ubuntu/downloads/header_parser.h | 36 | ubuntu/downloads/header_parser.h |
1010 | 37 | ubuntu/downloads/manager.h | 37 | ubuntu/downloads/manager.h |
1011 | 38 | ubuntu/downloads/mms_file_download.h | 38 | ubuntu/downloads/mms_file_download.h |
1012 | 39 | ubuntu/downloads/sm_file_download.h | 39 | ubuntu/downloads/sm_file_download.h |
1013 | 40 | 40 | ||
1014 | === modified file 'src/downloads/priv/ubuntu/downloads/download.h' | |||
1015 | --- src/downloads/priv/ubuntu/downloads/download.h 2015-09-22 14:54:32 +0000 | |||
1016 | +++ src/downloads/priv/ubuntu/downloads/download.h 2015-11-26 12:58:55 +0000 | |||
1017 | @@ -105,6 +105,7 @@ | |||
1018 | 105 | // slots to be implemented by the children | 105 | // slots to be implemented by the children |
1019 | 106 | virtual qulonglong progress() = 0; | 106 | virtual qulonglong progress() = 0; |
1020 | 107 | virtual qulonglong totalSize() = 0; | 107 | virtual qulonglong totalSize() = 0; |
1021 | 108 | virtual QString filePath() = 0; | ||
1022 | 108 | 109 | ||
1023 | 109 | signals: | 110 | signals: |
1024 | 110 | // signals that are exposed via dbus | 111 | // signals that are exposed via dbus |
1025 | 111 | 112 | ||
1026 | === modified file 'src/downloads/priv/ubuntu/downloads/download_adaptor.cpp' | |||
1027 | --- src/downloads/priv/ubuntu/downloads/download_adaptor.cpp 2015-09-22 14:54:32 +0000 | |||
1028 | +++ src/downloads/priv/ubuntu/downloads/download_adaptor.cpp 2015-11-26 12:58:55 +0000 | |||
1029 | @@ -69,6 +69,20 @@ | |||
1030 | 69 | QMetaObject::invokeMethod(parent(), "cancel"); | 69 | QMetaObject::invokeMethod(parent(), "cancel"); |
1031 | 70 | } | 70 | } |
1032 | 71 | 71 | ||
1033 | 72 | void DownloadAdaptor::collected() | ||
1034 | 73 | { | ||
1035 | 74 | // handle method call com.canonical.applications.Download.collected | ||
1036 | 75 | QMetaObject::invokeMethod(parent(), "collected"); | ||
1037 | 76 | } | ||
1038 | 77 | |||
1039 | 78 | QString DownloadAdaptor::filePath() | ||
1040 | 79 | { | ||
1041 | 80 | // handle method call com.canonical.applications.Download.filePath | ||
1042 | 81 | QString filePath; | ||
1043 | 82 | QMetaObject::invokeMethod(parent(), "filePath", Q_RETURN_ARG(QString, filePath)); | ||
1044 | 83 | return filePath; | ||
1045 | 84 | } | ||
1046 | 85 | |||
1047 | 72 | StringMap DownloadAdaptor::headers() | 86 | StringMap DownloadAdaptor::headers() |
1048 | 73 | { | 87 | { |
1049 | 74 | // handle method call com.canonical.applications.Download.headers | 88 | // handle method call com.canonical.applications.Download.headers |
1050 | @@ -143,6 +157,14 @@ | |||
1051 | 143 | QMetaObject::invokeMethod(parent(), "start"); | 157 | QMetaObject::invokeMethod(parent(), "start"); |
1052 | 144 | } | 158 | } |
1053 | 145 | 159 | ||
1054 | 160 | int DownloadAdaptor::state() | ||
1055 | 161 | { | ||
1056 | 162 | // handle method call com.canonical.applications.Download.state | ||
1057 | 163 | int state; | ||
1058 | 164 | QMetaObject::invokeMethod(parent(), "state", Q_RETURN_ARG(int, state)); | ||
1059 | 165 | return state; | ||
1060 | 166 | } | ||
1061 | 167 | |||
1062 | 146 | qulonglong DownloadAdaptor::throttle() | 168 | qulonglong DownloadAdaptor::throttle() |
1063 | 147 | { | 169 | { |
1064 | 148 | // handle method call com.canonical.applications.Download.throttle | 170 | // handle method call com.canonical.applications.Download.throttle |
1065 | 149 | 171 | ||
1066 | === modified file 'src/downloads/priv/ubuntu/downloads/download_adaptor.h' | |||
1067 | --- src/downloads/priv/ubuntu/downloads/download_adaptor.h 2015-09-22 14:54:32 +0000 | |||
1068 | +++ src/downloads/priv/ubuntu/downloads/download_adaptor.h 2015-11-26 12:58:55 +0000 | |||
1069 | @@ -9,8 +9,8 @@ | |||
1070 | 9 | * before re-generating it. | 9 | * before re-generating it. |
1071 | 10 | */ | 10 | */ |
1072 | 11 | 11 | ||
1075 | 12 | #ifndef DOWNLOAD_ADAPTOR_H_1440513488 | 12 | #ifndef DOWNLOAD_ADAPTOR_H_1446124951 |
1076 | 13 | #define DOWNLOAD_ADAPTOR_H_1440513488 | 13 | #define DOWNLOAD_ADAPTOR_H_1446124951 |
1077 | 14 | 14 | ||
1078 | 15 | #include <QtCore/QObject> | 15 | #include <QtCore/QObject> |
1079 | 16 | #include <QtDBus/QtDBus> | 16 | #include <QtDBus/QtDBus> |
1080 | @@ -71,10 +71,17 @@ | |||
1081 | 71 | " <method name=\"isGSMDownloadAllowed\">\n" | 71 | " <method name=\"isGSMDownloadAllowed\">\n" |
1082 | 72 | " <arg direction=\"out\" type=\"b\" name=\"allowed\"/>\n" | 72 | " <arg direction=\"out\" type=\"b\" name=\"allowed\"/>\n" |
1083 | 73 | " </method>\n" | 73 | " </method>\n" |
1084 | 74 | " <method name=\"filePath\">\n" | ||
1085 | 75 | " <arg direction=\"out\" type=\"s\" name=\"filepath\"/>\n" | ||
1086 | 76 | " </method>\n" | ||
1087 | 77 | " <method name=\"state\">\n" | ||
1088 | 78 | " <arg direction=\"out\" type=\"i\" name=\"state\"/>\n" | ||
1089 | 79 | " </method\n" | ||
1090 | 74 | " <method name=\"start\"/>\n" | 80 | " <method name=\"start\"/>\n" |
1091 | 75 | " <method name=\"pause\"/>\n" | 81 | " <method name=\"pause\"/>\n" |
1092 | 76 | " <method name=\"resume\"/>\n" | 82 | " <method name=\"resume\"/>\n" |
1093 | 77 | " <method name=\"cancel\"/>\n" | 83 | " <method name=\"cancel\"/>\n" |
1094 | 84 | " <method name=\"collected\"/>\n" | ||
1095 | 78 | " <signal name=\"started\">\n" | 85 | " <signal name=\"started\">\n" |
1096 | 79 | " <arg direction=\"out\" type=\"b\" name=\"success\"/>\n" | 86 | " <arg direction=\"out\" type=\"b\" name=\"success\"/>\n" |
1097 | 80 | " </signal>\n" | 87 | " </signal>\n" |
1098 | @@ -146,6 +153,8 @@ | |||
1099 | 146 | public Q_SLOTS: // METHODS | 153 | public Q_SLOTS: // METHODS |
1100 | 147 | void allowGSMDownload(bool allowed); | 154 | void allowGSMDownload(bool allowed); |
1101 | 148 | void cancel(); | 155 | void cancel(); |
1102 | 156 | void collected(); | ||
1103 | 157 | QString filePath(); | ||
1104 | 149 | StringMap headers(); | 158 | StringMap headers(); |
1105 | 150 | bool isGSMDownloadAllowed(); | 159 | bool isGSMDownloadAllowed(); |
1106 | 151 | QVariantMap metadata(); | 160 | QVariantMap metadata(); |
1107 | @@ -157,6 +166,7 @@ | |||
1108 | 157 | void setMetadata(const QVariantMap &data); | 166 | void setMetadata(const QVariantMap &data); |
1109 | 158 | void setThrottle(qulonglong speed); | 167 | void setThrottle(qulonglong speed); |
1110 | 159 | void start(); | 168 | void start(); |
1111 | 169 | int state(); | ||
1112 | 160 | qulonglong throttle(); | 170 | qulonglong throttle(); |
1113 | 161 | qulonglong totalSize(); | 171 | qulonglong totalSize(); |
1114 | 162 | Q_SIGNALS: // SIGNALS | 172 | Q_SIGNALS: // SIGNALS |
1115 | 163 | 173 | ||
1116 | === modified file 'src/downloads/priv/ubuntu/downloads/download_manager_adaptor.cpp' | |||
1117 | --- src/downloads/priv/ubuntu/downloads/download_manager_adaptor.cpp 2014-03-18 12:07:06 +0000 | |||
1118 | +++ src/downloads/priv/ubuntu/downloads/download_manager_adaptor.cpp 2015-11-26 12:58:55 +0000 | |||
1119 | @@ -2,7 +2,7 @@ | |||
1120 | 2 | * This file was generated by qdbusxml2cpp version 0.8 | 2 | * This file was generated by qdbusxml2cpp version 0.8 |
1121 | 3 | * Command line was: qdbusxml2cpp -c DownloadManagerAdaptor -a download_manager_adaptor.h:download_manager_adaptor.cpp -i metatypes.h com.canonical.applications.download_manager.xml | 3 | * Command line was: qdbusxml2cpp -c DownloadManagerAdaptor -a download_manager_adaptor.h:download_manager_adaptor.cpp -i metatypes.h com.canonical.applications.download_manager.xml |
1122 | 4 | * | 4 | * |
1124 | 5 | * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | 5 | * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). |
1125 | 6 | * | 6 | * |
1126 | 7 | * This is an auto-generated file. | 7 | * This is an auto-generated file. |
1127 | 8 | * Do not edit! All changes made to it will be lost. | 8 | * Do not edit! All changes made to it will be lost. |
1128 | @@ -99,6 +99,22 @@ | |||
1129 | 99 | return downloads; | 99 | return downloads; |
1130 | 100 | } | 100 | } |
1131 | 101 | 101 | ||
1132 | 102 | QList<QDBusObjectPath> DownloadManagerAdaptor::getUncollectedDownloads(const QString &appId) | ||
1133 | 103 | { | ||
1134 | 104 | // handle method call com.canonical.applications.DownloadManager.getUncollectedDownloads | ||
1135 | 105 | QList<QDBusObjectPath> downloads; | ||
1136 | 106 | QMetaObject::invokeMethod(parent(), "getUncollectedDownloads", Q_RETURN_ARG(QList<QDBusObjectPath>, downloads), Q_ARG(QString, appId)); | ||
1137 | 107 | return downloads; | ||
1138 | 108 | } | ||
1139 | 109 | |||
1140 | 110 | DownloadStateStruct DownloadManagerAdaptor::getDownloadState(const QString &downloadId) | ||
1141 | 111 | { | ||
1142 | 112 | // handle method call com.canonical.applications.DownloadManager.getDownloadState | ||
1143 | 113 | DownloadStateStruct state; | ||
1144 | 114 | QMetaObject::invokeMethod(parent(), "getDownloadState", Q_RETURN_ARG(DownloadStateStruct, state), Q_ARG(QString, downloadId)); | ||
1145 | 115 | return state; | ||
1146 | 116 | } | ||
1147 | 117 | |||
1148 | 102 | bool DownloadManagerAdaptor::isGSMDownloadAllowed() | 118 | bool DownloadManagerAdaptor::isGSMDownloadAllowed() |
1149 | 103 | { | 119 | { |
1150 | 104 | // handle method call com.canonical.applications.DownloadManager.isGSMDownloadAllowed | 120 | // handle method call com.canonical.applications.DownloadManager.isGSMDownloadAllowed |
1151 | 105 | 121 | ||
1152 | === modified file 'src/downloads/priv/ubuntu/downloads/download_manager_adaptor.h' | |||
1153 | --- src/downloads/priv/ubuntu/downloads/download_manager_adaptor.h 2014-03-18 12:07:06 +0000 | |||
1154 | +++ src/downloads/priv/ubuntu/downloads/download_manager_adaptor.h 2015-11-26 12:58:55 +0000 | |||
1155 | @@ -2,7 +2,7 @@ | |||
1156 | 2 | * This file was generated by qdbusxml2cpp version 0.8 | 2 | * This file was generated by qdbusxml2cpp version 0.8 |
1157 | 3 | * Command line was: qdbusxml2cpp -c DownloadManagerAdaptor -a download_manager_adaptor.h:download_manager_adaptor.cpp -i metatypes.h com.canonical.applications.download_manager.xml | 3 | * Command line was: qdbusxml2cpp -c DownloadManagerAdaptor -a download_manager_adaptor.h:download_manager_adaptor.cpp -i metatypes.h com.canonical.applications.download_manager.xml |
1158 | 4 | * | 4 | * |
1160 | 5 | * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | 5 | * qdbusxml2cpp is Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies). |
1161 | 6 | * | 6 | * |
1162 | 7 | * This is an auto-generated file. | 7 | * This is an auto-generated file. |
1163 | 8 | * This file may have been hand-edited. Look for HAND-EDIT comments | 8 | * This file may have been hand-edited. Look for HAND-EDIT comments |
1164 | @@ -70,6 +70,15 @@ | |||
1165 | 70 | " <arg direction=\"in\" type=\"s\" name=\"value\"/>\n" | 70 | " <arg direction=\"in\" type=\"s\" name=\"value\"/>\n" |
1166 | 71 | " <arg direction=\"out\" type=\"ao\" name=\"downloads\"/>\n" | 71 | " <arg direction=\"out\" type=\"ao\" name=\"downloads\"/>\n" |
1167 | 72 | " </method>\n" | 72 | " </method>\n" |
1168 | 73 | " <method name=\"getUncollectedDownloads\">\n" | ||
1169 | 74 | " <arg direction=\"in\" type=\"s\" name=\"appId\"/>\n" | ||
1170 | 75 | " <arg direction=\"out\" type=\"ao\" name=\"downloads\"/>\n" | ||
1171 | 76 | " </method>\n" | ||
1172 | 77 | " <method name=\"getDownloadState\">\n" | ||
1173 | 78 | " <annotation value=\"DownloadStateStruct\" name=\"org.qtproject.QtDBus.QtTypeName.Out0\"/>\n" | ||
1174 | 79 | " <arg direction=\"in\" type=\"s\" name=\"downloadId\"/>\n" | ||
1175 | 80 | " <arg direction=\"out\" type=\"(issss)\" name=\"state\"/>\n" | ||
1176 | 81 | " </method>\n" | ||
1177 | 73 | " <method name=\"setDefaultThrottle\">\n" | 82 | " <method name=\"setDefaultThrottle\">\n" |
1178 | 74 | " <arg direction=\"in\" type=\"t\" name=\"speed\"/>\n" | 83 | " <arg direction=\"in\" type=\"t\" name=\"speed\"/>\n" |
1179 | 75 | " </method>\n" | 84 | " </method>\n" |
1180 | @@ -102,6 +111,8 @@ | |||
1181 | 102 | void exit(); | 111 | void exit(); |
1182 | 103 | QList<QDBusObjectPath> getAllDownloads(); | 112 | QList<QDBusObjectPath> getAllDownloads(); |
1183 | 104 | QList<QDBusObjectPath> getAllDownloadsWithMetadata(const QString &name, const QString &value); | 113 | QList<QDBusObjectPath> getAllDownloadsWithMetadata(const QString &name, const QString &value); |
1184 | 114 | DownloadStateStruct getDownloadState(const QString &downloadId); | ||
1185 | 115 | QList<QDBusObjectPath> getUncollectedDownloads(const QString &appId); | ||
1186 | 105 | bool isGSMDownloadAllowed(); | 116 | bool isGSMDownloadAllowed(); |
1187 | 106 | void setDefaultThrottle(qulonglong speed); | 117 | void setDefaultThrottle(qulonglong speed); |
1188 | 107 | Q_SIGNALS: // SIGNALS | 118 | Q_SIGNALS: // SIGNALS |
1189 | 108 | 119 | ||
1190 | === modified file 'src/downloads/priv/ubuntu/downloads/downloads_db.cpp' | |||
1191 | --- src/downloads/priv/ubuntu/downloads/downloads_db.cpp 2014-04-15 15:15:28 +0000 | |||
1192 | +++ src/downloads/priv/ubuntu/downloads/downloads_db.cpp 2015-11-26 12:58:55 +0000 | |||
1193 | @@ -29,6 +29,7 @@ | |||
1194 | 29 | #include <unistd.h> | 29 | #include <unistd.h> |
1195 | 30 | #include "ubuntu/transfers/system/logger.h" | 30 | #include "ubuntu/transfers/system/logger.h" |
1196 | 31 | #include "downloads_db.h" | 31 | #include "downloads_db.h" |
1197 | 32 | #include "download_adaptor.h" | ||
1198 | 32 | 33 | ||
1199 | 33 | namespace { | 34 | namespace { |
1200 | 34 | const QString SINGLE_DOWNLOAD_TABLE = "CREATE TABLE IF NOT EXISTS SingleDownload("\ | 35 | const QString SINGLE_DOWNLOAD_TABLE = "CREATE TABLE IF NOT EXISTS SingleDownload("\ |
1201 | @@ -75,14 +76,26 @@ | |||
1202 | 75 | "throttle=:throttle, metadata=:metadata, headers=:headers "\ | 76 | "throttle=:throttle, metadata=:metadata, headers=:headers "\ |
1203 | 76 | "WHERE uuid=:uuid"; | 77 | "WHERE uuid=:uuid"; |
1204 | 77 | 78 | ||
1205 | 79 | const QString GET_SINGLE_DOWNLOAD_STATE = "SELECT state, url, local_path, hash FROM SingleDownload "\ | ||
1206 | 80 | "WHERE uuid=:uuid"; | ||
1207 | 81 | |||
1208 | 82 | const QString GET_UNCOLLECTED_DOWNLOADS = "SELECT uuid, appId, url, dbus_path, "\ | ||
1209 | 83 | "local_path, hash, hash_algo, state FROM SingleDownload "\ | ||
1210 | 84 | "WHERE appId=:appId AND state='uncoll'"; | ||
1211 | 85 | |||
1212 | 86 | const QString UPDATE_UNCOLLECTED_DOWNLOADS = "UPDATE SingleDownload SET state='finish' "\ | ||
1213 | 87 | "WHERE state='uncoll' AND appId=:appId"; | ||
1214 | 88 | |||
1215 | 78 | const QString IDLE_STRING = "idle"; | 89 | const QString IDLE_STRING = "idle"; |
1216 | 79 | const QString START_STRING = "start"; | 90 | const QString START_STRING = "start"; |
1217 | 80 | const QString PAUSE_STRING = "pause"; | 91 | const QString PAUSE_STRING = "pause"; |
1218 | 81 | const QString RESUME_STRING = "resume"; | 92 | const QString RESUME_STRING = "resume"; |
1219 | 82 | const QString CANCEL_STRING = "cancel"; | 93 | const QString CANCEL_STRING = "cancel"; |
1220 | 94 | const QString UNCOLLECTED_STRING = "uncoll"; | ||
1221 | 83 | const QString FINISH_STRING = "finish"; | 95 | const QString FINISH_STRING = "finish"; |
1222 | 84 | const QString ERROR_STRING = "error"; | 96 | const QString ERROR_STRING = "error"; |
1223 | 85 | 97 | ||
1224 | 98 | const QString DOWNLOAD_INTERFACE = "com.canonical.applications.Download"; | ||
1225 | 86 | } | 99 | } |
1226 | 87 | 100 | ||
1227 | 88 | namespace Ubuntu { | 101 | namespace Ubuntu { |
1228 | @@ -178,6 +191,8 @@ | |||
1229 | 178 | return RESUME_STRING; | 191 | return RESUME_STRING; |
1230 | 179 | case Download::CANCEL: | 192 | case Download::CANCEL: |
1231 | 180 | return CANCEL_STRING; | 193 | return CANCEL_STRING; |
1232 | 194 | case Download::UNCOLLECTED: | ||
1233 | 195 | return UNCOLLECTED_STRING; | ||
1234 | 181 | case Download::FINISH: | 196 | case Download::FINISH: |
1235 | 182 | return FINISH_STRING; | 197 | return FINISH_STRING; |
1236 | 183 | case Download::ERROR: | 198 | case Download::ERROR: |
1237 | @@ -200,6 +215,8 @@ | |||
1238 | 200 | return Download::RESUME; | 215 | return Download::RESUME; |
1239 | 201 | if (lowerState == CANCEL_STRING) | 216 | if (lowerState == CANCEL_STRING) |
1240 | 202 | return Download::CANCEL; | 217 | return Download::CANCEL; |
1241 | 218 | if (lowerState == UNCOLLECTED_STRING) | ||
1242 | 219 | return Download::UNCOLLECTED; | ||
1243 | 203 | if (lowerState == FINISH_STRING) | 220 | if (lowerState == FINISH_STRING) |
1244 | 204 | return Download::FINISH; | 221 | return Download::FINISH; |
1245 | 205 | if (lowerState == ERROR_STRING) | 222 | if (lowerState == ERROR_STRING) |
1246 | @@ -235,6 +252,94 @@ | |||
1247 | 235 | return false; | 252 | return false; |
1248 | 236 | } | 253 | } |
1249 | 237 | 254 | ||
1250 | 255 | DownloadStateStruct | ||
1251 | 256 | DownloadsDb::getDownloadState(const QString &downloadId) { | ||
1252 | 257 | bool opened = _db.open(); | ||
1253 | 258 | |||
1254 | 259 | if (!opened) { | ||
1255 | 260 | LOG(ERROR) << _db.lastError().text(); | ||
1256 | 261 | return DownloadStateStruct(); | ||
1257 | 262 | } | ||
1258 | 263 | |||
1259 | 264 | QSqlQuery query; | ||
1260 | 265 | // QString GET_SINGLE_DOWNLOAD_STATE = "SELECT state, url, local_path, hash FROM SingleDownload " | ||
1261 | 266 | // "WHERE uuid=:uuid"; | ||
1262 | 267 | query.prepare(GET_SINGLE_DOWNLOAD_STATE); | ||
1263 | 268 | query.bindValue(":uuid", downloadId); | ||
1264 | 269 | |||
1265 | 270 | bool success = query.exec(); | ||
1266 | 271 | if (success && query.next()) { | ||
1267 | 272 | // grab the data and create the state structure | ||
1268 | 273 | auto state = stringToState(query.value(0).toString()); | ||
1269 | 274 | auto url = query.value(1).toString(); | ||
1270 | 275 | auto localPath = query.value(2).toString(); | ||
1271 | 276 | auto hash = query.value(3).isValid()?query.value(3).toString():""; | ||
1272 | 277 | |||
1273 | 278 | DownloadStateStruct result(state, url, localPath, hash); | ||
1274 | 279 | _db.close(); | ||
1275 | 280 | |||
1276 | 281 | return result; | ||
1277 | 282 | } | ||
1278 | 283 | if (!success) { | ||
1279 | 284 | LOG(ERROR) << query.lastError().text(); | ||
1280 | 285 | } | ||
1281 | 286 | return DownloadStateStruct(); | ||
1282 | 287 | } | ||
1283 | 288 | |||
1284 | 289 | QList<Download*> | ||
1285 | 290 | DownloadsDb::getUncollectedDownloads(const QString &appId) { | ||
1286 | 291 | bool opened = _db.open(); | ||
1287 | 292 | QList<Download*> downloadList; | ||
1288 | 293 | |||
1289 | 294 | if (!opened) { | ||
1290 | 295 | LOG(ERROR) << _db.lastError().text(); | ||
1291 | 296 | return downloadList; | ||
1292 | 297 | } | ||
1293 | 298 | |||
1294 | 299 | QSqlQuery query; | ||
1295 | 300 | query.prepare(GET_UNCOLLECTED_DOWNLOADS); | ||
1296 | 301 | query.bindValue(":appId", appId); | ||
1297 | 302 | |||
1298 | 303 | bool success = query.exec(); | ||
1299 | 304 | if (!success) { | ||
1300 | 305 | LOG(ERROR) << query.lastError().text(); | ||
1301 | 306 | _db.close(); | ||
1302 | 307 | return downloadList; | ||
1303 | 308 | } | ||
1304 | 309 | while (query.next()) { | ||
1305 | 310 | auto uuid = query.value(0).toString(); | ||
1306 | 311 | auto appId = query.value(1).toString(); | ||
1307 | 312 | auto url = query.value(2).toString(); | ||
1308 | 313 | auto dbusPath = query.value(3).toString(); | ||
1309 | 314 | auto filePath = query.value(4).toString(); | ||
1310 | 315 | auto basePath = QFileInfo(filePath).absolutePath(); | ||
1311 | 316 | auto hash = query.value(5).isValid() ? query.value(5).toString() : ""; | ||
1312 | 317 | auto algo = query.value(6).isValid() ? query.value(6).toString() : ""; | ||
1313 | 318 | auto state = stringToState(query.value(7).toString()); | ||
1314 | 319 | QVariantMap metadata; | ||
1315 | 320 | QMap<QString, QString> headers; | ||
1316 | 321 | FileDownload *download = new FileDownload(uuid, appId, dbusPath, 1, basePath, url, hash, algo, metadata, headers); | ||
1317 | 322 | download->setState(state); | ||
1318 | 323 | download->setFilePath(filePath); | ||
1319 | 324 | auto downAdaptor = new DownloadAdaptor(download); | ||
1320 | 325 | download->setAdaptor(DOWNLOAD_INTERFACE, downAdaptor); | ||
1321 | 326 | |||
1322 | 327 | downloadList << download; | ||
1323 | 328 | |||
1324 | 329 | } | ||
1325 | 330 | |||
1326 | 331 | QSqlQuery updateQuery; | ||
1327 | 332 | updateQuery.prepare(UPDATE_UNCOLLECTED_DOWNLOADS); | ||
1328 | 333 | updateQuery.bindValue(":appId", appId); | ||
1329 | 334 | success = updateQuery.exec(); | ||
1330 | 335 | if (!success) { | ||
1331 | 336 | LOG(ERROR) << updateQuery.lastError().text(); | ||
1332 | 337 | } | ||
1333 | 338 | |||
1334 | 339 | _db.close(); | ||
1335 | 340 | return downloadList; | ||
1336 | 341 | } | ||
1337 | 342 | |||
1338 | 238 | bool | 343 | bool |
1339 | 239 | DownloadsDb::storeSingleDownload(FileDownload* download) { | 344 | DownloadsDb::storeSingleDownload(FileDownload* download) { |
1340 | 240 | // decide if we store it as a new download or update an existing one | 345 | // decide if we store it as a new download or update an existing one |
1341 | 241 | 346 | ||
1342 | === modified file 'src/downloads/priv/ubuntu/downloads/downloads_db.h' | |||
1343 | --- src/downloads/priv/ubuntu/downloads/downloads_db.h 2014-02-26 16:23:46 +0000 | |||
1344 | +++ src/downloads/priv/ubuntu/downloads/downloads_db.h 2015-11-26 12:58:55 +0000 | |||
1345 | @@ -16,12 +16,14 @@ | |||
1346 | 16 | * Boston, MA 02110-1301, USA. | 16 | * Boston, MA 02110-1301, USA. |
1347 | 17 | */ | 17 | */ |
1348 | 18 | 18 | ||
1351 | 19 | #ifndef DOWNLOADER_LIB_DOWNLOADS_DATABASE_H | 19 | #pragma once |
1350 | 20 | #define DOWNLOADER_LIB_DOWNLOADS_DATABASE_H | ||
1352 | 21 | 20 | ||
1353 | 22 | #include <QSqlDatabase> | 21 | #include <QSqlDatabase> |
1354 | 23 | #include <QObject> | 22 | #include <QObject> |
1356 | 24 | #include "ubuntu/transfers/system/file_manager.h" | 23 | |
1357 | 24 | #include <ubuntu/transfers/system/file_manager.h> | ||
1358 | 25 | #include <ubuntu/download_manager/download_state_struct.h> | ||
1359 | 26 | |||
1360 | 25 | #include "file_download.h" | 27 | #include "file_download.h" |
1361 | 26 | 28 | ||
1362 | 27 | namespace Ubuntu { | 29 | namespace Ubuntu { |
1363 | @@ -45,7 +47,11 @@ | |||
1364 | 45 | QString filename(); | 47 | QString filename(); |
1365 | 46 | bool dbExists(); // return if the db is present and valid | 48 | bool dbExists(); // return if the db is present and valid |
1366 | 47 | bool init(); // init or update the db | 49 | bool init(); // init or update the db |
1367 | 50 | |||
1368 | 48 | virtual bool store(Download* down); | 51 | virtual bool store(Download* down); |
1369 | 52 | virtual DownloadStateStruct getDownloadState(const QString &downloadId); | ||
1370 | 53 | virtual QList<Download*> getUncollectedDownloads(const QString &appId); | ||
1371 | 54 | |||
1372 | 49 | bool storeSingleDownload(FileDownload* download); | 55 | bool storeSingleDownload(FileDownload* download); |
1373 | 50 | void connectToDownload(Download* download); | 56 | void connectToDownload(Download* download); |
1374 | 51 | void disconnectFromDownload(Download* download); | 57 | void disconnectFromDownload(Download* download); |
1375 | @@ -78,5 +84,3 @@ | |||
1376 | 78 | } // DownloadManager | 84 | } // DownloadManager |
1377 | 79 | 85 | ||
1378 | 80 | } // Ubuntu | 86 | } // Ubuntu |
1379 | 81 | |||
1380 | 82 | #endif // DOWNLOADER_LIB_DOWNLOADS_DATABASE_H | ||
1381 | 83 | 87 | ||
1382 | === modified file 'src/downloads/priv/ubuntu/downloads/factory.cpp' | |||
1383 | --- src/downloads/priv/ubuntu/downloads/factory.cpp 2014-10-22 23:32:28 +0000 | |||
1384 | +++ src/downloads/priv/ubuntu/downloads/factory.cpp 2015-11-26 12:58:55 +0000 | |||
1385 | @@ -80,7 +80,13 @@ | |||
1386 | 80 | QScopedPointer<SecurityDetails> details( | 80 | QScopedPointer<SecurityDetails> details( |
1387 | 81 | getSecurityDetails(dbusOwner, metadata)); | 81 | getSecurityDetails(dbusOwner, metadata)); |
1388 | 82 | auto dbusPath = details->dbusPath.arg("download"); | 82 | auto dbusPath = details->dbusPath.arg("download"); |
1390 | 83 | auto down = new FileDownload(details->id, details->appId, | 83 | QString appId = details->appId; |
1391 | 84 | if (!details->isConfined && metadata.contains(Metadata::APP_ID)) { | ||
1392 | 85 | // If we're unconfined use the metadata app id to | ||
1393 | 86 | // distinguish between different unconfined apps | ||
1394 | 87 | appId = metadata[Metadata::APP_ID].toString(); | ||
1395 | 88 | } | ||
1396 | 89 | auto down = new FileDownload(details->id, appId, | ||
1397 | 84 | dbusPath, details->isConfined, details->localPath, url, metadata, headers); | 90 | dbusPath, details->isConfined, details->localPath, url, metadata, headers); |
1398 | 85 | auto downAdaptor = new DownloadAdaptor(down); | 91 | auto downAdaptor = new DownloadAdaptor(down); |
1399 | 86 | down->setAdaptor(DOWNLOAD_INTERFACE, downAdaptor); | 92 | down->setAdaptor(DOWNLOAD_INTERFACE, downAdaptor); |
1400 | 87 | 93 | ||
1401 | === modified file 'src/downloads/priv/ubuntu/downloads/file_download.cpp' | |||
1402 | --- src/downloads/priv/ubuntu/downloads/file_download.cpp 2015-02-25 16:24:24 +0000 | |||
1403 | +++ src/downloads/priv/ubuntu/downloads/file_download.cpp 2015-11-26 12:58:55 +0000 | |||
1404 | @@ -1095,7 +1095,7 @@ | |||
1405 | 1095 | } | 1095 | } |
1406 | 1096 | } | 1096 | } |
1407 | 1097 | 1097 | ||
1409 | 1098 | setState(Download::FINISH); | 1098 | setState(Download::UNCOLLECTED); |
1410 | 1099 | unlockFilePath(); | 1099 | unlockFilePath(); |
1411 | 1100 | 1100 | ||
1412 | 1101 | DOWN_LOG(INFO) << "EMIT finished" << filePath(); | 1101 | DOWN_LOG(INFO) << "EMIT finished" << filePath(); |
1413 | @@ -1211,6 +1211,18 @@ | |||
1414 | 1211 | Download::emitError(error); | 1211 | Download::emitError(error); |
1415 | 1212 | } | 1212 | } |
1416 | 1213 | 1213 | ||
1417 | 1214 | void | ||
1418 | 1215 | FileDownload::setFilePath(const QString& filePath) { | ||
1419 | 1216 | // Used to recreate downloads from the database with the correct path | ||
1420 | 1217 | _fileNameMutex->unlockFileName(_filePath); | ||
1421 | 1218 | _filePath = filePath; | ||
1422 | 1219 | } | ||
1423 | 1220 | |||
1424 | 1221 | QString | ||
1425 | 1222 | FileDownload::filePath() { | ||
1426 | 1223 | return _filePath; | ||
1427 | 1224 | } | ||
1428 | 1225 | |||
1429 | 1214 | } // Daemon | 1226 | } // Daemon |
1430 | 1215 | 1227 | ||
1431 | 1216 | } // DownloadManager | 1228 | } // DownloadManager |
1432 | 1217 | 1229 | ||
1433 | === modified file 'src/downloads/priv/ubuntu/downloads/file_download.h' | |||
1434 | --- src/downloads/priv/ubuntu/downloads/file_download.h 2015-02-25 16:24:24 +0000 | |||
1435 | +++ src/downloads/priv/ubuntu/downloads/file_download.h 2015-11-26 12:58:55 +0000 | |||
1436 | @@ -71,10 +71,6 @@ | |||
1437 | 71 | return _url; | 71 | return _url; |
1438 | 72 | } | 72 | } |
1439 | 73 | 73 | ||
1440 | 74 | virtual QString filePath() const { | ||
1441 | 75 | return _filePath; | ||
1442 | 76 | } | ||
1443 | 77 | |||
1444 | 78 | virtual QString hash() const { | 74 | virtual QString hash() const { |
1445 | 79 | return _hash; | 75 | return _hash; |
1446 | 80 | } | 76 | } |
1447 | @@ -89,6 +85,8 @@ | |||
1448 | 89 | virtual void resumeTransfer() override; | 85 | virtual void resumeTransfer() override; |
1449 | 90 | virtual void startTransfer() override; | 86 | virtual void startTransfer() override; |
1450 | 91 | 87 | ||
1451 | 88 | void setFilePath(const QString& path); | ||
1452 | 89 | |||
1453 | 92 | public slots: // NOLINT(whitespace/indent) | 90 | public slots: // NOLINT(whitespace/indent) |
1454 | 93 | qulonglong progress() override; | 91 | qulonglong progress() override; |
1455 | 94 | qulonglong totalSize() override; | 92 | qulonglong totalSize() override; |
1456 | @@ -96,6 +94,7 @@ | |||
1457 | 96 | virtual void setDestinationDir(const QString& path); | 94 | virtual void setDestinationDir(const QString& path); |
1458 | 97 | virtual void setHeaders(StringMap headers) override; | 95 | virtual void setHeaders(StringMap headers) override; |
1459 | 98 | virtual void setMetadata(const QVariantMap& metadata) override; | 96 | virtual void setMetadata(const QVariantMap& metadata) override; |
1460 | 97 | virtual QString filePath() override; | ||
1461 | 99 | 98 | ||
1462 | 100 | signals: | 99 | signals: |
1463 | 101 | void finished(const QString& path); | 100 | void finished(const QString& path); |
1464 | 102 | 101 | ||
1465 | === modified file 'src/downloads/priv/ubuntu/downloads/group_download.cpp' | |||
1466 | --- src/downloads/priv/ubuntu/downloads/group_download.cpp 2014-05-21 15:17:52 +0000 | |||
1467 | +++ src/downloads/priv/ubuntu/downloads/group_download.cpp 2015-11-26 12:58:55 +0000 | |||
1468 | @@ -275,6 +275,13 @@ | |||
1469 | 275 | return total; | 275 | return total; |
1470 | 276 | } | 276 | } |
1471 | 277 | 277 | ||
1472 | 278 | QString | ||
1473 | 279 | GroupDownload::filePath() { | ||
1474 | 280 | // A group download never has a file path of its own, each individual | ||
1475 | 281 | // download within the group has its own path | ||
1476 | 282 | return ""; | ||
1477 | 283 | } | ||
1478 | 284 | |||
1479 | 278 | void | 285 | void |
1480 | 279 | GroupDownload::onError(const QString& error) { | 286 | GroupDownload::onError(const QString& error) { |
1481 | 280 | TRACE; | 287 | TRACE; |
1482 | 281 | 288 | ||
1483 | === modified file 'src/downloads/priv/ubuntu/downloads/group_download.h' | |||
1484 | --- src/downloads/priv/ubuntu/downloads/group_download.h 2014-10-22 23:40:53 +0000 | |||
1485 | +++ src/downloads/priv/ubuntu/downloads/group_download.h 2015-11-26 12:58:55 +0000 | |||
1486 | @@ -63,6 +63,7 @@ | |||
1487 | 63 | virtual qulonglong progress(qulonglong &started, qulonglong &paused, | 63 | virtual qulonglong progress(qulonglong &started, qulonglong &paused, |
1488 | 64 | qulonglong &finished); | 64 | qulonglong &finished); |
1489 | 65 | virtual qulonglong totalSize() override; | 65 | virtual qulonglong totalSize() override; |
1490 | 66 | virtual QString filePath() override; | ||
1491 | 66 | 67 | ||
1492 | 67 | signals: | 68 | signals: |
1493 | 68 | void finished(const QStringList &path); | 69 | void finished(const QStringList &path); |
1494 | 69 | 70 | ||
1495 | === modified file 'src/downloads/priv/ubuntu/downloads/manager.cpp' | |||
1496 | --- src/downloads/priv/ubuntu/downloads/manager.cpp 2015-09-22 14:14:06 +0000 | |||
1497 | +++ src/downloads/priv/ubuntu/downloads/manager.cpp 2015-11-26 12:58:55 +0000 | |||
1498 | @@ -334,6 +334,45 @@ | |||
1499 | 334 | return paths; | 334 | return paths; |
1500 | 335 | } | 335 | } |
1501 | 336 | 336 | ||
1502 | 337 | QList<QDBusObjectPath> | ||
1503 | 338 | DownloadManager::getUncollectedDownloads(const QString &appId) { | ||
1504 | 339 | QScopedPointer<System::AppArmor> appArmor(new System::AppArmor(_conn)); | ||
1505 | 340 | auto owner = getCaller(); | ||
1506 | 341 | auto callerAppId = appArmor->appId(owner); | ||
1507 | 342 | QList<QDBusObjectPath> paths; | ||
1508 | 343 | QString testAppId = appId; | ||
1509 | 344 | if (appArmor->isConfined(callerAppId)) { | ||
1510 | 345 | // Confined apps always get their own downloads returned | ||
1511 | 346 | testAppId = callerAppId; | ||
1512 | 347 | } | ||
1513 | 348 | |||
1514 | 349 | LOG(INFO) << "Returning uncollected downloads for app with id" << testAppId; | ||
1515 | 350 | |||
1516 | 351 | // Fetch uncollected downloads that are still in memory | ||
1517 | 352 | auto transfers = _queue->transfers(); | ||
1518 | 353 | foreach(const QString& path, transfers.keys()) { | ||
1519 | 354 | auto t = transfers[path]; | ||
1520 | 355 | if (t->transferAppId() == testAppId && t->state() != Transfer::FINISH | ||
1521 | 356 | && t->state() != Transfer::CANCEL | ||
1522 | 357 | && t->state() != Transfer::ERROR) | ||
1523 | 358 | paths << QDBusObjectPath(path); | ||
1524 | 359 | } | ||
1525 | 360 | |||
1526 | 361 | // Fetch uncollected downloads from previous UDM sessions that are | ||
1527 | 362 | // in the database | ||
1528 | 363 | foreach(Download *download, _db->getUncollectedDownloads(testAppId)) { | ||
1529 | 364 | _conn->registerObject(download->path(), download); | ||
1530 | 365 | paths << QDBusObjectPath(download->path()); | ||
1531 | 366 | } | ||
1532 | 367 | |||
1533 | 368 | return paths; | ||
1534 | 369 | } | ||
1535 | 370 | |||
1536 | 371 | DownloadStateStruct | ||
1537 | 372 | DownloadManager::getDownloadState(const QString &downloadId) { | ||
1538 | 373 | return _db->getDownloadState(downloadId); | ||
1539 | 374 | } | ||
1540 | 375 | |||
1541 | 337 | } // Daemon | 376 | } // Daemon |
1542 | 338 | 377 | ||
1543 | 339 | } // DownloadManager | 378 | } // DownloadManager |
1544 | 340 | 379 | ||
1545 | === modified file 'src/downloads/priv/ubuntu/downloads/manager.h' | |||
1546 | --- src/downloads/priv/ubuntu/downloads/manager.h 2015-08-27 09:02:19 +0000 | |||
1547 | +++ src/downloads/priv/ubuntu/downloads/manager.h 2015-11-26 12:58:55 +0000 | |||
1548 | @@ -18,14 +18,17 @@ | |||
1549 | 18 | 18 | ||
1550 | 19 | #pragma once | 19 | #pragma once |
1551 | 20 | 20 | ||
1552 | 21 | #include <functional> | ||
1553 | 22 | |||
1554 | 23 | #include <QByteArray> | ||
1555 | 24 | #include <QDBusObjectPath> | ||
1556 | 21 | #include <QObject> | 25 | #include <QObject> |
1557 | 22 | #include <QByteArray> | ||
1558 | 23 | #include <QtDBus/QDBusObjectPath> | ||
1559 | 24 | #include <QSslCertificate> | 26 | #include <QSslCertificate> |
1560 | 27 | |||
1561 | 25 | #include <ubuntu/transfers/queue.h> | 28 | #include <ubuntu/transfers/queue.h> |
1562 | 26 | #include <ubuntu/transfers/system/dbus_connection.h> | 29 | #include <ubuntu/transfers/system/dbus_connection.h> |
1563 | 27 | #include <ubuntu/download_manager/metatypes.h> | 30 | #include <ubuntu/download_manager/metatypes.h> |
1565 | 28 | #include <functional> | 31 | |
1566 | 29 | #include "ubuntu/transfers/base_manager.h" | 32 | #include "ubuntu/transfers/base_manager.h" |
1567 | 30 | #include "ubuntu/transfers/system/application.h" | 33 | #include "ubuntu/transfers/system/application.h" |
1568 | 31 | #include "download.h" | 34 | #include "download.h" |
1569 | @@ -83,6 +86,9 @@ | |||
1570 | 83 | virtual QList<QDBusObjectPath> getAllDownloadsWithMetadata( | 86 | virtual QList<QDBusObjectPath> getAllDownloadsWithMetadata( |
1571 | 84 | const QString& name, | 87 | const QString& name, |
1572 | 85 | const QString& value); | 88 | const QString& value); |
1573 | 89 | virtual QList<QDBusObjectPath> getUncollectedDownloads( | ||
1574 | 90 | const QString& appId); | ||
1575 | 91 | virtual DownloadStateStruct getDownloadState(const QString &downloadId); | ||
1576 | 86 | signals: | 92 | signals: |
1577 | 87 | void downloadCreated(const QDBusObjectPath& path); | 93 | void downloadCreated(const QDBusObjectPath& path); |
1578 | 88 | 94 | ||
1579 | 89 | 95 | ||
1580 | === modified file 'src/downloads/priv/ubuntu/downloads/state_machines/download_sm.h' | |||
1581 | --- src/downloads/priv/ubuntu/downloads/state_machines/download_sm.h 2014-02-21 12:46:26 +0000 | |||
1582 | +++ src/downloads/priv/ubuntu/downloads/state_machines/download_sm.h 2015-11-26 12:58:55 +0000 | |||
1583 | @@ -157,6 +157,7 @@ | |||
1584 | 157 | static QString POST_PROCESSING; | 157 | static QString POST_PROCESSING; |
1585 | 158 | static QString ERROR; | 158 | static QString ERROR; |
1586 | 159 | static QString CANCELED; | 159 | static QString CANCELED; |
1587 | 160 | static QString UNCOLLECTED; | ||
1588 | 160 | static QString FINISHED; | 161 | static QString FINISHED; |
1589 | 161 | 162 | ||
1590 | 162 | signals: | 163 | signals: |
1591 | 163 | 164 | ||
1592 | === modified file 'src/downloads/qml/CMakeLists.txt' | |||
1593 | --- src/downloads/qml/CMakeLists.txt 2014-09-05 14:40:54 +0000 | |||
1594 | +++ src/downloads/qml/CMakeLists.txt 2015-11-26 12:58:55 +0000 | |||
1595 | @@ -5,6 +5,7 @@ | |||
1596 | 5 | backend.cpp | 5 | backend.cpp |
1597 | 6 | metadata.cpp | 6 | metadata.cpp |
1598 | 7 | download_error.cpp | 7 | download_error.cpp |
1599 | 8 | download_history.cpp | ||
1600 | 8 | single_download.cpp | 9 | single_download.cpp |
1601 | 9 | ubuntu_download_manager.cpp | 10 | ubuntu_download_manager.cpp |
1602 | 10 | ) | 11 | ) |
1603 | @@ -13,6 +14,7 @@ | |||
1604 | 13 | backend.h | 14 | backend.h |
1605 | 14 | metadata.h | 15 | metadata.h |
1606 | 15 | download_error.h | 16 | download_error.h |
1607 | 17 | download_history.h | ||
1608 | 16 | single_download.h | 18 | single_download.h |
1609 | 17 | ubuntu_download_manager.h | 19 | ubuntu_download_manager.h |
1610 | 18 | ) | 20 | ) |
1611 | 19 | 21 | ||
1612 | === modified file 'src/downloads/qml/backend.cpp' | |||
1613 | --- src/downloads/qml/backend.cpp 2014-09-23 10:38:11 +0000 | |||
1614 | +++ src/downloads/qml/backend.cpp 2015-11-26 12:58:55 +0000 | |||
1615 | @@ -15,6 +15,10 @@ | |||
1616 | 15 | qmlRegisterType<Ubuntu::DownloadManager::Metadata>(uri, 0, 1, "Metadata"); | 15 | qmlRegisterType<Ubuntu::DownloadManager::Metadata>(uri, 0, 1, "Metadata"); |
1617 | 16 | qmlRegisterType<Ubuntu::DownloadManager::SingleDownload>(uri, 0, 1, "SingleDownload"); | 16 | qmlRegisterType<Ubuntu::DownloadManager::SingleDownload>(uri, 0, 1, "SingleDownload"); |
1618 | 17 | qmlRegisterType<Ubuntu::DownloadManager::UbuntuDownloadManager>(uri, 0, 1, "DownloadManager"); | 17 | qmlRegisterType<Ubuntu::DownloadManager::UbuntuDownloadManager>(uri, 0, 1, "DownloadManager"); |
1619 | 18 | qmlRegisterType<Ubuntu::DownloadManager::DownloadError>(uri, 1, 2, "Error"); | ||
1620 | 19 | qmlRegisterType<Ubuntu::DownloadManager::Metadata>(uri, 1, 2, "Metadata"); | ||
1621 | 20 | qmlRegisterType<Ubuntu::DownloadManager::SingleDownload>(uri, 1, 2, "SingleDownload"); | ||
1622 | 21 | qmlRegisterType<Ubuntu::DownloadManager::UbuntuDownloadManager>(uri, 1, 2, "DownloadManager"); | ||
1623 | 18 | } | 22 | } |
1624 | 19 | 23 | ||
1625 | 20 | void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri) | 24 | void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri) |
1626 | 21 | 25 | ||
1627 | === added file 'src/downloads/qml/download_history.cpp' | |||
1628 | --- src/downloads/qml/download_history.cpp 1970-01-01 00:00:00 +0000 | |||
1629 | +++ src/downloads/qml/download_history.cpp 2015-11-26 12:58:55 +0000 | |||
1630 | @@ -0,0 +1,143 @@ | |||
1631 | 1 | #include "download_history.h" | ||
1632 | 2 | #include <glog/logging.h> | ||
1633 | 3 | #include <ubuntu/download_manager/download_struct.h> | ||
1634 | 4 | #include <QCoreApplication> | ||
1635 | 5 | |||
1636 | 6 | namespace Ubuntu { | ||
1637 | 7 | |||
1638 | 8 | namespace DownloadManager { | ||
1639 | 9 | |||
1640 | 10 | DownloadHistory::DownloadHistory(QObject *parent) : | ||
1641 | 11 | QObject(parent), | ||
1642 | 12 | m_manager(nullptr) | ||
1643 | 13 | { | ||
1644 | 14 | m_manager = Manager::createSessionManager("", this); | ||
1645 | 15 | |||
1646 | 16 | CHECK(connect(m_manager, &Manager::downloadsFound, | ||
1647 | 17 | this, &DownloadHistory::downloadsFound)) | ||
1648 | 18 | << "Could not connect to signal"; | ||
1649 | 19 | |||
1650 | 20 | // Get previous downloads for this app | ||
1651 | 21 | auto environment = QProcessEnvironment::systemEnvironment(); | ||
1652 | 22 | if (environment.contains("APP_ID")) { | ||
1653 | 23 | m_manager->getUncollectedDownloads(environment.value("APP_ID")); | ||
1654 | 24 | } else { | ||
1655 | 25 | m_manager->getUncollectedDownloads(QCoreApplication::applicationFilePath()); | ||
1656 | 26 | } | ||
1657 | 27 | } | ||
1658 | 28 | |||
1659 | 29 | DownloadHistory *DownloadHistory::instance() | ||
1660 | 30 | { | ||
1661 | 31 | static DownloadHistory *downloadHistory = new DownloadHistory(); | ||
1662 | 32 | return downloadHistory; | ||
1663 | 33 | } | ||
1664 | 34 | |||
1665 | 35 | QVariantList DownloadHistory::downloads() const | ||
1666 | 36 | { | ||
1667 | 37 | return m_downloads; | ||
1668 | 38 | } | ||
1669 | 39 | |||
1670 | 40 | void DownloadHistory::addDownload(SingleDownload *singleDownload) | ||
1671 | 41 | { | ||
1672 | 42 | m_downloads.append(QVariant::fromValue(singleDownload)); | ||
1673 | 43 | CHECK(connect(singleDownload, &SingleDownload::finished, | ||
1674 | 44 | this, &DownloadHistory::downloadCompleted)) | ||
1675 | 45 | << "Could not connect to signal"; | ||
1676 | 46 | CHECK(connect(singleDownload, &SingleDownload::errorFound, | ||
1677 | 47 | this, &DownloadHistory::onError)) | ||
1678 | 48 | << "Could not connect to signal"; | ||
1679 | 49 | CHECK(connect(singleDownload, &SingleDownload::paused, | ||
1680 | 50 | this, &DownloadHistory::onPaused)) | ||
1681 | 51 | << "Could not connect to signal"; | ||
1682 | 52 | CHECK(connect(singleDownload, &SingleDownload::resumed, | ||
1683 | 53 | this, &DownloadHistory::onResumed)) | ||
1684 | 54 | << "Could not connect to signal"; | ||
1685 | 55 | CHECK(connect(singleDownload, &SingleDownload::canceled, | ||
1686 | 56 | this, &DownloadHistory::onCanceled)) | ||
1687 | 57 | << "Could not connect to signal"; | ||
1688 | 58 | emit downloadsChanged(); | ||
1689 | 59 | } | ||
1690 | 60 | |||
1691 | 61 | void DownloadHistory::downloadsFound(DownloadsList* downloadsList) | ||
1692 | 62 | { | ||
1693 | 63 | foreach(QSharedPointer<Download> download, downloadsList->downloads()) { | ||
1694 | 64 | SingleDownload* singleDownload = new SingleDownload(this); | ||
1695 | 65 | singleDownload->bindDownload(download.data()); | ||
1696 | 66 | if (download->state() == Download::UNCOLLECTED && !download->filePath().isEmpty()) { | ||
1697 | 67 | emit singleDownload->finished(download.data()->filePath()); | ||
1698 | 68 | } | ||
1699 | 69 | } | ||
1700 | 70 | emit downloadsChanged(); | ||
1701 | 71 | } | ||
1702 | 72 | |||
1703 | 73 | bool DownloadHistory::cleanDownloads() const | ||
1704 | 74 | { | ||
1705 | 75 | return m_cleanDownloads; | ||
1706 | 76 | } | ||
1707 | 77 | |||
1708 | 78 | void DownloadHistory::setCleanDownloads(bool value) | ||
1709 | 79 | { | ||
1710 | 80 | m_cleanDownloads = value; | ||
1711 | 81 | if (m_cleanDownloads) { | ||
1712 | 82 | QVariantList newList; | ||
1713 | 83 | foreach(QVariant var, m_downloads) { | ||
1714 | 84 | SingleDownload *download = qobject_cast<SingleDownload*>(var.value<SingleDownload*>()); | ||
1715 | 85 | if (download != nullptr && !download->isCompleted()) { | ||
1716 | 86 | newList.append(QVariant::fromValue(download)); | ||
1717 | 87 | } else { | ||
1718 | 88 | download->deleteLater(); | ||
1719 | 89 | } | ||
1720 | 90 | } | ||
1721 | 91 | m_downloads = newList; | ||
1722 | 92 | emit downloadsChanged(); | ||
1723 | 93 | } | ||
1724 | 94 | } | ||
1725 | 95 | |||
1726 | 96 | void DownloadHistory::downloadCompleted(const QString& path) | ||
1727 | 97 | { | ||
1728 | 98 | SingleDownload* download = qobject_cast<SingleDownload*>(sender()); | ||
1729 | 99 | if (download != nullptr) { | ||
1730 | 100 | emit downloadFinished(download, path); | ||
1731 | 101 | if (m_cleanDownloads) { | ||
1732 | 102 | int index = m_downloads.indexOf(QVariant::fromValue(download)); | ||
1733 | 103 | m_downloads.removeAt(index); | ||
1734 | 104 | emit downloadsChanged(); | ||
1735 | 105 | } | ||
1736 | 106 | } | ||
1737 | 107 | } | ||
1738 | 108 | |||
1739 | 109 | void DownloadHistory::onError(DownloadError& downloadError) | ||
1740 | 110 | { | ||
1741 | 111 | Q_UNUSED(downloadError); | ||
1742 | 112 | SingleDownload* download = qobject_cast<SingleDownload*>(sender()); | ||
1743 | 113 | if (download != nullptr) { | ||
1744 | 114 | emit errorFound(download); | ||
1745 | 115 | } | ||
1746 | 116 | } | ||
1747 | 117 | |||
1748 | 118 | void DownloadHistory::onPaused() | ||
1749 | 119 | { | ||
1750 | 120 | SingleDownload* download = qobject_cast<SingleDownload*>(sender()); | ||
1751 | 121 | if (download != nullptr) { | ||
1752 | 122 | emit downloadPaused(download); | ||
1753 | 123 | } | ||
1754 | 124 | } | ||
1755 | 125 | |||
1756 | 126 | void DownloadHistory::onResumed() | ||
1757 | 127 | { | ||
1758 | 128 | SingleDownload* download = qobject_cast<SingleDownload*>(sender()); | ||
1759 | 129 | if (download != nullptr) { | ||
1760 | 130 | emit downloadResumed(download); | ||
1761 | 131 | } | ||
1762 | 132 | } | ||
1763 | 133 | |||
1764 | 134 | void DownloadHistory::onCanceled() | ||
1765 | 135 | { | ||
1766 | 136 | SingleDownload* download = qobject_cast<SingleDownload*>(sender()); | ||
1767 | 137 | if (download != nullptr) { | ||
1768 | 138 | emit downloadCanceled(download); | ||
1769 | 139 | } | ||
1770 | 140 | } | ||
1771 | 141 | |||
1772 | 142 | } | ||
1773 | 143 | } | ||
1774 | 0 | 144 | ||
1775 | === added file 'src/downloads/qml/download_history.h' | |||
1776 | --- src/downloads/qml/download_history.h 1970-01-01 00:00:00 +0000 | |||
1777 | +++ src/downloads/qml/download_history.h 2015-11-26 12:58:55 +0000 | |||
1778 | @@ -0,0 +1,69 @@ | |||
1779 | 1 | /* | ||
1780 | 2 | * Copyright 2015 Canonical Ltd. | ||
1781 | 3 | * | ||
1782 | 4 | * This library is free software; you can redistribute it and/or | ||
1783 | 5 | * modify it under the terms of version 3 of the GNU Lesser General Public | ||
1784 | 6 | * License as published by the Free Software Foundation. | ||
1785 | 7 | * | ||
1786 | 8 | * This program is distributed in the hope that it will be useful, | ||
1787 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1788 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1789 | 11 | * General Public License for more details. | ||
1790 | 12 | * | ||
1791 | 13 | * You should have received a copy of the GNU Lesser General Public | ||
1792 | 14 | * License along with this library; if not, write to the | ||
1793 | 15 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
1794 | 16 | * Boston, MA 02110-1301, USA. | ||
1795 | 17 | */ | ||
1796 | 18 | |||
1797 | 19 | #ifndef DOWNLOAD_HISTORY_H | ||
1798 | 20 | #define DOWNLOAD_HISTORY_H | ||
1799 | 21 | |||
1800 | 22 | #include <ubuntu/download_manager/manager.h> | ||
1801 | 23 | #include <ubuntu/download_manager/downloads_list.h> | ||
1802 | 24 | |||
1803 | 25 | #include "single_download.h" | ||
1804 | 26 | |||
1805 | 27 | namespace Ubuntu { | ||
1806 | 28 | |||
1807 | 29 | namespace DownloadManager { | ||
1808 | 30 | |||
1809 | 31 | class DownloadHistory : public QObject { | ||
1810 | 32 | Q_OBJECT | ||
1811 | 33 | |||
1812 | 34 | public: | ||
1813 | 35 | explicit DownloadHistory(QObject* parent=0); | ||
1814 | 36 | static DownloadHistory *instance(); | ||
1815 | 37 | |||
1816 | 38 | QVariantList downloads() const; | ||
1817 | 39 | void downloadsFound(DownloadsList* downloadsList); | ||
1818 | 40 | void addDownload(SingleDownload *singleDownload); | ||
1819 | 41 | bool cleanDownloads() const; | ||
1820 | 42 | void setCleanDownloads(bool value); | ||
1821 | 43 | |||
1822 | 44 | signals: | ||
1823 | 45 | void downloadsChanged(); | ||
1824 | 46 | void downloadFinished(SingleDownload *singleDownload, const QString& path); | ||
1825 | 47 | void errorFound(SingleDownload *download); | ||
1826 | 48 | void downloadPaused(SingleDownload *singleDownload); | ||
1827 | 49 | void downloadResumed(SingleDownload *singleDownload); | ||
1828 | 50 | void downloadCanceled(SingleDownload *singleDownload); | ||
1829 | 51 | |||
1830 | 52 | private slots: | ||
1831 | 53 | void downloadCompleted(const QString& path); | ||
1832 | 54 | void onError(DownloadError& error); | ||
1833 | 55 | void onPaused(); | ||
1834 | 56 | void onResumed(); | ||
1835 | 57 | void onCanceled(); | ||
1836 | 58 | |||
1837 | 59 | private: | ||
1838 | 60 | Manager* m_manager; | ||
1839 | 61 | QVariantList m_downloads; | ||
1840 | 62 | bool m_cleanDownloads; | ||
1841 | 63 | }; | ||
1842 | 64 | |||
1843 | 65 | } // Ubuntu | ||
1844 | 66 | |||
1845 | 67 | } // DownloadManager | ||
1846 | 68 | |||
1847 | 69 | #endif | ||
1848 | 0 | 70 | ||
1849 | === modified file 'src/downloads/qml/single_download.cpp' | |||
1850 | --- src/downloads/qml/single_download.cpp 2014-10-07 14:44:11 +0000 | |||
1851 | +++ src/downloads/qml/single_download.cpp 2015-11-26 12:58:55 +0000 | |||
1852 | @@ -20,6 +20,7 @@ | |||
1853 | 20 | #include <ubuntu/download_manager/download_struct.h> | 20 | #include <ubuntu/download_manager/download_struct.h> |
1854 | 21 | 21 | ||
1855 | 22 | #include "single_download.h" | 22 | #include "single_download.h" |
1856 | 23 | #include "download_history.h" | ||
1857 | 23 | 24 | ||
1858 | 24 | namespace Ubuntu { | 25 | namespace Ubuntu { |
1859 | 25 | 26 | ||
1860 | @@ -28,7 +29,7 @@ | |||
1861 | 28 | /*! | 29 | /*! |
1862 | 29 | \qmltype SingleDownload | 30 | \qmltype SingleDownload |
1863 | 30 | \instantiates SingleDownload | 31 | \instantiates SingleDownload |
1865 | 31 | \inqmlmodule Ubuntu.DownloadManager 0.1 | 32 | \inqmlmodule Ubuntu.DownloadManager 1.2 |
1866 | 32 | \ingroup download | 33 | \ingroup download |
1867 | 33 | \brief Manage file downloads and tracking the progress. | 34 | \brief Manage file downloads and tracking the progress. |
1868 | 34 | 35 | ||
1869 | @@ -39,8 +40,8 @@ | |||
1870 | 39 | 40 | ||
1871 | 40 | \qml | 41 | \qml |
1872 | 41 | import QtQuick 2.0 | 42 | import QtQuick 2.0 |
1875 | 42 | import Ubuntu.Components 0.1 | 43 | import Ubuntu.Components 1.2 |
1876 | 43 | import Ubuntu.DownloadManager 0.1 | 44 | import Ubuntu.DownloadManager 1.2 |
1877 | 44 | 45 | ||
1878 | 45 | Rectangle { | 46 | Rectangle { |
1879 | 46 | width: units.gu(100) | 47 | width: units.gu(100) |
1880 | @@ -152,8 +153,6 @@ | |||
1881 | 152 | &SingleDownload::onStarted)) | 153 | &SingleDownload::onStarted)) |
1882 | 153 | << "Could not connect to signal"; | 154 | << "Could not connect to signal"; |
1883 | 154 | 155 | ||
1884 | 155 | emit downloadIdChanged(); | ||
1885 | 156 | |||
1886 | 157 | // is the current in memory setting dirty, if they are, we do set the before we | 156 | // is the current in memory setting dirty, if they are, we do set the before we |
1887 | 158 | // start | 157 | // start |
1888 | 159 | if (m_dirty) { | 158 | if (m_dirty) { |
1889 | @@ -169,6 +168,14 @@ | |||
1890 | 169 | if (m_manager != nullptr && m_autoStart) { | 168 | if (m_manager != nullptr && m_autoStart) { |
1891 | 170 | startDownload(); | 169 | startDownload(); |
1892 | 171 | } | 170 | } |
1893 | 171 | |||
1894 | 172 | DownloadHistory::instance()->addDownload(this); | ||
1895 | 173 | |||
1896 | 174 | // Keep a record of the downloadId so clients can still access the property | ||
1897 | 175 | // after a download has finished | ||
1898 | 176 | m_downloadId = m_download->id(); | ||
1899 | 177 | |||
1900 | 178 | emit downloadIdChanged(); | ||
1901 | 172 | } | 179 | } |
1902 | 173 | 180 | ||
1903 | 174 | void | 181 | void |
1904 | @@ -222,7 +229,9 @@ | |||
1905 | 222 | &SingleDownload::bindDownload)) | 229 | &SingleDownload::bindDownload)) |
1906 | 223 | << "Could not connect to signal"; | 230 | << "Could not connect to signal"; |
1907 | 224 | } | 231 | } |
1909 | 225 | DownloadStruct dstruct(url); | 232 | Metadata metadata; |
1910 | 233 | QMap<QString, QString> headers; | ||
1911 | 234 | DownloadStruct dstruct(url, metadata.map(), headers); | ||
1912 | 226 | m_manager->createDownload(dstruct); | 235 | m_manager->createDownload(dstruct); |
1913 | 227 | } else { | 236 | } else { |
1914 | 228 | m_error.setMessage("Current download still in progress."); | 237 | m_error.setMessage("Current download still in progress."); |
1915 | @@ -258,7 +267,9 @@ | |||
1916 | 258 | void | 267 | void |
1917 | 259 | SingleDownload::pause() | 268 | SingleDownload::pause() |
1918 | 260 | { | 269 | { |
1920 | 261 | m_download->pause(); | 270 | if (m_download != nullptr) { |
1921 | 271 | m_download->pause(); | ||
1922 | 272 | } | ||
1923 | 262 | } | 273 | } |
1924 | 263 | 274 | ||
1925 | 264 | /*! | 275 | /*! |
1926 | @@ -270,7 +281,9 @@ | |||
1927 | 270 | void | 281 | void |
1928 | 271 | SingleDownload::resume() | 282 | SingleDownload::resume() |
1929 | 272 | { | 283 | { |
1931 | 273 | m_download->resume(); | 284 | if (m_download != nullptr) { |
1932 | 285 | m_download->resume(); | ||
1933 | 286 | } | ||
1934 | 274 | } | 287 | } |
1935 | 275 | 288 | ||
1936 | 276 | /*! | 289 | /*! |
1937 | @@ -281,7 +294,9 @@ | |||
1938 | 281 | void | 294 | void |
1939 | 282 | SingleDownload::cancel() | 295 | SingleDownload::cancel() |
1940 | 283 | { | 296 | { |
1942 | 284 | m_download->cancel(); | 297 | if (m_download != nullptr) { |
1943 | 298 | m_download->cancel(); | ||
1944 | 299 | } | ||
1945 | 285 | } | 300 | } |
1946 | 286 | 301 | ||
1947 | 287 | void | 302 | void |
1948 | @@ -354,7 +369,7 @@ | |||
1949 | 354 | bool | 369 | bool |
1950 | 355 | SingleDownload::allowMobileDownload() const { | 370 | SingleDownload::allowMobileDownload() const { |
1951 | 356 | if (m_download == nullptr) { | 371 | if (m_download == nullptr) { |
1953 | 357 | return m_mobile; | 372 | return m_mobile; |
1954 | 358 | } else { | 373 | } else { |
1955 | 359 | return m_download->isMobileDownloadAllowed(); | 374 | return m_download->isMobileDownloadAllowed(); |
1956 | 360 | } | 375 | } |
1957 | @@ -412,7 +427,7 @@ | |||
1958 | 412 | QString | 427 | QString |
1959 | 413 | SingleDownload::downloadId() const { | 428 | SingleDownload::downloadId() const { |
1960 | 414 | if (m_download == nullptr) { | 429 | if (m_download == nullptr) { |
1962 | 415 | return ""; | 430 | return m_downloadId; |
1963 | 416 | } else { | 431 | } else { |
1964 | 417 | return m_download->id(); | 432 | return m_download->id(); |
1965 | 418 | } | 433 | } |
1966 | @@ -577,11 +592,20 @@ | |||
1967 | 577 | */ | 592 | */ |
1968 | 578 | 593 | ||
1969 | 579 | /*! | 594 | /*! |
1971 | 580 | \qmlproperty QVariantMap SingleDownload:metadata: | 595 | \qmlproperty QVariantMap SingleDownload::metadata |
1972 | 581 | 596 | ||
1973 | 582 | This property allows to get and set the metadata that will be linked to | 597 | This property allows to get and set the metadata that will be linked to |
1974 | 583 | the download request. | 598 | the download request. |
1975 | 584 | */ | 599 | */ |
1976 | 585 | 600 | ||
1977 | 601 | /*! | ||
1978 | 602 | \qmlsignal SingleDownload::downloadFinished(QString path) | ||
1979 | 603 | |||
1980 | 604 | This signal is emitted when a download has finished. The downloaded file | ||
1981 | 605 | path is provided via the 'path' paremeter. The corresponding handler is | ||
1982 | 606 | \c onDownloadFinished | ||
1983 | 607 | */ | ||
1984 | 608 | |||
1985 | 609 | |||
1986 | 586 | } | 610 | } |
1987 | 587 | } | 611 | } |
1988 | 588 | 612 | ||
1989 | === modified file 'src/downloads/qml/single_download.h' | |||
1990 | --- src/downloads/qml/single_download.h 2015-02-02 11:22:26 +0000 | |||
1991 | +++ src/downloads/qml/single_download.h 2015-11-26 12:58:55 +0000 | |||
1992 | @@ -171,6 +171,7 @@ | |||
1993 | 171 | DownloadError m_error; | 171 | DownloadError m_error; |
1994 | 172 | Download* m_download = nullptr; | 172 | Download* m_download = nullptr; |
1995 | 173 | Manager* m_manager = nullptr; | 173 | Manager* m_manager = nullptr; |
1996 | 174 | QString m_downloadId; | ||
1997 | 174 | 175 | ||
1998 | 175 | }; | 176 | }; |
1999 | 176 | 177 | ||
2000 | 177 | 178 | ||
2001 | === modified file 'src/downloads/qml/ubuntu_download_manager.cpp' | |||
2002 | --- src/downloads/qml/ubuntu_download_manager.cpp 2014-05-07 12:27:08 +0000 | |||
2003 | +++ src/downloads/qml/ubuntu_download_manager.cpp 2015-11-26 12:58:55 +0000 | |||
2004 | @@ -1,6 +1,8 @@ | |||
2005 | 1 | #include "ubuntu_download_manager.h" | 1 | #include "ubuntu_download_manager.h" |
2006 | 2 | #include "download_history.h" | ||
2007 | 2 | #include <glog/logging.h> | 3 | #include <glog/logging.h> |
2008 | 3 | #include <ubuntu/download_manager/download_struct.h> | 4 | #include <ubuntu/download_manager/download_struct.h> |
2009 | 5 | #include <QDebug> | ||
2010 | 4 | 6 | ||
2011 | 5 | namespace Ubuntu { | 7 | namespace Ubuntu { |
2012 | 6 | 8 | ||
2013 | @@ -9,7 +11,7 @@ | |||
2014 | 9 | /*! | 11 | /*! |
2015 | 10 | \qmltype DownloadManager | 12 | \qmltype DownloadManager |
2016 | 11 | \instantiates DownloadManager | 13 | \instantiates DownloadManager |
2018 | 12 | \inqmlmodule Ubuntu.DownloadManager 0.1 | 14 | \inqmlmodule Ubuntu.DownloadManager 1.2 |
2019 | 13 | \ingroup download | 15 | \ingroup download |
2020 | 14 | \brief Manage downloads for several files. | 16 | \brief Manage downloads for several files. |
2021 | 15 | 17 | ||
2022 | @@ -23,8 +25,8 @@ | |||
2023 | 23 | 25 | ||
2024 | 24 | \qml | 26 | \qml |
2025 | 25 | import QtQuick 2.0 | 27 | import QtQuick 2.0 |
2028 | 26 | import Ubuntu.Components 0.1 | 28 | import Ubuntu.Components 1.2 |
2029 | 27 | import Ubuntu.DownloadManager 0.1 | 29 | import Ubuntu.DownloadManager 1.2 |
2030 | 28 | 30 | ||
2031 | 29 | Rectangle { | 31 | Rectangle { |
2032 | 30 | width: units.gu(100) | 32 | width: units.gu(100) |
2033 | @@ -89,6 +91,24 @@ | |||
2034 | 89 | CHECK(connect(m_manager, &Manager::downloadCreated, | 91 | CHECK(connect(m_manager, &Manager::downloadCreated, |
2035 | 90 | this, &UbuntuDownloadManager::downloadFileCreated)) | 92 | this, &UbuntuDownloadManager::downloadFileCreated)) |
2036 | 91 | << "Could not connect to signal"; | 93 | << "Could not connect to signal"; |
2037 | 94 | CHECK(connect(DownloadHistory::instance(), &DownloadHistory::downloadsChanged, | ||
2038 | 95 | this, &UbuntuDownloadManager::downloadsChanged)) | ||
2039 | 96 | << "Could not connect to signal"; | ||
2040 | 97 | CHECK(connect(DownloadHistory::instance(), &DownloadHistory::downloadFinished, | ||
2041 | 98 | this, &UbuntuDownloadManager::downloadFinished)) | ||
2042 | 99 | << "Could not connect to signal"; | ||
2043 | 100 | CHECK(connect(DownloadHistory::instance(), &DownloadHistory::downloadPaused, | ||
2044 | 101 | this, &UbuntuDownloadManager::downloadPaused)) | ||
2045 | 102 | << "Could not connect to signal"; | ||
2046 | 103 | CHECK(connect(DownloadHistory::instance(), &DownloadHistory::downloadResumed, | ||
2047 | 104 | this, &UbuntuDownloadManager::downloadResumed)) | ||
2048 | 105 | << "Could not connect to signal"; | ||
2049 | 106 | CHECK(connect(DownloadHistory::instance(), &DownloadHistory::downloadCanceled, | ||
2050 | 107 | this, &UbuntuDownloadManager::downloadCanceled)) | ||
2051 | 108 | << "Could not connect to signal"; | ||
2052 | 109 | CHECK(connect(DownloadHistory::instance(), &DownloadHistory::errorFound, | ||
2053 | 110 | this, &UbuntuDownloadManager::errorFound)) | ||
2054 | 111 | << "Could not connect to signal"; | ||
2055 | 92 | } | 112 | } |
2056 | 93 | 113 | ||
2057 | 94 | UbuntuDownloadManager::~UbuntuDownloadManager() | 114 | UbuntuDownloadManager::~UbuntuDownloadManager() |
2058 | @@ -96,7 +116,6 @@ | |||
2059 | 96 | if (m_manager != nullptr) { | 116 | if (m_manager != nullptr) { |
2060 | 97 | m_manager->deleteLater(); | 117 | m_manager->deleteLater(); |
2061 | 98 | } | 118 | } |
2062 | 99 | m_downloads.clear(); | ||
2063 | 100 | } | 119 | } |
2064 | 101 | 120 | ||
2065 | 102 | /*! | 121 | /*! |
2066 | @@ -106,7 +125,9 @@ | |||
2067 | 106 | */ | 125 | */ |
2068 | 107 | void UbuntuDownloadManager::download(QString url) | 126 | void UbuntuDownloadManager::download(QString url) |
2069 | 108 | { | 127 | { |
2071 | 109 | DownloadStruct dstruct(url); | 128 | Metadata metadata; |
2072 | 129 | QMap<QString, QString> headers; | ||
2073 | 130 | DownloadStruct dstruct(url, metadata.map(), headers); | ||
2074 | 110 | m_manager->createDownload(dstruct); | 131 | m_manager->createDownload(dstruct); |
2075 | 111 | } | 132 | } |
2076 | 112 | 133 | ||
2077 | @@ -116,12 +137,7 @@ | |||
2078 | 116 | CHECK(connect(singleDownload, &SingleDownload::errorFound, | 137 | CHECK(connect(singleDownload, &SingleDownload::errorFound, |
2079 | 117 | this, &UbuntuDownloadManager::registerError)) | 138 | this, &UbuntuDownloadManager::registerError)) |
2080 | 118 | << "Could not connect to signal"; | 139 | << "Could not connect to signal"; |
2081 | 119 | CHECK(connect(singleDownload, &SingleDownload::finished, | ||
2082 | 120 | this, &UbuntuDownloadManager::downloadCompleted)) | ||
2083 | 121 | << "Could not connect to signal"; | ||
2084 | 122 | singleDownload->bindDownload(download); | 140 | singleDownload->bindDownload(download); |
2085 | 123 | m_downloads.append(QVariant::fromValue(singleDownload)); | ||
2086 | 124 | emit downloadsChanged(); | ||
2087 | 125 | if (m_autoStart) { | 141 | if (m_autoStart) { |
2088 | 126 | singleDownload->startDownload(); | 142 | singleDownload->startDownload(); |
2089 | 127 | } | 143 | } |
2090 | @@ -132,41 +148,25 @@ | |||
2091 | 132 | Q_UNUSED(group); | 148 | Q_UNUSED(group); |
2092 | 133 | } | 149 | } |
2093 | 134 | 150 | ||
2095 | 135 | void UbuntuDownloadManager::registerError(DownloadError& error) | 151 | void UbuntuDownloadManager::registerError(DownloadError& downloadError) |
2096 | 136 | { | 152 | { |
2098 | 137 | m_errorMessage = error.message(); | 153 | m_errorMessage = downloadError.message(); |
2099 | 138 | emit errorChanged(); | 154 | emit errorChanged(); |
2100 | 139 | } | 155 | } |
2101 | 140 | 156 | ||
2102 | 157 | bool UbuntuDownloadManager::cleanDownloads() const | ||
2103 | 158 | { | ||
2104 | 159 | return DownloadHistory::instance()->cleanDownloads(); | ||
2105 | 160 | } | ||
2106 | 161 | |||
2107 | 141 | void UbuntuDownloadManager::setCleanDownloads(bool value) | 162 | void UbuntuDownloadManager::setCleanDownloads(bool value) |
2108 | 142 | { | 163 | { |
2123 | 143 | m_cleanDownloads = value; | 164 | DownloadHistory::instance()->setCleanDownloads(value); |
2110 | 144 | if (m_cleanDownloads) { | ||
2111 | 145 | QVariantList newList; | ||
2112 | 146 | foreach(QVariant var, m_downloads) { | ||
2113 | 147 | SingleDownload *download = qobject_cast<SingleDownload*>(var.value<SingleDownload*>()); | ||
2114 | 148 | if (download != nullptr && !download->isCompleted()) { | ||
2115 | 149 | newList.append(QVariant::fromValue(download)); | ||
2116 | 150 | } else { | ||
2117 | 151 | download->deleteLater(); | ||
2118 | 152 | } | ||
2119 | 153 | } | ||
2120 | 154 | m_downloads = newList; | ||
2121 | 155 | emit downloadsChanged(); | ||
2122 | 156 | } | ||
2124 | 157 | } | 165 | } |
2125 | 158 | 166 | ||
2127 | 159 | void UbuntuDownloadManager::downloadCompleted() | 167 | QVariantList UbuntuDownloadManager::downloads() |
2128 | 160 | { | 168 | { |
2138 | 161 | if (m_cleanDownloads) { | 169 | return DownloadHistory::instance()->downloads(); |
2130 | 162 | SingleDownload* download = qobject_cast<SingleDownload*>(sender()); | ||
2131 | 163 | if (download != nullptr) { | ||
2132 | 164 | int index = m_downloads.indexOf(QVariant::fromValue(download)); | ||
2133 | 165 | m_downloads.removeAt(index); | ||
2134 | 166 | emit downloadsChanged(); | ||
2135 | 167 | download->deleteLater(); | ||
2136 | 168 | } | ||
2137 | 169 | } | ||
2139 | 170 | } | 170 | } |
2140 | 171 | 171 | ||
2141 | 172 | /*! | 172 | /*! |
2142 | @@ -198,5 +198,47 @@ | |||
2143 | 198 | started, and let a custom delegate how to represent the UI for each download. | 198 | started, and let a custom delegate how to represent the UI for each download. |
2144 | 199 | */ | 199 | */ |
2145 | 200 | 200 | ||
2146 | 201 | /*! | ||
2147 | 202 | \qmlsignal DownloadManager::errorFound(SingleDownload download) | ||
2148 | 203 | \since Ubuntu.DownloadManager 1.2 | ||
2149 | 204 | |||
2150 | 205 | This signal is emitted when an error occurs in a download. The download in which the | ||
2151 | 206 | error occurred is provided via the 'download' parameter, from which the error message | ||
2152 | 207 | can be accessed via download.errorMessage. The corresponding handler is \c onErrorFound | ||
2153 | 208 | */ | ||
2154 | 209 | |||
2155 | 210 | /*! | ||
2156 | 211 | \qmlsignal DownloadManager::downloadFinished(SingleDownload download, QString path) | ||
2157 | 212 | \since Ubuntu.DownloadManager 1.2 | ||
2158 | 213 | |||
2159 | 214 | This signal is emitted when a download has finished. The finished download is provided | ||
2160 | 215 | via the 'download' parameter and the downloaded file path is provided via the 'path' | ||
2161 | 216 | paremeter. The corresponding handler is \c onDownloadFinished | ||
2162 | 217 | */ | ||
2163 | 218 | |||
2164 | 219 | /*! | ||
2165 | 220 | \qmlsignal DownloadManager::downloadPaused(SingleDownload download) | ||
2166 | 221 | \since Ubuntu.DownloadManager 1.2 | ||
2167 | 222 | |||
2168 | 223 | This signal is emitted when a download has been paused. The paused download is provided | ||
2169 | 224 | via the 'download' parameter. The corresponding handler is \c onDownloadPaused | ||
2170 | 225 | */ | ||
2171 | 226 | |||
2172 | 227 | /*! | ||
2173 | 228 | \qmlsignal DownloadManager::downloadResumed(SingleDownload download) | ||
2174 | 229 | \since Ubuntu.DownloadManager 1.2 | ||
2175 | 230 | |||
2176 | 231 | This signal is emitted when a download has been resumed. The resumed download is provided | ||
2177 | 232 | via the 'download' parameter. The corresponding handler is \c onDownloadResumed | ||
2178 | 233 | */ | ||
2179 | 234 | |||
2180 | 235 | /*! | ||
2181 | 236 | \qmlsignal DownloadManager::downloadCanceled(SingleDownload download) | ||
2182 | 237 | \since Ubuntu.DownloadManager 1.2 | ||
2183 | 238 | |||
2184 | 239 | This signal is emitted when a download has been canceled. The canceled download is provided | ||
2185 | 240 | via the 'download' parameter. The corresponding handler is \c onDownloadCanceled | ||
2186 | 241 | */ | ||
2187 | 201 | } | 242 | } |
2188 | 243 | |||
2189 | 202 | } | 244 | } |
2190 | 203 | 245 | ||
2191 | === modified file 'src/downloads/qml/ubuntu_download_manager.h' | |||
2192 | --- src/downloads/qml/ubuntu_download_manager.h 2014-06-25 08:46:25 +0000 | |||
2193 | +++ src/downloads/qml/ubuntu_download_manager.h 2015-11-26 12:58:55 +0000 | |||
2194 | @@ -45,27 +45,31 @@ | |||
2195 | 45 | 45 | ||
2196 | 46 | Q_INVOKABLE void download(QString url); | 46 | Q_INVOKABLE void download(QString url); |
2197 | 47 | 47 | ||
2199 | 48 | QVariantList downloads() { return m_downloads; } | 48 | QVariantList downloads(); |
2200 | 49 | QString errorMessage() const { return m_errorMessage; } | 49 | QString errorMessage() const { return m_errorMessage; } |
2201 | 50 | bool autoStart() const { return m_autoStart; } | 50 | bool autoStart() const { return m_autoStart; } |
2203 | 51 | bool cleanDownloads() const { return m_cleanDownloads; } | 51 | bool cleanDownloads() const; |
2204 | 52 | void setCleanDownloads(bool value); | 52 | void setCleanDownloads(bool value); |
2205 | 53 | void setAutoStart(bool value) { m_autoStart = value; } | 53 | void setAutoStart(bool value) { m_autoStart = value; } |
2206 | 54 | 54 | ||
2207 | 55 | signals: | 55 | signals: |
2208 | 56 | void errorChanged(); | 56 | void errorChanged(); |
2209 | 57 | void downloadsChanged(); | 57 | void downloadsChanged(); |
2210 | 58 | void downloadFinished(SingleDownload *download, const QString& path); | ||
2211 | 59 | void errorFound(SingleDownload *download); | ||
2212 | 60 | void downloadPaused(SingleDownload *download); | ||
2213 | 61 | void downloadResumed(SingleDownload *download); | ||
2214 | 62 | void downloadCanceled(SingleDownload *download); | ||
2215 | 58 | 63 | ||
2216 | 59 | private slots: | 64 | private slots: |
2217 | 60 | void registerError(DownloadError& error); | 65 | void registerError(DownloadError& error); |
2218 | 61 | void downloadFileCreated(Download* download); | 66 | void downloadFileCreated(Download* download); |
2219 | 62 | void downloadGroupCreated(GroupDownload* group); | 67 | void downloadGroupCreated(GroupDownload* group); |
2221 | 63 | void downloadCompleted(); | 68 | void downloadsFound(DownloadsList* downloads); |
2222 | 64 | 69 | ||
2223 | 65 | private: | 70 | private: |
2224 | 66 | bool m_autoStart; | 71 | bool m_autoStart; |
2225 | 67 | bool m_cleanDownloads; | 72 | bool m_cleanDownloads; |
2226 | 68 | QVariantList m_downloads; | ||
2227 | 69 | QString m_errorMessage; | 73 | QString m_errorMessage; |
2228 | 70 | Manager* m_manager; | 74 | Manager* m_manager; |
2229 | 71 | }; | 75 | }; |
2230 | 72 | 76 | ||
2231 | === modified file 'tests/downloads/daemon/download.h' | |||
2232 | --- tests/downloads/daemon/download.h 2014-07-03 09:01:01 +0000 | |||
2233 | +++ tests/downloads/daemon/download.h 2015-11-26 12:58:55 +0000 | |||
2234 | @@ -84,8 +84,8 @@ | |||
2235 | 84 | MOCK_METHOD0(pauseTransfer, void()); | 84 | MOCK_METHOD0(pauseTransfer, void()); |
2236 | 85 | MOCK_METHOD0(resumeTransfer, void()); | 85 | MOCK_METHOD0(resumeTransfer, void()); |
2237 | 86 | MOCK_METHOD0(startTransfer, void()); | 86 | MOCK_METHOD0(startTransfer, void()); |
2238 | 87 | MOCK_METHOD0(filePath, QString()); | ||
2239 | 87 | MOCK_CONST_METHOD0(isValid, bool()); | 88 | MOCK_CONST_METHOD0(isValid, bool()); |
2240 | 88 | MOCK_CONST_METHOD0(filePath, QString()); | ||
2241 | 89 | MOCK_CONST_METHOD0(state, Transfer::State()); | 89 | MOCK_CONST_METHOD0(state, Transfer::State()); |
2242 | 90 | MOCK_CONST_METHOD0(path, QString()); | 90 | MOCK_CONST_METHOD0(path, QString()); |
2243 | 91 | MOCK_CONST_METHOD0(metadata, QVariantMap()); | 91 | MOCK_CONST_METHOD0(metadata, QVariantMap()); |
2244 | 92 | 92 | ||
2245 | === modified file 'tests/downloads/daemon/test_download.cpp' | |||
2246 | --- tests/downloads/daemon/test_download.cpp 2015-02-25 16:24:24 +0000 | |||
2247 | +++ tests/downloads/daemon/test_download.cpp 2015-11-26 12:58:55 +0000 | |||
2248 | @@ -1301,7 +1301,7 @@ | |||
2249 | 1301 | QVERIFY(spy.ensureSignalEmitted()); | 1301 | QVERIFY(spy.ensureSignalEmitted()); |
2250 | 1302 | QTRY_COMPARE(spy.count(), 1); | 1302 | QTRY_COMPARE(spy.count(), 1); |
2251 | 1303 | QTRY_COMPARE(processingSpy.count(), 0); | 1303 | QTRY_COMPARE(processingSpy.count(), 0); |
2253 | 1304 | QCOMPARE(download->state(), Download::FINISH); | 1304 | QCOMPARE(download->state(), Download::UNCOLLECTED); |
2254 | 1305 | 1305 | ||
2255 | 1306 | delete download; | 1306 | delete download; |
2256 | 1307 | 1307 | ||
2257 | @@ -1481,7 +1481,7 @@ | |||
2258 | 1481 | QVERIFY(spy.ensureSignalEmitted()); | 1481 | QVERIFY(spy.ensureSignalEmitted()); |
2259 | 1482 | QTRY_COMPARE(spy.count(), 1); | 1482 | QTRY_COMPARE(spy.count(), 1); |
2260 | 1483 | QTRY_COMPARE(processingSpy.count(), 1); | 1483 | QTRY_COMPARE(processingSpy.count(), 1); |
2262 | 1484 | QCOMPARE(download->state(), Download::FINISH); | 1484 | QCOMPARE(download->state(), Download::UNCOLLECTED); |
2263 | 1485 | 1485 | ||
2264 | 1486 | delete download; | 1486 | delete download; |
2265 | 1487 | 1487 | ||
2266 | @@ -2196,7 +2196,7 @@ | |||
2267 | 2196 | 2196 | ||
2268 | 2197 | QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000); | 2197 | QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000); |
2269 | 2198 | QTRY_COMPARE_WITH_TIMEOUT(processingSpy.count(), 1, 20000); | 2198 | QTRY_COMPARE_WITH_TIMEOUT(processingSpy.count(), 1, 20000); |
2271 | 2199 | QCOMPARE(download->state(), Download::FINISH); | 2199 | QCOMPARE(download->state(), Download::UNCOLLECTED); |
2272 | 2200 | 2200 | ||
2273 | 2201 | delete download; | 2201 | delete download; |
2274 | 2202 | 2202 | ||
2275 | @@ -2309,7 +2309,7 @@ | |||
2276 | 2309 | 2309 | ||
2277 | 2310 | QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000); | 2310 | QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000); |
2278 | 2311 | QTRY_COMPARE_WITH_TIMEOUT(processingSpy.count(), 1, 20000); | 2311 | QTRY_COMPARE_WITH_TIMEOUT(processingSpy.count(), 1, 20000); |
2280 | 2312 | QCOMPARE(download->state(), Download::FINISH); | 2312 | QCOMPARE(download->state(), Download::UNCOLLECTED); |
2281 | 2313 | 2313 | ||
2282 | 2314 | delete download; | 2314 | delete download; |
2283 | 2315 | 2315 | ||
2284 | @@ -2431,7 +2431,7 @@ | |||
2285 | 2431 | QVERIFY(spy.ensureSignalEmitted()); | 2431 | QVERIFY(spy.ensureSignalEmitted()); |
2286 | 2432 | QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000); | 2432 | QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000); |
2287 | 2433 | QTRY_COMPARE_WITH_TIMEOUT(processingSpy.count(), 1, 20000); | 2433 | QTRY_COMPARE_WITH_TIMEOUT(processingSpy.count(), 1, 20000); |
2289 | 2434 | QCOMPARE(download->state(), Download::FINISH); | 2434 | QCOMPARE(download->state(), Download::UNCOLLECTED); |
2290 | 2435 | 2435 | ||
2291 | 2436 | delete download; | 2436 | delete download; |
2292 | 2437 | 2437 | ||
2293 | @@ -3735,7 +3735,7 @@ | |||
2294 | 3735 | QVERIFY(spy.ensureSignalEmitted()); | 3735 | QVERIFY(spy.ensureSignalEmitted()); |
2295 | 3736 | QCOMPARE(spy.count(), 1); | 3736 | QCOMPARE(spy.count(), 1); |
2296 | 3737 | QCOMPARE(processingSpy.count(), 1); | 3737 | QCOMPARE(processingSpy.count(), 1); |
2298 | 3738 | QCOMPARE(download->state(), Download::FINISH); | 3738 | QCOMPARE(download->state(), Download::UNCOLLECTED); |
2299 | 3739 | 3739 | ||
2300 | 3740 | delete download; | 3740 | delete download; |
2301 | 3741 | 3741 | ||
2302 | @@ -4167,7 +4167,7 @@ | |||
2303 | 4167 | 4167 | ||
2304 | 4168 | QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000); | 4168 | QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000); |
2305 | 4169 | QTRY_COMPARE_WITH_TIMEOUT(processingSpy.count(), 1, 20000); | 4169 | QTRY_COMPARE_WITH_TIMEOUT(processingSpy.count(), 1, 20000); |
2307 | 4170 | QCOMPARE(download->state(), Download::FINISH); | 4170 | QCOMPARE(download->state(), Download::UNCOLLECTED); |
2308 | 4171 | 4171 | ||
2309 | 4172 | delete download; | 4172 | delete download; |
2310 | 4173 | 4173 | ||
2311 | 4174 | 4174 | ||
2312 | === modified file 'tests/downloads/daemon/test_downloads_db.cpp' | |||
2313 | --- tests/downloads/daemon/test_downloads_db.cpp 2014-11-17 20:34:24 +0000 | |||
2314 | +++ tests/downloads/daemon/test_downloads_db.cpp 2015-11-26 12:58:55 +0000 | |||
2315 | @@ -351,4 +351,77 @@ | |||
2316 | 351 | QTRY_COMPARE(1, spy.count()); | 351 | QTRY_COMPARE(1, spy.count()); |
2317 | 352 | } | 352 | } |
2318 | 353 | 353 | ||
2319 | 354 | void | ||
2320 | 355 | TestDownloadsDb::testGetStateMissingDownload() { | ||
2321 | 356 | _db->init(); | ||
2322 | 357 | auto result = _db->getDownloadState("random uuid"); | ||
2323 | 358 | QVERIFY(!result.isValid()); | ||
2324 | 359 | } | ||
2325 | 360 | |||
2326 | 361 | void | ||
2327 | 362 | TestDownloadsDb::testGetStateDownload_data() { | ||
2328 | 363 | QTest::addColumn<QString>("id"); | ||
2329 | 364 | QTest::addColumn<QString>("appId"); | ||
2330 | 365 | QTest::addColumn<QString>("path"); | ||
2331 | 366 | QTest::addColumn<QUrl>("url"); | ||
2332 | 367 | QTest::addColumn<QString>("hash"); | ||
2333 | 368 | QTest::addColumn<QString>("hashAlgoString"); | ||
2334 | 369 | QTest::addColumn<QVariantMap>("metadata"); | ||
2335 | 370 | QTest::addColumn<QMap<QString, QString> >("headers"); | ||
2336 | 371 | |||
2337 | 372 | QTest::newRow("First Row") << UuidUtils::getDBusString(QUuid::createUuid()) | ||
2338 | 373 | << "FIRST APP" << "first path" << QUrl("http://ubuntu.com") << "" | ||
2339 | 374 | << "md5" << QVariantMap() << QMap<QString, QString>(); | ||
2340 | 375 | |||
2341 | 376 | QVariantMap secondMetadata; | ||
2342 | 377 | secondMetadata["test"] = 1; | ||
2343 | 378 | secondMetadata["command"] = "cd"; | ||
2344 | 379 | secondMetadata["hello"] = 23; | ||
2345 | 380 | |||
2346 | 381 | QTest::newRow("Second Row") << UuidUtils::getDBusString(QUuid::createUuid()) | ||
2347 | 382 | << "SECOND APP" << "second path" << QUrl("http://ubuntu.com/phone") | ||
2348 | 383 | << "" << "sha512" << secondMetadata << QMap<QString, QString>(); | ||
2349 | 384 | |||
2350 | 385 | QVariantMap thirdMetadata; | ||
2351 | 386 | secondMetadata["test"] = 3; | ||
2352 | 387 | secondMetadata["command"] = "return"; | ||
2353 | 388 | secondMetadata["hello"] = 500; | ||
2354 | 389 | |||
2355 | 390 | QMap<QString, QString> thirdHeaders; | ||
2356 | 391 | thirdHeaders["my-header"] = "I do something cool"; | ||
2357 | 392 | |||
2358 | 393 | QTest::newRow("Third Row") << UuidUtils::getDBusString(QUuid::createUuid()) | ||
2359 | 394 | << "THIRD APP" << "third path" << QUrl("http://ubuntu.com/tablet") | ||
2360 | 395 | << "" << "sha384" << thirdMetadata << thirdHeaders; | ||
2361 | 396 | } | ||
2362 | 397 | |||
2363 | 398 | void | ||
2364 | 399 | TestDownloadsDb::testGetStateDownload() { | ||
2365 | 400 | _db->init(); | ||
2366 | 401 | QFETCH(QString, id); | ||
2367 | 402 | QFETCH(QString, appId); | ||
2368 | 403 | QFETCH(QString, path); | ||
2369 | 404 | QFETCH(QUrl, url); | ||
2370 | 405 | QFETCH(QString, hash); | ||
2371 | 406 | QFETCH(QString, hashAlgoString); | ||
2372 | 407 | QFETCH(QVariantMap, metadata); | ||
2373 | 408 | QFETCH(StringMap, headers); | ||
2374 | 409 | |||
2375 | 410 | QScopedPointer<FileDownload> download(new FileDownload(id, appId, path, true, "", url, hash, | ||
2376 | 411 | hashAlgoString, metadata, headers)); | ||
2377 | 412 | |||
2378 | 413 | _db->storeSingleDownload(download.data()); | ||
2379 | 414 | |||
2380 | 415 | // create a second download with same id but a diff path to test is update | ||
2381 | 416 | QString newPath = path + path; | ||
2382 | 417 | QScopedPointer<FileDownload> secondDownload(new FileDownload(id, appId, | ||
2383 | 418 | newPath, true, "", url, hash, hashAlgoString, metadata, headers)); | ||
2384 | 419 | |||
2385 | 420 | _db->storeSingleDownload(secondDownload.data()); | ||
2386 | 421 | auto state = _db->getDownloadState(id); | ||
2387 | 422 | QVERIFY(state.isValid()); | ||
2388 | 423 | QCOMPARE(state.getUrl(), url.toString()); | ||
2389 | 424 | QCOMPARE(state.getHash(), state.getHash()); | ||
2390 | 425 | } | ||
2391 | 426 | |||
2392 | 354 | QTEST_MAIN(TestDownloadsDb) | 427 | QTEST_MAIN(TestDownloadsDb) |
2393 | 355 | 428 | ||
2394 | === modified file 'tests/downloads/daemon/test_downloads_db.h' | |||
2395 | --- tests/downloads/daemon/test_downloads_db.h 2014-07-03 09:01:01 +0000 | |||
2396 | +++ tests/downloads/daemon/test_downloads_db.h 2015-11-26 12:58:55 +0000 | |||
2397 | @@ -15,8 +15,7 @@ | |||
2398 | 15 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 15 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
2399 | 16 | * Boston, MA 02110-1301, USA. | 16 | * Boston, MA 02110-1301, USA. |
2400 | 17 | */ | 17 | */ |
2403 | 18 | #ifndef TEST_DOWNLOADS_DB_H | 18 | #pragma once |
2402 | 19 | #define TEST_DOWNLOADS_DB_H | ||
2404 | 20 | 19 | ||
2405 | 21 | #include <QDir> | 20 | #include <QDir> |
2406 | 22 | #include <QObject> | 21 | #include <QObject> |
2407 | @@ -65,9 +64,10 @@ | |||
2408 | 65 | void testStoreSingleDownloadPresent(); | 64 | void testStoreSingleDownloadPresent(); |
2409 | 66 | void testConnectedToDownload(); | 65 | void testConnectedToDownload(); |
2410 | 67 | void testDisconnectedFromDownload(); | 66 | void testDisconnectedFromDownload(); |
2411 | 67 | void testGetStateMissingDownload(); | ||
2412 | 68 | void testGetStateDownload_data(); | ||
2413 | 69 | void testGetStateDownload(); | ||
2414 | 68 | 70 | ||
2415 | 69 | private: | 71 | private: |
2416 | 70 | DownloadsDb* _db; | 72 | DownloadsDb* _db; |
2417 | 71 | }; | 73 | }; |
2418 | 72 | |||
2419 | 73 | #endif // TEST_DOWNLOADS_DB_H |