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