Merge lp:~stolowski/unity-scope-click/two-scopes into lp:unity-scope-click/devel
- two-scopes
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Alejandro J. Cura |
Approved revision: | 301 |
Merged at revision: | 282 |
Proposed branch: | lp:~stolowski/unity-scope-click/two-scopes |
Merge into: | lp:unity-scope-click/devel |
Diff against target: |
1160 lines (+735/-115) 25 files modified
CMakeLists.txt (+10/-5) data/CMakeLists.txt (+41/-19) data/clickscope.ini.in.in (+8/-0) data/com.canonical.scopes.clickstore.ini.in.in (+3/-3) libclickscope/click/interface.cpp (+0/-5) libclickscope/click/preview.cpp (+28/-0) libclickscope/click/preview.h (+7/-0) libclickscope/click/scope_activation.cpp (+31/-0) libclickscope/click/scope_activation.h (+13/-0) po/POTFILES.in (+5/-3) scope/CMakeLists.txt (+3/-2) scope/clickapps/CMakeLists.txt (+37/-0) scope/clickapps/apps-query.cpp (+218/-0) scope/clickapps/apps-query.h (+82/-0) scope/clickapps/apps-scope.cpp (+158/-0) scope/clickapps/apps-scope.h (+71/-0) scope/clickstore/CMakeLists.txt (+8/-7) scope/clickstore/store-query.cpp (+3/-39) scope/clickstore/store-query.h (+2/-5) scope/clickstore/store-scope.cpp (+2/-2) scope/tests/CMakeLists.txt (+1/-1) scope/tests/click_interface_tool/CMakeLists.txt (+1/-1) scope/tests/download_manager_tool/CMakeLists.txt (+1/-1) scope/tests/integration/CMakeLists.txt (+1/-1) scope/tests/test_query.cpp (+1/-21) |
To merge this branch: | bzr merge lp:~stolowski/unity-scope-click/two-scopes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alejandro J. Cura (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+221921@code.launchpad.net |
Commit message
Split click scope into two scopes.
Description of the change
This branch splits click scope into two scopes - Apps scope and Ubuntu store scope, as per latest designs. The store scope can be activated by clicking on a "Ubuntu store" icon shown in Apps scope, or from Scopes Scope.
Note: this is not fully finished; we need finalized design to tweak the look of the card/icon. We also need unity8 to treat the headerless category with Ubuntu store icon as local category (similar to installed apps), so that preview is not requested for it. For now (until that hack is added to unity8), I added a temporary InstalledScopeP
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:300
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alejandro J. Cura (alecu) wrote : | # |
Tested on Nexus 4 (mako), works ok.
Please add a bug (in unity8, or where's needed) for the clicking of the "banner" that leads to an intermediate preview, and add it to this proposal's description. Otherwise the code looks good.
Paweł Stołowski (stolowski) wrote : | # |
> Tested on Nexus 4 (mako), works ok.
> Please add a bug (in unity8, or where's needed) for the clicking of the
> "banner" that leads to an intermediate preview, and add it to this proposal's
> description. Otherwise the code looks good.
Bug added, https:/
Paweł Stołowski (stolowski) wrote : | # |
Also added unity8 bug for the lack of margin: https:/
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:301
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Alejandro J. Cura (alecu) wrote : | # |
With the latests changes it looks much nicer, +1
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2014-05-23 18:47:34 +0000 |
3 | +++ CMakeLists.txt 2014-06-04 14:46:15 +0000 |
4 | @@ -14,8 +14,10 @@ |
5 | |
6 | include(GNUInstallDirs) |
7 | |
8 | -set(SCOPE_LIB_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/unity-scopes/clickscope/) |
9 | -set(SCOPE_DATA_DIR ${CMAKE_INSTALL_FULL_DATADIR}/unity/scopes/clickscope/) |
10 | +set(STORE_LIB_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/unity-scopes/clickstore/) |
11 | +set(STORE_DATA_DIR ${CMAKE_INSTALL_FULL_DATADIR}/unity/scopes/clickstore/) |
12 | +set(APPS_LIB_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/unity-scopes/clickapps/) |
13 | +set(APPS_DATA_DIR ${CMAKE_INSTALL_FULL_DATADIR}/unity/scopes/clickapps/) |
14 | |
15 | include(FindPkgConfig) |
16 | |
17 | @@ -32,8 +34,11 @@ |
18 | SET (SCOPE_LIB_VERSION 0.2.0) |
19 | SET (SCOPE_LIB_SOVERSION 0) |
20 | SET (SCOPE_LIB_API_VERSION 2.0) |
21 | -SET (SCOPE_LIB_UNVERSIONED clickscope) |
22 | -SET (SCOPE_LIB_NAME ${SCOPE_LIB_UNVERSIONED}-${SCOPE_LIB_API_VERSION}) |
23 | +SET (STORE_LIB_UNVERSIONED com.canonical.scopes.clickstore) |
24 | +SET (SCOPE_LIB_NAME clickscope) |
25 | +SET (STORE_LIB_NAME ${STORE_LIB_UNVERSIONED}-${SCOPE_LIB_API_VERSION}) |
26 | +SET (APPS_LIB_UNVERSIONED scope) |
27 | +SET (APPS_LIB_NAME ${APPS_LIB_UNVERSIONED}-${SCOPE_LIB_API_VERSION}) |
28 | |
29 | # Build with system gmock and embedded gtest |
30 | set (GMOCK_INCLUDE_DIR "/usr/include/gmock/include" CACHE PATH "gmock source include directory") |
31 | @@ -108,4 +113,4 @@ |
32 | |
33 | add_custom_target (check-leaks |
34 | DEPENDS test-leaks |
35 | -) |
36 | \ No newline at end of file |
37 | +) |
38 | |
39 | === modified file 'data/CMakeLists.txt' |
40 | --- data/CMakeLists.txt 2014-04-29 18:42:40 +0000 |
41 | +++ data/CMakeLists.txt 2014-06-04 14:46:15 +0000 |
42 | @@ -1,21 +1,43 @@ |
43 | find_program(INTLTOOL_MERGE intltool-merge) |
44 | -set(SCOPE_INI_TARGET clickscope.ini) |
45 | - |
46 | -configure_file( |
47 | - ${SCOPE_INI_TARGET}.in.in |
48 | - ${SCOPE_INI_TARGET}.in |
49 | -) |
50 | - |
51 | -add_custom_target(${SCOPE_INI_TARGET} ALL |
52 | - COMMENT "Merging translations into ${SCOPE_INI_TARGET}" |
53 | - COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_SOURCE_DIR}/po ${SCOPE_INI_TARGET}.in ${SCOPE_INI_TARGET} >/dev/null |
54 | -) |
55 | - |
56 | -install( |
57 | - FILES clickscope-screenshot.jpg apps-scope.svg |
58 | - DESTINATION "${SCOPE_DATA_DIR}" |
59 | -) |
60 | -install( |
61 | - FILES "${CMAKE_CURRENT_BINARY_DIR}/${SCOPE_INI_TARGET}" |
62 | - DESTINATION "${SCOPE_LIB_DIR}" |
63 | +set(STORE_INI_TARGET com.canonical.scopes.clickstore.ini) |
64 | +set(APPS_INI_TARGET clickscope.ini) |
65 | + |
66 | +configure_file( |
67 | + ${STORE_INI_TARGET}.in.in |
68 | + ${STORE_INI_TARGET}.in |
69 | +) |
70 | + |
71 | +configure_file( |
72 | + ${APPS_INI_TARGET}.in.in |
73 | + ${APPS_INI_TARGET}.in |
74 | +) |
75 | + |
76 | +add_custom_target(${STORE_INI_TARGET} ALL |
77 | + COMMENT "Merging translations into ${STORE_INI_TARGET}" |
78 | + COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_SOURCE_DIR}/po ${STORE_INI_TARGET}.in ${STORE_INI_TARGET} >/dev/null |
79 | +) |
80 | + |
81 | +add_custom_target(${APPS_INI_TARGET} ALL |
82 | + COMMENT "Merging translations into ${APPS_INI_TARGET}" |
83 | + COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_SOURCE_DIR}/po ${APPS_INI_TARGET}.in ${APPS_INI_TARGET} >/dev/null |
84 | +) |
85 | + |
86 | +install( |
87 | + FILES clickscope-screenshot.jpg apps-scope.svg |
88 | + DESTINATION "${STORE_DATA_DIR}" |
89 | +) |
90 | + |
91 | +install( |
92 | + FILES clickscope-screenshot.jpg apps-scope.svg |
93 | + DESTINATION "${APPS_DATA_DIR}" |
94 | +) |
95 | + |
96 | +install( |
97 | + FILES "${CMAKE_CURRENT_BINARY_DIR}/${STORE_INI_TARGET}" |
98 | + DESTINATION "${STORE_LIB_DIR}" |
99 | +) |
100 | + |
101 | +install( |
102 | + FILES "${CMAKE_CURRENT_BINARY_DIR}/${APPS_INI_TARGET}" |
103 | + DESTINATION "${APPS_LIB_DIR}" |
104 | ) |
105 | |
106 | === added file 'data/clickscope.ini.in.in' |
107 | --- data/clickscope.ini.in.in 1970-01-01 00:00:00 +0000 |
108 | +++ data/clickscope.ini.in.in 2014-06-04 14:46:15 +0000 |
109 | @@ -0,0 +1,8 @@ |
110 | +[ScopeConfig] |
111 | +_DisplayName=Apps |
112 | +_Description=Scope for searching the installed click apps |
113 | +Author=Canonical Ltd. |
114 | +Art=@APPS_DATA_DIR@/clickscope-screenshot.jpg |
115 | +Icon=@APPS_DATA_DIR@/apps-scope.svg |
116 | +SearchHint=clickscope.SearchHint |
117 | +HotKey=clickscope.HotKey |
118 | |
119 | === renamed file 'data/clickscope.ini.in.in' => 'data/com.canonical.scopes.clickstore.ini.in.in' |
120 | --- data/clickscope.ini.in.in 2014-04-29 18:42:40 +0000 |
121 | +++ data/com.canonical.scopes.clickstore.ini.in.in 2014-06-04 14:46:15 +0000 |
122 | @@ -1,8 +1,8 @@ |
123 | [ScopeConfig] |
124 | -_DisplayName=Apps |
125 | +_DisplayName=Ubuntu Store |
126 | _Description=Scope for searching the click app store |
127 | Author=Canonical Ltd. |
128 | -Art=@SCOPE_DATA_DIR@/clickscope-screenshot.jpg |
129 | -Icon=@SCOPE_DATA_DIR@/apps-scope.svg |
130 | +Art=@STORE_DATA_DIR@/clickscope-screenshot.jpg |
131 | +Icon=@STORE_DATA_DIR@/apps-scope.svg |
132 | SearchHint=clickscope.SearchHint |
133 | HotKey=clickscope.HotKey |
134 | |
135 | === modified file 'libclickscope/click/interface.cpp' |
136 | --- libclickscope/click/interface.cpp 2014-05-26 14:02:45 +0000 |
137 | +++ libclickscope/click/interface.cpp 2014-06-04 14:46:15 +0000 |
138 | @@ -217,11 +217,6 @@ |
139 | }; |
140 | |
141 | keyFileLocator->enumerateKeyFilesForInstalledApplications(enumerator); |
142 | - // Sort applications so that newest come first. |
143 | - std::sort(result.begin(), result.end(), [](const Application& a, |
144 | - const Application& b) { |
145 | - return a.installed_time > b.installed_time; |
146 | - }); |
147 | return result; |
148 | } |
149 | |
150 | |
151 | === modified file 'libclickscope/click/preview.cpp' |
152 | --- libclickscope/click/preview.cpp 2014-05-26 14:02:45 +0000 |
153 | +++ libclickscope/click/preview.cpp 2014-06-04 14:46:15 +0000 |
154 | @@ -100,6 +100,10 @@ |
155 | } |
156 | } else { |
157 | // metadata.scope_data() is Null, so we return an appropriate "default" preview: |
158 | + if (result.uri().find("scope://") == 0) |
159 | + { |
160 | + return new InstalledScopePreview(result); |
161 | + } |
162 | if (result["installed"].get_bool() == true) { |
163 | return new InstalledPreview(result, metadata, client); |
164 | } else { |
165 | @@ -547,6 +551,30 @@ |
166 | } |
167 | } |
168 | |
169 | +// class InstalledScopePreview |
170 | +// this is a temporary fallback preview to get into the Store scope, the proper |
171 | +// requires 'store' category to be treated special (like 'local') in unity8 shell. |
172 | + |
173 | +InstalledScopePreview::InstalledScopePreview(const unity::scopes::Result& result) |
174 | + : PreviewStrategy(result) |
175 | +{ |
176 | +} |
177 | + |
178 | +void InstalledScopePreview::run(unity::scopes::PreviewReplyProxy const& reply) |
179 | +{ |
180 | + scopes::PreviewWidget actions("actions", "actions"); |
181 | + { |
182 | + scopes::VariantBuilder builder; |
183 | + builder.add_tuple({ |
184 | + {"id", scopes::Variant("search")}, |
185 | + {"uri", scopes::Variant(result.uri())}, |
186 | + {"label", scopes::Variant(_("Search"))} |
187 | + }); |
188 | + actions.add_attribute_value("actions", builder.end()); |
189 | + } |
190 | + |
191 | + reply->push({actions}); |
192 | +} |
193 | |
194 | // class PurchasingPreview |
195 | |
196 | |
197 | === modified file 'libclickscope/click/preview.h' |
198 | --- libclickscope/click/preview.h 2014-05-26 14:02:45 +0000 |
199 | +++ libclickscope/click/preview.h 2014-06-04 14:46:15 +0000 |
200 | @@ -172,6 +172,13 @@ |
201 | scopes::ActionMetadata metadata; |
202 | }; |
203 | |
204 | +class InstalledScopePreview : public PreviewStrategy |
205 | +{ |
206 | +public: |
207 | + InstalledScopePreview(const unity::scopes::Result& result); |
208 | + void run(unity::scopes::PreviewReplyProxy const& reply) override; |
209 | +}; |
210 | + |
211 | class PurchasingPreview : public PreviewStrategy |
212 | { |
213 | public: |
214 | |
215 | === modified file 'libclickscope/click/scope_activation.cpp' |
216 | --- libclickscope/click/scope_activation.cpp 2014-05-26 14:02:45 +0000 |
217 | +++ libclickscope/click/scope_activation.cpp 2014-06-04 14:46:15 +0000 |
218 | @@ -28,6 +28,9 @@ |
219 | */ |
220 | |
221 | #include "scope_activation.h" |
222 | +#include <click/package.h> |
223 | +#include <click/interface.h> |
224 | +#include <click/qtbridge.h> |
225 | #include <unity/scopes/ActivationResponse.h> |
226 | |
227 | unity::scopes::ActivationResponse click::ScopeActivation::activate() |
228 | @@ -46,3 +49,31 @@ |
229 | { |
230 | hints_[key] = value; |
231 | } |
232 | + |
233 | +click::PerformUninstallAction::PerformUninstallAction(const unity::scopes::Result& result, const unity::scopes::ActivationResponse& response) |
234 | + : result(result), |
235 | + response(response) |
236 | +{ |
237 | +} |
238 | + |
239 | +unity::scopes::ActivationResponse click::PerformUninstallAction::activate() |
240 | +{ |
241 | + click::Package package; |
242 | + package.title = result.title(); |
243 | + package.name = result["name"].get_string(); |
244 | + package.version = result["version"].get_string(); |
245 | + qt::core::world::enter_with_task([this, package] () |
246 | + { |
247 | + click::PackageManager manager; |
248 | + manager.uninstall(package, [&](int code, std::string stderr_content) { |
249 | + if (code != 0) { |
250 | + qDebug() << "Error removing package:" << stderr_content.c_str(); |
251 | + } else { |
252 | + qDebug() << "successfully removed package"; |
253 | + |
254 | + } |
255 | + } ); |
256 | + }); |
257 | + |
258 | + return response; |
259 | +} |
260 | |
261 | === modified file 'libclickscope/click/scope_activation.h' |
262 | --- libclickscope/click/scope_activation.h 2014-05-26 14:02:45 +0000 |
263 | +++ libclickscope/click/scope_activation.h 2014-06-04 14:46:15 +0000 |
264 | @@ -31,10 +31,23 @@ |
265 | #define CLICK_SCOPE_ACTIVATION_H |
266 | |
267 | #include <unity/scopes/ActivationQueryBase.h> |
268 | +#include <unity/scopes/ActivationResponse.h> |
269 | +#include <unity/scopes/Result.h> |
270 | |
271 | namespace click |
272 | { |
273 | |
274 | +class PerformUninstallAction: public unity::scopes::ActivationQueryBase |
275 | +{ |
276 | +public: |
277 | + PerformUninstallAction(const unity::scopes::Result& result, const unity::scopes::ActivationResponse& response); |
278 | + unity::scopes::ActivationResponse activate() override; |
279 | + |
280 | +private: |
281 | + unity::scopes::Result result; |
282 | + unity::scopes::ActivationResponse response; |
283 | +}; |
284 | + |
285 | class ScopeActivation : public unity::scopes::ActivationQueryBase |
286 | { |
287 | unity::scopes::ActivationResponse activate() override; |
288 | |
289 | === modified file 'po/POTFILES.in' |
290 | --- po/POTFILES.in 2014-04-29 18:42:40 +0000 |
291 | +++ po/POTFILES.in 2014-06-04 14:46:15 +0000 |
292 | @@ -1,3 +1,5 @@ |
293 | -[type: gettext/ini] data/clickscope.ini.in.in |
294 | -scope/click/preview.cpp |
295 | -scope/click/query.cpp |
296 | +[type: gettext/ini] data/com.canonical.scopes.clickstore.ini.in.in |
297 | +data/clickscope.ini.in.in |
298 | +libclickscope/click/preview.cpp |
299 | +scope/clickapps/apps-query.cpp |
300 | +scope/clickstore/store-query.cpp |
301 | |
302 | === modified file 'scope/CMakeLists.txt' |
303 | --- scope/CMakeLists.txt 2014-01-28 08:49:16 +0000 |
304 | +++ scope/CMakeLists.txt 2014-06-04 14:46:15 +0000 |
305 | @@ -1,2 +1,3 @@ |
306 | -add_subdirectory(click) |
307 | -add_subdirectory(tests) |
308 | \ No newline at end of file |
309 | +add_subdirectory(clickstore) |
310 | +add_subdirectory(clickapps) |
311 | +add_subdirectory(tests) |
312 | |
313 | === added directory 'scope/clickapps' |
314 | === added file 'scope/clickapps/CMakeLists.txt' |
315 | --- scope/clickapps/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
316 | +++ scope/clickapps/CMakeLists.txt 2014-06-04 14:46:15 +0000 |
317 | @@ -0,0 +1,37 @@ |
318 | +SET (CMAKE_INCLUDE_CURRENT_DIR ON) |
319 | +SET (CMAKE_AUTOMOC ON) |
320 | +find_package (Qt5Core REQUIRED) |
321 | +pkg_check_modules(JSON_CPP REQUIRED jsoncpp) |
322 | + |
323 | +add_definitions( |
324 | + -DGETTEXT_PACKAGE=\"${PROJECT_NAME}\" |
325 | + -DGETTEXT_LOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LOCALEDIR}\" |
326 | + -DSTORE_DATA_DIR="${STORE_DATA_DIR}" |
327 | +) |
328 | + |
329 | +add_library(${APPS_LIB_UNVERSIONED} SHARED |
330 | + apps-query.cpp |
331 | + apps-scope.cpp |
332 | +) |
333 | +set_target_properties(${APPS_LIB_UNVERSIONED} PROPERTIES PREFIX "") |
334 | + |
335 | +include_directories( |
336 | + ${CMAKE_SOURCE_DIR}/libclickscope |
337 | + ${JSON_CPP_INCLUDE_DIRS} |
338 | +) |
339 | + |
340 | +qt5_use_modules (${APPS_LIB_UNVERSIONED} Network) |
341 | + |
342 | +target_link_libraries (${APPS_LIB_UNVERSIONED} |
343 | + ${SCOPE_LIB_NAME} |
344 | + ${JSON_CPP_LDFLAGS} |
345 | + ${UNITY_SCOPES_LDFLAGS} |
346 | + ${UBUNTUONE_LDFLAGS} |
347 | + ${UBUNTU_DOWNLOAD_MANAGER_CLIENT_LDFLAGS} |
348 | + ${UBUNTU_DOWNLOAD_MANAGER_COMMON_LDFLAGS} |
349 | +) |
350 | + |
351 | +install( |
352 | + TARGETS ${APPS_LIB_UNVERSIONED} |
353 | + LIBRARY DESTINATION "${APPS_LIB_DIR}" |
354 | + ) |
355 | |
356 | === added file 'scope/clickapps/apps-query.cpp' |
357 | --- scope/clickapps/apps-query.cpp 1970-01-01 00:00:00 +0000 |
358 | +++ scope/clickapps/apps-query.cpp 2014-06-04 14:46:15 +0000 |
359 | @@ -0,0 +1,218 @@ |
360 | +/* |
361 | + * Copyright (C) 2014 Canonical Ltd. |
362 | + * |
363 | + * This program is free software: you can redistribute it and/or modify it |
364 | + * under the terms of the GNU General Public License version 3, as published |
365 | + * by the Free Software Foundation. |
366 | + * |
367 | + * This program is distributed in the hope that it will be useful, but |
368 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
369 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
370 | + * PURPOSE. See the GNU General Public License for more details. |
371 | + * |
372 | + * You should have received a copy of the GNU General Public License along |
373 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
374 | + * |
375 | + * In addition, as a special exception, the copyright holders give |
376 | + * permission to link the code of portions of this program with the |
377 | + * OpenSSL library under certain conditions as described in each |
378 | + * individual source file, and distribute linked combinations |
379 | + * including the two. |
380 | + * You must obey the GNU General Public License in all respects |
381 | + * for all of the code used other than OpenSSL. If you modify |
382 | + * file(s) with this exception, you may extend this exception to your |
383 | + * version of the file(s), but you are not obligated to do so. If you |
384 | + * do not wish to do so, delete this exception statement from your |
385 | + * version. If you delete this exception statement from all source |
386 | + * files in the program, then also delete it here. |
387 | + */ |
388 | + |
389 | +#include <click/application.h> |
390 | +#include <click/interface.h> |
391 | + |
392 | +#include <click/key_file_locator.h> |
393 | + |
394 | +#include <unity/scopes/CategoryRenderer.h> |
395 | +#include <unity/scopes/CategorisedResult.h> |
396 | +#include <unity/scopes/CannedQuery.h> |
397 | +#include <unity/scopes/SearchReply.h> |
398 | +#include <unity/scopes/SearchMetadata.h> |
399 | + |
400 | +#include <vector> |
401 | + |
402 | +#include <click/click-i18n.h> |
403 | +#include "apps-query.h" |
404 | + |
405 | +namespace |
406 | +{ |
407 | + |
408 | +std::string CATEGORY_APPS_DISPLAY = R"( |
409 | + { |
410 | + "schema-version" : 1, |
411 | + "template" : { |
412 | + "category-layout" : "grid", |
413 | + "card-size": "small" |
414 | + }, |
415 | + "components" : { |
416 | + "title" : "title", |
417 | + "art" : { |
418 | + "field": "art", |
419 | + "aspect-ratio": 1.6, |
420 | + "fill-mode": "fit" |
421 | + } |
422 | + } |
423 | + } |
424 | +)"; |
425 | + |
426 | +std::string CATEGORY_APPS_SEARCH = R"( |
427 | + { |
428 | + "schema-version" : 1, |
429 | + "template" : { |
430 | + "category-layout" : "grid", |
431 | + "card-layout" : "horizontal", |
432 | + "card-size": "large" |
433 | + }, |
434 | + "components" : { |
435 | + "title" : "title", |
436 | + "mascot" : { |
437 | + "field": "art" |
438 | + }, |
439 | + "subtitle": "publisher" |
440 | + } |
441 | + } |
442 | +)"; |
443 | + |
444 | +static const char CATEGORY_STORE[] = R"( |
445 | +{ |
446 | + "schema-version": 1, |
447 | + "template": { |
448 | + "category-layout": "grid", |
449 | + "card-size": "medium", |
450 | + "card-background": "color:///#E9E9E9" |
451 | + }, |
452 | + "components": { |
453 | + "title": "title", |
454 | + "subtitle": "author", |
455 | + "mascot": { |
456 | + "field": "art" |
457 | + }, |
458 | + "background": "background" |
459 | + } |
460 | +} |
461 | +)"; |
462 | + |
463 | + |
464 | +} |
465 | + |
466 | +void click::Query::push_local_results(scopes::SearchReplyProxy const &replyProxy, |
467 | + std::vector<click::Application> const &apps, |
468 | + std::string &categoryTemplate) |
469 | +{ |
470 | + scopes::CategoryRenderer rdr(categoryTemplate); |
471 | + auto cat = replyProxy->register_category("local", "", "", rdr); |
472 | + |
473 | + for(const auto & a: apps) |
474 | + { |
475 | + scopes::CategorisedResult res(cat); |
476 | + res.set_title(a.title); |
477 | + res.set_art(a.icon_url); |
478 | + res.set_uri(a.url); |
479 | + res[click::Query::ResultKeys::NAME] = a.name; |
480 | + res[click::Query::ResultKeys::DESCRIPTION] = a.description; |
481 | + res[click::Query::ResultKeys::MAIN_SCREENSHOT] = a.main_screenshot; |
482 | + res[click::Query::ResultKeys::INSTALLED] = true; |
483 | + res[click::Query::ResultKeys::VERSION] = a.version; |
484 | + replyProxy->push(res); |
485 | + } |
486 | +} |
487 | + |
488 | +struct click::Query::Private |
489 | +{ |
490 | + Private(const unity::scopes::CannedQuery& query, click::Index& index, const scopes::SearchMetadata& metadata) |
491 | + : query(query), |
492 | + index(index), |
493 | + meta(metadata) |
494 | + { |
495 | + } |
496 | + unity::scopes::CannedQuery query; |
497 | + click::Index& index; |
498 | + scopes::SearchMetadata meta; |
499 | +}; |
500 | + |
501 | +click::Query::Query(unity::scopes::CannedQuery const& query, click::Index& index, scopes::SearchMetadata const& metadata) |
502 | + : impl(new Private(query, index, metadata)) |
503 | +{ |
504 | +} |
505 | + |
506 | +void click::Query::cancelled() |
507 | +{ |
508 | + qDebug() << "cancelling search of" << QString::fromStdString(impl->query.query_string()); |
509 | +} |
510 | + |
511 | +click::Query::~Query() |
512 | +{ |
513 | + qDebug() << "destroying search"; |
514 | +} |
515 | + |
516 | +namespace |
517 | +{ |
518 | +click::Interface& clickInterfaceInstance() |
519 | +{ |
520 | + static QSharedPointer<click::KeyFileLocator> keyFileLocator(new click::KeyFileLocator()); |
521 | + static click::Interface iface(keyFileLocator); |
522 | + |
523 | + return iface; |
524 | +} |
525 | + |
526 | +} |
527 | + |
528 | +void click::Query::add_fake_store_app(scopes::SearchReplyProxy const& searchReply) |
529 | +{ |
530 | + static const std::string title = _("Get more apps in Ubuntu store"); |
531 | + auto name = title; |
532 | + |
533 | + std::string query = impl->query.query_string(); |
534 | + std::transform(query.begin(), query.end(), query.begin(), ::tolower); |
535 | + std::transform(name.begin(), name.end(), name.begin(), ::tolower); |
536 | + if (query.empty() || name.find(query) != std::string::npos) |
537 | + { |
538 | + scopes::CategoryRenderer rdr(CATEGORY_STORE); |
539 | + auto cat = searchReply->register_category("store", "", "", rdr); |
540 | + |
541 | + static const unity::scopes::CannedQuery store_scope("com.canonical.scopes.clickstore"); |
542 | + |
543 | + scopes::CategorisedResult res(cat); |
544 | + res.set_title(title); |
545 | + res.set_art(STORE_DATA_DIR "/apps-scope.svg"); |
546 | + res.set_uri(store_scope.to_uri()); |
547 | + res[click::Query::ResultKeys::NAME] = title; |
548 | + res[click::Query::ResultKeys::DESCRIPTION] = ""; |
549 | + res[click::Query::ResultKeys::MAIN_SCREENSHOT] = ""; |
550 | + res[click::Query::ResultKeys::INSTALLED] = true; |
551 | + res[click::Query::ResultKeys::VERSION] = ""; |
552 | + searchReply->push(res); |
553 | + } |
554 | +} |
555 | + |
556 | +void click::Query::run(scopes::SearchReplyProxy const& searchReply) |
557 | +{ |
558 | + auto query = impl->query.query_string(); |
559 | + std::string categoryTemplate = CATEGORY_APPS_SEARCH; |
560 | + if (query.empty()) { |
561 | + categoryTemplate = CATEGORY_APPS_DISPLAY; |
562 | + } |
563 | + auto localResults = clickInterfaceInstance().find_installed_apps( |
564 | + query); |
565 | + |
566 | + // Sort applications so that newest come first. |
567 | + std::sort(localResults.begin(), localResults.end(), [](const Application& a, const Application& b) { |
568 | + return a.installed_time > b.installed_time; |
569 | + }); |
570 | + |
571 | + push_local_results( |
572 | + searchReply, |
573 | + localResults, |
574 | + categoryTemplate); |
575 | + |
576 | + add_fake_store_app(searchReply); |
577 | +} |
578 | |
579 | === added file 'scope/clickapps/apps-query.h' |
580 | --- scope/clickapps/apps-query.h 1970-01-01 00:00:00 +0000 |
581 | +++ scope/clickapps/apps-query.h 2014-06-04 14:46:15 +0000 |
582 | @@ -0,0 +1,82 @@ |
583 | +/* |
584 | + * Copyright (C) 2014 Canonical Ltd. |
585 | + * |
586 | + * This program is free software: you can redistribute it and/or modify it |
587 | + * under the terms of the GNU General Public License version 3, as published |
588 | + * by the Free Software Foundation. |
589 | + * |
590 | + * This program is distributed in the hope that it will be useful, but |
591 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
592 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
593 | + * PURPOSE. See the GNU General Public License for more details. |
594 | + * |
595 | + * You should have received a copy of the GNU General Public License along |
596 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
597 | + * |
598 | + * In addition, as a special exception, the copyright holders give |
599 | + * permission to link the code of portions of this program with the |
600 | + * OpenSSL library under certain conditions as described in each |
601 | + * individual source file, and distribute linked combinations |
602 | + * including the two. |
603 | + * You must obey the GNU General Public License in all respects |
604 | + * for all of the code used other than OpenSSL. If you modify |
605 | + * file(s) with this exception, you may extend this exception to your |
606 | + * version of the file(s), but you are not obligated to do so. If you |
607 | + * do not wish to do so, delete this exception statement from your |
608 | + * version. If you delete this exception statement from all source |
609 | + * files in the program, then also delete it here. |
610 | + */ |
611 | + |
612 | +#ifndef APPS_QUERY_H |
613 | +#define APPS_QUERY_H |
614 | + |
615 | + |
616 | +#include <unity/scopes/SearchQueryBase.h> |
617 | + |
618 | +namespace scopes = unity::scopes; |
619 | + |
620 | +#include <QSharedPointer> |
621 | +#include <set> |
622 | + |
623 | + |
624 | +namespace click |
625 | +{ |
626 | + |
627 | +class Application; |
628 | +class Index; |
629 | + |
630 | +class Query : public scopes::SearchQueryBase |
631 | +{ |
632 | +public: |
633 | + struct ResultKeys |
634 | + { |
635 | + ResultKeys() = delete; |
636 | + |
637 | + constexpr static const char* NAME{"name"}; |
638 | + constexpr static const char* DESCRIPTION{"description"}; |
639 | + constexpr static const char* MAIN_SCREENSHOT{"main_screenshot"}; |
640 | + constexpr static const char* INSTALLED{"installed"}; |
641 | + constexpr static const char* DOWNLOAD_URL{"download_url"}; |
642 | + constexpr static const char* VERSION{"version"}; |
643 | + }; |
644 | + |
645 | + Query(unity::scopes::CannedQuery const& query, click::Index& index, scopes::SearchMetadata const& metadata); |
646 | + virtual ~Query(); |
647 | + |
648 | + virtual void cancelled() override; |
649 | + |
650 | + virtual void run(scopes::SearchReplyProxy const& reply) override; |
651 | + |
652 | +protected: |
653 | + virtual void add_fake_store_app(scopes::SearchReplyProxy const &replyProxy); |
654 | + virtual void push_local_results(scopes::SearchReplyProxy const &replyProxy, |
655 | + std::vector<click::Application> const &apps, |
656 | + std::string& categoryTemplate); |
657 | + |
658 | +private: |
659 | + struct Private; |
660 | + QSharedPointer<Private> impl; |
661 | +}; |
662 | +} |
663 | + |
664 | +#endif // CLICK_QUERY_H |
665 | |
666 | === added file 'scope/clickapps/apps-scope.cpp' |
667 | --- scope/clickapps/apps-scope.cpp 1970-01-01 00:00:00 +0000 |
668 | +++ scope/clickapps/apps-scope.cpp 2014-06-04 14:46:15 +0000 |
669 | @@ -0,0 +1,158 @@ |
670 | +/* |
671 | + * Copyright (C) 2014 Canonical Ltd. |
672 | + * |
673 | + * This program is free software: you can redistribute it and/or modify it |
674 | + * under the terms of the GNU General Public License version 3, as published |
675 | + * by the Free Software Foundation. |
676 | + * |
677 | + * This program is distributed in the hope that it will be useful, but |
678 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
679 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
680 | + * PURPOSE. See the GNU General Public License for more details. |
681 | + * |
682 | + * You should have received a copy of the GNU General Public License along |
683 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
684 | + * |
685 | + * In addition, as a special exception, the copyright holders give |
686 | + * permission to link the code of portions of this program with the |
687 | + * OpenSSL library under certain conditions as described in each |
688 | + * individual source file, and distribute linked combinations |
689 | + * including the two. |
690 | + * You must obey the GNU General Public License in all respects |
691 | + * for all of the code used other than OpenSSL. If you modify |
692 | + * file(s) with this exception, you may extend this exception to your |
693 | + * version of the file(s), but you are not obligated to do so. If you |
694 | + * do not wish to do so, delete this exception statement from your |
695 | + * version. If you delete this exception statement from all source |
696 | + * files in the program, then also delete it here. |
697 | + */ |
698 | + |
699 | +#include <click/qtbridge.h> |
700 | +#include <click/preview.h> |
701 | +#include <click/interface.h> |
702 | +#include <click/scope_activation.h> |
703 | + |
704 | +#include <QSharedPointer> |
705 | + |
706 | +#include <click/key_file_locator.h> |
707 | +#include <click/network_access_manager.h> |
708 | +#include <click/click-i18n.h> |
709 | +#include <unity/scopes/CannedQuery.h> |
710 | + |
711 | +#include "apps-scope.h" |
712 | +#include "apps-query.h" |
713 | + |
714 | +namespace |
715 | +{ |
716 | +click::Interface& clickInterfaceInstance() |
717 | +{ |
718 | + static QSharedPointer<click::KeyFileLocator> keyFileLocator(new click::KeyFileLocator()); |
719 | + static click::Interface iface(keyFileLocator); |
720 | + return iface; |
721 | +} |
722 | +} |
723 | + |
724 | +click::Scope::Scope() |
725 | +{ |
726 | + nam.reset(new click::network::AccessManager()); |
727 | + client.reset(new click::web::Client(nam)); |
728 | + index.reset(new click::Index(client)); |
729 | +} |
730 | + |
731 | +click::Scope::~Scope() |
732 | +{ |
733 | +} |
734 | + |
735 | +int click::Scope::start(std::string const&, scopes::RegistryProxy const&) |
736 | +{ |
737 | + setlocale(LC_ALL, ""); |
738 | + bindtextdomain(GETTEXT_PACKAGE, GETTEXT_LOCALEDIR); |
739 | + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); |
740 | + |
741 | + return VERSION; |
742 | +} |
743 | + |
744 | +void click::Scope::run() |
745 | +{ |
746 | + static const int zero = 0; |
747 | + auto emptyCb = [this]() |
748 | + { |
749 | + }; |
750 | + |
751 | + qt::core::world::build_and_run(zero, nullptr, emptyCb); |
752 | +} |
753 | + |
754 | +void click::Scope::stop() |
755 | +{ |
756 | + qt::core::world::destroy(); |
757 | +} |
758 | + |
759 | +scopes::SearchQueryBase::UPtr click::Scope::search(unity::scopes::CannedQuery const& q, scopes::SearchMetadata const& metadata) |
760 | +{ |
761 | + return scopes::SearchQueryBase::UPtr(new click::Query(q, *index, metadata)); |
762 | +} |
763 | + |
764 | + |
765 | +unity::scopes::PreviewQueryBase::UPtr click::Scope::preview(const unity::scopes::Result& result, |
766 | + const unity::scopes::ActionMetadata& metadata) { |
767 | + qDebug() << "Scope::preview() called."; |
768 | + return scopes::PreviewQueryBase::UPtr{new click::Preview(result, metadata, client, nam)}; |
769 | +} |
770 | + |
771 | + |
772 | +unity::scopes::ActivationQueryBase::UPtr click::Scope::perform_action(unity::scopes::Result const& result, unity::scopes::ActionMetadata const& metadata, std::string const& /* widget_id */, std::string const& action_id) |
773 | +{ |
774 | + if (action_id == click::Preview::Actions::CONFIRM_UNINSTALL) { |
775 | + const unity::scopes::CannedQuery cquery("clickscope"); |
776 | + return scopes::ActivationQueryBase::UPtr(new PerformUninstallAction(result, unity::scopes::ActivationResponse(cquery))); |
777 | + } |
778 | + |
779 | + auto activation = new ScopeActivation(); |
780 | + qDebug() << "perform_action called with action_id" << QString().fromStdString(action_id); |
781 | + |
782 | + if (action_id == click::Preview::Actions::UNINSTALL_CLICK) { |
783 | + activation->setHint(click::Preview::Actions::UNINSTALL_CLICK, unity::scopes::Variant(true)); |
784 | + activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview); |
785 | + } else if (action_id == click::Preview::Actions::CLOSE_PREVIEW) { |
786 | + activation->setHint(click::Preview::Actions::CLOSE_PREVIEW, unity::scopes::Variant(true)); |
787 | + activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview); |
788 | + } else if (action_id == click::Preview::Actions::RATED) { |
789 | + scopes::VariantMap rating_info = metadata.scope_data().get_dict(); |
790 | + // Cast to int because widget gives us double, which is wrong. |
791 | + int rating = ((int)rating_info["rating"].get_double()); |
792 | + std::string review_text = rating_info["review"].get_string(); |
793 | + |
794 | + // We have to get the values and then set them as hints here, to be |
795 | + // able to pass them on to the Preview, which actually makes the |
796 | + // call to submit. |
797 | + activation->setHint("rating", scopes::Variant(rating)); |
798 | + activation->setHint("review", scopes::Variant(review_text)); |
799 | + activation->setHint(click::Preview::Actions::RATED, |
800 | + scopes::Variant(true)); |
801 | + activation->setStatus(scopes::ActivationResponse::Status::ShowPreview); |
802 | + } |
803 | + return scopes::ActivationQueryBase::UPtr(activation); |
804 | +} |
805 | + |
806 | +#define EXPORT __attribute__ ((visibility ("default"))) |
807 | + |
808 | +extern "C" |
809 | +{ |
810 | + |
811 | + EXPORT |
812 | + unity::scopes::ScopeBase* |
813 | + // cppcheck-suppress unusedFunction |
814 | + UNITY_SCOPE_CREATE_FUNCTION() |
815 | + { |
816 | + return new click::Scope(); |
817 | + } |
818 | + |
819 | + EXPORT |
820 | + void |
821 | + // cppcheck-suppress unusedFunction |
822 | + UNITY_SCOPE_DESTROY_FUNCTION(unity::scopes::ScopeBase* scope_base) |
823 | + { |
824 | + delete scope_base; |
825 | + } |
826 | + |
827 | +} |
828 | |
829 | === added file 'scope/clickapps/apps-scope.h' |
830 | --- scope/clickapps/apps-scope.h 1970-01-01 00:00:00 +0000 |
831 | +++ scope/clickapps/apps-scope.h 2014-06-04 14:46:15 +0000 |
832 | @@ -0,0 +1,71 @@ |
833 | +/* |
834 | + * Copyright (C) 2014 Canonical Ltd. |
835 | + * |
836 | + * This program is free software: you can redistribute it and/or modify it |
837 | + * under the terms of the GNU General Public License version 3, as published |
838 | + * by the Free Software Foundation. |
839 | + * |
840 | + * This program is distributed in the hope that it will be useful, but |
841 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
842 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
843 | + * PURPOSE. See the GNU General Public License for more details. |
844 | + * |
845 | + * You should have received a copy of the GNU General Public License along |
846 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
847 | + * |
848 | + * In addition, as a special exception, the copyright holders give |
849 | + * permission to link the code of portions of this program with the |
850 | + * OpenSSL library under certain conditions as described in each |
851 | + * individual source file, and distribute linked combinations |
852 | + * including the two. |
853 | + * You must obey the GNU General Public License in all respects |
854 | + * for all of the code used other than OpenSSL. If you modify |
855 | + * file(s) with this exception, you may extend this exception to your |
856 | + * version of the file(s), but you are not obligated to do so. If you |
857 | + * do not wish to do so, delete this exception statement from your |
858 | + * version. If you delete this exception statement from all source |
859 | + * files in the program, then also delete it here. |
860 | + */ |
861 | + |
862 | +#ifndef APPS_SCOPE_H |
863 | +#define APPS_SCOPE_H |
864 | + |
865 | +#include <click/network_access_manager.h> |
866 | +#include <click/webclient.h> |
867 | + |
868 | +#include <unity/scopes/ScopeBase.h> |
869 | +#include <unity/scopes/QueryBase.h> |
870 | +#include <unity/scopes/ActivationQueryBase.h> |
871 | + |
872 | +#include <click/index.h> |
873 | + |
874 | +namespace scopes = unity::scopes; |
875 | + |
876 | +namespace click |
877 | +{ |
878 | +class Scope : public scopes::ScopeBase |
879 | +{ |
880 | +public: |
881 | + Scope(); |
882 | + ~Scope(); |
883 | + |
884 | + virtual int start(std::string const&, scopes::RegistryProxy const&) override; |
885 | + |
886 | + virtual void run() override; |
887 | + virtual void stop() override; |
888 | + |
889 | + virtual scopes::SearchQueryBase::UPtr search(scopes::CannedQuery const& q, scopes::SearchMetadata const&) override; |
890 | + unity::scopes::PreviewQueryBase::UPtr preview(const unity::scopes::Result&, |
891 | + const unity::scopes::ActionMetadata&) override; |
892 | + |
893 | + virtual unity::scopes::ActivationQueryBase::UPtr perform_action(unity::scopes::Result const& result, unity::scopes::ActionMetadata const& metadata, std::string const& widget_id, std::string const& action_id) override; |
894 | + |
895 | +private: |
896 | + QSharedPointer<click::network::AccessManager> nam; |
897 | + QSharedPointer<click::web::Client> client; |
898 | + QSharedPointer<click::Index> index; |
899 | + |
900 | + std::string installApplication(unity::scopes::Result const& result); |
901 | +}; |
902 | +} |
903 | +#endif // CLICK_SCOPE_H |
904 | |
905 | === renamed directory 'scope/click' => 'scope/clickstore' |
906 | === modified file 'scope/clickstore/CMakeLists.txt' |
907 | --- scope/click/CMakeLists.txt 2014-05-26 14:02:45 +0000 |
908 | +++ scope/clickstore/CMakeLists.txt 2014-06-04 14:46:15 +0000 |
909 | @@ -8,19 +8,20 @@ |
910 | -DGETTEXT_LOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LOCALEDIR}\" |
911 | ) |
912 | |
913 | -add_library(${SCOPE_LIB_UNVERSIONED} SHARED |
914 | - query.cpp |
915 | - scope.cpp |
916 | +add_library(${STORE_LIB_UNVERSIONED} SHARED |
917 | + store-query.cpp |
918 | + store-scope.cpp |
919 | ) |
920 | +set_target_properties(${STORE_LIB_UNVERSIONED} PROPERTIES PREFIX "") |
921 | |
922 | include_directories( |
923 | ${CMAKE_SOURCE_DIR}/libclickscope |
924 | ${JSON_CPP_INCLUDE_DIRS} |
925 | ) |
926 | |
927 | -qt5_use_modules (${SCOPE_LIB_UNVERSIONED} Network) |
928 | +qt5_use_modules (${STORE_LIB_UNVERSIONED} Network) |
929 | |
930 | -target_link_libraries (${SCOPE_LIB_UNVERSIONED} |
931 | +target_link_libraries (${STORE_LIB_UNVERSIONED} |
932 | ${SCOPE_LIB_NAME} |
933 | ${JSON_CPP_LDFLAGS} |
934 | ${UNITY_SCOPES_LDFLAGS} |
935 | @@ -30,6 +31,6 @@ |
936 | ) |
937 | |
938 | install( |
939 | - TARGETS ${SCOPE_LIB_UNVERSIONED} |
940 | - LIBRARY DESTINATION "${SCOPE_LIB_DIR}" |
941 | + TARGETS ${STORE_LIB_UNVERSIONED} |
942 | + LIBRARY DESTINATION "${STORE_LIB_DIR}" |
943 | ) |
944 | |
945 | === renamed file 'scope/click/query.cpp' => 'scope/clickstore/store-query.cpp' |
946 | --- scope/click/query.cpp 2014-05-26 14:02:45 +0000 |
947 | +++ scope/clickstore/store-query.cpp 2014-06-04 14:46:15 +0000 |
948 | @@ -28,7 +28,7 @@ |
949 | */ |
950 | |
951 | #include <click/application.h> |
952 | -#include "query.h" |
953 | +#include "store-query.h" |
954 | #include <click/qtbridge.h> |
955 | #include <click/interface.h> |
956 | |
957 | @@ -89,32 +89,6 @@ |
958 | |
959 | } |
960 | |
961 | -void click::Query::push_local_results(scopes::SearchReplyProxy const &replyProxy, |
962 | - std::vector<click::Application> const &apps, |
963 | - std::string &categoryTemplate) |
964 | -{ |
965 | - scopes::CategoryRenderer rdr(categoryTemplate); |
966 | - auto cat = replyProxy->register_category("local", _("My apps"), "", rdr); |
967 | - |
968 | - // cat might be null when the underlying query got cancelled. |
969 | - if (!cat) |
970 | - return; |
971 | - |
972 | - for(const auto & a: apps) |
973 | - { |
974 | - scopes::CategorisedResult res(cat); |
975 | - res.set_title(a.title); |
976 | - res.set_art(a.icon_url); |
977 | - res.set_uri(a.url); |
978 | - res[click::Query::ResultKeys::NAME] = a.name; |
979 | - res[click::Query::ResultKeys::DESCRIPTION] = a.description; |
980 | - res[click::Query::ResultKeys::MAIN_SCREENSHOT] = a.main_screenshot; |
981 | - res[click::Query::ResultKeys::INSTALLED] = true; |
982 | - res[click::Query::ResultKeys::VERSION] = a.version; |
983 | - replyProxy->push(res); |
984 | - } |
985 | -} |
986 | - |
987 | struct click::Query::Private |
988 | { |
989 | Private(const unity::scopes::CannedQuery& query, click::Index& index, const scopes::SearchMetadata& metadata) |
990 | @@ -189,11 +163,6 @@ |
991 | { |
992 | scopes::CategoryRenderer categoryRenderer(categoryTemplate); |
993 | auto category = register_category(searchReply, "appstore", _("Available"), "", categoryRenderer); |
994 | - if (!category) { |
995 | - // category might be null when the underlying query got cancelled. |
996 | - qDebug() << "category is null"; |
997 | - return; |
998 | - } |
999 | |
1000 | run_under_qt([=]() |
1001 | { |
1002 | @@ -205,6 +174,7 @@ |
1003 | qDebug() << "pushing result" << QString::fromStdString(p.name); |
1004 | try { |
1005 | scopes::CategorisedResult res(category); |
1006 | + // TODO: mark as installed |
1007 | if (locallyInstalledApps.count(p.name) > 0) { |
1008 | qDebug() << "already installed" << QString::fromStdString(p.name); |
1009 | continue; |
1010 | @@ -238,13 +208,7 @@ |
1011 | if (query.empty()) { |
1012 | categoryTemplate = CATEGORY_APPS_DISPLAY; |
1013 | } |
1014 | - auto localResults = clickInterfaceInstance().find_installed_apps( |
1015 | - query); |
1016 | - |
1017 | - push_local_results( |
1018 | - searchReply, |
1019 | - localResults, |
1020 | - categoryTemplate); |
1021 | + auto localResults = clickInterfaceInstance().find_installed_apps(query); |
1022 | |
1023 | std::set<std::string> locallyInstalledApps; |
1024 | for(const auto& app : localResults) { |
1025 | |
1026 | === renamed file 'scope/click/query.h' => 'scope/clickstore/store-query.h' |
1027 | --- scope/click/query.h 2014-05-14 18:34:20 +0000 |
1028 | +++ scope/clickstore/store-query.h 2014-06-04 14:46:15 +0000 |
1029 | @@ -27,8 +27,8 @@ |
1030 | * files in the program, then also delete it here. |
1031 | */ |
1032 | |
1033 | -#ifndef CLICK_QUERY_H |
1034 | -#define CLICK_QUERY_H |
1035 | +#ifndef STORE_QUERY_H |
1036 | +#define STORE_QUERY_H |
1037 | |
1038 | |
1039 | #include <unity/scopes/SearchQueryBase.h> |
1040 | @@ -81,9 +81,6 @@ |
1041 | virtual void add_available_apps(const scopes::SearchReplyProxy &searchReply, const std::set<std::string> &locallyInstalledApps, const std::string &category); |
1042 | virtual bool push_result(const scopes::SearchReplyProxy &searchReply, scopes::CategorisedResult const& res); |
1043 | virtual void finished(const scopes::SearchReplyProxy &searchReply); |
1044 | - virtual void push_local_results(scopes::SearchReplyProxy const &replyProxy, |
1045 | - std::vector<click::Application> const &apps, |
1046 | - std::string& categoryTemplate); |
1047 | virtual scopes::Category::SCPtr register_category(scopes::SearchReplyProxy const& searchReply, |
1048 | std::string const& id, |
1049 | std::string const& title, |
1050 | |
1051 | === renamed file 'scope/click/scope.cpp' => 'scope/clickstore/store-scope.cpp' |
1052 | --- scope/click/scope.cpp 2014-05-27 08:30:21 +0000 |
1053 | +++ scope/clickstore/store-scope.cpp 2014-06-04 14:46:15 +0000 |
1054 | @@ -28,8 +28,8 @@ |
1055 | */ |
1056 | |
1057 | #include <click/qtbridge.h> |
1058 | -#include "scope.h" |
1059 | -#include "query.h" |
1060 | +#include "store-scope.h" |
1061 | +#include "store-query.h" |
1062 | #include <click/preview.h> |
1063 | #include <click/interface.h> |
1064 | #include <click/scope_activation.h> |
1065 | |
1066 | === renamed file 'scope/click/scope.h' => 'scope/clickstore/store-scope.h' |
1067 | === modified file 'scope/tests/CMakeLists.txt' |
1068 | --- scope/tests/CMakeLists.txt 2014-05-26 14:27:31 +0000 |
1069 | +++ scope/tests/CMakeLists.txt 2014-06-04 14:46:15 +0000 |
1070 | @@ -22,7 +22,7 @@ |
1071 | qt5_use_modules(${CLICKSCOPE_TESTS_TARGET} Core DBus Network Test) |
1072 | |
1073 | target_link_libraries(${CLICKSCOPE_TESTS_TARGET} |
1074 | - ${SCOPE_LIB_UNVERSIONED} |
1075 | + ${STORE_LIB_UNVERSIONED} |
1076 | ${SCOPE_LIB_NAME} |
1077 | |
1078 | ${UNITY_SCOPES_LDFLAGS} |
1079 | |
1080 | === modified file 'scope/tests/click_interface_tool/CMakeLists.txt' |
1081 | --- scope/tests/click_interface_tool/CMakeLists.txt 2014-05-13 19:32:29 +0000 |
1082 | +++ scope/tests/click_interface_tool/CMakeLists.txt 2014-06-04 14:46:15 +0000 |
1083 | @@ -10,5 +10,5 @@ |
1084 | ) |
1085 | |
1086 | target_link_libraries (${CLICK_INTERFACE_TOOL_TARGET} |
1087 | - ${SCOPE_LIB_UNVERSIONED} |
1088 | + ${STORE_LIB_UNVERSIONED} |
1089 | ) |
1090 | |
1091 | === modified file 'scope/tests/download_manager_tool/CMakeLists.txt' |
1092 | --- scope/tests/download_manager_tool/CMakeLists.txt 2014-02-27 17:24:07 +0000 |
1093 | +++ scope/tests/download_manager_tool/CMakeLists.txt 2014-06-04 14:46:15 +0000 |
1094 | @@ -10,5 +10,5 @@ |
1095 | ) |
1096 | |
1097 | target_link_libraries (${DOWNLOAD_MANAGER_TOOL_TARGET} |
1098 | - ${SCOPE_LIB_UNVERSIONED} |
1099 | + ${STORE_LIB_UNVERSIONED} |
1100 | ) |
1101 | |
1102 | === modified file 'scope/tests/integration/CMakeLists.txt' |
1103 | --- scope/tests/integration/CMakeLists.txt 2014-02-27 17:24:07 +0000 |
1104 | +++ scope/tests/integration/CMakeLists.txt 2014-06-04 14:46:15 +0000 |
1105 | @@ -17,7 +17,7 @@ |
1106 | qt5_use_modules(${INTEGRATION_TARGET} Core DBus Network Test) |
1107 | |
1108 | target_link_libraries (${INTEGRATION_TARGET} |
1109 | - ${SCOPE_LIB_UNVERSIONED} |
1110 | + ${STORE_LIB_UNVERSIONED} |
1111 | |
1112 | gmock |
1113 | gmock_main |
1114 | |
1115 | === modified file 'scope/tests/test_query.cpp' |
1116 | --- scope/tests/test_query.cpp 2014-05-21 13:42:45 +0000 |
1117 | +++ scope/tests/test_query.cpp 2014-06-04 14:46:15 +0000 |
1118 | @@ -34,7 +34,7 @@ |
1119 | #include <gmock/gmock.h> |
1120 | |
1121 | #include "click/qtbridge.h" |
1122 | -#include "click/query.h" |
1123 | +#include "clickstore/store-query.h" |
1124 | #include "click/index.h" |
1125 | #include "click/application.h" |
1126 | |
1127 | @@ -199,25 +199,6 @@ |
1128 | q.wrap_add_available_apps(reply, no_installed_packages, FAKE_CATEGORY_TEMPLATE); |
1129 | } |
1130 | |
1131 | -TEST(QueryTest, testAddAvailableAppsWithNullCategory) |
1132 | -{ |
1133 | - click::PackageList packages { |
1134 | - {"name", "title", 0.0, "icon", "uri"} |
1135 | - }; |
1136 | - MockIndex mock_index(packages); |
1137 | - scopes::SearchMetadata metadata("en_EN", "phone"); |
1138 | - std::set<std::string> no_installed_packages; |
1139 | - const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, ""); |
1140 | - MockQuery q(query, mock_index, metadata); |
1141 | - EXPECT_CALL(mock_index, do_search(FAKE_QUERY, _)).Times(0); |
1142 | - |
1143 | - EXPECT_CALL(q, register_category(_, _, _, _, _)).WillOnce(Return(nullptr)); |
1144 | - |
1145 | - scopes::SearchReplyProxy reply; |
1146 | - EXPECT_CALL(q, push_result(_, _)).Times(0); |
1147 | - q.wrap_add_available_apps(reply, no_installed_packages, FAKE_CATEGORY_TEMPLATE); |
1148 | -} |
1149 | - |
1150 | TEST(QueryTest, testQueryRunCallsAddAvailableApps) |
1151 | { |
1152 | click::PackageList packages { |
1153 | @@ -229,7 +210,6 @@ |
1154 | const unity::scopes::CannedQuery query("foo.scope", FAKE_QUERY, ""); |
1155 | MockQueryRun q(query, mock_index, metadata); |
1156 | auto reply = scopes::SearchReplyProxy(); |
1157 | - EXPECT_CALL(q, push_local_results(_, _, _)); |
1158 | EXPECT_CALL(q, add_available_apps(reply, no_installed_packages, _)); |
1159 | |
1160 | q.run(reply); |
PASSED: Continuous integration, rev:299 jenkins. qa.ubuntu. com/job/ unity-team- unity-scope- click-devel- ci/94/ jenkins. qa.ubuntu. com/job/ unity-team- unity-scope- click-devel- utopic- amd64-ci/ 69 jenkins. qa.ubuntu. com/job/ unity-team- unity-scope- click-devel- utopic- armhf-ci/ 68 jenkins. qa.ubuntu. com/job/ unity-team- unity-scope- click-devel- utopic- armhf-ci/ 68/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ unity-team- unity-scope- click-devel- utopic- i386-ci/ 68
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- team-unity- scope-click- devel-ci/ 94/rebuild
http://