Merge lp:~abreu-alexandre/unity-js-scopes/add-filter-state-handling into lp:unity-js-scopes
- add-filter-state-handling
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Marcus Tomlinson | ||||
Approved revision: | 88 | ||||
Merged at revision: | 87 | ||||
Proposed branch: | lp:~abreu-alexandre/unity-js-scopes/add-filter-state-handling | ||||
Merge into: | lp:unity-js-scopes | ||||
Diff against target: |
601 lines (+391/-26) 11 files modified
examples/simple/simple.js (+11/-1) src/bindings/src/addon.cc (+45/-11) src/bindings/src/canned-query.cc (+90/-0) src/bindings/src/canned-query.h (+49/-0) src/bindings/src/option-selector-filter.cc (+86/-0) src/bindings/src/option-selector-filter.h (+54/-0) src/bindings/src/scope-base.cc (+3/-2) src/bindings/src/search-query.cc (+2/-2) src/bindings/src/search-query.h (+3/-1) src/bindings/src/search-reply.cc (+46/-7) src/bindings/src/search-reply.h (+2/-2) |
||||
To merge this branch: | bzr merge lp:~abreu-alexandre/unity-js-scopes/add-filter-state-handling | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Marcus Tomlinson (community) | Approve | ||
Review via email: mp+274605@code.launchpad.net |
Commit message
Add FilterState handling
Description of the change
Add FilterState handling
PS Jenkins bot (ps-jenkins) wrote : | # |
- 87. By Alexandre Abreu
-
merge trunk
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:87
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Marcus Tomlinson (marcustomlinson) wrote : | # |
Left some inline comments.
- 88. By Alexandre Abreu
-
updated
Alexandre Abreu (abreu-alexandre) wrote : | # |
updated
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:88
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'examples/simple/simple.js' | |||
2 | --- examples/simple/simple.js 2015-10-13 17:53:25 +0000 | |||
3 | +++ examples/simple/simple.js 2015-10-22 13:54:24 +0000 | |||
4 | @@ -50,7 +50,17 @@ | |||
5 | 50 | new scopes.lib.categorised_result(category); | 50 | new scopes.lib.categorised_result(category); |
6 | 51 | categorised_result.set_uri("http://www.ubuntu.com"); | 51 | categorised_result.set_uri("http://www.ubuntu.com"); |
7 | 52 | categorised_result.set_title("'" + qs + "'"); | 52 | categorised_result.set_title("'" + qs + "'"); |
9 | 53 | 53 | ||
10 | 54 | var filter_state = | ||
11 | 55 | new scopes.lib.filter_state(); | ||
12 | 56 | var option_filter = | ||
13 | 57 | new scopes.lib.option_selector_filter('me', 'push', false); | ||
14 | 58 | var option = option_filter.add_option("id", "yes"); | ||
15 | 59 | |||
16 | 60 | var p = search_reply.push([option_filter], filter_state); | ||
17 | 61 | |||
18 | 62 | console.log(' push : ' + p); | ||
19 | 63 | |||
20 | 54 | search_reply.push(categorised_result); | 64 | search_reply.push(categorised_result); |
21 | 55 | }, | 65 | }, |
22 | 56 | // cancelled | 66 | // cancelled |
23 | 57 | 67 | ||
24 | === modified file 'src/bindings/src/addon.cc' | |||
25 | --- src/bindings/src/addon.cc 2015-10-19 14:03:37 +0000 | |||
26 | +++ src/bindings/src/addon.cc 2015-10-22 13:54:24 +0000 | |||
27 | @@ -21,7 +21,6 @@ | |||
28 | 21 | #include <stdexcept> | 21 | #include <stdexcept> |
29 | 22 | 22 | ||
30 | 23 | #include <unity/scopes/ActionMetadata.h> | 23 | #include <unity/scopes/ActionMetadata.h> |
31 | 24 | #include <unity/scopes/CannedQuery.h> | ||
32 | 25 | #include <unity/scopes/Category.h> | 24 | #include <unity/scopes/Category.h> |
33 | 26 | #include <unity/scopes/CategoryRenderer.h> | 25 | #include <unity/scopes/CategoryRenderer.h> |
34 | 27 | #include <unity/scopes/Result.h> | 26 | #include <unity/scopes/Result.h> |
35 | @@ -34,9 +33,11 @@ | |||
36 | 34 | 33 | ||
37 | 35 | #include "action-metadata.h" | 34 | #include "action-metadata.h" |
38 | 36 | #include "activation-query.h" | 35 | #include "activation-query.h" |
39 | 36 | #include "canned-query.h" | ||
40 | 37 | #include "categorised-result.h" | 37 | #include "categorised-result.h" |
41 | 38 | #include "department.h" | 38 | #include "department.h" |
42 | 39 | #include "online-account-client.h" | 39 | #include "online-account-client.h" |
43 | 40 | #include "option-selector-filter.h" | ||
44 | 40 | #include "preview-query.h" | 41 | #include "preview-query.h" |
45 | 41 | #include "preview-reply.h" | 42 | #include "preview-reply.h" |
46 | 42 | #include "preview-widget.h" | 43 | #include "preview-widget.h" |
47 | @@ -183,16 +184,17 @@ | |||
48 | 183 | .add_method("set_category", &CategorisedResult::set_category) | 184 | .add_method("set_category", &CategorisedResult::set_category) |
49 | 184 | .add_method("category", &CategorisedResult::category); | 185 | .add_method("category", &CategorisedResult::category); |
50 | 185 | 186 | ||
52 | 186 | v8cpp::Class<unity::scopes::CannedQuery> canned_query(isolate); | 187 | v8cpp::Class<CannedQuery> canned_query(isolate); |
53 | 187 | canned_query | 188 | canned_query |
62 | 188 | .add_method("set_department_id", &unity::scopes::CannedQuery::set_department_id) | 189 | .set_constructor<v8::FunctionCallbackInfo<v8::Value>>() |
63 | 189 | .add_method("set_query_string", &unity::scopes::CannedQuery::set_query_string) | 190 | .add_method("set_department_id", &CannedQuery::set_department_id) |
64 | 190 | .add_method("set_filter_state", &unity::scopes::CannedQuery::set_filter_state) | 191 | .add_method("set_query_string", &CannedQuery::set_query_string) |
65 | 191 | .add_method("scope_id", &unity::scopes::CannedQuery::scope_id) | 192 | .add_method("set_filter_state", &CannedQuery::set_filter_state) |
66 | 192 | .add_method("department_id", &unity::scopes::CannedQuery::department_id) | 193 | .add_method("scope_id", &CannedQuery::scope_id) |
67 | 193 | .add_method("filter_state", &unity::scopes::CannedQuery::filter_state) | 194 | .add_method("department_id", &CannedQuery::department_id) |
68 | 194 | .add_method("query_string", &unity::scopes::CannedQuery::query_string) | 195 | .add_method("query_string", &CannedQuery::query_string) |
69 | 195 | .add_method("to_uri", &unity::scopes::CannedQuery::to_uri); | 196 | .add_method("to_uri", &CannedQuery::to_uri) |
70 | 197 | .add_method("filter_state", &CannedQuery::filter_state); | ||
71 | 196 | 198 | ||
72 | 197 | // TODO Should it be more of a value type? (it seems to be used that way | 199 | // TODO Should it be more of a value type? (it seems to be used that way |
73 | 198 | // in unity API) | 200 | // in unity API) |
74 | @@ -246,6 +248,33 @@ | |||
75 | 246 | .add_method("region_name", &unity::scopes::Location::region_name) | 248 | .add_method("region_name", &unity::scopes::Location::region_name) |
76 | 247 | .add_method("has_vertical_accuracy", &unity::scopes::Location::has_vertical_accuracy); | 249 | .add_method("has_vertical_accuracy", &unity::scopes::Location::has_vertical_accuracy); |
77 | 248 | 250 | ||
78 | 251 | v8cpp::Class<unity::scopes::FilterState> filter_state(isolate); | ||
79 | 252 | filter_state | ||
80 | 253 | .set_constructor<>() | ||
81 | 254 | .add_method("has_filter", &unity::scopes::FilterState::has_filter) | ||
82 | 255 | .add_method("remove", &unity::scopes::FilterState::remove); | ||
83 | 256 | |||
84 | 257 | v8cpp::Class<unity::scopes::FilterOption> filter_option(isolate); | ||
85 | 258 | filter_option | ||
86 | 259 | .add_method("id", &unity::scopes::FilterOption::id) | ||
87 | 260 | .add_method("label", &unity::scopes::FilterOption::label); | ||
88 | 261 | |||
89 | 262 | v8cpp::Class<OptionSelectorFilter> option_selector_filter(isolate); | ||
90 | 263 | option_selector_filter | ||
91 | 264 | .set_constructor<std::string, std::string, bool>() | ||
92 | 265 | .add_method("label", &OptionSelectorFilter::label) | ||
93 | 266 | .add_method("multi_select", &OptionSelectorFilter::multi_select) | ||
94 | 267 | .add_method("add_option", &OptionSelectorFilter::add_option) | ||
95 | 268 | .add_method("options", &OptionSelectorFilter::options) | ||
96 | 269 | .add_method("has_active_option", &OptionSelectorFilter::has_active_option) | ||
97 | 270 | .add_method("active_options", &OptionSelectorFilter::active_options) | ||
98 | 271 | .add_method("update_state", &OptionSelectorFilter::update_state) | ||
99 | 272 | // FilterBase | ||
100 | 273 | .add_method("set_display_hints", &OptionSelectorFilter::set_display_hints) | ||
101 | 274 | .add_method("display_hints", &OptionSelectorFilter::display_hints) | ||
102 | 275 | .add_method("id", &OptionSelectorFilter::id) | ||
103 | 276 | .add_method("filter_type", &OptionSelectorFilter::filter_type); | ||
104 | 277 | |||
105 | 249 | v8cpp::Class<PreviewWidget> preview_widget(isolate); | 278 | v8cpp::Class<PreviewWidget> preview_widget(isolate); |
106 | 250 | preview_widget | 279 | preview_widget |
107 | 251 | .set_constructor<v8::Local<v8::Value>, v8::Local<v8::Value>>() | 280 | .set_constructor<v8::Local<v8::Value>, v8::Local<v8::Value>>() |
108 | @@ -311,7 +340,7 @@ | |||
109 | 311 | 340 | ||
110 | 312 | v8cpp::Class<SearchQuery> search_query(isolate); | 341 | v8cpp::Class<SearchQuery> search_query(isolate); |
111 | 313 | search_query | 342 | search_query |
113 | 314 | .set_constructor<std::shared_ptr<unity::scopes::CannedQuery>, std::shared_ptr<unity::scopes::SearchMetadata>, v8::Local<v8::Function>, v8::Local<v8::Function>>() | 343 | .set_constructor<std::shared_ptr<CannedQuery>, std::shared_ptr<unity::scopes::SearchMetadata>, v8::Local<v8::Function>, v8::Local<v8::Function>>() |
114 | 315 | .add_method("onrun", &SearchQuery::onrun) | 344 | .add_method("onrun", &SearchQuery::onrun) |
115 | 316 | .add_method("oncancelled", &SearchQuery::oncancelled); | 345 | .add_method("oncancelled", &SearchQuery::oncancelled); |
116 | 317 | 346 | ||
117 | @@ -368,8 +397,11 @@ | |||
118 | 368 | module.add_class("category_renderer", category_renderer); | 397 | module.add_class("category_renderer", category_renderer); |
119 | 369 | module.add_class("column_layout", column_layout); | 398 | module.add_class("column_layout", column_layout); |
120 | 370 | module.add_class("department", department); | 399 | module.add_class("department", department); |
121 | 400 | module.add_class("filter_option", filter_option); | ||
122 | 401 | module.add_class("filter_state", filter_state); | ||
123 | 371 | module.add_class("location", location); | 402 | module.add_class("location", location); |
124 | 372 | module.add_class("online_account_client", online_account_client); | 403 | module.add_class("online_account_client", online_account_client); |
125 | 404 | module.add_class("option_selector_filter", option_selector_filter); | ||
126 | 373 | module.add_class("preview_widget", preview_widget); | 405 | module.add_class("preview_widget", preview_widget); |
127 | 374 | module.add_class("preview_query", preview_query); | 406 | module.add_class("preview_query", preview_query); |
128 | 375 | module.add_class("preview_reply", preview_reply); | 407 | module.add_class("preview_reply", preview_reply); |
129 | @@ -387,6 +419,8 @@ | |||
130 | 387 | // Standalone functions | 419 | // Standalone functions |
131 | 388 | module.add_function("new_category_renderer_from_file", &new_category_renderer_from_file); | 420 | module.add_function("new_category_renderer_from_file", &new_category_renderer_from_file); |
132 | 389 | 421 | ||
133 | 422 | module.add_function("create_option_selector_filter", &unity::scopes::OptionSelectorFilter::create); | ||
134 | 423 | |||
135 | 390 | module.add_function("runtime_version", &get_scopes_runtime_version); | 424 | module.add_function("runtime_version", &get_scopes_runtime_version); |
136 | 391 | 425 | ||
137 | 392 | exports->SetPrototype(module.create_prototype()); | 426 | exports->SetPrototype(module.create_prototype()); |
138 | 393 | 427 | ||
139 | === added file 'src/bindings/src/canned-query.cc' | |||
140 | --- src/bindings/src/canned-query.cc 1970-01-01 00:00:00 +0000 | |||
141 | +++ src/bindings/src/canned-query.cc 2015-10-22 13:54:24 +0000 | |||
142 | @@ -0,0 +1,90 @@ | |||
143 | 1 | /* | ||
144 | 2 | * Copyright 2015 Canonical Ltd. | ||
145 | 3 | * | ||
146 | 4 | * This file is part of unity-js-scopes. | ||
147 | 5 | * | ||
148 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
149 | 7 | * it under the terms of the GNU General Public License as published by | ||
150 | 8 | * the Free Software Foundation; version 3. | ||
151 | 9 | * | ||
152 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
153 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
154 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
155 | 13 | * GNU General Public License for more details. | ||
156 | 14 | * | ||
157 | 15 | * You should have received a copy of the GNU General Public License | ||
158 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
159 | 17 | */ | ||
160 | 18 | |||
161 | 19 | #include "canned-query.h" | ||
162 | 20 | |||
163 | 21 | CannedQuery::CannedQuery(v8::FunctionCallbackInfo<v8::Value> const& args) { | ||
164 | 22 | if (args.Length() != 3) { | ||
165 | 23 | throw std::runtime_error("Invalid number of arguments"); | ||
166 | 24 | } | ||
167 | 25 | |||
168 | 26 | if (!args[0]->IsString()) { | ||
169 | 27 | throw std::runtime_error("Invalid type for argument index 1"); | ||
170 | 28 | } | ||
171 | 29 | |||
172 | 30 | std::string scope_id = | ||
173 | 31 | *(v8::String::Utf8Value(args[0]->ToString())); | ||
174 | 32 | |||
175 | 33 | if (args[1]->IsString() && args[2]->IsString()) { | ||
176 | 34 | |||
177 | 35 | std::string query_str = | ||
178 | 36 | *(v8::String::Utf8Value(args[1]->ToString())); | ||
179 | 37 | |||
180 | 38 | std::string department_id = | ||
181 | 39 | *(v8::String::Utf8Value(args[2]->ToString())); | ||
182 | 40 | |||
183 | 41 | query_.reset( | ||
184 | 42 | new unity::scopes::CannedQuery( | ||
185 | 43 | scope_id, | ||
186 | 44 | query_str, | ||
187 | 45 | department_id)); | ||
188 | 46 | } else { | ||
189 | 47 | query_.reset( | ||
190 | 48 | new unity::scopes::CannedQuery(scope_id)); | ||
191 | 49 | } | ||
192 | 50 | } | ||
193 | 51 | |||
194 | 52 | CannedQuery::CannedQuery(const unity::scopes::CannedQuery& canned_query) { | ||
195 | 53 | query_.reset(new unity::scopes::CannedQuery(canned_query)); | ||
196 | 54 | } | ||
197 | 55 | |||
198 | 56 | void CannedQuery::set_department_id(const std::string& department_id) { | ||
199 | 57 | query_->set_department_id(department_id); | ||
200 | 58 | } | ||
201 | 59 | |||
202 | 60 | void CannedQuery::set_query_string(const std::string& query_string) { | ||
203 | 61 | query_->set_query_string(query_string); | ||
204 | 62 | } | ||
205 | 63 | |||
206 | 64 | void CannedQuery::set_filter_state(std::shared_ptr<unity::scopes::FilterState> filter_state) { | ||
207 | 65 | query_->set_filter_state(*filter_state); | ||
208 | 66 | } | ||
209 | 67 | |||
210 | 68 | std::string CannedQuery::scope_id() const { | ||
211 | 69 | return query_->scope_id(); | ||
212 | 70 | } | ||
213 | 71 | |||
214 | 72 | std::string CannedQuery::department_id() const { | ||
215 | 73 | return query_->department_id(); | ||
216 | 74 | } | ||
217 | 75 | |||
218 | 76 | std::string CannedQuery::query_string() const { | ||
219 | 77 | return query_->query_string(); | ||
220 | 78 | } | ||
221 | 79 | |||
222 | 80 | std::string CannedQuery::to_uri() const { | ||
223 | 81 | return query_->to_uri(); | ||
224 | 82 | } | ||
225 | 83 | |||
226 | 84 | unity::scopes::FilterState CannedQuery::filter_state() const { | ||
227 | 85 | return query_->filter_state(); | ||
228 | 86 | } | ||
229 | 87 | |||
230 | 88 | unity::scopes::CannedQuery & CannedQuery::canned_query() { | ||
231 | 89 | return *query_.get(); | ||
232 | 90 | } | ||
233 | 0 | 91 | ||
234 | === added file 'src/bindings/src/canned-query.h' | |||
235 | --- src/bindings/src/canned-query.h 1970-01-01 00:00:00 +0000 | |||
236 | +++ src/bindings/src/canned-query.h 2015-10-22 13:54:24 +0000 | |||
237 | @@ -0,0 +1,49 @@ | |||
238 | 1 | /* | ||
239 | 2 | * Copyright 2015 Canonical Ltd. | ||
240 | 3 | * | ||
241 | 4 | * This file is part of unity-js-scopes. | ||
242 | 5 | * | ||
243 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
244 | 7 | * it under the terms of the GNU General Public License as published by | ||
245 | 8 | * the Free Software Foundation; version 3. | ||
246 | 9 | * | ||
247 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
248 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
249 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
250 | 13 | * GNU General Public License for more details. | ||
251 | 14 | * | ||
252 | 15 | * You should have received a copy of the GNU General Public License | ||
253 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
254 | 17 | */ | ||
255 | 18 | |||
256 | 19 | #ifndef _UNITY_JS_CANNED_QUERY_H_ | ||
257 | 20 | #define _UNITY_JS_CANNED_QUERY_H_ | ||
258 | 21 | |||
259 | 22 | #include <unity/scopes/CannedQuery.h> | ||
260 | 23 | |||
261 | 24 | #include <v8-cpp.h> | ||
262 | 25 | |||
263 | 26 | class CannedQuery | ||
264 | 27 | { | ||
265 | 28 | public: | ||
266 | 29 | CannedQuery(const unity::scopes::CannedQuery& canned_query); | ||
267 | 30 | CannedQuery(v8::FunctionCallbackInfo<v8::Value> const& args); | ||
268 | 31 | |||
269 | 32 | // v8 bindings | ||
270 | 33 | void set_department_id(const std::string& department_id); | ||
271 | 34 | void set_query_string(const std::string& query_string); | ||
272 | 35 | void set_filter_state(std::shared_ptr<unity::scopes::FilterState> filter_state); | ||
273 | 36 | |||
274 | 37 | std::string scope_id() const; | ||
275 | 38 | std::string department_id() const; | ||
276 | 39 | std::string query_string() const; | ||
277 | 40 | std::string to_uri() const; | ||
278 | 41 | unity::scopes::FilterState filter_state() const; | ||
279 | 42 | |||
280 | 43 | unity::scopes::CannedQuery & canned_query(); | ||
281 | 44 | |||
282 | 45 | private: | ||
283 | 46 | std::unique_ptr<unity::scopes::CannedQuery> query_; | ||
284 | 47 | }; | ||
285 | 48 | |||
286 | 49 | #endif // _UNITY_JS_CANNED_QUERY_H_ | ||
287 | 0 | 50 | ||
288 | === added file 'src/bindings/src/option-selector-filter.cc' | |||
289 | --- src/bindings/src/option-selector-filter.cc 1970-01-01 00:00:00 +0000 | |||
290 | +++ src/bindings/src/option-selector-filter.cc 2015-10-22 13:54:24 +0000 | |||
291 | @@ -0,0 +1,86 @@ | |||
292 | 1 | /* | ||
293 | 2 | * Copyright 2015 Canonical Ltd. | ||
294 | 3 | * | ||
295 | 4 | * This file is part of unity-js-scopes. | ||
296 | 5 | * | ||
297 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
298 | 7 | * it under the terms of the GNU General Public License as published by | ||
299 | 8 | * the Free Software Foundation; version 3. | ||
300 | 9 | * | ||
301 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
302 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
303 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
304 | 13 | * GNU General Public License for more details. | ||
305 | 14 | * | ||
306 | 15 | * You should have received a copy of the GNU General Public License | ||
307 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
308 | 17 | */ | ||
309 | 18 | |||
310 | 19 | #include "option-selector-filter.h" | ||
311 | 20 | |||
312 | 21 | |||
313 | 22 | OptionSelectorFilter::OptionSelectorFilter( | ||
314 | 23 | std::string const &id, | ||
315 | 24 | std::string const &label, | ||
316 | 25 | bool multi_select) | ||
317 | 26 | : filter_(unity::scopes::OptionSelectorFilter::create(id, label, multi_select)){ | ||
318 | 27 | } | ||
319 | 28 | |||
320 | 29 | std::string OptionSelectorFilter::label() const { | ||
321 | 30 | return filter_->label(); | ||
322 | 31 | } | ||
323 | 32 | |||
324 | 33 | bool OptionSelectorFilter::multi_select() const { | ||
325 | 34 | return filter_->multi_select(); | ||
326 | 35 | } | ||
327 | 36 | |||
328 | 37 | unity::scopes::FilterOption::SCPtr OptionSelectorFilter::add_option( | ||
329 | 38 | std::string const& id, | ||
330 | 39 | std::string const& label) { | ||
331 | 40 | return filter_->add_option(id, label); | ||
332 | 41 | } | ||
333 | 42 | |||
334 | 43 | std::list<unity::scopes::FilterOption::SCPtr> OptionSelectorFilter::options() const { | ||
335 | 44 | return filter_->options(); | ||
336 | 45 | } | ||
337 | 46 | |||
338 | 47 | bool OptionSelectorFilter::has_active_option( | ||
339 | 48 | unity::scopes::FilterState const& filter_state) const { | ||
340 | 49 | return filter_->has_active_option(filter_state); | ||
341 | 50 | } | ||
342 | 51 | |||
343 | 52 | std::set<unity::scopes::FilterOption::SCPtr> OptionSelectorFilter::active_options( | ||
344 | 53 | unity::scopes::FilterState const& filter_state) const { | ||
345 | 54 | return filter_->active_options(filter_state); | ||
346 | 55 | } | ||
347 | 56 | |||
348 | 57 | void OptionSelectorFilter::update_state( | ||
349 | 58 | unity::scopes::FilterState& filter_state, | ||
350 | 59 | unity::scopes::FilterOption::SCPtr option, | ||
351 | 60 | bool active) const { | ||
352 | 61 | filter_->update_state(filter_state, option, active); | ||
353 | 62 | } | ||
354 | 63 | |||
355 | 64 | void OptionSelectorFilter::set_display_hints(int hints) { | ||
356 | 65 | filter_->set_display_hints(hints); | ||
357 | 66 | } | ||
358 | 67 | |||
359 | 68 | int OptionSelectorFilter::display_hints() const { | ||
360 | 69 | return filter_->display_hints(); | ||
361 | 70 | } | ||
362 | 71 | |||
363 | 72 | std::string OptionSelectorFilter::id() const { | ||
364 | 73 | return filter_->id(); | ||
365 | 74 | } | ||
366 | 75 | |||
367 | 76 | unity::scopes::VariantMap OptionSelectorFilter::serialize() const { | ||
368 | 77 | return filter_->serialize(); | ||
369 | 78 | } | ||
370 | 79 | |||
371 | 80 | std::string OptionSelectorFilter::filter_type() const { | ||
372 | 81 | return filter_->filter_type(); | ||
373 | 82 | } | ||
374 | 83 | |||
375 | 84 | unity::scopes::OptionSelectorFilter::SPtr OptionSelectorFilter::get_filter() { | ||
376 | 85 | return filter_; | ||
377 | 86 | } | ||
378 | 0 | 87 | ||
379 | === added file 'src/bindings/src/option-selector-filter.h' | |||
380 | --- src/bindings/src/option-selector-filter.h 1970-01-01 00:00:00 +0000 | |||
381 | +++ src/bindings/src/option-selector-filter.h 2015-10-22 13:54:24 +0000 | |||
382 | @@ -0,0 +1,54 @@ | |||
383 | 1 | /* | ||
384 | 2 | * Copyright 2015 Canonical Ltd. | ||
385 | 3 | * | ||
386 | 4 | * This file is part of unity-js-scopes. | ||
387 | 5 | * | ||
388 | 6 | * unity-js-scopes is free software; you can redistribute it and/or modify | ||
389 | 7 | * it under the terms of the GNU General Public License as published by | ||
390 | 8 | * the Free Software Foundation; version 3. | ||
391 | 9 | * | ||
392 | 10 | * unity-js-scopes is distributed in the hope that it will be useful, | ||
393 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
394 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
395 | 13 | * GNU General Public License for more details. | ||
396 | 14 | * | ||
397 | 15 | * You should have received a copy of the GNU General Public License | ||
398 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
399 | 17 | */ | ||
400 | 18 | |||
401 | 19 | #ifndef _UNITY_JS_OPTION_SELECTOR_FILTER_H_ | ||
402 | 20 | #define _UNITY_JS_OPTION_SELECTOR_FILTER_H_ | ||
403 | 21 | |||
404 | 22 | #include <unity/scopes/OptionSelectorFilter.h> | ||
405 | 23 | |||
406 | 24 | #include <v8-cpp.h> | ||
407 | 25 | |||
408 | 26 | |||
409 | 27 | class OptionSelectorFilter | ||
410 | 28 | { | ||
411 | 29 | public: | ||
412 | 30 | OptionSelectorFilter(std::string const &id, std::string const &label, bool multi_select); | ||
413 | 31 | |||
414 | 32 | std::string label() const; | ||
415 | 33 | bool multi_select() const; | ||
416 | 34 | unity::scopes::FilterOption::SCPtr add_option(std::string const& id, std::string const& label); | ||
417 | 35 | std::list<unity::scopes::FilterOption::SCPtr> options() const; | ||
418 | 36 | bool has_active_option(unity::scopes::FilterState const& filter_state) const; | ||
419 | 37 | std::set<unity::scopes::FilterOption::SCPtr> active_options(unity::scopes::FilterState const& filter_state) const; | ||
420 | 38 | void update_state(unity::scopes::FilterState& filter_state, unity::scopes::FilterOption::SCPtr option, bool active) const; | ||
421 | 39 | |||
422 | 40 | void set_display_hints(int hints); | ||
423 | 41 | int display_hints() const; | ||
424 | 42 | std::string id() const; | ||
425 | 43 | unity::scopes::VariantMap serialize() const; | ||
426 | 44 | std::string filter_type() const; | ||
427 | 45 | |||
428 | 46 | unity::scopes::OptionSelectorFilter::SPtr get_filter(); | ||
429 | 47 | |||
430 | 48 | private: | ||
431 | 49 | unity::scopes::OptionSelectorFilter::SPtr filter_; | ||
432 | 50 | }; | ||
433 | 51 | |||
434 | 52 | #endif // _UNITY_JS_OPTION_SELECTOR_FILTER_H_ | ||
435 | 53 | |||
436 | 54 | |||
437 | 0 | 55 | ||
438 | === modified file 'src/bindings/src/scope-base.cc' | |||
439 | --- src/bindings/src/scope-base.cc 2015-10-09 17:00:22 +0000 | |||
440 | +++ src/bindings/src/scope-base.cc 2015-10-22 13:54:24 +0000 | |||
441 | @@ -21,6 +21,7 @@ | |||
442 | 21 | #include "action-metadata.h" | 21 | #include "action-metadata.h" |
443 | 22 | #include "activation-query.h" | 22 | #include "activation-query.h" |
444 | 23 | #include "activation-query-proxy.h" | 23 | #include "activation-query-proxy.h" |
445 | 24 | #include "canned-query.h" | ||
446 | 24 | #include "search-query.h" | 25 | #include "search-query.h" |
447 | 25 | #include "search-query-proxy.h" | 26 | #include "search-query-proxy.h" |
448 | 26 | #include "search-metadata.h" | 27 | #include "search-metadata.h" |
449 | @@ -109,8 +110,8 @@ | |||
450 | 109 | return EventQueue::instance().run<unity::scopes::SearchQueryBase::UPtr>(isolate_, [this, query, metadata] | 110 | return EventQueue::instance().run<unity::scopes::SearchQueryBase::UPtr>(isolate_, [this, query, metadata] |
451 | 110 | { | 111 | { |
452 | 111 | // wrap & fire | 112 | // wrap & fire |
455 | 112 | std::shared_ptr<unity::scopes::CannedQuery> q( | 113 | std::shared_ptr<CannedQuery> q( |
456 | 113 | new unity::scopes::CannedQuery(std::move(query))); | 114 | new CannedQuery(query)); |
457 | 114 | 115 | ||
458 | 115 | std::shared_ptr<SearchMetaData> m( | 116 | std::shared_ptr<SearchMetaData> m( |
459 | 116 | new SearchMetaData(metadata)); | 117 | new SearchMetaData(metadata)); |
460 | 117 | 118 | ||
461 | === modified file 'src/bindings/src/search-query.cc' | |||
462 | --- src/bindings/src/search-query.cc 2015-10-13 17:53:25 +0000 | |||
463 | +++ src/bindings/src/search-query.cc 2015-10-22 13:54:24 +0000 | |||
464 | @@ -23,11 +23,11 @@ | |||
465 | 23 | #include "event_queue.h" | 23 | #include "event_queue.h" |
466 | 24 | 24 | ||
467 | 25 | SearchQuery::SearchQuery( | 25 | SearchQuery::SearchQuery( |
469 | 26 | std::shared_ptr<unity::scopes::CannedQuery> query, | 26 | std::shared_ptr<CannedQuery> query, |
470 | 27 | std::shared_ptr<unity::scopes::SearchMetadata> metadata, | 27 | std::shared_ptr<unity::scopes::SearchMetadata> metadata, |
471 | 28 | const v8::Local<v8::Function> &run_callback, | 28 | const v8::Local<v8::Function> &run_callback, |
472 | 29 | const v8::Local<v8::Function> &cancelled_callback) | 29 | const v8::Local<v8::Function> &cancelled_callback) |
474 | 30 | : unity::scopes::SearchQueryBase(*query, *metadata), | 30 | : unity::scopes::SearchQueryBase(query->canned_query(), *metadata), |
475 | 31 | isolate_(v8::Isolate::GetCurrent()), | 31 | isolate_(v8::Isolate::GetCurrent()), |
476 | 32 | run_callback_(v8::Isolate::GetCurrent(), run_callback), | 32 | run_callback_(v8::Isolate::GetCurrent(), run_callback), |
477 | 33 | cancelled_callback_(v8::Isolate::GetCurrent(), cancelled_callback) { | 33 | cancelled_callback_(v8::Isolate::GetCurrent(), cancelled_callback) { |
478 | 34 | 34 | ||
479 | === modified file 'src/bindings/src/search-query.h' | |||
480 | --- src/bindings/src/search-query.h 2015-10-13 17:53:25 +0000 | |||
481 | +++ src/bindings/src/search-query.h 2015-10-22 13:54:24 +0000 | |||
482 | @@ -21,13 +21,15 @@ | |||
483 | 21 | 21 | ||
484 | 22 | #include <unity/scopes/SearchQueryBase.h> | 22 | #include <unity/scopes/SearchQueryBase.h> |
485 | 23 | 23 | ||
486 | 24 | #include "canned-query.h" | ||
487 | 25 | |||
488 | 24 | #include <v8-cpp.h> | 26 | #include <v8-cpp.h> |
489 | 25 | 27 | ||
490 | 26 | class SearchQuery : public unity::scopes::SearchQueryBase, | 28 | class SearchQuery : public unity::scopes::SearchQueryBase, |
491 | 27 | public std::enable_shared_from_this<SearchQuery> | 29 | public std::enable_shared_from_this<SearchQuery> |
492 | 28 | { | 30 | { |
493 | 29 | public: | 31 | public: |
495 | 30 | SearchQuery(std::shared_ptr<unity::scopes::CannedQuery> query, | 32 | SearchQuery(std::shared_ptr<CannedQuery> query, |
496 | 31 | std::shared_ptr<unity::scopes::SearchMetadata> metadata, | 33 | std::shared_ptr<unity::scopes::SearchMetadata> metadata, |
497 | 32 | const v8::Local<v8::Function> &run_callback, | 34 | const v8::Local<v8::Function> &run_callback, |
498 | 33 | const v8::Local<v8::Function> &cancelled_callback); | 35 | const v8::Local<v8::Function> &cancelled_callback); |
499 | 34 | 36 | ||
500 | === modified file 'src/bindings/src/search-reply.cc' | |||
501 | --- src/bindings/src/search-reply.cc 2015-10-19 14:03:37 +0000 | |||
502 | +++ src/bindings/src/search-reply.cc 2015-10-22 13:54:24 +0000 | |||
503 | @@ -18,16 +18,40 @@ | |||
504 | 18 | 18 | ||
505 | 19 | #include "search-reply.h" | 19 | #include "search-reply.h" |
506 | 20 | 20 | ||
507 | 21 | #include "categorised-result.h" | ||
508 | 22 | #include "option-selector-filter.h" | ||
509 | 23 | |||
510 | 21 | #include <stdexcept> | 24 | #include <stdexcept> |
511 | 22 | 25 | ||
512 | 23 | #include <unity/scopes/SearchReply.h> | 26 | #include <unity/scopes/SearchReply.h> |
513 | 24 | 27 | ||
514 | 25 | 28 | ||
515 | 29 | namespace { | ||
516 | 30 | |||
517 | 31 | unity::scopes::Filters from_v8_to_filters( | ||
518 | 32 | v8::Isolate* isolate, | ||
519 | 33 | v8::Local<v8::Value> value) { | ||
520 | 34 | unity::scopes::Filters | ||
521 | 35 | filter_bases; | ||
522 | 36 | v8::Handle<v8::Object> o = v8::Handle<v8::Object>::Cast(value); | ||
523 | 37 | for (size_t i = 0; | ||
524 | 38 | i < o->Get(v8::String::NewFromUtf8(isolate, "length"))->ToObject()->Uint32Value(); | ||
525 | 39 | ++i) { | ||
526 | 40 | v8::Local<v8::Value> fv = o->Get(i); | ||
527 | 41 | try { | ||
528 | 42 | auto f = v8cpp::from_v8<std::shared_ptr<OptionSelectorFilter>>(isolate, fv); | ||
529 | 43 | filter_bases.push_back(f->get_filter()); | ||
530 | 44 | } catch(...) { } | ||
531 | 45 | } | ||
532 | 46 | return filter_bases; | ||
533 | 47 | } | ||
534 | 48 | |||
535 | 49 | } | ||
536 | 50 | |||
537 | 51 | |||
538 | 26 | SearchReply::SearchReply(unity::scopes::SearchReplyProxy const& reply) | 52 | SearchReply::SearchReply(unity::scopes::SearchReplyProxy const& reply) |
543 | 27 | : reply_(reply){ | 53 | : isolate_(v8::Isolate::GetCurrent()) |
544 | 28 | } | 54 | , reply_(reply){ |
541 | 29 | |||
542 | 30 | SearchReply::~SearchReply() { | ||
545 | 31 | } | 55 | } |
546 | 32 | 56 | ||
547 | 33 | unity::scopes::Category::SCPtr SearchReply::lookup_category( | 57 | unity::scopes::Category::SCPtr SearchReply::lookup_category( |
548 | @@ -35,9 +59,24 @@ | |||
549 | 35 | return reply_->lookup_category(id); | 59 | return reply_->lookup_category(id); |
550 | 36 | } | 60 | } |
551 | 37 | 61 | ||
555 | 38 | void SearchReply::push( | 62 | bool SearchReply::push(v8::FunctionCallbackInfo<v8::Value> const& args) { |
556 | 39 | std::shared_ptr<CategorisedResult> categorised_result) { | 63 | if (args.Length() != 1 && args.Length() != 2) { |
557 | 40 | reply_->push(*categorised_result); | 64 | throw std::runtime_error("Invalid number of arguments"); |
558 | 65 | } | ||
559 | 66 | |||
560 | 67 | if (args.Length() == 1) { | ||
561 | 68 | auto cr = | ||
562 | 69 | v8cpp::from_v8<std::shared_ptr<CategorisedResult>>(isolate_, args[0]); | ||
563 | 70 | return reply_->push(*cr); | ||
564 | 71 | } | ||
565 | 72 | |||
566 | 73 | auto filter_state = | ||
567 | 74 | v8cpp::from_v8<std::shared_ptr<unity::scopes::FilterState>>(isolate_, args[1]); | ||
568 | 75 | |||
569 | 76 | // TODO fix v8cpp shortcoming here | ||
570 | 77 | return reply_->push( | ||
571 | 78 | from_v8_to_filters(isolate_, args[0]), | ||
572 | 79 | *filter_state); | ||
573 | 41 | } | 80 | } |
574 | 42 | 81 | ||
575 | 43 | unity::scopes::Category::SCPtr SearchReply::register_category( | 82 | unity::scopes::Category::SCPtr SearchReply::register_category( |
576 | 44 | 83 | ||
577 | === modified file 'src/bindings/src/search-reply.h' | |||
578 | --- src/bindings/src/search-reply.h 2015-10-16 19:33:32 +0000 | |||
579 | +++ src/bindings/src/search-reply.h 2015-10-22 13:54:24 +0000 | |||
580 | @@ -32,7 +32,6 @@ | |||
581 | 32 | { | 32 | { |
582 | 33 | public: | 33 | public: |
583 | 34 | SearchReply(unity::scopes::SearchReplyProxy const& reply); | 34 | SearchReply(unity::scopes::SearchReplyProxy const& reply); |
584 | 35 | ~SearchReply(); | ||
585 | 36 | 35 | ||
586 | 37 | void register_departments(std::shared_ptr<Department> department); | 36 | void register_departments(std::shared_ptr<Department> department); |
587 | 38 | 37 | ||
588 | @@ -45,12 +44,13 @@ | |||
589 | 45 | unity::scopes::Category::SCPtr | 44 | unity::scopes::Category::SCPtr |
590 | 46 | lookup_category(const std::string& id); | 45 | lookup_category(const std::string& id); |
591 | 47 | 46 | ||
593 | 48 | void push(std::shared_ptr<CategorisedResult> categorised_result); | 47 | bool push(v8::FunctionCallbackInfo<v8::Value> const& args); |
594 | 49 | 48 | ||
595 | 50 | void finished(); | 49 | void finished(); |
596 | 51 | 50 | ||
597 | 52 | private: | 51 | private: |
598 | 53 | 52 | ||
599 | 53 | v8::Isolate* isolate_; | ||
600 | 54 | unity::scopes::SearchReplyProxy const reply_; | 54 | unity::scopes::SearchReplyProxy const reply_; |
601 | 55 | }; | 55 | }; |
602 | 56 | 56 |
FAILED: Continuous integration, rev:84 jenkins. qa.ubuntu. com/job/ unity-js- scopes- ci/9/ jenkins. qa.ubuntu. com/job/ unity-js- scopes- wily-amd64- ci/9/console jenkins. qa.ubuntu. com/job/ unity-js- scopes- wily-armhf- ci/9 jenkins. qa.ubuntu. com/job/ unity-js- scopes- wily-armhf- ci/9/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ unity-js- scopes- wily-i386- ci/9
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- js-scopes- ci/9/rebuild
http://