Merge lp:~mandel/ubuntu-download-manager/expose-property into lp:ubuntu-download-manager
- expose-property
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Manuel de la Peña | ||||||||
Approved revision: | 332 | ||||||||
Merged at revision: | 306 | ||||||||
Proposed branch: | lp:~mandel/ubuntu-download-manager/expose-property | ||||||||
Merge into: | lp:ubuntu-download-manager | ||||||||
Prerequisite: | lp:~mandel/ubuntu-download-manager/set-headers-dbus-method | ||||||||
Diff against target: |
2866 lines (+1519/-346) 35 files modified
CMakeLists.txt (+2/-1) debian/changelog (+8/-0) debian/control (+1/-0) debian/libubuntu-download-manager-client0.symbols (+1/-0) src/common/public/ubuntu/transfers/system/logger.cpp (+1/-0) src/downloads/client/CMakeLists.txt (+6/-0) src/downloads/client/symbols.map (+6/-0) src/downloads/client/ubuntu/download_manager/download_impl.cpp (+114/-25) src/downloads/client/ubuntu/download_manager/download_impl.h (+6/-3) src/downloads/client/ubuntu/download_manager/download_pendingcall_watcher.cpp (+23/-13) src/downloads/client/ubuntu/download_manager/logging/logger.cpp (+213/-0) src/downloads/client/ubuntu/download_manager/logging/logger.h (+106/-0) src/downloads/client/ubuntu/download_manager/manager.cpp (+2/-3) src/downloads/client/ubuntu/download_manager/manager_impl.cpp (+50/-18) src/downloads/client/ubuntu/download_manager/manager_impl.h (+8/-6) src/downloads/client/ubuntu/download_manager/manager_pendingcall_watcher.cpp (+48/-26) src/downloads/qml/CMakeLists.txt (+2/-2) src/downloads/qml/backend.h (+18/-0) src/downloads/qml/download_error.h (+18/-0) src/downloads/qml/single_download.cpp (+266/-54) src/downloads/qml/single_download.h (+93/-20) src/downloads/qml/ubuntu_download_manager.h (+18/-0) tests/CMakeLists.txt (+19/-173) tests/common/CMakeLists.txt (+55/-0) tests/common/base_testcase.cpp (+1/-1) tests/common/local_tree_testcase.cpp (+3/-1) tests/common/local_tree_testcase.h (+2/-0) tests/downloads/CMakeLists.txt (+19/-0) tests/downloads/client/CMakeLists.txt (+90/-0) tests/downloads/daemon/CMakeLists.txt (+129/-0) tests/downloads/qml/CMakeLists.txt (+14/-0) tests/downloads/qml/download.h (+53/-0) tests/downloads/qml/manager.h (+55/-0) tests/downloads/qml/test_single_download.cpp (+31/-0) tests/downloads/qml/test_single_download.h (+38/-0) |
||||||||
To merge this branch: | bzr merge lp:~mandel/ubuntu-download-manager/expose-property | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Diego Sarmentero (community) | Approve | ||
Review via email:
|
Commit message
Expose the headers property in the qml.
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
- 319. By Manuel de la Peña
-
Move the headers properties from QMap<QString, QString> to QVariantMap.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:319
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 320. By Manuel de la Peña
-
Ensure that properties can be used BEFORE the m_download pointer has been init.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:320
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 321. By Manuel de la Peña
-
Added logger definition.
- 322. By Manuel de la Peña
-
Merged client-logging into expose-property.
- 323. By Manuel de la Peña
-
Merged client-logging into expose-property.
- 324. By Manuel de la Peña
-
Merged client-logging into expose-property.
- 325. By Manuel de la Peña
-
Merged client-logging into expose-property.
- 326. By Manuel de la Peña
-
Remove logger so that it can be added in a diff mr.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:326
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 327. By Manuel de la Peña
-
Merged client-logging into expose-property.
- 328. By Manuel de la Peña
-
Update documentation.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:328
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 329. By Manuel de la Peña
-
Merged client-logging into expose-property.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:329
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 330. By Manuel de la Peña
-
Refactored tests so that we can easily add qml tests.
- 331. By Manuel de la Peña
-
Ensure that we set the internal pointer to nullptr when we either finish or cancel a download.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:331
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 332. By Manuel de la Peña
-
Fix memory leak.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:332
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2014-07-03 14:40:17 +0000 |
3 | +++ CMakeLists.txt 2014-07-03 14:40:18 +0000 |
4 | @@ -31,7 +31,7 @@ |
5 | ) |
6 | |
7 | set(UDM_VERSION_MAJOR 0) |
8 | -set(UDM_VERSION_MINOR 5) |
9 | +set(UDM_VERSION_MINOR 6) |
10 | set(UDM_VERSION_PATCH 0) |
11 | |
12 | find_package(Gtest REQUIRED) |
13 | @@ -46,6 +46,7 @@ |
14 | find_package(Qt5SystemInfo REQUIRED) |
15 | find_package(Qt5Sql REQUIRED) |
16 | find_package(Qt5Test REQUIRED) |
17 | +find_package(Boost COMPONENTS log REQUIRED) |
18 | |
19 | find_package(PkgConfig REQUIRED) |
20 | pkg_check_modules(DBUS REQUIRED dbus-1) |
21 | |
22 | === modified file 'debian/changelog' |
23 | --- debian/changelog 2014-07-03 14:40:17 +0000 |
24 | +++ debian/changelog 2014-07-03 14:40:18 +0000 |
25 | @@ -1,3 +1,11 @@ |
26 | +ubuntu-download-manager (0.6) UNRELEASED; urgency=medium |
27 | + |
28 | + * Add a new public object in the client library that provides a way |
29 | + to configure the logging done in the client library. ABI is changed |
30 | + and a new dependency is added. |
31 | + |
32 | + -- Manuel de la Pena <manuel.delapena@canonical.com> Thu, 26 Jun 2014 13:00:45 +0200 |
33 | + |
34 | ubuntu-download-manager (0.5) UNRELEASED; urgency=medium |
35 | |
36 | * Add support to set the headers for a single file download. This change |
37 | |
38 | === modified file 'debian/control' |
39 | --- debian/control 2014-04-30 14:59:42 +0000 |
40 | +++ debian/control 2014-07-03 14:40:18 +0000 |
41 | @@ -10,6 +10,7 @@ |
42 | qt5-default, |
43 | qtbase5-dev, |
44 | qtsystems5-dev, |
45 | + libboost-log-dev, |
46 | libdbus-1-dev, |
47 | libqt5sql5-sqlite, |
48 | libnih-dbus-dev, |
49 | |
50 | === modified file 'debian/libubuntu-download-manager-client0.symbols' |
51 | --- debian/libubuntu-download-manager-client0.symbols 2014-06-18 14:49:04 +0000 |
52 | +++ debian/libubuntu-download-manager-client0.symbols 2014-07-03 14:40:18 +0000 |
53 | @@ -24,6 +24,7 @@ |
54 | (c++)"Ubuntu::DownloadManager::ProcessError::~ProcessError()@Base" 0.4+14.10.20140618 |
55 | (c++)"Ubuntu::DownloadManager::ProcessError::~ProcessError()@Base" 0.4+14.10.20140618 |
56 | (c++)"Ubuntu::DownloadManager::ProcessError::~ProcessError()@Base" 0.4+14.10.20140618 |
57 | + (c++)"Ubuntu::DownloadManager::Logging::Logger::init(Ubuntu::DownloadManager::Logging::Logger::Level, QString const&)@Base" 0replaceme |
58 | (c++)"Ubuntu::DownloadManager::DownloadsList::qt_metacall(QMetaObject::Call, int, void**)@Base" 0.4+14.10.20140618 |
59 | (c++)"Ubuntu::DownloadManager::DownloadsList::qt_metacast(char const*)@Base" 0.4+14.10.20140618 |
60 | (c++)"Ubuntu::DownloadManager::DownloadsList::staticMetaObject@Base" 0.4+14.10.20140618 |
61 | |
62 | === modified file 'src/common/public/ubuntu/transfers/system/logger.cpp' |
63 | --- src/common/public/ubuntu/transfers/system/logger.cpp 2014-03-28 15:50:24 +0000 |
64 | +++ src/common/public/ubuntu/transfers/system/logger.cpp 2014-07-03 14:40:18 +0000 |
65 | @@ -118,6 +118,7 @@ |
66 | google::SetLogDestination(google::ERROR, toStdString(path).c_str()); |
67 | google::SetLogDestination(google::WARNING, toStdString(path).c_str()); |
68 | google::SetLogDestination(google::INFO, toStdString(path).c_str()); |
69 | + google::SetLogDestination(google::FATAL, toStdString(path).c_str()); |
70 | } |
71 | } |
72 | |
73 | |
74 | === modified file 'src/downloads/client/CMakeLists.txt' |
75 | --- src/downloads/client/CMakeLists.txt 2014-06-17 10:23:15 +0000 |
76 | +++ src/downloads/client/CMakeLists.txt 2014-07-03 14:40:18 +0000 |
77 | @@ -1,3 +1,5 @@ |
78 | +add_definitions(-DBOOST_LOG_DYN_LINK) |
79 | + |
80 | set(TARGET ubuntu-download-manager-client) |
81 | |
82 | set(SOURCES |
83 | @@ -11,6 +13,7 @@ |
84 | ubuntu/download_manager/manager_impl.cpp |
85 | ubuntu/download_manager/manager_interface.cpp |
86 | ubuntu/download_manager/manager_pendingcall_watcher.cpp |
87 | + ubuntu/download_manager/logging/logger.cpp |
88 | ubuntu/download_manager/pending_call_watcher.cpp |
89 | ) |
90 | |
91 | @@ -20,6 +23,7 @@ |
92 | ubuntu/download_manager/error.h |
93 | ubuntu/download_manager/group_download.h |
94 | ubuntu/download_manager/manager.h |
95 | + ubuntu/download_manager/logging/logger.h |
96 | ) |
97 | |
98 | set(PRIVATE_HEADERS |
99 | @@ -37,6 +41,7 @@ |
100 | include_directories(${Qt5Network_INCLUDE_DIRS}) |
101 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) |
102 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
103 | +include_directories(${Boost_INCLUDE_DIRS}) |
104 | include_directories(${CMAKE_SOURCE_DIR}/src/common/public) |
105 | include_directories(${CMAKE_SOURCE_DIR}/src/downloads/common) |
106 | |
107 | @@ -58,6 +63,7 @@ |
108 | ) |
109 | |
110 | target_link_libraries(${TARGET} |
111 | + ${Boost_LIBRARIES} |
112 | ${Qt5DBus_LIBRARIES} |
113 | ${GLOG_LIBRARIES} |
114 | udm-common |
115 | |
116 | === modified file 'src/downloads/client/symbols.map' |
117 | --- src/downloads/client/symbols.map 2014-06-17 10:23:15 +0000 |
118 | +++ src/downloads/client/symbols.map 2014-07-03 14:40:18 +0000 |
119 | @@ -11,6 +11,7 @@ |
120 | Ubuntu::DownloadManager::ProcessError::*; |
121 | Ubuntu::DownloadManager::GroupDownload::*; |
122 | Ubuntu::DownloadManager::Manager::*; |
123 | + Ubuntu::DownloadManager::Logging::Logger::init*; |
124 | typeinfo?for?Ubuntu::DownloadManager::Download; |
125 | typeinfo?for?Ubuntu::DownloadManager::DownloadsList; |
126 | typeinfo?for?Ubuntu::DownloadManager::Error; |
127 | @@ -21,6 +22,7 @@ |
128 | typeinfo?for?Ubuntu::DownloadManager::ProcessError; |
129 | typeinfo?for?Ubuntu::DownloadManager::GroupDownload; |
130 | typeinfo?for?Ubuntu::DownloadManager::Manager; |
131 | + typeinfo?for?Ubuntu::DownloadManager::Logging::Logger; |
132 | typeinfo?name?for?Ubuntu::DownloadManager::Download; |
133 | typeinfo?name?for?Ubuntu::DownloadManager::DownloadsList; |
134 | typeinfo?name?for?Ubuntu::DownloadManager::Error; |
135 | @@ -31,6 +33,7 @@ |
136 | typeinfo?name?for?Ubuntu::DownloadManager::ProcessError; |
137 | typeinfo?name?for?Ubuntu::DownloadManager::GroupDownload; |
138 | typeinfo?name?for?Ubuntu::DownloadManager::Manager; |
139 | + typeinfo?name?for?Ubuntu::DownloadManager::Logging::Logger; |
140 | VTT?for?Ubuntu::DownloadManager::Download; |
141 | VTT?for?Ubuntu::DownloadManager::DownloadsList; |
142 | VTT?for?Ubuntu::DownloadManager::Error; |
143 | @@ -41,6 +44,7 @@ |
144 | VTT?for?Ubuntu::DownloadManager::ProcessError; |
145 | VTT?for?Ubuntu::DownloadManager::GroupDownload; |
146 | VTT?for?Ubuntu::DownloadManager::Manager; |
147 | + VTT?for?Ubuntu::DownloadManager::Logging::Logger; |
148 | virtual?thunk?to?Ubuntu::DownloadManager::Download; |
149 | virtual?thunk?to?Ubuntu::DownloadManager::DownloadsList; |
150 | virtual?thunk?to?Ubuntu::DownloadManager::Error; |
151 | @@ -51,6 +55,7 @@ |
152 | virtual?thunk?to?Ubuntu::DownloadManager::ProcessError; |
153 | virtual?thunk?to?Ubuntu::DownloadManager::GroupDownload; |
154 | virtual?thunk?to?Ubuntu::DownloadManager::Manager; |
155 | + virtual?thunk?to?Ubuntu::DownloadManager::Logging::Logger; |
156 | vtable?for?Ubuntu::DownloadManager::Download; |
157 | vtable?for?Ubuntu::DownloadManager::DownloadsList; |
158 | vtable?for?Ubuntu::DownloadManager::Error; |
159 | @@ -61,6 +66,7 @@ |
160 | vtable?for?Ubuntu::DownloadManager::ProcessError; |
161 | vtable?for?Ubuntu::DownloadManager::GroupDownload; |
162 | vtable?for?Ubuntu::DownloadManager::Manager; |
163 | + vtable?for?Ubuntu::DownloadManager::Logging::Logger; |
164 | std::function* |
165 | }; |
166 | |
167 | |
168 | === modified file 'src/downloads/client/ubuntu/download_manager/download_impl.cpp' |
169 | --- src/downloads/client/ubuntu/download_manager/download_impl.cpp 2014-07-03 14:40:17 +0000 |
170 | +++ src/downloads/client/ubuntu/download_manager/download_impl.cpp 2014-07-03 14:40:18 +0000 |
171 | @@ -16,13 +16,15 @@ |
172 | * Boston, MA 02110-1301, USA. |
173 | */ |
174 | |
175 | -#include <glog/logging.h> |
176 | +#include <ubuntu/download_manager/logging/logger.h> |
177 | #include "download_impl.h" |
178 | |
179 | namespace Ubuntu { |
180 | |
181 | namespace DownloadManager { |
182 | |
183 | +using namespace Logging; |
184 | + |
185 | DownloadImpl::DownloadImpl(const QDBusConnection& conn, |
186 | const QString& servicePath, |
187 | const QDBusObjectPath& objectPath, |
188 | @@ -31,38 +33,92 @@ |
189 | _id(objectPath.path()), |
190 | _conn(conn), |
191 | _servicePath(servicePath) { |
192 | + |
193 | _dbusInterface = new DownloadInterface(servicePath, |
194 | _id, conn); |
195 | |
196 | // fwd all the signals but the error one |
197 | - CHECK(connect(_dbusInterface, &DownloadInterface::canceled, |
198 | - this, &Download::canceled)) << "Could not connect to signal"; |
199 | - CHECK(connect(_dbusInterface, &DownloadInterface::finished, |
200 | - this, &Download::finished)) << "Could not connect to signal"; |
201 | - CHECK(connect(_dbusInterface, &DownloadInterface::paused, |
202 | - this, &Download::paused)) << "Could not connect to signal"; |
203 | - CHECK(connect(_dbusInterface, &DownloadInterface::processing, |
204 | - this, &Download::processing)) << "Could not connect to signal"; |
205 | - CHECK(connect(_dbusInterface, static_cast<void(DownloadInterface::*) |
206 | + auto connected = connect(_dbusInterface, &DownloadInterface::canceled, |
207 | + this, &Download::canceled); |
208 | + |
209 | + if (!connected) { |
210 | + Logger::log(Logger::Critical, |
211 | + "Could not connect to signal DownloadInterface::canceled"); |
212 | + } |
213 | + |
214 | + connected = connect(_dbusInterface, &DownloadInterface::finished, |
215 | + this, &Download::finished); |
216 | + if (!connected) { |
217 | + Logger::log(Logger::Critical, |
218 | + "Could not connect to signal &DownloadInterface::finished"); |
219 | + } |
220 | + |
221 | + connected = connect(_dbusInterface, &DownloadInterface::paused, |
222 | + this, &Download::paused); |
223 | + if (!connected) { |
224 | + Logger::log(Logger::Critical, |
225 | + "Could not connect to signal DownloadInterface::paused"); |
226 | + } |
227 | + |
228 | + connected = connect(_dbusInterface, &DownloadInterface::processing, |
229 | + this, &Download::processing); |
230 | + if (!connected) { |
231 | + Logger::log(Logger::Critical, |
232 | + "Could not connect to signal DownloadInterface::processing"); |
233 | + } |
234 | + |
235 | + connected = connect(_dbusInterface, static_cast<void(DownloadInterface::*) |
236 | (qulonglong, qulonglong)>(&DownloadInterface::progress), |
237 | this, static_cast<void(Download::*) |
238 | - (qulonglong, qulonglong)>(&Download::progress))) |
239 | - << "Could not connect to signal"; |
240 | - CHECK(connect(_dbusInterface, &DownloadInterface::resumed, |
241 | - this, &Download::resumed)) << "Could not connect to signal"; |
242 | - CHECK(connect(_dbusInterface, &DownloadInterface::started, |
243 | - this, &Download::started)) << "Could not connect to signal"; |
244 | + (qulonglong, qulonglong)>(&Download::progress)); |
245 | + if (!connected) { |
246 | + Logger::log(Logger::Critical, |
247 | + "Could not connect to signal &DownloadInterface::progress"); |
248 | + } |
249 | + |
250 | + connected = connect(_dbusInterface, &DownloadInterface::resumed, |
251 | + this, &Download::resumed); |
252 | + if (!connected) { |
253 | + Logger::log(Logger::Critical, |
254 | + "Could not connect to signal &DownloadInterface::resumed"); |
255 | + } |
256 | + |
257 | + connected = connect(_dbusInterface, &DownloadInterface::started, |
258 | + this, &Download::started); |
259 | + if (!connected) { |
260 | + Logger::log(Logger::Critical, |
261 | + "Could not connect to signal &DownloadInterface::started"); |
262 | + } |
263 | |
264 | // connect to the different type of errors that will later be converted to |
265 | // the error type to be used by the client. |
266 | - CHECK(connect(_dbusInterface, &DownloadInterface::httpError, |
267 | - this, &DownloadImpl::onHttpError)) << "Could not connect to signal"; |
268 | - CHECK(connect(_dbusInterface, &DownloadInterface::networkError, |
269 | - this, &DownloadImpl::onNetworkError)) << "Could not connect to signal"; |
270 | - CHECK(connect(_dbusInterface, &DownloadInterface::processError, |
271 | - this, &DownloadImpl::onProcessError)) << "Could not connect to signal"; |
272 | - CHECK(connect(_dbusInterface, &DownloadInterface::authError, |
273 | - this, &DownloadImpl::onAuthError)) << "Could not connect to signal"; |
274 | + connected = connect(_dbusInterface, &DownloadInterface::httpError, |
275 | + this, &DownloadImpl::onHttpError); |
276 | + if (!connected) { |
277 | + Logger::log(Logger::Critical, |
278 | + "Could not connect to signal &DownloadInterface::httpError"); |
279 | + } |
280 | + |
281 | + connected = connect(_dbusInterface, &DownloadInterface::networkError, |
282 | + this, &DownloadImpl::onNetworkError); |
283 | + if (!connected) { |
284 | + Logger::log(Logger::Critical, |
285 | + "Could not connect to signal &DownloadInterface::networkError"); |
286 | + } |
287 | + |
288 | + connected = connect(_dbusInterface, &DownloadInterface::processError, |
289 | + this, &DownloadImpl::onProcessError); |
290 | + if (!connected) { |
291 | + Logger::log(Logger::Critical, |
292 | + "Could not connect to signal &DownloadInterface::processError"); |
293 | + } |
294 | + |
295 | + connected = connect(_dbusInterface, &DownloadInterface::authError, |
296 | + this, &DownloadImpl::onAuthError); |
297 | + if (!connected) { |
298 | + Logger::log(Logger::Critical, |
299 | + "Could not connect to signal &DownloadInterface::authError"); |
300 | + } |
301 | } |
302 | |
303 | DownloadImpl::DownloadImpl(const QDBusConnection& conn, Error* err, QObject* parent) |
304 | @@ -79,6 +135,9 @@ |
305 | |
306 | void |
307 | DownloadImpl::setLastError(Error* err) { |
308 | + Logger::log(Logger::Debug, |
309 | + QString("Download{%1} setLastError(%2)").arg(_id).arg( |
310 | + err->errorString())); |
311 | if (_lastError != nullptr) { |
312 | delete _lastError; |
313 | } |
314 | @@ -94,6 +153,7 @@ |
315 | |
316 | void |
317 | DownloadImpl::start() { |
318 | + Logger::log(Logger::Debug, QString("Download{%1} start())").arg(_id)); |
319 | QDBusPendingCall call = |
320 | _dbusInterface->start(); |
321 | auto watcher = new DownloadPCW(_conn, _servicePath, |
322 | @@ -103,6 +163,7 @@ |
323 | |
324 | void |
325 | DownloadImpl::pause() { |
326 | + Logger::log(Logger::Debug, QString("Download{%1} pause())").arg(_id)); |
327 | QDBusPendingCall call = |
328 | _dbusInterface->pause(); |
329 | auto watcher = new DownloadPCW(_conn, _servicePath, |
330 | @@ -112,6 +173,7 @@ |
331 | |
332 | void |
333 | DownloadImpl::resume() { |
334 | + Logger::log(Logger::Debug, QString("Download{%1} resume())").arg(_id)); |
335 | QDBusPendingCall call = |
336 | _dbusInterface->resume(); |
337 | auto watcher = new DownloadPCW(_conn, _servicePath, |
338 | @@ -121,6 +183,7 @@ |
339 | |
340 | void |
341 | DownloadImpl::cancel() { |
342 | + Logger::log(Logger::Debug, QString("Download{%1} cancel())").arg(_id)); |
343 | QDBusPendingCall call = |
344 | _dbusInterface->cancel(); |
345 | auto watcher = new DownloadPCW(_conn, _servicePath, |
346 | @@ -130,22 +193,28 @@ |
347 | |
348 | void |
349 | DownloadImpl::allowMobileDownload(bool allowed) { |
350 | + Logger::log(Logger::Debug, |
351 | + QString("Download{%1} allowMobileDownload%2())").arg(_id).arg(allowed)); |
352 | QDBusPendingReply<> reply = |
353 | _dbusInterface->allowGSMDownload(allowed); |
354 | // block, the call should be fast enough |
355 | reply.waitForFinished(); |
356 | if (reply.isError()) { |
357 | + Logger::log(Logger::Error, "Error when setting mobile data usage"); |
358 | setLastError(reply.error()); |
359 | } |
360 | } |
361 | |
362 | bool |
363 | DownloadImpl::isMobileDownloadAllowed() { |
364 | + Logger::log(Logger::Debug, |
365 | + QString("Download{%1} isMobileDownloadAllowed").arg(_id)); |
366 | QDBusPendingReply<bool> reply = |
367 | _dbusInterface->isGSMDownloadAllowed(); |
368 | // block, the call should be fast enough |
369 | reply.waitForFinished(); |
370 | if (reply.isError()) { |
371 | + Logger::log(Logger::Error, "Error when querying mobile data usage"); |
372 | setLastError(reply.error()); |
373 | return false; |
374 | } else { |
375 | @@ -156,33 +225,42 @@ |
376 | |
377 | void |
378 | DownloadImpl::setDestinationDir(const QString& path) { |
379 | + Logger::log(Logger::Debug, QString("Dowmload{%1} setDestinationDir(%2)") |
380 | + .arg(_id).arg(path)); |
381 | QDBusPendingReply<> reply = |
382 | _dbusInterface->setDestinationDir(path); |
383 | // block, the call should be fast enough |
384 | reply.waitForFinished(); |
385 | if (reply.isError()) { |
386 | + Logger::log(Logger::Error, "Error setting the download directory"); |
387 | setLastError(reply.error()); |
388 | } |
389 | } |
390 | |
391 | void |
392 | DownloadImpl::setHeaders(QMap<QString, QString> headers) { |
393 | + Logger::log(Logger::Debug, |
394 | + QString("Download {%1} setHeaders(%2)").arg(_id), headers); |
395 | + |
396 | QDBusPendingReply<> reply = |
397 | _dbusInterface->setHeaders(headers); |
398 | // block, the call should be fast enough |
399 | reply.waitForFinished(); |
400 | if (reply.isError()) { |
401 | + Logger::log(Logger::Error, "Error setting the download headers"); |
402 | setLastError(reply.error()); |
403 | } |
404 | } |
405 | |
406 | QMap<QString, QString> |
407 | DownloadImpl::headers() { |
408 | + Logger::log(Logger::Debug, QString("Download{%1} headers()").arg(_id)); |
409 | QDBusPendingReply<QMap<QString, QString> > reply = |
410 | _dbusInterface->headers(); |
411 | // block, the call should be fast enough |
412 | reply.waitForFinished(); |
413 | if (reply.isError()) { |
414 | + Logger::log(Logger::Error, "Error querying the download headers"); |
415 | setLastError(reply.error()); |
416 | QMap<QString, QString> empty; |
417 | return empty; |
418 | @@ -195,22 +273,27 @@ |
419 | |
420 | void |
421 | DownloadImpl::setThrottle(qulonglong speed) { |
422 | + Logger::log(Logger::Debug, |
423 | + QString("Download{%1} setThrottle(%2)").arg(_id).arg(speed)); |
424 | QDBusPendingReply<> reply = |
425 | _dbusInterface->setThrottle(speed); |
426 | // block, the call should be fast enough |
427 | reply.waitForFinished(); |
428 | if (reply.isError()) { |
429 | + Logger::log(Logger::Error, "Error setting the download throttle"); |
430 | setLastError(reply.error()); |
431 | } |
432 | } |
433 | |
434 | qulonglong |
435 | DownloadImpl::throttle() { |
436 | + Logger::log(Logger::Debug, QString("Download{%1} throttle()").arg(_id)); |
437 | QDBusPendingReply<qulonglong> reply = |
438 | _dbusInterface->throttle(); |
439 | // block, the call is fast enough |
440 | reply.waitForFinished(); |
441 | if (reply.isError()) { |
442 | + Logger::log(Logger::Error, "Error querying the download throttle"); |
443 | setLastError(reply.error()); |
444 | return 0; |
445 | } else { |
446 | @@ -226,11 +309,13 @@ |
447 | |
448 | QVariantMap |
449 | DownloadImpl::metadata() { |
450 | + Logger::log(Logger::Debug, QString("Download{%1} metadata()").arg(_id)); |
451 | QDBusPendingReply<QVariantMap> reply = |
452 | _dbusInterface->metadata(); |
453 | // block the call is fast enough |
454 | reply.waitForFinished(); |
455 | if (reply.isError()) { |
456 | + Logger::log(Logger::Error, "Error querying the download metadata"); |
457 | QVariantMap emptyResult; |
458 | setLastError(reply.error()); |
459 | return emptyResult; |
460 | @@ -242,11 +327,13 @@ |
461 | |
462 | qulonglong |
463 | DownloadImpl::progress() { |
464 | + Logger::log(Logger::Debug, QString("Download{%1} progress()").arg(_id)); |
465 | QDBusPendingReply<qulonglong> reply = |
466 | _dbusInterface->progress(); |
467 | // block call should be fast enough |
468 | reply.waitForFinished(); |
469 | if (reply.isError()) { |
470 | + Logger::log(Logger::Error, "Error querying the download progress"); |
471 | setLastError(reply.error()); |
472 | return 0; |
473 | } else { |
474 | @@ -257,11 +344,13 @@ |
475 | |
476 | qulonglong |
477 | DownloadImpl::totalSize() { |
478 | + Logger::log(Logger::Debug, QString("Download{%1} totalSize()").arg(_id)); |
479 | QDBusPendingReply<qulonglong> reply = |
480 | _dbusInterface->totalSize(); |
481 | - // block call should b fast enough |
482 | + // block call should be fast enough |
483 | reply.waitForFinished(); |
484 | if (reply.isError()) { |
485 | + Logger::log(Logger::Error, "Error querying the download size"); |
486 | setLastError(reply.error()); |
487 | return 0; |
488 | } else { |
489 | |
490 | === modified file 'src/downloads/client/ubuntu/download_manager/download_impl.h' |
491 | --- src/downloads/client/ubuntu/download_manager/download_impl.h 2014-07-03 14:40:17 +0000 |
492 | +++ src/downloads/client/ubuntu/download_manager/download_impl.h 2014-07-03 14:40:18 +0000 |
493 | @@ -24,11 +24,14 @@ |
494 | #include <QObject> |
495 | #include <QVariantMap> |
496 | #include <QString> |
497 | + |
498 | #include <ubuntu/transfers/visibility.h> |
499 | #include <ubuntu/download_manager/metatypes.h> |
500 | -#include "download_interface.h" |
501 | -#include "download_pendingcall_watcher.h" |
502 | -#include "error.h" |
503 | + |
504 | +#include <ubuntu/download_manager/download_interface.h> |
505 | +#include <ubuntu/download_manager/download_pendingcall_watcher.h> |
506 | +#include <ubuntu/download_manager/error.h> |
507 | + |
508 | #include "download.h" |
509 | |
510 | class QDBusConnection; |
511 | |
512 | === modified file 'src/downloads/client/ubuntu/download_manager/download_pendingcall_watcher.cpp' |
513 | --- src/downloads/client/ubuntu/download_manager/download_pendingcall_watcher.cpp 2014-04-09 11:10:26 +0000 |
514 | +++ src/downloads/client/ubuntu/download_manager/download_pendingcall_watcher.cpp 2014-07-03 14:40:18 +0000 |
515 | @@ -16,25 +16,33 @@ |
516 | * Boston, MA 02110-1301, USA. |
517 | */ |
518 | |
519 | -#include <QDebug> |
520 | #include <QDBusPendingReply> |
521 | -#include <glog/logging.h> |
522 | -#include "error.h" |
523 | -#include "download_pendingcall_watcher.h" |
524 | + |
525 | +#include <boost/log/sources/record_ostream.hpp> |
526 | +#include <boost/log/sources/severity_feature.hpp> |
527 | + |
528 | +#include <ubuntu/download_manager/error.h> |
529 | +#include <ubuntu/download_manager/logging/logger.h> |
530 | + |
531 | +#include <ubuntu/download_manager/download_pendingcall_watcher.h> |
532 | |
533 | namespace Ubuntu { |
534 | |
535 | namespace DownloadManager { |
536 | |
537 | -DownloadPCW::DownloadPCW( |
538 | - const QDBusConnection& conn, |
539 | - const QString& servicePath, |
540 | - const QDBusPendingCall& call, |
541 | - Download* parent) |
542 | +using namespace Logging; |
543 | + |
544 | +DownloadPCW::DownloadPCW(const QDBusConnection& conn, |
545 | + const QString& servicePath, |
546 | + const QDBusPendingCall& call, |
547 | + Download* parent) |
548 | : PendingCallWatcher(conn, servicePath, call, parent) { |
549 | - CHECK(connect(this, &DownloadPCW::finished, |
550 | - this, &DownloadPCW::onFinished)) |
551 | - << "Could not connect to signal"; |
552 | + auto connected = connect(this, &DownloadPCW::finished, |
553 | + this, &DownloadPCW::onFinished); |
554 | + if (!connected) { |
555 | + Logger::log(Logger::Critical, |
556 | + "Could not connect to signal &DownloadPCW::finished"); |
557 | + } |
558 | } |
559 | |
560 | void |
561 | @@ -42,7 +50,9 @@ |
562 | auto down = qobject_cast<Download*>(parent()); |
563 | QDBusPendingReply<> reply = *watcher; |
564 | if (reply.isError()) { |
565 | - qDebug() << "ERROR" << reply.error() << reply.error().type(); |
566 | + auto dbusErr = reply.error(); |
567 | + Logger::log(Logger::Error, |
568 | + QString("%1 %2").arg(dbusErr.name()).arg(dbusErr.message())); |
569 | auto err = new DBusError(reply.error()); |
570 | down->error(err); |
571 | } |
572 | |
573 | === added directory 'src/downloads/client/ubuntu/download_manager/logging' |
574 | === added file 'src/downloads/client/ubuntu/download_manager/logging/logger.cpp' |
575 | --- src/downloads/client/ubuntu/download_manager/logging/logger.cpp 1970-01-01 00:00:00 +0000 |
576 | +++ src/downloads/client/ubuntu/download_manager/logging/logger.cpp 2014-07-03 14:40:18 +0000 |
577 | @@ -0,0 +1,213 @@ |
578 | +/* |
579 | + * Copyright 2014 Canonical Ltd. |
580 | + * |
581 | + * This library is free software; you can redistribute it and/or |
582 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
583 | + * License as published by the Free Software Foundation. |
584 | + * |
585 | + * This program is distributed in the hope that it will be useful, |
586 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
587 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
588 | + * General Public License for more details. |
589 | + * |
590 | + * You should have received a copy of the GNU Lesser General Public |
591 | + * License along with this library; if not, write to the |
592 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
593 | + * Boston, MA 02110-1301, USA. |
594 | + */ |
595 | + |
596 | +#include <boost/log/expressions/attr_fwd.hpp> |
597 | +#include <boost/log/expressions/attr.hpp> |
598 | +#include <boost/log/expressions/formatters/date_time.hpp> |
599 | +#include <boost/log/keywords/channel.hpp> |
600 | +#include <boost/log/sources/severity_channel_logger.hpp> |
601 | +#include <boost/log/sources/record_ostream.hpp> |
602 | +#include <boost/log/support/date_time.hpp> |
603 | +#include <boost/log/utility/setup/console.hpp> |
604 | +#include <boost/log/utility/setup/file.hpp> |
605 | +#include <boost/log/utility/setup/common_attributes.hpp> |
606 | + |
607 | +#include <ubuntu/download_manager/download_struct.h> |
608 | +#include <ubuntu/download_manager/logging/logger.h> |
609 | + |
610 | +typedef boost::log::sources::severity_channel_logger_mt< |
611 | + Ubuntu::DownloadManager::Logging::Logger::Level, |
612 | + std::string> logger_mt; |
613 | + |
614 | +namespace { |
615 | + const std::string DOWNLOAD_MANAGER_CHANNEL = "ubuntu_download_manager"; |
616 | + void my_formatter(boost::log::record_view const& rec, |
617 | + boost::log::formatting_ostream& strm) { |
618 | + using namespace Ubuntu::DownloadManager::Logging; |
619 | + // grab the attributes we are interested in |
620 | + strm << boost::log::extract<unsigned int>("LineID", rec) << " ["; |
621 | + strm << boost::log::extract<boost::posix_time::ptime>("TimeStamp", rec) << "] "; |
622 | + strm << boost::log::extract<std::string>("Channel", rec) << " ["; |
623 | + auto severity = boost::log::extract<Logger::Level>("Severity", rec).get(); |
624 | + switch(severity) { |
625 | + case Logger::Debug: |
626 | + strm << "Debug"; |
627 | + break; |
628 | + case Logger::Normal: |
629 | + strm << "Normal"; |
630 | + break; |
631 | + case Logger::Notification: |
632 | + strm << "Notification"; |
633 | + break; |
634 | + case Logger::Warning: |
635 | + strm << "Warning"; |
636 | + break; |
637 | + case Logger::Error: |
638 | + strm << "Error"; |
639 | + break; |
640 | + default: |
641 | + strm << "Critical"; |
642 | + break; |
643 | + } |
644 | + strm << "] "; |
645 | + // Finally, put the record message to the stream |
646 | + strm << rec[boost::log::expressions::smessage]; |
647 | + } |
648 | +} |
649 | + |
650 | +namespace Ubuntu { |
651 | + |
652 | +namespace DownloadManager { |
653 | + |
654 | +namespace Logging { |
655 | + |
656 | +class LoggerPrivate { |
657 | + public: |
658 | + LoggerPrivate() { } |
659 | + |
660 | + void init(Logger::Level lvl, const QString& path) { |
661 | + if (_lg == nullptr) { |
662 | + boost::log::add_common_attributes(); |
663 | + |
664 | + _lg = new logger_mt( |
665 | + boost::log::keywords::channel = DOWNLOAD_MANAGER_CHANNEL, |
666 | + boost::log::keywords::severity = lvl); |
667 | + // create a sink with the given file name and then add a filter |
668 | + // to ensure that just the download manager logs are written in it |
669 | + auto sink = boost::log::add_file_log( |
670 | + boost::log::keywords::file_name = path.toStdString(), |
671 | + boost::log::keywords::auto_flush = true |
672 | + ); |
673 | + |
674 | + sink->set_formatter(&my_formatter); |
675 | + |
676 | + sink->set_filter |
677 | + ( |
678 | + boost::log::expressions::attr<std::string>("Channel") == DOWNLOAD_MANAGER_CHANNEL |
679 | + ); |
680 | + |
681 | + } else { |
682 | + log(Logger::Critical, "Logger init called more than once."); |
683 | + } |
684 | + } |
685 | + |
686 | + void log(Logger::Level lvl, const QString& msg) { |
687 | + if (_lg != nullptr) { |
688 | + auto rec = _lg->open_record(boost::log::keywords::severity = lvl); |
689 | + if (rec) { |
690 | + boost::log::record_ostream strm(rec); |
691 | + strm << msg.toStdString(); |
692 | + strm.flush(); |
693 | + _lg->push_record(boost::move(rec)); |
694 | + } |
695 | + } |
696 | + } |
697 | + |
698 | + void log(Logger::Level lvl, const QStringList& msgList) { |
699 | + auto msg = msgList.join(" "); |
700 | + log(lvl, msg); |
701 | + } |
702 | + |
703 | + void log(Logger::Level lvl, const QString& msg, QMap<QString, QString> map) { |
704 | + auto fmtMsg = msg.arg(toString(map)); |
705 | + log(lvl, fmtMsg); |
706 | + } |
707 | + |
708 | + void log(Logger::Level lvl, const QString& msg, DownloadStruct downStruct) { |
709 | + QStringList list; |
710 | + |
711 | + list << "\n\t\tUrl: " << downStruct.getUrl() |
712 | + << "\n\t\tHash Algorithm: '" << downStruct.getAlgorithm() << "'" |
713 | + << "\n\t\tMetadata: " << toString(downStruct.getMetadata()) |
714 | + << "\n\t\tHeaders: " << toString(downStruct.getHeaders()); |
715 | + |
716 | + auto fmtMsg = msg.arg(list.join("")); |
717 | + log(lvl, fmtMsg); |
718 | + } |
719 | + |
720 | + private: |
721 | + QString toString(QMap<QString, QString> map) { |
722 | + QStringList list; |
723 | + list << "{"; |
724 | + int index = map.keys().count(); |
725 | + foreach(const QString& key, map.keys()) { |
726 | + list << "'" << key << "': '" << map[key] << "'"; |
727 | + if (index != 1) { |
728 | + list << ", "; |
729 | + } |
730 | + index--; |
731 | + } |
732 | + list << "}"; |
733 | + return list.join(""); |
734 | + } |
735 | + |
736 | + QString toString(QVariantMap map) { |
737 | + QStringList list; |
738 | + list << "{"; |
739 | + int index = map.keys().count(); |
740 | + foreach(const QString& key, map.keys()) { |
741 | + list << "'" << key << "': '" |
742 | + << map[key].toString() << "'"; |
743 | + if (index != 1) { |
744 | + list << ", "; |
745 | + } |
746 | + index--; |
747 | + } |
748 | + list << "}"; |
749 | + return list.join(""); |
750 | + } |
751 | + |
752 | + private: |
753 | + logger_mt* _lg = nullptr; |
754 | +}; |
755 | + |
756 | +LoggerPrivate* Logger::_private = new LoggerPrivate(); |
757 | +QMutex Logger::_mutex; |
758 | + |
759 | +void |
760 | +Logger::init(Logger::Level lvl, const QString& path) { |
761 | + _mutex.lock(); |
762 | + _private->init(lvl, path); |
763 | + _mutex.unlock(); |
764 | +} |
765 | + |
766 | +void |
767 | +Logger::log(Logger::Level lvl, const QString& msg) { |
768 | + _private->log(lvl, msg); |
769 | +} |
770 | + |
771 | +void |
772 | +Logger::log(Logger::Level lvl, const QStringList& msg) { |
773 | + _private->log(lvl, msg); |
774 | +} |
775 | + |
776 | +void |
777 | +Logger::log(Level lvl, const QString& msg, QMap<QString, QString> map) { |
778 | + _private->log(lvl, msg, map); |
779 | +} |
780 | + |
781 | +void |
782 | +Logger::log(Level lvl, const QString& msg, DownloadStruct downStruct) { |
783 | + _private->log(lvl, msg, downStruct); |
784 | +} |
785 | + |
786 | +} // logging |
787 | + |
788 | +} // Transfers |
789 | + |
790 | +} // Ubuntu |
791 | |
792 | === added file 'src/downloads/client/ubuntu/download_manager/logging/logger.h' |
793 | --- src/downloads/client/ubuntu/download_manager/logging/logger.h 1970-01-01 00:00:00 +0000 |
794 | +++ src/downloads/client/ubuntu/download_manager/logging/logger.h 2014-07-03 14:40:18 +0000 |
795 | @@ -0,0 +1,106 @@ |
796 | +/* |
797 | + * Copyright 2014 Canonical Ltd. |
798 | + * |
799 | + * This library is free software; you can redistribute it and/or |
800 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
801 | + * License as published by the Free Software Foundation. |
802 | + * |
803 | + * This program is distributed in the hope that it will be useful, |
804 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
805 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
806 | + * General Public License for more details. |
807 | + * |
808 | + * You should have received a copy of the GNU Lesser General Public |
809 | + * License along with this library; if not, write to the |
810 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
811 | + * Boston, MA 02110-1301, USA. |
812 | + */ |
813 | + |
814 | +#ifndef UBUNTU_DOWNLOADMANAGER_CLIENT_LOGGER_H |
815 | +#define UBUNTU_DOWNLOADMANAGER_CLIENT_LOGGER_H |
816 | + |
817 | +#include <QMap> |
818 | +#include <QMutex> |
819 | +#include <QString> |
820 | +#include <QStringList> |
821 | +#include <QVariant> |
822 | + |
823 | + |
824 | +namespace Ubuntu { |
825 | + |
826 | +namespace DownloadManager { |
827 | + |
828 | +class DownloadImpl; |
829 | +class DownloadPCW; |
830 | +class ManagerImpl; |
831 | +class DownloadManagerPCW; |
832 | +class DownloadsListManagerPCW; |
833 | +class GroupManagerPCW; |
834 | +class MetadataDownloadsListManagerPCW; |
835 | +class DownloadStruct; |
836 | + |
837 | +namespace Logging { |
838 | + |
839 | +class LoggerPrivate; |
840 | + |
841 | +/*! |
842 | + \class Logger |
843 | + \brief The Logger class allows to control a logging that |
844 | + is performed within the library allowed the developer |
845 | + to set the log level as well as the path of the file |
846 | + where the logs are written. |
847 | + \since 0.5 |
848 | + |
849 | +*/ |
850 | +class Logger { |
851 | + friend class Ubuntu::DownloadManager::DownloadImpl; |
852 | + friend class Ubuntu::DownloadManager::DownloadPCW; |
853 | + friend class Ubuntu::DownloadManager::ManagerImpl; |
854 | + friend class Ubuntu::DownloadManager::DownloadManagerPCW; |
855 | + friend class Ubuntu::DownloadManager::DownloadsListManagerPCW; |
856 | + friend class Ubuntu::DownloadManager::GroupManagerPCW; |
857 | + friend class Ubuntu::DownloadManager::MetadataDownloadsListManagerPCW; |
858 | + |
859 | + public: |
860 | + /*! The different log levels supported by the default logger of the lib. */ |
861 | + enum Level |
862 | + { |
863 | + Debug, |
864 | + Normal, |
865 | + Notification, |
866 | + Warning, |
867 | + Error, |
868 | + Critical |
869 | + }; |
870 | + |
871 | + /*! |
872 | + \fn static void Logger::init(Level lvl, const QString& path) |
873 | + |
874 | + Initializes the logging service for the download library using |
875 | + the given \a level and writing the logs to the given \a path. |
876 | + */ |
877 | + static void init(Level lvl, const QString& path); |
878 | + |
879 | + protected: |
880 | + |
881 | + /*! \cond PRIVATE |
882 | + */ |
883 | + static void log(Level lvl, const QString& msg); |
884 | + static void log(Level lvl, const QStringList& msg); |
885 | + static void log(Level lvl, const QString& msg, QMap<QString, QString> map); |
886 | + static void log(Level lvl, const QString& msg, DownloadStruct downStruct); |
887 | + /*! \endcond |
888 | + */ |
889 | + |
890 | + private: |
891 | + static QMutex _mutex; |
892 | + static LoggerPrivate* _private; |
893 | +}; |
894 | + |
895 | +} // Logging |
896 | + |
897 | +} // DownloadManager |
898 | + |
899 | +} // Ubuntu |
900 | + |
901 | +#endif |
902 | |
903 | === modified file 'src/downloads/client/ubuntu/download_manager/manager.cpp' |
904 | --- src/downloads/client/ubuntu/download_manager/manager.cpp 2014-02-12 12:01:11 +0000 |
905 | +++ src/downloads/client/ubuntu/download_manager/manager.cpp 2014-07-03 14:40:18 +0000 |
906 | @@ -16,9 +16,8 @@ |
907 | * Boston, MA 02110-1301, USA. |
908 | */ |
909 | |
910 | -#include <QDebug> |
911 | -#include "manager_impl.h" |
912 | -#include "manager.h" |
913 | +#include <ubuntu/download_manager/manager_impl.h> |
914 | +#include <ubuntu/download_manager/manager.h> |
915 | |
916 | namespace { |
917 | const QString DOWNLOAD_SERVICE = "com.canonical.applications.Downloader"; |
918 | |
919 | === modified file 'src/downloads/client/ubuntu/download_manager/manager_impl.cpp' |
920 | --- src/downloads/client/ubuntu/download_manager/manager_impl.cpp 2014-04-09 11:10:26 +0000 |
921 | +++ src/downloads/client/ubuntu/download_manager/manager_impl.cpp 2014-07-03 14:40:18 +0000 |
922 | @@ -16,12 +16,13 @@ |
923 | * Boston, MA 02110-1301, USA. |
924 | */ |
925 | |
926 | -#include <QDebug> |
927 | -#include <glog/logging.h> |
928 | -#include "download_impl.h" |
929 | -#include "downloads_list.h" |
930 | +#include <ubuntu/download_manager/download_impl.h> |
931 | +#include <ubuntu/download_manager/downloads_list.h> |
932 | +#include <ubuntu/download_manager/logging/logger.h> |
933 | + |
934 | #include "manager_impl.h" |
935 | |
936 | + |
937 | namespace { |
938 | const QString MANAGER_PATH = "/"; |
939 | } |
940 | @@ -30,6 +31,8 @@ |
941 | |
942 | namespace DownloadManager { |
943 | |
944 | +using namespace Logging; |
945 | + |
946 | ManagerImpl::ManagerImpl(const QDBusConnection& conn, |
947 | const QString& path, |
948 | QObject* parent) |
949 | @@ -80,12 +83,14 @@ |
950 | |
951 | Download* |
952 | ManagerImpl::getDownloadForId(const QString& id) { |
953 | + Logger::log(Logger::Debug, QString("Manager getDownloadForId(%1)").arg(id)); |
954 | auto down = new DownloadImpl(_conn, _servicePath, QDBusObjectPath(id)); |
955 | return down; |
956 | } |
957 | |
958 | void |
959 | ManagerImpl::createDownload(DownloadStruct downStruct) { |
960 | + Logger::log(Logger::Debug, "Manager createDownload(%1)", downStruct); |
961 | DownloadCb cb = [](Download*) {}; |
962 | createDownload(downStruct, cb, cb); |
963 | } |
964 | @@ -98,8 +103,12 @@ |
965 | _dbusInterface->createDownload(downStruct); |
966 | auto watcher = new DownloadManagerPCW(_conn, |
967 | _servicePath, call, cb, errCb, this); |
968 | - CHECK(connect(watcher, &DownloadManagerPCW::callbackExecuted, |
969 | - this, &ManagerImpl::onWatcherDone)) << "Could not connect to signal"; |
970 | + auto connected = connect(watcher, &DownloadManagerPCW::callbackExecuted, |
971 | + this, &ManagerImpl::onWatcherDone); |
972 | + if (!connected) { |
973 | + Logger::log(Logger::Critical, |
974 | + "Could not connect to signal &DownloadManagerPCW::callbackExecuted,"); |
975 | + } |
976 | } |
977 | |
978 | void |
979 | @@ -125,28 +134,40 @@ |
980 | algorithm, allowed3G, metadata, headers); |
981 | auto watcher = new GroupManagerPCW(_conn, _servicePath, |
982 | call, cb, errCb, this); |
983 | - CHECK(connect(watcher, &GroupManagerPCW::callbackExecuted, |
984 | - this, &ManagerImpl::onWatcherDone)) << "Could not connect to signal"; |
985 | + auto connected = connect(watcher, &GroupManagerPCW::callbackExecuted, |
986 | + this, &ManagerImpl::onWatcherDone); |
987 | + if (!connected) { |
988 | + Logger::log(Logger::Critical, |
989 | + "Could not connect to signal &GroupManagerPCW::callbackExecuted"); |
990 | + } |
991 | } |
992 | |
993 | void |
994 | ManagerImpl::getAllDownloads() { |
995 | + Logger::log(Logger::Debug, "Manager getAllDownloads()"); |
996 | DownloadsListCb cb = [](DownloadsList*){}; |
997 | getAllDownloads(cb, cb); |
998 | } |
999 | |
1000 | void |
1001 | ManagerImpl::getAllDownloads(DownloadsListCb cb, DownloadsListCb errCb) { |
1002 | + Logger::log(Logger::Debug, "Manager getAllDownloads()"); |
1003 | QDBusPendingCall call = _dbusInterface->getAllDownloads(); |
1004 | auto watcher = new DownloadsListManagerPCW( |
1005 | _conn, _servicePath, call, cb, errCb, this); |
1006 | - CHECK(connect(watcher, &GroupManagerPCW::callbackExecuted, |
1007 | - this, &ManagerImpl::onWatcherDone)) << "Could not connect to signal"; |
1008 | + auto connected = connect(watcher, &GroupManagerPCW::callbackExecuted, |
1009 | + this, &ManagerImpl::onWatcherDone); |
1010 | + if (!connected) { |
1011 | + Logger::log(Logger::Critical, |
1012 | + "Could not connect to signal"); |
1013 | + } |
1014 | } |
1015 | |
1016 | void |
1017 | ManagerImpl::getAllDownloadsWithMetadata(const QString &name, |
1018 | const QString &value) { |
1019 | + Logger::log(Logger::Debug, |
1020 | + QString("Manager getAllDownloadsWithMetadata(%1, %2)").arg(name).arg(value)); |
1021 | MetadataDownloadsListCb cb = |
1022 | [](const QString&, const QString&, DownloadsList*){}; |
1023 | getAllDownloadsWithMetadata(name, value, cb, cb); |
1024 | @@ -157,12 +178,17 @@ |
1025 | const QString &value, |
1026 | MetadataDownloadsListCb cb, |
1027 | MetadataDownloadsListCb errCb) { |
1028 | + Logger::log(Logger::Debug, |
1029 | + QString("Manager getAllDownloadsWithMetadata(%1, %2)").arg(name).arg(value)); |
1030 | QDBusPendingCall call = _dbusInterface->getAllDownloadsWithMetadata( |
1031 | name, value); |
1032 | auto watcher = new MetadataDownloadsListManagerPCW( |
1033 | _conn, _servicePath, call, name, value, cb, errCb, this); |
1034 | - CHECK(connect(watcher, &GroupManagerPCW::callbackExecuted, |
1035 | - this, &ManagerImpl::onWatcherDone)) << "Could not connect to signal"; |
1036 | + auto connected = connect(watcher, &GroupManagerPCW::callbackExecuted, |
1037 | + this, &ManagerImpl::onWatcherDone); |
1038 | + if (!connected) { |
1039 | + Logger::log(Logger::Critical, "Could not connect to signal"); |
1040 | + } |
1041 | } |
1042 | |
1043 | bool |
1044 | @@ -187,27 +213,29 @@ |
1045 | |
1046 | void |
1047 | ManagerImpl::allowMobileDataDownload(bool allowed) { |
1048 | + Logger::log(Logger::Debug, |
1049 | + QString("Manager allowMobileDataDownload(%1)").arg(allowed)); |
1050 | QDBusPendingReply<> reply = |
1051 | _dbusInterface->allowGSMDownload(allowed); |
1052 | // we block but because we expect it to be fast |
1053 | reply.waitForFinished(); |
1054 | if (reply.isError()) { |
1055 | auto err = reply.error(); |
1056 | - qCritical() << "Error setting mobile data" << err; |
1057 | + Logger::log(Logger::Critical, "Error setting mobile data"); |
1058 | setLastError(err); |
1059 | } |
1060 | } |
1061 | |
1062 | bool |
1063 | ManagerImpl::isMobileDataDownload() { |
1064 | + Logger::log(Logger::Debug, "Manager isMobileDataDownload()"); |
1065 | QDBusPendingReply<bool> reply = |
1066 | _dbusInterface->isGSMDownloadAllowed(); |
1067 | // we block but because we expect it to be fast |
1068 | reply.waitForFinished(); |
1069 | if (reply.isError()) { |
1070 | auto err = reply.error(); |
1071 | - qCritical() << "Error getting if mobile data is enabled" |
1072 | - << err; |
1073 | + Logger::log(Logger::Error, "Error getting if mobile data is enabled"); |
1074 | setLastError(err); |
1075 | return false; |
1076 | } else { |
1077 | @@ -217,13 +245,14 @@ |
1078 | |
1079 | qulonglong |
1080 | ManagerImpl::defaultThrottle() { |
1081 | + Logger::log(Logger::Debug, "Manager defaultThrottle()"); |
1082 | QDBusPendingReply<qulonglong> reply = |
1083 | _dbusInterface->defaultThrottle(); |
1084 | // we block but because we expect it to be fast |
1085 | reply.waitForFinished(); |
1086 | if (reply.isError()) { |
1087 | auto err = reply.error(); |
1088 | - qCritical() << "Error getting the default throttle" << err; |
1089 | + Logger::log(Logger::Error, "Error getting the default throttle"); |
1090 | setLastError(err); |
1091 | return 0; |
1092 | } else { |
1093 | @@ -233,26 +262,29 @@ |
1094 | |
1095 | void |
1096 | ManagerImpl::setDefaultThrottle(qulonglong speed) { |
1097 | + Logger::log(Logger::Debug, |
1098 | + QString("Manager setDefaultThrottle(%1)").arg(speed)); |
1099 | QDBusPendingReply<> reply = |
1100 | _dbusInterface->setDefaultThrottle(speed); |
1101 | // we block but because we expect it to be fast |
1102 | reply.waitForFinished(); |
1103 | if (reply.isError()) { |
1104 | auto err = reply.error(); |
1105 | - qCritical() << "Error setting default throttle" << err; |
1106 | + Logger::log(Logger::Error, "Error setting default throttle"); |
1107 | setLastError(err); |
1108 | } |
1109 | } |
1110 | |
1111 | void |
1112 | ManagerImpl::exit() { |
1113 | + Logger::log(Logger::Debug, "Manager exit()"); |
1114 | QDBusPendingReply<> reply = |
1115 | _dbusInterface->exit(); |
1116 | // we block but because we expect it to be fast |
1117 | reply.waitForFinished(); |
1118 | if (reply.isError()) { |
1119 | auto err = reply.error(); |
1120 | - qCritical() << "Error setting killing the daemon" << err; |
1121 | + Logger::log(Logger::Error, "Error setting killing the daemon"); |
1122 | setLastError(err); |
1123 | } |
1124 | } |
1125 | |
1126 | === modified file 'src/downloads/client/ubuntu/download_manager/manager_impl.h' |
1127 | --- src/downloads/client/ubuntu/download_manager/manager_impl.h 2014-06-06 10:05:15 +0000 |
1128 | +++ src/downloads/client/ubuntu/download_manager/manager_impl.h 2014-07-03 14:40:18 +0000 |
1129 | @@ -21,13 +21,16 @@ |
1130 | |
1131 | #include <QDBusConnection> |
1132 | #include <QDBusObjectPath> |
1133 | + |
1134 | #include <ubuntu/transfers/visibility.h> |
1135 | #include <ubuntu/transfers/system/dbus_connection.h> |
1136 | -#include "download.h" |
1137 | -#include "error.h" |
1138 | -#include "group_download.h" |
1139 | -#include "manager_interface.h" |
1140 | -#include "manager_pendingcall_watcher.h" |
1141 | + |
1142 | +#include <ubuntu/download_manager/download.h> |
1143 | +#include <ubuntu/download_manager/error.h> |
1144 | +#include <ubuntu/download_manager/group_download.h> |
1145 | +#include <ubuntu/download_manager/manager_interface.h> |
1146 | +#include <ubuntu/download_manager/manager_pendingcall_watcher.h> |
1147 | + |
1148 | #include "manager.h" |
1149 | |
1150 | |
1151 | @@ -108,7 +111,6 @@ |
1152 | QString _servicePath; |
1153 | Error* _lastError = nullptr; |
1154 | ManagerInterface* _dbusInterface = nullptr; |
1155 | - |
1156 | }; |
1157 | |
1158 | } // DownloadManager |
1159 | |
1160 | === modified file 'src/downloads/client/ubuntu/download_manager/manager_pendingcall_watcher.cpp' |
1161 | --- src/downloads/client/ubuntu/download_manager/manager_pendingcall_watcher.cpp 2014-04-09 11:10:26 +0000 |
1162 | +++ src/downloads/client/ubuntu/download_manager/manager_pendingcall_watcher.cpp 2014-07-03 14:40:18 +0000 |
1163 | @@ -16,21 +16,27 @@ |
1164 | * Boston, MA 02110-1301, USA. |
1165 | */ |
1166 | |
1167 | -#include <QDebug> |
1168 | #include <QDBusPendingReply> |
1169 | #include <QDBusObjectPath> |
1170 | -#include <glog/logging.h> |
1171 | -#include "download_impl.h" |
1172 | -#include "downloads_list_impl.h" |
1173 | -#include "error.h" |
1174 | -#include "group_download.h" |
1175 | -#include "manager.h" |
1176 | -#include "manager_pendingcall_watcher.h" |
1177 | + |
1178 | +#include <boost/log/sources/record_ostream.hpp> |
1179 | +#include <boost/log/sources/severity_feature.hpp> |
1180 | + |
1181 | +#include <ubuntu/download_manager/download_impl.h> |
1182 | +#include <ubuntu/download_manager/downloads_list_impl.h> |
1183 | +#include <ubuntu/download_manager/error.h> |
1184 | +#include <ubuntu/download_manager/group_download.h> |
1185 | +#include <ubuntu/download_manager/manager.h> |
1186 | +#include <ubuntu/download_manager/logging/logger.h> |
1187 | + |
1188 | +#include <ubuntu/download_manager/manager_pendingcall_watcher.h> |
1189 | |
1190 | namespace Ubuntu { |
1191 | |
1192 | namespace DownloadManager { |
1193 | |
1194 | +using namespace Logging; |
1195 | + |
1196 | DownloadManagerPCW::DownloadManagerPCW(const QDBusConnection& conn, |
1197 | const QString& servicePath, |
1198 | const QDBusPendingCall& call, |
1199 | @@ -40,9 +46,12 @@ |
1200 | : PendingCallWatcher(conn, servicePath, call, parent), |
1201 | _cb(cb), |
1202 | _errCb(errCb) { |
1203 | - CHECK(connect(this, &QDBusPendingCallWatcher::finished, |
1204 | - this, &DownloadManagerPCW::onFinished)) |
1205 | - << "Could not connect to signal"; |
1206 | + auto connected = connect(this, &QDBusPendingCallWatcher::finished, |
1207 | + this, &DownloadManagerPCW::onFinished); |
1208 | + if (!connected) { |
1209 | + Logger::log(Logger::Critical, |
1210 | + "Could not connect to signal &QDBusPendingCallWatcher::finished"); |
1211 | + } |
1212 | } |
1213 | |
1214 | void |
1215 | @@ -50,14 +59,14 @@ |
1216 | QDBusPendingReply<QDBusObjectPath> reply = *watcher; |
1217 | auto man = static_cast<Manager*>(parent()); |
1218 | if (reply.isError()) { |
1219 | - qDebug() << "ERROR" << reply.error() << reply.error().type(); |
1220 | - // create error and deal with it |
1221 | + auto dbusErr = reply.error(); |
1222 | + Logger::log(Logger::Error, |
1223 | + QString("%1 %2").arg(dbusErr.name()).arg(dbusErr.message())); |
1224 | auto err = new DBusError(reply.error()); |
1225 | auto down = new DownloadImpl(_conn, err); |
1226 | _errCb(down); |
1227 | emit man->downloadCreated(down); |
1228 | } else { |
1229 | - qDebug() << "Success!"; |
1230 | auto path = reply.value(); |
1231 | auto down = new DownloadImpl(_conn, _servicePath, path); |
1232 | emit man->downloadCreated(down); |
1233 | @@ -76,8 +85,12 @@ |
1234 | : PendingCallWatcher(conn, servicePath, call, parent), |
1235 | _cb(cb), |
1236 | _errCb(errCb) { |
1237 | - connect(this, &QDBusPendingCallWatcher::finished, |
1238 | + auto connected = connect(this, &QDBusPendingCallWatcher::finished, |
1239 | this, &DownloadsListManagerPCW::onFinished); |
1240 | + if (!connected) { |
1241 | + Logger::log(Logger::Critical, |
1242 | + "Could not connect to signal &QDBusPendingCallWatcher::finished"); |
1243 | + } |
1244 | } |
1245 | |
1246 | void |
1247 | @@ -86,14 +99,14 @@ |
1248 | DownloadsListImpl* list; |
1249 | auto man = static_cast<Manager*>(parent()); |
1250 | if (reply.isError()) { |
1251 | - qDebug() << "ERROR" << reply.error() << reply.error().type(); |
1252 | - // create error and deal with it |
1253 | + auto dbusErr = reply.error(); |
1254 | + Logger::log(Logger::Error, |
1255 | + QString("%1 %2").arg(dbusErr.name()).arg(dbusErr.message())); |
1256 | auto err = new DBusError(reply.error()); |
1257 | list = new DownloadsListImpl(err); |
1258 | _errCb(list); |
1259 | emit man->downloadsFound(list); |
1260 | } else { |
1261 | - qDebug() << "Success!"; |
1262 | auto paths = reply.value(); |
1263 | QList<QSharedPointer<Download> > downloads; |
1264 | list = new DownloadsListImpl(); |
1265 | @@ -125,8 +138,12 @@ |
1266 | _value(value), |
1267 | _cb(cb), |
1268 | _errCb(errCb) { |
1269 | - connect(this, &QDBusPendingCallWatcher::finished, |
1270 | + auto connected = connect(this, &QDBusPendingCallWatcher::finished, |
1271 | this, &MetadataDownloadsListManagerPCW::onFinished); |
1272 | + if (!connected) { |
1273 | + Logger::log(Logger::Critical, |
1274 | + "Could not connect to signal &QDBusPendingCallWatcher::finished"); |
1275 | + } |
1276 | } |
1277 | |
1278 | void |
1279 | @@ -135,14 +152,14 @@ |
1280 | DownloadsListImpl* list; |
1281 | auto man = static_cast<Manager*>(parent()); |
1282 | if (reply.isError()) { |
1283 | - qDebug() << "ERROR" << reply.error() << reply.error().type(); |
1284 | - // create error and deal with it |
1285 | + auto dbusErr = reply.error(); |
1286 | + Logger::log(Logger::Error, |
1287 | + QString("%1 %2").arg(dbusErr.name()).arg(dbusErr.message())); |
1288 | auto err = new DBusError(reply.error()); |
1289 | list = new DownloadsListImpl(err); |
1290 | _errCb(_key, _value, list); |
1291 | emit man->downloadsWithMetadataFound(_key, _value, list); |
1292 | } else { |
1293 | - qDebug() << "Success!"; |
1294 | auto paths = reply.value(); |
1295 | QList<QSharedPointer<Download> > downloads; |
1296 | list = new DownloadsListImpl(); |
1297 | @@ -169,9 +186,12 @@ |
1298 | : PendingCallWatcher(conn, servicePath, call, parent), |
1299 | _cb(cb), |
1300 | _errCb(errCb) { |
1301 | - CHECK(connect(this, &QDBusPendingCallWatcher::finished, |
1302 | - this, &GroupManagerPCW::onFinished)) |
1303 | - << "Could not connect to signal"; |
1304 | + auto connected = connect(this, &QDBusPendingCallWatcher::finished, |
1305 | + this, &GroupManagerPCW::onFinished); |
1306 | + if (!connected) { |
1307 | + Logger::log(Logger::Critical, |
1308 | + "Could not connect to signal &DownloadPCW::finished"); |
1309 | + } |
1310 | } |
1311 | |
1312 | void |
1313 | @@ -179,7 +199,9 @@ |
1314 | QDBusPendingReply<QDBusObjectPath> reply = *watcher; |
1315 | auto man = static_cast<Manager*>(parent()); |
1316 | if (reply.isError()) { |
1317 | - // creater error and deal with it |
1318 | + auto dbusErr = reply.error(); |
1319 | + Logger::log(Logger::Error, |
1320 | + QString("%1 %2").arg(dbusErr.name()).arg(dbusErr.message())); |
1321 | auto err = new DBusError(reply.error()); |
1322 | auto down = new GroupDownload(err); |
1323 | _errCb(down); |
1324 | |
1325 | === modified file 'src/downloads/qml/CMakeLists.txt' |
1326 | --- src/downloads/qml/CMakeLists.txt 2014-05-07 12:27:08 +0000 |
1327 | +++ src/downloads/qml/CMakeLists.txt 2014-07-03 14:40:18 +0000 |
1328 | @@ -3,16 +3,16 @@ |
1329 | |
1330 | set(plugin_SRCS |
1331 | backend.cpp |
1332 | - ubuntu_download_manager.cpp |
1333 | download_error.cpp |
1334 | single_download.cpp |
1335 | + ubuntu_download_manager.cpp |
1336 | ) |
1337 | |
1338 | set(plugin_HDRS |
1339 | backend.h |
1340 | - ubuntu_download_manager.h |
1341 | download_error.h |
1342 | single_download.h |
1343 | + ubuntu_download_manager.h |
1344 | ) |
1345 | |
1346 | include_directories(${CMAKE_SOURCE_DIR}/src/common/public) |
1347 | |
1348 | === modified file 'src/downloads/qml/backend.h' |
1349 | --- src/downloads/qml/backend.h 2014-03-28 16:11:54 +0000 |
1350 | +++ src/downloads/qml/backend.h 2014-07-03 14:40:18 +0000 |
1351 | @@ -1,3 +1,21 @@ |
1352 | +/* |
1353 | + * Copyright 2014 Canonical Ltd. |
1354 | + * |
1355 | + * This library is free software; you can redistribute it and/or |
1356 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
1357 | + * License as published by the Free Software Foundation. |
1358 | + * |
1359 | + * This program is distributed in the hope that it will be useful, |
1360 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1361 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1362 | + * General Public License for more details. |
1363 | + * |
1364 | + * You should have received a copy of the GNU Lesser General Public |
1365 | + * License along with this library; if not, write to the |
1366 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
1367 | + * Boston, MA 02110-1301, USA. |
1368 | + */ |
1369 | + |
1370 | #ifndef BACKEND_PLUGIN_H |
1371 | #define BACKEND_PLUGIN_H |
1372 | |
1373 | |
1374 | === modified file 'src/downloads/qml/download_error.h' |
1375 | --- src/downloads/qml/download_error.h 2014-03-28 16:11:54 +0000 |
1376 | +++ src/downloads/qml/download_error.h 2014-07-03 14:40:18 +0000 |
1377 | @@ -1,3 +1,21 @@ |
1378 | +/* |
1379 | + * Copyright 2014 Canonical Ltd. |
1380 | + * |
1381 | + * This library is free software; you can redistribute it and/or |
1382 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
1383 | + * License as published by the Free Software Foundation. |
1384 | + * |
1385 | + * This program is distributed in the hope that it will be useful, |
1386 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1387 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1388 | + * General Public License for more details. |
1389 | + * |
1390 | + * You should have received a copy of the GNU Lesser General Public |
1391 | + * License along with this library; if not, write to the |
1392 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
1393 | + * Boston, MA 02110-1301, USA. |
1394 | + */ |
1395 | + |
1396 | #ifndef DOWNLOAD_ERROR_H |
1397 | #define DOWNLOAD_ERROR_H |
1398 | |
1399 | |
1400 | === modified file 'src/downloads/qml/single_download.cpp' |
1401 | --- src/downloads/qml/single_download.cpp 2014-05-07 12:27:08 +0000 |
1402 | +++ src/downloads/qml/single_download.cpp 2014-07-03 14:40:18 +0000 |
1403 | @@ -1,7 +1,6 @@ |
1404 | #include "single_download.h" |
1405 | #include <glog/logging.h> |
1406 | #include <ubuntu/download_manager/download_struct.h> |
1407 | -#include <QDebug> |
1408 | |
1409 | namespace Ubuntu { |
1410 | |
1411 | @@ -83,7 +82,8 @@ |
1412 | { |
1413 | } |
1414 | |
1415 | -void SingleDownload::bindDownload(Download* download) |
1416 | +void |
1417 | +SingleDownload::bindDownload(Download* download) |
1418 | { |
1419 | m_download = download; |
1420 | |
1421 | @@ -91,53 +91,88 @@ |
1422 | static_cast<void(Download::*)(Error*)>(&Download::error), |
1423 | this, &SingleDownload::registerError)) |
1424 | << "Could not connect to signal"; |
1425 | - CHECK(connect(m_download, &Download::finished, this, |
1426 | - &SingleDownload::finished)) << "Could not connect to signal"; |
1427 | - CHECK(connect(m_download, &Download::finished, this, |
1428 | - &SingleDownload::setCompleted)) << "Could not connect to signal"; |
1429 | - CHECK(connect(m_download, |
1430 | - static_cast<void(Download::*)(qulonglong, qulonglong)>( |
1431 | - &Download::progress), this, |
1432 | - &SingleDownload::progressReceived)) |
1433 | - << "Could not connect to signal"; |
1434 | - CHECK(connect(m_download, |
1435 | - static_cast<void(Download::*)(qulonglong, qulonglong)>( |
1436 | - &Download::progress), this, |
1437 | - &SingleDownload::setProgress)) << "Could not connect to signal"; |
1438 | - CHECK(connect(m_download, &Download::canceled, this, |
1439 | - &SingleDownload::canceled)) << "Could not connect to signal"; |
1440 | - CHECK(connect(m_download, &Download::canceled, this, |
1441 | - &SingleDownload::setDownloadCanceled)) |
1442 | - << "Could not connect to signal"; |
1443 | - CHECK(connect(m_download, &Download::paused, this, |
1444 | - &SingleDownload::paused)) << "Could not connect to signal"; |
1445 | - CHECK(connect(m_download, &Download::paused, this, |
1446 | - &SingleDownload::setDownloadPaused)) |
1447 | - << "Could not connect to signal"; |
1448 | - CHECK(connect(m_download, &Download::resumed, this, |
1449 | - &SingleDownload::resumed)) << "Could not connect to signal"; |
1450 | - CHECK(connect(m_download, &Download::resumed, this, |
1451 | - &SingleDownload::setDownloadStarted)) |
1452 | - << "Could not connect to signal"; |
1453 | - CHECK(connect(m_download, &Download::started, this, |
1454 | - &SingleDownload::started)) << "Could not connect to signal"; |
1455 | - CHECK(connect(m_download, &Download::started, this, |
1456 | - &SingleDownload::setDownloadStarted)) |
1457 | + |
1458 | + CHECK(connect(m_download, &Download::finished, this, |
1459 | + &SingleDownload::onFinished)) << "Could not connect to signal"; |
1460 | + |
1461 | + CHECK(connect(m_download, |
1462 | + static_cast<void(Download::*)(qulonglong, qulonglong)>( |
1463 | + &Download::progress), this, |
1464 | + &SingleDownload::onProgress)) << "Could not connect to signal"; |
1465 | + |
1466 | + CHECK(connect(m_download, &Download::canceled, this, |
1467 | + &SingleDownload::onCanceled)) |
1468 | + << "Could not connect to signal"; |
1469 | + |
1470 | + CHECK(connect(m_download, &Download::paused, this, |
1471 | + &SingleDownload::onPaused)) |
1472 | + << "Could not connect to signal"; |
1473 | + |
1474 | + CHECK(connect(m_download, &Download::resumed, this, |
1475 | + &SingleDownload::onResumed)) |
1476 | + << "Could not connect to signal"; |
1477 | + |
1478 | + CHECK(connect(m_download, &Download::started, this, |
1479 | + &SingleDownload::onStarted)) |
1480 | << "Could not connect to signal"; |
1481 | |
1482 | emit downloadIdChanged(); |
1483 | |
1484 | + // is the current in memory setting dirty, if they are, we do set the before we |
1485 | + // start |
1486 | + if (m_dirty) { |
1487 | + setAllowMobileDownload(m_mobile); |
1488 | + setThrottle(m_throttle); |
1489 | + setHeaders(m_headers); |
1490 | + |
1491 | + // is not really needed but we do it to be consistent |
1492 | + m_dirty = false; |
1493 | + } |
1494 | + |
1495 | if (m_manager != nullptr && m_autoStart) { |
1496 | startDownload(); |
1497 | } |
1498 | } |
1499 | |
1500 | +void |
1501 | +SingleDownload::unbindDownload(Download* download) { |
1502 | + CHECK(disconnect(download, |
1503 | + static_cast<void(Download::*)(Error*)>(&Download::error), |
1504 | + this, &SingleDownload::registerError)) |
1505 | + << "Could not connect to signal"; |
1506 | + |
1507 | + CHECK(disconnect(download, &Download::finished, this, |
1508 | + &SingleDownload::onFinished)) << "Could not connect to signal"; |
1509 | + |
1510 | + CHECK(disconnect(download, |
1511 | + static_cast<void(Download::*)(qulonglong, qulonglong)>( |
1512 | + &Download::progress), this, |
1513 | + &SingleDownload::onProgress)) << "Could not connect to signal"; |
1514 | + |
1515 | + CHECK(disconnect(download, &Download::canceled, this, |
1516 | + &SingleDownload::onCanceled)) |
1517 | + << "Could not connect to signal"; |
1518 | + |
1519 | + CHECK(disconnect(download, &Download::paused, this, |
1520 | + &SingleDownload::onPaused)) |
1521 | + << "Could not connect to signal"; |
1522 | + |
1523 | + CHECK(disconnect(download, &Download::resumed, this, |
1524 | + &SingleDownload::onResumed)) |
1525 | + << "Could not connect to signal"; |
1526 | + |
1527 | + CHECK(disconnect(download, &Download::started, this, |
1528 | + &SingleDownload::onStarted)) |
1529 | + << "Could not connect to signal"; |
1530 | +} |
1531 | + |
1532 | /*! |
1533 | \qmlmethod void SingleDownload::download(string url) |
1534 | |
1535 | Creates the download for the given url and reports the different states through the properties. |
1536 | */ |
1537 | -void SingleDownload::download(QString url) |
1538 | +void |
1539 | +SingleDownload::download(QString url) |
1540 | { |
1541 | if (!m_downloadInProgress) { |
1542 | if (m_manager == nullptr) { |
1543 | @@ -160,71 +195,240 @@ |
1544 | |
1545 | Starts the download, used when autoStart is False. |
1546 | */ |
1547 | -void SingleDownload::start() |
1548 | +void |
1549 | +SingleDownload::start() |
1550 | { |
1551 | startDownload(); |
1552 | } |
1553 | |
1554 | -void SingleDownload::startDownload() |
1555 | +void |
1556 | +SingleDownload::startDownload() |
1557 | { |
1558 | if (m_download != nullptr) { |
1559 | m_download->start(); |
1560 | } |
1561 | } |
1562 | |
1563 | -void SingleDownload::pause() |
1564 | +/*! |
1565 | + \qmlmethod void SingleDownload::pause() |
1566 | + |
1567 | + Pauses the download. An error is returned if the download was |
1568 | + already paused. |
1569 | +*/ |
1570 | +void |
1571 | +SingleDownload::pause() |
1572 | { |
1573 | m_download->pause(); |
1574 | } |
1575 | |
1576 | -void SingleDownload::resume() |
1577 | +/*! |
1578 | + \qmlmethod void SingleDownload::resume() |
1579 | + |
1580 | + Resumes and already paused download. An error is returned if the download was |
1581 | + already resumed or not paused. |
1582 | +*/ |
1583 | +void |
1584 | +SingleDownload::resume() |
1585 | { |
1586 | m_download->resume(); |
1587 | } |
1588 | |
1589 | -void SingleDownload::cancel() |
1590 | +/*! |
1591 | + \qmlmethod void SingleDownload::cancel() |
1592 | + |
1593 | + Cancels a download. |
1594 | +*/ |
1595 | +void |
1596 | +SingleDownload::cancel() |
1597 | { |
1598 | m_download->cancel(); |
1599 | } |
1600 | |
1601 | -void SingleDownload::setCompleted() |
1602 | -{ |
1603 | - m_completed = true; |
1604 | - m_downloading = false; |
1605 | - m_downloadInProgress = false; |
1606 | -} |
1607 | - |
1608 | -void SingleDownload::registerError(Error* error) |
1609 | +void |
1610 | +SingleDownload::registerError(Error* error) |
1611 | { |
1612 | m_error.setMessage(error->errorString()); |
1613 | emit errorFound(m_error); |
1614 | emit errorChanged(); |
1615 | } |
1616 | |
1617 | -void SingleDownload::setProgress(qulonglong received, qulonglong total) |
1618 | +void |
1619 | +SingleDownload::onFinished(const QString& path) |
1620 | +{ |
1621 | + m_completed = true; |
1622 | + m_downloading = false; |
1623 | + m_downloadInProgress = false; |
1624 | + |
1625 | + // unbind the download so that we have no memory leaks due to the connections |
1626 | + unbindDownload(m_download); |
1627 | + m_download->deleteLater(); |
1628 | + m_download = nullptr; |
1629 | + emit finished(path); |
1630 | +} |
1631 | + |
1632 | +void |
1633 | +SingleDownload::onProgress(qulonglong received, qulonglong total) |
1634 | { |
1635 | if (total > 0) { |
1636 | qulonglong result = (received * 100); |
1637 | m_progress = static_cast<int>(result / total); |
1638 | emit progressChanged(); |
1639 | } |
1640 | + emit progressReceived(received, total); |
1641 | } |
1642 | |
1643 | -void SingleDownload::setDownloadPaused(bool) |
1644 | +void |
1645 | +SingleDownload::onPaused(bool wasPaused) |
1646 | { |
1647 | m_downloading = false; |
1648 | -} |
1649 | - |
1650 | -void SingleDownload::setDownloadStarted(bool) |
1651 | + emit paused(wasPaused); |
1652 | +} |
1653 | + |
1654 | +void |
1655 | +SingleDownload::onResumed(bool wasResumed) { |
1656 | + m_downloading = true; |
1657 | + emit resumed(wasResumed); |
1658 | +} |
1659 | + |
1660 | +void |
1661 | +SingleDownload::onStarted(bool wasStarted) |
1662 | { |
1663 | m_downloading = true; |
1664 | + emit resumed(wasStarted); |
1665 | } |
1666 | |
1667 | -void SingleDownload::setDownloadCanceled(bool) |
1668 | +void |
1669 | +SingleDownload::onCanceled(bool wasCanceled) |
1670 | { |
1671 | m_completed = false; |
1672 | m_downloading = false; |
1673 | m_downloadInProgress = false; |
1674 | + |
1675 | + // unbind the download so that we have no memory leaks due to the connections |
1676 | + unbindDownload(m_download); |
1677 | + m_download->deleteLater(); |
1678 | + m_download = nullptr; |
1679 | + emit canceled(wasCanceled); |
1680 | +} |
1681 | + |
1682 | +bool |
1683 | +SingleDownload::allowMobileDownload() const { |
1684 | + if (m_download == nullptr) { |
1685 | + return m_mobile; |
1686 | + } else { |
1687 | + return m_download->isMobileDownloadAllowed(); |
1688 | + } |
1689 | +} |
1690 | + |
1691 | +void |
1692 | +SingleDownload::setAllowMobileDownload(bool value) { |
1693 | + if (m_download == nullptr) { |
1694 | + m_dirty = true; |
1695 | + m_mobile = value; |
1696 | + } else { |
1697 | + m_download->allowMobileDownload(value); |
1698 | + if (m_download->isError()) { |
1699 | + // set the error details and emit the signals |
1700 | + auto err = m_download->error(); |
1701 | + m_error.setType(getErrorType(err->type())); |
1702 | + m_error.setMessage(err->errorString()); |
1703 | + emit errorFound(m_error); |
1704 | + emit errorChanged(); |
1705 | + } else { |
1706 | + emit allowMobileDownloadChanged(); |
1707 | + } |
1708 | + } |
1709 | +} |
1710 | + |
1711 | +qulonglong |
1712 | +SingleDownload::throttle() const { |
1713 | + if (m_download == nullptr) { |
1714 | + return m_throttle; |
1715 | + } else { |
1716 | + return m_download->throttle(); |
1717 | + } |
1718 | +} |
1719 | + |
1720 | +void |
1721 | +SingleDownload::setThrottle(qulonglong value) { |
1722 | + if (m_download == nullptr) { |
1723 | + m_dirty = true; |
1724 | + m_throttle = value; |
1725 | + } else { |
1726 | + m_download->setThrottle(value); |
1727 | + if (m_download->isError()) { |
1728 | + // set the error details and emit the signals |
1729 | + auto err = m_download->error(); |
1730 | + m_error.setType(getErrorType(err->type())); |
1731 | + m_error.setMessage(err->errorString()); |
1732 | + emit errorFound(m_error); |
1733 | + emit errorChanged(); |
1734 | + } else { |
1735 | + emit throttleChanged(); |
1736 | + } |
1737 | + } |
1738 | +} |
1739 | + |
1740 | +QString |
1741 | +SingleDownload::downloadId() const { |
1742 | + if (m_download == nullptr) { |
1743 | + return ""; |
1744 | + } else { |
1745 | + return m_download->id(); |
1746 | + } |
1747 | +} |
1748 | + |
1749 | +QVariantMap |
1750 | +SingleDownload::headers() const { |
1751 | + if (m_download == nullptr) { |
1752 | + return m_headers; |
1753 | + } else { |
1754 | + // convert the QMap<QString, QString> into a QMap<QString, QVariant> |
1755 | + auto headers = m_download->headers(); |
1756 | + QVariantMap result; |
1757 | + foreach(const QString& key, headers.keys()) { |
1758 | + result[key] = headers[key]; // automatic conversion |
1759 | + } |
1760 | + return result; |
1761 | + } |
1762 | +} |
1763 | + |
1764 | +void |
1765 | +SingleDownload::setHeaders(QVariantMap headers) { |
1766 | + if (m_download == nullptr) { |
1767 | + m_dirty = true; |
1768 | + m_headers = headers; |
1769 | + } else { |
1770 | + QMap<QString, QString> stringMap; |
1771 | + // convert the QVariantMap in a QMap<QString, QString> and make sure |
1772 | + // that the variants can be converted to strings. |
1773 | + foreach(const QString& key, headers.keys()) { |
1774 | + auto data = headers[key]; |
1775 | + if (data.canConvert<QString>()) { |
1776 | + stringMap[key] = data.toString(); |
1777 | + } else { |
1778 | + m_error.setType("Headers Conversion Error"); |
1779 | + auto msg = QString( |
1780 | + "Could not convert data in header '%1' to string.").arg(key); |
1781 | + m_error.setMessage(msg); |
1782 | + emit errorFound(m_error); |
1783 | + emit errorChanged(); |
1784 | + return; |
1785 | + } |
1786 | + } |
1787 | + |
1788 | + m_download->setHeaders(stringMap); |
1789 | + if (m_download->isError()) { |
1790 | + // set the error details and emit the signals |
1791 | + auto err = m_download->error(); |
1792 | + m_error.setType(getErrorType(err->type())); |
1793 | + m_error.setMessage(err->errorString()); |
1794 | + emit errorFound(m_error); |
1795 | + emit errorChanged(); |
1796 | + } else { |
1797 | + emit headersChanged(); |
1798 | + } |
1799 | + } |
1800 | } |
1801 | |
1802 | /*! |
1803 | @@ -287,5 +491,13 @@ |
1804 | within the download manager. |
1805 | */ |
1806 | |
1807 | +/*! |
1808 | + \qmlproperty QVariantMap SingleDownload::headers |
1809 | + |
1810 | + This property allows to get and set the headers that will be used to perform |
1811 | + the download request. All headers must be strings or at least QVariant should |
1812 | + be able to convert them to strings. |
1813 | +*/ |
1814 | + |
1815 | } |
1816 | } |
1817 | |
1818 | === modified file 'src/downloads/qml/single_download.h' |
1819 | --- src/downloads/qml/single_download.h 2014-04-30 10:34:46 +0000 |
1820 | +++ src/downloads/qml/single_download.h 2014-07-03 14:40:18 +0000 |
1821 | @@ -1,3 +1,21 @@ |
1822 | +/* |
1823 | + * Copyright 2014 Canonical Ltd. |
1824 | + * |
1825 | + * This library is free software; you can redistribute it and/or |
1826 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
1827 | + * License as published by the Free Software Foundation. |
1828 | + * |
1829 | + * This program is distributed in the hope that it will be useful, |
1830 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1831 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1832 | + * General Public License for more details. |
1833 | + * |
1834 | + * You should have received a copy of the GNU Lesser General Public |
1835 | + * License along with this library; if not, write to the |
1836 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
1837 | + * Boston, MA 02110-1301, USA. |
1838 | + */ |
1839 | + |
1840 | #ifndef FILE_DOWNLOAD_H |
1841 | #define FILE_DOWNLOAD_H |
1842 | |
1843 | @@ -23,6 +41,7 @@ |
1844 | Q_PROPERTY(int progress READ progress NOTIFY progressChanged) |
1845 | Q_PROPERTY(bool downloading READ downloading NOTIFY downloadingChanged) |
1846 | Q_PROPERTY(QString downloadId READ downloadId NOTIFY downloadIdChanged) |
1847 | + Q_PROPERTY(QVariantMap headers READ headers WRITE setHeaders NOTIFY headersChanged) |
1848 | |
1849 | public: |
1850 | explicit SingleDownload(QObject *parent = 0); |
1851 | @@ -36,21 +55,50 @@ |
1852 | void startDownload(); |
1853 | |
1854 | // getters |
1855 | - bool isCompleted() const { return m_completed; } |
1856 | - DownloadError& error() { return m_error; } |
1857 | - QString errorMessage() const { return m_error.message(); } |
1858 | - qulonglong throttle() const { return m_download->throttle(); } |
1859 | - bool allowMobileDownload() const { return m_download->isMobileDownloadAllowed(); } |
1860 | - int progress() const { return m_progress; } |
1861 | - bool downloading() const { return m_downloading; } |
1862 | - bool downloadInProgress() const { return m_downloadInProgress; } |
1863 | - bool autoStart() const { return m_autoStart; } |
1864 | - QString downloadId() const { return m_download->id(); } |
1865 | + bool isCompleted() const { |
1866 | + return m_completed; |
1867 | + } |
1868 | + |
1869 | + DownloadError& error() { |
1870 | + return m_error; |
1871 | + } |
1872 | + |
1873 | + QString errorMessage() const { |
1874 | + return m_error.message(); |
1875 | + } |
1876 | + |
1877 | + qulonglong throttle() const; |
1878 | + |
1879 | + bool allowMobileDownload() const; |
1880 | + |
1881 | + int progress() const { |
1882 | + return m_progress; |
1883 | + } |
1884 | + |
1885 | + bool downloading() const { |
1886 | + return m_downloading; |
1887 | + } |
1888 | + |
1889 | + bool downloadInProgress() const { |
1890 | + return m_downloadInProgress; |
1891 | + } |
1892 | + |
1893 | + bool autoStart() const { |
1894 | + return m_autoStart; |
1895 | + } |
1896 | + |
1897 | + QString downloadId() const; |
1898 | + QVariantMap headers() const; |
1899 | |
1900 | // setters |
1901 | - void setAllowMobileDownload(bool value) { m_download->allowMobileDownload(value); emit allowMobileDownloadChanged(); } |
1902 | - void setThrottle(qulonglong value) { m_download->setThrottle(value); emit throttleChanged(); } |
1903 | - void setAutoStart(bool value) { m_autoStart = value; } |
1904 | + void setAllowMobileDownload(bool value); |
1905 | + void setThrottle(qulonglong value); |
1906 | + void setHeaders(QVariantMap headers); |
1907 | + |
1908 | + // only property that does not access the download obj |
1909 | + void setAutoStart(bool value) { |
1910 | + m_autoStart = value; |
1911 | + } |
1912 | |
1913 | signals: |
1914 | void isCompletedChanged(); |
1915 | @@ -60,6 +108,7 @@ |
1916 | void downloadingChanged(); |
1917 | void downloadInProgressChanged(); |
1918 | void downloadIdChanged(); |
1919 | + void headersChanged(); |
1920 | |
1921 | void canceled(bool success); |
1922 | void finished(const QString& path); |
1923 | @@ -73,22 +122,46 @@ |
1924 | |
1925 | public slots: |
1926 | void registerError(Error* error); |
1927 | - void setCompleted(); |
1928 | void bindDownload(Download* download); |
1929 | - void setProgress(qulonglong received, qulonglong total); |
1930 | - void setDownloadPaused(bool); |
1931 | - void setDownloadStarted(bool); |
1932 | - void setDownloadCanceled(bool); |
1933 | + void unbindDownload(Download* download); |
1934 | + void onFinished(const QString& path); |
1935 | + void onProgress(qulonglong received, qulonglong total); |
1936 | + void onPaused(bool wasPaused); |
1937 | + void onResumed(bool wasResumed); |
1938 | + void onStarted(bool wasStarted); |
1939 | + void onCanceled(bool wasCanceled); |
1940 | + |
1941 | +private: |
1942 | + QString getErrorType(Error::Type type) { |
1943 | + switch (type) { |
1944 | + case Error::Auth: |
1945 | + return QString("Auth"); |
1946 | + case Error::DBus: |
1947 | + return QString("DBus"); |
1948 | + case Error::Http: |
1949 | + return QString("Http"); |
1950 | + case Error::Network: |
1951 | + return QString("Network"); |
1952 | + case Error::Process: |
1953 | + return QString("Process"); |
1954 | + default: |
1955 | + return QString(); |
1956 | + } |
1957 | + } |
1958 | |
1959 | private: |
1960 | bool m_autoStart; |
1961 | bool m_completed; |
1962 | bool m_downloading; |
1963 | + bool m_dirty = false; |
1964 | bool m_downloadInProgress; |
1965 | int m_progress; |
1966 | + bool m_mobile = false; |
1967 | + qulonglong m_throttle = 0; |
1968 | + QVariantMap m_headers; |
1969 | DownloadError m_error; |
1970 | - Download* m_download; |
1971 | - Manager* m_manager; |
1972 | + Download* m_download = nullptr; |
1973 | + Manager* m_manager = nullptr; |
1974 | |
1975 | }; |
1976 | |
1977 | |
1978 | === modified file 'src/downloads/qml/ubuntu_download_manager.h' |
1979 | --- src/downloads/qml/ubuntu_download_manager.h 2014-03-28 16:11:54 +0000 |
1980 | +++ src/downloads/qml/ubuntu_download_manager.h 2014-07-03 14:40:18 +0000 |
1981 | @@ -1,3 +1,21 @@ |
1982 | +/* |
1983 | + * Copyright 2014 Canonical Ltd. |
1984 | + * |
1985 | + * This library is free software; you can redistribute it and/or |
1986 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
1987 | + * License as published by the Free Software Foundation. |
1988 | + * |
1989 | + * This program is distributed in the hope that it will be useful, |
1990 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1991 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1992 | + * General Public License for more details. |
1993 | + * |
1994 | + * You should have received a copy of the GNU Lesser General Public |
1995 | + * License along with this library; if not, write to the |
1996 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
1997 | + * Boston, MA 02110-1301, USA. |
1998 | + */ |
1999 | + |
2000 | #ifndef UBUNTUDOWNLOADMANAGER_PLUGIN_H |
2001 | #define UBUNTUDOWNLOADMANAGER_PLUGIN_H |
2002 | |
2003 | |
2004 | === modified file 'tests/CMakeLists.txt' |
2005 | --- tests/CMakeLists.txt 2014-07-03 14:40:17 +0000 |
2006 | +++ tests/CMakeLists.txt 2014-07-03 14:40:18 +0000 |
2007 | @@ -1,178 +1,24 @@ |
2008 | -set(DAEMON_TESTS |
2009 | - test_apn_request_factory |
2010 | - test_apparmor |
2011 | - test_base_download |
2012 | - test_cancel_download_transition |
2013 | - test_daemon |
2014 | - test_download |
2015 | - test_download_factory |
2016 | - test_download_manager |
2017 | - test_downloads_db |
2018 | - test_file_download_sm |
2019 | - test_filename_mutex |
2020 | - test_final_state |
2021 | - test_group_download |
2022 | - test_metadata |
2023 | - test_mms_download |
2024 | - test_network_error_transition |
2025 | - test_resume_download_transition |
2026 | - test_ssl_error_transition |
2027 | - test_start_download_transition |
2028 | - test_stop_request_transition |
2029 | - test_transfers_queue |
2030 | -) |
2031 | - |
2032 | -foreach(test ${DAEMON_TESTS}) |
2033 | - # set the sources per test |
2034 | - set(${test}_DAEMON_SOURCES |
2035 | - base_testcase.cpp |
2036 | - ${test}.cpp |
2037 | - ) |
2038 | - |
2039 | - set(${test}_DAEMON_HEADERS |
2040 | - application.h |
2041 | - apparmor.h |
2042 | - base_testcase.h |
2043 | - cryptographic_hash.h |
2044 | - database.h |
2045 | - dbus_connection.h |
2046 | - dbus_proxy.h |
2047 | - dbus_proxy_factory.h |
2048 | - download.h |
2049 | - factory.h |
2050 | - file_manager.h |
2051 | - filename_mutex.h |
2052 | - manager.h |
2053 | - matchers.h |
2054 | - network_reply.h |
2055 | - pending_reply.h |
2056 | - process.h |
2057 | - process_factory.h |
2058 | - queue.h |
2059 | - request_factory.h |
2060 | - sm_file_download.h |
2061 | - system_network_info.h |
2062 | - timer.h |
2063 | - transfer.h |
2064 | - uuid_factory.h |
2065 | - ${test}.h |
2066 | - ) |
2067 | - |
2068 | -endforeach(test) |
2069 | - |
2070 | -set(CLIENT_TESTS |
2071 | - test_client_download |
2072 | - test_download_manager_watch |
2073 | - test_download_watch |
2074 | - test_client_manager |
2075 | -) |
2076 | - |
2077 | -foreach(test ${CLIENT_TESTS}) |
2078 | - # set the sources per test |
2079 | - set(${test}_CLIENT_SOURCES |
2080 | - base_testcase.cpp |
2081 | - daemon_testcase.cpp |
2082 | - local_tree_testcase.cpp |
2083 | - testing_interface.cpp |
2084 | - ${test}.cpp |
2085 | - ) |
2086 | - |
2087 | - set(${test}_CLIENT_HEADERS |
2088 | - base_testcase.h |
2089 | - daemon_testcase.h |
2090 | - local_tree_testcase.h |
2091 | - testing_interface.h |
2092 | - ${test}.h |
2093 | - ) |
2094 | - |
2095 | -endforeach(test) |
2096 | - |
2097 | -include_directories(${Qt5Core_INCLUDE_DIRS}) |
2098 | -include_directories(${Qt5SystemInfo_INCLUDE_DIRS}) |
2099 | -include_directories(${Qt5DBus_INCLUDE_DIRS}) |
2100 | -include_directories(${Qt5Network_INCLUDE_DIRS}) |
2101 | -include_directories(${Qt5Test_INCLUDE_DIRS}) |
2102 | -include_directories(${Qt5Sql_INCLUDE_DIRS}) |
2103 | -include_directories(${DBUS_INCLUDE_DIRS}) |
2104 | -include_directories(${GTEST_INCLUDE_DIRS}) |
2105 | -include_directories(${GMOCK_INCLUDE_DIRS}) |
2106 | -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) |
2107 | -include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
2108 | -include_directories(${CMAKE_SOURCE_DIR}/src/common/public) |
2109 | -include_directories(${CMAKE_SOURCE_DIR}/src/common/priv) |
2110 | -include_directories(${CMAKE_SOURCE_DIR}/src/downloads/common) |
2111 | -include_directories(${CMAKE_SOURCE_DIR}/src/downloads/client) |
2112 | -include_directories(${CMAKE_SOURCE_DIR}/src/downloads/priv) |
2113 | - |
2114 | -link_directories(${NIH_DBUS_LIBDIR}) |
2115 | -link_directories(${GLOG_DBUS_LIBDIR}) |
2116 | +# Copyright © 2014 Canonical Ltd. |
2117 | +# |
2118 | +# This program is free software: you can redistribute it and/or modify |
2119 | +# it under the terms of the GNU General Public License version 3 as |
2120 | +# published by the Free Software Foundation. |
2121 | +# |
2122 | +# This program is distributed in the hope that it will be useful, |
2123 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2124 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2125 | +# GNU General Public License for more details. |
2126 | +# |
2127 | +# You should have received a copy of the GNU General Public License |
2128 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
2129 | +# |
2130 | +# Authored by: Manuel de la Peña <manuel.delapena@canonical.com> |
2131 | |
2132 | if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") |
2133 | -add_custom_target(download-daemon-tests-data ALL |
2134 | - COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data |
2135 | +add_custom_target(tests-data ALL |
2136 | + COMMAND cp -r ${CMAKE_SOURCE_DIR}/tests/data ${CMAKE_CURRENT_BINARY_DIR}/data |
2137 | ) |
2138 | endif(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}") |
2139 | |
2140 | -set(DAEMON_TESTS_LIBS |
2141 | - ${NIH_DBUS_LIBRARIES} |
2142 | - ${GLOG_LIBRARIES} |
2143 | - ${Qt5Core_LIBRARIES} |
2144 | - ${Qt5Sql_LIBRARIES} |
2145 | - ${Qt5DBus_LIBRARIES} |
2146 | - ${Qt5Test_LIBRARIES} |
2147 | - ${GMOCK_LIBRARY} |
2148 | - ${GTEST_BOTH_LIBRARIES} |
2149 | - udm-common |
2150 | - udm-priv-common |
2151 | - ubuntu-download-manager-common |
2152 | - ubuntu-download-manager-priv |
2153 | -) |
2154 | - |
2155 | - |
2156 | -foreach(test ${DAEMON_TESTS}) |
2157 | - # set targets, linked libs and test |
2158 | - add_executable(${test}_daemon |
2159 | - ${${test}_DAEMON_SOURCES} |
2160 | - ${${test}_DAEMON_HEADERS} |
2161 | - ) |
2162 | - |
2163 | - target_link_libraries(${test}_daemon |
2164 | - ${DAEMON_TESTS_LIBS} |
2165 | - ) |
2166 | - |
2167 | - |
2168 | - ADD_TEST(NAME daemon_${test} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${test}_daemon) |
2169 | -endforeach(test) |
2170 | - |
2171 | -find_program(DBUS_RUNNER dbus-test-runner) |
2172 | - |
2173 | -set(CLIENT_TESTS_LIBS |
2174 | - ${NIH_DBUS_LIBRARIES} |
2175 | - ${GLOG_LIBRARIES} |
2176 | - ${Qt5Network_LIBRARIES} |
2177 | - ${Qt5Test_LIBRARIES} |
2178 | - udm-common |
2179 | - udm-priv-common |
2180 | - ubuntu-download-manager-common |
2181 | - ubuntu-download-manager-client |
2182 | - ubuntu-download-manager-priv |
2183 | -) |
2184 | - |
2185 | -if(DBUS_RUNNER) |
2186 | - foreach(test ${CLIENT_TESTS}) |
2187 | - # set targets, linked libs and test |
2188 | - add_executable(${test}_client |
2189 | - ${${test}_CLIENT_SOURCES} |
2190 | - ${${test}_CLIENT_HEADERS} |
2191 | - ) |
2192 | - |
2193 | - target_link_libraries(${test}_client |
2194 | - ${CLIENT_TESTS_LIBS} |
2195 | - ) |
2196 | - |
2197 | - ADD_TEST(NAME client_${test} COMMAND dbus-test-runner -m 180 --task=${CMAKE_CURRENT_BINARY_DIR}/${test}_client -c) |
2198 | - |
2199 | - endforeach(test) |
2200 | -else(DBUS_RUNNER) |
2201 | - message(WARNING "dbus-test-runner binary not found tests will be disabled") |
2202 | -endif(DBUS_RUNNER) |
2203 | +add_subdirectory(common) |
2204 | +add_subdirectory(downloads) |
2205 | |
2206 | === added directory 'tests/common' |
2207 | === added file 'tests/common/CMakeLists.txt' |
2208 | --- tests/common/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
2209 | +++ tests/common/CMakeLists.txt 2014-07-03 14:40:18 +0000 |
2210 | @@ -0,0 +1,55 @@ |
2211 | +set(TARGET ubuntu-download-manager-test-lib) |
2212 | + |
2213 | +set(SOURCES |
2214 | + base_testcase.cpp |
2215 | + daemon_testcase.cpp |
2216 | + local_tree_testcase.cpp |
2217 | + testing_interface.cpp |
2218 | +) |
2219 | + |
2220 | +set(HEADERS |
2221 | + base_testcase.h |
2222 | + daemon_testcase.h |
2223 | + local_tree_testcase.h |
2224 | + matchers.h |
2225 | + testing_interface.h |
2226 | +) |
2227 | + |
2228 | +include_directories(${Qt5Core_INCLUDE_DIRS}) |
2229 | +include_directories(${Qt5SystemInfo_INCLUDE_DIRS}) |
2230 | +include_directories(${Qt5DBus_INCLUDE_DIRS}) |
2231 | +include_directories(${Qt5Network_INCLUDE_DIRS}) |
2232 | +include_directories(${Qt5Test_INCLUDE_DIRS}) |
2233 | +include_directories(${Qt5Sql_INCLUDE_DIRS}) |
2234 | +include_directories(${DBUS_INCLUDE_DIRS}) |
2235 | +include_directories(${GTEST_INCLUDE_DIRS}) |
2236 | +include_directories(${GMOCK_INCLUDE_DIRS}) |
2237 | +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) |
2238 | +include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
2239 | +include_directories(${CMAKE_SOURCE_DIR}/src/common/public) |
2240 | +include_directories(${CMAKE_SOURCE_DIR}/src/common/priv) |
2241 | +include_directories(${CMAKE_SOURCE_DIR}/src/downloads/common) |
2242 | +include_directories(${CMAKE_SOURCE_DIR}/src/downloads/client) |
2243 | +include_directories(${CMAKE_SOURCE_DIR}/src/downloads/priv) |
2244 | + |
2245 | +link_directories(${NIH_DBUS_LIBDIR}) |
2246 | +link_directories(${GLOG_DBUS_LIBDIR}) |
2247 | + |
2248 | +add_library(${TARGET} STATIC |
2249 | + ${HEADERS} |
2250 | + ${SOURCES} |
2251 | +) |
2252 | + |
2253 | +target_link_libraries(${TARGET} |
2254 | + ${NIH_DBUS_LIBRARIES} |
2255 | + ${GLOG_LIBRARIES} |
2256 | + ${Qt5Core_LIBRARIES} |
2257 | + ${Qt5Sql_LIBRARIES} |
2258 | + ${Qt5DBus_LIBRARIES} |
2259 | + ${Qt5Test_LIBRARIES} |
2260 | + ${GMOCK_LIBRARY} |
2261 | + ${GTEST_BOTH_LIBRARIES} |
2262 | + udm-common |
2263 | + ubuntu-download-manager-common |
2264 | + ubuntu-download-manager-client |
2265 | +) |
2266 | |
2267 | === renamed file 'tests/base_testcase.cpp' => 'tests/common/base_testcase.cpp' |
2268 | --- tests/base_testcase.cpp 2014-03-12 12:59:51 +0000 |
2269 | +++ tests/common/base_testcase.cpp 2014-07-03 14:40:18 +0000 |
2270 | @@ -59,7 +59,7 @@ |
2271 | QDir dir("."); |
2272 | dir.makeAbsolute(); |
2273 | |
2274 | - return dir.path() + "/data"; |
2275 | + return dir.path() + "/tests/data"; |
2276 | } |
2277 | |
2278 | bool |
2279 | |
2280 | === renamed file 'tests/base_testcase.h' => 'tests/common/base_testcase.h' |
2281 | === renamed file 'tests/daemon_testcase.cpp' => 'tests/common/daemon_testcase.cpp' |
2282 | === renamed file 'tests/daemon_testcase.h' => 'tests/common/daemon_testcase.h' |
2283 | === renamed file 'tests/local_tree_testcase.cpp' => 'tests/common/local_tree_testcase.cpp' |
2284 | --- tests/local_tree_testcase.cpp 2014-03-27 12:54:03 +0000 |
2285 | +++ tests/common/local_tree_testcase.cpp 2014-07-03 14:40:18 +0000 |
2286 | @@ -17,7 +17,7 @@ |
2287 | */ |
2288 | |
2289 | #include "local_tree_testcase.h" |
2290 | -#define TEST_DAEMON "../src/downloads/test-daemon/ubuntu-download-manager-test-daemon" |
2291 | +#define TEST_DAEMON "../../../src/downloads/test-daemon/ubuntu-download-manager-test-daemon" |
2292 | #define LARGE_FILE "otasigned.zip" |
2293 | #define SMALL_FILE "index.json" |
2294 | |
2295 | @@ -48,4 +48,6 @@ |
2296 | |
2297 | QString smallFile = dataDirectory() + "/" + QString(SMALL_FILE); |
2298 | addFileToHttpServer(smallFile); |
2299 | + Ubuntu::DownloadManager::Logging::Logger::init( |
2300 | + Ubuntu::DownloadManager::Logging::Logger::Debug, testDirectory() + "/client.log"); |
2301 | } |
2302 | |
2303 | === renamed file 'tests/local_tree_testcase.h' => 'tests/common/local_tree_testcase.h' |
2304 | --- tests/local_tree_testcase.h 2014-03-12 12:59:51 +0000 |
2305 | +++ tests/common/local_tree_testcase.h 2014-07-03 14:40:18 +0000 |
2306 | @@ -21,6 +21,8 @@ |
2307 | |
2308 | #include <QObject> |
2309 | #include <QUrl> |
2310 | + |
2311 | +#include <ubuntu/download_manager/logging/logger.h> |
2312 | #include "daemon_testcase.h" |
2313 | |
2314 | class LocalTreeTestCase : public DaemonTestCase { |
2315 | |
2316 | === renamed file 'tests/matchers.h' => 'tests/common/matchers.h' |
2317 | === renamed file 'tests/testing_interface.cpp' => 'tests/common/testing_interface.cpp' |
2318 | === renamed file 'tests/testing_interface.h' => 'tests/common/testing_interface.h' |
2319 | === added directory 'tests/downloads' |
2320 | === added file 'tests/downloads/CMakeLists.txt' |
2321 | --- tests/downloads/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
2322 | +++ tests/downloads/CMakeLists.txt 2014-07-03 14:40:18 +0000 |
2323 | @@ -0,0 +1,19 @@ |
2324 | +# Copyright © 2014 Canonical Ltd. |
2325 | +# |
2326 | +# This program is free software: you can redistribute it and/or modify |
2327 | +# it under the terms of the GNU General Public License version 3 as |
2328 | +# published by the Free Software Foundation. |
2329 | +# |
2330 | +# This program is distributed in the hope that it will be useful, |
2331 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2332 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2333 | +# GNU General Public License for more details. |
2334 | +# |
2335 | +# You should have received a copy of the GNU General Public License |
2336 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
2337 | +# |
2338 | +# Authored by: Manuel de la Peña <manuel.delapena@canonical.com> |
2339 | + |
2340 | +add_subdirectory(client) |
2341 | +add_subdirectory(daemon) |
2342 | +#add_subdirectory(qml) |
2343 | |
2344 | === added directory 'tests/downloads/client' |
2345 | === added file 'tests/downloads/client/CMakeLists.txt' |
2346 | --- tests/downloads/client/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
2347 | +++ tests/downloads/client/CMakeLists.txt 2014-07-03 14:40:18 +0000 |
2348 | @@ -0,0 +1,90 @@ |
2349 | +# Copyright © 2014 Canonical Ltd. |
2350 | +# |
2351 | +# This program is free software: you can redistribute it and/or modify |
2352 | +# it under the terms of the GNU General Public License version 3 as |
2353 | +# published by the Free Software Foundation. |
2354 | +# |
2355 | +# This program is distributed in the hope that it will be useful, |
2356 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2357 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2358 | +# GNU General Public License for more details. |
2359 | +# |
2360 | +# You should have received a copy of the GNU General Public License |
2361 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
2362 | +# |
2363 | +# Authored by: Manuel de la Peña <manuel.delapena@canonical.com> |
2364 | + |
2365 | + |
2366 | +set(CLIENT_TESTS |
2367 | + test_client_download |
2368 | + test_download_manager_watch |
2369 | + test_download_watch |
2370 | + test_client_manager |
2371 | +) |
2372 | + |
2373 | +foreach(test ${CLIENT_TESTS}) |
2374 | + # set the sources per test |
2375 | + set(${test}_CLIENT_SOURCES |
2376 | + ${test}.cpp |
2377 | + ) |
2378 | + |
2379 | + set(${test}_CLIENT_HEADERS |
2380 | + ${test}.h |
2381 | + ) |
2382 | + |
2383 | +endforeach(test) |
2384 | + |
2385 | +include_directories(${Qt5Core_INCLUDE_DIRS}) |
2386 | +include_directories(${Qt5SystemInfo_INCLUDE_DIRS}) |
2387 | +include_directories(${Qt5DBus_INCLUDE_DIRS}) |
2388 | +include_directories(${Qt5Network_INCLUDE_DIRS}) |
2389 | +include_directories(${Qt5Test_INCLUDE_DIRS}) |
2390 | +include_directories(${Qt5Sql_INCLUDE_DIRS}) |
2391 | +include_directories(${DBUS_INCLUDE_DIRS}) |
2392 | +include_directories(${GTEST_INCLUDE_DIRS}) |
2393 | +include_directories(${GMOCK_INCLUDE_DIRS}) |
2394 | +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) |
2395 | +include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
2396 | +include_directories(${CMAKE_SOURCE_DIR}/src/common/public) |
2397 | +include_directories(${CMAKE_SOURCE_DIR}/src/common/priv) |
2398 | +include_directories(${CMAKE_SOURCE_DIR}/src/downloads/common) |
2399 | +include_directories(${CMAKE_SOURCE_DIR}/src/downloads/client) |
2400 | +include_directories(${CMAKE_SOURCE_DIR}/src/downloads/priv) |
2401 | +include_directories(${CMAKE_SOURCE_DIR}/tests/common) |
2402 | + |
2403 | +link_directories(${NIH_DBUS_LIBDIR}) |
2404 | +link_directories(${GLOG_DBUS_LIBDIR}) |
2405 | + |
2406 | +find_program(DBUS_RUNNER dbus-test-runner) |
2407 | + |
2408 | +set(CLIENT_TESTS_LIBS |
2409 | + ${NIH_DBUS_LIBRARIES} |
2410 | + ${GLOG_LIBRARIES} |
2411 | + ${Qt5Network_LIBRARIES} |
2412 | + ${Qt5Test_LIBRARIES} |
2413 | + udm-common |
2414 | + udm-priv-common |
2415 | + ubuntu-download-manager-common |
2416 | + ubuntu-download-manager-client |
2417 | + ubuntu-download-manager-priv |
2418 | + ubuntu-download-manager-test-lib |
2419 | +) |
2420 | + |
2421 | +if(DBUS_RUNNER) |
2422 | + foreach(test ${CLIENT_TESTS}) |
2423 | + # set targets, linked libs and test |
2424 | + add_executable(${test}_client |
2425 | + ${${test}_CLIENT_SOURCES} |
2426 | + ${${test}_CLIENT_HEADERS} |
2427 | + ) |
2428 | + |
2429 | + target_link_libraries(${test}_client |
2430 | + ${CLIENT_TESTS_LIBS} |
2431 | + ) |
2432 | + |
2433 | + ADD_TEST(NAME client_${test} COMMAND dbus-test-runner -m 180 --task=${CMAKE_CURRENT_BINARY_DIR}/${test}_client -c) |
2434 | + |
2435 | + endforeach(test) |
2436 | +else(DBUS_RUNNER) |
2437 | + message(WARNING "dbus-test-runner binary not found tests will be disabled") |
2438 | +endif(DBUS_RUNNER) |
2439 | |
2440 | === renamed file 'tests/test_client_download.cpp' => 'tests/downloads/client/test_client_download.cpp' |
2441 | === renamed file 'tests/test_client_download.h' => 'tests/downloads/client/test_client_download.h' |
2442 | === renamed file 'tests/test_client_manager.cpp' => 'tests/downloads/client/test_client_manager.cpp' |
2443 | === renamed file 'tests/test_client_manager.h' => 'tests/downloads/client/test_client_manager.h' |
2444 | === renamed file 'tests/test_download_manager_watch.cpp' => 'tests/downloads/client/test_download_manager_watch.cpp' |
2445 | === renamed file 'tests/test_download_manager_watch.h' => 'tests/downloads/client/test_download_manager_watch.h' |
2446 | === renamed file 'tests/test_download_watch.cpp' => 'tests/downloads/client/test_download_watch.cpp' |
2447 | === renamed file 'tests/test_download_watch.h' => 'tests/downloads/client/test_download_watch.h' |
2448 | === renamed file 'tests/test_group_manager_watch.cpp' => 'tests/downloads/client/test_group_manager_watch.cpp' |
2449 | === renamed file 'tests/test_group_manager_watch.h' => 'tests/downloads/client/test_group_manager_watch.h' |
2450 | === added directory 'tests/downloads/daemon' |
2451 | === added file 'tests/downloads/daemon/CMakeLists.txt' |
2452 | --- tests/downloads/daemon/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
2453 | +++ tests/downloads/daemon/CMakeLists.txt 2014-07-03 14:40:18 +0000 |
2454 | @@ -0,0 +1,129 @@ |
2455 | +# Copyright © 2014 Canonical Ltd. |
2456 | +# |
2457 | +# This program is free software: you can redistribute it and/or modify |
2458 | +# it under the terms of the GNU General Public License version 3 as |
2459 | +# published by the Free Software Foundation. |
2460 | +# |
2461 | +# This program is distributed in the hope that it will be useful, |
2462 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
2463 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2464 | +# GNU General Public License for more details. |
2465 | +# |
2466 | +# You should have received a copy of the GNU General Public License |
2467 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
2468 | +# |
2469 | +# Authored by: Manuel de la Peña <manuel.delapena@canonical.com> |
2470 | + |
2471 | +set(DAEMON_TESTS |
2472 | + test_apn_request_factory |
2473 | + test_apparmor |
2474 | + test_base_download |
2475 | + test_cancel_download_transition |
2476 | + test_daemon |
2477 | + test_download |
2478 | + test_download_factory |
2479 | + test_download_manager |
2480 | + test_downloads_db |
2481 | + test_file_download_sm |
2482 | + test_filename_mutex |
2483 | + test_final_state |
2484 | + test_group_download |
2485 | + test_metadata |
2486 | + test_mms_download |
2487 | + test_network_error_transition |
2488 | + test_resume_download_transition |
2489 | + test_ssl_error_transition |
2490 | + test_start_download_transition |
2491 | + test_stop_request_transition |
2492 | + test_transfers_queue |
2493 | +) |
2494 | + |
2495 | +foreach(test ${DAEMON_TESTS}) |
2496 | + # set the sources per test |
2497 | + set(${test}_DAEMON_SOURCES |
2498 | + ${test}.cpp |
2499 | + ) |
2500 | + |
2501 | + set(${test}_DAEMON_HEADERS |
2502 | + application.h |
2503 | + apparmor.h |
2504 | + cryptographic_hash.h |
2505 | + database.h |
2506 | + dbus_connection.h |
2507 | + dbus_proxy.h |
2508 | + dbus_proxy_factory.h |
2509 | + download.h |
2510 | + factory.h |
2511 | + file_manager.h |
2512 | + filename_mutex.h |
2513 | + manager.h |
2514 | + network_reply.h |
2515 | + pending_reply.h |
2516 | + process.h |
2517 | + process_factory.h |
2518 | + queue.h |
2519 | + request_factory.h |
2520 | + sm_file_download.h |
2521 | + system_network_info.h |
2522 | + timer.h |
2523 | + transfer.h |
2524 | + uuid_factory.h |
2525 | + ${test}.h |
2526 | + ) |
2527 | + |
2528 | +endforeach(test) |
2529 | + |
2530 | + |
2531 | +include_directories(${Qt5Core_INCLUDE_DIRS}) |
2532 | +include_directories(${Qt5SystemInfo_INCLUDE_DIRS}) |
2533 | +include_directories(${Qt5DBus_INCLUDE_DIRS}) |
2534 | +include_directories(${Qt5Network_INCLUDE_DIRS}) |
2535 | +include_directories(${Qt5Test_INCLUDE_DIRS}) |
2536 | +include_directories(${Qt5Sql_INCLUDE_DIRS}) |
2537 | +include_directories(${DBUS_INCLUDE_DIRS}) |
2538 | +include_directories(${GTEST_INCLUDE_DIRS}) |
2539 | +include_directories(${GMOCK_INCLUDE_DIRS}) |
2540 | +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) |
2541 | +include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
2542 | +include_directories(${CMAKE_SOURCE_DIR}/src/common/public) |
2543 | +include_directories(${CMAKE_SOURCE_DIR}/src/common/priv) |
2544 | +include_directories(${CMAKE_SOURCE_DIR}/src/downloads/common) |
2545 | +include_directories(${CMAKE_SOURCE_DIR}/src/downloads/client) |
2546 | +include_directories(${CMAKE_SOURCE_DIR}/src/downloads/priv) |
2547 | +include_directories(${CMAKE_SOURCE_DIR}/tests/common) |
2548 | + |
2549 | +link_directories(${NIH_DBUS_LIBDIR}) |
2550 | +link_directories(${GLOG_DBUS_LIBDIR}) |
2551 | + |
2552 | +set(DAEMON_TESTS_LIBS |
2553 | + ${NIH_DBUS_LIBRARIES} |
2554 | + ${GLOG_LIBRARIES} |
2555 | + ${Qt5Core_LIBRARIES} |
2556 | + ${Qt5Sql_LIBRARIES} |
2557 | + ${Qt5DBus_LIBRARIES} |
2558 | + ${Qt5Test_LIBRARIES} |
2559 | + ${GMOCK_LIBRARY} |
2560 | + ${GTEST_BOTH_LIBRARIES} |
2561 | + udm-common |
2562 | + udm-priv-common |
2563 | + ubuntu-download-manager-common |
2564 | + ubuntu-download-manager-priv |
2565 | + ubuntu-download-manager-test-lib |
2566 | +) |
2567 | + |
2568 | + |
2569 | +foreach(test ${DAEMON_TESTS}) |
2570 | + # set targets, linked libs and test |
2571 | + add_executable(${test}_daemon |
2572 | + ${${test}_DAEMON_SOURCES} |
2573 | + ${${test}_DAEMON_HEADERS} |
2574 | + ) |
2575 | + |
2576 | + target_link_libraries(${test}_daemon |
2577 | + ${DAEMON_TESTS_LIBS} |
2578 | + ) |
2579 | + |
2580 | + |
2581 | + ADD_TEST(NAME daemon_${test} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${test}_daemon) |
2582 | +endforeach(test) |
2583 | + |
2584 | |
2585 | === renamed file 'tests/apparmor.h' => 'tests/downloads/daemon/apparmor.h' |
2586 | === renamed file 'tests/application.h' => 'tests/downloads/daemon/application.h' |
2587 | === renamed file 'tests/cryptographic_hash.h' => 'tests/downloads/daemon/cryptographic_hash.h' |
2588 | === renamed file 'tests/database.h' => 'tests/downloads/daemon/database.h' |
2589 | === renamed file 'tests/dbus_connection.h' => 'tests/downloads/daemon/dbus_connection.h' |
2590 | === renamed file 'tests/dbus_proxy.h' => 'tests/downloads/daemon/dbus_proxy.h' |
2591 | === renamed file 'tests/dbus_proxy_factory.h' => 'tests/downloads/daemon/dbus_proxy_factory.h' |
2592 | === renamed file 'tests/download.h' => 'tests/downloads/daemon/download.h' |
2593 | === renamed file 'tests/factory.h' => 'tests/downloads/daemon/factory.h' |
2594 | === renamed file 'tests/file_manager.h' => 'tests/downloads/daemon/file_manager.h' |
2595 | === renamed file 'tests/filename_mutex.h' => 'tests/downloads/daemon/filename_mutex.h' |
2596 | === renamed file 'tests/group_download.h' => 'tests/downloads/daemon/group_download.h' |
2597 | === renamed file 'tests/manager.h' => 'tests/downloads/daemon/manager.h' |
2598 | === renamed file 'tests/network_reply.h' => 'tests/downloads/daemon/network_reply.h' |
2599 | === renamed file 'tests/pending_reply.h' => 'tests/downloads/daemon/pending_reply.h' |
2600 | === renamed file 'tests/process.h' => 'tests/downloads/daemon/process.h' |
2601 | === renamed file 'tests/process_factory.h' => 'tests/downloads/daemon/process_factory.h' |
2602 | === renamed file 'tests/queue.h' => 'tests/downloads/daemon/queue.h' |
2603 | === renamed file 'tests/request_factory.h' => 'tests/downloads/daemon/request_factory.h' |
2604 | === renamed file 'tests/sm_file_download.h' => 'tests/downloads/daemon/sm_file_download.h' |
2605 | === renamed file 'tests/system_network_info.h' => 'tests/downloads/daemon/system_network_info.h' |
2606 | === renamed file 'tests/test_apn_request_factory.cpp' => 'tests/downloads/daemon/test_apn_request_factory.cpp' |
2607 | === renamed file 'tests/test_apn_request_factory.h' => 'tests/downloads/daemon/test_apn_request_factory.h' |
2608 | === renamed file 'tests/test_apparmor.cpp' => 'tests/downloads/daemon/test_apparmor.cpp' |
2609 | === renamed file 'tests/test_apparmor.h' => 'tests/downloads/daemon/test_apparmor.h' |
2610 | === renamed file 'tests/test_base_download.cpp' => 'tests/downloads/daemon/test_base_download.cpp' |
2611 | === renamed file 'tests/test_base_download.h' => 'tests/downloads/daemon/test_base_download.h' |
2612 | === renamed file 'tests/test_cancel_download_transition.cpp' => 'tests/downloads/daemon/test_cancel_download_transition.cpp' |
2613 | === renamed file 'tests/test_cancel_download_transition.h' => 'tests/downloads/daemon/test_cancel_download_transition.h' |
2614 | === renamed file 'tests/test_daemon.cpp' => 'tests/downloads/daemon/test_daemon.cpp' |
2615 | === renamed file 'tests/test_daemon.h' => 'tests/downloads/daemon/test_daemon.h' |
2616 | === renamed file 'tests/test_download.cpp' => 'tests/downloads/daemon/test_download.cpp' |
2617 | === renamed file 'tests/test_download.h' => 'tests/downloads/daemon/test_download.h' |
2618 | === renamed file 'tests/test_download_factory.cpp' => 'tests/downloads/daemon/test_download_factory.cpp' |
2619 | === renamed file 'tests/test_download_factory.h' => 'tests/downloads/daemon/test_download_factory.h' |
2620 | === renamed file 'tests/test_download_manager.cpp' => 'tests/downloads/daemon/test_download_manager.cpp' |
2621 | === renamed file 'tests/test_download_manager.h' => 'tests/downloads/daemon/test_download_manager.h' |
2622 | === renamed file 'tests/test_downloads_db.cpp' => 'tests/downloads/daemon/test_downloads_db.cpp' |
2623 | === renamed file 'tests/test_downloads_db.h' => 'tests/downloads/daemon/test_downloads_db.h' |
2624 | === renamed file 'tests/test_file_download_sm.cpp' => 'tests/downloads/daemon/test_file_download_sm.cpp' |
2625 | === renamed file 'tests/test_file_download_sm.h' => 'tests/downloads/daemon/test_file_download_sm.h' |
2626 | === renamed file 'tests/test_filename_mutex.cpp' => 'tests/downloads/daemon/test_filename_mutex.cpp' |
2627 | === renamed file 'tests/test_filename_mutex.h' => 'tests/downloads/daemon/test_filename_mutex.h' |
2628 | === renamed file 'tests/test_final_state.cpp' => 'tests/downloads/daemon/test_final_state.cpp' |
2629 | === renamed file 'tests/test_final_state.h' => 'tests/downloads/daemon/test_final_state.h' |
2630 | === renamed file 'tests/test_group_download.cpp' => 'tests/downloads/daemon/test_group_download.cpp' |
2631 | === renamed file 'tests/test_group_download.h' => 'tests/downloads/daemon/test_group_download.h' |
2632 | === renamed file 'tests/test_metadata.cpp' => 'tests/downloads/daemon/test_metadata.cpp' |
2633 | === renamed file 'tests/test_metadata.h' => 'tests/downloads/daemon/test_metadata.h' |
2634 | === renamed file 'tests/test_mms_download.cpp' => 'tests/downloads/daemon/test_mms_download.cpp' |
2635 | === renamed file 'tests/test_mms_download.h' => 'tests/downloads/daemon/test_mms_download.h' |
2636 | === renamed file 'tests/test_network_error_transition.cpp' => 'tests/downloads/daemon/test_network_error_transition.cpp' |
2637 | === renamed file 'tests/test_network_error_transition.h' => 'tests/downloads/daemon/test_network_error_transition.h' |
2638 | === renamed file 'tests/test_resume_download_transition.cpp' => 'tests/downloads/daemon/test_resume_download_transition.cpp' |
2639 | === renamed file 'tests/test_resume_download_transition.h' => 'tests/downloads/daemon/test_resume_download_transition.h' |
2640 | === renamed file 'tests/test_ssl_error_transition.cpp' => 'tests/downloads/daemon/test_ssl_error_transition.cpp' |
2641 | === renamed file 'tests/test_ssl_error_transition.h' => 'tests/downloads/daemon/test_ssl_error_transition.h' |
2642 | === renamed file 'tests/test_start_download_transition.cpp' => 'tests/downloads/daemon/test_start_download_transition.cpp' |
2643 | === renamed file 'tests/test_start_download_transition.h' => 'tests/downloads/daemon/test_start_download_transition.h' |
2644 | === renamed file 'tests/test_stop_request_transition.cpp' => 'tests/downloads/daemon/test_stop_request_transition.cpp' |
2645 | === renamed file 'tests/test_stop_request_transition.h' => 'tests/downloads/daemon/test_stop_request_transition.h' |
2646 | === renamed file 'tests/test_transfers_queue.cpp' => 'tests/downloads/daemon/test_transfers_queue.cpp' |
2647 | === renamed file 'tests/test_transfers_queue.h' => 'tests/downloads/daemon/test_transfers_queue.h' |
2648 | === renamed file 'tests/timer.h' => 'tests/downloads/daemon/timer.h' |
2649 | === renamed file 'tests/transfer.h' => 'tests/downloads/daemon/transfer.h' |
2650 | === renamed file 'tests/uuid_factory.h' => 'tests/downloads/daemon/uuid_factory.h' |
2651 | === added directory 'tests/downloads/qml' |
2652 | === added file 'tests/downloads/qml/CMakeLists.txt' |
2653 | --- tests/downloads/qml/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
2654 | +++ tests/downloads/qml/CMakeLists.txt 2014-07-03 14:40:18 +0000 |
2655 | @@ -0,0 +1,14 @@ |
2656 | +set(QML_TESTS |
2657 | +) |
2658 | + |
2659 | +foreach(test ${DAEMON_TESTS}) |
2660 | + # set the sources per test |
2661 | + set(${test}_QML_SOURCES |
2662 | + ${test}.cpp |
2663 | + ) |
2664 | + |
2665 | + set(${test}_QML_HEADERS |
2666 | + ${test}.h |
2667 | + ) |
2668 | + |
2669 | +endforeach(test) |
2670 | |
2671 | === added file 'tests/downloads/qml/download.h' |
2672 | --- tests/downloads/qml/download.h 1970-01-01 00:00:00 +0000 |
2673 | +++ tests/downloads/qml/download.h 2014-07-03 14:40:18 +0000 |
2674 | @@ -0,0 +1,53 @@ |
2675 | +/* |
2676 | + * Copyright 2014 Canonical Ltd. |
2677 | + * |
2678 | + * This library is free software; you can redistribute it and/or |
2679 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
2680 | + * License as published by the Free Software Foundation. |
2681 | + * |
2682 | + * This program is distributed in the hope that it will be useful, |
2683 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2684 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2685 | + * General Public License for more details. |
2686 | + * |
2687 | + * You should have received a copy of the GNU Lesser General Public |
2688 | + * License along with this library; if not, write to the |
2689 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
2690 | + * Boston, MA 02110-1301, USA. |
2691 | + */ |
2692 | + |
2693 | +#ifndef FAKE_CLIENT_DOWNLOAD_H |
2694 | +#define FAKE_CLIENT_DOWNLOAD_H |
2695 | + |
2696 | +#include <ubuntu/download_manager/download.h> |
2697 | +#include <gmock/gmock.h> |
2698 | + |
2699 | +using namespace Ubuntu::DownloadManager; |
2700 | + |
2701 | +class MockDownload : public Download { |
2702 | + |
2703 | + public: |
2704 | + explicit MockDownload(QObject* parent=0) |
2705 | + : Download(parent) { |
2706 | + } |
2707 | + |
2708 | + MOCK_METHOD0(start, void()); |
2709 | + MOCK_METHOD0(pause, void()); |
2710 | + MOCK_METHOD0(resume, void()); |
2711 | + MOCK_METHOD0(cancel, void()); |
2712 | + MOCK_METHOD1(allowMobileDownload, void(bool)); |
2713 | + MOCK_METHOD0(isMobileDownloadAllowed, bool()); |
2714 | + MOCK_METHOD1(setDestinationDir, void(const QString&)); |
2715 | + MOCK_METHOD1(setHeaders, void(QMap<QString, QString> headers)); |
2716 | + MOCK_METHOD0(headers, QMap<QString, QString>()); |
2717 | + MOCK_METHOD1(setThrottle, void(qulonglong)); |
2718 | + MOCK_METHOD0(throttle, qulonglong()); |
2719 | + MOCK_CONST_METHOD0(id, QString()); |
2720 | + MOCK_METHOD0(metadata, QVariantMap()); |
2721 | + MOCK_METHOD0(progress, qulonglong()); |
2722 | + MOCK_METHOD0(totalSize, qulonglong()); |
2723 | + MOCK_CONST_METHOD0(isError, bool()); |
2724 | + MOCK_CONST_METHOD0(error, Error*()); |
2725 | +}; |
2726 | + |
2727 | +#endif |
2728 | |
2729 | === added file 'tests/downloads/qml/manager.h' |
2730 | --- tests/downloads/qml/manager.h 1970-01-01 00:00:00 +0000 |
2731 | +++ tests/downloads/qml/manager.h 2014-07-03 14:40:18 +0000 |
2732 | @@ -0,0 +1,55 @@ |
2733 | +/* |
2734 | + * Copyright 2014 Canonical Ltd. |
2735 | + * |
2736 | + * This library is free software; you can redistribute it and/or |
2737 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
2738 | + * License as published by the Free Software Foundation. |
2739 | + * |
2740 | + * This program is distributed in the hope that it will be useful, |
2741 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2742 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2743 | + * General Public License for more details. |
2744 | + * |
2745 | + * You should have received a copy of the GNU Lesser General Public |
2746 | + * License along with this library; if not, write to the |
2747 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
2748 | + * Boston, MA 02110-1301, USA. |
2749 | + */ |
2750 | + |
2751 | +#ifndef FAKE_MANAGER_DOWNLOAD_H |
2752 | +#define FAKE_MANAGER_DOWNLOAD_H |
2753 | + |
2754 | +#include <ubuntu/download_manager/manager.h> |
2755 | +#include <gmock/gmock.h> |
2756 | + |
2757 | +using namespace Ubuntu::DownloadManager; |
2758 | + |
2759 | +class MockManager : public Manager { |
2760 | + public: |
2761 | + explicit MockManager(QObject* parent=0) |
2762 | + : Manager(parent) { |
2763 | + } |
2764 | + |
2765 | + MOCK_METHOD1(getDownloadForId, Download*(const QString&)); |
2766 | + MOCK_METHOD1(createDownload, void(DownloadStruct)); |
2767 | + MOCK_METHOD3(createDownload, void(DownloadStruct, DownloadCb, DownloadCb)); |
2768 | + MOCK_METHOD4(createDownload, void(StructList downs, const QString&, bool, |
2769 | + const QVariantMap&, StringMap)); |
2770 | + MOCK_METHOD7(createDownload, void(StructList, const QString&, bool, |
2771 | + const QVariantMap&, StringMap, GroupCb, GroupCb)); |
2772 | + MOCK_METHOD0(getAllDownloads, void()); |
2773 | + MOCK_METHOD2(getAllDownloads, void(DownloadsListCb, DownloadsListCb)); |
2774 | + MOCK_METHOD2(getAllDownloadsWithMetadata, void(const QString&, |
2775 | + const QString&)); |
2776 | + MOCK_METHOD2(getAllDownloadsWithMetadata, void(const QString&, |
2777 | + const QString&, MetadataDownloadsListCb, MetadataDownloadsListCb)); |
2778 | + MOCK_CONST_METHOD0(isError, bool()); |
2779 | + MOCK_CONST_METHOD0(lastError, Error*()); |
2780 | + MOCK_METHOD1(allowMobileDataDownload, void(bool)); |
2781 | + MOCK_METHOD0(isMobileDataDownload, bool()); |
2782 | + MOCK_METHOD0(defaultThrottle, qulonglong()); |
2783 | + MOCK_METHOD1(setDefaultThrottle, void(qulonglong)); |
2784 | + MOCK_METHOD0(exit, void()); |
2785 | +}; |
2786 | + |
2787 | +#endif |
2788 | |
2789 | === added file 'tests/downloads/qml/test_single_download.cpp' |
2790 | --- tests/downloads/qml/test_single_download.cpp 1970-01-01 00:00:00 +0000 |
2791 | +++ tests/downloads/qml/test_single_download.cpp 2014-07-03 14:40:18 +0000 |
2792 | @@ -0,0 +1,31 @@ |
2793 | +/* |
2794 | + * Copyright 2014 Canonical Ltd. |
2795 | + * |
2796 | + * This library is free software; you can redistribute it and/or |
2797 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
2798 | + * License as published by the Free Software Foundation. |
2799 | + * |
2800 | + * This program is distributed in the hope that it will be useful, |
2801 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2802 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2803 | + * General Public License for more details. |
2804 | + * |
2805 | + * You should have received a copy of the GNU Lesser General Public |
2806 | + * License along with this library; if not, write to the |
2807 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
2808 | + * Boston, MA 02110-1301, USA. |
2809 | + */ |
2810 | + |
2811 | +TestSingleDownload::TestSingleDownload(QObject *parent) |
2812 | + : LocalTreeTestCase("TestSingleDownload", parent) { |
2813 | +} |
2814 | + |
2815 | +void |
2816 | +TestSingleDownload::init() { |
2817 | + LocalTreeTestCase::init(); |
2818 | +} |
2819 | + |
2820 | +void |
2821 | +TestSingleDownload::cleanup() { |
2822 | + LocalTreeTestCase::cleanup(); |
2823 | +} |
2824 | |
2825 | === added file 'tests/downloads/qml/test_single_download.h' |
2826 | --- tests/downloads/qml/test_single_download.h 1970-01-01 00:00:00 +0000 |
2827 | +++ tests/downloads/qml/test_single_download.h 2014-07-03 14:40:18 +0000 |
2828 | @@ -0,0 +1,38 @@ |
2829 | +/* |
2830 | + * Copyright 2014 Canonical Ltd. |
2831 | + * |
2832 | + * This library is free software; you can redistribute it and/or |
2833 | + * modify it under the terms of version 3 of the GNU Lesser General Public |
2834 | + * License as published by the Free Software Foundation. |
2835 | + * |
2836 | + * This program is distributed in the hope that it will be useful, |
2837 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2838 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2839 | + * General Public License for more details. |
2840 | + * |
2841 | + * You should have received a copy of the GNU Lesser General Public |
2842 | + * License along with this library; if not, write to the |
2843 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
2844 | + * Boston, MA 02110-1301, USA. |
2845 | + */ |
2846 | + |
2847 | +#ifndef TEST_DOWNLOAD_H |
2848 | +#define TEST_DOWNLOAD_H |
2849 | + |
2850 | +#include <QObject> |
2851 | +#include <singled_download.h> |
2852 | +#include <local_tree_testcase.h> |
2853 | + |
2854 | +using namespace Ubuntu::DownloadManager; |
2855 | + |
2856 | +class TestSingleDownload : public LocalTreeTestCase { |
2857 | + Q_OBJECT |
2858 | + |
2859 | + public: |
2860 | + explicit TestSingleDownload(QObject *parent = 0); |
2861 | + |
2862 | + void init() override; |
2863 | + void cleanup() override; |
2864 | +}; |
2865 | + |
2866 | +#endif |
PASSED: Continuous integration, rev:318 jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- ci/673/ jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- utopic- amd64-ci/ 32 jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- utopic- armhf-ci/ 32 jenkins. qa.ubuntu. com/job/ ubuntu- download- manager- utopic- armhf-ci/ 32/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- download- manager- ci/673/ rebuild
http://