Merge lp:~dobey/unity-scope-click/no-more-click into lp:unity-scope-click
- no-more-click
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | dobey |
Approved revision: | 509 |
Merged at revision: | 510 |
Proposed branch: | lp:~dobey/unity-scope-click/no-more-click |
Merge into: | lp:unity-scope-click |
Diff against target: |
3453 lines (+11/-2854) 28 files modified
CMakeLists.txt (+0/-7) bin/CMakeLists.txt (+0/-1) bin/install-helper (+0/-77) debian/control (+0/-9) debian/unity-scope-click.install (+0/-1) libclickscope/click/CMakeLists.txt (+0/-9) libclickscope/click/download-manager.cpp (+0/-177) libclickscope/click/download-manager.h (+0/-87) libclickscope/click/index.cpp (+0/-43) libclickscope/click/interface.cpp (+0/-90) libclickscope/click/interface.h (+0/-4) libclickscope/click/preview.cpp (+8/-610) libclickscope/click/preview.h (+0/-122) libclickscope/click/reviews.cpp (+0/-245) libclickscope/click/reviews.h (+0/-95) libclickscope/click/scope_activation.cpp (+0/-40) libclickscope/click/scope_activation.h (+0/-7) libclickscope/tests/CMakeLists.txt (+0/-5) libclickscope/tests/mock_ubuntu_download_manager.h (+0/-140) libclickscope/tests/test_bootstrap.cpp (+0/-1) libclickscope/tests/test_download_manager.cpp (+0/-220) libclickscope/tests/test_index.cpp (+0/-12) libclickscope/tests/test_interface.cpp (+0/-74) libclickscope/tests/test_preview.cpp (+0/-181) libclickscope/tests/test_reviews.cpp (+0/-487) scope/clickapps/apps-scope.cpp (+3/-42) scope/clickapps/apps-scope.h (+0/-2) scope/tests/test_apps_scope.cpp (+0/-66) |
To merge this branch: | bzr merge lp:~dobey/unity-scope-click/no-more-click |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Charles Kerr (community) | Approve | ||
unity-api-1-bot | continuous-integration | Approve | |
Review via email: mp+312754@code.launchpad.net |
Commit message
Remove deps on ubuntu-
Remove download-manager, installing, uninstalling, and reviews code.
Description of the change
unity-api-1-bot (unity-api-1-bot) wrote : | # |
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:505
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:506
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:506
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:507
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:507
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:508
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Charles Kerr (charlesk) : | # |
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2016-12-02 18:37:59 +0000 |
3 | +++ CMakeLists.txt 2017-01-10 16:06:37 +0000 |
4 | @@ -26,9 +26,6 @@ |
5 | pkg_check_modules(UAL REQUIRED ubuntu-app-launch-2>=0.9 gobject-2.0) |
6 | add_definitions(${UAL_CFLAGS} ${UAL_CFLAGS_OTHER}) |
7 | |
8 | -pkg_check_modules(CLICK REQUIRED click-0.4) |
9 | -add_definitions(${CLICK_CFLAGS} ${CLICK_CFLAGS_OTHER}) |
10 | - |
11 | pkg_check_modules(UNITY_SCOPES REQUIRED libunity-scopes>=0.6.7 libunity-api>=0.1.3) |
12 | add_definitions(${UNITY_SCOPES_CFLAGS} ${UNITY_SCOPES_CFLAGS_OTHER}) |
13 | |
14 | @@ -38,9 +35,6 @@ |
15 | pkg_check_modules(UBUNTUONE REQUIRED ubuntuoneauth-2.0>=15.10) |
16 | add_definitions(${UBUNTUONE_CFLAGS} ${UBUNTUONE_CFLAGS_OTHER}) |
17 | |
18 | -pkg_check_modules(UBUNTU_DOWNLOAD_MANAGER_CLIENT REQUIRED ubuntu-download-manager-client) |
19 | -pkg_check_modules(UBUNTU_DOWNLOAD_MANAGER_COMMON REQUIRED ubuntu-download-manager-common) |
20 | - |
21 | SET (SCOPE_LIB_VERSION 0.2.0) |
22 | SET (SCOPE_LIB_SOVERSION 0) |
23 | SET (SCOPE_LIB_API_VERSION 2.0) |
24 | @@ -50,7 +44,6 @@ |
25 | |
26 | # Add our own subdirectories. |
27 | add_subdirectory(tests) |
28 | -add_subdirectory(bin) |
29 | add_subdirectory(libclickscope) |
30 | add_subdirectory(scope) |
31 | add_subdirectory(data) |
32 | |
33 | === removed directory 'bin' |
34 | === removed file 'bin/CMakeLists.txt' |
35 | --- bin/CMakeLists.txt 2016-10-25 13:12:57 +0000 |
36 | +++ bin/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
37 | @@ -1,1 +0,0 @@ |
38 | -install(PROGRAMS install-helper DESTINATION lib/unity-scope-click/) |
39 | |
40 | === removed file 'bin/install-helper' |
41 | --- bin/install-helper 2014-06-20 05:09:01 +0000 |
42 | +++ bin/install-helper 1970-01-01 00:00:00 +0000 |
43 | @@ -1,77 +0,0 @@ |
44 | -#!/bin/bash |
45 | -# |
46 | -# Copyright (C) 2014 Canonical Ltd. |
47 | -# |
48 | -# This program is free software: you can redistribute it and/or modify it |
49 | -# under the terms of the GNU General Public License version 3, as published |
50 | -# by the Free Software Foundation. |
51 | -# |
52 | -# This program is distributed in the hope that it will be useful, but |
53 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
54 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
55 | -# PURPOSE. See the GNU General Public License for more details. |
56 | -# |
57 | -# You should have received a copy of the GNU General Public License along |
58 | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
59 | -# |
60 | -# In addition, as a special exception, the copyright holders give |
61 | -# permission to link the code of portions of this program with the |
62 | -# OpenSSL library under certain conditions as described in each |
63 | -# individual source file, and distribute linked combinations |
64 | -# including the two. |
65 | -# You must obey the GNU General Public License in all respects |
66 | -# for all of the code used other than OpenSSL. If you modify |
67 | -# file(s) with this exception, you may extend this exception to your |
68 | -# version of the file(s), but you are not obligated to do so. If you |
69 | -# do not wish to do so, delete this exception statement from your |
70 | -# version. If you delete this exception statement from all source |
71 | -# files in the program, then also delete it here. |
72 | -# |
73 | - |
74 | -FILE_NAME="$1" |
75 | -PACKAGE_NAME="$2" |
76 | - |
77 | -SCOPES_OBJECTPATH=/com/canonical/unity/scopes |
78 | -SCOPES_INTERFACE=com.canonical.unity.scopes |
79 | -SCOPES_METHOD=InvalidateResults |
80 | - |
81 | -LAUNCHER_BUS=com.ubuntu.unity.launcher |
82 | -LAUNCHER_OBJECTPATH=/com/ubuntu/unity/launcher/installations |
83 | -LAUNCHER_INTERFACE=com.ubuntu.unity.launcher.Installations |
84 | -LAUNCHER_METHOD=completeInstallation |
85 | - |
86 | -function invalidate-scope { |
87 | - SCOPE_ID=$1 |
88 | - dbus-send $SCOPES_OBJECTPATH $SCOPES_INTERFACE.$SCOPES_METHOD string:$SCOPE_ID |
89 | -} |
90 | - |
91 | -function install-package { |
92 | - FILE_NAME="$1" |
93 | - pkcon -p install-local "$FILE_NAME" |
94 | -} |
95 | - |
96 | -function app_id-from-package_name { |
97 | - PACKAGE_NAME=$1 |
98 | - IFS=_ |
99 | - TRIPLET=($(ubuntu-app-triplet $PACKAGE_NAME)) |
100 | - unset IFS |
101 | - echo ${TRIPLET[0]}_${TRIPLET[1]}_current-user-version |
102 | -} |
103 | - |
104 | -function complete-installation { |
105 | - PACKAGE_NAME=$1 |
106 | - APP_ID=$2 |
107 | - dbus-send --dest=$LAUNCHER_BUS --type=method_call $LAUNCHER_OBJECTPATH $LAUNCHER_INTERFACE.$LAUNCHER_METHOD string:$PACKAGE_NAME string:$APP_ID |
108 | -} |
109 | - |
110 | -if install-package "$FILE_NAME" ; then |
111 | - invalidate-scope clickscope |
112 | - invalidate-scope com.canonical.scopes.clickstore |
113 | - APP_ID=$(app_id-from-package_name $PACKAGE_NAME) |
114 | - complete-installation $PACKAGE_NAME $APP_ID |
115 | -else |
116 | - PKCON_STATUS=$? |
117 | - NO_APP_ID="" |
118 | - complete-installation $PACKAGE_NAME $NO_APP_ID |
119 | - exit $PKCON_STATUS |
120 | -fi |
121 | |
122 | === modified file 'debian/control' |
123 | --- debian/control 2016-12-21 15:27:35 +0000 |
124 | +++ debian/control 2017-01-10 16:06:37 +0000 |
125 | @@ -12,24 +12,19 @@ |
126 | intltool, |
127 | lcov, |
128 | libboost-locale-dev, |
129 | - libclick-0.4-dev, |
130 | libglib2.0-dev (>= 2.32), |
131 | libjsoncpp-dev, |
132 | libubuntu-app-launch2-dev (>= 0.9), |
133 | - libubuntu-download-manager-client-dev (>= 0.3+14.10.20140430-0ubuntu1), |
134 | - libubuntu-download-manager-common-dev (>= 0.3+14.10.20140430-0ubuntu1), |
135 | libubuntuoneauth-2.0-dev (>= 15.10), |
136 | libunity-api-dev (>= 7.80.7), |
137 | libunity-scopes-dev (>= 0.6.7~), |
138 | libgsettings-qt-dev, |
139 | - ubuntu-sdk-libs, |
140 | pkg-config, |
141 | python3-all:native, |
142 | python3-fixtures, |
143 | python3-scope-harness (>= 0.5.8), |
144 | python3-testtools, |
145 | xvfb, |
146 | - ubuntu-download-manager, |
147 | Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> |
148 | Standards-Version: 3.9.5 |
149 | Homepage: https://launchpad.net/unity-scope-click |
150 | @@ -42,10 +37,6 @@ |
151 | Depends: account-plugin-ubuntuone, |
152 | libglib2.0-bin, |
153 | libsqlite3-0 (>= 3.8.5), |
154 | - packagekit, |
155 | - packagekit-tools, |
156 | - ubuntu-app-launch-tools, |
157 | - ubuntu-download-manager, |
158 | ${misc:Depends}, |
159 | ${shlibs:Depends}, |
160 | Breaks: unity (<< 7.0), |
161 | |
162 | === modified file 'debian/unity-scope-click.install' |
163 | --- debian/unity-scope-click.install 2016-11-04 20:17:19 +0000 |
164 | +++ debian/unity-scope-click.install 2017-01-10 16:06:37 +0000 |
165 | @@ -1,5 +1,4 @@ |
166 | usr/lib/*/unity-scopes/* |
167 | -usr/lib/unity-scope-click/* |
168 | usr/share/unity/scopes/clickapps/*.jpg |
169 | usr/share/unity/scopes/clickapps/*.png |
170 | usr/share/unity/scopes/clickapps/*.svg |
171 | |
172 | === modified file 'libclickscope/click/CMakeLists.txt' |
173 | --- libclickscope/click/CMakeLists.txt 2016-10-24 21:26:23 +0000 |
174 | +++ libclickscope/click/CMakeLists.txt 2017-01-10 16:06:37 +0000 |
175 | @@ -8,13 +8,11 @@ |
176 | add_definitions( |
177 | -DGETTEXT_PACKAGE=\"${PROJECT_NAME}\" |
178 | -DGETTEXT_LOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LOCALEDIR}\" |
179 | - -DCLICK_INSTALL_HELPER=\"${CMAKE_INSTALL_PREFIX}/lib/unity-scope-click/install-helper\" |
180 | ${GSETTINGS_QT_CFLAGS} ${GSETTINGS_QT_OTHER} |
181 | ) |
182 | |
183 | add_library(${SCOPE_LIB_NAME} STATIC |
184 | configuration.cpp |
185 | - download-manager.cpp |
186 | department-lookup.cpp |
187 | departments.cpp |
188 | departments-db.cpp |
189 | @@ -25,7 +23,6 @@ |
190 | network_access_manager.cpp |
191 | package.cpp |
192 | preview.cpp |
193 | - reviews.cpp |
194 | qtbridge.cpp |
195 | scope_activation.cpp |
196 | smartconnect.cpp |
197 | @@ -38,22 +35,16 @@ |
198 | |
199 | include_directories( |
200 | ${JSON_CPP_INCLUDE_DIRS} |
201 | - ${LIBPAY_INCLUDE_DIRS} |
202 | ${GSETTINGS_QT_INCLUDE_DIRS} |
203 | ${UAL_INCLUDE_DIRS} |
204 | - ${CLICK_INCLUDE_DIRS} |
205 | ${CMAKE_SOURCE_DIR}/libclickscope |
206 | ) |
207 | |
208 | target_link_libraries (${SCOPE_LIB_NAME} |
209 | ${JSON_CPP_LDFLAGS} |
210 | - ${LIBPAY_LDFLAGS} |
211 | ${UNITY_SCOPES_LDFLAGS} |
212 | ${UBUNTUONE_LDFLAGS} |
213 | - ${UBUNTU_DOWNLOAD_MANAGER_CLIENT_LDFLAGS} |
214 | - ${UBUNTU_DOWNLOAD_MANAGER_COMMON_LDFLAGS} |
215 | ${GSETTINGS_QT_LIBRARIES} |
216 | ${UAL_LDFLAGS} |
217 | - ${CLICK_LDFLAGS} |
218 | -lboost_locale |
219 | ) |
220 | |
221 | === removed file 'libclickscope/click/download-manager.cpp' |
222 | --- libclickscope/click/download-manager.cpp 2016-05-10 13:42:12 +0000 |
223 | +++ libclickscope/click/download-manager.cpp 1970-01-01 00:00:00 +0000 |
224 | @@ -1,177 +0,0 @@ |
225 | -/* |
226 | - * Copyright (C) 2014-2016 Canonical Ltd. |
227 | - * |
228 | - * This program is free software: you can redistribute it and/or modify it |
229 | - * under the terms of the GNU General Public License version 3, as published |
230 | - * by the Free Software Foundation. |
231 | - * |
232 | - * This program is distributed in the hope that it will be useful, but |
233 | - * WITHOUT ANY WARRANTY; without even the implied warranties of |
234 | - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
235 | - * PURPOSE. See the GNU General Public License for more details. |
236 | - * |
237 | - * You should have received a copy of the GNU General Public License along |
238 | - * with this program. If not, see <http://www.gnu.org/licenses/>. |
239 | - * |
240 | - * In addition, as a special exception, the copyright holders give |
241 | - * permission to link the code of portions of this program with the |
242 | - * OpenSSL library under certain conditions as described in each |
243 | - * individual source file, and distribute linked combinations |
244 | - * including the two. |
245 | - * You must obey the GNU General Public License in all respects |
246 | - * for all of the code used other than OpenSSL. If you modify |
247 | - * file(s) with this exception, you may extend this exception to your |
248 | - * version of the file(s), but you are not obligated to do so. If you |
249 | - * do not wish to do so, delete this exception statement from your |
250 | - * version. If you delete this exception statement from all source |
251 | - * files in the program, then also delete it here. |
252 | - */ |
253 | - |
254 | -#include "download-manager.h" |
255 | - |
256 | -#include <QDebug> |
257 | -#include <QObject> |
258 | -#include <QString> |
259 | -#include <QStringBuilder> |
260 | -#include <QTimer> |
261 | - |
262 | -#include <click/qtbridge.h> |
263 | - |
264 | -namespace u1 = UbuntuOne; |
265 | -#include <click/ubuntuone_credentials.h> |
266 | -#include <token.h> |
267 | - |
268 | -namespace udm = Ubuntu::DownloadManager; |
269 | -#include <ubuntu/download_manager/download_struct.h> |
270 | -#include <ubuntu/download_manager/downloads_list.h> |
271 | -#include <ubuntu/download_manager/download.h> |
272 | -#include <ubuntu/download_manager/error.h> |
273 | - |
274 | -namespace click |
275 | -{ |
276 | - |
277 | -static const QString DOWNLOAD_APP_ID_KEY = "app_id"; |
278 | -static const QString DOWNLOAD_COMMAND_KEY = "post-download-command"; |
279 | - |
280 | -static const QString DOWNLOAD_COMMAND = CLICK_INSTALL_HELPER; |
281 | - |
282 | -static const QString DOWNLOAD_MANAGER_SHA512 = "sha512"; |
283 | - |
284 | -const QByteArray& CLICK_TOKEN_HEADER() |
285 | -{ |
286 | - static const QByteArray result("X-Click-Token"); |
287 | - return result; |
288 | -} |
289 | - |
290 | -DownloadManager::DownloadManager(const QSharedPointer<click::web::Client>& client, |
291 | - const QSharedPointer<udm::Manager>& manager) : |
292 | - client(client), |
293 | - dm(manager) |
294 | -{ |
295 | -} |
296 | - |
297 | -DownloadManager::~DownloadManager() |
298 | -{ |
299 | -} |
300 | - |
301 | -void DownloadManager::get_progress(const std::string& package_name, |
302 | - const std::function<void (std::string)>& callback) |
303 | -{ |
304 | - dm->getAllDownloadsWithMetadata(DOWNLOAD_APP_ID_KEY, |
305 | - QString::fromStdString(package_name), |
306 | - [callback, package_name](const QString& /*key*/, const QString& /*value*/, DownloadsList* downloads_list){ |
307 | - // got downloads matching metadata |
308 | - std::string object_path; |
309 | - auto downloads = downloads_list->downloads(); |
310 | - if (downloads.size() > 0) { |
311 | - auto download = downloads.at(0); |
312 | - object_path = download->id().toStdString(); |
313 | - } |
314 | - qDebug() << "Found object path" << QString::fromStdString(object_path) |
315 | - << "for package" << QString::fromStdString(package_name); |
316 | - if (downloads.size() > 1) { |
317 | - qWarning() << "More than one download with the same object path"; |
318 | - } |
319 | - callback(object_path); |
320 | - }, [callback, package_name](const QString& /*key*/, const QString& /*value*/, DownloadsList* /*downloads_list*/){ |
321 | - // no downloads found |
322 | - qDebug() << "No object path found for package" << QString::fromStdString(package_name); |
323 | - callback(""); |
324 | - }); |
325 | -} |
326 | - |
327 | -click::web::Cancellable DownloadManager::start(const std::string& url, |
328 | - const std::string& download_sha512, |
329 | - const std::string& package_name, |
330 | - const std::function<void (std::string, Error)>& callback) |
331 | -{ |
332 | - QSharedPointer<click::web::Response> response = client->call |
333 | - (url, "HEAD", true); |
334 | - |
335 | - QObject::connect(response.data(), &click::web::Response::finished, |
336 | - [this, callback, url, download_sha512, package_name, |
337 | - response](QString) { |
338 | - auto status = response->get_status_code(); |
339 | - if (status == 200) { |
340 | - auto clickToken = response->get_header(CLICK_TOKEN_HEADER().data()); |
341 | - qDebug() << "Received click token:" << clickToken.c_str(); |
342 | - QVariantMap metadata; |
343 | - |
344 | - QVariant commandline = QVariant(QStringList() << DOWNLOAD_COMMAND << "$file" << package_name.c_str()); |
345 | - metadata[DOWNLOAD_COMMAND_KEY] = commandline; |
346 | - metadata[DOWNLOAD_APP_ID_KEY] = package_name.c_str(); |
347 | - metadata["package_name"] = package_name.c_str(); |
348 | - |
349 | - QMap<QString, QString> headers; |
350 | - headers[CLICK_TOKEN_HEADER()] = clickToken.c_str(); |
351 | - |
352 | - udm::DownloadStruct downloadStruct(url.c_str(), |
353 | - download_sha512.c_str(), |
354 | - DOWNLOAD_MANAGER_SHA512, |
355 | - metadata, |
356 | - headers); |
357 | - |
358 | - dm->createDownload(downloadStruct, |
359 | - [callback](Download* download) { |
360 | - if (download->isError()) { |
361 | - auto error = download->error()->errorString().toUtf8().data(); |
362 | - qDebug() << "Received error from ubuntu-download-manager:" << error; |
363 | - callback(error, Error::DownloadInstallError); |
364 | - } else { |
365 | - download->start(); |
366 | - callback(download->id().toUtf8().data(), Error::NoError); |
367 | - } |
368 | - }, |
369 | - [callback](Download* download) { |
370 | - callback(download->error()->errorString().toUtf8().data(), |
371 | - Error::DownloadInstallError); |
372 | - }); |
373 | - } else { |
374 | - std::string error{"Unhandled HTTP response code: "}; |
375 | - error += status; |
376 | - callback(error, Error::DownloadInstallError); |
377 | - } |
378 | - }); |
379 | - QObject::connect(response.data(), &click::web::Response::error, |
380 | - [this, callback, package_name](QString error, int error_code) { |
381 | - qWarning() << QStringLiteral("Network error (%1) fetching click token for:").arg(error_code) << package_name.c_str(); |
382 | - switch(error_code) { |
383 | - case 401: |
384 | - case 403: |
385 | - client->invalidateCredentials(); |
386 | - callback(error.toUtf8().data(), Error::CredentialsError); |
387 | - break; |
388 | - default: |
389 | - callback(error.toUtf8().data(), Error::DownloadInstallError); |
390 | - } |
391 | - }); |
392 | - |
393 | - return click::web::Cancellable(response); |
394 | -} |
395 | - |
396 | -void DownloadManager::setCredentialsService(const QSharedPointer<click::CredentialsService>& credentialsService) |
397 | -{ |
398 | - sso = credentialsService; |
399 | -} |
400 | - |
401 | -} // namespace click |
402 | |
403 | === removed file 'libclickscope/click/download-manager.h' |
404 | --- libclickscope/click/download-manager.h 2016-02-26 18:51:22 +0000 |
405 | +++ libclickscope/click/download-manager.h 1970-01-01 00:00:00 +0000 |
406 | @@ -1,87 +0,0 @@ |
407 | -/* |
408 | - * Copyright (C) 2014-2016 Canonical Ltd. |
409 | - * |
410 | - * This program is free software: you can redistribute it and/or modify it |
411 | - * under the terms of the GNU General Public License version 3, as published |
412 | - * by the Free Software Foundation. |
413 | - * |
414 | - * This program is distributed in the hope that it will be useful, but |
415 | - * WITHOUT ANY WARRANTY; without even the implied warranties of |
416 | - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
417 | - * PURPOSE. See the GNU General Public License for more details. |
418 | - * |
419 | - * You should have received a copy of the GNU General Public License along |
420 | - * with this program. If not, see <http://www.gnu.org/licenses/>. |
421 | - * |
422 | - * In addition, as a special exception, the copyright holders give |
423 | - * permission to link the code of portions of this program with the |
424 | - * OpenSSL library under certain conditions as described in each |
425 | - * individual source file, and distribute linked combinations |
426 | - * including the two. |
427 | - * You must obey the GNU General Public License in all respects |
428 | - * for all of the code used other than OpenSSL. If you modify |
429 | - * file(s) with this exception, you may extend this exception to your |
430 | - * version of the file(s), but you are not obligated to do so. If you |
431 | - * do not wish to do so, delete this exception statement from your |
432 | - * version. If you delete this exception statement from all source |
433 | - * files in the program, then also delete it here. |
434 | - */ |
435 | - |
436 | -#ifndef CLICK_DOWNLOAD_MANAGER_H |
437 | -#define CLICK_DOWNLOAD_MANAGER_H |
438 | - |
439 | -#include <QDebug> |
440 | -#include <QNetworkReply> |
441 | -#include <QObject> |
442 | -#include <QString> |
443 | - |
444 | -#include <click/ubuntuone_credentials.h> |
445 | -#include <click/webclient.h> |
446 | - |
447 | -#include <ubuntu/download_manager/manager.h> |
448 | - |
449 | -using Ubuntu::DownloadManager::Download; |
450 | - |
451 | -namespace UbuntuOne |
452 | -{ |
453 | -class Token; |
454 | -} |
455 | - |
456 | -namespace click |
457 | -{ |
458 | -// The dbus-send command to refresh the search results in the dash. |
459 | -static const QString REFRESH_SCOPE_COMMAND = QStringLiteral("dbus-send /com/canonical/unity/scopes com.canonical.unity.scopes.InvalidateResults string:%1"); |
460 | -static const QString APPS_SCOPE_ID = QStringLiteral("clickscope"); |
461 | -static const QString STORE_SCOPE_ID = QStringLiteral("com.canonical.scopes.clickstore"); |
462 | - |
463 | -const QByteArray& CLICK_TOKEN_HEADER(); |
464 | - |
465 | - |
466 | -class DownloadManager |
467 | -{ |
468 | -public: |
469 | - enum class Error {NoError, CredentialsError, DownloadInstallError}; |
470 | - |
471 | - DownloadManager(const QSharedPointer<click::web::Client>& client, |
472 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager); |
473 | - virtual ~DownloadManager(); |
474 | - |
475 | - virtual void get_progress(const std::string& package_name, |
476 | - const std::function<void (std::string)>& callback); |
477 | - virtual click::web::Cancellable start(const std::string& url, |
478 | - const std::string& download_sha512, |
479 | - const std::string& package_name, |
480 | - const std::function<void (std::string, |
481 | - Error)>& callback); |
482 | - |
483 | - virtual void setCredentialsService(const QSharedPointer<click::CredentialsService>& credentialsService); |
484 | - |
485 | -protected: |
486 | - QSharedPointer<click::web::Client> client; |
487 | - QSharedPointer<Ubuntu::DownloadManager::Manager> dm; |
488 | - QSharedPointer<click::CredentialsService> sso; |
489 | -}; |
490 | - |
491 | -} |
492 | - |
493 | -#endif /* CLICK_DOWNLOAD_MANAGER_H */ |
494 | |
495 | === modified file 'libclickscope/click/index.cpp' |
496 | --- libclickscope/click/index.cpp 2016-04-26 10:56:47 +0000 |
497 | +++ libclickscope/click/index.cpp 2017-01-10 16:06:37 +0000 |
498 | @@ -36,7 +36,6 @@ |
499 | |
500 | #include <click/smartconnect.h> |
501 | |
502 | -#include <click/download-manager.h> |
503 | #include "index.h" |
504 | #include "interface.h" |
505 | #include "application.h" |
506 | @@ -46,48 +45,6 @@ |
507 | namespace click |
508 | { |
509 | |
510 | -void PackageManager::uninstall(const Package& package, |
511 | - std::function<void(int, std::string)> callback) |
512 | -{ |
513 | - std::string package_id = package.name + ";" + package.version + ";all;local:click"; |
514 | - std::string command = "pkcon -p remove " + package_id; |
515 | - execute_uninstall_command(command, callback); |
516 | -} |
517 | - |
518 | -void PackageManager::execute_uninstall_command(const std::string& command, |
519 | - std::function<void(int, std::string)> callback) |
520 | -{ |
521 | - QSharedPointer<QProcess> process(new QProcess()); |
522 | - |
523 | - typedef void(QProcess::*QProcessFinished)(int, QProcess::ExitStatus); |
524 | - typedef void(QProcess::*QProcessError)(QProcess::ProcessError); |
525 | - QObject::connect(process.data(), |
526 | - static_cast<QProcessFinished>(&QProcess::finished), |
527 | - [process, callback](int code, QProcess::ExitStatus status) { |
528 | - Q_UNUSED(status); |
529 | - qDebug() << "command finished with exit code:" << code; |
530 | - callback(code, process.data()->readAllStandardError().data()); |
531 | - if (code == 0) { |
532 | - invalidate_results(APPS_SCOPE_ID.toUtf8().data()); |
533 | - invalidate_results(STORE_SCOPE_ID.toUtf8().data()); |
534 | - } |
535 | - } ); |
536 | - QObject::connect(process.data(), |
537 | - static_cast<QProcessError>(&QProcess::error), |
538 | - [process, callback](QProcess::ProcessError error) { |
539 | - qCritical() << "error running command:" << error; |
540 | - callback(-255 + error, process.data()->readAllStandardError().data()); |
541 | - } ); |
542 | - qDebug() << "Running command:" << command.c_str(); |
543 | - process.data()->start(command.c_str()); |
544 | -} |
545 | - |
546 | -void PackageManager::invalidate_results(const std::string& scope_id) |
547 | -{ |
548 | - QProcess::execute(REFRESH_SCOPE_COMMAND.arg(scope_id.c_str())); |
549 | -} |
550 | - |
551 | - |
552 | Index::Index(const QSharedPointer<click::web::Client>& client, |
553 | const QSharedPointer<Configuration> configuration) : |
554 | client(client), configuration(configuration) |
555 | |
556 | === modified file 'libclickscope/click/interface.cpp' |
557 | --- libclickscope/click/interface.cpp 2016-10-04 17:35:15 +0000 |
558 | +++ libclickscope/click/interface.cpp 2017-01-10 16:06:37 +0000 |
559 | @@ -27,8 +27,6 @@ |
560 | * files in the program, then also delete it here. |
561 | */ |
562 | |
563 | -#include <click.h> |
564 | - |
565 | #include "interface.h" |
566 | |
567 | #include <QDebug> |
568 | @@ -343,39 +341,6 @@ |
569 | return icon_id; |
570 | } |
571 | |
572 | -Manifest manifest_from_json(const std::string& json) |
573 | -{ |
574 | - using namespace boost::property_tree; |
575 | - |
576 | - std::istringstream is(json); |
577 | - |
578 | - ptree pt; |
579 | - read_json(is, pt); |
580 | - |
581 | - Manifest manifest; |
582 | - |
583 | - manifest.name = pt.get<std::string>("name"); |
584 | - manifest.version = pt.get<std::string>("version"); |
585 | - manifest.removable = pt.get<bool>("_removable"); |
586 | - |
587 | - BOOST_FOREACH(ptree::value_type &sv, pt.get_child("hooks")) |
588 | - { |
589 | - // FIXME: "primary app or scope" for a package is not defined, |
590 | - // we just use the first one in the manifest: |
591 | - auto app_name = sv.second.get("desktop", ""); |
592 | - if (manifest.first_app_name.empty() && !app_name.empty()) { |
593 | - manifest.first_app_name = sv.first; |
594 | - } |
595 | - auto scope_id = sv.second.get("scope", ""); |
596 | - if (manifest.first_scope_id.empty() && !scope_id.empty()) { |
597 | - manifest.first_scope_id = manifest.name + "_" + sv.first; |
598 | - } |
599 | - } |
600 | - qDebug() << "adding manifest: " << manifest.name.c_str() << manifest.version.c_str() << manifest.first_app_name.c_str(); |
601 | - |
602 | - return manifest; |
603 | -} |
604 | - |
605 | void Interface::get_installed_packages(std::function<void(PackageSet, InterfaceError)> callback) |
606 | { |
607 | PackageSet packages; |
608 | @@ -391,59 +356,4 @@ |
609 | callback(packages, InterfaceError::NoError); |
610 | } |
611 | |
612 | -std::string Interface::get_manifest_json(const std::string &package) const |
613 | -{ |
614 | - GError* error = nullptr; |
615 | - |
616 | - std::shared_ptr<ClickDB> clickdb{click_db_new(), |
617 | - [](ClickDB* db){g_clear_object(&db);}}; |
618 | - click_db_read(clickdb.get(), nullptr, &error); |
619 | - if (error != nullptr) { |
620 | - qCritical() << "Error reading click DB:" << error->message; |
621 | - g_error_free(error); |
622 | - return ""; |
623 | - } |
624 | - |
625 | - std::shared_ptr<ClickUser> clickuser{click_user_new_for_user(clickdb.get(), |
626 | - nullptr, |
627 | - &error), |
628 | - [](ClickUser* cu){g_clear_object(&cu);}}; |
629 | - if (error != nullptr) { |
630 | - qCritical() << "Error setting up click user:" << error->message; |
631 | - g_error_free(error); |
632 | - return ""; |
633 | - } |
634 | - |
635 | - auto result = click_user_get_manifest_as_string(clickuser.get(), |
636 | - package.c_str(), |
637 | - &error); |
638 | - if (error != nullptr) { |
639 | - qCritical() << "Error getting manifest:" << error->message; |
640 | - g_error_free(error); |
641 | - return ""; |
642 | - } |
643 | - |
644 | - std::string retval; |
645 | - if (result != nullptr) { |
646 | - retval = result; |
647 | - g_free(result); |
648 | - } |
649 | - return retval; |
650 | -} |
651 | - |
652 | -void Interface::get_manifest_for_app(const std::string &app_id, |
653 | - std::function<void(Manifest, InterfaceError)> callback) |
654 | -{ |
655 | - Manifest manifest; |
656 | - InterfaceError error; |
657 | - try { |
658 | - manifest = manifest_from_json(get_manifest_json(app_id)); |
659 | - error = InterfaceError::NoError; |
660 | - } catch (...) { |
661 | - qWarning() << "Can't parse manifest for:" << QString::fromStdString(app_id); |
662 | - error = InterfaceError::ParseError; |
663 | - } |
664 | - callback(manifest, error); |
665 | -} |
666 | - |
667 | } // namespace click |
668 | |
669 | === modified file 'libclickscope/click/interface.h' |
670 | --- libclickscope/click/interface.h 2016-09-02 21:29:13 +0000 |
671 | +++ libclickscope/click/interface.h 2017-01-10 16:06:37 +0000 |
672 | @@ -77,8 +77,6 @@ |
673 | enum class InterfaceError {NoError, CallError, ParseError}; |
674 | typedef std::list<Manifest> ManifestList; |
675 | |
676 | -Manifest manifest_from_json(const std::string& json); |
677 | - |
678 | class Interface |
679 | { |
680 | public: |
681 | @@ -97,8 +95,6 @@ |
682 | static bool is_icon_identifier(const std::string &icon_id); |
683 | static std::string add_theme_scheme(const std::string &filename); |
684 | virtual void get_installed_packages(std::function<void(PackageSet, InterfaceError)> callback); |
685 | - virtual std::string get_manifest_json(const std::string &package) const; |
686 | - virtual void get_manifest_for_app(const std::string &app_id, std::function<void(Manifest, InterfaceError)> callback); |
687 | }; |
688 | |
689 | } // namespace click |
690 | |
691 | === modified file 'libclickscope/click/preview.cpp' |
692 | --- libclickscope/click/preview.cpp 2016-10-24 21:26:23 +0000 |
693 | +++ libclickscope/click/preview.cpp 2017-01-10 16:06:37 +0000 |
694 | @@ -31,7 +31,6 @@ |
695 | #include <click/interface.h> |
696 | #include "preview.h" |
697 | #include <click/qtbridge.h> |
698 | -#include <click/download-manager.h> |
699 | #include <click/launcher.h> |
700 | #include <click/dbus_constants.h> |
701 | #include <click/departments-db.h> |
702 | @@ -172,76 +171,20 @@ |
703 | } |
704 | |
705 | void Preview::choose_strategy(const QSharedPointer<web::Client> &client, |
706 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager, |
707 | std::shared_ptr<click::DepartmentsDb> depts) |
708 | { |
709 | - strategy.reset(build_strategy(result, metadata, client, manager, depts)); |
710 | -} |
711 | - |
712 | -PreviewStrategy* Preview::build_installing(const std::string& download_url, |
713 | - const std::string& download_sha512, |
714 | - const unity::scopes::Result& result, |
715 | - const QSharedPointer<click::web::Client>& client, |
716 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager, |
717 | - std::shared_ptr<click::DepartmentsDb> depts) |
718 | -{ |
719 | - return new InstallingPreview(download_url, download_sha512, result, client, manager, depts); |
720 | -} |
721 | - |
722 | + strategy.reset(build_strategy(result, metadata, client, depts)); |
723 | +} |
724 | |
725 | PreviewStrategy* Preview::build_strategy(const unity::scopes::Result &result, |
726 | const unity::scopes::ActionMetadata &metadata, |
727 | const QSharedPointer<web::Client> &client, |
728 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager, |
729 | std::shared_ptr<click::DepartmentsDb> depts) |
730 | { |
731 | - if (metadata.scope_data().which() != scopes::Variant::Type::Null) { |
732 | - auto metadict = metadata.scope_data().get_dict(); |
733 | - |
734 | - if (metadict.count(click::Preview::Actions::DOWNLOAD_FAILED) != 0) { |
735 | - return new DownloadErrorPreview(result); |
736 | - } else if (metadict.count(click::Preview::Actions::DOWNLOAD_COMPLETED) != 0 || |
737 | - metadict.count(click::Preview::Actions::SHOW_INSTALLED) != 0) { |
738 | - qDebug() << "in Scope::preview(), metadata has download_completed=" |
739 | - << metadict.count(click::Preview::Actions::DOWNLOAD_COMPLETED) |
740 | - << " and close_preview=" |
741 | - << metadict.count(click::Preview::Actions::SHOW_INSTALLED); |
742 | - |
743 | - return new InstalledPreview(result, metadata, client, depts); |
744 | - } else if (metadict.count("action_id") != 0 && metadict.count("download_url") != 0) { |
745 | - std::string action_id = metadict["action_id"].get_string(); |
746 | - std::string download_url = metadict["download_url"].get_string(); |
747 | - std::string download_sha512 = metadict["download_sha512"].get_string(); |
748 | - if (action_id == click::Preview::Actions::INSTALL_CLICK) { |
749 | - return build_installing(download_url, download_sha512, result, client, manager, depts); |
750 | - } else { |
751 | - qWarning() << "unexpected action id " << QString::fromStdString(action_id) |
752 | - << " given with download_url" << QString::fromStdString(download_url); |
753 | - return new UninstalledPreview(result, metadata, client, depts, manager); |
754 | - } |
755 | - } else if (metadict.count(click::Preview::Actions::UNINSTALL_CLICK) != 0) { |
756 | - return new UninstallConfirmationPreview(result); |
757 | - } else if (metadict.count(click::Preview::Actions::CONFIRM_UNINSTALL) != 0) { |
758 | - return new UninstallingPreview(result, metadata, client, manager); |
759 | - } else if (metadict.count(click::Preview::Actions::RATED) != 0) { |
760 | - return new InstalledPreview(result, metadata, client, depts); |
761 | - } else if (metadict.count(click::Preview::Actions::SHOW_UNINSTALLED) != 0) { |
762 | - return new UninstalledPreview(result, metadata, client, depts, manager); |
763 | - } else { |
764 | - qWarning() << "preview() called with unexpected metadata. returning uninstalled preview"; |
765 | - return new UninstalledPreview(result, metadata, client, depts, manager); |
766 | - } |
767 | + if (result.uri().find("scope://") == 0) { |
768 | + return new InstalledScopePreview(result); |
769 | } else { |
770 | - // metadata.scope_data() is Null, so we return an appropriate "default" preview: |
771 | - if (result.uri().find("scope://") == 0) |
772 | - { |
773 | - return new InstalledScopePreview(result); |
774 | - } |
775 | - if (result["installed"].get_bool() == true) { |
776 | - return new InstalledPreview(result, metadata, client, depts); |
777 | - } else { |
778 | - return new UninstalledPreview(result, metadata, client, depts, manager); |
779 | - } |
780 | + return new InstalledPreview(result, metadata, client, depts); |
781 | } |
782 | |
783 | } |
784 | @@ -271,7 +214,6 @@ |
785 | result(result), |
786 | client(client), |
787 | index(new click::Index(client)), |
788 | - reviews(new click::Reviews(client)), |
789 | oa_client("ubuntuone", "ubuntuone", "ubuntuone", |
790 | scopes::OnlineAccountClient::MainLoopSelect::CreateInternalMainLoop) |
791 | { |
792 | @@ -327,9 +269,6 @@ |
793 | void PreviewStrategy::cancelled() |
794 | { |
795 | index_operation.cancel(); |
796 | - reviews_operation.cancel(); |
797 | - submit_operation.cancel(); |
798 | - purchase_operation.cancel(); |
799 | } |
800 | |
801 | scopes::PreviewWidget PreviewStrategy::build_other_metadata(const PackageDetails &details) |
802 | @@ -396,8 +335,7 @@ |
803 | // return them from populateDetails and check them in the calling code |
804 | // to decide whether to show error widgets. see bug LP: #1289541 |
805 | void PreviewStrategy::populateDetails(std::function<void(const click::PackageDetails& details)> details_callback, |
806 | - std::function<void(const click::ReviewList&, |
807 | - click::Reviews::Error)> reviews_callback, bool force_cache) |
808 | + bool force_cache) |
809 | { |
810 | |
811 | std::string app_name = get_string_maybe_null(result["name"]); |
812 | @@ -410,15 +348,14 @@ |
813 | details.description = get_string_maybe_null(result["description"]); |
814 | details.main_screenshot_url = get_string_maybe_null(result["main_screenshot"]); |
815 | details_callback(details); |
816 | - reviews_callback(click::ReviewList(), click::Reviews::Error::NoError); |
817 | } else { |
818 | qDebug() << "in populateDetails(), app_name is:" << app_name.c_str(); |
819 | // I think this should not be required when we switch the click::Index over |
820 | // to using the Qt bridge. With that, the qt dependency becomes an implementation detail |
821 | // and code using it does not need to worry about threading/event loop topics. |
822 | - run_under_qt([this, details_callback, reviews_callback, app_name, force_cache]() |
823 | + run_under_qt([this, details_callback, app_name, force_cache]() |
824 | { |
825 | - index_operation = index->get_details(app_name, [this, app_name, details_callback, reviews_callback, force_cache](PackageDetails details, click::Index::Error error){ |
826 | + index_operation = index->get_details(app_name, [this, app_name, details_callback, force_cache](PackageDetails details, click::Index::Error error){ |
827 | if(error == click::Index::Error::NoError) { |
828 | qDebug() << "Got details:" << app_name.c_str(); |
829 | details_callback(details); |
830 | @@ -431,9 +368,6 @@ |
831 | details.main_screenshot_url = get_string_maybe_null(result["main_screenshot"]); |
832 | details_callback(details); |
833 | } |
834 | - reviews_operation = reviews->fetch_reviews(app_name, |
835 | - reviews_callback, |
836 | - force_cache); |
837 | }, force_cache); |
838 | }); |
839 | } |
840 | @@ -551,65 +485,6 @@ |
841 | return widgets; |
842 | } |
843 | |
844 | -scopes::PreviewWidgetList PreviewStrategy::reviewsWidgets(const click::ReviewList& reviewlist) |
845 | -{ |
846 | - scopes::PreviewWidgetList widgets; |
847 | - |
848 | - scopes::PreviewWidget rating("reviews", "reviews"); |
849 | - scopes::VariantBuilder builder; |
850 | - |
851 | - if (reviewlist.size() > 0) { |
852 | - scopes::PreviewWidget title("reviews_title", "text"); |
853 | - title.add_attribute_value("title", scopes::Variant(_("Reviews"))); |
854 | - widgets.push_back(title); |
855 | - |
856 | - for (const auto& kv : reviewlist) { |
857 | - builder.add_tuple({ |
858 | - {"rating", scopes::Variant(kv.rating)}, |
859 | - {"author", scopes::Variant(kv.reviewer_name)}, |
860 | - {"review", scopes::Variant(kv.review_text)} |
861 | - }); |
862 | - } |
863 | - rating.add_attribute_value("reviews", builder.end()); |
864 | - widgets.push_back(rating); |
865 | - } |
866 | - |
867 | - return widgets; |
868 | -} |
869 | - |
870 | -scopes::PreviewWidgetList PreviewStrategy::downloadErrorWidgets() |
871 | -{ |
872 | - return errorWidgets(scopes::Variant(_("Download Error")), |
873 | - scopes::Variant(_("Download or install failed. Please try again.")), |
874 | - scopes::Variant(click::Preview::Actions::SHOW_UNINSTALLED), |
875 | - scopes::Variant(_("Close"))); |
876 | -} |
877 | - |
878 | -scopes::PreviewWidgetList PreviewStrategy::loginErrorWidgets(const std::string& download_url, const std::string& download_sha512) |
879 | -{ |
880 | - auto widgets = errorWidgets(scopes::Variant(_("Login Error")), |
881 | - scopes::Variant(_("Please log in to your Ubuntu One account.")), |
882 | - scopes::Variant(click::Preview::Actions::INSTALL_CLICK), |
883 | - scopes::Variant(_("Go to Accounts"))); |
884 | - auto buttons = widgets.back(); |
885 | - widgets.pop_back(); |
886 | - |
887 | - scopes::VariantBuilder builder; |
888 | - builder.add_tuple( |
889 | - { |
890 | - {"id", scopes::Variant(click::Preview::Actions::INSTALL_CLICK)}, |
891 | - {"label", scopes::Variant(_("Go to Accounts"))}, |
892 | - {"download_url", scopes::Variant(download_url)}, |
893 | - {"download_sha512", scopes::Variant(download_sha512)}, |
894 | - }); |
895 | - buttons.add_attribute_value("actions", builder.end()); |
896 | - oa_client.register_account_login_item(buttons, |
897 | - scopes::OnlineAccountClient::PostLoginAction::ContinueActivation, |
898 | - scopes::OnlineAccountClient::PostLoginAction::DoNothing); |
899 | - widgets.push_back(buttons); |
900 | - return widgets; |
901 | -} |
902 | - |
903 | scopes::PreviewWidgetList PreviewStrategy::errorWidgets(const scopes::Variant& title, |
904 | const scopes::Variant& summary, |
905 | const scopes::Variant& action_id, |
906 | @@ -639,129 +514,6 @@ |
907 | return widgets; |
908 | } |
909 | |
910 | -void PreviewStrategy::invalidateScope(const std::string& scope_id) |
911 | -{ |
912 | - run_under_qt([scope_id]() { |
913 | - PackageManager::invalidate_results(scope_id); |
914 | - }); |
915 | -} |
916 | - |
917 | -// class DownloadErrorPreview |
918 | - |
919 | -DownloadErrorPreview::DownloadErrorPreview(const unity::scopes::Result &result) |
920 | - : PreviewStrategy(result) |
921 | -{ |
922 | -} |
923 | - |
924 | -DownloadErrorPreview::~DownloadErrorPreview() |
925 | -{ |
926 | - |
927 | -} |
928 | - |
929 | -void DownloadErrorPreview::run(const unity::scopes::PreviewReplyProxy &reply) |
930 | -{ |
931 | - // NOTE: no details used by downloadErrorWidgets(), so no need to |
932 | - // call populateDetails() here. |
933 | - reply->push(downloadErrorWidgets()); |
934 | -} |
935 | - |
936 | -// class InstallingPreview |
937 | - |
938 | -InstallingPreview::InstallingPreview(const std::string &download_url, |
939 | - const std::string &download_sha512, |
940 | - const unity::scopes::Result &result, |
941 | - const QSharedPointer<click::web::Client>& client, |
942 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager, |
943 | - std::shared_ptr<click::DepartmentsDb> depts) : |
944 | - PreviewStrategy(result, client), |
945 | - DepartmentUpdater(depts), |
946 | - download_url(download_url), |
947 | - download_sha512(download_sha512), |
948 | - dm(new DownloadManager(client, manager)), |
949 | - depts_db(depts) |
950 | -{ |
951 | -} |
952 | - |
953 | -InstallingPreview::~InstallingPreview() |
954 | -{ |
955 | -} |
956 | - |
957 | -void InstallingPreview::startLauncherAnimation(const PackageDetails &details) |
958 | -{ |
959 | - Launcher l(LAUNCHER_BUSNAME, LAUNCHER_OBJECT_PATH, QDBusConnection::sessionBus()); |
960 | - l.startInstallation(QString::fromStdString(details.package.title), |
961 | - QString::fromStdString(details.package.icon_url), |
962 | - QString::fromStdString(details.package.name)); |
963 | - |
964 | -} |
965 | - |
966 | -void InstallingPreview::run(const unity::scopes::PreviewReplyProxy &reply) |
967 | -{ |
968 | - qDebug() << "Starting installation" << QString(download_url.c_str()) << QString(download_sha512.c_str()); |
969 | - std::promise<bool> promise; |
970 | - auto future = promise.get_future(); |
971 | - run_under_qt([this, reply, &promise]() { |
972 | - dm->start(download_url, download_sha512, result["name"].get_string(), |
973 | - [this, reply, &promise] (std::string msg, DownloadManager::Error dmerr){ |
974 | - switch (dmerr) |
975 | - { |
976 | - case DownloadManager::Error::DownloadInstallError: |
977 | - qWarning() << "Error received from UDM during startDownload:" << msg.c_str(); |
978 | - reply->push(downloadErrorWidgets()); |
979 | - promise.set_value(false); |
980 | - break; |
981 | - case DownloadManager::Error::CredentialsError: |
982 | - qWarning() << "InstallingPreview got error in getting credentials during startDownload"; |
983 | - reply->push(loginErrorWidgets(download_url, download_sha512)); |
984 | - promise.set_value(false); |
985 | - break; |
986 | - case DownloadManager::Error::NoError: { |
987 | - std::string object_path = msg; |
988 | - qDebug() << "Successfully created UDM Download."; |
989 | - populateDetails([this, reply, object_path](const PackageDetails &details) { |
990 | - store_department(details); |
991 | - pushPackagePreviewWidgets(cachedWidgets, details, progressBarWidget(object_path)); |
992 | - startLauncherAnimation(details); |
993 | - }, |
994 | - [this, reply, &promise](const ReviewList& reviewlist, |
995 | - click::Reviews::Error error) { |
996 | - if (error == click::Reviews::Error::NoError) { |
997 | - auto const revs = reviewsWidgets(reviewlist); |
998 | - cachedWidgets.push(revs); |
999 | - cachedWidgets.layout.appendToColumn(cachedWidgets.layout.singleColumn.column1, revs); |
1000 | - cachedWidgets.layout.appendToColumn(cachedWidgets.layout.twoColumns.column1, revs); |
1001 | - } else { |
1002 | - qDebug() << "There was an error getting reviews for:" << result["name"].get_string().c_str(); |
1003 | - } |
1004 | - cachedWidgets.flush(reply); |
1005 | - promise.set_value(true); |
1006 | - }); |
1007 | - break; |
1008 | - } |
1009 | - default: |
1010 | - qCritical() << "Unknown error occurred downloading."; |
1011 | - promise.set_value(false); |
1012 | - break; |
1013 | - } |
1014 | - }); |
1015 | - }); |
1016 | - future.get(); |
1017 | - reply->finished(); |
1018 | -} |
1019 | - |
1020 | -scopes::PreviewWidgetList PreviewStrategy::progressBarWidget(const std::string& object_path) |
1021 | -{ |
1022 | - scopes::PreviewWidgetList widgets; |
1023 | - scopes::PreviewWidget progress("download", "progress"); |
1024 | - scopes::VariantMap tuple; |
1025 | - tuple["dbus-name"] = "com.canonical.applications.Downloader"; |
1026 | - tuple["dbus-object"] = object_path; |
1027 | - progress.add_attribute_value("source", scopes::Variant(tuple)); |
1028 | - widgets.push_back(progress); |
1029 | - |
1030 | - return widgets; |
1031 | -} |
1032 | - |
1033 | // class InstalledPreview |
1034 | |
1035 | InstalledPreview::InstalledPreview(const unity::scopes::Result& result, |
1036 | @@ -778,163 +530,18 @@ |
1037 | { |
1038 | } |
1039 | |
1040 | -std::string InstalledPreview::get_consumer_key() |
1041 | -{ |
1042 | - std::promise<std::string> promise; |
1043 | - auto future = promise.get_future(); |
1044 | - QSharedPointer<click::CredentialsService> sso; |
1045 | - |
1046 | - qt::core::world::enter_with_task([this, &sso, &promise]() { |
1047 | - sso.reset(new click::CredentialsService()); |
1048 | - |
1049 | - QObject::connect(sso.data(), &click::CredentialsService::credentialsFound, |
1050 | - [&promise, &sso](const UbuntuOne::Token& token) { |
1051 | - qDebug() << "Credentials found"; |
1052 | - sso.clear(); |
1053 | - try { |
1054 | - promise.set_value(token.consumerKey().toStdString()); |
1055 | - } catch (const std::future_error&) { |
1056 | - // Ignore promise_already_satisfied |
1057 | - } |
1058 | - }); |
1059 | - QObject::connect(sso.data(), &click::CredentialsService::credentialsNotFound, |
1060 | - [&promise, &sso]() { |
1061 | - qDebug() << "No credentials found"; |
1062 | - sso.clear(); |
1063 | - try { |
1064 | - promise.set_value(""); |
1065 | - } catch (const std::future_error&) { |
1066 | - // Ignore promise_already_satisfied |
1067 | - } |
1068 | - }); |
1069 | - |
1070 | - sso->getCredentials(); |
1071 | - qDebug() << "getCredentials finished"; |
1072 | - }); |
1073 | - return future.get(); |
1074 | -} |
1075 | - |
1076 | -scopes::PreviewWidget InstalledPreview::createRatingWidget(const click::Review& review) const |
1077 | -{ |
1078 | - scopes::PreviewWidget rating("rating", "rating-input"); |
1079 | - |
1080 | - if (review.id != 0) { |
1081 | - qDebug() << "Review for current user already exists, review id:" << review.id; |
1082 | - rating = scopes::PreviewWidget(std::to_string(review.id), "rating-edit"); // pass review id via widget id |
1083 | - rating.add_attribute_value("review", scopes::Variant(review.review_text)); |
1084 | - rating.add_attribute_value("rating", scopes::Variant(review.rating)); |
1085 | - rating.add_attribute_value("author", scopes::Variant(review.reviewer_name)); |
1086 | - } |
1087 | - |
1088 | - return rating; |
1089 | -} |
1090 | - |
1091 | void InstalledPreview::run(unity::scopes::PreviewReplyProxy const& reply) |
1092 | { |
1093 | const bool force_cache = (metadata.internet_connectivity() == scopes::QueryMetadata::ConnectivityStatus::Disconnected); |
1094 | qDebug() << "preview, force_cache=" << force_cache << ", conn status=" << (int)metadata.internet_connectivity(); |
1095 | |
1096 | - // Check if the user is submitting a rating, so we can submit it. |
1097 | - Review review; |
1098 | - review.rating = 0; |
1099 | - std::string widget_id; |
1100 | - // We use a try/catch here, as scope_data() can be a dict, but not have |
1101 | - // the values we need, which will result in an exception thrown. |
1102 | - try { |
1103 | - auto metadict = metadata.scope_data().get_dict(); |
1104 | - review.rating = metadict["rating"].get_int(); |
1105 | - review.review_text = metadict["review"].get_string(); |
1106 | - widget_id = metadict["widget_id"].get_string(); |
1107 | - } catch(...) { |
1108 | - // Do nothing as we are not submitting a review. |
1109 | - } |
1110 | - |
1111 | - auto userid = get_consumer_key(); |
1112 | - |
1113 | - // |
1114 | // Get the click manifest. |
1115 | Manifest manifest; |
1116 | - std::promise<Manifest> manifest_promise; |
1117 | - std::future<Manifest> manifest_future = manifest_promise.get_future(); |
1118 | std::string app_name = result["name"].get_string(); |
1119 | - if (!app_name.empty() && !std::regex_match(app_name, desktop_match)) { |
1120 | - qt::core::world::enter_with_task([&]() { |
1121 | - click::Interface().get_manifest_for_app(app_name, |
1122 | - [&](Manifest found_manifest, InterfaceError error) { |
1123 | - qDebug() << "Got manifest for:" << app_name.c_str(); |
1124 | - |
1125 | - // Fill in required data about the package being reviewed. |
1126 | - review.package_name = found_manifest.name; |
1127 | - review.package_version = found_manifest.version; |
1128 | - |
1129 | - if (error != click::InterfaceError::NoError) { |
1130 | - qDebug() << "There was an error getting the manifest for:" << app_name.c_str(); |
1131 | - } |
1132 | - manifest_promise.set_value(found_manifest); |
1133 | - }); |
1134 | - }); |
1135 | - manifest = manifest_future.get(); |
1136 | - if (review.rating > 0) { |
1137 | - std::promise<bool> submit_promise; |
1138 | - std::future<bool> submit_future = submit_promise.get_future(); |
1139 | - qt::core::world::enter_with_task([this, review, &submit_promise, widget_id]() mutable { |
1140 | - if (widget_id == "rating") { |
1141 | - submit_operation = reviews->submit_review(review, |
1142 | - [&submit_promise](click::Reviews::Error){ |
1143 | - // TODO: Need to handle errors properly. |
1144 | - submit_promise.set_value(true); |
1145 | - }); |
1146 | - |
1147 | - } else { |
1148 | - try { |
1149 | - review.id = std::stoul(widget_id); |
1150 | - qDebug() << "Updating review" << review.id << "with '" << QString::fromStdString(review.review_text) << "'"; |
1151 | - submit_operation = reviews->edit_review(review, |
1152 | - [&submit_promise](click::Reviews::Error){ |
1153 | - // TODO: Need to handle errors properly. |
1154 | - submit_promise.set_value(true); |
1155 | - }); |
1156 | - } catch (const std::exception &e) { |
1157 | - qWarning() << "Failed to update review:" << QString::fromStdString(e.what()) << " review widget:" << QString::fromStdString(widget_id); |
1158 | - submit_promise.set_value(false); |
1159 | - } |
1160 | - } |
1161 | - }); |
1162 | - submit_future.get(); |
1163 | - } |
1164 | - } |
1165 | populateDetails([this, reply, manifest, app_name](const PackageDetails &details){ |
1166 | cachedDetails = details; |
1167 | store_department(details); |
1168 | pushPackagePreviewWidgets(cachedWidgets, details, createButtons(manifest)); |
1169 | - }, |
1170 | - [this, reply, &review, manifest, userid](const ReviewList& reviewlist, |
1171 | - click::Reviews::Error error) { |
1172 | - auto reviews = bring_to_front(reviewlist, userid); |
1173 | - if (manifest.removable && !cachedDetails.download_url.empty()) { |
1174 | - scopes::PreviewWidgetList review_input; |
1175 | - bool has_reviewed = reviews.size() > 0 && reviews.front().reviewer_username == userid; |
1176 | - |
1177 | - Review existing_review; |
1178 | - existing_review.id = 0; |
1179 | - if (has_reviewed) { |
1180 | - existing_review = reviews.front(); |
1181 | - reviews.pop_front(); |
1182 | - } |
1183 | - review_input.push_back(createRatingWidget(existing_review)); |
1184 | - cachedWidgets.push(review_input); |
1185 | - cachedWidgets.layout.appendToColumn(cachedWidgets.layout.singleColumn.column1, review_input); |
1186 | - cachedWidgets.layout.appendToColumn(cachedWidgets.layout.twoColumns.column1, review_input); |
1187 | - } |
1188 | - |
1189 | - if (error == click::Reviews::Error::NoError) { |
1190 | - auto const revs = reviewsWidgets(reviews); |
1191 | - cachedWidgets.push(revs); |
1192 | - cachedWidgets.layout.appendToColumn(cachedWidgets.layout.singleColumn.column1, revs); |
1193 | - cachedWidgets.layout.appendToColumn(cachedWidgets.layout.twoColumns.column1, revs); |
1194 | - } else { |
1195 | - qDebug() << "There was an error getting reviews for:" << result["name"].get_string().c_str(); |
1196 | - } |
1197 | cachedWidgets.flush(reply); |
1198 | reply->finished(); |
1199 | }, force_cache); |
1200 | @@ -965,16 +572,6 @@ |
1201 | qDebug() << "Adding button" << QString::fromStdString(open_label) << "-" |
1202 | << QString::fromStdString(uri); |
1203 | } |
1204 | - if (manifest.removable) |
1205 | - { |
1206 | - auto price = result.contains("price") ? result["price"].get_double() : 0.00f; |
1207 | - if (price == 0.00f) { |
1208 | - builder.add_tuple({ |
1209 | - {"id", scopes::Variant(click::Preview::Actions::UNINSTALL_CLICK)}, |
1210 | - {"label", scopes::Variant(_("Uninstall"))} |
1211 | - }); |
1212 | - } |
1213 | - } |
1214 | if (!uri.empty() || manifest.removable) { |
1215 | buttons.add_attribute_value("actions", builder.end()); |
1216 | widgets.push_back(buttons); |
1217 | @@ -1032,203 +629,4 @@ |
1218 | reply->push({actions}); |
1219 | } |
1220 | |
1221 | -// class PurchasingPreview |
1222 | - |
1223 | -PurchasingPreview::PurchasingPreview(const unity::scopes::Result& result, |
1224 | - const QSharedPointer<click::web::Client>& client) |
1225 | - : PreviewStrategy(result, client) |
1226 | -{ |
1227 | -} |
1228 | - |
1229 | -PurchasingPreview::~PurchasingPreview() |
1230 | -{ |
1231 | -} |
1232 | - |
1233 | -void PurchasingPreview::run(unity::scopes::PreviewReplyProxy const& reply) |
1234 | -{ |
1235 | - populateDetails([this, reply](const PackageDetails &details){ |
1236 | - reply->push(purchasingWidgets(details)); |
1237 | - }, |
1238 | - [this, reply](const click::ReviewList&, click::Reviews::Error) { |
1239 | - reply->finished(); |
1240 | - }); |
1241 | -} |
1242 | - |
1243 | -scopes::PreviewWidgetList PurchasingPreview::purchasingWidgets(const PackageDetails &/*details*/) |
1244 | -{ |
1245 | - scopes::PreviewWidgetList widgets; |
1246 | - return widgets; |
1247 | -} |
1248 | - |
1249 | -// class UninstallConfirmationPreview |
1250 | - |
1251 | -UninstallConfirmationPreview::UninstallConfirmationPreview(const unity::scopes::Result& result) |
1252 | - : PreviewStrategy(result) |
1253 | -{ |
1254 | -} |
1255 | - |
1256 | -UninstallConfirmationPreview::~UninstallConfirmationPreview() |
1257 | -{ |
1258 | -} |
1259 | - |
1260 | -void UninstallConfirmationPreview::run(unity::scopes::PreviewReplyProxy const& reply) |
1261 | -{ |
1262 | - // NOTE: no need to populateDetails() here. |
1263 | - scopes::PreviewWidgetList widgets; |
1264 | - |
1265 | - scopes::PreviewWidget header("hdr", "header"); |
1266 | - header.add_attribute_value("title", scopes::Variant(_("Confirmation"))); |
1267 | - std::string title = result["title"].get_string(); |
1268 | - // TRANSLATORS: Do NOT translate ${title} here. |
1269 | - std::string message = _("Uninstall ${title}?"); |
1270 | - boost::replace_first(message, "${title}", title); |
1271 | - header.add_attribute_value("subtitle", scopes::Variant(message)); |
1272 | - widgets.push_back(header); |
1273 | - |
1274 | - scopes::PreviewWidget buttons("buttons", "actions"); |
1275 | - scopes::VariantBuilder builder; |
1276 | - builder.add_tuple({ |
1277 | - {"id", scopes::Variant(click::Preview::Actions::SHOW_INSTALLED)}, |
1278 | - {"label", scopes::Variant(_("Cancel"))} |
1279 | - }); |
1280 | - builder.add_tuple({ |
1281 | - {"id", scopes::Variant(click::Preview::Actions::CONFIRM_UNINSTALL)}, |
1282 | - {"label", scopes::Variant(_("Confirm"))} |
1283 | - }); |
1284 | - buttons.add_attribute_value("actions", builder.end()); |
1285 | - widgets.push_back(buttons); |
1286 | - |
1287 | - reply->push(widgets); |
1288 | -} |
1289 | - |
1290 | -// class UninstalledPreview |
1291 | - |
1292 | -UninstalledPreview::UninstalledPreview(const unity::scopes::Result& result, |
1293 | - const unity::scopes::ActionMetadata& metadata, |
1294 | - const QSharedPointer<click::web::Client>& client, |
1295 | - const std::shared_ptr<click::DepartmentsDb>& depts, |
1296 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager) |
1297 | - : PreviewStrategy(result, client), |
1298 | - DepartmentUpdater(depts), |
1299 | - metadata(metadata), |
1300 | - dm(new DownloadManager(client, manager)) |
1301 | -{ |
1302 | - qDebug() << "Creating new UninstalledPreview for result" << QString::fromStdString(result["name"].get_string()); |
1303 | -} |
1304 | - |
1305 | -UninstalledPreview::~UninstalledPreview() |
1306 | -{ |
1307 | -} |
1308 | - |
1309 | -void UninstalledPreview::run(unity::scopes::PreviewReplyProxy const& reply) |
1310 | -{ |
1311 | - const bool force_cache = (metadata.internet_connectivity() == scopes::QueryMetadata::ConnectivityStatus::Disconnected); |
1312 | - qDebug() << "preview, force_cache=" << force_cache << ", conn status=" << (int)metadata.internet_connectivity(); |
1313 | - |
1314 | - qDebug() << "in UninstalledPreview::run, about to populate details"; |
1315 | - populateDetails([this, reply](const PackageDetails &details){ |
1316 | - store_department(details); |
1317 | - found_details = details; |
1318 | - }, |
1319 | - [this, reply](const ReviewList& reviewlist, |
1320 | - click::Reviews::Error reviewserror) { |
1321 | - std::string app_name = result["name"].get_string(); |
1322 | - dm->get_progress(app_name, |
1323 | - [this, reply, reviewlist, reviewserror](std::string object_path){ |
1324 | - found_object_path = object_path; |
1325 | - scopes::PreviewWidgetList button_widgets; |
1326 | - if(found_object_path.empty()) { |
1327 | - button_widgets = uninstalledActionButtonWidgets(found_details); |
1328 | - } else { |
1329 | - button_widgets = progressBarWidget(found_object_path); |
1330 | - } |
1331 | - qDebug() << "Pushed button action widgets."; |
1332 | - pushPackagePreviewWidgets(cachedWidgets, found_details, button_widgets); |
1333 | - qDebug() << "Pushed package details widgets."; |
1334 | - if (reviewserror == click::Reviews::Error::NoError) { |
1335 | - qDebug() << "Pushing reviews widgets."; |
1336 | - auto const revs = reviewsWidgets(reviewlist); |
1337 | - cachedWidgets.push(revs); |
1338 | - cachedWidgets.layout.appendToColumn(cachedWidgets.layout.singleColumn.column1, revs); |
1339 | - cachedWidgets.layout.appendToColumn(cachedWidgets.layout.twoColumns.column1, revs); |
1340 | - } else { |
1341 | - qDebug() << "There was an error getting reviews for:" << result["name"].get_string().c_str(); |
1342 | - } |
1343 | - cachedWidgets.flush(reply); |
1344 | - reply->finished(); |
1345 | - qDebug() << "---------- Finished reply for:" << result["name"].get_string().c_str(); |
1346 | - }); |
1347 | - }, force_cache); |
1348 | -} |
1349 | - |
1350 | -scopes::PreviewWidgetList UninstalledPreview::uninstalledActionButtonWidgets(const PackageDetails &details) |
1351 | -{ |
1352 | - scopes::PreviewWidgetList widgets; |
1353 | - auto price = result["price"].get_double(); |
1354 | - |
1355 | - if (price == double(0.00) |
1356 | - || result["purchased"].get_bool() == false) { |
1357 | - scopes::PreviewWidget buttons("buttons", "actions"); |
1358 | - scopes::VariantBuilder builder; |
1359 | - builder.add_tuple( |
1360 | - { |
1361 | - {"id", scopes::Variant(click::Preview::Actions::INSTALL_CLICK)}, |
1362 | - {"label", scopes::Variant(_("Install"))}, |
1363 | - {"download_url", scopes::Variant(details.download_url)}, |
1364 | - {"download_sha512", scopes::Variant(details.download_sha512)}, |
1365 | - }); |
1366 | - buttons.add_attribute_value("actions", builder.end()); |
1367 | - oa_client.register_account_login_item(buttons, |
1368 | - scopes::OnlineAccountClient::PostLoginAction::ContinueActivation, |
1369 | - scopes::OnlineAccountClient::PostLoginAction::DoNothing); |
1370 | - widgets.push_back(buttons); |
1371 | - } |
1372 | - |
1373 | - return widgets; |
1374 | -} |
1375 | - |
1376 | -// class UninstallingPreview : public UninstalledPreview |
1377 | - |
1378 | -// TODO: this class should be removed once uninstall() is handled elsewhere. |
1379 | -UninstallingPreview::UninstallingPreview(const unity::scopes::Result& result, |
1380 | - const unity::scopes::ActionMetadata& metadata, |
1381 | - const QSharedPointer<click::web::Client>& client, |
1382 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager) |
1383 | - : UninstalledPreview(result, metadata, client, nullptr, manager) |
1384 | -{ |
1385 | -} |
1386 | - |
1387 | -UninstallingPreview::~UninstallingPreview() |
1388 | -{ |
1389 | -} |
1390 | - |
1391 | -void UninstallingPreview::run(unity::scopes::PreviewReplyProxy const& reply) |
1392 | -{ |
1393 | - qDebug() << "in UninstallingPreview::run, calling uninstall"; |
1394 | - uninstall(); |
1395 | - qDebug() << "in UninstallingPreview::run, calling UninstalledPreview::run()"; |
1396 | - UninstalledPreview::run(reply); |
1397 | -} |
1398 | - |
1399 | -void UninstallingPreview::uninstall() |
1400 | -{ |
1401 | - click::Package package; |
1402 | - package.title = result.title(); |
1403 | - package.name = result["name"].get_string(); |
1404 | - package.version = result["version"].get_string(); |
1405 | - qt::core::world::enter_with_task([this, package] () |
1406 | - { |
1407 | - click::PackageManager manager; |
1408 | - manager.uninstall(package, [&](int code, std::string stderr_content) { |
1409 | - if (code != 0) { |
1410 | - qDebug() << "Error removing package:" << stderr_content.c_str(); |
1411 | - } else { |
1412 | - qDebug() << "successfully removed package"; |
1413 | - |
1414 | - } |
1415 | - } ); |
1416 | - }); |
1417 | -} |
1418 | - |
1419 | - |
1420 | } // namespace click |
1421 | |
1422 | === modified file 'libclickscope/click/preview.h' |
1423 | --- libclickscope/click/preview.h 2016-10-24 21:26:23 +0000 |
1424 | +++ libclickscope/click/preview.h 2017-01-10 16:06:37 +0000 |
1425 | @@ -31,9 +31,7 @@ |
1426 | #define CLICKPREVIEW_H |
1427 | |
1428 | #include <click/index.h> |
1429 | -#include <click/download-manager.h> |
1430 | #include <click/qtbridge.h> |
1431 | -#include "reviews.h" |
1432 | |
1433 | #include <click/network_access_manager.h> |
1434 | |
1435 | @@ -105,14 +103,7 @@ |
1436 | PreviewStrategy* build_strategy(const unity::scopes::Result& result, |
1437 | const unity::scopes::ActionMetadata& metadata, |
1438 | const QSharedPointer<web::Client> &client, |
1439 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager, |
1440 | std::shared_ptr<click::DepartmentsDb> depts); |
1441 | - virtual PreviewStrategy* build_installing(const std::string& download_url, |
1442 | - const std::string& download_sha512, |
1443 | - const unity::scopes::Result& result, |
1444 | - const QSharedPointer<click::web::Client>& client, |
1445 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager, |
1446 | - std::shared_ptr<click::DepartmentsDb> depts); |
1447 | public: |
1448 | UNITY_DEFINES_PTRS(Preview); |
1449 | struct Actions |
1450 | @@ -145,7 +136,6 @@ |
1451 | std::shared_future<void> const& qt_ready = std::future<void>()); |
1452 | virtual ~Preview(); |
1453 | void choose_strategy(const QSharedPointer<web::Client> &client, |
1454 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager, |
1455 | std::shared_ptr<click::DepartmentsDb> depts); |
1456 | // From unity::scopes::PreviewQuery |
1457 | void cancelled() override; |
1458 | @@ -168,20 +158,13 @@ |
1459 | const scopes::PreviewWidgetList& button_area_widgets); |
1460 | |
1461 | virtual void run_under_qt(const std::function<void ()> &task); |
1462 | - virtual void invalidateScope(const std::string& scope_id); |
1463 | |
1464 | protected: |
1465 | virtual void populateDetails(std::function<void(const PackageDetails &)> details_callback, |
1466 | - std::function<void(const click::ReviewList&, |
1467 | - click::Reviews::Error)> reviews_callback, |
1468 | bool force_cache = false); |
1469 | virtual scopes::PreviewWidgetList headerWidgets(const PackageDetails &details); |
1470 | virtual scopes::PreviewWidgetList screenshotsWidgets(const PackageDetails &details); |
1471 | virtual scopes::PreviewWidgetList descriptionWidgets(const PackageDetails &details); |
1472 | - virtual scopes::PreviewWidgetList progressBarWidget(const std::string& object_path); |
1473 | - virtual scopes::PreviewWidgetList reviewsWidgets(const click::ReviewList &reviewlist); |
1474 | - virtual scopes::PreviewWidgetList downloadErrorWidgets(); |
1475 | - virtual scopes::PreviewWidgetList loginErrorWidgets(const std::string& download_url, const std::string& download_sha512); |
1476 | virtual scopes::PreviewWidgetList errorWidgets(const scopes::Variant& title, |
1477 | const scopes::Variant& summary, |
1478 | const scopes::Variant& action_id, |
1479 | @@ -199,45 +182,7 @@ |
1480 | QSharedPointer<click::web::Client> client; |
1481 | QSharedPointer<click::Index> index; |
1482 | click::web::Cancellable index_operation; |
1483 | - QSharedPointer<click::Reviews> reviews; |
1484 | - click::web::Cancellable reviews_operation; |
1485 | - click::web::Cancellable submit_operation; |
1486 | scopes::OnlineAccountClient oa_client; |
1487 | - click::web::Cancellable purchase_operation; |
1488 | -}; |
1489 | - |
1490 | -class DownloadErrorPreview : public PreviewStrategy |
1491 | -{ |
1492 | -public: |
1493 | - DownloadErrorPreview(const unity::scopes::Result& result); |
1494 | - |
1495 | - virtual ~DownloadErrorPreview(); |
1496 | - |
1497 | - void run(unity::scopes::PreviewReplyProxy const& reply) override; |
1498 | -}; |
1499 | - |
1500 | -class InstallingPreview : public PreviewStrategy, public DepartmentUpdater |
1501 | -{ |
1502 | -public: |
1503 | - InstallingPreview(const unity::scopes::Result& result) : PreviewStrategy(result) {} |
1504 | - InstallingPreview(const std::string& download_url, |
1505 | - const std::string& download_sha512, |
1506 | - const unity::scopes::Result& result, |
1507 | - const QSharedPointer<click::web::Client>& client, |
1508 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager, |
1509 | - std::shared_ptr<click::DepartmentsDb> depts); |
1510 | - |
1511 | - virtual ~InstallingPreview(); |
1512 | - |
1513 | - void run(unity::scopes::PreviewReplyProxy const& reply) override; |
1514 | - |
1515 | -protected: |
1516 | - std::string download_url; |
1517 | - std::string download_sha512; |
1518 | - QSharedPointer<click::DownloadManager> dm; |
1519 | - std::shared_ptr<click::DepartmentsDb> depts_db; |
1520 | - CachedPreviewWidgets cachedWidgets; |
1521 | - void startLauncherAnimation(const PackageDetails& details); |
1522 | }; |
1523 | |
1524 | class InstalledPreview : public PreviewStrategy, public DepartmentUpdater |
1525 | @@ -253,9 +198,7 @@ |
1526 | void run(unity::scopes::PreviewReplyProxy const& reply) override; |
1527 | |
1528 | std::string getApplicationUri(const Manifest& manifest); |
1529 | - std::string get_consumer_key(); |
1530 | scopes::PreviewWidgetList createButtons(const click::Manifest& manifest); |
1531 | - scopes::PreviewWidget createRatingWidget(const click::Review& review) const; |
1532 | |
1533 | private: |
1534 | scopes::ActionMetadata metadata; |
1535 | @@ -270,71 +213,6 @@ |
1536 | void run(unity::scopes::PreviewReplyProxy const& reply) override; |
1537 | }; |
1538 | |
1539 | -class PurchasingPreview : public PreviewStrategy |
1540 | -{ |
1541 | -public: |
1542 | - PurchasingPreview(const unity::scopes::Result& result, |
1543 | - const QSharedPointer<click::web::Client>& client); |
1544 | - virtual ~PurchasingPreview(); |
1545 | - |
1546 | - void run(unity::scopes::PreviewReplyProxy const& reply) override; |
1547 | - |
1548 | -protected: |
1549 | - virtual scopes::PreviewWidgetList purchasingWidgets(const PackageDetails &); |
1550 | -}; |
1551 | - |
1552 | -class UninstallConfirmationPreview : public PreviewStrategy |
1553 | -{ |
1554 | -public: |
1555 | - UninstallConfirmationPreview(const unity::scopes::Result& result); |
1556 | - |
1557 | - virtual ~UninstallConfirmationPreview(); |
1558 | - |
1559 | - void run(unity::scopes::PreviewReplyProxy const& reply) override; |
1560 | -}; |
1561 | - |
1562 | -class UninstalledPreview : public PreviewStrategy, public DepartmentUpdater |
1563 | -{ |
1564 | -public: |
1565 | - UninstalledPreview(const unity::scopes::Result& result, |
1566 | - const unity::scopes::ActionMetadata& metadata, |
1567 | - const QSharedPointer<click::web::Client>& client, |
1568 | - const std::shared_ptr<click::DepartmentsDb>& depts, |
1569 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager); |
1570 | - |
1571 | - virtual ~UninstalledPreview(); |
1572 | - |
1573 | - void run(unity::scopes::PreviewReplyProxy const& reply) override; |
1574 | - virtual scopes::PreviewWidgetList uninstalledActionButtonWidgets(const PackageDetails &details); |
1575 | - |
1576 | -protected: |
1577 | - scopes::ActionMetadata metadata; |
1578 | - PackageDetails found_details; |
1579 | - CachedPreviewWidgets cachedWidgets; |
1580 | - std::string found_object_path; |
1581 | - |
1582 | - QSharedPointer<click::DownloadManager> dm; |
1583 | -}; |
1584 | - |
1585 | -// TODO: this is only necessary to perform uninstall. |
1586 | -// That should be moved to a separate action, and this class removed. |
1587 | -class UninstallingPreview : public UninstalledPreview |
1588 | -{ |
1589 | -public: |
1590 | - UninstallingPreview(const unity::scopes::Result& result, |
1591 | - const unity::scopes::ActionMetadata& metadata, |
1592 | - const QSharedPointer<click::web::Client>& client, |
1593 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager); |
1594 | - |
1595 | - virtual ~UninstallingPreview(); |
1596 | - |
1597 | - void run(unity::scopes::PreviewReplyProxy const& reply) override; |
1598 | - |
1599 | -protected: |
1600 | - void uninstall(); |
1601 | - |
1602 | -}; |
1603 | - |
1604 | } // namespace click |
1605 | |
1606 | #endif |
1607 | |
1608 | === removed file 'libclickscope/click/reviews.cpp' |
1609 | --- libclickscope/click/reviews.cpp 2016-05-25 16:19:51 +0000 |
1610 | +++ libclickscope/click/reviews.cpp 1970-01-01 00:00:00 +0000 |
1611 | @@ -1,245 +0,0 @@ |
1612 | -/* |
1613 | - * Copyright (C) 2014 Canonical Ltd. |
1614 | - * |
1615 | - * This program is free software: you can redistribute it and/or modify it |
1616 | - * under the terms of the GNU General Public License version 3, as published |
1617 | - * by the Free Software Foundation. |
1618 | - * |
1619 | - * This program is distributed in the hope that it will be useful, but |
1620 | - * WITHOUT ANY WARRANTY; without even the implied warranties of |
1621 | - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1622 | - * PURPOSE. See the GNU General Public License for more details. |
1623 | - * |
1624 | - * You should have received a copy of the GNU General Public License along |
1625 | - * with this program. If not, see <http://www.gnu.org/licenses/>. |
1626 | - * |
1627 | - * In addition, as a special exception, the copyright holders give |
1628 | - * permission to link the code of portions of this program with the |
1629 | - * OpenSSL library under certain conditions as described in each |
1630 | - * individual source file, and distribute linked combinations |
1631 | - * including the two. |
1632 | - * You must obey the GNU General Public License in all respects |
1633 | - * for all of the code used other than OpenSSL. If you modify |
1634 | - * file(s) with this exception, you may extend this exception to your |
1635 | - * version of the file(s), but you are not obligated to do so. If you |
1636 | - * do not wish to do so, delete this exception statement from your |
1637 | - * version. If you delete this exception statement from all source |
1638 | - * files in the program, then also delete it here. |
1639 | - */ |
1640 | - |
1641 | -#include <cstdlib> |
1642 | -#include <algorithm> |
1643 | - |
1644 | -#include <boost/property_tree/ptree.hpp> |
1645 | -#include <boost/property_tree/json_parser.hpp> |
1646 | -#include <boost/foreach.hpp> |
1647 | - |
1648 | -#include <click/configuration.h> |
1649 | - |
1650 | -#include <json/value.h> |
1651 | -#include <json/writer.h> |
1652 | - |
1653 | -#include "reviews.h" |
1654 | - |
1655 | -namespace click |
1656 | -{ |
1657 | - |
1658 | -bool operator== (const Review& lhs, const Review &rhs) |
1659 | -{ |
1660 | - return lhs.id == rhs.id && |
1661 | - lhs.rating == rhs.rating && |
1662 | - lhs.usefulness_favorable == rhs.usefulness_favorable && |
1663 | - lhs.usefulness_total == rhs.usefulness_total && |
1664 | - lhs.hide == rhs.hide && |
1665 | - lhs.date_created == rhs.date_created && |
1666 | - lhs.date_deleted == rhs.date_deleted && |
1667 | - lhs.package_name == rhs.package_name && |
1668 | - lhs.package_version == rhs.package_version && |
1669 | - lhs.language == rhs.language && |
1670 | - lhs.summary == rhs.summary && |
1671 | - lhs.review_text == rhs.review_text && |
1672 | - lhs.reviewer_name == rhs.reviewer_name && |
1673 | - lhs.reviewer_username == rhs.reviewer_username; |
1674 | -} |
1675 | - |
1676 | -ReviewList review_list_from_json (const std::string& json) |
1677 | -{ |
1678 | - std::istringstream stream(json); |
1679 | - |
1680 | - boost::property_tree::ptree tree; |
1681 | - boost::property_tree::read_json(stream, tree); |
1682 | - |
1683 | - ReviewList reviews; |
1684 | - |
1685 | - BOOST_FOREACH(boost::property_tree::ptree::value_type &value, tree) |
1686 | - { |
1687 | - assert(value.first.empty()); // array elements have no names |
1688 | - auto node = value.second; |
1689 | - Review review; |
1690 | - |
1691 | - review.id = node.get<uint32_t>("id"); |
1692 | - review.rating = node.get<int>("rating"); |
1693 | - review.usefulness_favorable = node.get<uint32_t>("usefulness_favorable"); |
1694 | - review.usefulness_total = node.get<uint32_t>("usefulness_total"); |
1695 | - review.hide = node.get<bool>("hide"); |
1696 | - review.date_created = node.get<std::string>("date_created"); |
1697 | - review.date_deleted = node.get<std::string>("date_deleted"); |
1698 | - review.package_name = node.get<std::string>("package_name"); |
1699 | - review.package_version = node.get<std::string>("version"); |
1700 | - review.language = node.get<std::string>("language"); |
1701 | - review.summary = node.get<std::string>("summary"); |
1702 | - review.review_text = node.get<std::string>("review_text"); |
1703 | - review.reviewer_username = node.get<std::string>("reviewer_username"); |
1704 | - review.reviewer_name = node.get<std::string>("reviewer_displayname", review.reviewer_username); |
1705 | - |
1706 | - reviews.push_back(review); |
1707 | - } |
1708 | - return reviews; |
1709 | -} |
1710 | - |
1711 | -ReviewList bring_to_front (const ReviewList& reviews, const std::string& userid) |
1712 | -{ |
1713 | - if (userid.size() == 0) |
1714 | - { |
1715 | - return reviews; |
1716 | - } |
1717 | - auto new_reviews = reviews; |
1718 | - auto it = std::find_if(new_reviews.begin(), new_reviews.end(), [userid](const Review& review) { |
1719 | - return review.reviewer_username == userid; |
1720 | - }); |
1721 | - if (it != new_reviews.end() && it != new_reviews.begin()) { |
1722 | - // move own review to the front |
1723 | - auto const review = *it; |
1724 | - new_reviews.erase(it); |
1725 | - new_reviews.push_front(review); |
1726 | - } |
1727 | - return new_reviews; |
1728 | -} |
1729 | - |
1730 | -Reviews::Reviews (const QSharedPointer<click::web::Client>& client) |
1731 | - : client(client) |
1732 | -{ |
1733 | -} |
1734 | - |
1735 | -Reviews::~Reviews () |
1736 | -{ |
1737 | -} |
1738 | - |
1739 | -click::web::Cancellable Reviews::fetch_reviews (const std::string& package_name, |
1740 | - std::function<void(ReviewList, Error)> callback, |
1741 | - bool force_cache) |
1742 | -{ |
1743 | - click::web::CallParams params; |
1744 | - params.add(click::REVIEWS_QUERY_ARGNAME, package_name.c_str()); |
1745 | - QSharedPointer<click::web::Response> response = client->call |
1746 | - (get_base_url() + click::REVIEWS_API_PATH, "GET", false, |
1747 | - std::map<std::string, std::string>{}, "", params, force_cache); |
1748 | - |
1749 | - QObject::connect(response.data(), &click::web::Response::finished, |
1750 | - [=](QString reply) { |
1751 | - auto status = response->get_status_code(); |
1752 | - click::ReviewList reviews; |
1753 | - if (status == 200) { |
1754 | - reviews = review_list_from_json(reply.toUtf8().constData()); |
1755 | - callback(reviews, click::Reviews::Error::NoError); |
1756 | - } else { |
1757 | - callback(reviews, click::Reviews::Error::NetworkError); |
1758 | - } |
1759 | - }); |
1760 | - QObject::connect(response.data(), &click::web::Response::error, |
1761 | - [=](QString) { |
1762 | - qDebug() << "Network error attempting to fetch reviews for:" << package_name.c_str(); |
1763 | - callback(ReviewList(), click::Reviews::Error::NetworkError); |
1764 | - }); |
1765 | - |
1766 | - return click::web::Cancellable(response); |
1767 | -} |
1768 | - |
1769 | -click::web::Cancellable Reviews::submit_review (const Review& review, |
1770 | - std::function<void(Error)> callback) |
1771 | -{ |
1772 | - std::map<std::string, std::string> headers({ |
1773 | - {click::web::CONTENT_TYPE_HEADER, click::web::CONTENT_TYPE_JSON}, |
1774 | - }); |
1775 | - Json::Value root(Json::ValueType::objectValue); |
1776 | - root["package_name"] = review.package_name; |
1777 | - root["version"] = review.package_version; |
1778 | - root["rating"] = review.rating; |
1779 | - root["review_text"] = review.review_text; |
1780 | - |
1781 | - root["arch_tag"] = click::Configuration().get_architecture(); |
1782 | - /* NOTE: We only use the base language code for reviews, except for |
1783 | - * codes in the click::Configuration::FULL_LANG_CODES vector. |
1784 | - */ |
1785 | - auto language = click::Configuration().get_language(); |
1786 | - if (click::Configuration::is_full_lang_code(language)) { |
1787 | - root["language"] = language; |
1788 | - } else { |
1789 | - root["language"] = click::Configuration().get_language_base(); |
1790 | - } |
1791 | - |
1792 | - // NOTE: "summary" is a required field, but we don't have one. Use "". |
1793 | - root["summary"] = "Review"; |
1794 | - |
1795 | - qDebug() << "Rating" << review.package_name.c_str() << review.rating; |
1796 | - |
1797 | - QSharedPointer<click::web::Response> response = client->call |
1798 | - (get_base_url() + click::REVIEWS_API_PATH, "POST", true, |
1799 | - headers, Json::FastWriter().write(root), click::web::CallParams()); |
1800 | - |
1801 | - QObject::connect(response.data(), &click::web::Response::finished, |
1802 | - [=](QString) { |
1803 | - qDebug() << "Review submitted for:" << review.package_name.c_str(); |
1804 | - callback(Error::NoError); |
1805 | - }); |
1806 | - QObject::connect(response.data(), &click::web::Response::error, |
1807 | - [=](QString) { |
1808 | - qCritical() << "Network error submitting a reviews for:" << review.package_name.c_str(); |
1809 | - callback(Error::NetworkError); |
1810 | - }); |
1811 | - |
1812 | - return click::web::Cancellable(response); |
1813 | -} |
1814 | - |
1815 | -click::web::Cancellable Reviews::edit_review (const Review& review, |
1816 | - std::function<void(Error)> callback) |
1817 | -{ |
1818 | - std::map<std::string, std::string> headers({ |
1819 | - {click::web::CONTENT_TYPE_HEADER, click::web::CONTENT_TYPE_JSON}, |
1820 | - }); |
1821 | - Json::Value root(Json::ValueType::objectValue); |
1822 | - root["rating"] = review.rating; |
1823 | - root["review_text"] = review.review_text; |
1824 | - // NOTE: "summary" is a required field, but we don't have one. Use "". |
1825 | - root["summary"] = "Review"; |
1826 | - |
1827 | - qDebug() << "Rating" << review.package_name.c_str() << review.rating; |
1828 | - |
1829 | - QSharedPointer<click::web::Response> response = client->call |
1830 | - (get_base_url() + click::REVIEWS_API_PATH + std::to_string(review.id) + "/", "PUT", true, |
1831 | - headers, Json::FastWriter().write(root), click::web::CallParams()); |
1832 | - |
1833 | - QObject::connect(response.data(), &click::web::Response::finished, |
1834 | - [=](QString) { |
1835 | - qDebug() << "Review updated for:" << review.package_name.c_str(); |
1836 | - callback(Error::NoError); |
1837 | - }); |
1838 | - QObject::connect(response.data(), &click::web::Response::error, |
1839 | - [=](QString) { |
1840 | - qCritical() << "Network error updating a review for:" << review.package_name.c_str(); |
1841 | - callback(Error::NetworkError); |
1842 | - }); |
1843 | - |
1844 | - return click::web::Cancellable(response); |
1845 | -} |
1846 | - |
1847 | -std::string Reviews::get_base_url () |
1848 | -{ |
1849 | - const char *env_url = getenv(REVIEWS_BASE_URL_ENVVAR.c_str()); |
1850 | - if (env_url != NULL) { |
1851 | - return env_url; |
1852 | - } |
1853 | - return click::REVIEWS_BASE_URL; |
1854 | -} |
1855 | - |
1856 | -} //namespace click |
1857 | |
1858 | === removed file 'libclickscope/click/reviews.h' |
1859 | --- libclickscope/click/reviews.h 2016-04-27 14:06:29 +0000 |
1860 | +++ libclickscope/click/reviews.h 1970-01-01 00:00:00 +0000 |
1861 | @@ -1,95 +0,0 @@ |
1862 | -/* |
1863 | - * Copyright (C) 2014 Canonical Ltd. |
1864 | - * |
1865 | - * This program is free software: you can redistribute it and/or modify it |
1866 | - * under the terms of the GNU General Public License version 3, as published |
1867 | - * by the Free Software Foundation. |
1868 | - * |
1869 | - * This program is distributed in the hope that it will be useful, but |
1870 | - * WITHOUT ANY WARRANTY; without even the implied warranties of |
1871 | - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1872 | - * PURPOSE. See the GNU General Public License for more details. |
1873 | - * |
1874 | - * You should have received a copy of the GNU General Public License along |
1875 | - * with this program. If not, see <http://www.gnu.org/licenses/>. |
1876 | - * |
1877 | - * In addition, as a special exception, the copyright holders give |
1878 | - * permission to link the code of portions of this program with the |
1879 | - * OpenSSL library under certain conditions as described in each |
1880 | - * individual source file, and distribute linked combinations |
1881 | - * including the two. |
1882 | - * You must obey the GNU General Public License in all respects |
1883 | - * for all of the code used other than OpenSSL. If you modify |
1884 | - * file(s) with this exception, you may extend this exception to your |
1885 | - * version of the file(s), but you are not obligated to do so. If you |
1886 | - * do not wish to do so, delete this exception statement from your |
1887 | - * version. If you delete this exception statement from all source |
1888 | - * files in the program, then also delete it here. |
1889 | - */ |
1890 | - |
1891 | -#ifndef CLICK_REVIEWS_H |
1892 | -#define CLICK_REVIEWS_H |
1893 | - |
1894 | -#include <functional> |
1895 | -#include <string> |
1896 | -#include <list> |
1897 | - |
1898 | -#include <click/webclient.h> |
1899 | - |
1900 | -namespace click |
1901 | -{ |
1902 | - |
1903 | -const std::string REVIEWS_BASE_URL_ENVVAR = "U1_REVIEWS_BASE_URL"; |
1904 | -const std::string REVIEWS_BASE_URL = "https://reviews.ubuntu.com"; |
1905 | -const std::string REVIEWS_API_PATH = "/click/api/1.0/reviews/"; |
1906 | -const std::string REVIEWS_QUERY_ARGNAME = "package_name"; |
1907 | - |
1908 | -struct Review |
1909 | -{ |
1910 | - uint32_t id; |
1911 | - int rating; |
1912 | - uint32_t usefulness_favorable; |
1913 | - uint32_t usefulness_total; |
1914 | - bool hide; |
1915 | - std::string date_created; |
1916 | - std::string date_deleted; |
1917 | - std::string package_name; |
1918 | - std::string package_version; |
1919 | - std::string language; |
1920 | - std::string summary; |
1921 | - std::string review_text; |
1922 | - std::string reviewer_name; |
1923 | - std::string reviewer_username; |
1924 | -}; |
1925 | - |
1926 | -typedef std::list<Review> ReviewList; |
1927 | - |
1928 | -ReviewList review_list_from_json (const std::string& json); |
1929 | -ReviewList bring_to_front (const ReviewList& reviews, const std::string& userid); |
1930 | - |
1931 | -class Reviews |
1932 | -{ |
1933 | -protected: |
1934 | - QSharedPointer<web::Client> client; |
1935 | -public: |
1936 | - enum class Error {NoError, CredentialsError, NetworkError}; |
1937 | - Reviews() {} |
1938 | - Reviews(const QSharedPointer<click::web::Client>& client); |
1939 | - virtual ~Reviews(); |
1940 | - |
1941 | - virtual click::web::Cancellable fetch_reviews (const std::string& package_name, |
1942 | - std::function<void(ReviewList, Error)> callback, |
1943 | - bool force_cache = false); |
1944 | - click::web::Cancellable submit_review (const Review& review, |
1945 | - std::function<void(Error)> callback); |
1946 | - click::web::Cancellable edit_review (const Review& review, |
1947 | - std::function<void(Error)> callback); |
1948 | - |
1949 | - static std::string get_base_url (); |
1950 | -}; |
1951 | - |
1952 | -bool operator==(const Review& lhs, const Review& rhs); |
1953 | - |
1954 | -} // namespace click |
1955 | - |
1956 | -#endif // CLICK_REVIEWS_H |
1957 | |
1958 | === modified file 'libclickscope/click/scope_activation.cpp' |
1959 | --- libclickscope/click/scope_activation.cpp 2016-05-19 18:05:56 +0000 |
1960 | +++ libclickscope/click/scope_activation.cpp 2017-01-10 16:06:37 +0000 |
1961 | @@ -28,7 +28,6 @@ |
1962 | */ |
1963 | |
1964 | #include "scope_activation.h" |
1965 | -#include <click/download-manager.h> |
1966 | #include <click/package.h> |
1967 | #include <click/interface.h> |
1968 | #include <click/qtbridge.h> |
1969 | @@ -55,42 +54,3 @@ |
1970 | { |
1971 | hints_[key] = value; |
1972 | } |
1973 | - |
1974 | -click::PerformUninstallAction::PerformUninstallAction(const unity::scopes::Result& result, const unity::scopes::ActionMetadata& metadata) |
1975 | - : unity::scopes::ActivationQueryBase(result, metadata) |
1976 | -{ |
1977 | -} |
1978 | - |
1979 | -unity::scopes::ActivationResponse click::PerformUninstallAction::activate() |
1980 | -{ |
1981 | - std::promise<bool> uninstall_success_p; |
1982 | - std::future<bool> uninstall_success_f = uninstall_success_p.get_future(); |
1983 | - |
1984 | - auto const res = result(); |
1985 | - click::Package package; |
1986 | - package.title = res.title(); |
1987 | - package.name = res["name"].get_string(); |
1988 | - package.version = res["version"].get_string(); |
1989 | - qt::core::world::enter_with_task([this, package, &uninstall_success_p] () |
1990 | - { |
1991 | - click::PackageManager manager; |
1992 | - manager.uninstall(package, [&](int code, std::string stderr_content) { |
1993 | - if (code != 0) { |
1994 | - qDebug() << "Error removing package:" << stderr_content.c_str(); |
1995 | - uninstall_success_p.set_value(false); |
1996 | - } else { |
1997 | - qDebug() << "successfully removed package"; |
1998 | - uninstall_success_p.set_value(true); |
1999 | - } |
2000 | - } ); |
2001 | - }); |
2002 | - |
2003 | - if (uninstall_success_f.get()) |
2004 | - { |
2005 | - if (res.contains("lonely_result") && res.value("lonely_result").get_bool()) |
2006 | - { |
2007 | - return unity::scopes::ActivationResponse(unity::scopes::CannedQuery(APPS_SCOPE_ID.toUtf8().data())); |
2008 | - } |
2009 | - } |
2010 | - return unity::scopes::ActivationResponse(unity::scopes::ActivationResponse::ShowDash); |
2011 | -} |
2012 | |
2013 | === modified file 'libclickscope/click/scope_activation.h' |
2014 | --- libclickscope/click/scope_activation.h 2016-05-18 12:38:46 +0000 |
2015 | +++ libclickscope/click/scope_activation.h 2017-01-10 16:06:37 +0000 |
2016 | @@ -37,13 +37,6 @@ |
2017 | namespace click |
2018 | { |
2019 | |
2020 | -class PerformUninstallAction: public unity::scopes::ActivationQueryBase |
2021 | -{ |
2022 | -public: |
2023 | - PerformUninstallAction(const unity::scopes::Result& result, const unity::scopes::ActionMetadata& metadata); |
2024 | - unity::scopes::ActivationResponse activate() override; |
2025 | -}; |
2026 | - |
2027 | class ScopeActivation : public unity::scopes::ActivationQueryBase |
2028 | { |
2029 | unity::scopes::ActivationResponse activate() override; |
2030 | |
2031 | === modified file 'libclickscope/tests/CMakeLists.txt' |
2032 | --- libclickscope/tests/CMakeLists.txt 2016-10-24 21:26:23 +0000 |
2033 | +++ libclickscope/tests/CMakeLists.txt 2017-01-10 16:06:37 +0000 |
2034 | @@ -20,7 +20,6 @@ |
2035 | add_executable (${LIBCLICKSCOPE_TESTS_TARGET} |
2036 | mock_network_access_manager.h |
2037 | mock_ual.h |
2038 | - mock_ubuntu_download_manager.h |
2039 | mock_ubuntuone_credentials.h |
2040 | mock_webclient.h |
2041 | fake_json.cpp |
2042 | @@ -28,12 +27,10 @@ |
2043 | test_configuration.cpp |
2044 | test_departments.cpp |
2045 | test_departments-db.cpp |
2046 | - test_download_manager.cpp |
2047 | test_index.cpp |
2048 | test_interface.cpp |
2049 | test_package.cpp |
2050 | test_preview.cpp |
2051 | - test_reviews.cpp |
2052 | test_smartconnect.cpp |
2053 | test_utils.cpp |
2054 | test_webclient.cpp |
2055 | @@ -46,8 +43,6 @@ |
2056 | |
2057 | ${UNITY_SCOPES_LDFLAGS} |
2058 | ${UBUNTUONE_LDFLAGS} |
2059 | - ${UBUNTU_DOWNLOAD_MANAGER_CLIENT_LDFLAGS} |
2060 | - ${UBUNTU_DOWNLOAD_MANAGER_COMMON_LDFLAGS} |
2061 | ${JSON_CPP_LDFLAGS} |
2062 | |
2063 | gmock |
2064 | |
2065 | === removed file 'libclickscope/tests/mock_ubuntu_download_manager.h' |
2066 | --- libclickscope/tests/mock_ubuntu_download_manager.h 2016-02-24 17:48:56 +0000 |
2067 | +++ libclickscope/tests/mock_ubuntu_download_manager.h 1970-01-01 00:00:00 +0000 |
2068 | @@ -1,140 +0,0 @@ |
2069 | -/* |
2070 | - * Copyright (C) 2014-2016 Canonical Ltd. |
2071 | - * |
2072 | - * This program is free software: you can redistribute it and/or modify it |
2073 | - * under the terms of the GNU General Public License version 3, as published |
2074 | - * by the Free Software Foundation. |
2075 | - * |
2076 | - * This program is distributed in the hope that it will be useful, but |
2077 | - * WITHOUT ANY WARRANTY; without even the implied warranties of |
2078 | - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
2079 | - * PURPOSE. See the GNU General Public License for more details. |
2080 | - * |
2081 | - * You should have received a copy of the GNU General Public License along |
2082 | - * with this program. If not, see <http://www.gnu.org/licenses/>. |
2083 | - * |
2084 | - * In addition, as a special exception, the copyright holders give |
2085 | - * permission to link the code of portions of this program with the |
2086 | - * OpenSSL library under certain conditions as described in each |
2087 | - * individual source file, and distribute linked combinations |
2088 | - * including the two. |
2089 | - * You must obey the GNU General Public License in all respects |
2090 | - * for all of the code used other than OpenSSL. If you modify |
2091 | - * file(s) with this exception, you may extend this exception to your |
2092 | - * version of the file(s), but you are not obligated to do so. If you |
2093 | - * do not wish to do so, delete this exception statement from your |
2094 | - * version. If you delete this exception statement from all source |
2095 | - * files in the program, then also delete it here. |
2096 | - */ |
2097 | - |
2098 | -#ifndef _MOCK_UBUNTU_DOWNLOAD_MANAGER_H_ |
2099 | -#define _MOCK_UBUNTU_DOWNLOAD_MANAGER_H_ |
2100 | - |
2101 | -#include <QDBusConnection> |
2102 | -#include <QDBusObjectPath> |
2103 | - |
2104 | -#include <ubuntu/download_manager/download.h> |
2105 | -#include <ubuntu/download_manager/downloads_list.h> |
2106 | -#include <ubuntu/download_manager/error.h> |
2107 | -#include <ubuntu/download_manager/manager.h> |
2108 | - |
2109 | -#include <gmock/gmock.h> |
2110 | - |
2111 | -class MockDownload : public Ubuntu::DownloadManager::Download |
2112 | -{ |
2113 | -public: |
2114 | - MockDownload() : Ubuntu::DownloadManager::Download(){}; |
2115 | - MockDownload(Ubuntu::DownloadManager::Error *err) : Ubuntu::DownloadManager::Download(err) {}; |
2116 | - // mock ALL methods so that we do not have an abstract class |
2117 | - |
2118 | - MOCK_METHOD0(start, void()); |
2119 | - MOCK_METHOD0(pause, void()); |
2120 | - MOCK_METHOD0(resume, void()); |
2121 | - MOCK_METHOD0(cancel, void()); |
2122 | - |
2123 | - MOCK_METHOD1(allowMobileDownload, void(bool)); |
2124 | - MOCK_METHOD0(isMobileDownloadAllowed, bool()); |
2125 | - |
2126 | - MOCK_METHOD1(setThrottle, void(qulonglong)); |
2127 | - MOCK_METHOD0(throttle, qulonglong()); |
2128 | - |
2129 | - MOCK_CONST_METHOD0(id, QString()); |
2130 | - |
2131 | - MOCK_METHOD1(setDestinationDir, void(const QString& path)); |
2132 | - MOCK_METHOD0(metadata, QVariantMap()); |
2133 | - MOCK_METHOD1(setMetadata, void(QVariantMap)); |
2134 | - MOCK_METHOD0(progress, qulonglong()); |
2135 | - MOCK_METHOD0(totalSize, qulonglong()); |
2136 | - |
2137 | - MOCK_CONST_METHOD0(clickPackage, QString()); |
2138 | - MOCK_CONST_METHOD0(title, QString()); |
2139 | - MOCK_CONST_METHOD0(showInIndicator, bool()); |
2140 | - |
2141 | - MOCK_CONST_METHOD0(isError, bool()); |
2142 | - MOCK_CONST_METHOD0(error, Error*()); |
2143 | - MOCK_METHOD0(headers, QMap<QString, QString>()); |
2144 | - MOCK_METHOD1(setHeaders, void(QMap<QString, QString>)); |
2145 | - MOCK_CONST_METHOD0(destinationApp, QString()); |
2146 | - |
2147 | - MOCK_METHOD0(collected, void()); |
2148 | - MOCK_METHOD0(filePath, QString()); |
2149 | - MOCK_METHOD0(state, Download::State()); |
2150 | -}; |
2151 | - |
2152 | -class MockError : public Ubuntu::DownloadManager::Error |
2153 | -{ |
2154 | -public: |
2155 | - |
2156 | - MockError() : Ubuntu::DownloadManager::Error(Ubuntu::DownloadManager::Error::Type::Process, 0) {}; |
2157 | - MOCK_METHOD0(errorString, QString()); |
2158 | -}; |
2159 | - |
2160 | -class MockDownloadsList : public Ubuntu::DownloadManager::DownloadsList |
2161 | -{ |
2162 | -public: |
2163 | - |
2164 | - MockDownloadsList() : Ubuntu::DownloadManager::DownloadsList() {}; |
2165 | - |
2166 | - MOCK_CONST_METHOD0(downloads, QList<QSharedPointer<Ubuntu::DownloadManager::Download>>()); |
2167 | - MOCK_CONST_METHOD0(isError, bool()); |
2168 | - MOCK_CONST_METHOD0(error, Ubuntu::DownloadManager::Error*()); |
2169 | -}; |
2170 | - |
2171 | -class MockSystemDownloadManager : public Ubuntu::DownloadManager::Manager |
2172 | -{ |
2173 | -public: |
2174 | - |
2175 | - MockSystemDownloadManager() : Ubuntu::DownloadManager::Manager() {}; |
2176 | - |
2177 | - MOCK_METHOD1(getDownloadForId, Download*(const QString&)); |
2178 | - MOCK_METHOD1(createDownload, |
2179 | - void(DownloadStruct downStruct)); |
2180 | - MOCK_METHOD3(createDownload, |
2181 | - void(DownloadStruct downStruct, DownloadCb cb, DownloadCb errCb)); |
2182 | - MOCK_METHOD5(createDownload, |
2183 | - void(StructList downs, const QString &algorithm, bool allowed3G, const QVariantMap &metadata, StringMap headers)); |
2184 | - MOCK_METHOD7(createDownload, |
2185 | - void(StructList downs, const QString &algorithm, bool allowed3G, const QVariantMap &metadata, StringMap headers, GroupCb cb, GroupCb errCb)); |
2186 | - |
2187 | - MOCK_METHOD2(getAllDownloads, void(const QString &appId, bool uncompleted)); |
2188 | - MOCK_METHOD4(getAllDownloads, void(const QString &appId, |
2189 | - bool uncompleted, |
2190 | - DownloadsListCb cb, |
2191 | - DownloadsListCb errCb)); |
2192 | - MOCK_METHOD2(getAllDownloadsWithMetadata, void(const QString &name, |
2193 | - const QString &value)); |
2194 | - |
2195 | - MOCK_METHOD4(getAllDownloadsWithMetadata, void(const QString &name, |
2196 | - const QString &value, MetadataDownloadsListCb cb, |
2197 | - MetadataDownloadsListCb errCb)); |
2198 | - |
2199 | - MOCK_CONST_METHOD0(isError, bool()); |
2200 | - MOCK_CONST_METHOD0(lastError, Error*()); |
2201 | - MOCK_METHOD1(allowMobileDataDownload, void(bool)); |
2202 | - MOCK_METHOD0(isMobileDataDownload, bool()); |
2203 | - MOCK_METHOD0(defaultThrottle, qulonglong()); |
2204 | - MOCK_METHOD1(setDefaultThrottle, void(qulonglong)); |
2205 | - MOCK_METHOD0(exit, void()); |
2206 | -}; |
2207 | - |
2208 | -#endif /* _MOCK_UBUNTU_DOWNLOAD_MANAGER_H_ */ |
2209 | |
2210 | === modified file 'libclickscope/tests/test_bootstrap.cpp' |
2211 | --- libclickscope/tests/test_bootstrap.cpp 2016-06-30 20:42:56 +0000 |
2212 | +++ libclickscope/tests/test_bootstrap.cpp 2017-01-10 16:06:37 +0000 |
2213 | @@ -27,7 +27,6 @@ |
2214 | * files in the program, then also delete it here. |
2215 | */ |
2216 | #include <click/configuration.h> |
2217 | -#include <click/reviews.h> |
2218 | #include <click/webclient.h> |
2219 | #include <click/index.h> |
2220 | |
2221 | |
2222 | === removed file 'libclickscope/tests/test_download_manager.cpp' |
2223 | --- libclickscope/tests/test_download_manager.cpp 2016-05-10 13:42:12 +0000 |
2224 | +++ libclickscope/tests/test_download_manager.cpp 1970-01-01 00:00:00 +0000 |
2225 | @@ -1,220 +0,0 @@ |
2226 | -/* |
2227 | - * Copyright (C) 2014-2016 Canonical Ltd. |
2228 | - * |
2229 | - * This program is free software: you can redistribute it and/or modify it |
2230 | - * under the terms of the GNU General Public License version 3, as published |
2231 | - * by the Free Software Foundation. |
2232 | - * |
2233 | - * This program is distributed in the hope that it will be useful, but |
2234 | - * WITHOUT ANY WARRANTY; without even the implied warranties of |
2235 | - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
2236 | - * PURPOSE. See the GNU General Public License for more details. |
2237 | - * |
2238 | - * You should have received a copy of the GNU General Public License along |
2239 | - * with this program. If not, see <http://www.gnu.org/licenses/>. |
2240 | - * |
2241 | - * In addition, as a special exception, the copyright holders give |
2242 | - * permission to link the code of portions of this program with the |
2243 | - * OpenSSL library under certain conditions as described in each |
2244 | - * individual source file, and distribute linked combinations |
2245 | - * including the two. |
2246 | - * You must obey the GNU General Public License in all respects |
2247 | - * for all of the code used other than OpenSSL. If you modify |
2248 | - * file(s) with this exception, you may extend this exception to your |
2249 | - * version of the file(s), but you are not obligated to do so. If you |
2250 | - * do not wish to do so, delete this exception statement from your |
2251 | - * version. If you delete this exception statement from all source |
2252 | - * files in the program, then also delete it here. |
2253 | - */ |
2254 | - |
2255 | -#include <click/download-manager.h> |
2256 | -#include <tests/mock_network_access_manager.h> |
2257 | -#include <tests/mock_webclient.h> |
2258 | -#include <tests/mock_ubuntu_download_manager.h> |
2259 | -#include <tests/mock_ubuntuone_credentials.h> |
2260 | - |
2261 | -#include <gtest/gtest.h> |
2262 | -#include <memory> |
2263 | - |
2264 | -using namespace ::testing; |
2265 | - |
2266 | -namespace udm = Ubuntu::DownloadManager; |
2267 | -#include <ubuntu/download_manager/download_struct.h> |
2268 | - |
2269 | -namespace |
2270 | -{ |
2271 | -const QString TEST_URL("http://test.local/"); |
2272 | -const QString TEST_SHA512("fake_hash"); |
2273 | -const QString TEST_HEADER_VALUE("test header value"); |
2274 | -const QString TEST_APP_ID("test_app_id"); |
2275 | -const QString TEST_CLICK_TOKEN_VALUE("test token value"); |
2276 | -const QString TEST_DOWNLOAD_ID("/com/ubuntu/download_manager/test"); |
2277 | -const QString TEST_DOWNLOADERROR_STRING("test downloadError string"); |
2278 | - |
2279 | - |
2280 | -class DownloadManagerTest : public ::testing::Test |
2281 | -{ |
2282 | -protected: |
2283 | - QSharedPointer<MockClient> clientPtr; |
2284 | - QSharedPointer<MockNetworkAccessManager> namPtr; |
2285 | - QSharedPointer<MockSystemDownloadManager> sdmPtr; |
2286 | - QSharedPointer<MockCredentialsService> ssoPtr; |
2287 | - std::shared_ptr<click::DownloadManager> dmPtr; |
2288 | - |
2289 | - virtual void SetUp() |
2290 | - { |
2291 | - ssoPtr.reset(new MockCredentialsService()); |
2292 | - namPtr.reset(new MockNetworkAccessManager()); |
2293 | - clientPtr.reset(new NiceMock<MockClient>(namPtr)); |
2294 | - clientPtr->setCredentialsService(ssoPtr); |
2295 | - dmPtr.reset(new click::DownloadManager(clientPtr, sdmPtr)); |
2296 | - } |
2297 | - |
2298 | - MOCK_METHOD2(start_callback, void(std::string, click::DownloadManager::Error)); |
2299 | - MOCK_METHOD1(progress_callback, void(std::string)); |
2300 | -}; |
2301 | - |
2302 | -} |
2303 | - |
2304 | -TEST_F(DownloadManagerTest, testStartCallsWebservice) |
2305 | -{ |
2306 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2307 | - auto response = responseForReply(reply.asSharedPtr()); |
2308 | - |
2309 | - EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
2310 | - .Times(1) |
2311 | - .WillOnce(Return(response)); |
2312 | - |
2313 | - dmPtr->start("", "", "", |
2314 | - [](std::string, click::DownloadManager::Error) {}); |
2315 | -} |
2316 | - |
2317 | -TEST_F(DownloadManagerTest, testStartCallbackCalled) |
2318 | -{ |
2319 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2320 | - auto response = responseForReply(reply.asSharedPtr()); |
2321 | - |
2322 | - EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(0))); |
2323 | - EXPECT_CALL(reply.instance, readAll()) |
2324 | - .Times(1) |
2325 | - .WillOnce(Return("")); |
2326 | - EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
2327 | - .Times(1) |
2328 | - .WillOnce(Return(response)); |
2329 | - EXPECT_CALL(*this, start_callback(_, _)).Times(1); |
2330 | - |
2331 | - dmPtr->start("", "", "", |
2332 | - [this](std::string msg, click::DownloadManager::Error err) { |
2333 | - start_callback(msg, err); |
2334 | - }); |
2335 | - response->replyFinished(); |
2336 | -} |
2337 | - |
2338 | -TEST_F(DownloadManagerTest, testStartHTTPForbidden) |
2339 | -{ |
2340 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2341 | - auto response = responseForReply(reply.asSharedPtr()); |
2342 | - |
2343 | - EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(403))); |
2344 | - EXPECT_CALL(reply.instance, readAll()) |
2345 | - .Times(1) |
2346 | - .WillOnce(Return("")); |
2347 | - EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
2348 | - .Times(1) |
2349 | - .WillOnce(Return(response)); |
2350 | - EXPECT_CALL(*this, start_callback(StartsWith("Unhandled HTTP response code:"), |
2351 | - click::DownloadManager::Error::DownloadInstallError)).Times(1); |
2352 | - |
2353 | - dmPtr->start("", "", "", |
2354 | - [this](std::string msg, click::DownloadManager::Error err) { |
2355 | - start_callback(msg, err); |
2356 | - }); |
2357 | - response->replyFinished(); |
2358 | -} |
2359 | - |
2360 | -TEST_F(DownloadManagerTest, testStartHTTPError) |
2361 | -{ |
2362 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2363 | - auto response = responseForReply(reply.asSharedPtr()); |
2364 | - |
2365 | - EXPECT_CALL(reply.instance, errorString()) |
2366 | - .WillOnce(Return(QString("ERROR"))); |
2367 | - EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(404))); |
2368 | - EXPECT_CALL(reply.instance, readAll()) |
2369 | - .Times(1) |
2370 | - .WillOnce(Return("")); |
2371 | - EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
2372 | - .Times(1) |
2373 | - .WillOnce(Return(response)); |
2374 | - EXPECT_CALL(*this, start_callback("ERROR (203)", |
2375 | - click::DownloadManager::Error::DownloadInstallError)).Times(1); |
2376 | - |
2377 | - dmPtr->start("", "", "", |
2378 | - [this](std::string msg, click::DownloadManager::Error err) { |
2379 | - start_callback(msg, err); |
2380 | - }); |
2381 | - response->errorHandler(QNetworkReply::ContentNotFoundError); |
2382 | -} |
2383 | - |
2384 | -TEST_F(DownloadManagerTest, testStartCredentialsError) |
2385 | -{ |
2386 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2387 | - auto response = responseForReply(reply.asSharedPtr()); |
2388 | - |
2389 | - EXPECT_CALL(reply.instance, errorString()) |
2390 | - .WillOnce(Return(QString("ERROR"))); |
2391 | - EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(401))); |
2392 | - EXPECT_CALL(reply.instance, readAll()) |
2393 | - .Times(1) |
2394 | - .WillOnce(Return("")); |
2395 | - EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
2396 | - .Times(1) |
2397 | - .WillOnce(Return(response)); |
2398 | - EXPECT_CALL(*ssoPtr, invalidateCredentials()); |
2399 | - EXPECT_CALL(*this, start_callback("ERROR (201)", |
2400 | - click::DownloadManager::Error::CredentialsError)).Times(1); |
2401 | - |
2402 | - dmPtr->start("", "", "test.package", |
2403 | - [this](std::string msg, click::DownloadManager::Error err) { |
2404 | - start_callback(msg, err); |
2405 | - }); |
2406 | - response->errorHandler(QNetworkReply::ContentAccessDenied); |
2407 | -} |
2408 | - |
2409 | -// FIXME: createDownload() SEGV under tests |
2410 | -TEST_F(DownloadManagerTest, DISABLED_testStartDownloadCreated) |
2411 | -{ |
2412 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2413 | - auto response = responseForReply(reply.asSharedPtr()); |
2414 | - |
2415 | - EXPECT_CALL(reply.instance, rawHeader(QByteArray("X-Click-Token"))) |
2416 | - .Times(1) |
2417 | - .WillOnce(Return(QString("clicktoken"))); |
2418 | - EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(200))); |
2419 | - EXPECT_CALL(reply.instance, readAll()) |
2420 | - .Times(1) |
2421 | - .WillOnce(Return("")); |
2422 | - EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
2423 | - .Times(1) |
2424 | - .WillOnce(Return(response)); |
2425 | - |
2426 | - EXPECT_CALL(*sdmPtr, createDownload(_, _, _)); |
2427 | - dmPtr->start("", "", "test.package", |
2428 | - [this](std::string msg, click::DownloadManager::Error err) { |
2429 | - start_callback(msg, err); |
2430 | - }); |
2431 | - response->replyFinished(); |
2432 | -} |
2433 | - |
2434 | -// FIXME: getAllDownloadsWithMetadata() SEGV under tests |
2435 | -TEST_F(DownloadManagerTest, DISABLED_testGetProgressNoDownloads) |
2436 | -{ |
2437 | - EXPECT_CALL(*sdmPtr, getAllDownloadsWithMetadata(_, _, _, _)) |
2438 | - .Times(1) |
2439 | - .WillOnce(InvokeArgument<3>(QStringLiteral(""), QStringLiteral(""), |
2440 | - nullptr)); |
2441 | - dmPtr->get_progress("com.example.test", |
2442 | - [this](std::string object_path) { |
2443 | - progress_callback(object_path); |
2444 | - }); |
2445 | -} |
2446 | |
2447 | === modified file 'libclickscope/tests/test_index.cpp' |
2448 | --- libclickscope/tests/test_index.cpp 2016-12-02 18:37:59 +0000 |
2449 | +++ libclickscope/tests/test_index.cpp 2017-01-10 16:06:37 +0000 |
2450 | @@ -613,18 +613,6 @@ |
2451 | EXPECT_EQ(1u, lists.second.size()); |
2452 | } |
2453 | |
2454 | -TEST_F(MockPackageManager, testUninstallCommandCorrect) |
2455 | -{ |
2456 | - click::Package package = { |
2457 | - "org.example.testapp", "Test App", 0.00, |
2458 | - "/tmp/foo.png", |
2459 | - "uri", "0.1.5", "app" |
2460 | - }; |
2461 | - std::string expected = "pkcon -p remove org.example.testapp;0.1.5;all;local:click"; |
2462 | - EXPECT_CALL(*this, execute_uninstall_command(expected, _)).Times(1); |
2463 | - uninstall(package, [](int, std::string) {}); |
2464 | -} |
2465 | - |
2466 | class ExhibitionistIndex : public click::Index { |
2467 | public: |
2468 | using click::Index::build_index_query; |
2469 | |
2470 | === modified file 'libclickscope/tests/test_interface.cpp' |
2471 | --- libclickscope/tests/test_interface.cpp 2016-12-02 18:37:59 +0000 |
2472 | +++ libclickscope/tests/test_interface.cpp 2017-01-10 16:06:37 +0000 |
2473 | @@ -114,7 +114,6 @@ |
2474 | public: |
2475 | FakeClickInterface() {} |
2476 | |
2477 | - MOCK_CONST_METHOD1(get_manifest_json, std::string(const std::string&)); |
2478 | MOCK_CONST_METHOD0(installed_apps, std::list<std::shared_ptr<ual::Application>>()); |
2479 | }; |
2480 | |
2481 | @@ -485,79 +484,6 @@ |
2482 | Interface::add_theme_scheme("/usr/share/unity8/graphics/applicationIcons/contacts-app@18.png")); |
2483 | } |
2484 | |
2485 | -TEST(ClickInterface, testManifestFromJsonOneApp) |
2486 | -{ |
2487 | - Manifest m = manifest_from_json(FAKE_JSON_MANIFEST_ONE_APP); |
2488 | - ASSERT_EQ(m.first_app_name, "fake-app"); |
2489 | - ASSERT_TRUE(m.has_any_apps()); |
2490 | - ASSERT_FALSE(m.has_any_scopes()); |
2491 | -} |
2492 | - |
2493 | -TEST(ClickInterface, testManifestFromJsonOneScope) |
2494 | -{ |
2495 | - Manifest m = manifest_from_json(FAKE_JSON_MANIFEST_ONE_SCOPE); |
2496 | - ASSERT_EQ(m.first_scope_id, "com.example.fake-scope_fake-scope-hook"); |
2497 | - ASSERT_FALSE(m.has_any_apps()); |
2498 | - ASSERT_TRUE(m.has_any_scopes()); |
2499 | -} |
2500 | - |
2501 | -TEST(ClickInterface, testManifestFromJsonOneAppOneScope) |
2502 | -{ |
2503 | - Manifest m = manifest_from_json(FAKE_JSON_MANIFEST_ONE_APP_ONE_SCOPE); |
2504 | - ASSERT_EQ(m.first_app_name, "fake-app"); |
2505 | - ASSERT_EQ(m.first_scope_id, "com.example.fake-1app-1scope_fake-scope-hook"); |
2506 | - ASSERT_TRUE(m.has_any_apps()); |
2507 | - ASSERT_TRUE(m.has_any_scopes()); |
2508 | -} |
2509 | - |
2510 | -TEST(ClickInterface, testManifestFromJsonTwoAppsTwoScopes) |
2511 | -{ |
2512 | - Manifest m = manifest_from_json(FAKE_JSON_MANIFEST_TWO_APPS_TWO_SCOPES); |
2513 | - ASSERT_EQ(m.first_app_name, "fake-app1"); |
2514 | - ASSERT_EQ(m.first_scope_id, "com.example.fake-2apps-2scopes_fake-scope-hook1"); |
2515 | - ASSERT_TRUE(m.has_any_apps()); |
2516 | - ASSERT_TRUE(m.has_any_scopes()); |
2517 | -} |
2518 | - |
2519 | -TEST_F(ClickInterfaceTest, testGetManifestForAppParseError) |
2520 | -{ |
2521 | - FakeClickInterface iface; |
2522 | - EXPECT_CALL(iface, get_manifest_json(_)). |
2523 | - Times(1). |
2524 | - WillOnce(Return("INVALID JSON")); |
2525 | - EXPECT_CALL(*this, manifest_callback(_, InterfaceError::ParseError)); |
2526 | - iface.get_manifest_for_app(FAKE_PACKAGENAME, [this](Manifest manifest, |
2527 | - InterfaceError error){ |
2528 | - manifest_callback(manifest, error); |
2529 | - }); |
2530 | -} |
2531 | - |
2532 | -TEST_F(ClickInterfaceTest, testGetManifestForAppIsRemovable) |
2533 | -{ |
2534 | - FakeClickInterface iface; |
2535 | - EXPECT_CALL(iface, get_manifest_json(_)). |
2536 | - Times(1). |
2537 | - WillOnce(Return(FAKE_JSON_MANIFEST_REMOVABLE)); |
2538 | - iface.get_manifest_for_app(FAKE_PACKAGENAME, [](Manifest manifest, |
2539 | - InterfaceError error){ |
2540 | - ASSERT_TRUE(error == InterfaceError::NoError); |
2541 | - ASSERT_TRUE(manifest.removable); |
2542 | - }); |
2543 | -} |
2544 | - |
2545 | -TEST_F(ClickInterfaceTest, testGetManifestForAppIsNotRemovable) |
2546 | -{ |
2547 | - FakeClickInterface iface; |
2548 | - EXPECT_CALL(iface, get_manifest_json(_)). |
2549 | - Times(1). |
2550 | - WillOnce(Return(FAKE_JSON_MANIFEST_NONREMOVABLE)); |
2551 | - iface.get_manifest_for_app(FAKE_PACKAGENAME, [](Manifest manifest, |
2552 | - InterfaceError error){ |
2553 | - ASSERT_TRUE(error == InterfaceError::NoError); |
2554 | - ASSERT_FALSE(manifest.removable); |
2555 | - }); |
2556 | -} |
2557 | - |
2558 | TEST_F(ClickInterfaceTest, testGetInstalledPackagesParsed) |
2559 | { |
2560 | FakeClickInterface iface; |
2561 | |
2562 | === modified file 'libclickscope/tests/test_preview.cpp' |
2563 | --- libclickscope/tests/test_preview.cpp 2016-12-02 18:37:59 +0000 |
2564 | +++ libclickscope/tests/test_preview.cpp 2017-01-10 16:06:37 +0000 |
2565 | @@ -31,9 +31,7 @@ |
2566 | |
2567 | #include <click/index.h> |
2568 | #include <click/interface.h> |
2569 | -#include <click/reviews.h> |
2570 | #include <fake_json.h> |
2571 | -#include <mock_ubuntu_download_manager.h> |
2572 | |
2573 | #include <QCoreApplication> |
2574 | #include <QTimer> |
2575 | @@ -70,26 +68,12 @@ |
2576 | |
2577 | }; |
2578 | |
2579 | -class FakeReviews : public click::Reviews |
2580 | -{ |
2581 | -public: |
2582 | - FakeReviews() { |
2583 | - |
2584 | - } |
2585 | - |
2586 | - click::web::Cancellable fetch_reviews(const std::string &/*package_name*/, std::function<void (click::ReviewList, Error)> callback, bool) override { |
2587 | - callback(click::ReviewList(), Error::NoError); |
2588 | - return click::web::Cancellable(); |
2589 | - } |
2590 | -}; |
2591 | - |
2592 | class FakePreview : public click::PreviewStrategy |
2593 | { |
2594 | public: |
2595 | FakePreview(Result& result) : click::PreviewStrategy::PreviewStrategy(result) |
2596 | { |
2597 | index.reset(new FakeIndex()); |
2598 | - reviews.reset(new FakeReviews()); |
2599 | } |
2600 | |
2601 | void run(const PreviewReplyProxy &/*reply*/) |
2602 | @@ -155,8 +139,6 @@ |
2603 | FakePreview preview{result}; |
2604 | preview.populateDetails( |
2605 | [](const click::PackageDetails &){ |
2606 | - }, |
2607 | - [](const click::ReviewList&, click::Reviews::Error){ |
2608 | }); |
2609 | |
2610 | } |
2611 | @@ -342,150 +324,6 @@ |
2612 | ASSERT_EQ(expected_order, preview.call_order); |
2613 | } |
2614 | |
2615 | -class StrategyChooserTest : public Test { |
2616 | -protected: |
2617 | - unity::scopes::testing::Result result; |
2618 | - unity::scopes::ActionMetadata metadata; |
2619 | - unity::scopes::VariantMap metadict; |
2620 | - QSharedPointer<click::web::Client> client; |
2621 | - QSharedPointer<MockSystemDownloadManager> dm; |
2622 | - std::shared_ptr<click::DepartmentsDb> depts; |
2623 | - const std::string FAKE_SHA512 = "FAKE_SHA512"; |
2624 | - |
2625 | -public: |
2626 | - StrategyChooserTest() : metadata("en_EN", "phone") { |
2627 | - } |
2628 | -}; |
2629 | - |
2630 | -class MockablePreview : public click::Preview { |
2631 | -public: |
2632 | - MockablePreview(const unity::scopes::Result& result, const unity::scopes::ActionMetadata& metadata) : |
2633 | - click::Preview(result, metadata) |
2634 | - { |
2635 | - |
2636 | - } |
2637 | - |
2638 | - MOCK_METHOD6(build_installing, |
2639 | - click::PreviewStrategy*(const std::string&, |
2640 | - const std::string&, |
2641 | - const unity::scopes::Result&, |
2642 | - const QSharedPointer<click::web::Client>&, |
2643 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>&, |
2644 | - std::shared_ptr<click::DepartmentsDb>)); |
2645 | -}; |
2646 | - |
2647 | -TEST_F(StrategyChooserTest, testSha512IsUsed) { |
2648 | - metadict["action_id"] = click::Preview::Actions::INSTALL_CLICK; |
2649 | - metadict["download_url"] = "fake_download_url"; |
2650 | - metadict["download_sha512"] = FAKE_SHA512; |
2651 | - metadata.set_scope_data(unity::scopes::Variant(metadict)); |
2652 | - MockablePreview preview(result, metadata); |
2653 | - EXPECT_CALL(preview, build_installing(_, FAKE_SHA512, _, _, _, _)); |
2654 | - preview.choose_strategy(client, dm, depts); |
2655 | -} |
2656 | - |
2657 | - |
2658 | -class UninstalledPreviewTest : public PreviewsBaseTest { |
2659 | -public: |
2660 | - FakeResult result{vm}; |
2661 | - click::PackageDetails details; |
2662 | - unity::scopes::PreviewWidgetList widgets; |
2663 | - QSharedPointer<click::web::Client> client; |
2664 | - QSharedPointer<MockSystemDownloadManager> sdm; |
2665 | - std::shared_ptr<click::DepartmentsDb> depts; |
2666 | - unity::scopes::testing::MockPreviewReply reply; |
2667 | - std::shared_ptr<unity::scopes::testing::MockPreviewReply> replyptr{&reply, [](unity::scopes::testing::MockPreviewReply*){}}; |
2668 | -}; |
2669 | - |
2670 | -class FakeBaseUninstalledPreview : public click::UninstalledPreview { |
2671 | - std::string object_path; |
2672 | -public: |
2673 | - FakeBaseUninstalledPreview(const std::string& object_path, |
2674 | - const unity::scopes::Result& result, |
2675 | - const unity::scopes::ActionMetadata& metadata, |
2676 | - const QSharedPointer<click::web::Client>& client, |
2677 | - const std::shared_ptr<click::DepartmentsDb>& depts, |
2678 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager) |
2679 | - : click::UninstalledPreview(result, metadata, client, depts, manager), |
2680 | - object_path(object_path) |
2681 | - { |
2682 | - } |
2683 | - |
2684 | - void populateDetails(std::function<void (const click::PackageDetails &)> details_callback, |
2685 | - std::function<void (const click::ReviewList &, click::Reviews::Error)> reviews_callback) { |
2686 | - click::PackageDetails details; |
2687 | - details_callback(details); |
2688 | - reviews_callback({}, click::Reviews::Error::NoError); |
2689 | - } |
2690 | -}; |
2691 | - |
2692 | -class FakeUninstalledPreview : public FakeBaseUninstalledPreview { |
2693 | -public: |
2694 | - MOCK_METHOD1(uninstalledActionButtonWidgets, scopes::PreviewWidgetList (const click::PackageDetails &details)); |
2695 | - MOCK_METHOD1(progressBarWidget, scopes::PreviewWidgetList(const std::string& object_path)); |
2696 | - FakeUninstalledPreview(const std::string& object_path, |
2697 | - const unity::scopes::Result& result, |
2698 | - const unity::scopes::ActionMetadata& metadata, |
2699 | - const QSharedPointer<click::web::Client>& client, |
2700 | - const std::shared_ptr<click::DepartmentsDb>& depts, |
2701 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager) |
2702 | - : FakeBaseUninstalledPreview(object_path, result, metadata, client, depts, manager) { |
2703 | - } |
2704 | -}; |
2705 | - |
2706 | - |
2707 | -// FIXME: Needs Qt main loop |
2708 | -TEST_F(UninstalledPreviewTest, DISABLED_testDownloadInProgress) { |
2709 | - std::string fake_object_path = "/fake/object/path"; |
2710 | - |
2711 | - result["name"] = "fake_app_name"; |
2712 | - scopes::PreviewWidgetList response; |
2713 | - unity::scopes::ActionMetadata metadata("en_EN", "desktop"); |
2714 | - FakeUninstalledPreview preview(fake_object_path, result, metadata, client, depts, sdm); |
2715 | - EXPECT_CALL(preview, progressBarWidget(_)) |
2716 | - .Times(1) |
2717 | - .WillOnce(Return(response)); |
2718 | - EXPECT_CALL(*replyptr, register_layout(_)); |
2719 | - preview.run(replyptr); |
2720 | -} |
2721 | - |
2722 | -// FIXME: Needs Qt main loop |
2723 | -TEST_F(UninstalledPreviewTest, DISABLED_testNoDownloadProgress) { |
2724 | - std::string fake_object_path = ""; |
2725 | - |
2726 | - result["name"] = "fake_app_name"; |
2727 | - scopes::PreviewWidgetList response; |
2728 | - unity::scopes::ActionMetadata metadata("en_EN", "desktop"); |
2729 | - FakeUninstalledPreview preview(fake_object_path, result, metadata, client, depts, sdm); |
2730 | - EXPECT_CALL(preview, uninstalledActionButtonWidgets(_)) |
2731 | - .Times(1) |
2732 | - .WillOnce(Return(response)); |
2733 | - preview.run(replyptr); |
2734 | -} |
2735 | - |
2736 | -class FakeUninstalledRefundablePreview : FakeBaseUninstalledPreview { |
2737 | -public: |
2738 | - FakeUninstalledRefundablePreview(const unity::scopes::Result& result, |
2739 | - const unity::scopes::ActionMetadata& metadata, |
2740 | - const QSharedPointer<click::web::Client>& client, |
2741 | - const std::shared_ptr<click::DepartmentsDb>& depts, |
2742 | - const QSharedPointer<Ubuntu::DownloadManager::Manager>& manager) |
2743 | - : FakeBaseUninstalledPreview(std::string{""}, result, metadata, client, depts, manager){ |
2744 | - } |
2745 | - using click::UninstalledPreview::uninstalledActionButtonWidgets; |
2746 | -}; |
2747 | - |
2748 | -unity::scopes::VariantArray get_actions_from_widgets(const unity::scopes::PreviewWidgetList& widgets, int widget_number) { |
2749 | - auto widget = *std::next(widgets.begin(), widget_number); |
2750 | - return widget.attribute_values()["actions"].get_array(); |
2751 | -} |
2752 | - |
2753 | -std::string get_action_from_widgets(const unity::scopes::PreviewWidgetList& widgets, int widget_number, int action_number) { |
2754 | - auto actions = get_actions_from_widgets(widgets, widget_number); |
2755 | - auto selected_action = actions.at(action_number).get_dict(); |
2756 | - return selected_action["id"].get_string(); |
2757 | -} |
2758 | - |
2759 | class InstalledPreviewTest : public Test { |
2760 | protected: |
2761 | unity::scopes::testing::Result result; |
2762 | @@ -499,25 +337,6 @@ |
2763 | } |
2764 | }; |
2765 | |
2766 | -TEST_F(InstalledPreviewTest, testReviewWidgetIsNew) { |
2767 | - click::InstalledPreview preview(result, metadata, client, depts); |
2768 | - click::Review existing_review; |
2769 | - existing_review.id = 0; |
2770 | - auto widget = preview.createRatingWidget(existing_review); |
2771 | - ASSERT_EQ(widget.widget_type(), "rating-input"); |
2772 | -} |
2773 | - |
2774 | -TEST_F(InstalledPreviewTest, testReviewWidgetIsEdit) { |
2775 | - click::InstalledPreview preview(result, metadata, client, depts); |
2776 | - click::Review existing_review; |
2777 | - existing_review.id = 123456789; |
2778 | - existing_review.rating = 2.625f; |
2779 | - existing_review.review_text = "Mediocre at best."; |
2780 | - existing_review.reviewer_name = "reviewbot"; |
2781 | - auto widget = preview.createRatingWidget(existing_review); |
2782 | - ASSERT_EQ(widget.widget_type(), "rating-edit"); |
2783 | -} |
2784 | - |
2785 | TEST_F(InstalledPreviewTest, testGetApplicationURIClick) { |
2786 | click::InstalledPreview preview(result, metadata, client, depts); |
2787 | click::Manifest manifest; |
2788 | |
2789 | === removed file 'libclickscope/tests/test_reviews.cpp' |
2790 | --- libclickscope/tests/test_reviews.cpp 2016-12-02 18:37:59 +0000 |
2791 | +++ libclickscope/tests/test_reviews.cpp 1970-01-01 00:00:00 +0000 |
2792 | @@ -1,487 +0,0 @@ |
2793 | -/* |
2794 | - * Copyright (C) 2014 Canonical Ltd. |
2795 | - * |
2796 | - * This program is free software: you can redistribute it and/or modify it |
2797 | - * under the terms of the GNU General Public License version 3, as published |
2798 | - * by the Free Software Foundation. |
2799 | - * |
2800 | - * This program is distributed in the hope that it will be useful, but |
2801 | - * WITHOUT ANY WARRANTY; without even the implied warranties of |
2802 | - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
2803 | - * PURPOSE. See the GNU General Public License for more details. |
2804 | - * |
2805 | - * You should have received a copy of the GNU General Public License along |
2806 | - * with this program. If not, see <http://www.gnu.org/licenses/>. |
2807 | - * |
2808 | - * In addition, as a special exception, the copyright holders give |
2809 | - * permission to link the code of portions of this program with the |
2810 | - * OpenSSL library under certain conditions as described in each |
2811 | - * individual source file, and distribute linked combinations |
2812 | - * including the two. |
2813 | - * You must obey the GNU General Public License in all respects |
2814 | - * for all of the code used other than OpenSSL. If you modify |
2815 | - * file(s) with this exception, you may extend this exception to your |
2816 | - * version of the file(s), but you are not obligated to do so. If you |
2817 | - * do not wish to do so, delete this exception statement from your |
2818 | - * version. If you delete this exception statement from all source |
2819 | - * files in the program, then also delete it here. |
2820 | - */ |
2821 | - |
2822 | -#include <click/configuration.h> |
2823 | -#include <click/reviews.h> |
2824 | -#include <click/webclient.h> |
2825 | - |
2826 | -#include <tests/mock_network_access_manager.h> |
2827 | -#include <tests/mock_ubuntuone_credentials.h> |
2828 | -#include <tests/mock_webclient.h> |
2829 | - |
2830 | -#include "fake_json.h" |
2831 | - |
2832 | -#include <gtest/gtest.h> |
2833 | -#include <memory> |
2834 | -#include <stdlib.h> |
2835 | - |
2836 | -using namespace ::testing; |
2837 | - |
2838 | -namespace |
2839 | -{ |
2840 | - |
2841 | -class ReviewsTest : public ::testing::Test { |
2842 | -protected: |
2843 | - QSharedPointer<MockClient> clientPtr; |
2844 | - QSharedPointer<MockNetworkAccessManager> namPtr; |
2845 | - std::shared_ptr<click::Reviews> reviewsPtr; |
2846 | - |
2847 | - virtual void SetUp() { |
2848 | - namPtr.reset(new MockNetworkAccessManager()); |
2849 | - clientPtr.reset(new NiceMock<MockClient>(namPtr)); |
2850 | - reviewsPtr.reset(new click::Reviews(clientPtr)); |
2851 | - } |
2852 | - |
2853 | -public: |
2854 | - MOCK_METHOD2(reviews_callback, void(click::ReviewList, click::Reviews::Error)); |
2855 | -}; |
2856 | -} |
2857 | - |
2858 | -TEST_F(ReviewsTest, bringToFrontUserMatches) |
2859 | -{ |
2860 | - click::Review r1; |
2861 | - r1.id = 1; |
2862 | - r1.reviewer_username = "user1"; |
2863 | - |
2864 | - click::Review r2; |
2865 | - r2.id = 2; |
2866 | - r2.reviewer_username = "user2"; |
2867 | - |
2868 | - click::Review r3; |
2869 | - r3.id = 3; |
2870 | - r3.reviewer_username = "user3"; |
2871 | - |
2872 | - click::ReviewList reviews {r1, r2, r3}; |
2873 | - |
2874 | - auto newReviews = bring_to_front(reviews, "user2"); |
2875 | - EXPECT_EQ(3u, newReviews.size()); |
2876 | - auto it = newReviews.begin(); |
2877 | - EXPECT_EQ(2u, (*it).id); |
2878 | - ++it; |
2879 | - EXPECT_EQ(1u, (*it).id); |
2880 | - ++it; |
2881 | - EXPECT_EQ(3u, (*it).id); |
2882 | -} |
2883 | - |
2884 | -TEST_F(ReviewsTest, bringToFrontUserMatchesFirstElement) |
2885 | -{ |
2886 | - click::Review r1; |
2887 | - r1.id = 1; |
2888 | - r1.reviewer_username = "user1"; |
2889 | - |
2890 | - click::Review r2; |
2891 | - r2.id = 2; |
2892 | - r2.reviewer_username = "user2"; |
2893 | - |
2894 | - click::ReviewList reviews {r1, r2}; |
2895 | - |
2896 | - auto newReviews = bring_to_front(reviews, "user1"); |
2897 | - EXPECT_EQ(2u, newReviews.size()); |
2898 | - auto it = newReviews.begin(); |
2899 | - EXPECT_EQ(1u, (*it).id); |
2900 | - ++it; |
2901 | - EXPECT_EQ(2u, (*it).id); |
2902 | -} |
2903 | - |
2904 | -TEST_F(ReviewsTest, bringToFrontEmptyList) |
2905 | -{ |
2906 | - click::ReviewList reviews; |
2907 | - |
2908 | - auto newReviews = bring_to_front(reviews, "user1"); |
2909 | - EXPECT_EQ(0u, newReviews.size()); |
2910 | -} |
2911 | - |
2912 | -TEST_F(ReviewsTest, bringToFrontUserDoesntMatch) |
2913 | -{ |
2914 | - click::Review r1; |
2915 | - r1.id = 1; |
2916 | - r1.reviewer_username = "user1"; |
2917 | - |
2918 | - click::Review r2; |
2919 | - r2.id = 2; |
2920 | - r2.reviewer_username = "user2"; |
2921 | - |
2922 | - click::ReviewList reviews {r1, r2}; |
2923 | - |
2924 | - auto newReviews = bring_to_front(reviews, "user0"); |
2925 | - EXPECT_EQ(2u, newReviews.size()); |
2926 | - auto it = newReviews.begin(); |
2927 | - EXPECT_EQ(1u, (*it).id); |
2928 | - ++it; |
2929 | - EXPECT_EQ(2u, (*it).id); |
2930 | -} |
2931 | - |
2932 | -TEST_F(ReviewsTest, testFetchReviewsCallsWebservice) |
2933 | -{ |
2934 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2935 | - auto response = responseForReply(reply.asSharedPtr()); |
2936 | - |
2937 | - EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
2938 | - .Times(1) |
2939 | - .WillOnce(Return(response)); |
2940 | - |
2941 | - reviewsPtr->fetch_reviews("", [](click::ReviewList, |
2942 | - click::Reviews::Error) {}); |
2943 | -} |
2944 | - |
2945 | -TEST_F(ReviewsTest, testFetchReviewsDoesNotSignCall) |
2946 | -{ |
2947 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2948 | - auto response = responseForReply(reply.asSharedPtr()); |
2949 | - |
2950 | - EXPECT_CALL(*clientPtr, callImpl(_, _, false, _, _, _)) |
2951 | - .Times(1) |
2952 | - .WillOnce(Return(response)); |
2953 | - |
2954 | - reviewsPtr->fetch_reviews("", [](click::ReviewList, |
2955 | - click::Reviews::Error) {}); |
2956 | -} |
2957 | - |
2958 | -TEST_F(ReviewsTest, testFetchReviewsSendsQueryAsParam) |
2959 | -{ |
2960 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2961 | - auto response = responseForReply(reply.asSharedPtr()); |
2962 | - |
2963 | - click::web::CallParams params; |
2964 | - params.add(click::REVIEWS_QUERY_ARGNAME, FAKE_PACKAGENAME); |
2965 | - EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, params)) |
2966 | - .Times(1) |
2967 | - .WillOnce(Return(response)); |
2968 | - |
2969 | - reviewsPtr->fetch_reviews(FAKE_PACKAGENAME, [](click::ReviewList, |
2970 | - click::Reviews::Error) {}); |
2971 | -} |
2972 | - |
2973 | -TEST_F(ReviewsTest, testFetchReviewsSendsCorrectPath) |
2974 | -{ |
2975 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2976 | - auto response = responseForReply(reply.asSharedPtr()); |
2977 | - |
2978 | - EXPECT_CALL(*clientPtr, callImpl(EndsWith(click::REVIEWS_API_PATH), |
2979 | - _, _, _, _, _)) |
2980 | - .Times(1) |
2981 | - .WillOnce(Return(response)); |
2982 | - |
2983 | - reviewsPtr->fetch_reviews(FAKE_PACKAGENAME, [](click::ReviewList, |
2984 | - click::Reviews::Error) {}); |
2985 | -} |
2986 | - |
2987 | -TEST_F(ReviewsTest, testFetchReviewsCallbackCalled) |
2988 | -{ |
2989 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
2990 | - auto response = responseForReply(reply.asSharedPtr()); |
2991 | - |
2992 | - QByteArray fake_json("[]"); |
2993 | - EXPECT_CALL(reply.instance, readAll()) |
2994 | - .Times(1) |
2995 | - .WillOnce(Return(fake_json)); |
2996 | - EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
2997 | - .Times(1) |
2998 | - .WillOnce(Return(response)); |
2999 | - EXPECT_CALL(*this, reviews_callback(_, _)).Times(1); |
3000 | - |
3001 | - reviewsPtr->fetch_reviews("", [this](click::ReviewList reviews, |
3002 | - click::Reviews::Error error){ |
3003 | - reviews_callback(reviews, error); |
3004 | - }); |
3005 | - response->replyFinished(); |
3006 | -} |
3007 | - |
3008 | -TEST_F(ReviewsTest, testFetchReviewsNot200) |
3009 | -{ |
3010 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3011 | - auto response = responseForReply(reply.asSharedPtr()); |
3012 | - |
3013 | - EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(301))); |
3014 | - EXPECT_CALL(reply.instance, readAll()) |
3015 | - .Times(1) |
3016 | - .WillOnce(Return(FAKE_JSON_REVIEWS_RESULT_ONE.c_str())); |
3017 | - EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
3018 | - .Times(1) |
3019 | - .WillOnce(Return(response)); |
3020 | - click::ReviewList empty_reviews_list; |
3021 | - EXPECT_CALL(*this, reviews_callback(empty_reviews_list, _)).Times(1); |
3022 | - |
3023 | - reviewsPtr->fetch_reviews("", [this](click::ReviewList reviews, |
3024 | - click::Reviews::Error error){ |
3025 | - reviews_callback(reviews, error); |
3026 | - }); |
3027 | - response->replyFinished(); |
3028 | -} |
3029 | - |
3030 | -TEST_F(ReviewsTest, testFetchReviewsEmptyJsonIsParsed) |
3031 | -{ |
3032 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3033 | - auto response = responseForReply(reply.asSharedPtr()); |
3034 | - |
3035 | - QByteArray fake_json("[]"); |
3036 | - EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(200))); |
3037 | - EXPECT_CALL(reply.instance, readAll()) |
3038 | - .Times(1) |
3039 | - .WillOnce(Return(fake_json)); |
3040 | - EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
3041 | - .Times(1) |
3042 | - .WillOnce(Return(response)); |
3043 | - click::ReviewList empty_reviews_list; |
3044 | - EXPECT_CALL(*this, reviews_callback(empty_reviews_list, _)).Times(1); |
3045 | - |
3046 | - reviewsPtr->fetch_reviews("", [this](click::ReviewList reviews, |
3047 | - click::Reviews::Error error){ |
3048 | - reviews_callback(reviews, error); |
3049 | - }); |
3050 | - response->replyFinished(); |
3051 | -} |
3052 | - |
3053 | -TEST_F(ReviewsTest, testFetchReviewsSingleJsonIsParsed) |
3054 | -{ |
3055 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3056 | - auto response = responseForReply(reply.asSharedPtr()); |
3057 | - |
3058 | - QByteArray fake_json(FAKE_JSON_REVIEWS_RESULT_ONE.c_str()); |
3059 | - EXPECT_CALL(reply.instance, attribute(_)).WillOnce(Return(QVariant(200))); |
3060 | - EXPECT_CALL(reply.instance, readAll()) |
3061 | - .Times(1) |
3062 | - .WillOnce(Return(fake_json)); |
3063 | - EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
3064 | - .Times(1) |
3065 | - .WillOnce(Return(response)); |
3066 | - click::ReviewList single_review_list = |
3067 | - { |
3068 | - click::Review |
3069 | - { |
3070 | - 1, 4, 0, 0, false, |
3071 | - "2014-01-28T09:09:47.218Z", "null", |
3072 | - FAKE_PACKAGENAME, "0.2", |
3073 | - "en", |
3074 | - "Review Summary", "It is ok.", |
3075 | - "Reviewer", "reviewer" |
3076 | - } |
3077 | - }; |
3078 | - EXPECT_CALL(*this, reviews_callback(single_review_list, _)).Times(1); |
3079 | - |
3080 | - reviewsPtr->fetch_reviews("", [this](click::ReviewList reviews, |
3081 | - click::Reviews::Error error){ |
3082 | - reviews_callback(reviews, error); |
3083 | - }); |
3084 | - response->replyFinished(); |
3085 | -} |
3086 | - |
3087 | -TEST_F(ReviewsTest, testFetchReviewsNetworkErrorReported) |
3088 | -{ |
3089 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3090 | - auto response = responseForReply(reply.asSharedPtr()); |
3091 | - |
3092 | - EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
3093 | - .Times(1) |
3094 | - .WillOnce(Return(response)); |
3095 | - EXPECT_CALL(reply.instance, errorString()) |
3096 | - .Times(1) |
3097 | - .WillOnce(Return("fake error")); |
3098 | - reviewsPtr->fetch_reviews("", [this](click::ReviewList reviews, |
3099 | - click::Reviews::Error error){ |
3100 | - reviews_callback(reviews, error); |
3101 | - }); |
3102 | - click::ReviewList empty_reviews_list; |
3103 | - EXPECT_CALL(*this, reviews_callback(empty_reviews_list, |
3104 | - click::Reviews::Error::NetworkError)) |
3105 | - .Times(1); |
3106 | - |
3107 | - emit reply.instance.error(QNetworkReply::UnknownNetworkError); |
3108 | -} |
3109 | - |
3110 | -TEST_F(ReviewsTest, testFetchReviewsIsCancellable) |
3111 | -{ |
3112 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3113 | - auto response = responseForReply(reply.asSharedPtr()); |
3114 | - |
3115 | - EXPECT_CALL(*clientPtr, callImpl(_, _, _, _, _, _)) |
3116 | - .Times(1) |
3117 | - .WillOnce(Return(response)); |
3118 | - |
3119 | - auto fetch_reviews_op = reviewsPtr->fetch_reviews("", [](click::ReviewList, |
3120 | - click::Reviews::Error) {}); |
3121 | - EXPECT_CALL(reply.instance, abort()).Times(1); |
3122 | - fetch_reviews_op.cancel(); |
3123 | -} |
3124 | - |
3125 | -TEST_F(ReviewsTest, testSubmitReviewIsCancellable) |
3126 | -{ |
3127 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3128 | - auto response = responseForReply(reply.asSharedPtr()); |
3129 | - |
3130 | - click::Review review; |
3131 | - review.rating = 3; |
3132 | - review.review_text = "A review"; |
3133 | - review.package_name = "com.example.test"; |
3134 | - review.package_version = "0.1"; |
3135 | - |
3136 | - EXPECT_CALL(*clientPtr, callImpl(_, "POST", true, _, _, _)) |
3137 | - .Times(1) |
3138 | - .WillOnce(Return(response)); |
3139 | - |
3140 | - auto submit_op = reviewsPtr->submit_review(review, |
3141 | - [](click::Reviews::Error){}); |
3142 | - EXPECT_CALL(reply.instance, abort()).Times(1); |
3143 | - submit_op.cancel(); |
3144 | -} |
3145 | - |
3146 | -TEST_F(ReviewsTest, testSubmitReviewUtf8) |
3147 | -{ |
3148 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3149 | - auto response = responseForReply(reply.asSharedPtr()); |
3150 | - |
3151 | - click::Review review; |
3152 | - review.rating = 3; |
3153 | - review.review_text = "'\"小海嚴選"; |
3154 | - review.package_name = "com.example.test"; |
3155 | - review.package_version = "0.1"; |
3156 | - |
3157 | - // NOTE: gmock replaces the \" above as \\\" for HasSubstr(), so we have |
3158 | - // to manually copy the string into the expected result. |
3159 | - std::string expected_review_text = "\"review_text\":\"'\\\"小海嚴選\""; |
3160 | - |
3161 | - EXPECT_CALL(*clientPtr, callImpl(_, "POST", true, _, |
3162 | - HasSubstr(expected_review_text), _)) |
3163 | - .Times(1) |
3164 | - .WillOnce(Return(response)); |
3165 | - |
3166 | - auto submit_op = reviewsPtr->submit_review(review, |
3167 | - [](click::Reviews::Error){}); |
3168 | -} |
3169 | - |
3170 | -TEST_F(ReviewsTest, testSubmitReviewLanguageCorrect) |
3171 | -{ |
3172 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3173 | - auto response = responseForReply(reply.asSharedPtr()); |
3174 | - |
3175 | - click::Review review; |
3176 | - review.rating = 3; |
3177 | - review.review_text = "A review."; |
3178 | - review.package_name = "com.example.test"; |
3179 | - review.package_version = "0.1"; |
3180 | - |
3181 | - ASSERT_EQ(setenv(click::Configuration::LANGUAGE_ENVVAR, |
3182 | - "es_AR.UTF-8", 1), 0); |
3183 | - std::string expected_language = "\"language\":\"es\""; |
3184 | - EXPECT_CALL(*clientPtr, callImpl(_, "POST", true, _, |
3185 | - HasSubstr(expected_language), _)) |
3186 | - .Times(1) |
3187 | - .WillOnce(Return(response)); |
3188 | - |
3189 | - auto submit_op = reviewsPtr->submit_review(review, |
3190 | - [](click::Reviews::Error){}); |
3191 | - ASSERT_EQ(unsetenv(click::Configuration::LANGUAGE_ENVVAR), 0); |
3192 | -} |
3193 | - |
3194 | -TEST_F(ReviewsTest, testSubmitReviewLanguageCorrectForFullLangCodes) |
3195 | -{ |
3196 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3197 | - auto response = responseForReply(reply.asSharedPtr()); |
3198 | - |
3199 | - click::Review review; |
3200 | - review.rating = 3; |
3201 | - review.review_text = "A review."; |
3202 | - review.package_name = "com.example.test"; |
3203 | - review.package_version = "0.1"; |
3204 | - |
3205 | - for (std::string lang: click::Configuration::FULL_LANG_CODES) { |
3206 | - ASSERT_EQ(setenv(click::Configuration::LANGUAGE_ENVVAR, |
3207 | - lang.c_str(), 1), 0); |
3208 | - std::string expected_language = "\"language\":\"" + lang + "\""; |
3209 | - EXPECT_CALL(*clientPtr, callImpl(_, "POST", true, _, |
3210 | - HasSubstr(expected_language), _)) |
3211 | - .Times(1) |
3212 | - .WillOnce(Return(response)); |
3213 | - |
3214 | - auto submit_op = reviewsPtr->submit_review(review, |
3215 | - [](click::Reviews::Error){}); |
3216 | - ASSERT_EQ(unsetenv(click::Configuration::LANGUAGE_ENVVAR), 0); |
3217 | - } |
3218 | -} |
3219 | - |
3220 | -TEST_F(ReviewsTest, testEditReviewUrlHasReviewId) |
3221 | -{ |
3222 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3223 | - auto response = responseForReply(reply.asSharedPtr()); |
3224 | - |
3225 | - click::Review review; |
3226 | - review.id = 1234; |
3227 | - review.rating = 4; |
3228 | - review.review_text = "A review"; |
3229 | - review.package_name = "com.example.test"; |
3230 | - review.package_version = "0.1"; |
3231 | - |
3232 | - EXPECT_CALL(*clientPtr, callImpl(HasSubstr("/1234/"), "PUT", true, _, _, _)) |
3233 | - .Times(1) |
3234 | - .WillOnce(Return(response)); |
3235 | - |
3236 | - auto submit_op = reviewsPtr->edit_review(review, |
3237 | - [](click::Reviews::Error){}); |
3238 | -} |
3239 | - |
3240 | -TEST_F(ReviewsTest, testEditReviewIsCancellable) |
3241 | -{ |
3242 | - LifetimeHelper<click::network::Reply, MockNetworkReply> reply; |
3243 | - auto response = responseForReply(reply.asSharedPtr()); |
3244 | - |
3245 | - click::Review review; |
3246 | - review.id = 1234; |
3247 | - review.rating = 4; |
3248 | - review.review_text = "A review"; |
3249 | - review.package_name = "com.example.test"; |
3250 | - review.package_version = "0.1"; |
3251 | - |
3252 | - EXPECT_CALL(*clientPtr, callImpl(_, "PUT", true, _, _, _)) |
3253 | - .Times(1) |
3254 | - .WillOnce(Return(response)); |
3255 | - |
3256 | - auto submit_op = reviewsPtr->edit_review(review, |
3257 | - [](click::Reviews::Error){}); |
3258 | - EXPECT_CALL(reply.instance, abort()).Times(1); |
3259 | - submit_op.cancel(); |
3260 | -} |
3261 | - |
3262 | - |
3263 | -TEST_F(ReviewsTest, testGetBaseUrl) |
3264 | -{ |
3265 | - const char *value = getenv(click::REVIEWS_BASE_URL_ENVVAR.c_str()); |
3266 | - if (value != NULL) { |
3267 | - ASSERT_TRUE(unsetenv(click::REVIEWS_BASE_URL_ENVVAR.c_str()) == 0); |
3268 | - } |
3269 | - ASSERT_TRUE(click::Reviews::get_base_url() == click::REVIEWS_BASE_URL); |
3270 | - |
3271 | -} |
3272 | - |
3273 | -TEST_F(ReviewsTest, testGetBaseUrlFromEnv) |
3274 | -{ |
3275 | - ASSERT_TRUE(setenv(click::REVIEWS_BASE_URL_ENVVAR.c_str(), |
3276 | - FAKE_SERVER.c_str(), 1) == 0); |
3277 | - ASSERT_TRUE(click::Reviews::get_base_url() == FAKE_SERVER); |
3278 | - ASSERT_TRUE(unsetenv(click::REVIEWS_BASE_URL_ENVVAR.c_str()) == 0); |
3279 | -} |
3280 | |
3281 | === modified file 'scope/clickapps/apps-scope.cpp' |
3282 | --- scope/clickapps/apps-scope.cpp 2016-11-08 13:42:04 +0000 |
3283 | +++ scope/clickapps/apps-scope.cpp 2017-01-10 16:06:37 +0000 |
3284 | @@ -81,7 +81,6 @@ |
3285 | static const int zero = 0; |
3286 | auto emptyCb = [this]() |
3287 | { |
3288 | - dm.reset(Ubuntu::DownloadManager::Manager::createSessionManager()); |
3289 | qt_ready_for_search_p.set_value(); |
3290 | |
3291 | sso.reset(new click::CredentialsService()); |
3292 | @@ -107,57 +106,19 @@ |
3293 | const unity::scopes::ActionMetadata& metadata) { |
3294 | qDebug() << "Scope::preview() called."; |
3295 | auto preview = new click::Preview(result, metadata, qt_ready_for_preview_f.share()); |
3296 | - preview->choose_strategy(client, dm, depts_db); |
3297 | + preview->choose_strategy(client, depts_db); |
3298 | return unity::scopes::PreviewQueryBase::UPtr{preview}; |
3299 | } |
3300 | |
3301 | |
3302 | unity::scopes::ActivationQueryBase::UPtr click::Scope::perform_action(unity::scopes::Result const& result, unity::scopes::ActionMetadata const& metadata, |
3303 | - std::string const& widget_id, std::string const& action_id) |
3304 | + std::string const&, std::string const& action_id) |
3305 | { |
3306 | - if (action_id == click::Preview::Actions::CONFIRM_UNINSTALL) { |
3307 | - return scopes::ActivationQueryBase::UPtr(new PerformUninstallAction(result, metadata)); |
3308 | - } |
3309 | - |
3310 | auto activation = new ScopeActivation(result, metadata); |
3311 | qDebug() << "perform_action called with action_id" << QString().fromStdString(action_id); |
3312 | |
3313 | - if (action_id == click::Preview::Actions::UNINSTALL_CLICK) { |
3314 | - activation->setHint(click::Preview::Actions::UNINSTALL_CLICK, unity::scopes::Variant(true)); |
3315 | - activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview); |
3316 | - } else if (action_id == click::Preview::Actions::CANCEL_PURCHASE_INSTALLED) { |
3317 | - activation->setHint(click::Preview::Actions::CANCEL_PURCHASE_INSTALLED, unity::scopes::Variant(true)); |
3318 | - activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview); |
3319 | - } else if (action_id == click::Preview::Actions::CANCEL_PURCHASE_UNINSTALLED) { |
3320 | - activation->setHint(click::Preview::Actions::CANCEL_PURCHASE_UNINSTALLED, unity::scopes::Variant(true)); |
3321 | - activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview); |
3322 | - } else if (action_id == click::Preview::Actions::SHOW_INSTALLED) { |
3323 | + if (action_id == click::Preview::Actions::SHOW_INSTALLED) { |
3324 | activation->setHint(click::Preview::Actions::SHOW_INSTALLED, unity::scopes::Variant(true)); |
3325 | - activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview); |
3326 | - } else if (action_id == click::Preview::Actions::SHOW_UNINSTALLED) { |
3327 | - activation->setHint(click::Preview::Actions::SHOW_UNINSTALLED, unity::scopes::Variant(true)); |
3328 | - activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview); |
3329 | - } else if (action_id == click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED) { |
3330 | - activation->setHint(click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED, unity::scopes::Variant(true)); |
3331 | - activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview); |
3332 | - } else if (action_id == click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED) { |
3333 | - activation->setHint(click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED, unity::scopes::Variant(true)); |
3334 | - activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview); |
3335 | - } else if (action_id == click::Preview::Actions::RATED) { |
3336 | - scopes::VariantMap rating_info = metadata.scope_data().get_dict(); |
3337 | - // Cast to int because widget gives us double, which is wrong. |
3338 | - int rating = ((int)rating_info["rating"].get_double()); |
3339 | - std::string review_text = rating_info["review"].get_string(); |
3340 | - |
3341 | - // We have to get the values and then set them as hints here, to be |
3342 | - // able to pass them on to the Preview, which actually makes the |
3343 | - // call to submit. |
3344 | - activation->setHint("rating", scopes::Variant(rating)); |
3345 | - activation->setHint("review", scopes::Variant(review_text)); |
3346 | - activation->setHint(click::Preview::Actions::RATED, |
3347 | - scopes::Variant(true)); |
3348 | - activation->setHint("widget_id", scopes::Variant(widget_id)); |
3349 | - activation->setStatus(scopes::ActivationResponse::Status::ShowPreview); |
3350 | } |
3351 | return scopes::ActivationQueryBase::UPtr(activation); |
3352 | } |
3353 | |
3354 | === modified file 'scope/clickapps/apps-scope.h' |
3355 | --- scope/clickapps/apps-scope.h 2016-10-24 21:26:23 +0000 |
3356 | +++ scope/clickapps/apps-scope.h 2017-01-10 16:06:37 +0000 |
3357 | @@ -34,7 +34,6 @@ |
3358 | #include <click/network_access_manager.h> |
3359 | #include <click/webclient.h> |
3360 | |
3361 | -#include <ubuntu/download_manager/manager.h> |
3362 | #include <unity/scopes/ScopeBase.h> |
3363 | #include <unity/scopes/QueryBase.h> |
3364 | #include <unity/scopes/ActivationQueryBase.h> |
3365 | @@ -73,7 +72,6 @@ |
3366 | QSharedPointer<click::network::AccessManager> nam; |
3367 | QSharedPointer<click::web::Client> client; |
3368 | QSharedPointer<click::Index> index; |
3369 | - QSharedPointer<Ubuntu::DownloadManager::Manager> dm; |
3370 | QSharedPointer<click::CredentialsService> sso; |
3371 | std::shared_ptr<click::DepartmentsDb> depts_db; |
3372 | |
3373 | |
3374 | === modified file 'scope/tests/test_apps_scope.cpp' |
3375 | --- scope/tests/test_apps_scope.cpp 2015-11-24 18:23:23 +0000 |
3376 | +++ scope/tests/test_apps_scope.cpp 2017-01-10 16:06:37 +0000 |
3377 | @@ -53,32 +53,6 @@ |
3378 | } |
3379 | }; |
3380 | |
3381 | -TEST_F(AppsScopeTest, DISABLED_testConfirmUninstall) |
3382 | -{ |
3383 | - result.set_title("foo"); |
3384 | - result[click::apps::Query::ResultKeys::NAME] = "foo.name"; |
3385 | - result[click::apps::Query::ResultKeys::VERSION] = "0.1"; |
3386 | - auto activation = scope.perform_action(result, metadata, "widget", |
3387 | - click::Preview::Actions::CONFIRM_UNINSTALL); |
3388 | - auto response = activation->activate(); |
3389 | -} |
3390 | - |
3391 | -TEST_F(AppsScopeTest, testCancelPurchaseInstalled) |
3392 | -{ |
3393 | - auto activation = scope.perform_action(result, metadata, "button", |
3394 | - click::Preview::Actions::CANCEL_PURCHASE_INSTALLED); |
3395 | - auto response = activation->activate(); |
3396 | - EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CANCEL_PURCHASE_INSTALLED].get_bool()); |
3397 | -} |
3398 | - |
3399 | -TEST_F(AppsScopeTest, testCancelPurchaseUninstalled) |
3400 | -{ |
3401 | - auto activation = scope.perform_action(result, metadata, "button", |
3402 | - click::Preview::Actions::CANCEL_PURCHASE_UNINSTALLED); |
3403 | - auto response = activation->activate(); |
3404 | - EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CANCEL_PURCHASE_UNINSTALLED].get_bool()); |
3405 | -} |
3406 | - |
3407 | TEST_F(AppsScopeTest, testShowInstalled) |
3408 | { |
3409 | auto activation = scope.perform_action(result, metadata, "button", |
3410 | @@ -86,43 +60,3 @@ |
3411 | auto response = activation->activate(); |
3412 | EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::SHOW_INSTALLED].get_bool()); |
3413 | } |
3414 | - |
3415 | -TEST_F(AppsScopeTest, testShowUninstalled) |
3416 | -{ |
3417 | - auto activation = scope.perform_action(result, metadata, "button", |
3418 | - click::Preview::Actions::SHOW_UNINSTALLED); |
3419 | - auto response = activation->activate(); |
3420 | - EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::SHOW_UNINSTALLED].get_bool()); |
3421 | -} |
3422 | - |
3423 | -TEST_F(AppsScopeTest, testConfirmCancelPurchaseUninstalled) |
3424 | -{ |
3425 | - auto activation = scope.perform_action(result, metadata, "widget_id", |
3426 | - click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED); |
3427 | - auto response = activation->activate(); |
3428 | - EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED].get_bool()); |
3429 | -} |
3430 | - |
3431 | -TEST_F(AppsScopeTest, testConfirmCancelPurcahseInstalled) |
3432 | -{ |
3433 | - auto activation = scope.perform_action(result, metadata, "widget_id", |
3434 | - click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED); |
3435 | - auto response = activation->activate(); |
3436 | - EXPECT_TRUE(response.scope_data().get_dict()[click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED].get_bool()); |
3437 | -} |
3438 | - |
3439 | -TEST_F(AppsScopeTest, testRatingNew) |
3440 | -{ |
3441 | - auto activation = scope.perform_action(result, metadata, "rating", |
3442 | - click::Preview::Actions::RATED); |
3443 | - auto response = activation->activate(); |
3444 | - EXPECT_EQ("rating", response.scope_data().get_dict()["widget_id"].get_string()); |
3445 | -} |
3446 | - |
3447 | -TEST_F(AppsScopeTest, testRatingEdit) |
3448 | -{ |
3449 | - auto activation = scope.perform_action(result, metadata, "93345", |
3450 | - click::Preview::Actions::RATED); |
3451 | - auto response = activation->activate(); |
3452 | - EXPECT_EQ("93345", response.scope_data().get_dict()["widget_id"].get_string()); |
3453 | -} |
FAILED: Continuous integration, rev:504 /jenkins. canonical. com/unity- api-1/job/ lp-unity- scope-click- ci/130/ /jenkins. canonical. com/unity- api-1/job/ build/1248/ console /jenkins. canonical. com/unity- api-1/job/ build-0- fetch/1255 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 1038/console /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= zesty/1038/ console /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 1038/console /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= zesty/1038/ console /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 1038/console /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= zesty/1038/ console
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/unity- api-1/job/ lp-unity- scope-click- ci/130/ rebuild
https:/