Merge lp:~townsend/libertine-scope/release-1.3 into lp:libertine-scope/release
- release-1.3
- Merge into release
Status: | Merged | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Larry Price | ||||||||||||||||
Approved revision: | 42 | ||||||||||||||||
Merged at revision: | 42 | ||||||||||||||||
Proposed branch: | lp:~townsend/libertine-scope/release-1.3 | ||||||||||||||||
Merge into: | lp:libertine-scope/release | ||||||||||||||||
Diff against target: |
2064 lines (+1116/-263) 42 files modified
.bzrignore (+1/-0) CMakeLists.txt (+11/-8) data/CMakeLists.txt (+6/-9) data/blacklist (+11/-0) data/libertine-scope-settings.ini.in (+0/-24) debian/changelog (+23/-0) libertine-scope.apparmor (+1/-1) libertine-scope/CMakeLists.txt (+4/-1) libertine-scope/action.cpp (+66/-0) libertine-scope/action.h (+45/-0) libertine-scope/blacklist.cpp (+78/-0) libertine-scope/blacklist.h (+36/-0) libertine-scope/config.h.in (+26/-0) libertine-scope/hidden_apps.cpp (+92/-0) libertine-scope/hidden_apps.h (+38/-0) libertine-scope/preview.cpp (+20/-0) libertine-scope/preview.h (+0/-2) libertine-scope/query.cpp (+192/-34) libertine-scope/query.h (+26/-18) libertine-scope/scope.cpp (+14/-37) po/en_AU.po (+4/-3) po/en_GB.po (+4/-3) po/es.po (+9/-5) po/fi.po (+4/-3) po/fr.po (+4/-3) po/gl.po (+8/-3) po/libertine-scope.pot (+23/-1) po/ms.po (+4/-3) po/pt.po (+4/-3) po/uk.po (+4/-3) tests/CMakeLists.txt (+24/-21) tests/TypedScopeFixture.h (+1/-0) tests/data/blacklist (+9/-0) tests/data/hidden (+1/-0) tests/fake_container.cpp (+1/-2) tests/fake_container_json.h (+2/-2) tests/fake_libertine.cpp (+0/-6) tests/fake_libertine.h (+2/-2) tests/test_blacklist.cpp (+65/-0) tests/test_hidden_apps.cpp (+107/-0) tests/test_preview.cpp (+2/-1) tests/test_query.cpp (+144/-65) |
||||||||||||||||
To merge this branch: | bzr merge lp:~townsend/libertine-scope/release-1.3 | ||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Larry Price | Approve | ||
Review via email: mp+297631@code.launchpad.net |
Commit message
* Use wildcard matching for allowing reading any puritine click package paths that have the name "puritine" anywhere in the Click package name. (LP: #1590453)
* Replace the scope settings approach to suppress display of apps with a scope filter based approach. This provides a blacklist file for permanent suppression and filters for user suppression.
* Provide a "Hidden X Apps" department for a place to store the apps hidden in the main scope view, so they can be unhidden later if desired.
* Hide 'Help' by default for all containers. (LP: #1591511)
* Removed Settings. (LP: #1591494)
* Refactor Query class for consistent style and extract some functionality to helper classes.
* Show a message when no apps are available due to filters or no apps installed. (LP: #1589699)
Description of the change
Preview Diff
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2016-02-29 18:49:55 +0000 | |||
3 | +++ .bzrignore 2016-06-16 14:35:35 +0000 | |||
4 | @@ -1,2 +1,3 @@ | |||
5 | 1 | po/POTFILES.in | 1 | po/POTFILES.in |
6 | 2 | po/Makefile.in.in | 2 | po/Makefile.in.in |
7 | 3 | config.h | ||
8 | 3 | 4 | ||
9 | === modified file 'CMakeLists.txt' | |||
10 | --- CMakeLists.txt 2016-06-01 20:28:54 +0000 | |||
11 | +++ CMakeLists.txt 2016-06-16 14:35:35 +0000 | |||
12 | @@ -1,6 +1,6 @@ | |||
13 | 1 | cmake_minimum_required(VERSION 3.0) | 1 | cmake_minimum_required(VERSION 3.0) |
14 | 2 | project(libertine-scope | 2 | project(libertine-scope |
16 | 3 | VERSION 1.2 | 3 | VERSION 1.3 |
17 | 4 | LANGUAGES CXX) | 4 | LANGUAGES CXX) |
18 | 5 | 5 | ||
19 | 6 | # We require at least g++ 4.9, to avoid ABI breakage with earlier versions. | 6 | # We require at least g++ 4.9, to avoid ABI breakage with earlier versions. |
20 | @@ -46,7 +46,10 @@ | |||
21 | 46 | set(APP ${PROJECT}) | 46 | set(APP ${PROJECT}) |
22 | 47 | 47 | ||
23 | 48 | # Important project paths | 48 | # Important project paths |
24 | 49 | # Use this SCOPE_INSTALL_DIR when building the debian | ||
25 | 49 | set(SCOPE_INSTALL_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/unity-scopes/libertine-scope/) | 50 | set(SCOPE_INSTALL_DIR ${CMAKE_INSTALL_FULL_LIBDIR}/unity-scopes/libertine-scope/) |
26 | 51 | # USE this when building the click | ||
27 | 52 | #set(SCOPE_INSTALL_DIR "/libertine-scope") | ||
28 | 50 | set(SCOPE_NAME "libertine-scope") | 53 | set(SCOPE_NAME "libertine-scope") |
29 | 51 | set(GETTEXT_PACKAGE "${SCOPE_NAME}") | 54 | set(GETTEXT_PACKAGE "${SCOPE_NAME}") |
30 | 52 | 55 | ||
31 | @@ -63,10 +66,12 @@ | |||
32 | 63 | 66 | ||
33 | 64 | # Configure and install the click manifest and apparmor files | 67 | # Configure and install the click manifest and apparmor files |
34 | 65 | configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json) | 68 | configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json) |
39 | 66 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json | 69 | install(FILES |
40 | 67 | DESTINATION ${SCOPE_INSTALL_DIR}) | 70 | ${CMAKE_CURRENT_BINARY_DIR}/manifest.json |
41 | 68 | install(FILES "libertine-scope.apparmor" | 71 | "libertine-scope.apparmor" |
42 | 69 | DESTINATION ${SCOPE_INSTALL_DIR}) | 72 | DESTINATION ${SCOPE_INSTALL_DIR}) |
43 | 73 | #Use this DESTINATION when building click | ||
44 | 74 | # DESTINATION "/") | ||
45 | 70 | 75 | ||
46 | 71 | # Add our main directories | 76 | # Add our main directories |
47 | 72 | add_subdirectory(libertine-scope) | 77 | add_subdirectory(libertine-scope) |
48 | @@ -76,9 +81,7 @@ | |||
49 | 76 | # Set up the tests | 81 | # Set up the tests |
50 | 77 | enable_testing() | 82 | enable_testing() |
51 | 78 | add_subdirectory(tests) | 83 | add_subdirectory(tests) |
55 | 79 | add_custom_target(check | 84 | add_custom_target(check ${CMAKE_CTEST_COMMAND} --force-new-ctest-process --output-on-failure) |
53 | 80 | ${CMAKE_CTEST_COMMAND} --force-new-ctest-process --output-on-failure | ||
54 | 81 | ) | ||
56 | 82 | 85 | ||
57 | 83 | set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}) | 86 | set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}) |
58 | 84 | add_custom_target(dist | 87 | add_custom_target(dist |
59 | 85 | 88 | ||
60 | === modified file 'data/CMakeLists.txt' | |||
61 | --- data/CMakeLists.txt 2016-06-02 16:56:29 +0000 | |||
62 | +++ data/CMakeLists.txt 2016-06-16 14:35:35 +0000 | |||
63 | @@ -1,4 +1,3 @@ | |||
64 | 1 | |||
65 | 2 | # Put the ini files in the build directory next to the scope | 1 | # Put the ini files in the build directory next to the scope |
66 | 3 | # .so file so that the test tools can find them. | 2 | # .so file so that the test tools can find them. |
67 | 4 | intltool_merge_translations( | 3 | intltool_merge_translations( |
68 | @@ -7,18 +6,11 @@ | |||
69 | 7 | ALL | 6 | ALL |
70 | 8 | UTF8 | 7 | UTF8 |
71 | 9 | ) | 8 | ) |
72 | 10 | intltool_merge_translations( | ||
73 | 11 | "libertine-scope-settings.ini.in" | ||
74 | 12 | "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}_${SCOPE_NAME}-settings.ini" | ||
75 | 13 | ALL | ||
76 | 14 | UTF8 | ||
77 | 15 | ) | ||
78 | 16 | 9 | ||
79 | 17 | # Install the scope ini files | 10 | # Install the scope ini files |
80 | 18 | install( | 11 | install( |
81 | 19 | FILES | 12 | FILES |
82 | 20 | "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}_${SCOPE_NAME}.ini" | 13 | "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}_${SCOPE_NAME}.ini" |
83 | 21 | "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME}_${SCOPE_NAME}-settings.ini" | ||
84 | 22 | DESTINATION | 14 | DESTINATION |
85 | 23 | ${SCOPE_INSTALL_DIR} | 15 | ${SCOPE_INSTALL_DIR} |
86 | 24 | ) | 16 | ) |
87 | @@ -31,4 +23,9 @@ | |||
88 | 31 | ${SCOPE_INSTALL_DIR} | 23 | ${SCOPE_INSTALL_DIR} |
89 | 32 | ) | 24 | ) |
90 | 33 | 25 | ||
92 | 34 | 26 | install( | |
93 | 27 | FILES | ||
94 | 28 | "blacklist" | ||
95 | 29 | DESTINATION | ||
96 | 30 | ${SCOPE_INSTALL_DIR} | ||
97 | 31 | ) | ||
98 | 35 | 32 | ||
99 | === added file 'data/blacklist' | |||
100 | --- data/blacklist 1970-01-01 00:00:00 +0000 | |||
101 | +++ data/blacklist 2016-06-16 14:35:35 +0000 | |||
102 | @@ -0,0 +1,11 @@ | |||
103 | 1 | # containerID/desktop file name (without .desktop extension) | ||
104 | 2 | # use containerID "all" to blacklist app from all containers | ||
105 | 3 | # examples: | ||
106 | 4 | all/mb-panel-manager | ||
107 | 5 | all/openjdk-7-java | ||
108 | 6 | all/openjdk-7-policytool | ||
109 | 7 | all/debian-uxterm | ||
110 | 8 | all/yelp | ||
111 | 9 | # include apps per container that are blacklisted for "all" by prepending "whitelist/" | ||
112 | 10 | #whitelist/testc/yelp | ||
113 | 11 | #whitelist/testc/mb-panel-manager | ||
114 | 0 | 12 | ||
115 | === removed file 'data/libertine-scope-settings.ini.in' | |||
116 | --- data/libertine-scope-settings.ini.in 2016-04-21 16:25:00 +0000 | |||
117 | +++ data/libertine-scope-settings.ini.in 1970-01-01 00:00:00 +0000 | |||
118 | @@ -1,24 +0,0 @@ | |||
119 | 1 | [blacklist] | ||
120 | 2 | type = string | ||
121 | 3 | _displayName = Excluded Apps | ||
122 | 4 | defaultValue = Panel Manager;OpenJDK Java 7 Policy Tool;OpenJDK Java 8 Policy Tool; | ||
123 | 5 | |||
124 | 6 | # Below are some example settings. You can access your scope's | ||
125 | 7 | # settings by calling settings() from the Query::run() method. | ||
126 | 8 | # E.g. auto location = settings().at("location").get_string(); | ||
127 | 9 | |||
128 | 10 | #[location] | ||
129 | 11 | #type = string | ||
130 | 12 | #defaultValue = London,uk | ||
131 | 13 | #_displayName = Default Location | ||
132 | 14 | |||
133 | 15 | #[units] | ||
134 | 16 | #type = list | ||
135 | 17 | #_displayName = Temperature Units | ||
136 | 18 | #_displayValues = Metric;Imperial | ||
137 | 19 | #defaultValue = 0 | ||
138 | 20 | |||
139 | 21 | #[forecast] | ||
140 | 22 | #type = boolean | ||
141 | 23 | #defaultValue = true | ||
142 | 24 | #_displayName = Show Forecast | ||
143 | 25 | 0 | ||
144 | === modified file 'debian/changelog' | |||
145 | --- debian/changelog 2016-06-02 18:45:10 +0000 | |||
146 | +++ debian/changelog 2016-06-16 14:35:35 +0000 | |||
147 | @@ -1,3 +1,26 @@ | |||
148 | 1 | libertine-scope (1.3-0ubuntu1) UNRELEASED; urgency=medium | ||
149 | 2 | |||
150 | 3 | [ Chris Townsend ] | ||
151 | 4 | * Use wildcard matching for allowing reading any puritine click package paths | ||
152 | 5 | that have the name "puritine" anywhere in the Click package name. (LP: #1590453) | ||
153 | 6 | |||
154 | 7 | [ Kyle Nitzsche ] | ||
155 | 8 | * Replace the scope settings approach to suppress display of apps with a scope | ||
156 | 9 | filter based approach. This provides a blacklist file for permanent suppression | ||
157 | 10 | and filters for user suppression. | ||
158 | 11 | * Provide a "Hidden X Apps" department for a place to store the apps hidden in | ||
159 | 12 | the main scope view, so they can be unhidden later if desired. | ||
160 | 13 | * Hide 'Help' by default for all containers. (LP: #1591511) | ||
161 | 14 | * Removed Settings. (LP: #1591494) | ||
162 | 15 | |||
163 | 16 | [ Larry Price ] | ||
164 | 17 | * Refactor Query class for consistent style and extract some functionality to | ||
165 | 18 | helper classes. | ||
166 | 19 | * Show a message when no apps are available due to filters or no apps installed. | ||
167 | 20 | (LP: #1589699) | ||
168 | 21 | |||
169 | 22 | -- Chris Townsend <christopher.townsend@canonical.com> Thu, 16 Jun 2016 08:47:40 -0400 | ||
170 | 23 | |||
171 | 1 | libertine-scope (1.2+16.10.20160602.1-0ubuntu1) yakkety; urgency=medium | 24 | libertine-scope (1.2+16.10.20160602.1-0ubuntu1) yakkety; urgency=medium |
172 | 2 | 25 | ||
173 | 3 | [ Chris Townsend ] | 26 | [ Chris Townsend ] |
174 | 4 | 27 | ||
175 | === modified file 'libertine-scope.apparmor' | |||
176 | --- libertine-scope.apparmor 2016-06-01 16:09:43 +0000 | |||
177 | +++ libertine-scope.apparmor 2016-06-16 14:35:35 +0000 | |||
178 | @@ -5,7 +5,7 @@ | |||
179 | 5 | "read_path": [ | 5 | "read_path": [ |
180 | 6 | "@{HOME}/.local/share/libertine/", | 6 | "@{HOME}/.local/share/libertine/", |
181 | 7 | "@{HOME}/.cache/libertine-container/", | 7 | "@{HOME}/.cache/libertine-container/", |
183 | 8 | "@{CLICK_DIR}/com.ubuntu.puritine/" | 8 | "@{CLICK_DIR}/*puritine*/" |
184 | 9 | ], | 9 | ], |
185 | 10 | "write_path": [ | 10 | "write_path": [ |
186 | 11 | "/{dev,run}/shm/lttng-ust-wait-5*" | 11 | "/{dev,run}/shm/lttng-ust-wait-5*" |
187 | 12 | 12 | ||
188 | === modified file 'libertine-scope/CMakeLists.txt' | |||
189 | --- libertine-scope/CMakeLists.txt 2016-05-20 20:55:47 +0000 | |||
190 | +++ libertine-scope/CMakeLists.txt 2016-06-16 14:35:35 +0000 | |||
191 | @@ -24,12 +24,15 @@ | |||
192 | 24 | ${URL_DISPATCHER_LIBRARIES} | 24 | ${URL_DISPATCHER_LIBRARIES} |
193 | 25 | ) | 25 | ) |
194 | 26 | 26 | ||
195 | 27 | configure_file( | ||
196 | 28 | "${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" | ||
197 | 29 | "${CMAKE_CURRENT_SOURCE_DIR}/config.h" | ||
198 | 30 | ) | ||
199 | 27 | 31 | ||
200 | 28 | set_target_properties(scope | 32 | set_target_properties(scope |
201 | 29 | PROPERTIES | 33 | PROPERTIES |
202 | 30 | OUTPUT_NAME "${PACKAGE_NAME}_${SCOPE_NAME}" | 34 | OUTPUT_NAME "${PACKAGE_NAME}_${SCOPE_NAME}" |
203 | 31 | ) | 35 | ) |
204 | 32 | |||
205 | 33 | install(TARGETS scope | 36 | install(TARGETS scope |
206 | 34 | LIBRARY DESTINATION ${SCOPE_INSTALL_DIR} | 37 | LIBRARY DESTINATION ${SCOPE_INSTALL_DIR} |
207 | 35 | ) | 38 | ) |
208 | 36 | 39 | ||
209 | === added file 'libertine-scope/action.cpp' | |||
210 | --- libertine-scope/action.cpp 1970-01-01 00:00:00 +0000 | |||
211 | +++ libertine-scope/action.cpp 2016-06-16 14:35:35 +0000 | |||
212 | @@ -0,0 +1,66 @@ | |||
213 | 1 | /* | ||
214 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
215 | 3 | * | ||
216 | 4 | * This program is free software: you can redistribute it and/or modify | ||
217 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
218 | 6 | * published by the Free Software Foundation. | ||
219 | 7 | * | ||
220 | 8 | * This program is distributed in the hope that it will be useful, | ||
221 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
222 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
223 | 11 | * GNU General Public License for more details. | ||
224 | 12 | * | ||
225 | 13 | * You should have received a copy of the GNU General Public License | ||
226 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
227 | 15 | * * Authored by: | ||
228 | 16 | * Kyle Nitzsche <kyle.nitzsche@canonical.com> | ||
229 | 17 | */ | ||
230 | 18 | |||
231 | 19 | #include "libertine-scope/action.h" | ||
232 | 20 | #include "libertine-scope/config.h" | ||
233 | 21 | #include "libertine-scope/hidden_apps.h" | ||
234 | 22 | #include <unity/scopes/ActivationResponse.h> | ||
235 | 23 | #include <unity/scopes/CannedQuery.h> | ||
236 | 24 | #include <url-dispatcher.h> | ||
237 | 25 | #include <QString> | ||
238 | 26 | #include <QFile> | ||
239 | 27 | #include <QTextStream> | ||
240 | 28 | |||
241 | 29 | namespace usc = unity::scopes; | ||
242 | 30 | |||
243 | 31 | |||
244 | 32 | Action:: | ||
245 | 33 | Action(usc::Result const& result, | ||
246 | 34 | usc::ActionMetadata const& metadata, | ||
247 | 35 | std::string const& action_id, | ||
248 | 36 | std::shared_ptr<HiddenApps> hidden) | ||
249 | 37 | : usc::ActivationQueryBase(result, metadata), | ||
250 | 38 | action_id_(action_id), | ||
251 | 39 | hidden_(hidden) | ||
252 | 40 | { | ||
253 | 41 | } | ||
254 | 42 | |||
255 | 43 | usc::ActivationResponse | ||
256 | 44 | Action::activate() | ||
257 | 45 | { | ||
258 | 46 | if (action_id_ == "open") | ||
259 | 47 | { | ||
260 | 48 | url_dispatch_send(result().uri().c_str() , NULL, NULL); | ||
261 | 49 | return usc::ActivationResponse(usc::ActivationResponse::Status::NotHandled); | ||
262 | 50 | } | ||
263 | 51 | else if (action_id_ == "hide") | ||
264 | 52 | { | ||
265 | 53 | hidden_->add(QString::fromStdString(result()["app_id"].get_string())); | ||
266 | 54 | |||
267 | 55 | usc::CannedQuery cq(SCOPE_PKG + "_" + SCOPE_APP); | ||
268 | 56 | return usc::ActivationResponse(cq); | ||
269 | 57 | } | ||
270 | 58 | else if (action_id_ == "show") | ||
271 | 59 | { | ||
272 | 60 | hidden_->remove(QString::fromStdString(result()["app_id"].get_string())); | ||
273 | 61 | |||
274 | 62 | usc::CannedQuery cq(SCOPE_PKG + "_" + SCOPE_APP); | ||
275 | 63 | return usc::ActivationResponse(cq); | ||
276 | 64 | } | ||
277 | 65 | return usc::ActivationResponse(usc::ActivationResponse::Status::NotHandled); | ||
278 | 66 | } | ||
279 | 0 | 67 | ||
280 | === added file 'libertine-scope/action.h' | |||
281 | --- libertine-scope/action.h 1970-01-01 00:00:00 +0000 | |||
282 | +++ libertine-scope/action.h 2016-06-16 14:35:35 +0000 | |||
283 | @@ -0,0 +1,45 @@ | |||
284 | 1 | /* | ||
285 | 2 | * Copyright (C) 2016 Canonical Ltd | ||
286 | 3 | * | ||
287 | 4 | * This program is free software: you can redistribute it and/or modify | ||
288 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
289 | 6 | * published by the Free Software Foundation. | ||
290 | 7 | * | ||
291 | 8 | * This program is distributed in the hope that it will be useful, | ||
292 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
293 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
294 | 11 | * GNU General Public License for more details. | ||
295 | 12 | * | ||
296 | 13 | * You should have received a copy of the GNU General Public License | ||
297 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
298 | 15 | * * Authored by: | ||
299 | 16 | * Kyle Nitzsche <kyle.nitzsche@canonical.com> | ||
300 | 17 | */ | ||
301 | 18 | |||
302 | 19 | #ifndef SCOPE_ACTION_H_ | ||
303 | 20 | #define SCOPE_ACTION_H_ | ||
304 | 21 | |||
305 | 22 | #include "libertine-scope/scope.h" | ||
306 | 23 | #include <unity/scopes/ActionMetadata.h> | ||
307 | 24 | #include <unity/scopes/ActivationQueryBase.h> | ||
308 | 25 | #include <unity/scopes/ActivationResponse.h> | ||
309 | 26 | #include <unity/scopes/Result.h> | ||
310 | 27 | |||
311 | 28 | class HiddenApps; | ||
312 | 29 | |||
313 | 30 | class Action : public unity::scopes::ActivationQueryBase { | ||
314 | 31 | public: | ||
315 | 32 | Action(unity::scopes::Result const& result, | ||
316 | 33 | unity::scopes::ActionMetadata const& metadata, | ||
317 | 34 | std::string const& action_id, | ||
318 | 35 | std::shared_ptr<HiddenApps> hidden); | ||
319 | 36 | |||
320 | 37 | virtual ~Action() = default; | ||
321 | 38 | virtual unity::scopes::ActivationResponse activate() override; | ||
322 | 39 | |||
323 | 40 | private: | ||
324 | 41 | std::string action_id_; | ||
325 | 42 | std::string cache_dir_; | ||
326 | 43 | std::shared_ptr<HiddenApps> hidden_; | ||
327 | 44 | }; | ||
328 | 45 | #endif | ||
329 | 0 | 46 | ||
330 | === added file 'libertine-scope/blacklist.cpp' | |||
331 | --- libertine-scope/blacklist.cpp 1970-01-01 00:00:00 +0000 | |||
332 | +++ libertine-scope/blacklist.cpp 2016-06-16 14:35:35 +0000 | |||
333 | @@ -0,0 +1,78 @@ | |||
334 | 1 | /* | ||
335 | 2 | * Copyright 2016 Canonical Ltd. | ||
336 | 3 | * | ||
337 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
338 | 5 | * the terms of the GNU General Public License, version 3, as published by the | ||
339 | 6 | * Free Software Foundation. | ||
340 | 7 | * | ||
341 | 8 | * This program is distributed in the hope that it will be useful, | ||
342 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
343 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
344 | 11 | * GNU General Public License for more details. | ||
345 | 12 | * | ||
346 | 13 | * You should have received a copy of the GNU General Public License | ||
347 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
348 | 15 | */ | ||
349 | 16 | #include "libertine-scope/blacklist.h" | ||
350 | 17 | |||
351 | 18 | #include <QFile> | ||
352 | 19 | #include <QTextStream> | ||
353 | 20 | |||
354 | 21 | namespace | ||
355 | 22 | { | ||
356 | 23 | inline QString | ||
357 | 24 | parse_whitelist_key(QString const& line) | ||
358 | 25 | { | ||
359 | 26 | QStringList props = line.split("/"); | ||
360 | 27 | return props.length() == 3 ? QString("%1/%2").arg(props[1]).arg(props[2]) : ""; | ||
361 | 28 | } | ||
362 | 29 | } | ||
363 | 30 | |||
364 | 31 | |||
365 | 32 | Blacklist:: | ||
366 | 33 | Blacklist(std::string const& data_directory) | ||
367 | 34 | { | ||
368 | 35 | parse_blacklist(QString("%1/blacklist").arg(QString::fromStdString(data_directory))); | ||
369 | 36 | } | ||
370 | 37 | |||
371 | 38 | |||
372 | 39 | void Blacklist:: | ||
373 | 40 | parse_blacklist(QString const& blacklist_file_name) | ||
374 | 41 | { | ||
375 | 42 | QFile blacklist_file(blacklist_file_name); | ||
376 | 43 | if (blacklist_file.open(QIODevice::ReadOnly | QIODevice::Text)) | ||
377 | 44 | { | ||
378 | 45 | QTextStream in(&blacklist_file); | ||
379 | 46 | while (!in.atEnd()) | ||
380 | 47 | { | ||
381 | 48 | QString line(in.readLine()); | ||
382 | 49 | if (!line.startsWith("#")) | ||
383 | 50 | { | ||
384 | 51 | if (line.startsWith("whitelist")) | ||
385 | 52 | { | ||
386 | 53 | auto whitelisted_app = parse_whitelist_key(line); | ||
387 | 54 | if (!whitelisted_app.isEmpty()) | ||
388 | 55 | { | ||
389 | 56 | whitelist_.append(parse_whitelist_key(line)); | ||
390 | 57 | } | ||
391 | 58 | } | ||
392 | 59 | else | ||
393 | 60 | { | ||
394 | 61 | blacklist_.append(line.trimmed()); | ||
395 | 62 | } | ||
396 | 63 | } | ||
397 | 64 | } | ||
398 | 65 | blacklist_file.close(); | ||
399 | 66 | } | ||
400 | 67 | } | ||
401 | 68 | |||
402 | 69 | |||
403 | 70 | bool Blacklist:: | ||
404 | 71 | app_is_blacklisted(QString const& app_id, std::string const& container_id) const | ||
405 | 72 | { | ||
406 | 73 | auto global_app_id = QString("all/%1").arg(app_id); | ||
407 | 74 | auto local_app_id = QString("%1/%2").arg(QString::fromStdString(container_id)).arg(app_id); | ||
408 | 75 | |||
409 | 76 | return !(whitelist_.contains(global_app_id) || whitelist_.contains(local_app_id)) && | ||
410 | 77 | (blacklist_.contains(global_app_id) || blacklist_.contains(local_app_id)); | ||
411 | 78 | } | ||
412 | 0 | 79 | ||
413 | === added file 'libertine-scope/blacklist.h' | |||
414 | --- libertine-scope/blacklist.h 1970-01-01 00:00:00 +0000 | |||
415 | +++ libertine-scope/blacklist.h 2016-06-16 14:35:35 +0000 | |||
416 | @@ -0,0 +1,36 @@ | |||
417 | 1 | /* | ||
418 | 2 | * Copyright 2016 Canonical Ltd. | ||
419 | 3 | * | ||
420 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
421 | 5 | * the terms of the GNU General Public License, version 3, as published by the | ||
422 | 6 | * Free Software Foundation. | ||
423 | 7 | * | ||
424 | 8 | * This program is distributed in the hope that it will be useful, | ||
425 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
426 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
427 | 11 | * GNU General Public License for more details. | ||
428 | 12 | * | ||
429 | 13 | * You should have received a copy of the GNU General Public License | ||
430 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
431 | 15 | */ | ||
432 | 16 | #ifndef BLACKLIST_H | ||
433 | 17 | #define BLACKLIST_H | ||
434 | 18 | |||
435 | 19 | #include <QStringList> | ||
436 | 20 | |||
437 | 21 | class Blacklist | ||
438 | 22 | { | ||
439 | 23 | public: | ||
440 | 24 | explicit Blacklist(std::string const& data_directory); | ||
441 | 25 | virtual ~Blacklist() = default; | ||
442 | 26 | |||
443 | 27 | virtual bool app_is_blacklisted(QString const& app_id, std::string const& container_id) const; | ||
444 | 28 | |||
445 | 29 | private: | ||
446 | 30 | void parse_blacklist(QString const& blacklist_file_name); | ||
447 | 31 | |||
448 | 32 | QStringList blacklist_; | ||
449 | 33 | QStringList whitelist_; | ||
450 | 34 | }; | ||
451 | 35 | |||
452 | 36 | #endif // BLACKLIST_H | ||
453 | 0 | 37 | ||
454 | === added file 'libertine-scope/config.h.in' | |||
455 | --- libertine-scope/config.h.in 1970-01-01 00:00:00 +0000 | |||
456 | +++ libertine-scope/config.h.in 2016-06-16 14:35:35 +0000 | |||
457 | @@ -0,0 +1,26 @@ | |||
458 | 1 | /* | ||
459 | 2 | * Copyright 2015-2016 Canonical Ltd. | ||
460 | 3 | * | ||
461 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
462 | 5 | * the terms of the GNU General Public License, version 3, as published by the | ||
463 | 6 | * Free Software Foundation. | ||
464 | 7 | * | ||
465 | 8 | * This program is distributed in the hope that it will be useful, | ||
466 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
467 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
468 | 11 | * GNU General Public License for more details. | ||
469 | 12 | * | ||
470 | 13 | * You should have received a copy of the GNU General Public License | ||
471 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
472 | 15 | */ | ||
473 | 16 | #ifndef LIBERTINE_SCOPE_CONFIG_H_ | ||
474 | 17 | #define LIBERTINE_SCOPE_CONFIG_H_ | ||
475 | 18 | |||
476 | 19 | const std::string SCOPE_PKG = "@PACKAGE_NAME@"; | ||
477 | 20 | const std::string SCOPE_APP = "@SCOPE_NAME@"; | ||
478 | 21 | const std::string ROOT_DEPT_ID = "root_dept"; | ||
479 | 22 | const std::string HIDDEN_DEPT_ID = "hidden_dept"; | ||
480 | 23 | |||
481 | 24 | #endif // LIBERTINE_SCOPE_CONFIG_H_ | ||
482 | 25 | |||
483 | 26 | |||
484 | 0 | 27 | ||
485 | === added file 'libertine-scope/hidden_apps.cpp' | |||
486 | --- libertine-scope/hidden_apps.cpp 1970-01-01 00:00:00 +0000 | |||
487 | +++ libertine-scope/hidden_apps.cpp 2016-06-16 14:35:35 +0000 | |||
488 | @@ -0,0 +1,92 @@ | |||
489 | 1 | /* | ||
490 | 2 | * Copyright 2016 Canonical Ltd. | ||
491 | 3 | * | ||
492 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
493 | 5 | * the terms of the GNU General Public License, version 3, as published by the | ||
494 | 6 | * Free Software Foundation. | ||
495 | 7 | * | ||
496 | 8 | * This program is distributed in the hope that it will be useful, | ||
497 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
498 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
499 | 11 | * GNU General Public License for more details. | ||
500 | 12 | * | ||
501 | 13 | * You should have received a copy of the GNU General Public License | ||
502 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
503 | 15 | */ | ||
504 | 16 | #include "libertine-scope/hidden_apps.h" | ||
505 | 17 | |||
506 | 18 | #include <QFile> | ||
507 | 19 | #include <QTextStream> | ||
508 | 20 | |||
509 | 21 | |||
510 | 22 | namespace | ||
511 | 23 | { | ||
512 | 24 | QStringList | ||
513 | 25 | get_hidden_apps(const QString& hidden_file_name) | ||
514 | 26 | { | ||
515 | 27 | QFile hidden_file(hidden_file_name); | ||
516 | 28 | if (!hidden_file.open(QIODevice::ReadOnly | QIODevice::Text)) | ||
517 | 29 | { | ||
518 | 30 | return QStringList{}; | ||
519 | 31 | } | ||
520 | 32 | |||
521 | 33 | return QString(hidden_file.readAll()).split('\n', QString::SkipEmptyParts); | ||
522 | 34 | } | ||
523 | 35 | } | ||
524 | 36 | |||
525 | 37 | |||
526 | 38 | HiddenApps:: | ||
527 | 39 | HiddenApps(const std::string &cache_directory) | ||
528 | 40 | : hidden_file_name_(QString("%1/hidden").arg(QString::fromStdString(cache_directory))) | ||
529 | 41 | , apps_(get_hidden_apps(hidden_file_name_)) | ||
530 | 42 | { | ||
531 | 43 | } | ||
532 | 44 | |||
533 | 45 | |||
534 | 46 | bool HiddenApps:: | ||
535 | 47 | app_is_hidden(QString const& app_id) const | ||
536 | 48 | { | ||
537 | 49 | return apps_.contains(app_id); | ||
538 | 50 | } | ||
539 | 51 | |||
540 | 52 | |||
541 | 53 | bool HiddenApps:: | ||
542 | 54 | empty() const | ||
543 | 55 | { | ||
544 | 56 | return apps_.empty(); | ||
545 | 57 | } | ||
546 | 58 | |||
547 | 59 | |||
548 | 60 | void HiddenApps:: | ||
549 | 61 | add(const QString &app_id) | ||
550 | 62 | { | ||
551 | 63 | if (!app_is_hidden(app_id)) | ||
552 | 64 | { | ||
553 | 65 | QFile hidden_file(hidden_file_name_); | ||
554 | 66 | if (hidden_file.open(QIODevice::Append | QIODevice::Text)) | ||
555 | 67 | { | ||
556 | 68 | hidden_file.write(app_id.toUtf8() + "\n"); | ||
557 | 69 | } | ||
558 | 70 | |||
559 | 71 | apps_.append(app_id); | ||
560 | 72 | } | ||
561 | 73 | } | ||
562 | 74 | |||
563 | 75 | |||
564 | 76 | void HiddenApps:: | ||
565 | 77 | remove(const QString &app_id) | ||
566 | 78 | { | ||
567 | 79 | if (app_is_hidden(app_id)) | ||
568 | 80 | { | ||
569 | 81 | apps_.removeAll(app_id); | ||
570 | 82 | |||
571 | 83 | QFile hidden_file(hidden_file_name_); | ||
572 | 84 | if (hidden_file.open(QIODevice::WriteOnly | QIODevice::Text)) | ||
573 | 85 | { | ||
574 | 86 | for (auto const& app : apps_) | ||
575 | 87 | { | ||
576 | 88 | hidden_file.write(app.toUtf8() + "\n"); | ||
577 | 89 | } | ||
578 | 90 | } | ||
579 | 91 | } | ||
580 | 92 | } | ||
581 | 0 | 93 | ||
582 | === added file 'libertine-scope/hidden_apps.h' | |||
583 | --- libertine-scope/hidden_apps.h 1970-01-01 00:00:00 +0000 | |||
584 | +++ libertine-scope/hidden_apps.h 2016-06-16 14:35:35 +0000 | |||
585 | @@ -0,0 +1,38 @@ | |||
586 | 1 | /* | ||
587 | 2 | * Copyright 2016 Canonical Ltd. | ||
588 | 3 | * | ||
589 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
590 | 5 | * the terms of the GNU General Public License, version 3, as published by the | ||
591 | 6 | * Free Software Foundation. | ||
592 | 7 | * | ||
593 | 8 | * This program is distributed in the hope that it will be useful, | ||
594 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
595 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
596 | 11 | * GNU General Public License for more details. | ||
597 | 12 | * | ||
598 | 13 | * You should have received a copy of the GNU General Public License | ||
599 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
600 | 15 | */ | ||
601 | 16 | #ifndef HIDDEN_APPS_H | ||
602 | 17 | #define HIDDEN_APPS_H | ||
603 | 18 | |||
604 | 19 | #include <string> | ||
605 | 20 | #include <QStringList> | ||
606 | 21 | |||
607 | 22 | class HiddenApps | ||
608 | 23 | { | ||
609 | 24 | public: | ||
610 | 25 | explicit HiddenApps(const std::string& cache_directory); | ||
611 | 26 | virtual ~HiddenApps() = default; | ||
612 | 27 | |||
613 | 28 | virtual bool app_is_hidden(QString const& app_id) const; | ||
614 | 29 | virtual bool empty() const; | ||
615 | 30 | virtual void add(QString const& app_id); | ||
616 | 31 | virtual void remove(QString const& app_id); | ||
617 | 32 | |||
618 | 33 | private: | ||
619 | 34 | QString hidden_file_name_; | ||
620 | 35 | QStringList apps_; | ||
621 | 36 | }; | ||
622 | 37 | |||
623 | 38 | #endif // HIDDEN_APPS_H | ||
624 | 0 | 39 | ||
625 | === modified file 'libertine-scope/preview.cpp' | |||
626 | --- libertine-scope/preview.cpp 2016-05-03 13:25:14 +0000 | |||
627 | +++ libertine-scope/preview.cpp 2016-06-16 14:35:35 +0000 | |||
628 | @@ -15,6 +15,7 @@ | |||
629 | 15 | */ | 15 | */ |
630 | 16 | 16 | ||
631 | 17 | #include "libertine-scope/preview.h" | 17 | #include "libertine-scope/preview.h" |
632 | 18 | #include "libertine-scope/config.h" | ||
633 | 18 | #include <unity/scopes/PreviewReply.h> | 19 | #include <unity/scopes/PreviewReply.h> |
634 | 19 | #include <unity/scopes/Variant.h> | 20 | #include <unity/scopes/Variant.h> |
635 | 20 | #include <unity/scopes/VariantBuilder.h> | 21 | #include <unity/scopes/VariantBuilder.h> |
636 | @@ -57,6 +58,25 @@ | |||
637 | 57 | {"id", usc::Variant("open")}, | 58 | {"id", usc::Variant("open")}, |
638 | 58 | {"label", usc::Variant("Open")}, | 59 | {"label", usc::Variant("Open")}, |
639 | 59 | }); | 60 | }); |
640 | 61 | |||
641 | 62 | if (result().contains("department_id")) | ||
642 | 63 | { | ||
643 | 64 | if (result()["department_id"].get_string() == ROOT_DEPT_ID) | ||
644 | 65 | { | ||
645 | 66 | vb.add_tuple({ | ||
646 | 67 | {"id", usc::Variant("hide")}, | ||
647 | 68 | {"label", usc::Variant("Hide")}, | ||
648 | 69 | }); | ||
649 | 70 | } | ||
650 | 71 | else | ||
651 | 72 | { | ||
652 | 73 | vb.add_tuple({ | ||
653 | 74 | {"id", usc::Variant("show")}, | ||
654 | 75 | //Translators: Users tap "Show" button to remove an app from the hidden list of apps: so the meaning is to undo a hide | ||
655 | 76 | {"label", usc::Variant("Show")}, | ||
656 | 77 | }); | ||
657 | 78 | } | ||
658 | 79 | } | ||
659 | 60 | buttons.add_attribute_value("actions", vb.end()); | 80 | buttons.add_attribute_value("actions", vb.end()); |
660 | 61 | 81 | ||
661 | 62 | usc::PreviewWidget desc("desc", "text"); | 82 | usc::PreviewWidget desc("desc", "text"); |
662 | 63 | 83 | ||
663 | === modified file 'libertine-scope/preview.h' | |||
664 | --- libertine-scope/preview.h 2016-01-04 23:05:30 +0000 | |||
665 | +++ libertine-scope/preview.h 2016-06-16 14:35:35 +0000 | |||
666 | @@ -33,8 +33,6 @@ | |||
667 | 33 | 33 | ||
668 | 34 | void | 34 | void |
669 | 35 | run(unity::scopes::PreviewReplyProxy const& reply) override; | 35 | run(unity::scopes::PreviewReplyProxy const& reply) override; |
670 | 36 | |||
671 | 37 | private: | ||
672 | 38 | }; | 36 | }; |
673 | 39 | 37 | ||
674 | 40 | #endif /* LIBERTINE_SCOPE_PREVIEW_H */ | 38 | #endif /* LIBERTINE_SCOPE_PREVIEW_H */ |
675 | 41 | 39 | ||
676 | === modified file 'libertine-scope/query.cpp' | |||
677 | --- libertine-scope/query.cpp 2016-05-04 17:56:13 +0000 | |||
678 | +++ libertine-scope/query.cpp 2016-06-16 14:35:35 +0000 | |||
679 | @@ -16,26 +16,66 @@ | |||
680 | 16 | 16 | ||
681 | 17 | #include "libertine-scope/query.h" | 17 | #include "libertine-scope/query.h" |
682 | 18 | #include "libertine-scope/container.h" | 18 | #include "libertine-scope/container.h" |
683 | 19 | #include "libertine-scope/config.h" | ||
684 | 20 | #include "libertine-scope/localization.h" | ||
685 | 19 | #include <unity/scopes/CategorisedResult.h> | 21 | #include <unity/scopes/CategorisedResult.h> |
686 | 20 | #include <unity/scopes/CategoryRenderer.h> | 22 | #include <unity/scopes/CategoryRenderer.h> |
687 | 21 | #include <unity/scopes/QueryBase.h> | 23 | #include <unity/scopes/QueryBase.h> |
688 | 22 | #include <unity/scopes/SearchReply.h> | 24 | #include <unity/scopes/SearchReply.h> |
689 | 25 | #include <unity/scopes/Department.h> | ||
690 | 26 | #include <unity/scopes/OptionSelectorFilter.h> | ||
691 | 27 | #include <unity/scopes/FilterOption.h> | ||
692 | 23 | #include <QString> | 28 | #include <QString> |
693 | 24 | #include <QStringList> | 29 | #include <QStringList> |
694 | 25 | #include <QRegExp> | 30 | #include <QRegExp> |
696 | 26 | 31 | #include <QFile> | |
697 | 32 | #include <QTextStream> | ||
698 | 27 | 33 | ||
699 | 28 | namespace usc = unity::scopes; | 34 | namespace usc = unity::scopes; |
700 | 29 | 35 | ||
701 | 30 | |||
702 | 31 | namespace | 36 | namespace |
703 | 32 | { | 37 | { |
710 | 33 | 38 | static const auto ROOT_DEPT_TITLE = _("X Apps"); | |
711 | 34 | /** | 39 | static const auto HIDDEN_DEPT_TITLE = _("Hidden X Apps"); |
712 | 35 | * A custom rendering layout brazenly stolen from the click scope, so they look | 40 | static const auto DESCRIPTION_FIELD = "description"; |
713 | 36 | * sorta similar. At least until they change theirs. | 41 | static const auto APP_ID_FIELD = "app_id"; |
714 | 37 | */ | 42 | static const auto DEPARTMENT_ID_FIELD = "department_id"; |
715 | 38 | std::string const CATEGORY_APPS_DISPLAY = R"( | 43 | static const auto EXCLUDED_APPS_FILTER_TITLE = _("Exclude Apps: "); |
716 | 44 | |||
717 | 45 | struct AppInfo | ||
718 | 46 | { | ||
719 | 47 | QString container; | ||
720 | 48 | QString app_id; | ||
721 | 49 | QString key; | ||
722 | 50 | }; | ||
723 | 51 | |||
724 | 52 | static AppInfo | ||
725 | 53 | parse_app_info(std::string const& uri) | ||
726 | 54 | { | ||
727 | 55 | QStringList uri_split = QString::fromStdString(uri).split("/"); | ||
728 | 56 | if (uri_split.size() < 4) | ||
729 | 57 | { | ||
730 | 58 | return AppInfo{}; | ||
731 | 59 | } | ||
732 | 60 | |||
733 | 61 | return AppInfo{uri_split[2], uri_split[3], QString("%1/%2").arg(uri_split[2]).arg(uri_split[3])}; | ||
734 | 62 | } | ||
735 | 63 | |||
736 | 64 | static void | ||
737 | 65 | register_departments(usc::SearchReplyProxy const& reply) | ||
738 | 66 | { | ||
739 | 67 | usc::CannedQuery departments("libertine-scope.ubuntu"); | ||
740 | 68 | departments.set_department_id(ROOT_DEPT_ID); | ||
741 | 69 | departments.set_department_id(HIDDEN_DEPT_ID); | ||
742 | 70 | |||
743 | 71 | usc::Department::SPtr root_dept{std::move(usc::Department::create("", departments, ROOT_DEPT_TITLE))}; | ||
744 | 72 | root_dept->add_subdepartment(std::move(usc::Department::create(HIDDEN_DEPT_ID, departments, HIDDEN_DEPT_TITLE))); | ||
745 | 73 | |||
746 | 74 | reply->register_departments(root_dept); | ||
747 | 75 | } | ||
748 | 76 | |||
749 | 77 | |||
750 | 78 | static const auto CATEGORY_APPS_DISPLAY = R"( | ||
751 | 39 | { | 79 | { |
752 | 40 | "schema-version" : 1, | 80 | "schema-version" : 1, |
753 | 41 | "template" : { | 81 | "template" : { |
754 | @@ -53,15 +93,37 @@ | |||
755 | 53 | } | 93 | } |
756 | 54 | )"; | 94 | )"; |
757 | 55 | 95 | ||
758 | 96 | |||
759 | 97 | static const auto CATEGORY_HINT = R"( | ||
760 | 98 | { | ||
761 | 99 | "schema-version": 1, | ||
762 | 100 | "template": { | ||
763 | 101 | "category-layout": "grid", | ||
764 | 102 | "card-size": "large", | ||
765 | 103 | "card-layout": "horizontal" | ||
766 | 104 | }, | ||
767 | 105 | "components": { | ||
768 | 106 | "title": "title" | ||
769 | 107 | } | ||
770 | 108 | } | ||
771 | 109 | )"; | ||
772 | 56 | } // anonymous namespace | 110 | } // anonymous namespace |
773 | 57 | 111 | ||
774 | 58 | 112 | ||
775 | 113 | std::string const Query::NO_RESULTS_HINT = _("No XApps available. Install new applications with the Libertine Manager."); | ||
776 | 114 | std::string const Query::ALL_RESULTS_FILTERED_HINT = _("All XApps hidden. Reset filters or check the Hidden XApps department."); | ||
777 | 115 | |||
778 | 116 | |||
779 | 59 | Query:: | 117 | Query:: |
780 | 60 | Query(usc::CannedQuery const& query, | 118 | Query(usc::CannedQuery const& query, |
781 | 61 | usc::SearchMetadata const& metadata, | 119 | usc::SearchMetadata const& metadata, |
785 | 62 | Libertine::Factory const& libertine_factory) | 120 | Libertine::Factory const& libertine_factory, |
786 | 63 | : usc::SearchQueryBase(query, metadata) | 121 | std::shared_ptr<HiddenApps> hidden, |
787 | 64 | , libertine_factory_(libertine_factory) | 122 | std::shared_ptr<Blacklist> blacklist) |
788 | 123 | : usc::SearchQueryBase(query, metadata) | ||
789 | 124 | , libertine_(libertine_factory()) | ||
790 | 125 | , hidden_(hidden) | ||
791 | 126 | , blacklist_(blacklist) | ||
792 | 65 | { | 127 | { |
793 | 66 | } | 128 | } |
794 | 67 | 129 | ||
795 | @@ -72,44 +134,127 @@ | |||
796 | 72 | } | 134 | } |
797 | 73 | 135 | ||
798 | 74 | 136 | ||
801 | 75 | unity::scopes::VariantMap | 137 | QStringList Query:: |
802 | 76 | Query::settings() const | 138 | make_filters(usc::SearchReplyProxy const& reply) const |
803 | 77 | { | 139 | { |
805 | 78 | return SearchQueryBase::settings(); | 140 | auto filter_state = query().filter_state(); |
806 | 141 | QStringList excludes_by_filter; | ||
807 | 142 | std::list<usc::FilterBase::SCPtr> app_filters; | ||
808 | 143 | |||
809 | 144 | //make exclude scope filter for apps | ||
810 | 145 | for (auto const& container: libertine_->get_container_list()) | ||
811 | 146 | { | ||
812 | 147 | usc::OptionSelectorFilter::SPtr filter{usc::OptionSelectorFilter::create(container->id(), | ||
813 | 148 | EXCLUDED_APPS_FILTER_TITLE + container->name(), | ||
814 | 149 | true)}; | ||
815 | 150 | // filter apps from blacklist | ||
816 | 151 | for (auto const& app: container->app_launchers()) | ||
817 | 152 | { | ||
818 | 153 | auto app_info = parse_app_info(app.uri()); | ||
819 | 154 | |||
820 | 155 | if (hidden_->app_is_hidden(app_info.key)) | ||
821 | 156 | { | ||
822 | 157 | continue; | ||
823 | 158 | } | ||
824 | 159 | |||
825 | 160 | if (!blacklist_->app_is_blacklisted(app_info.app_id, container->id())) | ||
826 | 161 | { | ||
827 | 162 | filter->add_option(app_info.key.toStdString(), app.name()); | ||
828 | 163 | } | ||
829 | 164 | } | ||
830 | 165 | |||
831 | 166 | // get apps manually filtered by user | ||
832 | 167 | if (filter->has_active_option(filter_state)) | ||
833 | 168 | { | ||
834 | 169 | auto filteredApps = filter->active_options(filter_state); | ||
835 | 170 | for (auto const &app: filteredApps) | ||
836 | 171 | { | ||
837 | 172 | excludes_by_filter.append(QString::fromStdString(app->id())); | ||
838 | 173 | } | ||
839 | 174 | } | ||
840 | 175 | |||
841 | 176 | if (!filter->options().empty()) | ||
842 | 177 | { | ||
843 | 178 | app_filters.push_back(filter); | ||
844 | 179 | } | ||
845 | 180 | } | ||
846 | 181 | |||
847 | 182 | if (!app_filters.empty()) | ||
848 | 183 | { | ||
849 | 184 | reply->push(app_filters, filter_state); | ||
850 | 185 | } | ||
851 | 186 | |||
852 | 187 | return excludes_by_filter; | ||
853 | 79 | } | 188 | } |
854 | 80 | 189 | ||
855 | 81 | 190 | ||
858 | 82 | QStringList | 191 | void Query:: |
859 | 83 | Query::blacklist() const | 192 | show_hint(usc::SearchReplyProxy const& reply, |
860 | 193 | std::string const& reason) const | ||
861 | 84 | { | 194 | { |
870 | 85 | QStringList blacklistedApps; | 195 | auto hint_category = reply->register_category("hint", "", "", usc::CategoryRenderer(CATEGORY_HINT)); |
871 | 86 | auto blacklist = settings()["blacklist"]; | 196 | usc::CategorisedResult res(hint_category); |
872 | 87 | if (!blacklist.is_null()) { | 197 | res.set_uri(usc::CannedQuery(query()).to_uri()); |
873 | 88 | blacklistedApps = QString::fromStdString(blacklist.get_string()) | 198 | res.set_title(reason); |
874 | 89 | .remove("\"") | 199 | reply->push(res); |
867 | 90 | .split(";", QString::SkipEmptyParts); | ||
868 | 91 | } | ||
869 | 92 | return blacklistedApps; | ||
875 | 93 | } | 200 | } |
876 | 94 | 201 | ||
877 | 95 | 202 | ||
878 | 96 | void Query:: | 203 | void Query:: |
879 | 97 | run(usc::SearchReplyProxy const& reply) | 204 | run(usc::SearchReplyProxy const& reply) |
880 | 98 | { | 205 | { |
886 | 99 | auto blacklistedApps = blacklist(); | 206 | if (!hidden_->empty()) |
887 | 100 | QRegExp re(QString::fromStdString(query().query_string()), Qt::CaseInsensitive); | 207 | { |
888 | 101 | Libertine::UPtr libertine = libertine_factory_(); | 208 | register_departments(reply); |
889 | 102 | 209 | } | |
890 | 103 | for (auto const& container: libertine->get_container_list()) | 210 | |
891 | 211 | // only provide filters in root department | ||
892 | 212 | QStringList excludes_by_filter; | ||
893 | 213 | if (query().department_id().empty()) | ||
894 | 214 | { | ||
895 | 215 | excludes_by_filter = make_filters(reply); | ||
896 | 216 | } | ||
897 | 217 | |||
898 | 218 | QRegExp search_query(QString::fromStdString(query().query_string()), Qt::CaseInsensitive); | ||
899 | 219 | bool has_no_apps = true, | ||
900 | 220 | all_filtered = true; | ||
901 | 221 | |||
902 | 222 | for (auto const& container: libertine_->get_container_list()) | ||
903 | 104 | { | 223 | { |
904 | 105 | auto category = reply->register_category(container->id(), | 224 | auto category = reply->register_category(container->id(), |
905 | 106 | container->name(), | 225 | container->name(), |
906 | 107 | "Application", | 226 | "Application", |
907 | 108 | usc::CategoryRenderer(CATEGORY_APPS_DISPLAY)); | 227 | usc::CategoryRenderer(CATEGORY_APPS_DISPLAY)); |
908 | 228 | |||
909 | 109 | for (auto const& app: container->app_launchers()) | 229 | for (auto const& app: container->app_launchers()) |
910 | 110 | { | 230 | { |
913 | 111 | if (!(re.isEmpty() || QString::fromStdString(app.name()).contains(re)) | 231 | has_no_apps = false; |
914 | 112 | || blacklistedApps.contains(QString::fromStdString(app.name()))) | 232 | if (!(search_query.isEmpty() || QString::fromStdString(app.name()).contains(search_query))) |
915 | 233 | { | ||
916 | 234 | continue; | ||
917 | 235 | } | ||
918 | 236 | |||
919 | 237 | auto app_info = parse_app_info(app.uri()); | ||
920 | 238 | |||
921 | 239 | if (blacklist_->app_is_blacklisted(app_info.app_id, container->id())) | ||
922 | 240 | { | ||
923 | 241 | continue; | ||
924 | 242 | } | ||
925 | 243 | |||
926 | 244 | if (excludes_by_filter.contains(app_info.key)) | ||
927 | 245 | { | ||
928 | 246 | continue; | ||
929 | 247 | } | ||
930 | 248 | |||
931 | 249 | // ignore hidden apps in root department | ||
932 | 250 | if (query().department_id().empty() || query().department_id() == ROOT_DEPT_ID) | ||
933 | 251 | { | ||
934 | 252 | if (hidden_->app_is_hidden(app_info.key)) | ||
935 | 253 | { | ||
936 | 254 | continue; | ||
937 | 255 | } | ||
938 | 256 | } | ||
939 | 257 | else if (!hidden_->app_is_hidden(app_info.key)) | ||
940 | 113 | { | 258 | { |
941 | 114 | continue; | 259 | continue; |
942 | 115 | } | 260 | } |
943 | @@ -118,12 +263,25 @@ | |||
944 | 118 | result.set_title(app.name()); | 263 | result.set_title(app.name()); |
945 | 119 | result.set_art(app.icon()); | 264 | result.set_art(app.icon()); |
946 | 120 | result.set_uri(app.uri()); | 265 | result.set_uri(app.uri()); |
948 | 121 | result["description"] = app.description(); | 266 | result[DESCRIPTION_FIELD] = app.description(); |
949 | 267 | result[APP_ID_FIELD] = app_info.key.toStdString(); | ||
950 | 268 | result[DEPARTMENT_ID_FIELD] = (query().department_id().empty() || query().department_id() == ROOT_DEPT_ID) ? ROOT_DEPT_ID : HIDDEN_DEPT_ID; | ||
951 | 269 | |||
952 | 122 | if (!reply->push(result)) | 270 | if (!reply->push(result)) |
953 | 123 | { | 271 | { |
955 | 124 | break; | 272 | return; |
956 | 125 | } | 273 | } |
957 | 274 | |||
958 | 275 | all_filtered = false; | ||
959 | 126 | } | 276 | } |
960 | 127 | } | 277 | } |
961 | 278 | |||
962 | 279 | if (has_no_apps) | ||
963 | 280 | { | ||
964 | 281 | show_hint(reply, NO_RESULTS_HINT); | ||
965 | 282 | } | ||
966 | 283 | else if (all_filtered) | ||
967 | 284 | { | ||
968 | 285 | show_hint(reply, ALL_RESULTS_FILTERED_HINT); | ||
969 | 286 | } | ||
970 | 128 | } | 287 | } |
971 | 129 | |||
972 | 130 | 288 | ||
973 | === modified file 'libertine-scope/query.h' | |||
974 | --- libertine-scope/query.h 2016-05-04 17:56:13 +0000 | |||
975 | +++ libertine-scope/query.h 2016-06-16 14:35:35 +0000 | |||
976 | @@ -17,10 +17,11 @@ | |||
977 | 17 | #define LIBERTINE_SCOPE_QUERY_H_ | 17 | #define LIBERTINE_SCOPE_QUERY_H_ |
978 | 18 | 18 | ||
979 | 19 | #include "libertine-scope/libertine.h" | 19 | #include "libertine-scope/libertine.h" |
980 | 20 | #include "libertine-scope/blacklist.h" | ||
981 | 21 | #include "libertine-scope/hidden_apps.h" | ||
982 | 20 | #include <unity/scopes/ReplyProxyFwd.h> | 22 | #include <unity/scopes/ReplyProxyFwd.h> |
983 | 21 | #include <unity/scopes/SearchQueryBase.h> | 23 | #include <unity/scopes/SearchQueryBase.h> |
986 | 22 | 24 | #include <QStringList> | |
985 | 23 | class QStringList; | ||
987 | 24 | 25 | ||
988 | 25 | 26 | ||
989 | 26 | /** | 27 | /** |
990 | @@ -30,25 +31,32 @@ | |||
991 | 30 | : public unity::scopes::SearchQueryBase | 31 | : public unity::scopes::SearchQueryBase |
992 | 31 | { | 32 | { |
993 | 32 | public: | 33 | public: |
1008 | 33 | Query(unity::scopes::CannedQuery const& query, | 34 | Query(unity::scopes::CannedQuery const& query, |
1009 | 34 | unity::scopes::SearchMetadata const& metadata, | 35 | unity::scopes::SearchMetadata const& metadata, |
1010 | 35 | Libertine::Factory const& libertine_factory); | 36 | Libertine::Factory const& libertine_factory, |
1011 | 36 | 37 | std::shared_ptr<HiddenApps> hidden_apps, | |
1012 | 37 | ~Query() = default; | 38 | std::shared_ptr<Blacklist> blacklist); |
1013 | 38 | 39 | ||
1014 | 39 | void | 40 | ~Query() = default; |
1015 | 40 | cancelled() override; | 41 | |
1016 | 41 | 42 | virtual void | |
1017 | 42 | void | 43 | cancelled() override; |
1018 | 43 | run(unity::scopes::SearchReplyProxy const& reply) override; | 44 | |
1019 | 44 | 45 | void | |
1020 | 45 | // Overriding base class method to add ability to test | 46 | run(unity::scopes::SearchReplyProxy const& reply) override; |
1021 | 46 | virtual unity::scopes::VariantMap settings() const; | 47 | |
1022 | 48 | static std::string const NO_RESULTS_HINT; | ||
1023 | 49 | static std::string const ALL_RESULTS_FILTERED_HINT; | ||
1024 | 47 | 50 | ||
1025 | 48 | private: | 51 | private: |
1027 | 49 | QStringList blacklist() const; | 52 | QStringList get_hidden_department() const; |
1028 | 53 | QStringList make_filters(unity::scopes::SearchReplyProxy const& reply) const; | ||
1029 | 54 | void show_hint(unity::scopes::SearchReplyProxy const& reply, std::string const& reason) const; | ||
1030 | 55 | void parse_blacklist(const std::string& data_dir); | ||
1031 | 50 | 56 | ||
1033 | 51 | Libertine::Factory libertine_factory_; | 57 | Libertine::UPtr libertine_; |
1034 | 58 | std::shared_ptr<HiddenApps> hidden_; | ||
1035 | 59 | std::shared_ptr<Blacklist> blacklist_; | ||
1036 | 52 | }; | 60 | }; |
1037 | 53 | 61 | ||
1038 | 54 | #endif // LIBERTINE_SCOPE_QUERY_H_ | 62 | #endif // LIBERTINE_SCOPE_QUERY_H_ |
1039 | 55 | 63 | ||
1040 | === modified file 'libertine-scope/scope.cpp' | |||
1041 | --- libertine-scope/scope.cpp 2016-01-19 21:10:09 +0000 | |||
1042 | +++ libertine-scope/scope.cpp 2016-06-16 14:35:35 +0000 | |||
1043 | @@ -17,40 +17,17 @@ | |||
1044 | 17 | 17 | ||
1045 | 18 | #include "libertine-scope/preview.h" | 18 | #include "libertine-scope/preview.h" |
1046 | 19 | #include "libertine-scope/query.h" | 19 | #include "libertine-scope/query.h" |
1048 | 20 | #include <localization.h> | 20 | #include "libertine-scope/action.h" |
1049 | 21 | #include "libertine-scope/localization.h" | ||
1050 | 21 | #include <sstream> | 22 | #include <sstream> |
1051 | 22 | #include <unity/scopes/ActivationResponse.h> | ||
1052 | 23 | #include <url-dispatcher.h> | 23 | #include <url-dispatcher.h> |
1053 | 24 | #include <QFile> | ||
1054 | 25 | #include <QTextStream> | ||
1055 | 26 | #include <QString> | ||
1056 | 24 | 27 | ||
1057 | 25 | 28 | ||
1058 | 26 | namespace usc = unity::scopes; | 29 | namespace usc = unity::scopes; |
1059 | 27 | 30 | ||
1060 | 28 | namespace | ||
1061 | 29 | { | ||
1062 | 30 | |||
1063 | 31 | /** | ||
1064 | 32 | * @todo move this class into its own source file. | ||
1065 | 33 | */ | ||
1066 | 34 | class ScopeActivation | ||
1067 | 35 | : public usc::ActivationQueryBase | ||
1068 | 36 | { | ||
1069 | 37 | public: | ||
1070 | 38 | ScopeActivation(usc::Result const& result, | ||
1071 | 39 | usc::ActionMetadata const& metadata) | ||
1072 | 40 | : ActivationQueryBase(result, metadata) | ||
1073 | 41 | { } | ||
1074 | 42 | |||
1075 | 43 | usc::ActivationResponse | ||
1076 | 44 | activate() override | ||
1077 | 45 | { | ||
1078 | 46 | return usc::ActivationResponse(status); | ||
1079 | 47 | } | ||
1080 | 48 | |||
1081 | 49 | usc::ActivationResponse::Status status = usc::ActivationResponse::Status::NotHandled; | ||
1082 | 50 | }; | ||
1083 | 51 | |||
1084 | 52 | } // anonymous namespace | ||
1085 | 53 | |||
1086 | 54 | 31 | ||
1087 | 55 | Scope:: | 32 | Scope:: |
1088 | 56 | Scope(Libertine::Factory const& libertine_factory) | 33 | Scope(Libertine::Factory const& libertine_factory) |
1089 | @@ -79,7 +56,11 @@ | |||
1090 | 79 | search(usc::CannedQuery const& query, | 56 | search(usc::CannedQuery const& query, |
1091 | 80 | usc::SearchMetadata const& metadata) | 57 | usc::SearchMetadata const& metadata) |
1092 | 81 | { | 58 | { |
1094 | 82 | return usc::SearchQueryBase::UPtr(new Query(query, metadata, libertine_factory_)); | 59 | return usc::SearchQueryBase::UPtr(new Query(query, |
1095 | 60 | metadata, | ||
1096 | 61 | libertine_factory_, | ||
1097 | 62 | std::make_shared<HiddenApps>(cache_directory()), | ||
1098 | 63 | std::make_shared<Blacklist>(scope_directory()))); | ||
1099 | 83 | } | 64 | } |
1100 | 84 | 65 | ||
1101 | 85 | 66 | ||
1102 | @@ -97,14 +78,10 @@ | |||
1103 | 97 | std::string const& /* widget_id */, | 78 | std::string const& /* widget_id */, |
1104 | 98 | std::string const& action_id) | 79 | std::string const& action_id) |
1105 | 99 | { | 80 | { |
1114 | 100 | auto activation = new ScopeActivation(result, metadata); | 81 | return usc::ActivationQueryBase::UPtr(new Action(result, |
1115 | 101 | 82 | metadata, | |
1116 | 102 | if (action_id == "open") | 83 | action_id, |
1117 | 103 | { | 84 | std::make_shared<HiddenApps>(cache_directory()))); |
1110 | 104 | url_dispatch_send(result.uri().c_str() , NULL, NULL); | ||
1111 | 105 | } | ||
1112 | 106 | |||
1113 | 107 | return usc::ActivationQueryBase::UPtr(activation); | ||
1118 | 108 | } | 85 | } |
1119 | 109 | 86 | ||
1120 | 110 | 87 | ||
1121 | 111 | 88 | ||
1122 | === modified file 'po/en_AU.po' | |||
1123 | --- po/en_AU.po 2016-06-09 06:33:15 +0000 | |||
1124 | +++ po/en_AU.po 2016-06-16 14:35:35 +0000 | |||
1125 | @@ -6,15 +6,16 @@ | |||
1126 | 6 | msgid "" | 6 | msgid "" |
1127 | 7 | msgstr "" | 7 | msgstr "" |
1128 | 8 | "Project-Id-Version: libertine-scope\n" | 8 | "Project-Id-Version: libertine-scope\n" |
1131 | 9 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" | 9 | "Report-Msgid-Bugs-To: \n" |
1132 | 10 | "POT-Creation-Date: 2016-06-08 19:33+0000\n" | 10 | "POT-Creation-Date: 2016-06-02 13:05-0400\n" |
1133 | 11 | "PO-Revision-Date: 2016-05-21 11:19+0000\n" | 11 | "PO-Revision-Date: 2016-05-21 11:19+0000\n" |
1134 | 12 | "Last-Translator: Jared Norris <jarednorris@ubuntu.com>\n" | 12 | "Last-Translator: Jared Norris <jarednorris@ubuntu.com>\n" |
1135 | 13 | "Language-Team: English (Australia) <en_AU@li.org>\n" | 13 | "Language-Team: English (Australia) <en_AU@li.org>\n" |
1136 | 14 | "Language: \n" | ||
1137 | 14 | "MIME-Version: 1.0\n" | 15 | "MIME-Version: 1.0\n" |
1138 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | 16 | "Content-Type: text/plain; charset=UTF-8\n" |
1139 | 16 | "Content-Transfer-Encoding: 8bit\n" | 17 | "Content-Transfer-Encoding: 8bit\n" |
1141 | 17 | "X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n" | 18 | "X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n" |
1142 | 18 | "X-Generator: Launchpad (build 18097)\n" | 19 | "X-Generator: Launchpad (build 18097)\n" |
1143 | 19 | 20 | ||
1144 | 20 | #: ../data/libertine-scope.ini.in.h:1 | 21 | #: ../data/libertine-scope.ini.in.h:1 |
1145 | 21 | 22 | ||
1146 | === modified file 'po/en_GB.po' | |||
1147 | --- po/en_GB.po 2016-06-09 06:33:15 +0000 | |||
1148 | +++ po/en_GB.po 2016-06-16 14:35:35 +0000 | |||
1149 | @@ -6,15 +6,16 @@ | |||
1150 | 6 | msgid "" | 6 | msgid "" |
1151 | 7 | msgstr "" | 7 | msgstr "" |
1152 | 8 | "Project-Id-Version: libertine-scope\n" | 8 | "Project-Id-Version: libertine-scope\n" |
1155 | 9 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" | 9 | "Report-Msgid-Bugs-To: \n" |
1156 | 10 | "POT-Creation-Date: 2016-06-08 19:33+0000\n" | 10 | "POT-Creation-Date: 2016-06-02 13:05-0400\n" |
1157 | 11 | "PO-Revision-Date: 2016-05-20 16:47+0000\n" | 11 | "PO-Revision-Date: 2016-05-20 16:47+0000\n" |
1158 | 12 | "Last-Translator: Andi Chandler <Unknown>\n" | 12 | "Last-Translator: Andi Chandler <Unknown>\n" |
1159 | 13 | "Language-Team: English (United Kingdom) <en_GB@li.org>\n" | 13 | "Language-Team: English (United Kingdom) <en_GB@li.org>\n" |
1160 | 14 | "Language: \n" | ||
1161 | 14 | "MIME-Version: 1.0\n" | 15 | "MIME-Version: 1.0\n" |
1162 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | 16 | "Content-Type: text/plain; charset=UTF-8\n" |
1163 | 16 | "Content-Transfer-Encoding: 8bit\n" | 17 | "Content-Transfer-Encoding: 8bit\n" |
1165 | 17 | "X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n" | 18 | "X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n" |
1166 | 18 | "X-Generator: Launchpad (build 18097)\n" | 19 | "X-Generator: Launchpad (build 18097)\n" |
1167 | 19 | 20 | ||
1168 | 20 | #: ../data/libertine-scope.ini.in.h:1 | 21 | #: ../data/libertine-scope.ini.in.h:1 |
1169 | 21 | 22 | ||
1170 | === modified file 'po/es.po' | |||
1171 | --- po/es.po 2016-06-09 06:33:15 +0000 | |||
1172 | +++ po/es.po 2016-06-16 14:35:35 +0000 | |||
1173 | @@ -6,15 +6,16 @@ | |||
1174 | 6 | msgid "" | 6 | msgid "" |
1175 | 7 | msgstr "" | 7 | msgstr "" |
1176 | 8 | "Project-Id-Version: libertine-scope\n" | 8 | "Project-Id-Version: libertine-scope\n" |
1179 | 9 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" | 9 | "Report-Msgid-Bugs-To: \n" |
1180 | 10 | "POT-Creation-Date: 2016-06-08 19:33+0000\n" | 10 | "POT-Creation-Date: 2016-06-02 13:05-0400\n" |
1181 | 11 | "PO-Revision-Date: 2016-06-04 22:37+0000\n" | 11 | "PO-Revision-Date: 2016-06-04 22:37+0000\n" |
1182 | 12 | "Last-Translator: Adolfo Jayme <fitoschido@gmail.com>\n" | 12 | "Last-Translator: Adolfo Jayme <fitoschido@gmail.com>\n" |
1183 | 13 | "Language-Team: Spanish <es@li.org>\n" | 13 | "Language-Team: Spanish <es@li.org>\n" |
1184 | 14 | "Language: es\n" | ||
1185 | 14 | "MIME-Version: 1.0\n" | 15 | "MIME-Version: 1.0\n" |
1186 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | 16 | "Content-Type: text/plain; charset=UTF-8\n" |
1187 | 16 | "Content-Transfer-Encoding: 8bit\n" | 17 | "Content-Transfer-Encoding: 8bit\n" |
1189 | 17 | "X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n" | 18 | "X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n" |
1190 | 18 | "X-Generator: Launchpad (build 18097)\n" | 19 | "X-Generator: Launchpad (build 18097)\n" |
1191 | 19 | 20 | ||
1192 | 20 | #: ../data/libertine-scope.ini.in.h:1 | 21 | #: ../data/libertine-scope.ini.in.h:1 |
1193 | @@ -23,5 +24,8 @@ | |||
1194 | 23 | 24 | ||
1195 | 24 | #: ../data/libertine-scope.ini.in.h:2 | 25 | #: ../data/libertine-scope.ini.in.h:2 |
1196 | 25 | msgid "Surface and launch DEB-packaged X11-based applications." | 26 | msgid "Surface and launch DEB-packaged X11-based applications." |
1199 | 26 | msgstr "" | 27 | msgstr "Mostrar y ejecutar aplicaciones basadas en X11 y empaquetadas en DEB." |
1200 | 27 | "Mostrar y ejecutar aplicaciones basadas en X11 y empaquetadas en DEB." | 28 | |
1201 | 29 | #, fuzzy | ||
1202 | 30 | #~ msgid "X Apps" | ||
1203 | 31 | #~ msgstr "XApps" | ||
1204 | 28 | 32 | ||
1205 | === modified file 'po/fi.po' | |||
1206 | --- po/fi.po 2016-06-09 06:33:15 +0000 | |||
1207 | +++ po/fi.po 2016-06-16 14:35:35 +0000 | |||
1208 | @@ -6,15 +6,16 @@ | |||
1209 | 6 | msgid "" | 6 | msgid "" |
1210 | 7 | msgstr "" | 7 | msgstr "" |
1211 | 8 | "Project-Id-Version: libertine-scope\n" | 8 | "Project-Id-Version: libertine-scope\n" |
1214 | 9 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" | 9 | "Report-Msgid-Bugs-To: \n" |
1215 | 10 | "POT-Creation-Date: 2016-06-08 19:33+0000\n" | 10 | "POT-Creation-Date: 2016-06-02 13:05-0400\n" |
1216 | 11 | "PO-Revision-Date: 2016-05-30 07:34+0000\n" | 11 | "PO-Revision-Date: 2016-05-30 07:34+0000\n" |
1217 | 12 | "Last-Translator: Jiri Grönroos <Unknown>\n" | 12 | "Last-Translator: Jiri Grönroos <Unknown>\n" |
1218 | 13 | "Language-Team: Finnish <fi@li.org>\n" | 13 | "Language-Team: Finnish <fi@li.org>\n" |
1219 | 14 | "Language: fi\n" | ||
1220 | 14 | "MIME-Version: 1.0\n" | 15 | "MIME-Version: 1.0\n" |
1221 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | 16 | "Content-Type: text/plain; charset=UTF-8\n" |
1222 | 16 | "Content-Transfer-Encoding: 8bit\n" | 17 | "Content-Transfer-Encoding: 8bit\n" |
1224 | 17 | "X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n" | 18 | "X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n" |
1225 | 18 | "X-Generator: Launchpad (build 18097)\n" | 19 | "X-Generator: Launchpad (build 18097)\n" |
1226 | 19 | 20 | ||
1227 | 20 | #: ../data/libertine-scope.ini.in.h:1 | 21 | #: ../data/libertine-scope.ini.in.h:1 |
1228 | 21 | 22 | ||
1229 | === modified file 'po/fr.po' | |||
1230 | --- po/fr.po 2016-06-09 06:33:15 +0000 | |||
1231 | +++ po/fr.po 2016-06-16 14:35:35 +0000 | |||
1232 | @@ -6,15 +6,16 @@ | |||
1233 | 6 | msgid "" | 6 | msgid "" |
1234 | 7 | msgstr "" | 7 | msgstr "" |
1235 | 8 | "Project-Id-Version: libertine-scope\n" | 8 | "Project-Id-Version: libertine-scope\n" |
1238 | 9 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" | 9 | "Report-Msgid-Bugs-To: \n" |
1239 | 10 | "POT-Creation-Date: 2016-06-08 19:33+0000\n" | 10 | "POT-Creation-Date: 2016-06-02 13:05-0400\n" |
1240 | 11 | "PO-Revision-Date: 2016-05-21 12:23+0000\n" | 11 | "PO-Revision-Date: 2016-05-21 12:23+0000\n" |
1241 | 12 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | 12 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
1242 | 13 | "Language-Team: French <fr@li.org>\n" | 13 | "Language-Team: French <fr@li.org>\n" |
1243 | 14 | "Language: fr\n" | ||
1244 | 14 | "MIME-Version: 1.0\n" | 15 | "MIME-Version: 1.0\n" |
1245 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | 16 | "Content-Type: text/plain; charset=UTF-8\n" |
1246 | 16 | "Content-Transfer-Encoding: 8bit\n" | 17 | "Content-Transfer-Encoding: 8bit\n" |
1248 | 17 | "X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n" | 18 | "X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n" |
1249 | 18 | "X-Generator: Launchpad (build 18097)\n" | 19 | "X-Generator: Launchpad (build 18097)\n" |
1250 | 19 | 20 | ||
1251 | 20 | #: ../data/libertine-scope.ini.in.h:1 | 21 | #: ../data/libertine-scope.ini.in.h:1 |
1252 | 21 | 22 | ||
1253 | === modified file 'po/gl.po' | |||
1254 | --- po/gl.po 2016-06-09 06:33:15 +0000 | |||
1255 | +++ po/gl.po 2016-06-16 14:35:35 +0000 | |||
1256 | @@ -6,15 +6,16 @@ | |||
1257 | 6 | msgid "" | 6 | msgid "" |
1258 | 7 | msgstr "" | 7 | msgstr "" |
1259 | 8 | "Project-Id-Version: libertine-scope\n" | 8 | "Project-Id-Version: libertine-scope\n" |
1262 | 9 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" | 9 | "Report-Msgid-Bugs-To: \n" |
1263 | 10 | "POT-Creation-Date: 2016-06-08 19:33+0000\n" | 10 | "POT-Creation-Date: 2016-06-02 13:05-0400\n" |
1264 | 11 | "PO-Revision-Date: 2016-06-06 23:23+0000\n" | 11 | "PO-Revision-Date: 2016-06-06 23:23+0000\n" |
1265 | 12 | "Last-Translator: Marcos Lans <Unknown>\n" | 12 | "Last-Translator: Marcos Lans <Unknown>\n" |
1266 | 13 | "Language-Team: Galician <gl@li.org>\n" | 13 | "Language-Team: Galician <gl@li.org>\n" |
1267 | 14 | "Language: gl\n" | ||
1268 | 14 | "MIME-Version: 1.0\n" | 15 | "MIME-Version: 1.0\n" |
1269 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | 16 | "Content-Type: text/plain; charset=UTF-8\n" |
1270 | 16 | "Content-Transfer-Encoding: 8bit\n" | 17 | "Content-Transfer-Encoding: 8bit\n" |
1272 | 17 | "X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n" | 18 | "X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n" |
1273 | 18 | "X-Generator: Launchpad (build 18097)\n" | 19 | "X-Generator: Launchpad (build 18097)\n" |
1274 | 19 | 20 | ||
1275 | 20 | #: ../data/libertine-scope.ini.in.h:1 | 21 | #: ../data/libertine-scope.ini.in.h:1 |
1276 | @@ -25,3 +26,7 @@ | |||
1277 | 25 | msgid "Surface and launch DEB-packaged X11-based applications." | 26 | msgid "Surface and launch DEB-packaged X11-based applications." |
1278 | 26 | msgstr "" | 27 | msgstr "" |
1279 | 27 | "Inicia e executa aplicativos baseados en X11 empaquetados en formato DEB." | 28 | "Inicia e executa aplicativos baseados en X11 empaquetados en formato DEB." |
1280 | 29 | |||
1281 | 30 | #, fuzzy | ||
1282 | 31 | #~ msgid "X Apps" | ||
1283 | 32 | #~ msgstr "XApps" | ||
1284 | 28 | 33 | ||
1285 | === modified file 'po/libertine-scope.pot' | |||
1286 | --- po/libertine-scope.pot 2016-06-02 17:13:50 +0000 | |||
1287 | +++ po/libertine-scope.pot 2016-06-16 14:35:35 +0000 | |||
1288 | @@ -8,7 +8,7 @@ | |||
1289 | 8 | msgstr "" | 8 | msgstr "" |
1290 | 9 | "Project-Id-Version: PACKAGE VERSION\n" | 9 | "Project-Id-Version: PACKAGE VERSION\n" |
1291 | 10 | "Report-Msgid-Bugs-To: \n" | 10 | "Report-Msgid-Bugs-To: \n" |
1293 | 11 | "POT-Creation-Date: 2016-06-02 13:05-0400\n" | 11 | "POT-Creation-Date: 2016-06-16 08:41-0400\n" |
1294 | 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
1295 | 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
1296 | 14 | "Language-Team: LANGUAGE <LL@li.org>\n" | 14 | "Language-Team: LANGUAGE <LL@li.org>\n" |
1297 | @@ -24,3 +24,25 @@ | |||
1298 | 24 | #: ../data/libertine-scope.ini.in.h:2 | 24 | #: ../data/libertine-scope.ini.in.h:2 |
1299 | 25 | msgid "Surface and launch DEB-packaged X11-based applications." | 25 | msgid "Surface and launch DEB-packaged X11-based applications." |
1300 | 26 | msgstr "" | 26 | msgstr "" |
1301 | 27 | |||
1302 | 28 | #: ../libertine-scope/query.cpp:38 | ||
1303 | 29 | msgid "X Apps" | ||
1304 | 30 | msgstr "" | ||
1305 | 31 | |||
1306 | 32 | #: ../libertine-scope/query.cpp:39 | ||
1307 | 33 | msgid "Hidden X Apps" | ||
1308 | 34 | msgstr "" | ||
1309 | 35 | |||
1310 | 36 | #: ../libertine-scope/query.cpp:43 | ||
1311 | 37 | msgid "Exclude Apps: " | ||
1312 | 38 | msgstr "" | ||
1313 | 39 | |||
1314 | 40 | #. anonymous namespace | ||
1315 | 41 | #: ../libertine-scope/query.cpp:113 | ||
1316 | 42 | msgid "" | ||
1317 | 43 | "No XApps available. Install new applications with the Libertine Manager." | ||
1318 | 44 | msgstr "" | ||
1319 | 45 | |||
1320 | 46 | #: ../libertine-scope/query.cpp:114 | ||
1321 | 47 | msgid "All XApps hidden. Reset filters or check the Hidden XApps department." | ||
1322 | 48 | msgstr "" | ||
1323 | 27 | 49 | ||
1324 | === modified file 'po/ms.po' | |||
1325 | --- po/ms.po 2016-06-09 06:33:15 +0000 | |||
1326 | +++ po/ms.po 2016-06-16 14:35:35 +0000 | |||
1327 | @@ -6,15 +6,16 @@ | |||
1328 | 6 | msgid "" | 6 | msgid "" |
1329 | 7 | msgstr "" | 7 | msgstr "" |
1330 | 8 | "Project-Id-Version: libertine-scope\n" | 8 | "Project-Id-Version: libertine-scope\n" |
1333 | 9 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" | 9 | "Report-Msgid-Bugs-To: \n" |
1334 | 10 | "POT-Creation-Date: 2016-06-08 19:33+0000\n" | 10 | "POT-Creation-Date: 2016-06-02 13:05-0400\n" |
1335 | 11 | "PO-Revision-Date: 2016-05-22 00:24+0000\n" | 11 | "PO-Revision-Date: 2016-05-22 00:24+0000\n" |
1336 | 12 | "Last-Translator: abuyop <Unknown>\n" | 12 | "Last-Translator: abuyop <Unknown>\n" |
1337 | 13 | "Language-Team: Malay <ms@li.org>\n" | 13 | "Language-Team: Malay <ms@li.org>\n" |
1338 | 14 | "Language: ms\n" | ||
1339 | 14 | "MIME-Version: 1.0\n" | 15 | "MIME-Version: 1.0\n" |
1340 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | 16 | "Content-Type: text/plain; charset=UTF-8\n" |
1341 | 16 | "Content-Transfer-Encoding: 8bit\n" | 17 | "Content-Transfer-Encoding: 8bit\n" |
1343 | 17 | "X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n" | 18 | "X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n" |
1344 | 18 | "X-Generator: Launchpad (build 18097)\n" | 19 | "X-Generator: Launchpad (build 18097)\n" |
1345 | 19 | 20 | ||
1346 | 20 | #: ../data/libertine-scope.ini.in.h:1 | 21 | #: ../data/libertine-scope.ini.in.h:1 |
1347 | 21 | 22 | ||
1348 | === modified file 'po/pt.po' | |||
1349 | --- po/pt.po 2016-06-09 06:33:15 +0000 | |||
1350 | +++ po/pt.po 2016-06-16 14:35:35 +0000 | |||
1351 | @@ -6,15 +6,16 @@ | |||
1352 | 6 | msgid "" | 6 | msgid "" |
1353 | 7 | msgstr "" | 7 | msgstr "" |
1354 | 8 | "Project-Id-Version: libertine-scope\n" | 8 | "Project-Id-Version: libertine-scope\n" |
1357 | 9 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" | 9 | "Report-Msgid-Bugs-To: \n" |
1358 | 10 | "POT-Creation-Date: 2016-06-08 19:33+0000\n" | 10 | "POT-Creation-Date: 2016-06-02 13:05-0400\n" |
1359 | 11 | "PO-Revision-Date: 2016-05-20 16:05+0000\n" | 11 | "PO-Revision-Date: 2016-05-20 16:05+0000\n" |
1360 | 12 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | 12 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
1361 | 13 | "Language-Team: Portuguese <pt@li.org>\n" | 13 | "Language-Team: Portuguese <pt@li.org>\n" |
1362 | 14 | "Language: pt\n" | ||
1363 | 14 | "MIME-Version: 1.0\n" | 15 | "MIME-Version: 1.0\n" |
1364 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | 16 | "Content-Type: text/plain; charset=UTF-8\n" |
1365 | 16 | "Content-Transfer-Encoding: 8bit\n" | 17 | "Content-Transfer-Encoding: 8bit\n" |
1367 | 17 | "X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n" | 18 | "X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n" |
1368 | 18 | "X-Generator: Launchpad (build 18097)\n" | 19 | "X-Generator: Launchpad (build 18097)\n" |
1369 | 19 | 20 | ||
1370 | 20 | #: ../data/libertine-scope.ini.in.h:1 | 21 | #: ../data/libertine-scope.ini.in.h:1 |
1371 | 21 | 22 | ||
1372 | === modified file 'po/uk.po' | |||
1373 | --- po/uk.po 2016-06-09 06:33:15 +0000 | |||
1374 | +++ po/uk.po 2016-06-16 14:35:35 +0000 | |||
1375 | @@ -6,15 +6,16 @@ | |||
1376 | 6 | msgid "" | 6 | msgid "" |
1377 | 7 | msgstr "" | 7 | msgstr "" |
1378 | 8 | "Project-Id-Version: libertine-scope\n" | 8 | "Project-Id-Version: libertine-scope\n" |
1381 | 9 | "Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n" | 9 | "Report-Msgid-Bugs-To: \n" |
1382 | 10 | "POT-Creation-Date: 2016-06-08 19:33+0000\n" | 10 | "POT-Creation-Date: 2016-06-02 13:05-0400\n" |
1383 | 11 | "PO-Revision-Date: 2016-05-20 15:56+0000\n" | 11 | "PO-Revision-Date: 2016-05-20 15:56+0000\n" |
1384 | 12 | "Last-Translator: Yuri Chornoivan <yurchor@gmail.com>\n" | 12 | "Last-Translator: Yuri Chornoivan <yurchor@gmail.com>\n" |
1385 | 13 | "Language-Team: Ukrainian <uk@li.org>\n" | 13 | "Language-Team: Ukrainian <uk@li.org>\n" |
1386 | 14 | "Language: uk\n" | ||
1387 | 14 | "MIME-Version: 1.0\n" | 15 | "MIME-Version: 1.0\n" |
1388 | 15 | "Content-Type: text/plain; charset=UTF-8\n" | 16 | "Content-Type: text/plain; charset=UTF-8\n" |
1389 | 16 | "Content-Transfer-Encoding: 8bit\n" | 17 | "Content-Transfer-Encoding: 8bit\n" |
1391 | 17 | "X-Launchpad-Export-Date: 2016-06-09 06:33+0000\n" | 18 | "X-Launchpad-Export-Date: 2016-06-07 05:45+0000\n" |
1392 | 18 | "X-Generator: Launchpad (build 18097)\n" | 19 | "X-Generator: Launchpad (build 18097)\n" |
1393 | 19 | 20 | ||
1394 | 20 | #: ../data/libertine-scope.ini.in.h:1 | 21 | #: ../data/libertine-scope.ini.in.h:1 |
1395 | 21 | 22 | ||
1396 | === modified file 'tests/CMakeLists.txt' | |||
1397 | --- tests/CMakeLists.txt 2016-05-03 13:25:14 +0000 | |||
1398 | +++ tests/CMakeLists.txt 2016-06-16 14:35:35 +0000 | |||
1399 | @@ -3,24 +3,27 @@ | |||
1400 | 3 | set (GTEST_INCLUDE_DIR "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory") | 3 | set (GTEST_INCLUDE_DIR "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory") |
1401 | 4 | add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock") | 4 | add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock") |
1402 | 5 | 5 | ||
1424 | 6 | add_executable(libertine_scope_tests | 6 | function(create_test test_name) |
1425 | 7 | fake_container.cpp | 7 | add_executable(${test_name}_exe |
1426 | 8 | fake_libertine.cpp | 8 | fake_container.cpp |
1427 | 9 | 9 | fake_libertine.cpp | |
1428 | 10 | # tests | 10 | ${test_name}.cpp |
1429 | 11 | test_scope.cpp | 11 | ) |
1430 | 12 | test_preview.cpp | 12 | |
1431 | 13 | test_query.cpp | 13 | target_link_libraries(${test_name}_exe |
1432 | 14 | ) | 14 | scope |
1433 | 15 | 15 | Qt5::Core | |
1434 | 16 | target_link_libraries(libertine_scope_tests | 16 | gmock |
1435 | 17 | scope | 17 | gmock_main |
1436 | 18 | Qt5::Core | 18 | ) |
1437 | 19 | gmock | 19 | |
1438 | 20 | gmock_main | 20 | add_test(${test_name} ${test_name}_exe) |
1439 | 21 | ) | 21 | endfunction(create_test) |
1440 | 22 | 22 | ||
1441 | 23 | add_test(test_scope libertine_scope_tests) | 23 | create_test(test_scope) |
1442 | 24 | add_test(test_preview libertine_scope_tests) | 24 | create_test(test_preview) |
1443 | 25 | add_test(test_query libertine_scope_tests) | 25 | create_test(test_query) |
1444 | 26 | 26 | create_test(test_hidden_apps) | |
1445 | 27 | create_test(test_blacklist) | ||
1446 | 28 | |||
1447 | 29 | file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) | ||
1448 | 27 | 30 | ||
1449 | === modified file 'tests/TypedScopeFixture.h' | |||
1450 | --- tests/TypedScopeFixture.h 2016-01-19 05:10:54 +0000 | |||
1451 | +++ tests/TypedScopeFixture.h 2016-06-16 14:35:35 +0000 | |||
1452 | @@ -85,6 +85,7 @@ | |||
1453 | 85 | { | 85 | { |
1454 | 86 | TypedScopeFixtureHelper::set_registry(scope, registry_proxy); | 86 | TypedScopeFixtureHelper::set_registry(scope, registry_proxy); |
1455 | 87 | TypedScopeFixtureHelper::set_scope_directory(scope, "/tmp"); | 87 | TypedScopeFixtureHelper::set_scope_directory(scope, "/tmp"); |
1456 | 88 | TypedScopeFixtureHelper::set_cache_directory(scope, "/tmp"); | ||
1457 | 88 | TypedScopeFixtureHelper::set_app_directory(scope, "/tmp"); | 89 | TypedScopeFixtureHelper::set_app_directory(scope, "/tmp"); |
1458 | 89 | } | 90 | } |
1459 | 90 | 91 | ||
1460 | 91 | 92 | ||
1461 | === added directory 'tests/data' | |||
1462 | === added file 'tests/data/blacklist' | |||
1463 | --- tests/data/blacklist 1970-01-01 00:00:00 +0000 | |||
1464 | +++ tests/data/blacklist 2016-06-16 14:35:35 +0000 | |||
1465 | @@ -0,0 +1,9 @@ | |||
1466 | 1 | # simple blacklisting` | ||
1467 | 2 | container1/app1 | ||
1468 | 3 | all/app2 | ||
1469 | 4 | |||
1470 | 5 | # blacklisted but overriden by whitelisting | ||
1471 | 6 | all/app3 | ||
1472 | 7 | all/app4 | ||
1473 | 8 | whitelist/container1/app3 | ||
1474 | 9 | whitelist/all/app4 | ||
1475 | 0 | 10 | ||
1476 | === added file 'tests/data/hidden' | |||
1477 | --- tests/data/hidden 1970-01-01 00:00:00 +0000 | |||
1478 | +++ tests/data/hidden 2016-06-16 14:35:35 +0000 | |||
1479 | @@ -0,0 +1,1 @@ | |||
1480 | 1 | container1/app1 | ||
1481 | 0 | 2 | ||
1482 | === modified file 'tests/fake_container.cpp' | |||
1483 | --- tests/fake_container.cpp 2016-04-27 17:53:30 +0000 | |||
1484 | +++ tests/fake_container.cpp 2016-06-16 14:35:35 +0000 | |||
1485 | @@ -42,10 +42,9 @@ | |||
1486 | 42 | } | 42 | } |
1487 | 43 | }; | 43 | }; |
1488 | 44 | 44 | ||
1489 | 45 | |||
1490 | 46 | FakeContainer:: | 45 | FakeContainer:: |
1491 | 47 | FakeContainer(std::string const& json_string) | 46 | FakeContainer(std::string const& json_string) |
1493 | 48 | : Container("fakeId", "fakeName") | 47 | : Container("fake-container", "fake-container") |
1494 | 49 | { | 48 | { |
1495 | 50 | QJsonDocument json = QJsonDocument::fromJson(QByteArray::fromStdString(json_string), nullptr); | 49 | QJsonDocument json = QJsonDocument::fromJson(QByteArray::fromStdString(json_string), nullptr); |
1496 | 51 | QJsonObject object = json.object(); | 50 | QJsonObject object = json.object(); |
1497 | 52 | 51 | ||
1498 | === modified file 'tests/fake_container_json.h' | |||
1499 | --- tests/fake_container_json.h 2016-04-27 17:53:30 +0000 | |||
1500 | +++ tests/fake_container_json.h 2016-06-16 14:35:35 +0000 | |||
1501 | @@ -32,7 +32,7 @@ | |||
1502 | 32 | "name": "Panel Manager", | 32 | "name": "Panel Manager", |
1503 | 33 | "no_display": false, | 33 | "no_display": false, |
1504 | 34 | "description": "some description", | 34 | "description": "some description", |
1506 | 35 | "uri": "some/uri" | 35 | "uri": "some/uri/pad1/pad2/" |
1507 | 36 | }, | 36 | }, |
1508 | 37 | { | 37 | { |
1509 | 38 | "desktop_file_name": "/home/someuser/.cache/libertine-container/fake1/rootfs/usr/share/applications/sakura.desktop", | 38 | "desktop_file_name": "/home/someuser/.cache/libertine-container/fake1/rootfs/usr/share/applications/sakura.desktop", |
1510 | @@ -44,7 +44,7 @@ | |||
1511 | 44 | "name": "Sakura", | 44 | "name": "Sakura", |
1512 | 45 | "no_display": false, | 45 | "no_display": false, |
1513 | 46 | "description": "some other description", | 46 | "description": "some other description", |
1515 | 47 | "uri": "some/other/uri" | 47 | "uri": "some/other/uri/pad" |
1516 | 48 | } | 48 | } |
1517 | 49 | ] | 49 | ] |
1518 | 50 | } | 50 | } |
1519 | 51 | 51 | ||
1520 | === modified file 'tests/fake_libertine.cpp' | |||
1521 | --- tests/fake_libertine.cpp 2016-01-19 00:16:56 +0000 | |||
1522 | +++ tests/fake_libertine.cpp 2016-06-16 14:35:35 +0000 | |||
1523 | @@ -25,12 +25,6 @@ | |||
1524 | 25 | } | 25 | } |
1525 | 26 | 26 | ||
1526 | 27 | 27 | ||
1527 | 28 | FakeLibertine:: | ||
1528 | 29 | ~FakeLibertine() | ||
1529 | 30 | { | ||
1530 | 31 | } | ||
1531 | 32 | |||
1532 | 33 | |||
1533 | 34 | Libertine::ContainerList const& FakeLibertine:: | 28 | Libertine::ContainerList const& FakeLibertine:: |
1534 | 35 | get_container_list() const | 29 | get_container_list() const |
1535 | 36 | { | 30 | { |
1536 | 37 | 31 | ||
1537 | === modified file 'tests/fake_libertine.h' | |||
1538 | --- tests/fake_libertine.h 2016-01-19 21:10:09 +0000 | |||
1539 | +++ tests/fake_libertine.h 2016-06-16 14:35:35 +0000 | |||
1540 | @@ -27,9 +27,9 @@ | |||
1541 | 27 | : public Libertine | 27 | : public Libertine |
1542 | 28 | { | 28 | { |
1543 | 29 | public: | 29 | public: |
1545 | 30 | ~FakeLibertine(); | 30 | virtual ~FakeLibertine() = default; |
1546 | 31 | 31 | ||
1548 | 32 | Libertine::ContainerList const& | 32 | virtual Libertine::ContainerList const& |
1549 | 33 | get_container_list() const override; | 33 | get_container_list() const override; |
1550 | 34 | 34 | ||
1551 | 35 | static Libertine::UPtr | 35 | static Libertine::UPtr |
1552 | 36 | 36 | ||
1553 | === added file 'tests/test_blacklist.cpp' | |||
1554 | --- tests/test_blacklist.cpp 1970-01-01 00:00:00 +0000 | |||
1555 | +++ tests/test_blacklist.cpp 2016-06-16 14:35:35 +0000 | |||
1556 | @@ -0,0 +1,65 @@ | |||
1557 | 1 | /* | ||
1558 | 2 | * Copyright 2016 Canonical Ltd. | ||
1559 | 3 | * | ||
1560 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
1561 | 5 | * the terms of the GNU General Public License, version 3, as published by the | ||
1562 | 6 | * Free Software Foundation. | ||
1563 | 7 | * | ||
1564 | 8 | * This program is distributed in the hope that it will be useful, | ||
1565 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1566 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1567 | 11 | * GNU General Public License for more details. | ||
1568 | 12 | * | ||
1569 | 13 | * You should have received a copy of the GNU General Public License | ||
1570 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1571 | 15 | */ | ||
1572 | 16 | #include "libertine-scope/blacklist.h" | ||
1573 | 17 | #include <gtest/gtest.h> | ||
1574 | 18 | #include <QDir> | ||
1575 | 19 | #include <QTemporaryDir> | ||
1576 | 20 | |||
1577 | 21 | |||
1578 | 22 | namespace | ||
1579 | 23 | { | ||
1580 | 24 | class TestBlacklistFixture : public ::testing::Test | ||
1581 | 25 | { | ||
1582 | 26 | public: | ||
1583 | 27 | TestBlacklistFixture() | ||
1584 | 28 | : blacklist(QString("%1/data").arg(QDir::currentPath()).toStdString()) | ||
1585 | 29 | { | ||
1586 | 30 | } | ||
1587 | 31 | |||
1588 | 32 | protected: | ||
1589 | 33 | Blacklist blacklist; | ||
1590 | 34 | }; | ||
1591 | 35 | |||
1592 | 36 | TEST_F(TestBlacklistFixture, ReturnsFalseWhenFileDoesNotExist) | ||
1593 | 37 | { | ||
1594 | 38 | EXPECT_FALSE(Blacklist(QTemporaryDir().path().toStdString()).app_is_blacklisted("app1", "container1")); | ||
1595 | 39 | } | ||
1596 | 40 | |||
1597 | 41 | TEST_F(TestBlacklistFixture, ReturnsFalseWhenAppIsNotInTheList) | ||
1598 | 42 | { | ||
1599 | 43 | EXPECT_FALSE(blacklist.app_is_blacklisted("app5", "container1")); | ||
1600 | 44 | } | ||
1601 | 45 | |||
1602 | 46 | TEST_F(TestBlacklistFixture, ReturnsTrueWhenAppIsBlacklistedLocally) | ||
1603 | 47 | { | ||
1604 | 48 | EXPECT_TRUE(blacklist.app_is_blacklisted("app1", "container1")); | ||
1605 | 49 | } | ||
1606 | 50 | |||
1607 | 51 | TEST_F(TestBlacklistFixture, ReturnsTrueWhenAppIsBlacklistedGlobally) | ||
1608 | 52 | { | ||
1609 | 53 | EXPECT_TRUE(blacklist.app_is_blacklisted("app2", "container2")); | ||
1610 | 54 | } | ||
1611 | 55 | |||
1612 | 56 | TEST_F(TestBlacklistFixture, ReturnsFalseWhenAppIsWhitelistedLocally) | ||
1613 | 57 | { | ||
1614 | 58 | EXPECT_FALSE(blacklist.app_is_blacklisted("app3", "container1")); | ||
1615 | 59 | } | ||
1616 | 60 | |||
1617 | 61 | TEST_F(TestBlacklistFixture, ReturnsFalseWhenAppIsWhitelistedGlobally) | ||
1618 | 62 | { | ||
1619 | 63 | EXPECT_FALSE(blacklist.app_is_blacklisted("app4", "container2")); | ||
1620 | 64 | } | ||
1621 | 65 | } | ||
1622 | 0 | 66 | ||
1623 | === added file 'tests/test_hidden_apps.cpp' | |||
1624 | --- tests/test_hidden_apps.cpp 1970-01-01 00:00:00 +0000 | |||
1625 | +++ tests/test_hidden_apps.cpp 2016-06-16 14:35:35 +0000 | |||
1626 | @@ -0,0 +1,107 @@ | |||
1627 | 1 | /* | ||
1628 | 2 | * Copyright 2016 Canonical Ltd. | ||
1629 | 3 | * | ||
1630 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
1631 | 5 | * the terms of the GNU General Public License, version 3, as published by the | ||
1632 | 6 | * Free Software Foundation. | ||
1633 | 7 | * | ||
1634 | 8 | * This program is distributed in the hope that it will be useful, | ||
1635 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1636 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1637 | 11 | * GNU General Public License for more details. | ||
1638 | 12 | * | ||
1639 | 13 | * You should have received a copy of the GNU General Public License | ||
1640 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1641 | 15 | */ | ||
1642 | 16 | #include "libertine-scope/hidden_apps.h" | ||
1643 | 17 | #include <gtest/gtest.h> | ||
1644 | 18 | #include <QDir> | ||
1645 | 19 | #include <QTemporaryDir> | ||
1646 | 20 | |||
1647 | 21 | namespace | ||
1648 | 22 | { | ||
1649 | 23 | class TestHiddenAppsFixture : public ::testing::Test | ||
1650 | 24 | { | ||
1651 | 25 | public: | ||
1652 | 26 | TestHiddenAppsFixture() | ||
1653 | 27 | : hidden(QString("%1/data").arg(QDir::currentPath()).toStdString()) | ||
1654 | 28 | { | ||
1655 | 29 | } | ||
1656 | 30 | |||
1657 | 31 | virtual void SetUp() | ||
1658 | 32 | { | ||
1659 | 33 | QFile file(QString("%1/data/hidden").arg(QDir::currentPath())); | ||
1660 | 34 | if (file.open(QIODevice::ReadOnly | QIODevice::Text)) | ||
1661 | 35 | { | ||
1662 | 36 | original_file_contents = file.readAll(); | ||
1663 | 37 | } | ||
1664 | 38 | } | ||
1665 | 39 | |||
1666 | 40 | virtual void TearDown() | ||
1667 | 41 | { | ||
1668 | 42 | QFile file(QString("%1/data/hidden").arg(QDir::currentPath())); | ||
1669 | 43 | if (file.open(QIODevice::WriteOnly | QIODevice::Text)) | ||
1670 | 44 | { | ||
1671 | 45 | file.write(original_file_contents); | ||
1672 | 46 | } | ||
1673 | 47 | } | ||
1674 | 48 | |||
1675 | 49 | protected: | ||
1676 | 50 | HiddenApps hidden; | ||
1677 | 51 | QByteArray original_file_contents; | ||
1678 | 52 | }; | ||
1679 | 53 | |||
1680 | 54 | |||
1681 | 55 | TEST_F(TestHiddenAppsFixture, HiddenReturnsFalseWhenFileDoesNotExist) | ||
1682 | 56 | { | ||
1683 | 57 | EXPECT_FALSE(HiddenApps(QTemporaryDir().path().toStdString()).app_is_hidden("container1/app1")); | ||
1684 | 58 | } | ||
1685 | 59 | |||
1686 | 60 | TEST_F(TestHiddenAppsFixture, HiddenReturnsFalseWhenAppNotListed) | ||
1687 | 61 | { | ||
1688 | 62 | EXPECT_FALSE(hidden.app_is_hidden("container2/app1")); | ||
1689 | 63 | } | ||
1690 | 64 | |||
1691 | 65 | TEST_F(TestHiddenAppsFixture, HiddenReturnsFalseWhenAppIsListed) | ||
1692 | 66 | { | ||
1693 | 67 | EXPECT_TRUE(hidden.app_is_hidden("container1/app1")); | ||
1694 | 68 | } | ||
1695 | 69 | |||
1696 | 70 | TEST_F(TestHiddenAppsFixture, AddAppendsAppToFile) | ||
1697 | 71 | { | ||
1698 | 72 | ASSERT_FALSE(hidden.app_is_hidden("container1/app6")); | ||
1699 | 73 | hidden.add("container1/app6"); | ||
1700 | 74 | ASSERT_TRUE(hidden.app_is_hidden("container1/app6")); | ||
1701 | 75 | |||
1702 | 76 | QFile file(QString("%1/data/hidden").arg(QDir::currentPath())); | ||
1703 | 77 | ASSERT_TRUE(file.open(QIODevice::ReadOnly | QIODevice::Text)); | ||
1704 | 78 | auto contents = QString(file.readAll()).split('\n', QString::SkipEmptyParts); | ||
1705 | 79 | EXPECT_EQ("container1/app6", contents.last()); | ||
1706 | 80 | } | ||
1707 | 81 | |||
1708 | 82 | TEST_F(TestHiddenAppsFixture, AddDoesNotAppendWhenAppAlreadyInFile) | ||
1709 | 83 | { | ||
1710 | 84 | ASSERT_TRUE(hidden.app_is_hidden("container1/app1")); | ||
1711 | 85 | hidden.add("container1/app1"); | ||
1712 | 86 | |||
1713 | 87 | QFile file(QString("%1/data/hidden").arg(QDir::currentPath())); | ||
1714 | 88 | ASSERT_TRUE(file.open(QIODevice::ReadOnly | QIODevice::Text)); | ||
1715 | 89 | auto contents = QString(file.readAll()).split('\n', QString::SkipEmptyParts); | ||
1716 | 90 | EXPECT_EQ(1, contents.count("container1/app1")); | ||
1717 | 91 | } | ||
1718 | 92 | |||
1719 | 93 | TEST_F(TestHiddenAppsFixture, RemoveDeletesLineFromFile) | ||
1720 | 94 | { | ||
1721 | 95 | ASSERT_FALSE(hidden.app_is_hidden("container1/app6")); | ||
1722 | 96 | hidden.add("container1/app6"); | ||
1723 | 97 | ASSERT_TRUE(hidden.app_is_hidden("container1/app6")); | ||
1724 | 98 | |||
1725 | 99 | hidden.remove("container1/app6"); | ||
1726 | 100 | ASSERT_FALSE(hidden.app_is_hidden("container1/app6")); | ||
1727 | 101 | |||
1728 | 102 | QFile file(QString("%1/data/hidden").arg(QDir::currentPath())); | ||
1729 | 103 | ASSERT_TRUE(file.open(QIODevice::ReadOnly | QIODevice::Text)); | ||
1730 | 104 | auto contents = QString(file.readAll()).split('\n', QString::SkipEmptyParts); | ||
1731 | 105 | EXPECT_NE("container1/app6", contents.last()); | ||
1732 | 106 | } | ||
1733 | 107 | } | ||
1734 | 0 | 108 | ||
1735 | === modified file 'tests/test_preview.cpp' | |||
1736 | --- tests/test_preview.cpp 2016-04-27 17:53:30 +0000 | |||
1737 | +++ tests/test_preview.cpp 2016-06-16 14:35:35 +0000 | |||
1738 | @@ -28,6 +28,7 @@ | |||
1739 | 28 | TEST(TestPreview, pushesWidgetsWithAppInformation) | 28 | TEST(TestPreview, pushesWidgetsWithAppInformation) |
1740 | 29 | { | 29 | { |
1741 | 30 | unity::scopes::testing::Result result; | 30 | unity::scopes::testing::Result result; |
1742 | 31 | result["department_id"] = ""; | ||
1743 | 31 | unity::scopes::ActionMetadata metadata("en_US", "phone"); | 32 | unity::scopes::ActionMetadata metadata("en_US", "phone"); |
1744 | 32 | 33 | ||
1745 | 33 | std::unique_ptr<unity::scopes::PreviewWidgetList> list(new unity::scopes::PreviewWidgetList()); | 34 | std::unique_ptr<unity::scopes::PreviewWidgetList> list(new unity::scopes::PreviewWidgetList()); |
1746 | @@ -57,7 +58,7 @@ | |||
1747 | 57 | EXPECT_EQ("actions", buttons.widget_type()); | 58 | EXPECT_EQ("actions", buttons.widget_type()); |
1748 | 58 | 59 | ||
1749 | 59 | auto buttons_actions = buttons.attribute_values()["actions"].get_array(); | 60 | auto buttons_actions = buttons.attribute_values()["actions"].get_array(); |
1751 | 60 | ASSERT_EQ(1, buttons_actions.size()); | 61 | ASSERT_EQ(2, buttons_actions.size()); |
1752 | 61 | EXPECT_EQ("open", buttons_actions[0].get_dict()["id"].get_string()); | 62 | EXPECT_EQ("open", buttons_actions[0].get_dict()["id"].get_string()); |
1753 | 62 | EXPECT_EQ("Open", buttons_actions[0].get_dict()["label"].get_string()); | 63 | EXPECT_EQ("Open", buttons_actions[0].get_dict()["label"].get_string()); |
1754 | 63 | } | 64 | } |
1755 | 64 | 65 | ||
1756 | === modified file 'tests/test_query.cpp' | |||
1757 | --- tests/test_query.cpp 2016-04-27 18:37:46 +0000 | |||
1758 | +++ tests/test_query.cpp 2016-06-16 14:35:35 +0000 | |||
1759 | @@ -15,6 +15,7 @@ | |||
1760 | 15 | */ | 15 | */ |
1761 | 16 | 16 | ||
1762 | 17 | #include "libertine-scope/query.h" | 17 | #include "libertine-scope/query.h" |
1763 | 18 | #include "libertine-scope/config.h" | ||
1764 | 18 | #include "tests/fake_libertine.h" | 19 | #include "tests/fake_libertine.h" |
1765 | 19 | #include <unity/scopes/SearchMetadata.h> | 20 | #include <unity/scopes/SearchMetadata.h> |
1766 | 20 | #include <unity/scopes/CannedQuery.h> | 21 | #include <unity/scopes/CannedQuery.h> |
1767 | @@ -34,19 +35,19 @@ | |||
1768 | 34 | "app_launchers": [{ | 35 | "app_launchers": [{ |
1769 | 35 | "name": "LibreOffice", | 36 | "name": "LibreOffice", |
1770 | 36 | "no_display": false, | 37 | "no_display": false, |
1772 | 37 | "uri": "appid://fake/libreoffice/0.0", | 38 | "uri": "appid://fake-container/libreoffice/0.0", |
1773 | 38 | "icons": ["file:///lo.png"], | 39 | "icons": ["file:///lo.png"], |
1774 | 39 | "description": "libreoffice!" | 40 | "description": "libreoffice!" |
1775 | 40 | }, { | 41 | }, { |
1776 | 41 | "name": "Linux", | 42 | "name": "Linux", |
1777 | 42 | "no_display": true, | 43 | "no_display": true, |
1779 | 43 | "uri": "appid://fake/linux/0.0", | 44 | "uri": "appid://fake-container/linux/0.0", |
1780 | 44 | "icons": ["file:///nix.png"], | 45 | "icons": ["file:///nix.png"], |
1781 | 45 | "description": "linux!" | 46 | "description": "linux!" |
1782 | 46 | }, { | 47 | }, { |
1783 | 47 | "name": "Library", | 48 | "name": "Library", |
1784 | 48 | "no_display": false, | 49 | "no_display": false, |
1786 | 49 | "uri": "appid://fake/library/0.0", | 50 | "uri": "appid://fake-container/library/0.0", |
1787 | 50 | "icons": ["file:///lib.png"], | 51 | "icons": ["file:///lib.png"], |
1788 | 51 | "description": "library!" | 52 | "description": "library!" |
1789 | 52 | }] | 53 | }] |
1790 | @@ -66,6 +67,30 @@ | |||
1791 | 66 | }; | 67 | }; |
1792 | 67 | 68 | ||
1793 | 68 | 69 | ||
1794 | 70 | class MockHiddenApps : public HiddenApps | ||
1795 | 71 | { | ||
1796 | 72 | public: | ||
1797 | 73 | MockHiddenApps() | ||
1798 | 74 | : HiddenApps("") | ||
1799 | 75 | { | ||
1800 | 76 | } | ||
1801 | 77 | |||
1802 | 78 | MOCK_CONST_METHOD1(app_is_hidden, bool(QString const&)); | ||
1803 | 79 | MOCK_CONST_METHOD0(empty, bool()); | ||
1804 | 80 | }; | ||
1805 | 81 | |||
1806 | 82 | class MockBlacklist : public Blacklist | ||
1807 | 83 | { | ||
1808 | 84 | public: | ||
1809 | 85 | MockBlacklist() | ||
1810 | 86 | : Blacklist("") | ||
1811 | 87 | { | ||
1812 | 88 | } | ||
1813 | 89 | |||
1814 | 90 | MOCK_CONST_METHOD2(app_is_blacklisted, bool(QString const&, std::string const&)); | ||
1815 | 91 | }; | ||
1816 | 92 | |||
1817 | 93 | |||
1818 | 69 | MATCHER_P4(ResultPropertiesMatch, title, art, description, uri, "") | 94 | MATCHER_P4(ResultPropertiesMatch, title, art, description, uri, "") |
1819 | 70 | { | 95 | { |
1820 | 71 | return arg.contains("title") && arg.contains("art") && arg.contains("description") && arg.contains("uri") && | 96 | return arg.contains("title") && arg.contains("art") && arg.contains("description") && arg.contains("uri") && |
1821 | @@ -76,6 +101,12 @@ | |||
1822 | 76 | } | 101 | } |
1823 | 77 | 102 | ||
1824 | 78 | 103 | ||
1825 | 104 | MATCHER_P(ResultTitleMatch, title, "") | ||
1826 | 105 | { | ||
1827 | 106 | return arg.contains("title") && arg["title"] == unity::scopes::Variant(title); | ||
1828 | 107 | } | ||
1829 | 108 | |||
1830 | 109 | |||
1831 | 79 | class TestQueryFixture : public ::testing::Test | 110 | class TestQueryFixture : public ::testing::Test |
1832 | 80 | { | 111 | { |
1833 | 81 | public: | 112 | public: |
1834 | @@ -84,13 +115,25 @@ | |||
1835 | 84 | , canned_query("libertine-scope") | 115 | , canned_query("libertine-scope") |
1836 | 85 | , reply() | 116 | , reply() |
1837 | 86 | , proxy(&reply, [](unity::scopes::SearchReply*) {}) | 117 | , proxy(&reply, [](unity::scopes::SearchReply*) {}) |
1840 | 87 | , category(std::make_shared<FakeCategory>("fakeId", "fake-container", "Application", unity::scopes::CategoryRenderer())) | 118 | , category(std::make_shared<FakeCategory>("fake-container", "fake-container", "Application", unity::scopes::CategoryRenderer())) |
1841 | 88 | { | 119 | , hidden(new testing::NiceMock<MockHiddenApps>()) |
1842 | 120 | , blacklist(new testing::NiceMock<MockBlacklist>()) | ||
1843 | 121 | { | ||
1844 | 122 | } | ||
1845 | 123 | |||
1846 | 124 | virtual void SetUp() | ||
1847 | 125 | { | ||
1848 | 126 | EXPECT_CALL(*blacklist, app_is_blacklisted(testing::_, "fake-container")) | ||
1849 | 127 | .WillRepeatedly(testing::Return(false)); | ||
1850 | 128 | EXPECT_CALL(*hidden, empty()) | ||
1851 | 129 | .WillRepeatedly(testing::Return(true)); | ||
1852 | 130 | EXPECT_CALL(*hidden, app_is_hidden(testing::_)) | ||
1853 | 131 | .WillRepeatedly(testing::Return(false)); | ||
1854 | 89 | } | 132 | } |
1855 | 90 | 133 | ||
1856 | 91 | void expect_registry() | 134 | void expect_registry() |
1857 | 92 | { | 135 | { |
1859 | 93 | EXPECT_CALL(reply, register_category("fakeId", "fake-container", "Application", testing::_)).WillOnce(testing::Return(category)); | 136 | EXPECT_CALL(reply, register_category("fake-container", "fake-container", "Application", testing::_)).WillOnce(testing::Return(category)); |
1860 | 94 | } | 137 | } |
1861 | 95 | 138 | ||
1862 | 96 | void expect_push(std::string title, std::string art, std::string description, std::string appId, bool success = true) | 139 | void expect_push(std::string title, std::string art, std::string description, std::string appId, bool success = true) |
1863 | @@ -100,17 +143,17 @@ | |||
1864 | 100 | 143 | ||
1865 | 101 | void expect_push_libreoffice(bool success = true) | 144 | void expect_push_libreoffice(bool success = true) |
1866 | 102 | { | 145 | { |
1868 | 103 | expect_push("LibreOffice", "file:///lo.png", "libreoffice!", "appid://fake/libreoffice/0.0", success); | 146 | expect_push("LibreOffice", "file:///lo.png", "libreoffice!", "appid://fake-container/libreoffice/0.0", success); |
1869 | 104 | } | 147 | } |
1870 | 105 | 148 | ||
1871 | 106 | void expect_push_library(bool success = true) | 149 | void expect_push_library(bool success = true) |
1872 | 107 | { | 150 | { |
1874 | 108 | expect_push("Library", "file:///lib.png", "library!", "appid://fake/library/0.0", success); | 151 | expect_push("Library", "file:///lib.png", "library!", "appid://fake-container/library/0.0", success); |
1875 | 109 | } | 152 | } |
1876 | 110 | 153 | ||
1877 | 111 | void expect_push_linux(bool success = true) | 154 | void expect_push_linux(bool success = true) |
1878 | 112 | { | 155 | { |
1880 | 113 | expect_push("Linux", "file:///nix.png", "linux!", "appid://fake/linux/0.0", success); | 156 | expect_push("Linux", "file:///nix.png", "linux!", "appid://fake-container/linux/0.0", success); |
1881 | 114 | } | 157 | } |
1882 | 115 | 158 | ||
1883 | 116 | unity::scopes::SearchMetadata metadata; | 159 | unity::scopes::SearchMetadata metadata; |
1884 | @@ -118,10 +161,12 @@ | |||
1885 | 118 | testing::NiceMock<unity::scopes::testing::MockSearchReply> reply; | 161 | testing::NiceMock<unity::scopes::testing::MockSearchReply> reply; |
1886 | 119 | unity::scopes::SearchReplyProxy proxy; | 162 | unity::scopes::SearchReplyProxy proxy; |
1887 | 120 | std::shared_ptr<FakeCategory> category; | 163 | std::shared_ptr<FakeCategory> category; |
1888 | 164 | std::shared_ptr<MockHiddenApps> hidden; | ||
1889 | 165 | std::shared_ptr<MockBlacklist> blacklist; | ||
1890 | 121 | }; | 166 | }; |
1891 | 122 | 167 | ||
1892 | 123 | 168 | ||
1894 | 124 | TEST_F(TestQueryFixture, returnsAllDisplayableAppsWithoutFilters) | 169 | TEST_F(TestQueryFixture, pushesAllDisplayableAppsWithoutFilters) |
1895 | 125 | { | 170 | { |
1896 | 126 | expect_registry(); | 171 | expect_registry(); |
1897 | 127 | expect_push_libreoffice(); | 172 | expect_push_libreoffice(); |
1898 | @@ -130,12 +175,12 @@ | |||
1899 | 130 | 175 | ||
1900 | 131 | Query query(canned_query, metadata, []() { | 176 | Query query(canned_query, metadata, []() { |
1901 | 132 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); | 177 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); |
1903 | 133 | }); | 178 | }, hidden, blacklist); |
1904 | 134 | query.run(proxy); | 179 | query.run(proxy); |
1905 | 135 | } | 180 | } |
1906 | 136 | 181 | ||
1907 | 137 | 182 | ||
1909 | 138 | TEST_F(TestQueryFixture, returnsRegularExpressionFilteredListOfApps) | 183 | TEST_F(TestQueryFixture, pushesRegularExpressionFilteredListOfApps) |
1910 | 139 | { | 184 | { |
1911 | 140 | expect_registry(); | 185 | expect_registry(); |
1912 | 141 | expect_push_libreoffice(); | 186 | expect_push_libreoffice(); |
1913 | @@ -143,7 +188,7 @@ | |||
1914 | 143 | 188 | ||
1915 | 144 | Query query(canned_query, metadata, []() { | 189 | Query query(canned_query, metadata, []() { |
1916 | 145 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); | 190 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); |
1918 | 146 | }); | 191 | }, hidden, blacklist); |
1919 | 147 | query.run(proxy); | 192 | query.run(proxy); |
1920 | 148 | } | 193 | } |
1921 | 149 | 194 | ||
1922 | @@ -155,56 +200,90 @@ | |||
1923 | 155 | 200 | ||
1924 | 156 | Query query(canned_query, metadata, []() { | 201 | Query query(canned_query, metadata, []() { |
1925 | 157 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); | 202 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); |
1978 | 158 | }); | 203 | }, hidden, blacklist); |
1979 | 159 | query.run(proxy); | 204 | query.run(proxy); |
1980 | 160 | } | 205 | } |
1981 | 161 | 206 | ||
1982 | 162 | 207 | ||
1983 | 163 | // Query class with faked out Settings | 208 | TEST_F(TestQueryFixture, ignoresBlacklistedApps) |
1984 | 164 | class QueryWithFakeSettings : public Query | 209 | { |
1985 | 165 | { | 210 | expect_registry(); |
1986 | 166 | public: | 211 | expect_push_linux(); |
1987 | 167 | QueryWithFakeSettings(unity::scopes::CannedQuery const& query, | 212 | expect_push_library(); |
1988 | 168 | unity::scopes::SearchMetadata const& metadata, | 213 | |
1989 | 169 | Libertine::Factory const& libertine_factory) | 214 | EXPECT_CALL(*blacklist, app_is_blacklisted(QString("libreoffice"), "fake-container")) |
1990 | 170 | : Query(query, metadata, libertine_factory) | 215 | .WillRepeatedly(testing::Return(true)); |
1991 | 171 | , settings_() | 216 | |
1992 | 172 | { | 217 | Query query(canned_query, metadata, []() { |
1993 | 173 | } | 218 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); |
1994 | 174 | 219 | }, hidden, blacklist); | |
1995 | 175 | unity::scopes::VariantMap settings() const override | 220 | query.run(proxy); |
1996 | 176 | { | 221 | } |
1997 | 177 | return settings_; | 222 | |
1998 | 178 | } | 223 | |
1999 | 179 | 224 | TEST_F(TestQueryFixture, ignoresHiddenAppsInRootDepartment) | |
2000 | 180 | unity::scopes::VariantMap settings_; | 225 | { |
2001 | 181 | }; | 226 | expect_registry(); |
2002 | 182 | 227 | expect_push_linux(); | |
2003 | 183 | 228 | expect_push_libreoffice(); | |
2004 | 184 | TEST_F(TestQueryFixture, ignoresAnyBlacklistedApps) | 229 | |
2005 | 185 | { | 230 | EXPECT_CALL(*hidden, app_is_hidden(QString("fake-container/library"))) |
2006 | 186 | expect_registry(); | 231 | .WillRepeatedly(testing::Return(true)); |
2007 | 187 | expect_push_library(); | 232 | EXPECT_CALL(*hidden, empty()) |
2008 | 188 | 233 | .WillOnce(testing::Return(false)); | |
2009 | 189 | QueryWithFakeSettings query(canned_query, metadata, []() { | 234 | |
2010 | 190 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); | 235 | Query query(canned_query, metadata, []() { |
2011 | 191 | }); | 236 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); |
2012 | 192 | query.settings_["blacklist"] = "LibreOffice;Linux"; | 237 | }, hidden, blacklist); |
2013 | 193 | query.run(proxy); | 238 | query.run(proxy); |
2014 | 194 | } | 239 | } |
2015 | 195 | 240 | ||
2016 | 196 | 241 | ||
2017 | 197 | TEST_F(TestQueryFixture, stripsQuotationMarksFromBlacklist) | 242 | TEST_F(TestQueryFixture, ignoresNonHiddenAppsInHiddenDepartment) |
2018 | 198 | { | 243 | { |
2019 | 199 | expect_registry(); | 244 | expect_registry(); |
2020 | 200 | expect_push_linux(); | 245 | expect_push_library(); |
2021 | 201 | expect_push_library(); | 246 | |
2022 | 202 | 247 | EXPECT_CALL(*hidden, app_is_hidden(QString("fake-container/library"))) | |
2023 | 203 | QueryWithFakeSettings query(canned_query, metadata, []() { | 248 | .WillRepeatedly(testing::Return(true)); |
2024 | 204 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); | 249 | EXPECT_CALL(*hidden, empty()) |
2025 | 205 | }); | 250 | .WillOnce(testing::Return(false)); |
2026 | 206 | query.settings_["blacklist"] = "\"LibreOffice\""; | 251 | |
2027 | 207 | query.run(proxy); | 252 | canned_query.set_department_id(HIDDEN_DEPT_ID); |
2028 | 208 | } | 253 | |
2029 | 209 | 254 | Query query(canned_query, metadata, []() { | |
2030 | 255 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); | ||
2031 | 256 | }, hidden, blacklist); | ||
2032 | 257 | query.run(proxy); | ||
2033 | 258 | } | ||
2034 | 259 | |||
2035 | 260 | |||
2036 | 261 | TEST_F(TestQueryFixture, showsHintWhenAllAppsFiltered) | ||
2037 | 262 | { | ||
2038 | 263 | expect_registry(); | ||
2039 | 264 | |||
2040 | 265 | EXPECT_CALL(reply, register_category("hint", "", "", testing::_)).WillOnce(testing::Return(category)); | ||
2041 | 266 | EXPECT_CALL(reply, push(testing::Matcher<unity::scopes::CategorisedResult const&>(ResultTitleMatch(Query::ALL_RESULTS_FILTERED_HINT)))).WillOnce(testing::Return(true)); | ||
2042 | 267 | |||
2043 | 268 | EXPECT_CALL(*hidden, app_is_hidden(testing::_)).WillRepeatedly(testing::Return(true)); | ||
2044 | 269 | |||
2045 | 270 | Query query(canned_query, metadata, []() { | ||
2046 | 271 | return FakeLibertine::make_fake(LIBERTINE_OUTPUT_WITH_APPS); | ||
2047 | 272 | }, hidden, blacklist); | ||
2048 | 273 | query.run(proxy); | ||
2049 | 274 | } | ||
2050 | 275 | |||
2051 | 276 | |||
2052 | 277 | TEST_F(TestQueryFixture, showsHintWhenNoAppsInContainer) | ||
2053 | 278 | { | ||
2054 | 279 | expect_registry(); | ||
2055 | 280 | |||
2056 | 281 | EXPECT_CALL(reply, register_category("hint", "", "", testing::_)).WillOnce(testing::Return(category)); | ||
2057 | 282 | EXPECT_CALL(reply, push(testing::Matcher<unity::scopes::CategorisedResult const&>(ResultTitleMatch(Query::NO_RESULTS_HINT)))).WillOnce(testing::Return(true)); | ||
2058 | 283 | |||
2059 | 284 | Query query(canned_query, metadata, []() { | ||
2060 | 285 | return FakeLibertine::make_fake(""); | ||
2061 | 286 | }, hidden, blacklist); | ||
2062 | 287 | query.run(proxy); | ||
2063 | 288 | } | ||
2064 | 210 | } // anonymous namespace | 289 | } // anonymous namespace |
lgtm