Merge lp:unity-scopes-api/staging into lp:unity-scopes-api
- staging
- Merge into trunk
Proposed by
Michal Hruby
Status: | Merged |
---|---|
Merged at revision: | 205 |
Proposed branch: | lp:unity-scopes-api/staging |
Merge into: | lp:unity-scopes-api |
Diff against target: |
3746 lines (+2416/-313) 73 files modified
CMakeLists.txt (+1/-1) CONFIGFILES (+1/-1) RELEASE_NOTES.md (+6/-0) debian/changelog (+9/-0) debian/libunity-scopes1.symbols (+38/-4) demo/client.cpp (+5/-4) demo/scopes/scope-A/scope-A.cpp (+1/-1) doc/tutorial.dox (+44/-19) include/unity/scopes/OptionSelectorFilter.h (+8/-1) include/unity/scopes/RadioButtonsFilter.h (+124/-0) include/unity/scopes/RangeInputFilter.h (+1/-1) include/unity/scopes/RatingFilter.h (+180/-0) include/unity/scopes/internal/FilterBaseImpl.h (+1/-0) include/unity/scopes/internal/MWPublisher.h (+55/-0) include/unity/scopes/internal/MWSubscriber.h (+57/-0) include/unity/scopes/internal/MiddlewareBase.h (+5/-0) include/unity/scopes/internal/OptionSelectorFilterImpl.h (+3/-1) include/unity/scopes/internal/RadioButtonsFilterImpl.h (+50/-0) include/unity/scopes/internal/RatingFilterImpl.h (+64/-0) include/unity/scopes/internal/smartscopes/SmartScopesClient.h (+1/-0) include/unity/scopes/internal/zmq_middleware/ObjectAdapter.h (+0/-2) include/unity/scopes/internal/zmq_middleware/Util.h (+4/-0) include/unity/scopes/internal/zmq_middleware/ZmqMiddleware.h (+4/-1) include/unity/scopes/internal/zmq_middleware/ZmqPublisher.h (+83/-0) include/unity/scopes/internal/zmq_middleware/ZmqSubscriber.h (+86/-0) scoperegistry/CMakeLists.txt (+0/-1) scoperegistry/FindFiles.cpp (+17/-6) scoperegistry/FindFiles.h (+7/-3) scoperegistry/ScopeSet.cpp (+0/-124) scoperegistry/ScopeSet.h (+0/-56) scoperegistry/scoperegistry.cpp (+3/-4) scoperunner/scoperunner.cpp (+31/-1) src/scopes/CMakeLists.txt (+2/-0) src/scopes/OptionSelectorFilter.cpp (+7/-2) src/scopes/RadioButtonsFilter.cpp (+80/-0) src/scopes/RatingFilter.cpp (+105/-0) src/scopes/internal/CMakeLists.txt (+4/-0) src/scopes/internal/FilterBaseImpl.cpp (+60/-0) src/scopes/internal/MWPublisher.cpp (+42/-0) src/scopes/internal/MWSubscriber.cpp (+42/-0) src/scopes/internal/OptionSelectorFilterImpl.cpp (+32/-0) src/scopes/internal/RadioButtonsFilterImpl.cpp (+81/-0) src/scopes/internal/RatingFilterImpl.cpp (+109/-0) src/scopes/internal/SearchReplyImpl.cpp (+11/-1) src/scopes/internal/smartscopes/SSRegistryObject.cpp (+5/-0) src/scopes/internal/smartscopes/SmartScopesClient.cpp (+5/-0) src/scopes/internal/zmq_middleware/CMakeLists.txt (+2/-0) src/scopes/internal/zmq_middleware/ObjectAdapter.cpp (+0/-41) src/scopes/internal/zmq_middleware/Util.cpp (+42/-0) src/scopes/internal/zmq_middleware/ZmqMiddleware.cpp (+17/-4) src/scopes/internal/zmq_middleware/ZmqPublisher.cpp (+157/-0) src/scopes/internal/zmq_middleware/ZmqSubscriber.cpp (+185/-0) test/gtest/scopes/CMakeLists.txt (+2/-0) test/gtest/scopes/Filters/Filters_test.cpp (+72/-0) test/gtest/scopes/Filters/TestScope.h (+1/-1) test/gtest/scopes/IdleShutdown/IdleShutdown_test.cpp (+12/-6) test/gtest/scopes/IdleShutdown/SlowSearchScope.cpp (+1/-1) test/gtest/scopes/IdleShutdown/Zmq.ini.in (+5/-1) test/gtest/scopes/OptionSelectorFilter/OptionSelectorFilter_test.cpp (+3/-0) test/gtest/scopes/RadioButtonsFilter/CMakeLists.txt (+4/-0) test/gtest/scopes/RadioButtonsFilter/RadioButtonsFilter_test.cpp (+71/-0) test/gtest/scopes/RatingFilter/CMakeLists.txt (+4/-0) test/gtest/scopes/RatingFilter/RatingFilter_test.cpp (+111/-0) test/gtest/scopes/Registry/Registry_test.cpp (+0/-19) test/gtest/scopes/Registry/Zmq.ini.in (+1/-0) test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py (+1/-1) test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp (+2/-0) test/gtest/scopes/internal/zmq_middleware/CMakeLists.txt (+1/-0) test/gtest/scopes/internal/zmq_middleware/ObjectAdapter/ObjectAdapter_test.cpp (+2/-4) test/gtest/scopes/internal/zmq_middleware/PubSub/CMakeLists.txt (+6/-0) test/gtest/scopes/internal/zmq_middleware/PubSub/PubSub_test.cpp (+237/-0) test/gtest/scopes/internal/zmq_middleware/PubSub/Zmq.ini.in (+2/-0) test/gtest/scopes/internal/zmq_middleware/RegistryI/RegistryI_test.cpp (+1/-1) |
To merge this branch: | bzr merge lp:unity-scopes-api/staging |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Unity Team | Pending | ||
Review via email:
|
Commit message
Sync with devel.
Description of the change
Sync with devel.
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Needs Fixing
(continuous-integration)
lp:unity-scopes-api/staging
updated
- 205. By Tarmac
-
Sync with devel.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2014-05-15 08:17:57 +0000 | |||
3 | +++ CMakeLists.txt 2014-05-21 14:02:43 +0000 | |||
4 | @@ -179,7 +179,7 @@ | |||
5 | 179 | # API version | 179 | # API version |
6 | 180 | set(UNITY_SCOPES_MAJOR 0) | 180 | set(UNITY_SCOPES_MAJOR 0) |
7 | 181 | set(UNITY_SCOPES_MINOR 4) | 181 | set(UNITY_SCOPES_MINOR 4) |
9 | 182 | set(UNITY_SCOPES_MICRO 6) | 182 | set(UNITY_SCOPES_MICRO 7) |
10 | 183 | 183 | ||
11 | 184 | # Version for testing, with all symbols visible | 184 | # Version for testing, with all symbols visible |
12 | 185 | set(UNITY_SCOPES_TEST_LIB ${UNITY_SCOPES_LIB}-test) | 185 | set(UNITY_SCOPES_TEST_LIB ${UNITY_SCOPES_LIB}-test) |
13 | 186 | 186 | ||
14 | === modified file 'CONFIGFILES' | |||
15 | --- CONFIGFILES 2014-05-15 07:33:37 +0000 | |||
16 | +++ CONFIGFILES 2014-05-21 14:02:43 +0000 | |||
17 | @@ -279,7 +279,7 @@ | |||
18 | 279 | 279 | ||
19 | 280 | If set, the results for this scope will be set to expire, and be refreshed. Valid values are: | 280 | If set, the results for this scope will be set to expire, and be refreshed. Valid values are: |
20 | 281 | 281 | ||
22 | 282 | - none | 282 | - None |
23 | 283 | 283 | ||
24 | 284 | - Small - in the order of a minute | 284 | - Small - in the order of a minute |
25 | 285 | 285 | ||
26 | 286 | 286 | ||
27 | === modified file 'RELEASE_NOTES.md' | |||
28 | --- RELEASE_NOTES.md 2014-05-15 10:34:30 +0000 | |||
29 | +++ RELEASE_NOTES.md 2014-05-21 14:02:43 +0000 | |||
30 | @@ -1,6 +1,12 @@ | |||
31 | 1 | Release notes | 1 | Release notes |
32 | 2 | ============= | 2 | ============= |
33 | 3 | 3 | ||
34 | 4 | Changes in version 0.4.7 | ||
35 | 5 | ======================== | ||
36 | 6 | - Implemented RatingFilter and RadioButtonsFilter. | ||
37 | 7 | - changed create() methods of OptionSelectorFilter and RangeInputFilter to return unique_ptr (UPtr) | ||
38 | 8 | instead of shared pointers. | ||
39 | 9 | |||
40 | 4 | Changes in version 0.4.6 | 10 | Changes in version 0.4.6 |
41 | 5 | ======================== | 11 | ======================== |
42 | 6 | - Added method to get and set display hints for filters (at this moment the only display hint | 12 | - Added method to get and set display hints for filters (at this moment the only display hint |
43 | 7 | 13 | ||
44 | === modified file 'debian/changelog' | |||
45 | --- debian/changelog 2014-05-19 10:10:28 +0000 | |||
46 | +++ debian/changelog 2014-05-21 14:02:43 +0000 | |||
47 | @@ -1,3 +1,12 @@ | |||
48 | 1 | unity-scopes-api (0.4.7-0ubuntu1) UNRELEASED; urgency=medium | ||
49 | 2 | |||
50 | 3 | [ Pawel Stolowski ] | ||
51 | 4 | * Implemented RatingFilter and RadioButtonFilter. | ||
52 | 5 | * Fixed lp:1319712: Appearance attributes not supported for remote scopes. | ||
53 | 6 | * Changed create() methods of OptionSelectorFilter and RangeInputFilter to return unique ptr. | ||
54 | 7 | |||
55 | 8 | -- Pawel Stolowski <pawel.stolowski@ubuntu.com> Fri, 16 May 2014 17:48:23 +0200 | ||
56 | 9 | |||
57 | 1 | unity-scopes-api (0.4.6+14.10.20140519-0ubuntu1) utopic; urgency=medium | 10 | unity-scopes-api (0.4.6+14.10.20140519-0ubuntu1) utopic; urgency=medium |
58 | 2 | 11 | ||
59 | 3 | [ Pete Woods ] | 12 | [ Pete Woods ] |
60 | 4 | 13 | ||
61 | === modified file 'debian/libunity-scopes1.symbols' | |||
62 | --- debian/libunity-scopes1.symbols 2014-05-19 10:10:27 +0000 | |||
63 | +++ debian/libunity-scopes1.symbols 2014-05-21 14:02:43 +0000 | |||
64 | @@ -82,6 +82,14 @@ | |||
65 | 82 | (c++)"unity::scopes::ListenerBase::~ListenerBase()@Base" 0.4.0+14.04.20140312.1 | 82 | (c++)"unity::scopes::ListenerBase::~ListenerBase()@Base" 0.4.0+14.04.20140312.1 |
66 | 83 | (c++)"unity::scopes::PreviewReply::PreviewReply()@Base" 0.4.0+14.04.20140312.1 | 83 | (c++)"unity::scopes::PreviewReply::PreviewReply()@Base" 0.4.0+14.04.20140312.1 |
67 | 84 | (c++)"unity::scopes::PreviewReply::~PreviewReply()@Base" 0.4.0+14.04.20140312.1 | 84 | (c++)"unity::scopes::PreviewReply::~PreviewReply()@Base" 0.4.0+14.04.20140312.1 |
68 | 85 | (c++)"unity::scopes::RatingFilter::add_option(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0replaceme | ||
69 | 86 | (c++)"unity::scopes::RatingFilter::set_on_icon(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0replaceme | ||
70 | 87 | (c++)"unity::scopes::RatingFilter::set_off_icon(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0replaceme | ||
71 | 88 | (c++)"unity::scopes::RatingFilter::update_state(unity::scopes::FilterState&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)@Base" 0replaceme | ||
72 | 89 | (c++)"unity::scopes::RatingFilter::create(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0replaceme | ||
73 | 90 | (c++)"unity::scopes::RatingFilter::create(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)@Base" 0replaceme | ||
74 | 91 | (c++)"unity::scopes::RatingFilter::RatingFilter(unity::scopes::internal::RatingFilterImpl*)@Base" 0replaceme | ||
75 | 92 | (c++)"unity::scopes::RatingFilter::~RatingFilter()@Base" 0replaceme | ||
76 | 85 | (c++)"unity::scopes::PreviewWidget::add_attribute_value(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unity::scopes::Variant const&)@Base" 0.4.0+14.04.20140312.1 | 93 | (c++)"unity::scopes::PreviewWidget::add_attribute_value(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unity::scopes::Variant const&)@Base" 0.4.0+14.04.20140312.1 |
77 | 86 | (c++)"unity::scopes::PreviewWidget::add_attribute_mapping(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1 | 94 | (c++)"unity::scopes::PreviewWidget::add_attribute_mapping(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1 |
78 | 87 | (c++)"unity::scopes::PreviewWidget::PreviewWidget(unity::scopes::PreviewWidget&&)@Base" 0.4.0+14.04.20140312.1 | 95 | (c++)"unity::scopes::PreviewWidget::PreviewWidget(unity::scopes::PreviewWidget&&)@Base" 0.4.0+14.04.20140312.1 |
79 | @@ -216,6 +224,11 @@ | |||
80 | 216 | (c++)"unity::scopes::ActivationResponse::~ActivationResponse()@Base" 0.4.0+14.04.20140312.1 | 224 | (c++)"unity::scopes::ActivationResponse::~ActivationResponse()@Base" 0.4.0+14.04.20140312.1 |
81 | 217 | (c++)"unity::scopes::ActivationResponse::operator=(unity::scopes::ActivationResponse&&)@Base" 0.4.0+14.04.20140312.1 | 225 | (c++)"unity::scopes::ActivationResponse::operator=(unity::scopes::ActivationResponse&&)@Base" 0.4.0+14.04.20140312.1 |
82 | 218 | (c++)"unity::scopes::ActivationResponse::operator=(unity::scopes::ActivationResponse const&)@Base" 0.4.0+14.04.20140312.1 | 226 | (c++)"unity::scopes::ActivationResponse::operator=(unity::scopes::ActivationResponse const&)@Base" 0.4.0+14.04.20140312.1 |
83 | 227 | (c++)"unity::scopes::RadioButtonsFilter::add_option(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0replaceme | ||
84 | 228 | (c++)"unity::scopes::RadioButtonsFilter::update_state(unity::scopes::FilterState&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)@Base" 0replaceme | ||
85 | 229 | (c++)"unity::scopes::RadioButtonsFilter::create(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0replaceme | ||
86 | 230 | (c++)"unity::scopes::RadioButtonsFilter::RadioButtonsFilter(unity::scopes::internal::RadioButtonsFilterImpl*)@Base" 0replaceme | ||
87 | 231 | (c++)"unity::scopes::RadioButtonsFilter::~RadioButtonsFilter()@Base" 0replaceme | ||
88 | 219 | (c++)"unity::scopes::SearchListenerBase::push(unity::scopes::Annotation)@Base" 0.4.0+14.04.20140312.1 | 232 | (c++)"unity::scopes::SearchListenerBase::push(unity::scopes::Annotation)@Base" 0.4.0+14.04.20140312.1 |
89 | 220 | (c++)"unity::scopes::SearchListenerBase::push(std::list<unity::scopes::Department, std::allocator<unity::scopes::Department> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1 | 233 | (c++)"unity::scopes::SearchListenerBase::push(std::list<unity::scopes::Department, std::allocator<unity::scopes::Department> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1 |
90 | 221 | (c++)"unity::scopes::SearchListenerBase::push(std::list<std::shared_ptr<unity::scopes::FilterBase const>, std::allocator<std::shared_ptr<unity::scopes::FilterBase const> > > const&, unity::scopes::FilterState const&)@Base" 0.4.0+14.04.20140312.1 | 234 | (c++)"unity::scopes::SearchListenerBase::push(std::list<std::shared_ptr<unity::scopes::FilterBase const>, std::allocator<std::shared_ptr<unity::scopes::FilterBase const> > > const&, unity::scopes::FilterState const&)@Base" 0.4.0+14.04.20140312.1 |
91 | @@ -447,13 +460,12 @@ | |||
92 | 447 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_search_hint(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1 | 460 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_search_hint(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1 |
93 | 448 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_display_name(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1 | 461 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_display_name(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1 |
94 | 449 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_scope_directory(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.2+14.04.20140404.2 | 462 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_scope_directory(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.2+14.04.20140404.2 |
95 | 463 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_results_ttl_type(unity::scopes::ScopeMetadata::ResultsTtlType)@Base" 0.4.6+14.10.20140519 | ||
96 | 450 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_appearance_attributes(std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unity::scopes::Variant, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, unity::scopes::Variant> > > const&)@Base" 0.4.2+14.04.20140404.2 | 464 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_appearance_attributes(std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unity::scopes::Variant, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, unity::scopes::Variant> > > const&)@Base" 0.4.2+14.04.20140404.2 |
97 | 451 | (c++)"unity::scopes::internal::ScopeMetadataImpl::create(std::unique_ptr<unity::scopes::internal::ScopeMetadataImpl, std::default_delete<unity::scopes::internal::ScopeMetadataImpl> >)@Base" 0.4.0+14.04.20140312.1 | 465 | (c++)"unity::scopes::internal::ScopeMetadataImpl::create(std::unique_ptr<unity::scopes::internal::ScopeMetadataImpl, std::default_delete<unity::scopes::internal::ScopeMetadataImpl> >)@Base" 0.4.0+14.04.20140312.1 |
98 | 452 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_art(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1 | 466 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_art(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1 |
99 | 453 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_icon(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1 | 467 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_icon(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@Base" 0.4.0+14.04.20140312.1 |
100 | 454 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_proxy(std::shared_ptr<unity::scopes::Scope> const&)@Base" 0.4.0+14.04.20140312.1 | 468 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_proxy(std::shared_ptr<unity::scopes::Scope> const&)@Base" 0.4.0+14.04.20140312.1 |
101 | 455 | (c++)"unity::scopes::internal::ScopeMetadataImpl::set_results_ttl_type(unity::scopes::ScopeMetadata::ResultsTtlType)@Base" 0.4.6+14.10.20140519 | ||
102 | 456 | (c++)"unity::scopes::internal::ScopeMetadataImpl::results_ttl_type() const@Base" 0.4.6+14.10.20140519 | ||
103 | 457 | (c++)"unity::scopes::internal::ScopeMetadataImpl::ScopeMetadataImpl(unity::scopes::internal::MiddlewareBase*)@Base" 0.4.0+14.04.20140312.1 | 469 | (c++)"unity::scopes::internal::ScopeMetadataImpl::ScopeMetadataImpl(unity::scopes::internal::MiddlewareBase*)@Base" 0.4.0+14.04.20140312.1 |
104 | 458 | (c++)"unity::scopes::internal::ScopeMetadataImpl::ScopeMetadataImpl(unity::scopes::internal::ScopeMetadataImpl const&)@Base" 0.4.0+14.04.20140312.1 | 470 | (c++)"unity::scopes::internal::ScopeMetadataImpl::ScopeMetadataImpl(unity::scopes::internal::ScopeMetadataImpl const&)@Base" 0.4.0+14.04.20140312.1 |
105 | 459 | (c++)"unity::scopes::internal::ScopeMetadataImpl::ScopeMetadataImpl(std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unity::scopes::Variant, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, unity::scopes::Variant> > > const&, unity::scopes::internal::MiddlewareBase*)@Base" 0.4.0+14.04.20140312.1 | 471 | (c++)"unity::scopes::internal::ScopeMetadataImpl::ScopeMetadataImpl(std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, unity::scopes::Variant, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, unity::scopes::Variant> > > const&, unity::scopes::internal::MiddlewareBase*)@Base" 0.4.0+14.04.20140312.1 |
106 | @@ -522,6 +534,14 @@ | |||
107 | 522 | (c++)"unity::scopes::ColumnLayout::serialize() const@Base" 0.4.0+14.04.20140312.1 | 534 | (c++)"unity::scopes::ColumnLayout::serialize() const@Base" 0.4.0+14.04.20140312.1 |
108 | 523 | (c++)"unity::scopes::FilterOption::id() const@Base" 0.4.0+14.04.20140312.1 | 535 | (c++)"unity::scopes::FilterOption::id() const@Base" 0.4.0+14.04.20140312.1 |
109 | 524 | (c++)"unity::scopes::FilterOption::label() const@Base" 0.4.0+14.04.20140312.1 | 536 | (c++)"unity::scopes::FilterOption::label() const@Base" 0.4.0+14.04.20140312.1 |
110 | 537 | (c++)"unity::scopes::RatingFilter::update_state(unity::scopes::FilterState&, std::shared_ptr<unity::scopes::FilterOption const>, bool) const@Base" 0replaceme | ||
111 | 538 | (c++)"unity::scopes::RatingFilter::active_rating(unity::scopes::FilterState const&) const@Base" 0replaceme | ||
112 | 539 | (c++)"unity::scopes::RatingFilter::has_active_rating(unity::scopes::FilterState const&) const@Base" 0replaceme | ||
113 | 540 | (c++)"unity::scopes::RatingFilter::fwd() const@Base" 0replaceme | ||
114 | 541 | (c++)"unity::scopes::RatingFilter::label() const@Base" 0replaceme | ||
115 | 542 | (c++)"unity::scopes::RatingFilter::on_icon() const@Base" 0replaceme | ||
116 | 543 | (c++)"unity::scopes::RatingFilter::options() const@Base" 0replaceme | ||
117 | 544 | (c++)"unity::scopes::RatingFilter::off_icon() const@Base" 0replaceme | ||
118 | 525 | (c++)"unity::scopes::PreviewWidget::widget_type() const@Base" 0.4.0+14.04.20140312.1 | 545 | (c++)"unity::scopes::PreviewWidget::widget_type() const@Base" 0.4.0+14.04.20140312.1 |
119 | 526 | (c++)"unity::scopes::PreviewWidget::attribute_values() const@Base" 0.4.0+14.04.20140312.1 | 546 | (c++)"unity::scopes::PreviewWidget::attribute_values() const@Base" 0.4.0+14.04.20140312.1 |
120 | 527 | (c++)"unity::scopes::PreviewWidget::attribute_mappings() const@Base" 0.4.0+14.04.20140312.1 | 547 | (c++)"unity::scopes::PreviewWidget::attribute_mappings() const@Base" 0.4.0+14.04.20140312.1 |
121 | @@ -532,6 +552,7 @@ | |||
122 | 532 | (c++)"unity::scopes::ScopeMetadata::search_hint() const@Base" 0.4.0+14.04.20140312.1 | 552 | (c++)"unity::scopes::ScopeMetadata::search_hint() const@Base" 0.4.0+14.04.20140312.1 |
123 | 533 | (c++)"unity::scopes::ScopeMetadata::display_name() const@Base" 0.4.0+14.04.20140312.1 | 553 | (c++)"unity::scopes::ScopeMetadata::display_name() const@Base" 0.4.0+14.04.20140312.1 |
124 | 534 | (c++)"unity::scopes::ScopeMetadata::scope_directory() const@Base" 0.4.2+14.04.20140404.2 | 554 | (c++)"unity::scopes::ScopeMetadata::scope_directory() const@Base" 0.4.2+14.04.20140404.2 |
125 | 555 | (c++)"unity::scopes::ScopeMetadata::results_ttl_type() const@Base" 0.4.6+14.10.20140519 | ||
126 | 535 | (c++)"unity::scopes::ScopeMetadata::appearance_attributes() const@Base" 0.4.2+14.04.20140404.2 | 556 | (c++)"unity::scopes::ScopeMetadata::appearance_attributes() const@Base" 0.4.2+14.04.20140404.2 |
127 | 536 | (c++)"unity::scopes::ScopeMetadata::art() const@Base" 0.4.0+14.04.20140312.1 | 557 | (c++)"unity::scopes::ScopeMetadata::art() const@Base" 0.4.0+14.04.20140312.1 |
128 | 537 | (c++)"unity::scopes::ScopeMetadata::icon() const@Base" 0.4.0+14.04.20140312.1 | 558 | (c++)"unity::scopes::ScopeMetadata::icon() const@Base" 0.4.0+14.04.20140312.1 |
129 | @@ -541,7 +562,6 @@ | |||
130 | 541 | (c++)"unity::scopes::ScopeMetadata::scope_id() const@Base" 0.4.0+14.04.20140312.1 | 562 | (c++)"unity::scopes::ScopeMetadata::scope_id() const@Base" 0.4.0+14.04.20140312.1 |
131 | 542 | (c++)"unity::scopes::ScopeMetadata::invisible() const@Base" 0.4.0+14.04.20140312.1 | 563 | (c++)"unity::scopes::ScopeMetadata::invisible() const@Base" 0.4.0+14.04.20140312.1 |
132 | 543 | (c++)"unity::scopes::ScopeMetadata::serialize() const@Base" 0.4.0+14.04.20140312.1 | 564 | (c++)"unity::scopes::ScopeMetadata::serialize() const@Base" 0.4.0+14.04.20140312.1 |
133 | 544 | (c++)"unity::scopes::ScopeMetadata::results_ttl_type() const@Base" 0.4.6+14.10.20140519 | ||
134 | 545 | (c++)"unity::scopes::ActionMetadata::scope_data() const@Base" 0.4.0+14.04.20140312.1 | 565 | (c++)"unity::scopes::ActionMetadata::scope_data() const@Base" 0.4.0+14.04.20140312.1 |
135 | 546 | (c++)"unity::scopes::ActionMetadata::form_factor() const@Base" 0.4.0+14.04.20140312.1 | 566 | (c++)"unity::scopes::ActionMetadata::form_factor() const@Base" 0.4.0+14.04.20140312.1 |
136 | 547 | (c++)"unity::scopes::ActionMetadata::locale() const@Base" 0.4.0+14.04.20140312.1 | 567 | (c++)"unity::scopes::ActionMetadata::locale() const@Base" 0.4.0+14.04.20140312.1 |
137 | @@ -573,10 +593,17 @@ | |||
138 | 573 | (c++)"unity::scopes::ActivationResponse::query() const@Base" 0.4.0+14.04.20140312.1 | 593 | (c++)"unity::scopes::ActivationResponse::query() const@Base" 0.4.0+14.04.20140312.1 |
139 | 574 | (c++)"unity::scopes::ActivationResponse::status() const@Base" 0.4.0+14.04.20140312.1 | 594 | (c++)"unity::scopes::ActivationResponse::status() const@Base" 0.4.0+14.04.20140312.1 |
140 | 575 | (c++)"unity::scopes::ActivationResponse::serialize() const@Base" 0.4.0+14.04.20140312.1 | 595 | (c++)"unity::scopes::ActivationResponse::serialize() const@Base" 0.4.0+14.04.20140312.1 |
141 | 596 | (c++)"unity::scopes::RadioButtonsFilter::update_state(unity::scopes::FilterState&, std::shared_ptr<unity::scopes::FilterOption const>, bool) const@Base" 0replaceme | ||
142 | 597 | (c++)"unity::scopes::RadioButtonsFilter::active_option(unity::scopes::FilterState const&) const@Base" 0replaceme | ||
143 | 598 | (c++)"unity::scopes::RadioButtonsFilter::has_active_option(unity::scopes::FilterState const&) const@Base" 0replaceme | ||
144 | 599 | (c++)"unity::scopes::RadioButtonsFilter::fwd() const@Base" 0replaceme | ||
145 | 600 | (c++)"unity::scopes::RadioButtonsFilter::label() const@Base" 0replaceme | ||
146 | 601 | (c++)"unity::scopes::RadioButtonsFilter::options() const@Base" 0replaceme | ||
147 | 576 | (c++)"unity::scopes::MiddlewareException::self() const@Base" 0.4.0+14.04.20140312.1 | 602 | (c++)"unity::scopes::MiddlewareException::self() const@Base" 0.4.0+14.04.20140312.1 |
148 | 577 | (c++)"unity::scopes::OptionSelectorFilter::multi_select() const@Base" 0.4.0+14.04.20140312.1 | 603 | (c++)"unity::scopes::OptionSelectorFilter::multi_select() const@Base" 0.4.0+14.04.20140312.1 |
149 | 578 | (c++)"unity::scopes::OptionSelectorFilter::update_state(unity::scopes::FilterState&, std::shared_ptr<unity::scopes::FilterOption const>, bool) const@Base" 0.4.0+14.04.20140312.1 | 604 | (c++)"unity::scopes::OptionSelectorFilter::update_state(unity::scopes::FilterState&, std::shared_ptr<unity::scopes::FilterOption const>, bool) const@Base" 0.4.0+14.04.20140312.1 |
150 | 579 | (c++)"unity::scopes::OptionSelectorFilter::active_options(unity::scopes::FilterState const&) const@Base" 0.4.0+14.04.20140312.1 | 605 | (c++)"unity::scopes::OptionSelectorFilter::active_options(unity::scopes::FilterState const&) const@Base" 0.4.0+14.04.20140312.1 |
151 | 606 | (c++)"unity::scopes::OptionSelectorFilter::has_active_option(unity::scopes::FilterState const&) const@Base" 0replaceme | ||
152 | 580 | (c++)"unity::scopes::OptionSelectorFilter::fwd() const@Base" 0.4.0+14.04.20140312.1 | 607 | (c++)"unity::scopes::OptionSelectorFilter::fwd() const@Base" 0.4.0+14.04.20140312.1 |
153 | 581 | (c++)"unity::scopes::OptionSelectorFilter::label() const@Base" 0.4.0+14.04.20140312.1 | 608 | (c++)"unity::scopes::OptionSelectorFilter::label() const@Base" 0.4.0+14.04.20140312.1 |
154 | 582 | (c++)"unity::scopes::OptionSelectorFilter::options() const@Base" 0.4.0+14.04.20140312.1 | 609 | (c++)"unity::scopes::OptionSelectorFilter::options() const@Base" 0.4.0+14.04.20140312.1 |
155 | @@ -644,13 +671,13 @@ | |||
156 | 644 | (c++)"unity::scopes::internal::ScopeConfig::idle_timeout() const@Base" 0.4.5+14.10.20140513 | 671 | (c++)"unity::scopes::internal::ScopeConfig::idle_timeout() const@Base" 0.4.5+14.10.20140513 |
157 | 645 | (c++)"unity::scopes::internal::ScopeConfig::overrideable() const@Base" 0.4.0+14.04.20140312.1 | 672 | (c++)"unity::scopes::internal::ScopeConfig::overrideable() const@Base" 0.4.0+14.04.20140312.1 |
158 | 646 | (c++)"unity::scopes::internal::ScopeConfig::scope_runner() const@Base" 0.4.2+14.04.20140404.2 | 673 | (c++)"unity::scopes::internal::ScopeConfig::scope_runner() const@Base" 0.4.2+14.04.20140404.2 |
159 | 674 | (c++)"unity::scopes::internal::ScopeConfig::results_ttl_type() const@Base" 0.4.6+14.10.20140519 | ||
160 | 647 | (c++)"unity::scopes::internal::ScopeConfig::appearance_attributes() const@Base" 0.4.2+14.04.20140404.2 | 675 | (c++)"unity::scopes::internal::ScopeConfig::appearance_attributes() const@Base" 0.4.2+14.04.20140404.2 |
161 | 648 | (c++)"unity::scopes::internal::ScopeConfig::art() const@Base" 0.4.0+14.04.20140312.1 | 676 | (c++)"unity::scopes::internal::ScopeConfig::art() const@Base" 0.4.0+14.04.20140312.1 |
162 | 649 | (c++)"unity::scopes::internal::ScopeConfig::icon() const@Base" 0.4.0+14.04.20140312.1 | 677 | (c++)"unity::scopes::internal::ScopeConfig::icon() const@Base" 0.4.0+14.04.20140312.1 |
163 | 650 | (c++)"unity::scopes::internal::ScopeConfig::author() const@Base" 0.4.0+14.04.20140312.1 | 678 | (c++)"unity::scopes::internal::ScopeConfig::author() const@Base" 0.4.0+14.04.20140312.1 |
164 | 651 | (c++)"unity::scopes::internal::ScopeConfig::hot_key() const@Base" 0.4.0+14.04.20140312.1 | 679 | (c++)"unity::scopes::internal::ScopeConfig::hot_key() const@Base" 0.4.0+14.04.20140312.1 |
165 | 652 | (c++)"unity::scopes::internal::ScopeConfig::invisible() const@Base" 0.4.0+14.04.20140312.1 | 680 | (c++)"unity::scopes::internal::ScopeConfig::invisible() const@Base" 0.4.0+14.04.20140312.1 |
166 | 653 | (c++)"unity::scopes::internal::ScopeConfig::results_ttl_type() const@Base" 0.4.6+14.10.20140519 | ||
167 | 654 | (c++)"unity::scopes::internal::ScopeLoader::scope_base() const@Base" 0.4.0+14.04.20140312.1 | 681 | (c++)"unity::scopes::internal::ScopeLoader::scope_base() const@Base" 0.4.0+14.04.20140312.1 |
168 | 655 | (c++)"unity::scopes::internal::ScopeLoader::libpath() const@Base" 0.4.0+14.04.20140312.1 | 682 | (c++)"unity::scopes::internal::ScopeLoader::libpath() const@Base" 0.4.0+14.04.20140312.1 |
169 | 656 | (c++)"unity::scopes::internal::ScopeLoader::scope_id() const@Base" 0.4.2+14.04.20140404.2 | 683 | (c++)"unity::scopes::internal::ScopeLoader::scope_id() const@Base" 0.4.2+14.04.20140404.2 |
170 | @@ -693,6 +720,7 @@ | |||
171 | 693 | (c++)"unity::scopes::internal::ScopeMetadataImpl::search_hint() const@Base" 0.4.0+14.04.20140312.1 | 720 | (c++)"unity::scopes::internal::ScopeMetadataImpl::search_hint() const@Base" 0.4.0+14.04.20140312.1 |
172 | 694 | (c++)"unity::scopes::internal::ScopeMetadataImpl::display_name() const@Base" 0.4.0+14.04.20140312.1 | 721 | (c++)"unity::scopes::internal::ScopeMetadataImpl::display_name() const@Base" 0.4.0+14.04.20140312.1 |
173 | 695 | (c++)"unity::scopes::internal::ScopeMetadataImpl::scope_directory() const@Base" 0.4.2+14.04.20140404.2 | 722 | (c++)"unity::scopes::internal::ScopeMetadataImpl::scope_directory() const@Base" 0.4.2+14.04.20140404.2 |
174 | 723 | (c++)"unity::scopes::internal::ScopeMetadataImpl::results_ttl_type() const@Base" 0.4.6+14.10.20140519 | ||
175 | 696 | (c++)"unity::scopes::internal::ScopeMetadataImpl::appearance_attributes() const@Base" 0.4.2+14.04.20140404.2 | 724 | (c++)"unity::scopes::internal::ScopeMetadataImpl::appearance_attributes() const@Base" 0.4.2+14.04.20140404.2 |
176 | 697 | (c++)"unity::scopes::internal::ScopeMetadataImpl::art() const@Base" 0.4.0+14.04.20140312.1 | 725 | (c++)"unity::scopes::internal::ScopeMetadataImpl::art() const@Base" 0.4.0+14.04.20140312.1 |
177 | 698 | (c++)"unity::scopes::internal::ScopeMetadataImpl::icon() const@Base" 0.4.0+14.04.20140312.1 | 726 | (c++)"unity::scopes::internal::ScopeMetadataImpl::icon() const@Base" 0.4.0+14.04.20140312.1 |
178 | @@ -710,6 +738,7 @@ | |||
179 | 710 | (c++)"typeinfo for unity::scopes::SearchReply@Base" 0.4.0+14.04.20140312.1 | 738 | (c++)"typeinfo for unity::scopes::SearchReply@Base" 0.4.0+14.04.20140312.1 |
180 | 711 | (c++)"typeinfo for unity::scopes::ListenerBase@Base" 0.4.0+14.04.20140312.1 | 739 | (c++)"typeinfo for unity::scopes::ListenerBase@Base" 0.4.0+14.04.20140312.1 |
181 | 712 | (c++)"typeinfo for unity::scopes::PreviewReply@Base" 0.4.0+14.04.20140312.1 | 740 | (c++)"typeinfo for unity::scopes::PreviewReply@Base" 0.4.0+14.04.20140312.1 |
182 | 741 | (c++)"typeinfo for unity::scopes::RatingFilter@Base" 0replaceme | ||
183 | 713 | (c++)"typeinfo for unity::scopes::PreviewWidget@Base" 0.4.0+14.04.20140312.1 | 742 | (c++)"typeinfo for unity::scopes::PreviewWidget@Base" 0.4.0+14.04.20140312.1 |
184 | 714 | (c++)"typeinfo for unity::scopes::VariantBuilder@Base" 0.4.0+14.04.20140312.1 | 743 | (c++)"typeinfo for unity::scopes::VariantBuilder@Base" 0.4.0+14.04.20140312.1 |
185 | 715 | (c++)"typeinfo for unity::scopes::ConfigException@Base" 0.4.0+14.04.20140312.1 | 744 | (c++)"typeinfo for unity::scopes::ConfigException@Base" 0.4.0+14.04.20140312.1 |
186 | @@ -720,6 +749,7 @@ | |||
187 | 720 | (c++)"typeinfo for unity::scopes::TimeoutException@Base" 0.4.0+14.04.20140312.1 | 749 | (c++)"typeinfo for unity::scopes::TimeoutException@Base" 0.4.0+14.04.20140312.1 |
188 | 721 | (c++)"typeinfo for unity::scopes::CategorisedResult@Base" 0.4.0+14.04.20140312.1 | 750 | (c++)"typeinfo for unity::scopes::CategorisedResult@Base" 0.4.0+14.04.20140312.1 |
189 | 722 | (c++)"typeinfo for unity::scopes::NotFoundException@Base" 0.4.0+14.04.20140312.1 | 751 | (c++)"typeinfo for unity::scopes::NotFoundException@Base" 0.4.0+14.04.20140312.1 |
190 | 752 | (c++)"typeinfo for unity::scopes::RadioButtonsFilter@Base" 0replaceme | ||
191 | 723 | (c++)"typeinfo for unity::scopes::SearchListenerBase@Base" 0.4.0+14.04.20140312.1 | 753 | (c++)"typeinfo for unity::scopes::SearchListenerBase@Base" 0.4.0+14.04.20140312.1 |
192 | 724 | (c++)"typeinfo for unity::scopes::ActivationQueryBase@Base" 0.4.0+14.04.20140312.1 | 754 | (c++)"typeinfo for unity::scopes::ActivationQueryBase@Base" 0.4.0+14.04.20140312.1 |
193 | 725 | (c++)"typeinfo for unity::scopes::MiddlewareException@Base" 0.4.0+14.04.20140312.1 | 755 | (c++)"typeinfo for unity::scopes::MiddlewareException@Base" 0.4.0+14.04.20140312.1 |
194 | @@ -748,6 +778,7 @@ | |||
195 | 748 | (c++)"typeinfo name for unity::scopes::SearchReply@Base" 0.4.0+14.04.20140312.1 | 778 | (c++)"typeinfo name for unity::scopes::SearchReply@Base" 0.4.0+14.04.20140312.1 |
196 | 749 | (c++)"typeinfo name for unity::scopes::ListenerBase@Base" 0.4.0+14.04.20140312.1 | 779 | (c++)"typeinfo name for unity::scopes::ListenerBase@Base" 0.4.0+14.04.20140312.1 |
197 | 750 | (c++)"typeinfo name for unity::scopes::PreviewReply@Base" 0.4.0+14.04.20140312.1 | 780 | (c++)"typeinfo name for unity::scopes::PreviewReply@Base" 0.4.0+14.04.20140312.1 |
198 | 781 | (c++)"typeinfo name for unity::scopes::RatingFilter@Base" 0replaceme | ||
199 | 751 | (c++)"typeinfo name for unity::scopes::PreviewWidget@Base" 0.4.0+14.04.20140312.1 | 782 | (c++)"typeinfo name for unity::scopes::PreviewWidget@Base" 0.4.0+14.04.20140312.1 |
200 | 752 | (c++)"typeinfo name for unity::scopes::VariantBuilder@Base" 0.4.0+14.04.20140312.1 | 783 | (c++)"typeinfo name for unity::scopes::VariantBuilder@Base" 0.4.0+14.04.20140312.1 |
201 | 753 | (c++)"typeinfo name for unity::scopes::ConfigException@Base" 0.4.0+14.04.20140312.1 | 784 | (c++)"typeinfo name for unity::scopes::ConfigException@Base" 0.4.0+14.04.20140312.1 |
202 | @@ -758,6 +789,7 @@ | |||
203 | 758 | (c++)"typeinfo name for unity::scopes::TimeoutException@Base" 0.4.0+14.04.20140312.1 | 789 | (c++)"typeinfo name for unity::scopes::TimeoutException@Base" 0.4.0+14.04.20140312.1 |
204 | 759 | (c++)"typeinfo name for unity::scopes::CategorisedResult@Base" 0.4.0+14.04.20140312.1 | 790 | (c++)"typeinfo name for unity::scopes::CategorisedResult@Base" 0.4.0+14.04.20140312.1 |
205 | 760 | (c++)"typeinfo name for unity::scopes::NotFoundException@Base" 0.4.0+14.04.20140312.1 | 791 | (c++)"typeinfo name for unity::scopes::NotFoundException@Base" 0.4.0+14.04.20140312.1 |
206 | 792 | (c++)"typeinfo name for unity::scopes::RadioButtonsFilter@Base" 0replaceme | ||
207 | 761 | (c++)"typeinfo name for unity::scopes::SearchListenerBase@Base" 0.4.0+14.04.20140312.1 | 793 | (c++)"typeinfo name for unity::scopes::SearchListenerBase@Base" 0.4.0+14.04.20140312.1 |
208 | 762 | (c++)"typeinfo name for unity::scopes::ActivationQueryBase@Base" 0.4.0+14.04.20140312.1 | 794 | (c++)"typeinfo name for unity::scopes::ActivationQueryBase@Base" 0.4.0+14.04.20140312.1 |
209 | 763 | (c++)"typeinfo name for unity::scopes::MiddlewareException@Base" 0.4.0+14.04.20140312.1 | 795 | (c++)"typeinfo name for unity::scopes::MiddlewareException@Base" 0.4.0+14.04.20140312.1 |
210 | @@ -797,6 +829,7 @@ | |||
211 | 797 | (c++)"vtable for unity::scopes::SearchReply@Base" 0.4.0+14.04.20140312.1 | 829 | (c++)"vtable for unity::scopes::SearchReply@Base" 0.4.0+14.04.20140312.1 |
212 | 798 | (c++)"vtable for unity::scopes::ListenerBase@Base" 0.4.0+14.04.20140312.1 | 830 | (c++)"vtable for unity::scopes::ListenerBase@Base" 0.4.0+14.04.20140312.1 |
213 | 799 | (c++)"vtable for unity::scopes::PreviewReply@Base" 0.4.0+14.04.20140312.1 | 831 | (c++)"vtable for unity::scopes::PreviewReply@Base" 0.4.0+14.04.20140312.1 |
214 | 832 | (c++)"vtable for unity::scopes::RatingFilter@Base" 0replaceme | ||
215 | 800 | (c++)"vtable for unity::scopes::PreviewWidget@Base" 0.4.0+14.04.20140312.1 | 833 | (c++)"vtable for unity::scopes::PreviewWidget@Base" 0.4.0+14.04.20140312.1 |
216 | 801 | (c++)"vtable for unity::scopes::VariantBuilder@Base" 0.4.0+14.04.20140312.1 | 834 | (c++)"vtable for unity::scopes::VariantBuilder@Base" 0.4.0+14.04.20140312.1 |
217 | 802 | (c++)"vtable for unity::scopes::ConfigException@Base" 0.4.0+14.04.20140312.1 | 835 | (c++)"vtable for unity::scopes::ConfigException@Base" 0.4.0+14.04.20140312.1 |
218 | @@ -807,6 +840,7 @@ | |||
219 | 807 | (c++)"vtable for unity::scopes::TimeoutException@Base" 0.4.0+14.04.20140312.1 | 840 | (c++)"vtable for unity::scopes::TimeoutException@Base" 0.4.0+14.04.20140312.1 |
220 | 808 | (c++)"vtable for unity::scopes::CategorisedResult@Base" 0.4.0+14.04.20140312.1 | 841 | (c++)"vtable for unity::scopes::CategorisedResult@Base" 0.4.0+14.04.20140312.1 |
221 | 809 | (c++)"vtable for unity::scopes::NotFoundException@Base" 0.4.0+14.04.20140312.1 | 842 | (c++)"vtable for unity::scopes::NotFoundException@Base" 0.4.0+14.04.20140312.1 |
222 | 843 | (c++)"vtable for unity::scopes::RadioButtonsFilter@Base" 0replaceme | ||
223 | 810 | (c++)"vtable for unity::scopes::SearchListenerBase@Base" 0.4.0+14.04.20140312.1 | 844 | (c++)"vtable for unity::scopes::SearchListenerBase@Base" 0.4.0+14.04.20140312.1 |
224 | 811 | (c++)"vtable for unity::scopes::ActivationQueryBase@Base" 0.4.0+14.04.20140312.1 | 845 | (c++)"vtable for unity::scopes::ActivationQueryBase@Base" 0.4.0+14.04.20140312.1 |
225 | 812 | (c++)"vtable for unity::scopes::MiddlewareException@Base" 0.4.0+14.04.20140312.1 | 846 | (c++)"vtable for unity::scopes::MiddlewareException@Base" 0.4.0+14.04.20140312.1 |
226 | 813 | 847 | ||
227 | === modified file 'demo/client.cpp' | |||
228 | --- demo/client.cpp 2014-04-29 13:51:44 +0000 | |||
229 | +++ demo/client.cpp 2014-05-21 14:02:43 +0000 | |||
230 | @@ -422,10 +422,11 @@ | |||
231 | 422 | } | 422 | } |
232 | 423 | 423 | ||
233 | 424 | auto meta = r->get_metadata(scope_id); | 424 | auto meta = r->get_metadata(scope_id); |
238 | 425 | cout << "Scope metadata: " << endl; | 425 | cout << "Scope metadata: " << endl; |
239 | 426 | cout << "\tscope_id: " << meta.scope_id() << endl; | 426 | cout << "\tscope_id: " << meta.scope_id() << endl; |
240 | 427 | cout << "\tdisplay_name: " << meta.display_name() << endl; | 427 | cout << "\tdisplay_name: " << meta.display_name() << endl; |
241 | 428 | cout << "\tdescription: " << meta.description() << endl; | 428 | cout << "\tdescription: " << meta.description() << endl; |
242 | 429 | cout << "\tappearance attr: " << to_string(Variant(meta.appearance_attributes())) << endl; | ||
243 | 429 | string tmp; | 430 | string tmp; |
244 | 430 | try | 431 | try |
245 | 431 | { | 432 | { |
246 | 432 | 433 | ||
247 | === modified file 'demo/scopes/scope-A/scope-A.cpp' | |||
248 | --- demo/scopes/scope-A/scope-A.cpp 2014-04-29 11:20:57 +0000 | |||
249 | +++ demo/scopes/scope-A/scope-A.cpp 2014-05-21 14:02:43 +0000 | |||
250 | @@ -59,7 +59,7 @@ | |||
251 | 59 | reply->register_departments(departments); | 59 | reply->register_departments(departments); |
252 | 60 | 60 | ||
253 | 61 | Filters filters; | 61 | Filters filters; |
255 | 62 | auto filter = OptionSelectorFilter::create("f1", "Options"); | 62 | OptionSelectorFilter::SPtr filter = OptionSelectorFilter::create("f1", "Options"); |
256 | 63 | filter->add_option("1", "Option 1"); | 63 | filter->add_option("1", "Option 1"); |
257 | 64 | filter->add_option("2", "Option 2"); | 64 | filter->add_option("2", "Option 2"); |
258 | 65 | filters.push_back(filter); | 65 | filters.push_back(filter); |
259 | 66 | 66 | ||
260 | === modified file 'doc/tutorial.dox' | |||
261 | --- doc/tutorial.dox 2014-05-08 10:47:45 +0000 | |||
262 | +++ doc/tutorial.dox 2014-05-21 14:02:43 +0000 | |||
263 | @@ -188,7 +188,7 @@ | |||
264 | 188 | and \link unity::scopes::SearchReply::push push\endlink. | 188 | and \link unity::scopes::SearchReply::push push\endlink. |
265 | 189 | 189 | ||
266 | 190 | The \link unity::scopes::SearchReply::register_category register_category\endlink method is a factory method for creating new categories (see | 190 | The \link unity::scopes::SearchReply::register_category register_category\endlink method is a factory method for creating new categories (see |
268 | 191 | \link unity::scopes::Category\endlink). Categories can be created at any point during query processing inside run method, but it's recommended to create | 191 | \link unity::scopes::Category\endlink). Categories can be created at any point during query processing inside run method, but we recommend to create |
269 | 192 | them as soon as possible (ideally as soon as they are known to the scope). | 192 | them as soon as possible (ideally as soon as they are known to the scope). |
270 | 193 | 193 | ||
271 | 194 | When creating a category, one of its parameters is a \link unity::scopes::CategoryRenderer \endlink instance, | 194 | When creating a category, one of its parameters is a \link unity::scopes::CategoryRenderer \endlink instance, |
272 | @@ -552,29 +552,39 @@ | |||
273 | 552 | restart scope-registry | 552 | restart scope-registry |
274 | 553 | \endverbatim | 553 | \endverbatim |
275 | 554 | 554 | ||
277 | 555 | The scope will be installed under one of the "scopes directories" | 555 | Scopes are installed under one of the "scopes directories" |
278 | 556 | scanned by the scope registry. Currently these default to: | 556 | scanned by the scope registry. Currently these default to: |
279 | 557 | 557 | ||
280 | 558 | <ul> | 558 | <ul> |
281 | 559 | <li>/usr/lib/${arch}/unity-scopes</li> | 559 | <li>/usr/lib/${arch}/unity-scopes</li> |
282 | 560 | <li>/custom/lib/${arch}/unity-scopes</li> | 560 | <li>/custom/lib/${arch}/unity-scopes</li> |
284 | 561 | <!-- <li>??? Click packages?</li> --> | 561 | <li>$HOME/.local/share/unity-scopes</li> |
285 | 562 | </ul> | 562 | </ul> |
286 | 563 | 563 | ||
290 | 564 | Individual scopes are installed into a subdirectory matching the | 564 | The `/usr/lib` directory is for scopes that are pre-installed by Canonical. |
291 | 565 | scope's name. At a minimum, the directory structure should contain | 565 | The `/custom/lib` directory is for scopes that pre-installed by OEMs. |
292 | 566 | the following: | 566 | The `$HOME/.local` directory is for scopes that are installed from click packages. |
293 | 567 | |||
294 | 568 | Individual scopes are installed into subdirectories of these | ||
295 | 569 | installation directories. The name of the subdirectory containing | ||
296 | 570 | a scope's `.ini` and `.so` files can be anything but, to avoid name clashes, | ||
297 | 571 | we strongly suggest something that is unique, such as `com.canonical.scopes.scopename`. | ||
298 | 572 | At a minimum, the directory structure must contain the following: | ||
299 | 567 | 573 | ||
300 | 568 | -+- ${scopesdir} | 574 | -+- ${scopesdir} |
302 | 569 | `-+- scopename | 575 | `-+- subdirectory |
303 | 570 | |--- scopename.ini | 576 | |--- scopename.ini |
305 | 571 | `--- libscopename.so | 577 | `--- <library>.so |
306 | 572 | 578 | ||
309 | 573 | That is, a scope metadata file and a shared library containing the | 579 | That is, each subdirectory must contain a scope `.ini` file and a shared library containing the |
310 | 574 | scope code. The scope author is free to ship additional data in this | 580 | scope code. The scope author is free to ship additional data in this |
311 | 575 | directory (e.g. icons and screenshots). | 581 | directory (e.g. icons and screenshots). |
312 | 576 | 582 | ||
314 | 577 | The scope metadata file uses the standard ini file format, with the | 583 | The name of the scope's `.ini` file _must_ be a unique ID for the scope. We _strongly_ |
315 | 584 | suggest to use a unique identifier, such as `com.canonical.scopes.scopename`, to avoid | ||
316 | 585 | clashes with scopes created by other developers. | ||
317 | 586 | |||
318 | 587 | The scope `.ini` file uses the standard `.ini` file format, with the | ||
319 | 578 | following keys: | 588 | following keys: |
320 | 579 | 589 | ||
321 | 580 | [ScopeConfig] | 590 | [ScopeConfig] |
322 | @@ -585,8 +595,22 @@ | |||
323 | 585 | Art = path to screenshot of the scope | 595 | Art = path to screenshot of the scope |
324 | 586 | SearchHint = hint text displayed to user when viewing scope | 596 | SearchHint = hint text displayed to user when viewing scope |
325 | 587 | HotKey = | 597 | HotKey = |
328 | 588 | 598 | ResultsTtlType = None, Small, Medium, or Large | |
329 | 589 | In addition to allowing the registry to make the scope available, this information controls how the scope appears in the "Scopes" scope. | 599 | |
330 | 600 | [Appearance] | ||
331 | 601 | TODO: document valid attributes | ||
332 | 602 | |||
333 | 603 | The `ScopeConfig` group is mandatory and must contain settings for at least `DisplayName`, `Description`, and Author. | ||
334 | 604 | `DisplayName` and `Description` can (and should) be localized. For example: | ||
335 | 605 | |||
336 | 606 | `Description[de] = Fußballergebnisse` | ||
337 | 607 | |||
338 | 608 | In addition to allowing the registry to make the scope available, this information controls how the scope appears | ||
339 | 609 | in the "Scopes" scope. | ||
340 | 610 | |||
341 | 611 | The name of of the scope's `.so` file can be `libscopename.so`, `scopename.so`, or simply `scope.so`. For example, | ||
342 | 612 | for a scope named `Fred`, the names `libFred.so`, `Fred.so`, and `scope.so` are acceptable. (No other library | ||
343 | 613 | names are valid.) | ||
344 | 590 | 614 | ||
345 | 591 | \subsection scopetool Previewing scope | 615 | \subsection scopetool Previewing scope |
346 | 592 | 616 | ||
347 | @@ -599,16 +623,17 @@ | |||
348 | 599 | sudo apt-get install unity-scope-tool | 623 | sudo apt-get install unity-scope-tool |
349 | 600 | \endverbatim | 624 | \endverbatim |
350 | 601 | 625 | ||
354 | 602 | After installation, you can run the scope-tool with a parameter specifying | 626 | After installation, you can run the scope-tool with a parameter specifying the |
355 | 603 | path to your scope configuration file (for example `unity-scope-tool ~/dev/myscope/build/myscope.ini`). If a binary for your scope can be found in the same | 627 | path to your scope configuration file (for example `unity-scope-tool ~/dev/myscope/build/myscope.ini`). |
356 | 604 | directory (ie there's `~/dev/myscope/build/libmyscope.so`), the scope-tool will | 628 | If a binary for your scope can be found in the same |
357 | 629 | directory, the scope-tool will | ||
358 | 605 | display surfacing and search results provided by your scope, and allow you to | 630 | display surfacing and search results provided by your scope, and allow you to |
359 | 606 | perform searches, invoke previews and actions within previews. | 631 | perform searches, invoke previews and actions within previews. |
360 | 607 | 632 | ||
363 | 608 | Note that the scope-tool is using the same rendering mechanism as Unity | 633 | Note that the scope-tool uses the same rendering mechanism as Unity |
364 | 609 | itself, and therefore what you see in the scope-tool is what you get in Unity. | 634 | itself and, therefore, what you see in the scope-tool is what you get in Unity. |
365 | 610 | It can also be used to fine-tune the category definitions, as it allows you | 635 | It can also be used to fine-tune the category definitions, as it allows you |
367 | 611 | to manipulate the definitions on the fly, and once you're happy with the result | 636 | to manipulate the definitions on the fly. Once you are happy with the result |
368 | 612 | you can just copy the JSON definition back into your scope | 637 | you can just copy the JSON definition back into your scope |
369 | 613 | (see unity::scopes::CategoryRenderer::CategoryRenderer()). | 638 | (see unity::scopes::CategoryRenderer::CategoryRenderer()). |
370 | 614 | 639 | ||
371 | 615 | 640 | ||
372 | === modified file 'include/unity/scopes/OptionSelectorFilter.h' | |||
373 | --- include/unity/scopes/OptionSelectorFilter.h 2014-05-08 16:10:18 +0000 | |||
374 | +++ include/unity/scopes/OptionSelectorFilter.h 2014-05-21 14:02:43 +0000 | |||
375 | @@ -57,7 +57,7 @@ | |||
376 | 57 | \param multi_select If true, the filter permits more than option to be selected; otherwise, only a single | 57 | \param multi_select If true, the filter permits more than option to be selected; otherwise, only a single |
377 | 58 | option can be selected. | 58 | option can be selected. |
378 | 59 | */ | 59 | */ |
380 | 60 | static OptionSelectorFilter::SPtr create(std::string const& id, std::string const& label, bool multi_select = false); | 60 | static OptionSelectorFilter::UPtr create(std::string const& id, std::string const& label, bool multi_select = false); |
381 | 61 | 61 | ||
382 | 62 | /** | 62 | /** |
383 | 63 | \brief Get the label of this filter. | 63 | \brief Get the label of this filter. |
384 | @@ -84,6 +84,13 @@ | |||
385 | 84 | std::list<FilterOption::SCPtr> options() const; | 84 | std::list<FilterOption::SCPtr> options() const; |
386 | 85 | 85 | ||
387 | 86 | /** | 86 | /** |
388 | 87 | \brief Check if an option is active for this filter. | ||
389 | 88 | \param filter_state The state of filters | ||
390 | 89 | \return true if an option is active | ||
391 | 90 | */ | ||
392 | 91 | bool has_active_option(FilterState const& filter_state) const; | ||
393 | 92 | |||
394 | 93 | /** | ||
395 | 87 | \brief Get active options from an instance of FilterState for this filter. | 94 | \brief Get active options from an instance of FilterState for this filter. |
396 | 88 | \return The set of selected filter options. | 95 | \return The set of selected filter options. |
397 | 89 | */ | 96 | */ |
398 | 90 | 97 | ||
399 | === added file 'include/unity/scopes/RadioButtonsFilter.h' | |||
400 | --- include/unity/scopes/RadioButtonsFilter.h 1970-01-01 00:00:00 +0000 | |||
401 | +++ include/unity/scopes/RadioButtonsFilter.h 2014-05-21 14:02:43 +0000 | |||
402 | @@ -0,0 +1,124 @@ | |||
403 | 1 | /* | ||
404 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
405 | 3 | * | ||
406 | 4 | * This program is free software: you can redistribute it and/or modify | ||
407 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
408 | 6 | * published by the Free Software Foundation. | ||
409 | 7 | * | ||
410 | 8 | * This program is distributed in the hope that it will be useful, | ||
411 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
412 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
413 | 11 | * GNU Lesser General Public License for more details. | ||
414 | 12 | * | ||
415 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
416 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
417 | 15 | * | ||
418 | 16 | * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com> | ||
419 | 17 | */ | ||
420 | 18 | |||
421 | 19 | #ifndef UNITY_SCOPES_RADIOBUTTONSFILTER_H | ||
422 | 20 | #define UNITY_SCOPES_RADIOBUTTONSFILTER_H | ||
423 | 21 | |||
424 | 22 | #include <unity/scopes/FilterBase.h> | ||
425 | 23 | #include <unity/scopes/FilterOption.h> | ||
426 | 24 | |||
427 | 25 | namespace unity | ||
428 | 26 | { | ||
429 | 27 | |||
430 | 28 | namespace scopes | ||
431 | 29 | { | ||
432 | 30 | |||
433 | 31 | class FilterState; | ||
434 | 32 | |||
435 | 33 | namespace internal | ||
436 | 34 | { | ||
437 | 35 | |||
438 | 36 | class RadioButtonsFilterImpl; | ||
439 | 37 | |||
440 | 38 | } | ||
441 | 39 | |||
442 | 40 | /** | ||
443 | 41 | \brief A filter that displays mutually exclusive list of options. | ||
444 | 42 | |||
445 | 43 | Displays filter with a set of options and allows only one option to be selected at a time. | ||
446 | 44 | */ | ||
447 | 45 | class UNITY_API RadioButtonsFilter : public FilterBase | ||
448 | 46 | { | ||
449 | 47 | public: | ||
450 | 48 | /// @cond | ||
451 | 49 | UNITY_DEFINES_PTRS(RadioButtonsFilter); | ||
452 | 50 | /// @endcond | ||
453 | 51 | |||
454 | 52 | /** | ||
455 | 53 | \brief Creates RadioButtonsFilter filter. | ||
456 | 54 | |||
457 | 55 | Creates an empty RadioButtonsFilter filter. Use unity::scopes::RadioButtonsFilter::add_option() to add options to it. | ||
458 | 56 | \param id A unique identifier for the filter that can be used to identify it later among several filters. | ||
459 | 57 | \param label A display label for this filter | ||
460 | 58 | \return Instance of RadioButtonsFilter | ||
461 | 59 | */ | ||
462 | 60 | static RadioButtonsFilter::UPtr create(std::string const& id, std::string const& label); | ||
463 | 61 | |||
464 | 62 | /** | ||
465 | 63 | \brief Adds a new option to the filter. | ||
466 | 64 | |||
467 | 65 | \param id A unique identifier of the option. | ||
468 | 66 | \param label A display label for the option | ||
469 | 67 | \return Instance of FilterOption | ||
470 | 68 | */ | ||
471 | 69 | FilterOption::SCPtr add_option(std::string const& id, std::string const& label); | ||
472 | 70 | |||
473 | 71 | /** | ||
474 | 72 | \brief Get the label of this filter. | ||
475 | 73 | \return The filter label. | ||
476 | 74 | */ | ||
477 | 75 | std::string label() const; | ||
478 | 76 | |||
479 | 77 | /** | ||
480 | 78 | \brief Get active option from an instance of FilterState for this filter. | ||
481 | 79 | \return The active option or nullptr if no option is active. | ||
482 | 80 | */ | ||
483 | 81 | FilterOption::SCPtr active_option(FilterState const& filter_state) const; | ||
484 | 82 | |||
485 | 83 | /** | ||
486 | 84 | \brief Check if active options. | ||
487 | 85 | \param filter_state The state of filters | ||
488 | 86 | \return true if there is at least one option active | ||
489 | 87 | */ | ||
490 | 88 | bool has_active_option(FilterState const& filter_state) const; | ||
491 | 89 | |||
492 | 90 | |||
493 | 91 | /** | ||
494 | 92 | \brief Get all options of this filter, in the order they were added. | ||
495 | 93 | \return The list of options. | ||
496 | 94 | */ | ||
497 | 95 | std::list<FilterOption::SCPtr> options() const; | ||
498 | 96 | |||
499 | 97 | /** | ||
500 | 98 | \brief Marks given FilterOption of this filter instance as active (or not active) in a FilterState object. | ||
501 | 99 | |||
502 | 100 | Records the given FilterOption as "selected" in the FilterState. This is meant to be used to modify a | ||
503 | 101 | FilterState received with a search request before sending it back to the client (UI shell). | ||
504 | 102 | Only one option can be active at a time - marking an option active automatically deactivates any other option. | ||
505 | 103 | */ | ||
506 | 104 | void update_state(FilterState& filter_state, FilterOption::SCPtr option, bool active) const; | ||
507 | 105 | |||
508 | 106 | /** | ||
509 | 107 | \brief Marks an option of a filter active/inactive in a FilterState object, without having an instance of OptionSelectorFilter. | ||
510 | 108 | |||
511 | 109 | Updates an instance of FilterState, without the need for an OptionSelectorFilter instance. This is meant | ||
512 | 110 | to be used when creating a canned Query that references another scope. | ||
513 | 111 | */ | ||
514 | 112 | static void update_state(FilterState& filter_state, std::string const& filter_id, std::string const& option_id, bool value); | ||
515 | 113 | |||
516 | 114 | private: | ||
517 | 115 | RadioButtonsFilter(internal::RadioButtonsFilterImpl*); | ||
518 | 116 | internal::RadioButtonsFilterImpl* fwd() const; | ||
519 | 117 | friend class internal::RadioButtonsFilterImpl; | ||
520 | 118 | }; | ||
521 | 119 | |||
522 | 120 | } // namespace scopes | ||
523 | 121 | |||
524 | 122 | } // namespace unity | ||
525 | 123 | |||
526 | 124 | #endif | ||
527 | 0 | 125 | ||
528 | === modified file 'include/unity/scopes/RangeInputFilter.h' | |||
529 | --- include/unity/scopes/RangeInputFilter.h 2014-05-09 11:26:27 +0000 | |||
530 | +++ include/unity/scopes/RangeInputFilter.h 2014-05-21 14:02:43 +0000 | |||
531 | @@ -124,10 +124,10 @@ | |||
532 | 124 | \brief Store start and end value in the filter state, without having an instance of RangeInputFilter. | 124 | \brief Store start and end value in the filter state, without having an instance of RangeInputFilter. |
533 | 125 | 125 | ||
534 | 126 | Updates filter_state with start and end values without an instance of RangeInputFilter. This is meant | 126 | Updates filter_state with start and end values without an instance of RangeInputFilter. This is meant |
535 | 127 | for the explanation of this method. | ||
536 | 127 | to be used when creating a CannedQuery that points to a foreign scope. | 128 | to be used when creating a CannedQuery that points to a foreign scope. |
537 | 128 | 129 | ||
538 | 129 | See the documentation of unity::scopes::update_state(FilterState const& filter_state, Variant const& start_value, Variant const& end_value) | 130 | See the documentation of unity::scopes::update_state(FilterState const& filter_state, Variant const& start_value, Variant const& end_value) |
539 | 130 | for the explanation of this method. | ||
540 | 131 | 131 | ||
541 | 132 | \param filter_state FilterState instance to update | 132 | \param filter_state FilterState instance to update |
542 | 133 | \param filter_id Unique identifier of filter | 133 | \param filter_id Unique identifier of filter |
543 | 134 | 134 | ||
544 | === added file 'include/unity/scopes/RatingFilter.h' | |||
545 | --- include/unity/scopes/RatingFilter.h 1970-01-01 00:00:00 +0000 | |||
546 | +++ include/unity/scopes/RatingFilter.h 2014-05-21 14:02:43 +0000 | |||
547 | @@ -0,0 +1,180 @@ | |||
548 | 1 | /* | ||
549 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
550 | 3 | * | ||
551 | 4 | * This program is free software: you can redistribute it and/or modify | ||
552 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
553 | 6 | * published by the Free Software Foundation. | ||
554 | 7 | * | ||
555 | 8 | * This program is distributed in the hope that it will be useful, | ||
556 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
557 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
558 | 11 | * GNU Lesser General Public License for more details. | ||
559 | 12 | * | ||
560 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
561 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
562 | 15 | * | ||
563 | 16 | * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com> | ||
564 | 17 | */ | ||
565 | 18 | |||
566 | 19 | #ifndef UNITY_SCOPES_RATINGFILTER_H | ||
567 | 20 | #define UNITY_SCOPES_RATINGFILTER_H | ||
568 | 21 | |||
569 | 22 | #include <unity/scopes/FilterBase.h> | ||
570 | 23 | #include <unity/scopes/FilterOption.h> | ||
571 | 24 | |||
572 | 25 | namespace unity | ||
573 | 26 | { | ||
574 | 27 | |||
575 | 28 | namespace scopes | ||
576 | 29 | { | ||
577 | 30 | |||
578 | 31 | class FilterState; | ||
579 | 32 | |||
580 | 33 | namespace internal | ||
581 | 34 | { | ||
582 | 35 | |||
583 | 36 | class RatingFilterImpl; | ||
584 | 37 | |||
585 | 38 | } | ||
586 | 39 | |||
587 | 40 | /** | ||
588 | 41 | \brief A filter that allows for rating-based selection. | ||
589 | 42 | |||
590 | 43 | Displays filter with a set of options, where every option has a label and icon. | ||
591 | 44 | Only one option can be active at a time. The active option uses the icon in "on" state | ||
592 | 45 | (see unity::scopes::RatingFilter::set_on_icon() ). All other icons are "off" (see unity::scopes::RatingFilter::set_off_icon() ). | ||
593 | 46 | By default, "on" and "off" icons are bright and dim star respectively. | ||
594 | 47 | |||
595 | 48 | This filter is best suited for rating-based filtering. | ||
596 | 49 | */ | ||
597 | 50 | class UNITY_API RatingFilter : public FilterBase | ||
598 | 51 | { | ||
599 | 52 | public: | ||
600 | 53 | /// @cond | ||
601 | 54 | UNITY_DEFINES_PTRS(RatingFilter); | ||
602 | 55 | /// @endcond | ||
603 | 56 | |||
604 | 57 | /** | ||
605 | 58 | \brief Creates RatingFilter widget. | ||
606 | 59 | |||
607 | 60 | Creates an empty RatingFilter widget. Use unity::scopes::RatingFilter::add_option() to add rating options to it. | ||
608 | 61 | \param id A unique identifier for the filter that can be used to identify it later among several filters. | ||
609 | 62 | \param label A display label for this filter | ||
610 | 63 | \return Instance of RatingFilter | ||
611 | 64 | */ | ||
612 | 65 | static RatingFilter::UPtr create(std::string const& id, std::string const& label); | ||
613 | 66 | |||
614 | 67 | /** | ||
615 | 68 | \brief Creates RatingFilter widget. | ||
616 | 69 | |||
617 | 70 | Creates a RatingFilter widget and populates it with some standard rating options. | ||
618 | 71 | This is a convienience factory method, that fills RatingFilter in with options for ratings | ||
619 | 72 | from 1 up to top_rating. Options are created with identifiers "1", "2" and so on, and labels | ||
620 | 73 | "1+", "2+" etc., except for that last label, which is just the number (no plus sign). The maximum top_rating | ||
621 | 74 | allowed is 10. | ||
622 | 75 | |||
623 | 76 | \param id A unique identifier for the filter that can be used to identify it later among several filters. | ||
624 | 77 | \param label A display label for this filter | ||
625 | 78 | \param top_rating The maximum rating allowed. | ||
626 | 79 | \return Instance of RatingFilter | ||
627 | 80 | */ | ||
628 | 81 | static RatingFilter::UPtr create(std::string const& id, std::string const& label, int top_rating); | ||
629 | 82 | |||
630 | 83 | /** | ||
631 | 84 | \brief Adds a new option to the filter. | ||
632 | 85 | |||
633 | 86 | \param id A unique identifier of the option. | ||
634 | 87 | \param label A display label for the option | ||
635 | 88 | \return Instance of FilterOption | ||
636 | 89 | */ | ||
637 | 90 | FilterOption::SCPtr add_option(std::string const& id, std::string const& label); | ||
638 | 91 | |||
639 | 92 | /** | ||
640 | 93 | \brief Set a custom icon for the "on" state. | ||
641 | 94 | |||
642 | 95 | If not set, a star icon will be used by default. | ||
643 | 96 | |||
644 | 97 | \param on_icon icon uri | ||
645 | 98 | */ | ||
646 | 99 | void set_on_icon(std::string const& on_icon); | ||
647 | 100 | |||
648 | 101 | /** | ||
649 | 102 | \brief Set a custom icon for the "off" state. | ||
650 | 103 | |||
651 | 104 | If not set, a dim star icon will be used by default. | ||
652 | 105 | |||
653 | 106 | \param off_icon icon uri | ||
654 | 107 | */ | ||
655 | 108 | void set_off_icon(std::string const& off_icon); | ||
656 | 109 | |||
657 | 110 | /** | ||
658 | 111 | \brief Get the label of this filter. | ||
659 | 112 | \return The filter label. | ||
660 | 113 | */ | ||
661 | 114 | std::string label() const; | ||
662 | 115 | |||
663 | 116 | /** | ||
664 | 117 | \brief Get custom icon for the "on" state. | ||
665 | 118 | |||
666 | 119 | If empty, then the default icon will be used. | ||
667 | 120 | |||
668 | 121 | \return icon uri or empty string | ||
669 | 122 | */ | ||
670 | 123 | std::string on_icon() const; | ||
671 | 124 | |||
672 | 125 | /** | ||
673 | 126 | \brief Get custom icon for the "off" state. | ||
674 | 127 | |||
675 | 128 | If empty, then the default icon will be used. | ||
676 | 129 | |||
677 | 130 | \return icon uri or empty string | ||
678 | 131 | */ | ||
679 | 132 | std::string off_icon() const; | ||
680 | 133 | |||
681 | 134 | /** | ||
682 | 135 | \brief Get all options of this filter, in the order they were added. | ||
683 | 136 | \return The list of options. | ||
684 | 137 | */ | ||
685 | 138 | std::list<FilterOption::SCPtr> options() const; | ||
686 | 139 | |||
687 | 140 | /** | ||
688 | 141 | \brief Check if a rating option is active. | ||
689 | 142 | \param filter_state The state of filters | ||
690 | 143 | \return true if a rating option is active. | ||
691 | 144 | */ | ||
692 | 145 | bool has_active_rating(FilterState const& filter_state) const; | ||
693 | 146 | |||
694 | 147 | /** | ||
695 | 148 | \brief Get active option from an instance of FilterState for this filter. | ||
696 | 149 | \return The active option or nullptr if no option is active. | ||
697 | 150 | */ | ||
698 | 151 | FilterOption::SCPtr active_rating(FilterState const& filter_state) const; | ||
699 | 152 | |||
700 | 153 | /** | ||
701 | 154 | \brief Marks given FilterOption of this filter instance as active (or not active) in a FilterState object. | ||
702 | 155 | |||
703 | 156 | Records the given FilterOption as "selected" in the FilterState. This is meant to be used to modify a | ||
704 | 157 | FilterState received with a search request before sending it back to the client (UI shell). | ||
705 | 158 | Only one option can be active at a time - marking an option active automatically deactivates any other option. | ||
706 | 159 | */ | ||
707 | 160 | void update_state(FilterState& filter_state, FilterOption::SCPtr option, bool active) const; | ||
708 | 161 | |||
709 | 162 | /** | ||
710 | 163 | \brief Marks an option of a filter active/inactive in a FilterState object, without having an instance of OptionSelectorFilter. | ||
711 | 164 | |||
712 | 165 | Updates an instance of FilterState, without the need for an OptionSelectorFilter instance. This is meant | ||
713 | 166 | to be used when creating a canned Query that references another scope. | ||
714 | 167 | */ | ||
715 | 168 | static void update_state(FilterState& filter_state, std::string const& filter_id, std::string const& option_id, bool value); | ||
716 | 169 | |||
717 | 170 | private: | ||
718 | 171 | RatingFilter(internal::RatingFilterImpl*); | ||
719 | 172 | internal::RatingFilterImpl* fwd() const; | ||
720 | 173 | friend class internal::RatingFilterImpl; | ||
721 | 174 | }; | ||
722 | 175 | |||
723 | 176 | } // namespace scopes | ||
724 | 177 | |||
725 | 178 | } // namespace unity | ||
726 | 179 | |||
727 | 180 | #endif | ||
728 | 0 | 181 | ||
729 | === modified file 'include/unity/scopes/internal/FilterBaseImpl.h' | |||
730 | --- include/unity/scopes/internal/FilterBaseImpl.h 2014-05-02 10:19:46 +0000 | |||
731 | +++ include/unity/scopes/internal/FilterBaseImpl.h 2014-05-21 14:02:43 +0000 | |||
732 | @@ -47,6 +47,7 @@ | |||
733 | 47 | static FilterBase::SCPtr deserialize(VariantMap const& var); | 47 | static FilterBase::SCPtr deserialize(VariantMap const& var); |
734 | 48 | static VariantArray serialize_filters(Filters const& filters); | 48 | static VariantArray serialize_filters(Filters const& filters); |
735 | 49 | static Filters deserialize_filters(VariantArray const& var); | 49 | static Filters deserialize_filters(VariantArray const& var); |
736 | 50 | static void validate_filters(Filters const& filters); | ||
737 | 50 | 51 | ||
738 | 51 | protected: | 52 | protected: |
739 | 52 | virtual void serialize(VariantMap& var) const = 0; | 53 | virtual void serialize(VariantMap& var) const = 0; |
740 | 53 | 54 | ||
741 | === added file 'include/unity/scopes/internal/MWPublisher.h' | |||
742 | --- include/unity/scopes/internal/MWPublisher.h 1970-01-01 00:00:00 +0000 | |||
743 | +++ include/unity/scopes/internal/MWPublisher.h 2014-05-21 14:02:43 +0000 | |||
744 | @@ -0,0 +1,55 @@ | |||
745 | 1 | /* | ||
746 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
747 | 3 | * | ||
748 | 4 | * This program is free software: you can redistribute it and/or modify | ||
749 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
750 | 6 | * published by the Free Software Foundation. | ||
751 | 7 | * | ||
752 | 8 | * This program is distributed in the hope that it will be useful, | ||
753 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
754 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
755 | 11 | * GNU Lesser General Public License for more details. | ||
756 | 12 | * | ||
757 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
758 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
759 | 15 | * | ||
760 | 16 | * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com> | ||
761 | 17 | */ | ||
762 | 18 | |||
763 | 19 | #ifndef UNITY_SCOPES_INTERNAL_MWPUBLISHER_H | ||
764 | 20 | #define UNITY_SCOPES_INTERNAL_MWPUBLISHER_H | ||
765 | 21 | |||
766 | 22 | #include <unity/util/DefinesPtrs.h> | ||
767 | 23 | #include <unity/util/NonCopyable.h> | ||
768 | 24 | |||
769 | 25 | namespace unity | ||
770 | 26 | { | ||
771 | 27 | |||
772 | 28 | namespace scopes | ||
773 | 29 | { | ||
774 | 30 | |||
775 | 31 | namespace internal | ||
776 | 32 | { | ||
777 | 33 | |||
778 | 34 | class MWPublisher | ||
779 | 35 | { | ||
780 | 36 | public: | ||
781 | 37 | NONCOPYABLE(MWPublisher); | ||
782 | 38 | UNITY_DEFINES_PTRS(MWPublisher); | ||
783 | 39 | |||
784 | 40 | virtual ~MWPublisher(); | ||
785 | 41 | |||
786 | 42 | virtual std::string endpoint() const = 0; | ||
787 | 43 | virtual void send_message(std::string const& message, std::string const& topic = "") = 0; | ||
788 | 44 | |||
789 | 45 | protected: | ||
790 | 46 | MWPublisher(); | ||
791 | 47 | }; | ||
792 | 48 | |||
793 | 49 | } // namespace internal | ||
794 | 50 | |||
795 | 51 | } // namespace scopes | ||
796 | 52 | |||
797 | 53 | } // namespace unity | ||
798 | 54 | |||
799 | 55 | #endif // UNITY_SCOPES_INTERNAL_MWPUBLISHER_H | ||
800 | 0 | 56 | ||
801 | === added file 'include/unity/scopes/internal/MWSubscriber.h' | |||
802 | --- include/unity/scopes/internal/MWSubscriber.h 1970-01-01 00:00:00 +0000 | |||
803 | +++ include/unity/scopes/internal/MWSubscriber.h 2014-05-21 14:02:43 +0000 | |||
804 | @@ -0,0 +1,57 @@ | |||
805 | 1 | /* | ||
806 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
807 | 3 | * | ||
808 | 4 | * This program is free software: you can redistribute it and/or modify | ||
809 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
810 | 6 | * published by the Free Software Foundation. | ||
811 | 7 | * | ||
812 | 8 | * This program is distributed in the hope that it will be useful, | ||
813 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
814 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
815 | 11 | * GNU Lesser General Public License for more details. | ||
816 | 12 | * | ||
817 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
818 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
819 | 15 | * | ||
820 | 16 | * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com> | ||
821 | 17 | */ | ||
822 | 18 | |||
823 | 19 | #ifndef UNITY_SCOPES_INTERNAL_MWSUBSCRIBER_H | ||
824 | 20 | #define UNITY_SCOPES_INTERNAL_MWSUBSCRIBER_H | ||
825 | 21 | |||
826 | 22 | #include <unity/util/DefinesPtrs.h> | ||
827 | 23 | #include <unity/util/NonCopyable.h> | ||
828 | 24 | |||
829 | 25 | namespace unity | ||
830 | 26 | { | ||
831 | 27 | |||
832 | 28 | namespace scopes | ||
833 | 29 | { | ||
834 | 30 | |||
835 | 31 | namespace internal | ||
836 | 32 | { | ||
837 | 33 | |||
838 | 34 | typedef std::function<void(std::string const& message)> SubscriberCallback; | ||
839 | 35 | |||
840 | 36 | class MWSubscriber | ||
841 | 37 | { | ||
842 | 38 | public: | ||
843 | 39 | NONCOPYABLE(MWSubscriber); | ||
844 | 40 | UNITY_DEFINES_PTRS(MWSubscriber); | ||
845 | 41 | |||
846 | 42 | virtual ~MWSubscriber(); | ||
847 | 43 | |||
848 | 44 | virtual std::string endpoint() const = 0; | ||
849 | 45 | virtual void set_message_callback(SubscriberCallback callback) = 0; | ||
850 | 46 | |||
851 | 47 | protected: | ||
852 | 48 | MWSubscriber(); | ||
853 | 49 | }; | ||
854 | 50 | |||
855 | 51 | } // namespace internal | ||
856 | 52 | |||
857 | 53 | } // namespace scopes | ||
858 | 54 | |||
859 | 55 | } // namespace unity | ||
860 | 56 | |||
861 | 57 | #endif // UNITY_SCOPES_INTERNAL_MWSUBSCRIBER_H | ||
862 | 0 | 58 | ||
863 | === modified file 'include/unity/scopes/internal/MiddlewareBase.h' | |||
864 | --- include/unity/scopes/internal/MiddlewareBase.h 2014-05-08 12:55:26 +0000 | |||
865 | +++ include/unity/scopes/internal/MiddlewareBase.h 2014-05-21 14:02:43 +0000 | |||
866 | @@ -20,11 +20,13 @@ | |||
867 | 20 | #define UNITY_SCOPES_INTERNAL_MIDDLEWAREBASE_H | 20 | #define UNITY_SCOPES_INTERNAL_MIDDLEWAREBASE_H |
868 | 21 | 21 | ||
869 | 22 | #include <unity/scopes/internal/MWObjectProxyFwd.h> | 22 | #include <unity/scopes/internal/MWObjectProxyFwd.h> |
870 | 23 | #include <unity/scopes/internal/MWPublisher.h> | ||
871 | 23 | #include <unity/scopes/internal/MWQueryCtrlProxyFwd.h> | 24 | #include <unity/scopes/internal/MWQueryCtrlProxyFwd.h> |
872 | 24 | #include <unity/scopes/internal/MWQueryProxyFwd.h> | 25 | #include <unity/scopes/internal/MWQueryProxyFwd.h> |
873 | 25 | #include <unity/scopes/internal/MWRegistryProxyFwd.h> | 26 | #include <unity/scopes/internal/MWRegistryProxyFwd.h> |
874 | 26 | #include <unity/scopes/internal/MWScopeProxyFwd.h> | 27 | #include <unity/scopes/internal/MWScopeProxyFwd.h> |
875 | 27 | #include <unity/scopes/internal/MWStateReceiverProxyFwd.h> | 28 | #include <unity/scopes/internal/MWStateReceiverProxyFwd.h> |
876 | 29 | #include <unity/scopes/internal/MWSubscriber.h> | ||
877 | 28 | #include <unity/scopes/internal/QueryObjectBase.h> | 30 | #include <unity/scopes/internal/QueryObjectBase.h> |
878 | 29 | #include <unity/scopes/internal/QueryCtrlObjectBase.h> | 31 | #include <unity/scopes/internal/QueryCtrlObjectBase.h> |
879 | 30 | #include <unity/scopes/internal/RegistryObjectBase.h> | 32 | #include <unity/scopes/internal/RegistryObjectBase.h> |
880 | @@ -84,6 +86,9 @@ | |||
881 | 84 | virtual void add_dflt_scope_object(ScopeObjectBase::SPtr const& scope) = 0; | 86 | virtual void add_dflt_scope_object(ScopeObjectBase::SPtr const& scope) = 0; |
882 | 85 | virtual MWStateReceiverProxy add_state_receiver_object(std::string const& identity, StateReceiverObject::SPtr const& state_receiver) = 0; | 87 | virtual MWStateReceiverProxy add_state_receiver_object(std::string const& identity, StateReceiverObject::SPtr const& state_receiver) = 0; |
883 | 86 | 88 | ||
884 | 89 | virtual MWPublisher::UPtr create_publisher(std::string const& publisher_id) = 0; | ||
885 | 90 | virtual MWSubscriber::UPtr create_subscriber(std::string const& publisher_id, std::string const& topic = "") = 0; | ||
886 | 91 | |||
887 | 87 | virtual std::string get_scope_endpoint() = 0; | 92 | virtual std::string get_scope_endpoint() = 0; |
888 | 88 | virtual std::string get_query_endpoint() = 0; | 93 | virtual std::string get_query_endpoint() = 0; |
889 | 89 | virtual std::string get_query_ctrl_endpoint() = 0; | 94 | virtual std::string get_query_ctrl_endpoint() = 0; |
890 | 90 | 95 | ||
891 | === modified file 'include/unity/scopes/internal/OptionSelectorFilterImpl.h' | |||
892 | --- include/unity/scopes/internal/OptionSelectorFilterImpl.h 2014-05-08 16:10:18 +0000 | |||
893 | +++ include/unity/scopes/internal/OptionSelectorFilterImpl.h 2014-05-21 14:02:43 +0000 | |||
894 | @@ -43,9 +43,11 @@ | |||
895 | 43 | OptionSelectorFilterImpl(VariantMap const& var); | 43 | OptionSelectorFilterImpl(VariantMap const& var); |
896 | 44 | std::string label() const; | 44 | std::string label() const; |
897 | 45 | bool multi_select() const; | 45 | bool multi_select() const; |
899 | 46 | FilterOption::SCPtr add_option(std::string const& id, std::string const& label); | 46 | virtual FilterOption::SCPtr add_option(std::string const& id, std::string const& label); |
900 | 47 | std::list<FilterOption::SCPtr> options() const; | 47 | std::list<FilterOption::SCPtr> options() const; |
901 | 48 | int num_of_options() const; | ||
902 | 48 | std::set<FilterOption::SCPtr> active_options(FilterState const& filter_state) const; | 49 | std::set<FilterOption::SCPtr> active_options(FilterState const& filter_state) const; |
903 | 50 | bool has_active_option(FilterState const& filter_state) const; | ||
904 | 49 | void update_state(FilterState& filter_state, FilterOption::SCPtr option, bool active) const; | 51 | void update_state(FilterState& filter_state, FilterOption::SCPtr option, bool active) const; |
905 | 50 | static void update_state(FilterState& filter_state, std::string const& filter_id, std::string const& option_id, bool value); | 52 | static void update_state(FilterState& filter_state, std::string const& filter_id, std::string const& option_id, bool value); |
906 | 51 | static OptionSelectorFilter::SPtr create(VariantMap const& var); | 53 | static OptionSelectorFilter::SPtr create(VariantMap const& var); |
907 | 52 | 54 | ||
908 | === added file 'include/unity/scopes/internal/RadioButtonsFilterImpl.h' | |||
909 | --- include/unity/scopes/internal/RadioButtonsFilterImpl.h 1970-01-01 00:00:00 +0000 | |||
910 | +++ include/unity/scopes/internal/RadioButtonsFilterImpl.h 2014-05-21 14:02:43 +0000 | |||
911 | @@ -0,0 +1,50 @@ | |||
912 | 1 | /* | ||
913 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
914 | 3 | * | ||
915 | 4 | * This program is free software: you can redistribute it and/or modify | ||
916 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
917 | 6 | * published by the Free Software Foundation. | ||
918 | 7 | * | ||
919 | 8 | * This program is distributed in the hope that it will be useful, | ||
920 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
921 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
922 | 11 | * GNU Lesser General Public License for more details. | ||
923 | 12 | * | ||
924 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
925 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
926 | 15 | * | ||
927 | 16 | * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com> | ||
928 | 17 | */ | ||
929 | 18 | |||
930 | 19 | #ifndef UNITY_INTERNAL_RADIOBUTTONSFILTERIMPL_H | ||
931 | 20 | #define UNITY_INTERNAL_RADIOBUTTONSFILTERIMPL_H | ||
932 | 21 | |||
933 | 22 | #include <unity/scopes/internal/OptionSelectorFilterImpl.h> | ||
934 | 23 | #include <unity/scopes/RadioButtonsFilter.h> | ||
935 | 24 | |||
936 | 25 | namespace unity | ||
937 | 26 | { | ||
938 | 27 | |||
939 | 28 | namespace scopes | ||
940 | 29 | { | ||
941 | 30 | |||
942 | 31 | namespace internal | ||
943 | 32 | { | ||
944 | 33 | |||
945 | 34 | class RadioButtonsFilterImpl : public OptionSelectorFilterImpl | ||
946 | 35 | { | ||
947 | 36 | public: | ||
948 | 37 | RadioButtonsFilterImpl(std::string const& id, std::string const& label); | ||
949 | 38 | RadioButtonsFilterImpl(VariantMap const& var); | ||
950 | 39 | FilterOption::SCPtr active_option(FilterState const& filter_state) const; | ||
951 | 40 | std::string filter_type() const override; | ||
952 | 41 | static RadioButtonsFilter::SPtr create(VariantMap const& var); | ||
953 | 42 | }; | ||
954 | 43 | |||
955 | 44 | } // namespace internal | ||
956 | 45 | |||
957 | 46 | } // namespace scopes | ||
958 | 47 | |||
959 | 48 | } // namespace unity | ||
960 | 49 | |||
961 | 50 | #endif | ||
962 | 0 | 51 | ||
963 | === added file 'include/unity/scopes/internal/RatingFilterImpl.h' | |||
964 | --- include/unity/scopes/internal/RatingFilterImpl.h 1970-01-01 00:00:00 +0000 | |||
965 | +++ include/unity/scopes/internal/RatingFilterImpl.h 2014-05-21 14:02:43 +0000 | |||
966 | @@ -0,0 +1,64 @@ | |||
967 | 1 | /* | ||
968 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
969 | 3 | * | ||
970 | 4 | * This program is free software: you can redistribute it and/or modify | ||
971 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
972 | 6 | * published by the Free Software Foundation. | ||
973 | 7 | * | ||
974 | 8 | * This program is distributed in the hope that it will be useful, | ||
975 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
976 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
977 | 11 | * GNU Lesser General Public License for more details. | ||
978 | 12 | * | ||
979 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
980 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
981 | 15 | * | ||
982 | 16 | * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com> | ||
983 | 17 | */ | ||
984 | 18 | |||
985 | 19 | #ifndef UNITY_INTERNAL_RATINGFILTERIMPL_H | ||
986 | 20 | #define UNITY_INTERNAL_RATINGFILTERIMPL_H | ||
987 | 21 | |||
988 | 22 | #include <unity/scopes/internal/RadioButtonsFilterImpl.h> | ||
989 | 23 | #include <unity/scopes/RatingFilter.h> | ||
990 | 24 | |||
991 | 25 | namespace unity | ||
992 | 26 | { | ||
993 | 27 | |||
994 | 28 | namespace scopes | ||
995 | 29 | { | ||
996 | 30 | |||
997 | 31 | namespace internal | ||
998 | 32 | { | ||
999 | 33 | |||
1000 | 34 | class RatingFilterImpl : public RadioButtonsFilterImpl | ||
1001 | 35 | { | ||
1002 | 36 | public: | ||
1003 | 37 | RatingFilterImpl(std::string const& id, std::string const& label); | ||
1004 | 38 | RatingFilterImpl(std::string const& id, std::string const& label, int top_rating); | ||
1005 | 39 | RatingFilterImpl(VariantMap const& var); | ||
1006 | 40 | FilterOption::SCPtr add_option(std::string const& id, std::string const& label) override; | ||
1007 | 41 | void set_on_icon(std::string const& on_icon); | ||
1008 | 42 | void set_off_icon(std::string const& off_icon); | ||
1009 | 43 | std::string on_icon() const; | ||
1010 | 44 | std::string off_icon() const; | ||
1011 | 45 | FilterOption::SCPtr active_rating(FilterState const& filter_state) const; | ||
1012 | 46 | |||
1013 | 47 | static RatingFilter::SPtr create(VariantMap const& var); | ||
1014 | 48 | |||
1015 | 49 | std::string filter_type() const override; | ||
1016 | 50 | |||
1017 | 51 | static const int max_rating = 10; | ||
1018 | 52 | |||
1019 | 53 | private: | ||
1020 | 54 | std::string on_icon_; | ||
1021 | 55 | std::string off_icon_; | ||
1022 | 56 | }; | ||
1023 | 57 | |||
1024 | 58 | } // namespace internal | ||
1025 | 59 | |||
1026 | 60 | } // namespace scopes | ||
1027 | 61 | |||
1028 | 62 | } // namespace unity | ||
1029 | 63 | |||
1030 | 64 | #endif | ||
1031 | 0 | 65 | ||
1032 | === modified file 'include/unity/scopes/internal/smartscopes/SmartScopesClient.h' | |||
1033 | --- include/unity/scopes/internal/smartscopes/SmartScopesClient.h 2014-03-24 10:15:20 +0000 | |||
1034 | +++ include/unity/scopes/internal/smartscopes/SmartScopesClient.h 2014-05-21 14:02:43 +0000 | |||
1035 | @@ -54,6 +54,7 @@ | |||
1036 | 54 | std::string base_url; | 54 | std::string base_url; |
1037 | 55 | std::shared_ptr<std::string> icon; // optional | 55 | std::shared_ptr<std::string> icon; // optional |
1038 | 56 | std::shared_ptr<std::string> art; // optional | 56 | std::shared_ptr<std::string> art; // optional |
1039 | 57 | std::shared_ptr<VariantMap> appearance; // optional | ||
1040 | 57 | bool invisible = false; | 58 | bool invisible = false; |
1041 | 58 | }; | 59 | }; |
1042 | 59 | 60 | ||
1043 | 60 | 61 | ||
1044 | === modified file 'include/unity/scopes/internal/zmq_middleware/ObjectAdapter.h' | |||
1045 | --- include/unity/scopes/internal/zmq_middleware/ObjectAdapter.h 2014-05-08 13:27:38 +0000 | |||
1046 | +++ include/unity/scopes/internal/zmq_middleware/ObjectAdapter.h 2014-05-21 14:02:43 +0000 | |||
1047 | @@ -98,8 +98,6 @@ | |||
1048 | 98 | // zmqpp::socket subscribe_to_ctrl_socket(); | 98 | // zmqpp::socket subscribe_to_ctrl_socket(); |
1049 | 99 | // void stop_workers() noexcept; | 99 | // void stop_workers() noexcept; |
1050 | 100 | 100 | ||
1051 | 101 | void safe_bind(zmqpp::socket& s, std::string const& endpoint); | ||
1052 | 102 | |||
1053 | 103 | std::shared_ptr<ServantBase> find_servant(std::string const& id, std::string const& category); | 101 | std::shared_ptr<ServantBase> find_servant(std::string const& id, std::string const& category); |
1054 | 104 | 102 | ||
1055 | 105 | // Thread start functions | 103 | // Thread start functions |
1056 | 106 | 104 | ||
1057 | === modified file 'include/unity/scopes/internal/zmq_middleware/Util.h' | |||
1058 | --- include/unity/scopes/internal/zmq_middleware/Util.h 2014-01-28 06:34:03 +0000 | |||
1059 | +++ include/unity/scopes/internal/zmq_middleware/Util.h 2014-05-21 14:02:43 +0000 | |||
1060 | @@ -19,6 +19,8 @@ | |||
1061 | 19 | #ifndef UNITY_SCOPES_INTERNAL_ZMQMIDDLEWARE_UTIL_H | 19 | #ifndef UNITY_SCOPES_INTERNAL_ZMQMIDDLEWARE_UTIL_H |
1062 | 20 | #define UNITY_SCOPES_INTERNAL_ZMQMIDDLEWARE_UTIL_H | 20 | #define UNITY_SCOPES_INTERNAL_ZMQMIDDLEWARE_UTIL_H |
1063 | 21 | 21 | ||
1064 | 22 | #include <zmqpp/socket.hpp> | ||
1065 | 23 | |||
1066 | 22 | #include <string> | 24 | #include <string> |
1067 | 23 | 25 | ||
1068 | 24 | namespace unity | 26 | namespace unity |
1069 | @@ -35,6 +37,8 @@ | |||
1070 | 35 | 37 | ||
1071 | 36 | void throw_if_bad_endpoint(std::string const& endpoint); | 38 | void throw_if_bad_endpoint(std::string const& endpoint); |
1072 | 37 | 39 | ||
1073 | 40 | void safe_bind(zmqpp::socket& s, std::string const& endpoint); | ||
1074 | 41 | |||
1075 | 38 | } // namespace zmq_middleware | 42 | } // namespace zmq_middleware |
1076 | 39 | 43 | ||
1077 | 40 | } // namespace internal | 44 | } // namespace internal |
1078 | 41 | 45 | ||
1079 | === modified file 'include/unity/scopes/internal/zmq_middleware/ZmqMiddleware.h' | |||
1080 | --- include/unity/scopes/internal/zmq_middleware/ZmqMiddleware.h 2014-05-15 00:34:39 +0000 | |||
1081 | +++ include/unity/scopes/internal/zmq_middleware/ZmqMiddleware.h 2014-05-21 14:02:43 +0000 | |||
1082 | @@ -78,10 +78,13 @@ | |||
1083 | 78 | virtual void add_dflt_query_object(QueryObjectBase::SPtr const& query) override; | 78 | virtual void add_dflt_query_object(QueryObjectBase::SPtr const& query) override; |
1084 | 79 | virtual MWRegistryProxy add_registry_object(std::string const& identity, RegistryObjectBase::SPtr const& registry) override; | 79 | virtual MWRegistryProxy add_registry_object(std::string const& identity, RegistryObjectBase::SPtr const& registry) override; |
1085 | 80 | virtual MWReplyProxy add_reply_object(ReplyObjectBase::SPtr const& reply) override; | 80 | virtual MWReplyProxy add_reply_object(ReplyObjectBase::SPtr const& reply) override; |
1087 | 81 | virtual MWScopeProxy add_scope_object(std::string const& identity, ScopeObjectBase::SPtr const& scope, int64_t idle_timeout = 0) override; | 81 | virtual MWScopeProxy add_scope_object(std::string const& identity, ScopeObjectBase::SPtr const& scope, int64_t idle_timeout) override; |
1088 | 82 | virtual void add_dflt_scope_object(ScopeObjectBase::SPtr const& scope) override; | 82 | virtual void add_dflt_scope_object(ScopeObjectBase::SPtr const& scope) override; |
1089 | 83 | virtual MWStateReceiverProxy add_state_receiver_object(std::string const& identity, StateReceiverObject::SPtr const& state_receiver) override; | 83 | virtual MWStateReceiverProxy add_state_receiver_object(std::string const& identity, StateReceiverObject::SPtr const& state_receiver) override; |
1090 | 84 | 84 | ||
1091 | 85 | virtual MWPublisher::UPtr create_publisher(std::string const& publisher_id) override; | ||
1092 | 86 | virtual MWSubscriber::UPtr create_subscriber(std::string const& publisher_id, std::string const& topic) override; | ||
1093 | 87 | |||
1094 | 85 | virtual std::string get_scope_endpoint() override; | 88 | virtual std::string get_scope_endpoint() override; |
1095 | 86 | virtual std::string get_query_endpoint() override; | 89 | virtual std::string get_query_endpoint() override; |
1096 | 87 | virtual std::string get_query_ctrl_endpoint() override; | 90 | virtual std::string get_query_ctrl_endpoint() override; |
1097 | 88 | 91 | ||
1098 | === added file 'include/unity/scopes/internal/zmq_middleware/ZmqPublisher.h' | |||
1099 | --- include/unity/scopes/internal/zmq_middleware/ZmqPublisher.h 1970-01-01 00:00:00 +0000 | |||
1100 | +++ include/unity/scopes/internal/zmq_middleware/ZmqPublisher.h 2014-05-21 14:02:43 +0000 | |||
1101 | @@ -0,0 +1,83 @@ | |||
1102 | 1 | /* | ||
1103 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
1104 | 3 | * | ||
1105 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1106 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
1107 | 6 | * published by the Free Software Foundation. | ||
1108 | 7 | * | ||
1109 | 8 | * This program is distributed in the hope that it will be useful, | ||
1110 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1111 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1112 | 11 | * GNU Lesser General Public License for more details. | ||
1113 | 12 | * | ||
1114 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1115 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1116 | 15 | * | ||
1117 | 16 | * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com> | ||
1118 | 17 | */ | ||
1119 | 18 | |||
1120 | 19 | #ifndef UNITY_SCOPES_INTERNAL_ZMQMIDDLEWARE_ZMQPUBLISHER_H | ||
1121 | 20 | #define UNITY_SCOPES_INTERNAL_ZMQMIDDLEWARE_ZMQPUBLISHER_H | ||
1122 | 21 | |||
1123 | 22 | #include <unity/scopes/internal/MWPublisher.h> | ||
1124 | 23 | |||
1125 | 24 | #include <zmqpp/context.hpp> | ||
1126 | 25 | #include <zmqpp/socket.hpp> | ||
1127 | 26 | |||
1128 | 27 | #include <condition_variable> | ||
1129 | 28 | #include <queue> | ||
1130 | 29 | #include <thread> | ||
1131 | 30 | |||
1132 | 31 | namespace unity | ||
1133 | 32 | { | ||
1134 | 33 | |||
1135 | 34 | namespace scopes | ||
1136 | 35 | { | ||
1137 | 36 | |||
1138 | 37 | namespace internal | ||
1139 | 38 | { | ||
1140 | 39 | |||
1141 | 40 | namespace zmq_middleware | ||
1142 | 41 | { | ||
1143 | 42 | |||
1144 | 43 | class ZmqPublisher : public virtual MWPublisher | ||
1145 | 44 | { | ||
1146 | 45 | public: | ||
1147 | 46 | ZmqPublisher(zmqpp::context* context, std::string const& publisher_id, | ||
1148 | 47 | std::string const& endpoint_dir); | ||
1149 | 48 | virtual ~ZmqPublisher(); | ||
1150 | 49 | |||
1151 | 50 | std::string endpoint() const override; | ||
1152 | 51 | void send_message(std::string const& message, std::string const& topic) override; | ||
1153 | 52 | |||
1154 | 53 | private: | ||
1155 | 54 | enum ThreadState | ||
1156 | 55 | { | ||
1157 | 56 | NotRunning, | ||
1158 | 57 | Running, | ||
1159 | 58 | Stopping, | ||
1160 | 59 | Failed | ||
1161 | 60 | }; | ||
1162 | 61 | |||
1163 | 62 | zmqpp::context* const context_; | ||
1164 | 63 | std::string const endpoint_; | ||
1165 | 64 | std::queue<std::string> message_queue_; | ||
1166 | 65 | |||
1167 | 66 | std::thread thread_; | ||
1168 | 67 | std::mutex mutex_; | ||
1169 | 68 | std::condition_variable cond_; | ||
1170 | 69 | ThreadState thread_state_; | ||
1171 | 70 | std::exception_ptr thread_exception_; | ||
1172 | 71 | |||
1173 | 72 | void publisher_thread(); | ||
1174 | 73 | }; | ||
1175 | 74 | |||
1176 | 75 | } // namespace zmq_middleware | ||
1177 | 76 | |||
1178 | 77 | } // namespace internal | ||
1179 | 78 | |||
1180 | 79 | } // namespace scopes | ||
1181 | 80 | |||
1182 | 81 | } // namespace unity | ||
1183 | 82 | |||
1184 | 83 | #endif // UNITY_SCOPES_INTERNAL_ZMQMIDDLEWARE_ZMQPUBLISHER_H | ||
1185 | 0 | 84 | ||
1186 | === added file 'include/unity/scopes/internal/zmq_middleware/ZmqSubscriber.h' | |||
1187 | --- include/unity/scopes/internal/zmq_middleware/ZmqSubscriber.h 1970-01-01 00:00:00 +0000 | |||
1188 | +++ include/unity/scopes/internal/zmq_middleware/ZmqSubscriber.h 2014-05-21 14:02:43 +0000 | |||
1189 | @@ -0,0 +1,86 @@ | |||
1190 | 1 | /* | ||
1191 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
1192 | 3 | * | ||
1193 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1194 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
1195 | 6 | * published by the Free Software Foundation. | ||
1196 | 7 | * | ||
1197 | 8 | * This program is distributed in the hope that it will be useful, | ||
1198 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1199 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1200 | 11 | * GNU Lesser General Public License for more details. | ||
1201 | 12 | * | ||
1202 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1203 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1204 | 15 | * | ||
1205 | 16 | * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com> | ||
1206 | 17 | */ | ||
1207 | 18 | |||
1208 | 19 | #ifndef UNITY_SCOPES_INTERNAL_ZMQMIDDLEWARE_ZMQSUBSCRIBER_H | ||
1209 | 20 | #define UNITY_SCOPES_INTERNAL_ZMQMIDDLEWARE_ZMQSUBSCRIBER_H | ||
1210 | 21 | |||
1211 | 22 | #include <unity/scopes/internal/MWSubscriber.h> | ||
1212 | 23 | |||
1213 | 24 | #include <zmqpp/context.hpp> | ||
1214 | 25 | |||
1215 | 26 | #include <condition_variable> | ||
1216 | 27 | #include <thread> | ||
1217 | 28 | |||
1218 | 29 | namespace unity | ||
1219 | 30 | { | ||
1220 | 31 | |||
1221 | 32 | namespace scopes | ||
1222 | 33 | { | ||
1223 | 34 | |||
1224 | 35 | namespace internal | ||
1225 | 36 | { | ||
1226 | 37 | |||
1227 | 38 | namespace zmq_middleware | ||
1228 | 39 | { | ||
1229 | 40 | |||
1230 | 41 | class StopPublisher; | ||
1231 | 42 | |||
1232 | 43 | class ZmqSubscriber : public virtual MWSubscriber | ||
1233 | 44 | { | ||
1234 | 45 | public: | ||
1235 | 46 | ZmqSubscriber(zmqpp::context* context, std::string const& publisher_id, | ||
1236 | 47 | std::string const& endpoint_dir, std::string const& topic); | ||
1237 | 48 | virtual ~ZmqSubscriber(); | ||
1238 | 49 | |||
1239 | 50 | std::string endpoint() const override; | ||
1240 | 51 | void set_message_callback(SubscriberCallback callback) override; | ||
1241 | 52 | |||
1242 | 53 | private: | ||
1243 | 54 | enum ThreadState | ||
1244 | 55 | { | ||
1245 | 56 | NotRunning, | ||
1246 | 57 | Running, | ||
1247 | 58 | Stopping, | ||
1248 | 59 | Failed | ||
1249 | 60 | }; | ||
1250 | 61 | |||
1251 | 62 | zmqpp::context* const context_; | ||
1252 | 63 | std::string const endpoint_; | ||
1253 | 64 | std::string const topic_; | ||
1254 | 65 | |||
1255 | 66 | std::thread thread_; | ||
1256 | 67 | std::unique_ptr<StopPublisher> thread_stopper_; | ||
1257 | 68 | std::mutex mutex_; | ||
1258 | 69 | std::condition_variable cond_; | ||
1259 | 70 | ThreadState thread_state_; | ||
1260 | 71 | std::exception_ptr thread_exception_; | ||
1261 | 72 | |||
1262 | 73 | SubscriberCallback callback_; | ||
1263 | 74 | |||
1264 | 75 | void subscriber_thread(); | ||
1265 | 76 | }; | ||
1266 | 77 | |||
1267 | 78 | } // namespace zmq_middleware | ||
1268 | 79 | |||
1269 | 80 | } // namespace internal | ||
1270 | 81 | |||
1271 | 82 | } // namespace scopes | ||
1272 | 83 | |||
1273 | 84 | } // namespace unity | ||
1274 | 85 | |||
1275 | 86 | #endif // UNITY_SCOPES_INTERNAL_ZMQMIDDLEWARE_ZMQSUBSCRIBER_H | ||
1276 | 0 | 87 | ||
1277 | === modified file 'scoperegistry/CMakeLists.txt' | |||
1278 | --- scoperegistry/CMakeLists.txt 2014-05-06 09:00:45 +0000 | |||
1279 | +++ scoperegistry/CMakeLists.txt 2014-05-21 14:02:43 +0000 | |||
1280 | @@ -1,7 +1,6 @@ | |||
1281 | 1 | set(SRC | 1 | set(SRC |
1282 | 2 | FindFiles.cpp | 2 | FindFiles.cpp |
1283 | 3 | scoperegistry.cpp | 3 | scoperegistry.cpp |
1284 | 4 | ScopeSet.cpp | ||
1285 | 5 | ) | 4 | ) |
1286 | 6 | 5 | ||
1287 | 7 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) | 6 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) |
1288 | 8 | 7 | ||
1289 | === modified file 'scoperegistry/FindFiles.cpp' | |||
1290 | --- scoperegistry/FindFiles.cpp 2014-04-04 13:22:38 +0000 | |||
1291 | +++ scoperegistry/FindFiles.cpp 2014-05-21 14:02:43 +0000 | |||
1292 | @@ -21,12 +21,14 @@ | |||
1293 | 21 | #include <unity/UnityExceptions.h> | 21 | #include <unity/UnityExceptions.h> |
1294 | 22 | #include <unity/util/ResourcePtr.h> | 22 | #include <unity/util/ResourcePtr.h> |
1295 | 23 | 23 | ||
1296 | 24 | #include <boost/filesystem/path.hpp> | ||
1297 | 25 | |||
1298 | 26 | #include <map> | ||
1299 | 27 | |||
1300 | 24 | #include <dirent.h> | 28 | #include <dirent.h> |
1301 | 25 | #include <string.h> | 29 | #include <string.h> |
1302 | 26 | #include <sys/stat.h> | 30 | #include <sys/stat.h> |
1303 | 27 | 31 | ||
1304 | 28 | #include <boost/filesystem/path.hpp> | ||
1305 | 29 | |||
1306 | 30 | using namespace std; | 32 | using namespace std; |
1307 | 31 | using namespace unity; | 33 | using namespace unity; |
1308 | 32 | using namespace boost; | 34 | using namespace boost; |
1309 | @@ -86,10 +88,14 @@ | |||
1310 | 86 | // Return all files of the form dir/*/<scomescope>.ini that are regular files or | 88 | // Return all files of the form dir/*/<scomescope>.ini that are regular files or |
1311 | 87 | // symbolic links and have the specified suffix. | 89 | // symbolic links and have the specified suffix. |
1312 | 88 | // The empty suffix is legal and causes all regular files and symlinks to be returned. | 90 | // The empty suffix is legal and causes all regular files and symlinks to be returned. |
1313 | 91 | // Print error message for any scopes with an id that was seen previously. | ||
1314 | 89 | 92 | ||
1316 | 90 | vector<string> find_scope_config_files(string const& install_dir, string const& suffix) | 93 | vector<string> find_scope_config_files(string const& install_dir, |
1317 | 94 | string const& suffix, | ||
1318 | 95 | function<void(string const&)> error) | ||
1319 | 91 | { | 96 | { |
1320 | 92 | vector<string> files; | 97 | vector<string> files; |
1321 | 98 | map<string, string> scopes_seen; | ||
1322 | 93 | 99 | ||
1323 | 94 | auto subdirs = find_entries(install_dir, Directory); | 100 | auto subdirs = find_entries(install_dir, Directory); |
1324 | 95 | for (auto subdir : subdirs) | 101 | for (auto subdir : subdirs) |
1325 | @@ -97,13 +103,18 @@ | |||
1326 | 97 | auto candidates = find_entries(subdir, File); | 103 | auto candidates = find_entries(subdir, File); |
1327 | 98 | for (auto c : candidates) | 104 | for (auto c : candidates) |
1328 | 99 | { | 105 | { |
1329 | 100 | // TODO Check for multiple ini files | ||
1330 | 101 | |||
1331 | 102 | filesystem::path path(c); | 106 | filesystem::path path(c); |
1332 | 103 | if (path.extension() != suffix) { | 107 | if (path.extension() != suffix) { |
1333 | 104 | continue; | 108 | continue; |
1334 | 105 | } | 109 | } |
1336 | 106 | 110 | auto stem = path.stem().native(); | |
1337 | 111 | auto const it = scopes_seen.find(stem); | ||
1338 | 112 | if (it != scopes_seen.end()) | ||
1339 | 113 | { | ||
1340 | 114 | error("ignoring second instance of non-unique scope: " + path.native() + "\n" | ||
1341 | 115 | "previous instance: " + it->second); | ||
1342 | 116 | } | ||
1343 | 117 | scopes_seen[stem] = path.native(); | ||
1344 | 107 | files.emplace_back(c); | 118 | files.emplace_back(c); |
1345 | 108 | } | 119 | } |
1346 | 109 | } | 120 | } |
1347 | 110 | 121 | ||
1348 | === modified file 'scoperegistry/FindFiles.h' | |||
1349 | --- scoperegistry/FindFiles.h 2013-11-21 21:44:00 +0000 | |||
1350 | +++ scoperegistry/FindFiles.h 2014-05-21 14:02:43 +0000 | |||
1351 | @@ -19,8 +19,9 @@ | |||
1352 | 19 | #ifndef SCOPEREGISTRY_FINDFILES_H | 19 | #ifndef SCOPEREGISTRY_FINDFILES_H |
1353 | 20 | #define SCOPEREGISTRY_FINDFILES_H | 20 | #define SCOPEREGISTRY_FINDFILES_H |
1354 | 21 | 21 | ||
1355 | 22 | #include <functional> | ||
1356 | 23 | #include <string> | ||
1357 | 22 | #include <vector> | 24 | #include <vector> |
1358 | 23 | #include <string> | ||
1359 | 24 | 25 | ||
1360 | 25 | namespace scoperegistry | 26 | namespace scoperegistry |
1361 | 26 | { | 27 | { |
1362 | @@ -34,11 +35,14 @@ | |||
1363 | 34 | // we get those two .ini files, but no .ini files in canonical or underneath | 35 | // we get those two .ini files, but no .ini files in canonical or underneath |
1364 | 35 | // further-nested directories. | 36 | // further-nested directories. |
1365 | 36 | 37 | ||
1367 | 37 | std::vector<std::string> find_scope_config_files(std::string const& install_dir, std::string const& suffix); | 38 | std::vector<std::string> find_scope_config_files(std::string const& install_dir, |
1368 | 39 | std::string const& suffix, | ||
1369 | 40 | std::function<void(std::string const&)> error); | ||
1370 | 38 | 41 | ||
1371 | 39 | // Return a vector of file names in dir with the given suffix. | 42 | // Return a vector of file names in dir with the given suffix. |
1372 | 40 | 43 | ||
1374 | 41 | std::vector<std::string> find_files(std::string const& dir, std::string const& suffix); | 44 | std::vector<std::string> find_files(std::string const& dir, |
1375 | 45 | std::string const& suffix); | ||
1376 | 42 | 46 | ||
1377 | 43 | } // namespace scoperegistry | 47 | } // namespace scoperegistry |
1378 | 44 | 48 | ||
1379 | 45 | 49 | ||
1380 | === removed file 'scoperegistry/ScopeSet.cpp' | |||
1381 | --- scoperegistry/ScopeSet.cpp 2014-04-03 12:57:25 +0000 | |||
1382 | +++ scoperegistry/ScopeSet.cpp 1970-01-01 00:00:00 +0000 | |||
1383 | @@ -1,124 +0,0 @@ | |||
1384 | 1 | /* | ||
1385 | 2 | * Copyright (C) 2013 Canonical Ltd | ||
1386 | 3 | * | ||
1387 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1388 | 5 | * it under the terms of the Lesser GNU General Public License version 3 as | ||
1389 | 6 | * published by the Free Software Foundation. | ||
1390 | 7 | * | ||
1391 | 8 | * This program is distributed in the hope that it will be useful, | ||
1392 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1393 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1394 | 11 | * GNU Lesser General Public License for more details. | ||
1395 | 12 | * | ||
1396 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1397 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1398 | 15 | * | ||
1399 | 16 | * Authored by: Jussi Pakkanen <jussi.pakkanen@canonical.com> | ||
1400 | 17 | */ | ||
1401 | 18 | |||
1402 | 19 | #include"FindFiles.h" | ||
1403 | 20 | #include"ScopeSet.h" | ||
1404 | 21 | #include <unity/scopes/ScopeMetadata.h> | ||
1405 | 22 | #include <unity/scopes/internal/RegistryConfig.h> | ||
1406 | 23 | #include <unity/scopes/internal/ScopeConfig.h> | ||
1407 | 24 | #include <unity/scopes/ScopeExceptions.h> | ||
1408 | 25 | #include<memory> | ||
1409 | 26 | #include<map> | ||
1410 | 27 | #include<set> | ||
1411 | 28 | #include<cstring> | ||
1412 | 29 | |||
1413 | 30 | using namespace std; | ||
1414 | 31 | using namespace unity::scopes; | ||
1415 | 32 | using namespace unity::scopes::internal; | ||
1416 | 33 | |||
1417 | 34 | namespace scoperegistry | ||
1418 | 35 | { | ||
1419 | 36 | |||
1420 | 37 | static string strip_suffix(string const& s, string const& suffix) | ||
1421 | 38 | { | ||
1422 | 39 | auto s_len = s.length(); | ||
1423 | 40 | auto suffix_len = suffix.length(); | ||
1424 | 41 | if (s_len >= suffix_len) | ||
1425 | 42 | { | ||
1426 | 43 | if (s.compare(s_len - suffix_len, suffix_len, suffix) == 0) | ||
1427 | 44 | { | ||
1428 | 45 | return string(s, 0, s_len - suffix_len); | ||
1429 | 46 | } | ||
1430 | 47 | } | ||
1431 | 48 | return s; | ||
1432 | 49 | } | ||
1433 | 50 | |||
1434 | 51 | struct ScopeSetPrivate | ||
1435 | 52 | { | ||
1436 | 53 | std::set<string> overridable_scopes; | ||
1437 | 54 | std::map<string, unique_ptr<ScopeConfig>> scopes; | ||
1438 | 55 | }; | ||
1439 | 56 | |||
1440 | 57 | ScopeSet::ScopeSet(const RegistryConfig& c) : p(new ScopeSetPrivate()) | ||
1441 | 58 | { | ||
1442 | 59 | string canonical_dir = c.scope_installdir(); | ||
1443 | 60 | string oem_dir = c.oem_installdir(); | ||
1444 | 61 | auto canonical_files = find_scope_config_files(canonical_dir, ".ini"); | ||
1445 | 62 | auto oem_files = find_scope_config_files(oem_dir, ".ini"); | ||
1446 | 63 | for (const auto &path : canonical_files) | ||
1447 | 64 | { | ||
1448 | 65 | unique_ptr<ScopeConfig> sc(new ScopeConfig(path)); | ||
1449 | 66 | // basename() modifies its argument | ||
1450 | 67 | string file_name = basename(const_cast<char*>(string(path).c_str())); | ||
1451 | 68 | string scope_id = strip_suffix(file_name, ".ini"); | ||
1452 | 69 | if (sc->overrideable()) | ||
1453 | 70 | { | ||
1454 | 71 | p->overridable_scopes.insert(path); | ||
1455 | 72 | } | ||
1456 | 73 | p->scopes[scope_id] = move(sc); | ||
1457 | 74 | } | ||
1458 | 75 | for (const auto &path : oem_files) | ||
1459 | 76 | { | ||
1460 | 77 | unique_ptr<ScopeConfig> sc(new ScopeConfig(path)); | ||
1461 | 78 | string file_name = basename(const_cast<char*>(string(path).c_str())); | ||
1462 | 79 | string scope_id = strip_suffix(file_name, ".ini"); | ||
1463 | 80 | if (p->scopes.find(scope_id) != p->scopes.end()) | ||
1464 | 81 | { | ||
1465 | 82 | if (p->overridable_scopes.find(scope_id) != p->overridable_scopes.end()) | ||
1466 | 83 | { | ||
1467 | 84 | p->scopes[scope_id] = move(sc); | ||
1468 | 85 | } | ||
1469 | 86 | else | ||
1470 | 87 | { | ||
1471 | 88 | // print error about trying to override a non-overridable scope. | ||
1472 | 89 | } | ||
1473 | 90 | } | ||
1474 | 91 | else | ||
1475 | 92 | { | ||
1476 | 93 | p->scopes[scope_id] = move(sc); | ||
1477 | 94 | } | ||
1478 | 95 | } | ||
1479 | 96 | // Add click scope parsing here. | ||
1480 | 97 | } | ||
1481 | 98 | |||
1482 | 99 | ScopeSet::~ScopeSet() | ||
1483 | 100 | { | ||
1484 | 101 | delete p; | ||
1485 | 102 | } | ||
1486 | 103 | |||
1487 | 104 | std::vector<std::string> ScopeSet::list() const | ||
1488 | 105 | { | ||
1489 | 106 | vector<string> list; | ||
1490 | 107 | for (auto &i : p->scopes) | ||
1491 | 108 | { | ||
1492 | 109 | list.push_back(i.first); | ||
1493 | 110 | } | ||
1494 | 111 | return list; | ||
1495 | 112 | } | ||
1496 | 113 | |||
1497 | 114 | const unity::scopes::internal::ScopeConfig& | ||
1498 | 115 | ScopeSet::get(const std::string& name) | ||
1499 | 116 | { | ||
1500 | 117 | if (p->scopes.find(name) == p->scopes.end()) | ||
1501 | 118 | { | ||
1502 | 119 | throw NotFoundException("Scope does not exist", name); | ||
1503 | 120 | } | ||
1504 | 121 | return *p->scopes[name].get(); | ||
1505 | 122 | } | ||
1506 | 123 | |||
1507 | 124 | } | ||
1508 | 125 | 0 | ||
1509 | === removed file 'scoperegistry/ScopeSet.h' | |||
1510 | --- scoperegistry/ScopeSet.h 2014-01-14 13:36:43 +0000 | |||
1511 | +++ scoperegistry/ScopeSet.h 1970-01-01 00:00:00 +0000 | |||
1512 | @@ -1,56 +0,0 @@ | |||
1513 | 1 | /* | ||
1514 | 2 | * Copyright (C) 2013 Canonical Ltd | ||
1515 | 3 | * | ||
1516 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1517 | 5 | * it under the terms of the Lesser GNU General Public License version 3 as | ||
1518 | 6 | * published by the Free Software Foundation. | ||
1519 | 7 | * | ||
1520 | 8 | * This program is distributed in the hope that it will be useful, | ||
1521 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1522 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1523 | 11 | * GNU Lesser General Public License for more details. | ||
1524 | 12 | * | ||
1525 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1526 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1527 | 15 | * | ||
1528 | 16 | * Authored by: Jussi Pakkanen <jussi.pakkanen@canonical.com> | ||
1529 | 17 | */ | ||
1530 | 18 | |||
1531 | 19 | #ifndef SCOPEREGISTRY_SCOPESET_H_ | ||
1532 | 20 | #define SCOPEREGISTRY_SCOPESET_H_ | ||
1533 | 21 | |||
1534 | 22 | #include<vector> | ||
1535 | 23 | #include<string> | ||
1536 | 24 | #include<unity/scopes/internal/RegistryConfig.h> | ||
1537 | 25 | #include<unity/scopes/internal/ScopeConfig.h> | ||
1538 | 26 | |||
1539 | 27 | |||
1540 | 28 | namespace scoperegistry | ||
1541 | 29 | { | ||
1542 | 30 | |||
1543 | 31 | struct ScopeSetPrivate; | ||
1544 | 32 | |||
1545 | 33 | |||
1546 | 34 | class ScopeSet final | ||
1547 | 35 | { | ||
1548 | 36 | |||
1549 | 37 | public: | ||
1550 | 38 | |||
1551 | 39 | ScopeSet(const ::unity::scopes::internal::RegistryConfig& c); | ||
1552 | 40 | ~ScopeSet(); | ||
1553 | 41 | |||
1554 | 42 | ScopeSet(const ScopeSet&) = delete; | ||
1555 | 43 | ScopeSet& operator=(const ScopeSet&) = delete; | ||
1556 | 44 | |||
1557 | 45 | std::vector<std::string> list() const; | ||
1558 | 46 | const unity::scopes::internal::ScopeConfig& get(const std::string& name); | ||
1559 | 47 | |||
1560 | 48 | private: | ||
1561 | 49 | ScopeSetPrivate* p; | ||
1562 | 50 | |||
1563 | 51 | }; | ||
1564 | 52 | |||
1565 | 53 | |||
1566 | 54 | } | ||
1567 | 55 | |||
1568 | 56 | #endif | ||
1569 | 57 | 0 | ||
1570 | === modified file 'scoperegistry/scoperegistry.cpp' | |||
1571 | --- scoperegistry/scoperegistry.cpp 2014-05-14 17:26:34 +0000 | |||
1572 | +++ scoperegistry/scoperegistry.cpp 2014-05-21 14:02:43 +0000 | |||
1573 | @@ -136,7 +136,7 @@ | |||
1574 | 136 | map<string, string> fixed_scopes; // Scopes that the OEM cannot override | 136 | map<string, string> fixed_scopes; // Scopes that the OEM cannot override |
1575 | 137 | map<string, string> overrideable_scopes; // Scopes that the OEM can override | 137 | map<string, string> overrideable_scopes; // Scopes that the OEM can override |
1576 | 138 | 138 | ||
1578 | 139 | auto config_files = find_scope_config_files(scope_installdir, ".ini"); | 139 | auto config_files = find_scope_config_files(scope_installdir, ".ini", error); |
1579 | 140 | for (auto&& path : config_files) | 140 | for (auto&& path : config_files) |
1580 | 141 | { | 141 | { |
1581 | 142 | filesystem::path p(path); | 142 | filesystem::path p(path); |
1582 | @@ -163,7 +163,7 @@ | |||
1583 | 163 | { | 163 | { |
1584 | 164 | try | 164 | try |
1585 | 165 | { | 165 | { |
1587 | 166 | auto oem_paths = find_scope_config_files(oem_installdir, ".ini"); | 166 | auto oem_paths = find_scope_config_files(oem_installdir, ".ini", error); |
1588 | 167 | for (auto&& path : oem_paths) | 167 | for (auto&& path : oem_paths) |
1589 | 168 | { | 168 | { |
1590 | 169 | filesystem::path p(path); | 169 | filesystem::path p(path); |
1591 | @@ -199,7 +199,7 @@ | |||
1592 | 199 | { | 199 | { |
1593 | 200 | try | 200 | try |
1594 | 201 | { | 201 | { |
1596 | 202 | auto click_paths = find_scope_config_files(click_installdir, ".ini"); | 202 | auto click_paths = find_scope_config_files(click_installdir, ".ini", error); |
1597 | 203 | for (auto&& path : click_paths) | 203 | for (auto&& path : click_paths) |
1598 | 204 | { | 204 | { |
1599 | 205 | filesystem::path p(path); | 205 | filesystem::path p(path); |
1600 | @@ -424,7 +424,6 @@ | |||
1601 | 424 | 424 | ||
1602 | 425 | add_local_scopes(registry, local_scopes, middleware, scoperunner_path, config_file, false, process_timeout); | 425 | add_local_scopes(registry, local_scopes, middleware, scoperunner_path, config_file, false, process_timeout); |
1603 | 426 | add_local_scopes(registry, click_scopes, middleware, scoperunner_path, config_file, true, process_timeout); | 426 | add_local_scopes(registry, click_scopes, middleware, scoperunner_path, config_file, true, process_timeout); |
1604 | 427 | local_scopes.insert(click_scopes.begin(), click_scopes.end()); | ||
1605 | 428 | if (ss_reg_id.empty()) | 427 | if (ss_reg_id.empty()) |
1606 | 429 | { | 428 | { |
1607 | 430 | error("no remote registry configured, only local scopes will be available"); | 429 | error("no remote registry configured, only local scopes will be available"); |
1608 | 431 | 430 | ||
1609 | === modified file 'scoperunner/scoperunner.cpp' | |||
1610 | --- scoperunner/scoperunner.cpp 2014-05-09 04:04:06 +0000 | |||
1611 | +++ scoperunner/scoperunner.cpp 2014-05-21 14:02:43 +0000 | |||
1612 | @@ -93,7 +93,37 @@ | |||
1613 | 93 | auto rt = RuntimeImpl::create(scope_id, runtime_config); | 93 | auto rt = RuntimeImpl::create(scope_id, runtime_config); |
1614 | 94 | auto mw = rt->factory()->create(scope_id, reg_conf.mw_kind(), reg_conf.mw_configfile()); | 94 | auto mw = rt->factory()->create(scope_id, reg_conf.mw_kind(), reg_conf.mw_configfile()); |
1615 | 95 | 95 | ||
1617 | 96 | ScopeLoader::SPtr loader = ScopeLoader::load(scope_id, lib_dir + "lib" + scope_id + ".so", rt->registry()); | 96 | // For a scope_id "Fred", we look for the library as "libFred.so", "Fred.so", and "scope.so". |
1618 | 97 | vector<string> libs; | ||
1619 | 98 | libs.push_back(lib_dir + "lib" + scope_id + ".so"); | ||
1620 | 99 | libs.push_back(lib_dir + scope_id + ".so"); | ||
1621 | 100 | libs.push_back(lib_dir + "scope.so"); | ||
1622 | 101 | string failed_libs; | ||
1623 | 102 | ScopeLoader::SPtr loader; | ||
1624 | 103 | exception_ptr ep; | ||
1625 | 104 | for (auto const& lib : libs) | ||
1626 | 105 | { | ||
1627 | 106 | try | ||
1628 | 107 | { | ||
1629 | 108 | loader = ScopeLoader::load(scope_id, lib, rt->registry()); | ||
1630 | 109 | } | ||
1631 | 110 | catch (unity::ResourceException& e) | ||
1632 | 111 | { | ||
1633 | 112 | failed_libs += "\n " + lib; | ||
1634 | 113 | ep = e.remember(ep); | ||
1635 | 114 | } | ||
1636 | 115 | if (loader) | ||
1637 | 116 | { | ||
1638 | 117 | break; | ||
1639 | 118 | } | ||
1640 | 119 | } | ||
1641 | 120 | if (!loader) | ||
1642 | 121 | { | ||
1643 | 122 | unity::ResourceException e("Cannot load scope " + scope_id + "; tried in the following locations:" | ||
1644 | 123 | + failed_libs); | ||
1645 | 124 | e.remember(ep); | ||
1646 | 125 | throw e; | ||
1647 | 126 | } | ||
1648 | 97 | loader->start(); | 127 | loader->start(); |
1649 | 98 | 128 | ||
1650 | 99 | // Give a thread to the scope to do with as it likes. If the scope doesn't want to use it and | 129 | // Give a thread to the scope to do with as it likes. If the scope doesn't want to use it and |
1651 | 100 | 130 | ||
1652 | === modified file 'src/scopes/CMakeLists.txt' | |||
1653 | --- src/scopes/CMakeLists.txt 2014-05-08 14:49:31 +0000 | |||
1654 | +++ src/scopes/CMakeLists.txt 2014-05-21 14:02:43 +0000 | |||
1655 | @@ -29,6 +29,8 @@ | |||
1656 | 29 | ${CMAKE_CURRENT_SOURCE_DIR}/PreviewWidget.cpp | 29 | ${CMAKE_CURRENT_SOURCE_DIR}/PreviewWidget.cpp |
1657 | 30 | ${CMAKE_CURRENT_SOURCE_DIR}/QueryBase.cpp | 30 | ${CMAKE_CURRENT_SOURCE_DIR}/QueryBase.cpp |
1658 | 31 | ${CMAKE_CURRENT_SOURCE_DIR}/QueryCtrl.cpp | 31 | ${CMAKE_CURRENT_SOURCE_DIR}/QueryCtrl.cpp |
1659 | 32 | ${CMAKE_CURRENT_SOURCE_DIR}/RadioButtonsFilter.cpp | ||
1660 | 33 | ${CMAKE_CURRENT_SOURCE_DIR}/RatingFilter.cpp | ||
1661 | 32 | ${CMAKE_CURRENT_SOURCE_DIR}/Registry.cpp | 34 | ${CMAKE_CURRENT_SOURCE_DIR}/Registry.cpp |
1662 | 33 | ${CMAKE_CURRENT_SOURCE_DIR}/Reply.cpp | 35 | ${CMAKE_CURRENT_SOURCE_DIR}/Reply.cpp |
1663 | 34 | ${CMAKE_CURRENT_SOURCE_DIR}/Result.cpp | 36 | ${CMAKE_CURRENT_SOURCE_DIR}/Result.cpp |
1664 | 35 | 37 | ||
1665 | === modified file 'src/scopes/OptionSelectorFilter.cpp' | |||
1666 | --- src/scopes/OptionSelectorFilter.cpp 2014-05-08 16:10:18 +0000 | |||
1667 | +++ src/scopes/OptionSelectorFilter.cpp 2014-05-21 14:02:43 +0000 | |||
1668 | @@ -30,9 +30,9 @@ | |||
1669 | 30 | { | 30 | { |
1670 | 31 | } | 31 | } |
1671 | 32 | 32 | ||
1673 | 33 | OptionSelectorFilter::SPtr OptionSelectorFilter::create(std::string const& id, std::string const& label, bool multi_select) | 33 | OptionSelectorFilter::UPtr OptionSelectorFilter::create(std::string const& id, std::string const& label, bool multi_select) |
1674 | 34 | { | 34 | { |
1676 | 35 | return std::shared_ptr<OptionSelectorFilter>(new OptionSelectorFilter(new internal::OptionSelectorFilterImpl(id, label, multi_select))); | 35 | return std::unique_ptr<OptionSelectorFilter>(new OptionSelectorFilter(new internal::OptionSelectorFilterImpl(id, label, multi_select))); |
1677 | 36 | } | 36 | } |
1678 | 37 | 37 | ||
1679 | 38 | std::string OptionSelectorFilter::label() const | 38 | std::string OptionSelectorFilter::label() const |
1680 | @@ -55,6 +55,11 @@ | |||
1681 | 55 | return fwd()->options(); | 55 | return fwd()->options(); |
1682 | 56 | } | 56 | } |
1683 | 57 | 57 | ||
1684 | 58 | bool OptionSelectorFilter::has_active_option(FilterState const& filter_state) const | ||
1685 | 59 | { | ||
1686 | 60 | return fwd()->has_active_option(filter_state); | ||
1687 | 61 | } | ||
1688 | 62 | |||
1689 | 58 | std::set<FilterOption::SCPtr> OptionSelectorFilter::active_options(FilterState const& filter_state) const | 63 | std::set<FilterOption::SCPtr> OptionSelectorFilter::active_options(FilterState const& filter_state) const |
1690 | 59 | { | 64 | { |
1691 | 60 | return fwd()->active_options(filter_state); | 65 | return fwd()->active_options(filter_state); |
1692 | 61 | 66 | ||
1693 | === added file 'src/scopes/RadioButtonsFilter.cpp' | |||
1694 | --- src/scopes/RadioButtonsFilter.cpp 1970-01-01 00:00:00 +0000 | |||
1695 | +++ src/scopes/RadioButtonsFilter.cpp 2014-05-21 14:02:43 +0000 | |||
1696 | @@ -0,0 +1,80 @@ | |||
1697 | 1 | /* | ||
1698 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
1699 | 3 | * | ||
1700 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1701 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
1702 | 6 | * published by the Free Software Foundation. | ||
1703 | 7 | * | ||
1704 | 8 | * This program is distributed in the hope that it will be useful, | ||
1705 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1706 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1707 | 11 | * GNU Lesser General Public License for more details. | ||
1708 | 12 | * | ||
1709 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1710 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1711 | 15 | * | ||
1712 | 16 | * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com> | ||
1713 | 17 | */ | ||
1714 | 18 | |||
1715 | 19 | #include <unity/scopes/RadioButtonsFilter.h> | ||
1716 | 20 | #include <unity/scopes/internal/RadioButtonsFilterImpl.h> | ||
1717 | 21 | |||
1718 | 22 | namespace unity | ||
1719 | 23 | { | ||
1720 | 24 | |||
1721 | 25 | namespace scopes | ||
1722 | 26 | { | ||
1723 | 27 | |||
1724 | 28 | RadioButtonsFilter::RadioButtonsFilter(internal::RadioButtonsFilterImpl *impl) | ||
1725 | 29 | : FilterBase(impl) | ||
1726 | 30 | { | ||
1727 | 31 | } | ||
1728 | 32 | |||
1729 | 33 | FilterOption::SCPtr RadioButtonsFilter::add_option(std::string const& id, std::string const& label) | ||
1730 | 34 | { | ||
1731 | 35 | return fwd()->add_option(id, label); | ||
1732 | 36 | } | ||
1733 | 37 | |||
1734 | 38 | std::string RadioButtonsFilter::label() const | ||
1735 | 39 | { | ||
1736 | 40 | return fwd()->label(); | ||
1737 | 41 | } | ||
1738 | 42 | |||
1739 | 43 | FilterOption::SCPtr RadioButtonsFilter::active_option(FilterState const& filter_state) const | ||
1740 | 44 | { | ||
1741 | 45 | return fwd()->active_option(filter_state); | ||
1742 | 46 | } | ||
1743 | 47 | |||
1744 | 48 | bool RadioButtonsFilter::has_active_option(FilterState const& filter_state) const | ||
1745 | 49 | { | ||
1746 | 50 | return fwd()->has_active_option(filter_state); | ||
1747 | 51 | } | ||
1748 | 52 | |||
1749 | 53 | std::list<FilterOption::SCPtr> RadioButtonsFilter::options() const | ||
1750 | 54 | { | ||
1751 | 55 | return fwd()->options(); | ||
1752 | 56 | } | ||
1753 | 57 | |||
1754 | 58 | void RadioButtonsFilter::update_state(FilterState& filter_state, FilterOption::SCPtr option, bool active) const | ||
1755 | 59 | { | ||
1756 | 60 | fwd()->update_state(filter_state, option, active); | ||
1757 | 61 | } | ||
1758 | 62 | |||
1759 | 63 | void RadioButtonsFilter::update_state(FilterState& filter_state, std::string const& filter_id, std::string const& option_id, bool value) | ||
1760 | 64 | { | ||
1761 | 65 | internal::RadioButtonsFilterImpl::update_state(filter_state, filter_id, option_id, value); | ||
1762 | 66 | } | ||
1763 | 67 | |||
1764 | 68 | RadioButtonsFilter::UPtr RadioButtonsFilter::create(std::string const& id, std::string const& label) | ||
1765 | 69 | { | ||
1766 | 70 | return std::unique_ptr<RadioButtonsFilter>(new RadioButtonsFilter(new internal::RadioButtonsFilterImpl(id, label))); | ||
1767 | 71 | } | ||
1768 | 72 | |||
1769 | 73 | internal::RadioButtonsFilterImpl* RadioButtonsFilter::fwd() const | ||
1770 | 74 | { | ||
1771 | 75 | return dynamic_cast<internal::RadioButtonsFilterImpl*>(p.get()); | ||
1772 | 76 | } | ||
1773 | 77 | |||
1774 | 78 | } // namespace scopes | ||
1775 | 79 | |||
1776 | 80 | } // namespace unity | ||
1777 | 0 | 81 | ||
1778 | === added file 'src/scopes/RatingFilter.cpp' | |||
1779 | --- src/scopes/RatingFilter.cpp 1970-01-01 00:00:00 +0000 | |||
1780 | +++ src/scopes/RatingFilter.cpp 2014-05-21 14:02:43 +0000 | |||
1781 | @@ -0,0 +1,105 @@ | |||
1782 | 1 | /* | ||
1783 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
1784 | 3 | * | ||
1785 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1786 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
1787 | 6 | * published by the Free Software Foundation. | ||
1788 | 7 | * | ||
1789 | 8 | * This program is distributed in the hope that it will be useful, | ||
1790 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1791 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1792 | 11 | * GNU Lesser General Public License for more details. | ||
1793 | 12 | * | ||
1794 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1795 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1796 | 15 | * | ||
1797 | 16 | * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com> | ||
1798 | 17 | */ | ||
1799 | 18 | |||
1800 | 19 | #include <unity/scopes/RatingFilter.h> | ||
1801 | 20 | #include <unity/scopes/internal/RatingFilterImpl.h> | ||
1802 | 21 | |||
1803 | 22 | namespace unity | ||
1804 | 23 | { | ||
1805 | 24 | |||
1806 | 25 | namespace scopes | ||
1807 | 26 | { | ||
1808 | 27 | |||
1809 | 28 | RatingFilter::RatingFilter(internal::RatingFilterImpl *impl) | ||
1810 | 29 | : FilterBase(impl) | ||
1811 | 30 | { | ||
1812 | 31 | } | ||
1813 | 32 | |||
1814 | 33 | RatingFilter::UPtr RatingFilter::create(std::string const& id, std::string const& label, int top_rating) | ||
1815 | 34 | { | ||
1816 | 35 | return std::unique_ptr<RatingFilter>(new RatingFilter(new internal::RatingFilterImpl(id, label, top_rating))); | ||
1817 | 36 | } | ||
1818 | 37 | |||
1819 | 38 | RatingFilter::UPtr RatingFilter::create(std::string const& id, std::string const& label) | ||
1820 | 39 | { | ||
1821 | 40 | return std::unique_ptr<RatingFilter>(new RatingFilter(new internal::RatingFilterImpl(id, label))); | ||
1822 | 41 | } | ||
1823 | 42 | |||
1824 | 43 | FilterOption::SCPtr RatingFilter::add_option(std::string const& id, std::string const& label) | ||
1825 | 44 | { | ||
1826 | 45 | return fwd()->add_option(id, label); | ||
1827 | 46 | } | ||
1828 | 47 | |||
1829 | 48 | void RatingFilter::set_on_icon(std::string const& on_icon) | ||
1830 | 49 | { | ||
1831 | 50 | fwd()->set_on_icon(on_icon); | ||
1832 | 51 | } | ||
1833 | 52 | |||
1834 | 53 | void RatingFilter::set_off_icon(std::string const& off_icon) | ||
1835 | 54 | { | ||
1836 | 55 | fwd()->set_off_icon(off_icon); | ||
1837 | 56 | } | ||
1838 | 57 | |||
1839 | 58 | std::string RatingFilter::label() const | ||
1840 | 59 | { | ||
1841 | 60 | return fwd()->label(); | ||
1842 | 61 | } | ||
1843 | 62 | |||
1844 | 63 | std::list<FilterOption::SCPtr> RatingFilter::options() const | ||
1845 | 64 | { | ||
1846 | 65 | return fwd()->options(); | ||
1847 | 66 | } | ||
1848 | 67 | |||
1849 | 68 | std::string RatingFilter::on_icon() const | ||
1850 | 69 | { | ||
1851 | 70 | return fwd()->on_icon(); | ||
1852 | 71 | } | ||
1853 | 72 | |||
1854 | 73 | std::string RatingFilter::off_icon() const | ||
1855 | 74 | { | ||
1856 | 75 | return fwd()->off_icon(); | ||
1857 | 76 | } | ||
1858 | 77 | |||
1859 | 78 | FilterOption::SCPtr RatingFilter::active_rating(FilterState const& filter_state) const | ||
1860 | 79 | { | ||
1861 | 80 | return fwd()->active_option(filter_state); | ||
1862 | 81 | } | ||
1863 | 82 | |||
1864 | 83 | bool RatingFilter::has_active_rating(FilterState const& filter_state) const | ||
1865 | 84 | { | ||
1866 | 85 | return fwd()->has_active_option(filter_state); | ||
1867 | 86 | } | ||
1868 | 87 | |||
1869 | 88 | void RatingFilter::update_state(FilterState& filter_state, FilterOption::SCPtr option, bool active) const | ||
1870 | 89 | { | ||
1871 | 90 | fwd()->update_state(filter_state, option, active); | ||
1872 | 91 | } | ||
1873 | 92 | |||
1874 | 93 | void RatingFilter::update_state(FilterState& filter_state, std::string const& filter_id, std::string const& option_id, bool value) | ||
1875 | 94 | { | ||
1876 | 95 | internal::RatingFilterImpl::update_state(filter_state, filter_id, option_id, value); | ||
1877 | 96 | } | ||
1878 | 97 | |||
1879 | 98 | internal::RatingFilterImpl* RatingFilter::fwd() const | ||
1880 | 99 | { | ||
1881 | 100 | return dynamic_cast<internal::RatingFilterImpl*>(p.get()); | ||
1882 | 101 | } | ||
1883 | 102 | |||
1884 | 103 | } // namespace scopes | ||
1885 | 104 | |||
1886 | 105 | } // namespace unity | ||
1887 | 0 | 106 | ||
1888 | === modified file 'src/scopes/internal/CMakeLists.txt' | |||
1889 | --- src/scopes/internal/CMakeLists.txt 2014-05-08 14:49:31 +0000 | |||
1890 | +++ src/scopes/internal/CMakeLists.txt 2014-05-21 14:02:43 +0000 | |||
1891 | @@ -29,12 +29,14 @@ | |||
1892 | 29 | ${CMAKE_CURRENT_SOURCE_DIR}/MiddlewareBase.cpp | 29 | ${CMAKE_CURRENT_SOURCE_DIR}/MiddlewareBase.cpp |
1893 | 30 | ${CMAKE_CURRENT_SOURCE_DIR}/MiddlewareFactory.cpp | 30 | ${CMAKE_CURRENT_SOURCE_DIR}/MiddlewareFactory.cpp |
1894 | 31 | ${CMAKE_CURRENT_SOURCE_DIR}/MWObject.cpp | 31 | ${CMAKE_CURRENT_SOURCE_DIR}/MWObject.cpp |
1895 | 32 | ${CMAKE_CURRENT_SOURCE_DIR}/MWPublisher.cpp | ||
1896 | 32 | ${CMAKE_CURRENT_SOURCE_DIR}/MWQuery.cpp | 33 | ${CMAKE_CURRENT_SOURCE_DIR}/MWQuery.cpp |
1897 | 33 | ${CMAKE_CURRENT_SOURCE_DIR}/MWQueryCtrl.cpp | 34 | ${CMAKE_CURRENT_SOURCE_DIR}/MWQueryCtrl.cpp |
1898 | 34 | ${CMAKE_CURRENT_SOURCE_DIR}/MWRegistry.cpp | 35 | ${CMAKE_CURRENT_SOURCE_DIR}/MWRegistry.cpp |
1899 | 35 | ${CMAKE_CURRENT_SOURCE_DIR}/MWReply.cpp | 36 | ${CMAKE_CURRENT_SOURCE_DIR}/MWReply.cpp |
1900 | 36 | ${CMAKE_CURRENT_SOURCE_DIR}/MWScope.cpp | 37 | ${CMAKE_CURRENT_SOURCE_DIR}/MWScope.cpp |
1901 | 37 | ${CMAKE_CURRENT_SOURCE_DIR}/MWStateReceiver.cpp | 38 | ${CMAKE_CURRENT_SOURCE_DIR}/MWStateReceiver.cpp |
1902 | 39 | ${CMAKE_CURRENT_SOURCE_DIR}/MWSubscriber.cpp | ||
1903 | 38 | ${CMAKE_CURRENT_SOURCE_DIR}/ObjectImpl.cpp | 40 | ${CMAKE_CURRENT_SOURCE_DIR}/ObjectImpl.cpp |
1904 | 39 | ${CMAKE_CURRENT_SOURCE_DIR}/OptionSelectorFilterImpl.cpp | 41 | ${CMAKE_CURRENT_SOURCE_DIR}/OptionSelectorFilterImpl.cpp |
1905 | 40 | ${CMAKE_CURRENT_SOURCE_DIR}/PreviewQueryObject.cpp | 42 | ${CMAKE_CURRENT_SOURCE_DIR}/PreviewQueryObject.cpp |
1906 | @@ -46,6 +48,8 @@ | |||
1907 | 46 | ${CMAKE_CURRENT_SOURCE_DIR}/QueryCtrlObject.cpp | 48 | ${CMAKE_CURRENT_SOURCE_DIR}/QueryCtrlObject.cpp |
1908 | 47 | ${CMAKE_CURRENT_SOURCE_DIR}/QueryMetadataImpl.cpp | 49 | ${CMAKE_CURRENT_SOURCE_DIR}/QueryMetadataImpl.cpp |
1909 | 48 | ${CMAKE_CURRENT_SOURCE_DIR}/QueryObject.cpp | 50 | ${CMAKE_CURRENT_SOURCE_DIR}/QueryObject.cpp |
1910 | 51 | ${CMAKE_CURRENT_SOURCE_DIR}/RadioButtonsFilterImpl.cpp | ||
1911 | 52 | ${CMAKE_CURRENT_SOURCE_DIR}/RatingFilterImpl.cpp | ||
1912 | 49 | ${CMAKE_CURRENT_SOURCE_DIR}/RangeInputFilterImpl.cpp | 53 | ${CMAKE_CURRENT_SOURCE_DIR}/RangeInputFilterImpl.cpp |
1913 | 50 | ${CMAKE_CURRENT_SOURCE_DIR}/Reaper.cpp | 54 | ${CMAKE_CURRENT_SOURCE_DIR}/Reaper.cpp |
1914 | 51 | ${CMAKE_CURRENT_SOURCE_DIR}/RegistryConfig.cpp | 55 | ${CMAKE_CURRENT_SOURCE_DIR}/RegistryConfig.cpp |
1915 | 52 | 56 | ||
1916 | === modified file 'src/scopes/internal/FilterBaseImpl.cpp' | |||
1917 | --- src/scopes/internal/FilterBaseImpl.cpp 2014-05-15 22:32:00 +0000 | |||
1918 | +++ src/scopes/internal/FilterBaseImpl.cpp 2014-05-21 14:02:43 +0000 | |||
1919 | @@ -22,6 +22,8 @@ | |||
1920 | 22 | #include <unity/scopes/internal/Utils.h> | 22 | #include <unity/scopes/internal/Utils.h> |
1921 | 23 | #include <unity/scopes/internal/OptionSelectorFilterImpl.h> | 23 | #include <unity/scopes/internal/OptionSelectorFilterImpl.h> |
1922 | 24 | #include <unity/scopes/internal/RangeInputFilterImpl.h> | 24 | #include <unity/scopes/internal/RangeInputFilterImpl.h> |
1923 | 25 | #include <unity/scopes/internal/RadioButtonsFilterImpl.h> | ||
1924 | 26 | #include <unity/scopes/internal/RatingFilterImpl.h> | ||
1925 | 25 | #include <unity/UnityExceptions.h> | 27 | #include <unity/UnityExceptions.h> |
1926 | 26 | #include <sstream> | 28 | #include <sstream> |
1927 | 27 | 29 | ||
1928 | @@ -117,6 +119,14 @@ | |||
1929 | 117 | { | 119 | { |
1930 | 118 | return RangeInputFilterImpl::create(var); | 120 | return RangeInputFilterImpl::create(var); |
1931 | 119 | } | 121 | } |
1932 | 122 | if (ftype == "radio_buttons") | ||
1933 | 123 | { | ||
1934 | 124 | return RadioButtonsFilterImpl::create(var); | ||
1935 | 125 | } | ||
1936 | 126 | if (ftype == "rating") | ||
1937 | 127 | { | ||
1938 | 128 | return RatingFilterImpl::create(var); | ||
1939 | 129 | } | ||
1940 | 120 | throw unity::LogicException("Unknown filter type: " + ftype); | 130 | throw unity::LogicException("Unknown filter type: " + ftype); |
1941 | 121 | } | 131 | } |
1942 | 122 | throw unity::LogicException("FilterBase: Missing 'filter_type'"); | 132 | throw unity::LogicException("FilterBase: Missing 'filter_type'"); |
1943 | @@ -142,6 +152,56 @@ | |||
1944 | 142 | return filters; | 152 | return filters; |
1945 | 143 | } | 153 | } |
1946 | 144 | 154 | ||
1947 | 155 | void FilterBaseImpl::validate_filters(Filters const& filters) | ||
1948 | 156 | { | ||
1949 | 157 | for (auto const& f: filters) | ||
1950 | 158 | { | ||
1951 | 159 | if (f == nullptr) | ||
1952 | 160 | { | ||
1953 | 161 | throw unity::LogicException("FilterBaseImpl::validate_filters(): invalid null filter pointer"); | ||
1954 | 162 | } | ||
1955 | 163 | { | ||
1956 | 164 | OptionSelectorFilter::SCPtr optsel = std::dynamic_pointer_cast<OptionSelectorFilter const>(f); | ||
1957 | 165 | if (optsel) | ||
1958 | 166 | { | ||
1959 | 167 | if (optsel->options().size() == 0) | ||
1960 | 168 | { | ||
1961 | 169 | std::stringstream err; | ||
1962 | 170 | err << "FilterBaseImpl::validate_filters(): invalid empty OptionSelectorFilter '" << f->id() << "'"; | ||
1963 | 171 | throw unity::LogicException(err.str()); | ||
1964 | 172 | } | ||
1965 | 173 | continue; | ||
1966 | 174 | } | ||
1967 | 175 | } | ||
1968 | 176 | { | ||
1969 | 177 | RatingFilter::SCPtr rating = std::dynamic_pointer_cast<RatingFilter const>(f); | ||
1970 | 178 | if (rating) | ||
1971 | 179 | { | ||
1972 | 180 | if (rating->options().size() == 0) | ||
1973 | 181 | { | ||
1974 | 182 | std::stringstream err; | ||
1975 | 183 | err << "FilterBaseImpl::validate_filters(): invalid empty RatingFilter '" << f->id() << "'"; | ||
1976 | 184 | throw unity::LogicException(err.str()); | ||
1977 | 185 | } | ||
1978 | 186 | continue; | ||
1979 | 187 | } | ||
1980 | 188 | } | ||
1981 | 189 | { | ||
1982 | 190 | RadioButtonsFilter::SCPtr radiobtn = std::dynamic_pointer_cast<RadioButtonsFilter const>(f); | ||
1983 | 191 | if (radiobtn) | ||
1984 | 192 | { | ||
1985 | 193 | if (radiobtn->options().size() == 0) | ||
1986 | 194 | { | ||
1987 | 195 | std::stringstream err; | ||
1988 | 196 | err << "FilterBaseImpl::validate_filters(): invalid empty RadioButtonsFilter '" << f->id() << "'"; | ||
1989 | 197 | throw unity::LogicException(err.str()); | ||
1990 | 198 | } | ||
1991 | 199 | continue; | ||
1992 | 200 | } | ||
1993 | 201 | } | ||
1994 | 202 | } | ||
1995 | 203 | } | ||
1996 | 204 | |||
1997 | 145 | } // namespace internal | 205 | } // namespace internal |
1998 | 146 | 206 | ||
1999 | 147 | } // namespace scopes | 207 | } // namespace scopes |
2000 | 148 | 208 | ||
2001 | === added file 'src/scopes/internal/MWPublisher.cpp' | |||
2002 | --- src/scopes/internal/MWPublisher.cpp 1970-01-01 00:00:00 +0000 | |||
2003 | +++ src/scopes/internal/MWPublisher.cpp 2014-05-21 14:02:43 +0000 | |||
2004 | @@ -0,0 +1,42 @@ | |||
2005 | 1 | /* | ||
2006 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
2007 | 3 | * | ||
2008 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2009 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
2010 | 6 | * published by the Free Software Foundation. | ||
2011 | 7 | * | ||
2012 | 8 | * This program is distributed in the hope that it will be useful, | ||
2013 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2014 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2015 | 11 | * GNU Lesser General Public License for more details. | ||
2016 | 12 | * | ||
2017 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2018 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2019 | 15 | * | ||
2020 | 16 | * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com> | ||
2021 | 17 | */ | ||
2022 | 18 | |||
2023 | 19 | #include <unity/scopes/internal/MWPublisher.h> | ||
2024 | 20 | |||
2025 | 21 | namespace unity | ||
2026 | 22 | { | ||
2027 | 23 | |||
2028 | 24 | namespace scopes | ||
2029 | 25 | { | ||
2030 | 26 | |||
2031 | 27 | namespace internal | ||
2032 | 28 | { | ||
2033 | 29 | |||
2034 | 30 | MWPublisher::MWPublisher() | ||
2035 | 31 | { | ||
2036 | 32 | } | ||
2037 | 33 | |||
2038 | 34 | MWPublisher::~MWPublisher() | ||
2039 | 35 | { | ||
2040 | 36 | } | ||
2041 | 37 | |||
2042 | 38 | } // namespace internal | ||
2043 | 39 | |||
2044 | 40 | } // namespace scopes | ||
2045 | 41 | |||
2046 | 42 | } // namespace unity | ||
2047 | 0 | 43 | ||
2048 | === added file 'src/scopes/internal/MWSubscriber.cpp' | |||
2049 | --- src/scopes/internal/MWSubscriber.cpp 1970-01-01 00:00:00 +0000 | |||
2050 | +++ src/scopes/internal/MWSubscriber.cpp 2014-05-21 14:02:43 +0000 | |||
2051 | @@ -0,0 +1,42 @@ | |||
2052 | 1 | /* | ||
2053 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
2054 | 3 | * | ||
2055 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2056 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
2057 | 6 | * published by the Free Software Foundation. | ||
2058 | 7 | * | ||
2059 | 8 | * This program is distributed in the hope that it will be useful, | ||
2060 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2061 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2062 | 11 | * GNU Lesser General Public License for more details. | ||
2063 | 12 | * | ||
2064 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2065 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2066 | 15 | * | ||
2067 | 16 | * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com> | ||
2068 | 17 | */ | ||
2069 | 18 | |||
2070 | 19 | #include <unity/scopes/internal/MWSubscriber.h> | ||
2071 | 20 | |||
2072 | 21 | namespace unity | ||
2073 | 22 | { | ||
2074 | 23 | |||
2075 | 24 | namespace scopes | ||
2076 | 25 | { | ||
2077 | 26 | |||
2078 | 27 | namespace internal | ||
2079 | 28 | { | ||
2080 | 29 | |||
2081 | 30 | MWSubscriber::MWSubscriber() | ||
2082 | 31 | { | ||
2083 | 32 | } | ||
2084 | 33 | |||
2085 | 34 | MWSubscriber::~MWSubscriber() | ||
2086 | 35 | { | ||
2087 | 36 | } | ||
2088 | 37 | |||
2089 | 38 | } // namespace internal | ||
2090 | 39 | |||
2091 | 40 | } // namespace scopes | ||
2092 | 41 | |||
2093 | 42 | } // namespace unity | ||
2094 | 0 | 43 | ||
2095 | === modified file 'src/scopes/internal/OptionSelectorFilterImpl.cpp' | |||
2096 | --- src/scopes/internal/OptionSelectorFilterImpl.cpp 2014-05-15 03:23:43 +0000 | |||
2097 | +++ src/scopes/internal/OptionSelectorFilterImpl.cpp 2014-05-21 14:02:43 +0000 | |||
2098 | @@ -131,6 +131,11 @@ | |||
2099 | 131 | } | 131 | } |
2100 | 132 | } | 132 | } |
2101 | 133 | 133 | ||
2102 | 134 | int OptionSelectorFilterImpl::num_of_options() const | ||
2103 | 135 | { | ||
2104 | 136 | return options_.size(); | ||
2105 | 137 | } | ||
2106 | 138 | |||
2107 | 134 | std::list<FilterOption::SCPtr> OptionSelectorFilterImpl::options() const | 139 | std::list<FilterOption::SCPtr> OptionSelectorFilterImpl::options() const |
2108 | 135 | { | 140 | { |
2109 | 136 | return options_; | 141 | return options_; |
2110 | @@ -170,6 +175,33 @@ | |||
2111 | 170 | return opts; | 175 | return opts; |
2112 | 171 | } | 176 | } |
2113 | 172 | 177 | ||
2114 | 178 | bool OptionSelectorFilterImpl::has_active_option(FilterState const& filter_state) const | ||
2115 | 179 | { | ||
2116 | 180 | if (filter_state.has_filter(id())) | ||
2117 | 181 | { | ||
2118 | 182 | try | ||
2119 | 183 | { | ||
2120 | 184 | auto const var = FilterBaseImpl::get(filter_state, id()).get_array(); // this can throw if of different type | ||
2121 | 185 | |||
2122 | 186 | for (auto const& idvar: var) | ||
2123 | 187 | { | ||
2124 | 188 | auto const opt_id = idvar.get_string(); | ||
2125 | 189 | for (auto const& opt: options_) | ||
2126 | 190 | { | ||
2127 | 191 | if (opt_id == opt->id()) | ||
2128 | 192 | { | ||
2129 | 193 | return true; | ||
2130 | 194 | } | ||
2131 | 195 | } | ||
2132 | 196 | } | ||
2133 | 197 | } | ||
2134 | 198 | catch (...) | ||
2135 | 199 | { | ||
2136 | 200 | } | ||
2137 | 201 | } | ||
2138 | 202 | return false; | ||
2139 | 203 | } | ||
2140 | 204 | |||
2141 | 173 | void OptionSelectorFilterImpl::update_state(FilterState& filter_state, FilterOption::SCPtr option, bool active) const | 205 | void OptionSelectorFilterImpl::update_state(FilterState& filter_state, FilterOption::SCPtr option, bool active) const |
2142 | 174 | { | 206 | { |
2143 | 175 | auto const oid(option->id()); | 207 | auto const oid(option->id()); |
2144 | 176 | 208 | ||
2145 | === added file 'src/scopes/internal/RadioButtonsFilterImpl.cpp' | |||
2146 | --- src/scopes/internal/RadioButtonsFilterImpl.cpp 1970-01-01 00:00:00 +0000 | |||
2147 | +++ src/scopes/internal/RadioButtonsFilterImpl.cpp 2014-05-21 14:02:43 +0000 | |||
2148 | @@ -0,0 +1,81 @@ | |||
2149 | 1 | /* | ||
2150 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
2151 | 3 | * | ||
2152 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2153 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
2154 | 6 | * published by the Free Software Foundation. | ||
2155 | 7 | * | ||
2156 | 8 | * This program is distributed in the hope that it will be useful, | ||
2157 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2158 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2159 | 11 | * GNU Lesser General Public License for more details. | ||
2160 | 12 | * | ||
2161 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2162 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2163 | 15 | * | ||
2164 | 16 | * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com> | ||
2165 | 17 | */ | ||
2166 | 18 | |||
2167 | 19 | #include <unity/scopes/internal/RadioButtonsFilterImpl.h> | ||
2168 | 20 | #include <unity/scopes/FilterState.h> | ||
2169 | 21 | #include <sstream> | ||
2170 | 22 | #include <unity/UnityExceptions.h> | ||
2171 | 23 | |||
2172 | 24 | namespace unity | ||
2173 | 25 | { | ||
2174 | 26 | |||
2175 | 27 | namespace scopes | ||
2176 | 28 | { | ||
2177 | 29 | |||
2178 | 30 | namespace internal | ||
2179 | 31 | { | ||
2180 | 32 | |||
2181 | 33 | RadioButtonsFilterImpl::RadioButtonsFilterImpl(std::string const& id, std::string const& label) | ||
2182 | 34 | : OptionSelectorFilterImpl(id, label, false) | ||
2183 | 35 | { | ||
2184 | 36 | } | ||
2185 | 37 | |||
2186 | 38 | RadioButtonsFilterImpl::RadioButtonsFilterImpl(VariantMap const& var) | ||
2187 | 39 | : OptionSelectorFilterImpl(var) | ||
2188 | 40 | { | ||
2189 | 41 | if (multi_select()) // this should never happen unless a client bypasses the api | ||
2190 | 42 | { | ||
2191 | 43 | std::stringstream err; | ||
2192 | 44 | err << "RadioButtonsFilterImpl(): invalid filter data, multi selection is not available with RadioButtonsFilter, filter id '" << id() << "'"; | ||
2193 | 45 | throw unity::LogicException(err.str()); | ||
2194 | 46 | } | ||
2195 | 47 | } | ||
2196 | 48 | |||
2197 | 49 | FilterOption::SCPtr RadioButtonsFilterImpl::active_option(FilterState const& filter_state) const | ||
2198 | 50 | { | ||
2199 | 51 | auto const active = active_options(filter_state); | ||
2200 | 52 | if (active.size() > 1) // this should never happen unless a client bypasses the api | ||
2201 | 53 | { | ||
2202 | 54 | std::stringstream err; | ||
2203 | 55 | err << "RadioButtonsFilterImpl::active_option(): internal error, more than one button active, filter id '" << id() << "'"; | ||
2204 | 56 | throw unity::LogicException(err.str()); | ||
2205 | 57 | } | ||
2206 | 58 | |||
2207 | 59 | if (active.size() == 1) | ||
2208 | 60 | { | ||
2209 | 61 | return *active.begin(); | ||
2210 | 62 | } | ||
2211 | 63 | |||
2212 | 64 | return nullptr; | ||
2213 | 65 | } | ||
2214 | 66 | |||
2215 | 67 | std::string RadioButtonsFilterImpl::filter_type() const | ||
2216 | 68 | { | ||
2217 | 69 | return "radio_buttons"; | ||
2218 | 70 | } | ||
2219 | 71 | |||
2220 | 72 | RadioButtonsFilter::SPtr RadioButtonsFilterImpl::create(VariantMap const& var) | ||
2221 | 73 | { | ||
2222 | 74 | return std::shared_ptr<RadioButtonsFilter>(new RadioButtonsFilter(new RadioButtonsFilterImpl(var))); | ||
2223 | 75 | } | ||
2224 | 76 | |||
2225 | 77 | } // namespace internal | ||
2226 | 78 | |||
2227 | 79 | } // namespace scopes | ||
2228 | 80 | |||
2229 | 81 | } // namespace unity | ||
2230 | 0 | 82 | ||
2231 | === added file 'src/scopes/internal/RatingFilterImpl.cpp' | |||
2232 | --- src/scopes/internal/RatingFilterImpl.cpp 1970-01-01 00:00:00 +0000 | |||
2233 | +++ src/scopes/internal/RatingFilterImpl.cpp 2014-05-21 14:02:43 +0000 | |||
2234 | @@ -0,0 +1,109 @@ | |||
2235 | 1 | /* | ||
2236 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
2237 | 3 | * | ||
2238 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2239 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
2240 | 6 | * published by the Free Software Foundation. | ||
2241 | 7 | * | ||
2242 | 8 | * This program is distributed in the hope that it will be useful, | ||
2243 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2244 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2245 | 11 | * GNU Lesser General Public License for more details. | ||
2246 | 12 | * | ||
2247 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2248 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2249 | 15 | * | ||
2250 | 16 | * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com> | ||
2251 | 17 | */ | ||
2252 | 18 | |||
2253 | 19 | #include <unity/scopes/RatingFilter.h> | ||
2254 | 20 | #include <unity/scopes/internal/RatingFilterImpl.h> | ||
2255 | 21 | #include <unity/UnityExceptions.h> | ||
2256 | 22 | #include <sstream> | ||
2257 | 23 | |||
2258 | 24 | namespace unity | ||
2259 | 25 | { | ||
2260 | 26 | |||
2261 | 27 | namespace scopes | ||
2262 | 28 | { | ||
2263 | 29 | |||
2264 | 30 | namespace internal | ||
2265 | 31 | { | ||
2266 | 32 | |||
2267 | 33 | RatingFilterImpl::RatingFilterImpl(std::string const& id, std::string const& label) | ||
2268 | 34 | : RadioButtonsFilterImpl(id, label) | ||
2269 | 35 | { | ||
2270 | 36 | } | ||
2271 | 37 | |||
2272 | 38 | RatingFilterImpl::RatingFilterImpl(std::string const& id, std::string const& label, int top_rating) | ||
2273 | 39 | : RadioButtonsFilterImpl(id, label) | ||
2274 | 40 | { | ||
2275 | 41 | if (top_rating < 2 || top_rating > max_rating) | ||
2276 | 42 | { | ||
2277 | 43 | std::stringstream err; | ||
2278 | 44 | err << "RatingFilterImpl(): top_rating " << top_rating << " outside of allowed range for filter '" << id << "'"; | ||
2279 | 45 | throw unity::LogicException(err.str()); | ||
2280 | 46 | } | ||
2281 | 47 | |||
2282 | 48 | // create rating options from 1..top_rating range, e.g. "1+", "2+", ..., "5". | ||
2283 | 49 | for (int i = 1; i <= top_rating; i++) | ||
2284 | 50 | { | ||
2285 | 51 | auto const num = std::to_string(i); | ||
2286 | 52 | RadioButtonsFilterImpl::add_option(num, i < top_rating ? num + "+" : num); | ||
2287 | 53 | } | ||
2288 | 54 | } | ||
2289 | 55 | |||
2290 | 56 | RatingFilterImpl::RatingFilterImpl(VariantMap const& var) | ||
2291 | 57 | : RadioButtonsFilterImpl(var) | ||
2292 | 58 | { | ||
2293 | 59 | } | ||
2294 | 60 | |||
2295 | 61 | FilterOption::SCPtr RatingFilterImpl::add_option(std::string const& id, std::string const& label) | ||
2296 | 62 | { | ||
2297 | 63 | if (num_of_options() < max_rating) | ||
2298 | 64 | { | ||
2299 | 65 | return RadioButtonsFilterImpl::add_option(id, label); | ||
2300 | 66 | } | ||
2301 | 67 | else | ||
2302 | 68 | { | ||
2303 | 69 | std::stringstream err; | ||
2304 | 70 | err << "RatingFilterImpl::add_option(): maximum number of rating options reached for filter '" << id << "'"; | ||
2305 | 71 | throw unity::LogicException(err.str()); | ||
2306 | 72 | } | ||
2307 | 73 | } | ||
2308 | 74 | |||
2309 | 75 | void RatingFilterImpl::set_on_icon(std::string const& on_icon) | ||
2310 | 76 | { | ||
2311 | 77 | on_icon_ = on_icon; | ||
2312 | 78 | } | ||
2313 | 79 | |||
2314 | 80 | void RatingFilterImpl::set_off_icon(std::string const& off_icon) | ||
2315 | 81 | { | ||
2316 | 82 | off_icon_ = off_icon; | ||
2317 | 83 | } | ||
2318 | 84 | |||
2319 | 85 | std::string RatingFilterImpl::on_icon() const | ||
2320 | 86 | { | ||
2321 | 87 | return on_icon_; | ||
2322 | 88 | } | ||
2323 | 89 | |||
2324 | 90 | std::string RatingFilterImpl::off_icon() const | ||
2325 | 91 | { | ||
2326 | 92 | return off_icon_; | ||
2327 | 93 | } | ||
2328 | 94 | |||
2329 | 95 | RatingFilter::SPtr RatingFilterImpl::create(VariantMap const& var) | ||
2330 | 96 | { | ||
2331 | 97 | return std::shared_ptr<RatingFilter>(new RatingFilter(new RatingFilterImpl(var))); | ||
2332 | 98 | } | ||
2333 | 99 | |||
2334 | 100 | std::string RatingFilterImpl::filter_type() const | ||
2335 | 101 | { | ||
2336 | 102 | return "rating"; | ||
2337 | 103 | } | ||
2338 | 104 | |||
2339 | 105 | } // namespace internal | ||
2340 | 106 | |||
2341 | 107 | } // namespace scopes | ||
2342 | 108 | |||
2343 | 109 | } // namespace unity | ||
2344 | 0 | 110 | ||
2345 | === modified file 'src/scopes/internal/SearchReplyImpl.cpp' | |||
2346 | --- src/scopes/internal/SearchReplyImpl.cpp 2014-04-29 11:20:57 +0000 | |||
2347 | +++ src/scopes/internal/SearchReplyImpl.cpp 2014-05-21 14:02:43 +0000 | |||
2348 | @@ -62,7 +62,7 @@ | |||
2349 | 62 | } | 62 | } |
2350 | 63 | catch (unity::LogicException const &e) | 63 | catch (unity::LogicException const &e) |
2351 | 64 | { | 64 | { |
2353 | 65 | throw unity::LogicException("Reply::register_departments(): Failed to validate departments"); | 65 | throw unity::LogicException("SearchReplyImpl::register_departments(): Failed to validate departments"); |
2354 | 66 | } | 66 | } |
2355 | 67 | 67 | ||
2356 | 68 | ReplyImpl::push(internal::DepartmentImpl::serialize_departments(departments, current_department_id)); // ignore return value? | 68 | ReplyImpl::push(internal::DepartmentImpl::serialize_departments(departments, current_department_id)); // ignore return value? |
2357 | @@ -129,6 +129,16 @@ | |||
2358 | 129 | 129 | ||
2359 | 130 | bool SearchReplyImpl::push(unity::scopes::Filters const& filters, unity::scopes::FilterState const& filter_state) | 130 | bool SearchReplyImpl::push(unity::scopes::Filters const& filters, unity::scopes::FilterState const& filter_state) |
2360 | 131 | { | 131 | { |
2361 | 132 | // basic consistency check | ||
2362 | 133 | try | ||
2363 | 134 | { | ||
2364 | 135 | internal::FilterBaseImpl::validate_filters(filters); | ||
2365 | 136 | } | ||
2366 | 137 | catch (unity::LogicException const &e) | ||
2367 | 138 | { | ||
2368 | 139 | throw unity::LogicException("SearchReplyImpl::push(): Failed to validate filters"); | ||
2369 | 140 | } | ||
2370 | 141 | |||
2371 | 132 | VariantMap var; | 142 | VariantMap var; |
2372 | 133 | var["filters"] = internal::FilterBaseImpl::serialize_filters(filters); | 143 | var["filters"] = internal::FilterBaseImpl::serialize_filters(filters); |
2373 | 134 | var["filter_state"] = filter_state.serialize(); | 144 | var["filter_state"] = filter_state.serialize(); |
2374 | 135 | 145 | ||
2375 | === modified file 'src/scopes/internal/smartscopes/SSRegistryObject.cpp' | |||
2376 | --- src/scopes/internal/smartscopes/SSRegistryObject.cpp 2014-05-09 08:20:57 +0000 | |||
2377 | +++ src/scopes/internal/smartscopes/SSRegistryObject.cpp 2014-05-21 14:02:43 +0000 | |||
2378 | @@ -232,6 +232,11 @@ | |||
2379 | 232 | metadata->set_art(*scope.art); | 232 | metadata->set_art(*scope.art); |
2380 | 233 | } | 233 | } |
2381 | 234 | 234 | ||
2382 | 235 | if (scope.appearance) | ||
2383 | 236 | { | ||
2384 | 237 | metadata->set_appearance_attributes(*scope.appearance); | ||
2385 | 238 | } | ||
2386 | 239 | |||
2387 | 235 | metadata->set_invisible(scope.invisible); | 240 | metadata->set_invisible(scope.invisible); |
2388 | 236 | 241 | ||
2389 | 237 | ScopeProxy proxy = ScopeImpl::create(middleware_->create_scope_proxy(scope.id, ss_scope_endpoint_), | 242 | ScopeProxy proxy = ScopeImpl::create(middleware_->create_scope_proxy(scope.id, ss_scope_endpoint_), |
2390 | 238 | 243 | ||
2391 | === modified file 'src/scopes/internal/smartscopes/SmartScopesClient.cpp' | |||
2392 | --- src/scopes/internal/smartscopes/SmartScopesClient.cpp 2014-05-09 09:56:09 +0000 | |||
2393 | +++ src/scopes/internal/smartscopes/SmartScopesClient.cpp 2014-05-21 14:02:43 +0000 | |||
2394 | @@ -259,6 +259,11 @@ | |||
2395 | 259 | scope.art.reset(new std::string(child_node->get_node("art")->as_string())); | 259 | scope.art.reset(new std::string(child_node->get_node("art")->as_string())); |
2396 | 260 | } | 260 | } |
2397 | 261 | 261 | ||
2398 | 262 | if (child_node->has_node("appearance")) | ||
2399 | 263 | { | ||
2400 | 264 | scope.appearance.reset(new VariantMap(child_node->get_node("appearance")->to_variant().get_dict())); | ||
2401 | 265 | } | ||
2402 | 266 | |||
2403 | 262 | scope.invisible = child_node->has_node("invisible") ? child_node->get_node("invisible")->as_bool() : false; | 267 | scope.invisible = child_node->has_node("invisible") ? child_node->get_node("invisible")->as_bool() : false; |
2404 | 263 | 268 | ||
2405 | 264 | remote_scopes.push_back(scope); | 269 | remote_scopes.push_back(scope); |
2406 | 265 | 270 | ||
2407 | === modified file 'src/scopes/internal/zmq_middleware/CMakeLists.txt' | |||
2408 | --- src/scopes/internal/zmq_middleware/CMakeLists.txt 2014-04-15 00:30:07 +0000 | |||
2409 | +++ src/scopes/internal/zmq_middleware/CMakeLists.txt 2014-05-21 14:02:43 +0000 | |||
2410 | @@ -21,6 +21,7 @@ | |||
2411 | 21 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqMiddleware.cpp | 21 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqMiddleware.cpp |
2412 | 22 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqException.cpp | 22 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqException.cpp |
2413 | 23 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqObject.cpp | 23 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqObject.cpp |
2414 | 24 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqPublisher.cpp | ||
2415 | 24 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqQuery.cpp | 25 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqQuery.cpp |
2416 | 25 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqQueryCtrl.cpp | 26 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqQueryCtrl.cpp |
2417 | 26 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqReceiver.cpp | 27 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqReceiver.cpp |
2418 | @@ -29,5 +30,6 @@ | |||
2419 | 29 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqScope.cpp | 30 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqScope.cpp |
2420 | 30 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqSender.cpp | 31 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqSender.cpp |
2421 | 31 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqStateReceiver.cpp | 32 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqStateReceiver.cpp |
2422 | 33 | ${CMAKE_CURRENT_SOURCE_DIR}/ZmqSubscriber.cpp | ||
2423 | 32 | ) | 34 | ) |
2424 | 33 | set(UNITY_SCOPES_LIB_SRC ${UNITY_SCOPES_LIB_SRC} ${SRC} PARENT_SCOPE) | 35 | set(UNITY_SCOPES_LIB_SRC ${UNITY_SCOPES_LIB_SRC} ${SRC} PARENT_SCOPE) |
2425 | 34 | 36 | ||
2426 | === modified file 'src/scopes/internal/zmq_middleware/ObjectAdapter.cpp' | |||
2427 | --- src/scopes/internal/zmq_middleware/ObjectAdapter.cpp 2014-05-14 04:50:14 +0000 | |||
2428 | +++ src/scopes/internal/zmq_middleware/ObjectAdapter.cpp 2014-05-21 14:02:43 +0000 | |||
2429 | @@ -494,47 +494,6 @@ | |||
2430 | 494 | } | 494 | } |
2431 | 495 | } | 495 | } |
2432 | 496 | 496 | ||
2433 | 497 | // For the ipc transport, zmq permits more than one server to bind to the same endpoint. | ||
2434 | 498 | // If a server binds to an endpoint while another server is using that endpoint, the | ||
2435 | 499 | // second server silently "steals" the endpoint from the previous server, so all | ||
2436 | 500 | // connects after that point go to the new server, while connects that happened earlier | ||
2437 | 501 | // go to the old server. This is meant as a fail-over feature, and cannot be disabled. | ||
2438 | 502 | // | ||
2439 | 503 | // We don't want this and need an error if two servers try to use the same endpoint. | ||
2440 | 504 | // Hacky solution: we check whether it's possible to successfully connect to the | ||
2441 | 505 | // endpoint. If so, a server is still running there, and we throw. This has a | ||
2442 | 506 | // small race because a second server may connect after the check, but before | ||
2443 | 507 | // the bind. But, in practice, that's good enough for our purposes. | ||
2444 | 508 | |||
2445 | 509 | void ObjectAdapter::safe_bind(zmqpp::socket& s, string const& endpoint) | ||
2446 | 510 | { | ||
2447 | 511 | const std::string transport_prefix = "ipc://"; | ||
2448 | 512 | if (endpoint.substr(0, transport_prefix.size()) == transport_prefix) | ||
2449 | 513 | { | ||
2450 | 514 | string path = endpoint.substr(transport_prefix.size()); | ||
2451 | 515 | struct sockaddr_un addr; | ||
2452 | 516 | memset(&addr, 0, sizeof(addr)); | ||
2453 | 517 | addr.sun_family = AF_UNIX; | ||
2454 | 518 | strncpy(addr.sun_path, path.c_str(), sizeof(addr.sun_path) - 1); | ||
2455 | 519 | int fd = ::socket(AF_UNIX, SOCK_STREAM, 0); | ||
2456 | 520 | if (fd == -1) | ||
2457 | 521 | { | ||
2458 | 522 | // LCOV_EXCL_START | ||
2459 | 523 | throw MiddlewareException("ObjectAdapter: broker thread failure (adapter: " + name_ + "): " + | ||
2460 | 524 | "cannot create socket: " + strerror(errno)); | ||
2461 | 525 | // LCOV_EXCL_STOP | ||
2462 | 526 | } | ||
2463 | 527 | util::ResourcePtr<int, decltype(&::close)> close_guard(fd, ::close); | ||
2464 | 528 | if (::connect(fd, (struct sockaddr*)&addr, sizeof(addr)) == 0) | ||
2465 | 529 | { | ||
2466 | 530 | // Connect succeeded, so another server is using the socket already. | ||
2467 | 531 | throw MiddlewareException("ObjectAdapter: broker thread failure (adapter: " + name_ + "): " + | ||
2468 | 532 | "address in use: " + endpoint); | ||
2469 | 533 | } | ||
2470 | 534 | } | ||
2471 | 535 | s.bind(endpoint); | ||
2472 | 536 | } | ||
2473 | 537 | |||
2474 | 538 | shared_ptr<ServantBase> ObjectAdapter::find_servant(string const& id, string const& category) | 497 | shared_ptr<ServantBase> ObjectAdapter::find_servant(string const& id, string const& category) |
2475 | 539 | { | 498 | { |
2476 | 540 | shared_ptr<ServantBase> servant = find(id); | 499 | shared_ptr<ServantBase> servant = find(id); |
2477 | 541 | 500 | ||
2478 | === modified file 'src/scopes/internal/zmq_middleware/Util.cpp' | |||
2479 | --- src/scopes/internal/zmq_middleware/Util.cpp 2014-01-28 06:34:03 +0000 | |||
2480 | +++ src/scopes/internal/zmq_middleware/Util.cpp 2014-05-21 14:02:43 +0000 | |||
2481 | @@ -19,7 +19,10 @@ | |||
2482 | 19 | #include <unity/scopes/internal/zmq_middleware/Util.h> | 19 | #include <unity/scopes/internal/zmq_middleware/Util.h> |
2483 | 20 | 20 | ||
2484 | 21 | #include <unity/scopes/ScopeExceptions.h> | 21 | #include <unity/scopes/ScopeExceptions.h> |
2485 | 22 | #include <unity/util/ResourcePtr.h> | ||
2486 | 22 | 23 | ||
2487 | 24 | #include <unistd.h> | ||
2488 | 25 | #include <sys/socket.h> | ||
2489 | 23 | #include <sys/un.h> | 26 | #include <sys/un.h> |
2490 | 24 | 27 | ||
2491 | 25 | using namespace std; | 28 | using namespace std; |
2492 | @@ -55,6 +58,45 @@ | |||
2493 | 55 | } | 58 | } |
2494 | 56 | } | 59 | } |
2495 | 57 | 60 | ||
2496 | 61 | // For the ipc transport, zmq permits more than one server to bind to the same endpoint. | ||
2497 | 62 | // If a server binds to an endpoint while another server is using that endpoint, the | ||
2498 | 63 | // second server silently "steals" the endpoint from the previous server, so all | ||
2499 | 64 | // connects after that point go to the new server, while connects that happened earlier | ||
2500 | 65 | // go to the old server. This is meant as a fail-over feature, and cannot be disabled. | ||
2501 | 66 | // | ||
2502 | 67 | // We don't want this and need an error if two servers try to use the same endpoint. | ||
2503 | 68 | // Hacky solution: we check whether it's possible to successfully connect to the | ||
2504 | 69 | // endpoint. If so, a server is still running there, and we throw. This has a | ||
2505 | 70 | // small race because a second server may connect after the check, but before | ||
2506 | 71 | // the bind. But, in practice, that's good enough for our purposes. | ||
2507 | 72 | |||
2508 | 73 | void safe_bind(zmqpp::socket& s, string const& endpoint) | ||
2509 | 74 | { | ||
2510 | 75 | const std::string transport_prefix = "ipc://"; | ||
2511 | 76 | if (endpoint.substr(0, transport_prefix.size()) == transport_prefix) | ||
2512 | 77 | { | ||
2513 | 78 | string path = endpoint.substr(transport_prefix.size()); | ||
2514 | 79 | struct sockaddr_un addr; | ||
2515 | 80 | memset(&addr, 0, sizeof(addr)); | ||
2516 | 81 | addr.sun_family = AF_UNIX; | ||
2517 | 82 | strncpy(addr.sun_path, path.c_str(), sizeof(addr.sun_path) - 1); | ||
2518 | 83 | int fd = ::socket(AF_UNIX, SOCK_STREAM, 0); | ||
2519 | 84 | if (fd == -1) | ||
2520 | 85 | { | ||
2521 | 86 | // LCOV_EXCL_START | ||
2522 | 87 | throw MiddlewareException("safe_bind(): cannot create socket: " + std::string(strerror(errno))); | ||
2523 | 88 | // LCOV_EXCL_STOP | ||
2524 | 89 | } | ||
2525 | 90 | util::ResourcePtr<int, decltype(&::close)> close_guard(fd, ::close); | ||
2526 | 91 | if (::connect(fd, (struct sockaddr*)&addr, sizeof(addr)) == 0) | ||
2527 | 92 | { | ||
2528 | 93 | // Connect succeeded, so another server is using the socket already. | ||
2529 | 94 | throw MiddlewareException("safe_bind(): address in use: " + endpoint); | ||
2530 | 95 | } | ||
2531 | 96 | } | ||
2532 | 97 | s.bind(endpoint); | ||
2533 | 98 | } | ||
2534 | 99 | |||
2535 | 58 | } // namespace zmq_middleware | 100 | } // namespace zmq_middleware |
2536 | 59 | 101 | ||
2537 | 60 | } // namespace internal | 102 | } // namespace internal |
2538 | 61 | 103 | ||
2539 | === modified file 'src/scopes/internal/zmq_middleware/ZmqMiddleware.cpp' | |||
2540 | --- src/scopes/internal/zmq_middleware/ZmqMiddleware.cpp 2014-05-15 08:12:19 +0000 | |||
2541 | +++ src/scopes/internal/zmq_middleware/ZmqMiddleware.cpp 2014-05-21 14:02:43 +0000 | |||
2542 | @@ -29,12 +29,14 @@ | |||
2543 | 29 | #include <unity/scopes/internal/zmq_middleware/ReplyI.h> | 29 | #include <unity/scopes/internal/zmq_middleware/ReplyI.h> |
2544 | 30 | #include <unity/scopes/internal/zmq_middleware/ScopeI.h> | 30 | #include <unity/scopes/internal/zmq_middleware/ScopeI.h> |
2545 | 31 | #include <unity/scopes/internal/zmq_middleware/StateReceiverI.h> | 31 | #include <unity/scopes/internal/zmq_middleware/StateReceiverI.h> |
2546 | 32 | #include <unity/scopes/internal/zmq_middleware/ZmqPublisher.h> | ||
2547 | 32 | #include <unity/scopes/internal/zmq_middleware/ZmqQuery.h> | 33 | #include <unity/scopes/internal/zmq_middleware/ZmqQuery.h> |
2548 | 33 | #include <unity/scopes/internal/zmq_middleware/ZmqQueryCtrl.h> | 34 | #include <unity/scopes/internal/zmq_middleware/ZmqQueryCtrl.h> |
2549 | 34 | #include <unity/scopes/internal/zmq_middleware/ZmqRegistry.h> | 35 | #include <unity/scopes/internal/zmq_middleware/ZmqRegistry.h> |
2550 | 35 | #include <unity/scopes/internal/zmq_middleware/ZmqReply.h> | 36 | #include <unity/scopes/internal/zmq_middleware/ZmqReply.h> |
2551 | 36 | #include <unity/scopes/internal/zmq_middleware/ZmqScope.h> | 37 | #include <unity/scopes/internal/zmq_middleware/ZmqScope.h> |
2552 | 37 | #include <unity/scopes/internal/zmq_middleware/ZmqStateReceiver.h> | 38 | #include <unity/scopes/internal/zmq_middleware/ZmqStateReceiver.h> |
2553 | 39 | #include <unity/scopes/internal/zmq_middleware/ZmqSubscriber.h> | ||
2554 | 38 | #include <unity/scopes/internal/zmq_middleware/RethrowException.h> | 40 | #include <unity/scopes/internal/zmq_middleware/RethrowException.h> |
2555 | 39 | #include <unity/scopes/ScopeExceptions.h> | 41 | #include <unity/scopes/ScopeExceptions.h> |
2556 | 40 | #include <unity/UnityExceptions.h> | 42 | #include <unity/UnityExceptions.h> |
2557 | @@ -59,10 +61,11 @@ | |||
2558 | 59 | namespace | 61 | namespace |
2559 | 60 | { | 62 | { |
2560 | 61 | 63 | ||
2565 | 62 | char const* query_suffix = "-q"; // Appended to server_name_ to create query adapter name | 64 | char const* query_suffix = "-q"; // Appended to server_name_ to create query adapter name |
2566 | 63 | char const* ctrl_suffix = "-c"; // Appended to server_name_ to create control adapter name | 65 | char const* ctrl_suffix = "-c"; // Appended to server_name_ to create control adapter name |
2567 | 64 | char const* reply_suffix = "-r"; // Appended to server_name_ to create reply adapter name | 66 | char const* reply_suffix = "-r"; // Appended to server_name_ to create reply adapter name |
2568 | 65 | char const* state_suffix = "-s"; // Appended to server_name_ to create state adapter name | 67 | char const* state_suffix = "-s"; // Appended to server_name_ to create state adapter name |
2569 | 68 | char const* publisher_suffix = "-p"; // Appended to publisher_id to create a publisher endpoint | ||
2570 | 66 | 69 | ||
2571 | 67 | char const* query_category = "Query"; // query adapter category name | 70 | char const* query_category = "Query"; // query adapter category name |
2572 | 68 | char const* ctrl_category = "QueryCtrl"; // control adapter category name | 71 | char const* ctrl_category = "QueryCtrl"; // control adapter category name |
2573 | @@ -657,6 +660,16 @@ | |||
2574 | 657 | return proxy; | 660 | return proxy; |
2575 | 658 | } | 661 | } |
2576 | 659 | 662 | ||
2577 | 663 | MWPublisher::UPtr ZmqMiddleware::create_publisher(std::string const& publisher_id) | ||
2578 | 664 | { | ||
2579 | 665 | return MWPublisher::UPtr(new ZmqPublisher(&context_, publisher_id + publisher_suffix, config_.public_dir())); | ||
2580 | 666 | } | ||
2581 | 667 | |||
2582 | 668 | MWSubscriber::UPtr ZmqMiddleware::create_subscriber(std::string const& publisher_id, std::string const& topic) | ||
2583 | 669 | { | ||
2584 | 670 | return MWSubscriber::UPtr(new ZmqSubscriber(&context_, publisher_id + publisher_suffix, config_.public_dir(), topic)); | ||
2585 | 671 | } | ||
2586 | 672 | |||
2587 | 660 | std::string ZmqMiddleware::get_scope_endpoint() | 673 | std::string ZmqMiddleware::get_scope_endpoint() |
2588 | 661 | { | 674 | { |
2589 | 662 | return "ipc://" + config_.private_dir() + "/" + server_name_; | 675 | return "ipc://" + config_.private_dir() + "/" + server_name_; |
2590 | 663 | 676 | ||
2591 | === added file 'src/scopes/internal/zmq_middleware/ZmqPublisher.cpp' | |||
2592 | --- src/scopes/internal/zmq_middleware/ZmqPublisher.cpp 1970-01-01 00:00:00 +0000 | |||
2593 | +++ src/scopes/internal/zmq_middleware/ZmqPublisher.cpp 2014-05-21 14:02:43 +0000 | |||
2594 | @@ -0,0 +1,157 @@ | |||
2595 | 1 | /* | ||
2596 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
2597 | 3 | * | ||
2598 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2599 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
2600 | 6 | * published by the Free Software Foundation. | ||
2601 | 7 | * | ||
2602 | 8 | * This program is distributed in the hope that it will be useful, | ||
2603 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2604 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2605 | 11 | * GNU Lesser General Public License for more details. | ||
2606 | 12 | * | ||
2607 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2608 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2609 | 15 | * | ||
2610 | 16 | * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com> | ||
2611 | 17 | */ | ||
2612 | 18 | |||
2613 | 19 | #include <unity/scopes/internal/zmq_middleware/ZmqPublisher.h> | ||
2614 | 20 | |||
2615 | 21 | #include <unity/scopes/internal/zmq_middleware/Util.h> | ||
2616 | 22 | #include <unity/scopes/ScopeExceptions.h> | ||
2617 | 23 | #include <unity/util/ResourcePtr.h> | ||
2618 | 24 | |||
2619 | 25 | #include <unistd.h> | ||
2620 | 26 | #include <sys/socket.h> | ||
2621 | 27 | #include <sys/un.h> | ||
2622 | 28 | |||
2623 | 29 | namespace unity | ||
2624 | 30 | { | ||
2625 | 31 | |||
2626 | 32 | namespace scopes | ||
2627 | 33 | { | ||
2628 | 34 | |||
2629 | 35 | namespace internal | ||
2630 | 36 | { | ||
2631 | 37 | |||
2632 | 38 | namespace zmq_middleware | ||
2633 | 39 | { | ||
2634 | 40 | |||
2635 | 41 | ZmqPublisher::ZmqPublisher(zmqpp::context* context, std::string const& publisher_id, | ||
2636 | 42 | std::string const& endpoint_dir) | ||
2637 | 43 | : context_(context) | ||
2638 | 44 | , endpoint_("ipc://" + endpoint_dir + "/" + publisher_id) | ||
2639 | 45 | , thread_state_(NotRunning) | ||
2640 | 46 | , thread_exception_(nullptr) | ||
2641 | 47 | { | ||
2642 | 48 | // Validate publisher_id | ||
2643 | 49 | if (publisher_id.find('/') != std::string::npos) | ||
2644 | 50 | { | ||
2645 | 51 | throw MiddlewareException("ZmqPublisher(): A publisher cannot contain a '/' in its id"); | ||
2646 | 52 | } | ||
2647 | 53 | |||
2648 | 54 | // Start the publisher thread | ||
2649 | 55 | thread_ = std::thread(&ZmqPublisher::publisher_thread, this); | ||
2650 | 56 | |||
2651 | 57 | std::unique_lock<std::mutex> lock(mutex_); | ||
2652 | 58 | cond_.wait(lock, [this] { return thread_state_ == Running || thread_state_ == Failed; }); | ||
2653 | 59 | |||
2654 | 60 | if (thread_state_ == Failed) | ||
2655 | 61 | { | ||
2656 | 62 | if (thread_.joinable()) | ||
2657 | 63 | { | ||
2658 | 64 | thread_.join(); | ||
2659 | 65 | } | ||
2660 | 66 | try | ||
2661 | 67 | { | ||
2662 | 68 | std::rethrow_exception(thread_exception_); | ||
2663 | 69 | } | ||
2664 | 70 | catch (...) | ||
2665 | 71 | { | ||
2666 | 72 | throw MiddlewareException("ZmqPublisher(): publisher thread failed to start (endpoint: " + | ||
2667 | 73 | endpoint_ + ")"); | ||
2668 | 74 | } | ||
2669 | 75 | } | ||
2670 | 76 | } | ||
2671 | 77 | |||
2672 | 78 | ZmqPublisher::~ZmqPublisher() | ||
2673 | 79 | { | ||
2674 | 80 | { | ||
2675 | 81 | std::lock_guard<std::mutex> lock(mutex_); | ||
2676 | 82 | thread_state_ = Stopping; | ||
2677 | 83 | cond_.notify_all(); | ||
2678 | 84 | } | ||
2679 | 85 | |||
2680 | 86 | if (thread_.joinable()) | ||
2681 | 87 | { | ||
2682 | 88 | thread_.join(); | ||
2683 | 89 | } | ||
2684 | 90 | } | ||
2685 | 91 | |||
2686 | 92 | std::string ZmqPublisher::endpoint() const | ||
2687 | 93 | { | ||
2688 | 94 | return endpoint_; | ||
2689 | 95 | } | ||
2690 | 96 | |||
2691 | 97 | void ZmqPublisher::send_message(std::string const& message, std::string const& topic) | ||
2692 | 98 | { | ||
2693 | 99 | std::lock_guard<std::mutex> lock(mutex_); | ||
2694 | 100 | |||
2695 | 101 | // Write message in the format: "<topic>:<message>" | ||
2696 | 102 | message_queue_.push(topic + ':' + message); | ||
2697 | 103 | cond_.notify_all(); | ||
2698 | 104 | } | ||
2699 | 105 | |||
2700 | 106 | void ZmqPublisher::publisher_thread() | ||
2701 | 107 | { | ||
2702 | 108 | try | ||
2703 | 109 | { | ||
2704 | 110 | // Create the publisher socket | ||
2705 | 111 | zmqpp::socket pub_socket(zmqpp::socket(*context_, zmqpp::socket_type::publish)); | ||
2706 | 112 | pub_socket.set(zmqpp::socket_option::linger, 5000); | ||
2707 | 113 | safe_bind(pub_socket, endpoint_); | ||
2708 | 114 | |||
2709 | 115 | // Notify constructor that the thread is now running | ||
2710 | 116 | std::unique_lock<std::mutex> lock(mutex_); | ||
2711 | 117 | thread_state_ = Running; | ||
2712 | 118 | cond_.notify_all(); | ||
2713 | 119 | |||
2714 | 120 | // Wait for send_message or stop | ||
2715 | 121 | while (true) | ||
2716 | 122 | { | ||
2717 | 123 | // mutex_ unlocked | ||
2718 | 124 | cond_.wait(lock, [this] { return thread_state_ == Stopping || !message_queue_.empty(); }); | ||
2719 | 125 | // mutex_ locked | ||
2720 | 126 | |||
2721 | 127 | // Flush out the message queue before stopping the thread | ||
2722 | 128 | if (!message_queue_.empty()) | ||
2723 | 129 | { | ||
2724 | 130 | pub_socket.send(message_queue_.front()); | ||
2725 | 131 | message_queue_.pop(); | ||
2726 | 132 | } | ||
2727 | 133 | else if (thread_state_ == Stopping) | ||
2728 | 134 | { | ||
2729 | 135 | break; | ||
2730 | 136 | } | ||
2731 | 137 | } | ||
2732 | 138 | |||
2733 | 139 | // Clean up | ||
2734 | 140 | pub_socket.close(); | ||
2735 | 141 | } | ||
2736 | 142 | catch (...) | ||
2737 | 143 | { | ||
2738 | 144 | std::lock_guard<std::mutex> lock(mutex_); | ||
2739 | 145 | thread_exception_ = std::current_exception(); | ||
2740 | 146 | thread_state_ = Failed; | ||
2741 | 147 | cond_.notify_all(); | ||
2742 | 148 | } | ||
2743 | 149 | } | ||
2744 | 150 | |||
2745 | 151 | } // namespace zmq_middleware | ||
2746 | 152 | |||
2747 | 153 | } // namespace internal | ||
2748 | 154 | |||
2749 | 155 | } // namespace scopes | ||
2750 | 156 | |||
2751 | 157 | } // namespace unity | ||
2752 | 0 | 158 | ||
2753 | === added file 'src/scopes/internal/zmq_middleware/ZmqSubscriber.cpp' | |||
2754 | --- src/scopes/internal/zmq_middleware/ZmqSubscriber.cpp 1970-01-01 00:00:00 +0000 | |||
2755 | +++ src/scopes/internal/zmq_middleware/ZmqSubscriber.cpp 2014-05-21 14:02:43 +0000 | |||
2756 | @@ -0,0 +1,185 @@ | |||
2757 | 1 | /* | ||
2758 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
2759 | 3 | * | ||
2760 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2761 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
2762 | 6 | * published by the Free Software Foundation. | ||
2763 | 7 | * | ||
2764 | 8 | * This program is distributed in the hope that it will be useful, | ||
2765 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2766 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2767 | 11 | * GNU Lesser General Public License for more details. | ||
2768 | 12 | * | ||
2769 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2770 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2771 | 15 | * | ||
2772 | 16 | * Authored by: Marcus Tomlinson <marcus.tomlinson@canonical.com> | ||
2773 | 17 | */ | ||
2774 | 18 | |||
2775 | 19 | #include <unity/scopes/internal/zmq_middleware/ZmqSubscriber.h> | ||
2776 | 20 | |||
2777 | 21 | #include <unity/scopes/internal/UniqueID.h> | ||
2778 | 22 | #include <unity/scopes/internal/zmq_middleware/StopPublisher.h> | ||
2779 | 23 | #include <unity/scopes/ScopeExceptions.h> | ||
2780 | 24 | |||
2781 | 25 | #include <zmqpp/poller.hpp> | ||
2782 | 26 | #include <zmqpp/socket.hpp> | ||
2783 | 27 | |||
2784 | 28 | namespace unity | ||
2785 | 29 | { | ||
2786 | 30 | |||
2787 | 31 | namespace scopes | ||
2788 | 32 | { | ||
2789 | 33 | |||
2790 | 34 | namespace internal | ||
2791 | 35 | { | ||
2792 | 36 | |||
2793 | 37 | namespace zmq_middleware | ||
2794 | 38 | { | ||
2795 | 39 | |||
2796 | 40 | ZmqSubscriber::ZmqSubscriber(zmqpp::context* context, std::string const& publisher_id, | ||
2797 | 41 | std::string const& endpoint_dir, std::string const& topic) | ||
2798 | 42 | : context_(context) | ||
2799 | 43 | , endpoint_("ipc://" + endpoint_dir + "/" + publisher_id) | ||
2800 | 44 | , topic_(topic) | ||
2801 | 45 | , thread_state_(NotRunning) | ||
2802 | 46 | , thread_exception_(nullptr) | ||
2803 | 47 | , callback_(nullptr) | ||
2804 | 48 | { | ||
2805 | 49 | // Validate publisher_id | ||
2806 | 50 | if (publisher_id.find('/') != std::string::npos) | ||
2807 | 51 | { | ||
2808 | 52 | throw MiddlewareException("ZmqSubscriber(): A publisher cannot contain a '/' in its id"); | ||
2809 | 53 | } | ||
2810 | 54 | |||
2811 | 55 | // Start thread_stopper_ publisher (used to send a stop message to the subscriber on destruction) | ||
2812 | 56 | try | ||
2813 | 57 | { | ||
2814 | 58 | UniqueID unique_id; | ||
2815 | 59 | thread_stopper_.reset(new StopPublisher(context, unique_id.gen())); | ||
2816 | 60 | } | ||
2817 | 61 | catch (...) | ||
2818 | 62 | { | ||
2819 | 63 | throw MiddlewareException("ZmqSubscriber(): thread_stopper_ failed to initialize (adapter: " + publisher_id + ")"); | ||
2820 | 64 | } | ||
2821 | 65 | |||
2822 | 66 | // Start the subscriber thread | ||
2823 | 67 | thread_ = std::thread(&ZmqSubscriber::subscriber_thread, this); | ||
2824 | 68 | |||
2825 | 69 | std::unique_lock<std::mutex> lock(mutex_); | ||
2826 | 70 | cond_.wait(lock, [this] { return thread_state_ == Running || thread_state_ == Failed; }); | ||
2827 | 71 | |||
2828 | 72 | if (thread_state_ == Failed) | ||
2829 | 73 | { | ||
2830 | 74 | if (thread_.joinable()) | ||
2831 | 75 | { | ||
2832 | 76 | thread_.join(); | ||
2833 | 77 | } | ||
2834 | 78 | try | ||
2835 | 79 | { | ||
2836 | 80 | std::rethrow_exception(thread_exception_); | ||
2837 | 81 | } | ||
2838 | 82 | catch (...) | ||
2839 | 83 | { | ||
2840 | 84 | throw MiddlewareException("ZmqSubscriber(): subscriber thread failed to start (endpoint: " + | ||
2841 | 85 | endpoint_ + ")"); | ||
2842 | 86 | } | ||
2843 | 87 | } | ||
2844 | 88 | } | ||
2845 | 89 | |||
2846 | 90 | ZmqSubscriber::~ZmqSubscriber() | ||
2847 | 91 | { | ||
2848 | 92 | thread_stopper_->stop(); | ||
2849 | 93 | |||
2850 | 94 | if (thread_.joinable()) | ||
2851 | 95 | { | ||
2852 | 96 | thread_.join(); | ||
2853 | 97 | } | ||
2854 | 98 | } | ||
2855 | 99 | |||
2856 | 100 | std::string ZmqSubscriber::endpoint() const | ||
2857 | 101 | { | ||
2858 | 102 | return endpoint_; | ||
2859 | 103 | } | ||
2860 | 104 | |||
2861 | 105 | void ZmqSubscriber::set_message_callback(SubscriberCallback callback) | ||
2862 | 106 | { | ||
2863 | 107 | std::lock_guard<std::mutex> lock(mutex_); | ||
2864 | 108 | callback_ = callback; | ||
2865 | 109 | } | ||
2866 | 110 | |||
2867 | 111 | void ZmqSubscriber::subscriber_thread() | ||
2868 | 112 | { | ||
2869 | 113 | try | ||
2870 | 114 | { | ||
2871 | 115 | // Subscribe to our associated publisher socket | ||
2872 | 116 | zmqpp::socket sub_socket(*context_, zmqpp::socket_type::subscribe); | ||
2873 | 117 | sub_socket.set(zmqpp::socket_option::linger, 0); | ||
2874 | 118 | sub_socket.connect(endpoint_); | ||
2875 | 119 | sub_socket.subscribe(topic_); | ||
2876 | 120 | |||
2877 | 121 | // Subscribe to the thread_stopper_ socket | ||
2878 | 122 | zmqpp::socket stop_socket = thread_stopper_->subscribe(); | ||
2879 | 123 | |||
2880 | 124 | // Configure the message poller | ||
2881 | 125 | zmqpp::poller poller; | ||
2882 | 126 | poller.add(sub_socket); | ||
2883 | 127 | poller.add(stop_socket); | ||
2884 | 128 | |||
2885 | 129 | // Notify constructor that the thread is now running | ||
2886 | 130 | { | ||
2887 | 131 | std::lock_guard<std::mutex> lock(mutex_); | ||
2888 | 132 | thread_state_ = Running; | ||
2889 | 133 | cond_.notify_all(); | ||
2890 | 134 | } | ||
2891 | 135 | |||
2892 | 136 | // Poll for messages | ||
2893 | 137 | std::string message; | ||
2894 | 138 | while (true) | ||
2895 | 139 | { | ||
2896 | 140 | poller.poll(); | ||
2897 | 141 | |||
2898 | 142 | // Flush out the message queue before stopping the thread | ||
2899 | 143 | if (poller.has_input(sub_socket)) | ||
2900 | 144 | { | ||
2901 | 145 | sub_socket.receive(message); | ||
2902 | 146 | |||
2903 | 147 | // Discard the message if no callback is set | ||
2904 | 148 | std::lock_guard<std::mutex> lock(mutex_); | ||
2905 | 149 | if (callback_) | ||
2906 | 150 | { | ||
2907 | 151 | // Message should arrive in the format: "<topic>:<message>" | ||
2908 | 152 | if (message.length() > topic_.length() && | ||
2909 | 153 | message[topic_.length()] == ':') | ||
2910 | 154 | { | ||
2911 | 155 | callback_(message.substr(topic_.length() + 1)); | ||
2912 | 156 | } | ||
2913 | 157 | } | ||
2914 | 158 | } | ||
2915 | 159 | else if(poller.has_input(stop_socket)) | ||
2916 | 160 | { | ||
2917 | 161 | break; | ||
2918 | 162 | } | ||
2919 | 163 | } | ||
2920 | 164 | |||
2921 | 165 | // Clean up | ||
2922 | 166 | poller.remove(sub_socket); | ||
2923 | 167 | poller.remove(stop_socket); | ||
2924 | 168 | sub_socket.close(); | ||
2925 | 169 | } | ||
2926 | 170 | catch (...) | ||
2927 | 171 | { | ||
2928 | 172 | std::lock_guard<std::mutex> lock(mutex_); | ||
2929 | 173 | thread_exception_ = std::current_exception(); | ||
2930 | 174 | thread_state_ = Failed; | ||
2931 | 175 | cond_.notify_all(); | ||
2932 | 176 | } | ||
2933 | 177 | } | ||
2934 | 178 | |||
2935 | 179 | } // namespace zmq_middleware | ||
2936 | 180 | |||
2937 | 181 | } // namespace internal | ||
2938 | 182 | |||
2939 | 183 | } // namespace scopes | ||
2940 | 184 | |||
2941 | 185 | } // namespace unity | ||
2942 | 0 | 186 | ||
2943 | === modified file 'test/gtest/scopes/CMakeLists.txt' | |||
2944 | --- test/gtest/scopes/CMakeLists.txt 2014-05-14 04:50:14 +0000 | |||
2945 | +++ test/gtest/scopes/CMakeLists.txt 2014-05-21 14:02:43 +0000 | |||
2946 | @@ -14,7 +14,9 @@ | |||
2947 | 14 | add_subdirectory(IdleShutdown) | 14 | add_subdirectory(IdleShutdown) |
2948 | 15 | add_subdirectory(Invocation) | 15 | add_subdirectory(Invocation) |
2949 | 16 | add_subdirectory(OptionSelectorFilter) | 16 | add_subdirectory(OptionSelectorFilter) |
2950 | 17 | add_subdirectory(RadioButtonsFilter) | ||
2951 | 17 | add_subdirectory(RangeInputFilter) | 18 | add_subdirectory(RangeInputFilter) |
2952 | 19 | add_subdirectory(RatingFilter) | ||
2953 | 18 | add_subdirectory(PreviewWidget) | 20 | add_subdirectory(PreviewWidget) |
2954 | 19 | add_subdirectory(QueryMetadata) | 21 | add_subdirectory(QueryMetadata) |
2955 | 20 | add_subdirectory(Registry) | 22 | add_subdirectory(Registry) |
2956 | 21 | 23 | ||
2957 | === modified file 'test/gtest/scopes/Filters/Filters_test.cpp' | |||
2958 | --- test/gtest/scopes/Filters/Filters_test.cpp 2014-05-08 17:08:38 +0000 | |||
2959 | +++ test/gtest/scopes/Filters/Filters_test.cpp 2014-05-21 14:02:43 +0000 | |||
2960 | @@ -18,7 +18,10 @@ | |||
2961 | 18 | 18 | ||
2962 | 19 | #include <unity/scopes/internal/RuntimeImpl.h> | 19 | #include <unity/scopes/internal/RuntimeImpl.h> |
2963 | 20 | #include <unity/scopes/internal/ScopeImpl.h> | 20 | #include <unity/scopes/internal/ScopeImpl.h> |
2964 | 21 | #include <unity/scopes/internal/FilterBaseImpl.h> | ||
2965 | 21 | #include <unity/scopes/FilterOption.h> | 22 | #include <unity/scopes/FilterOption.h> |
2966 | 23 | #include <unity/scopes/RadioButtonsFilter.h> | ||
2967 | 24 | #include <unity/scopes/RatingFilter.h> | ||
2968 | 22 | #include <unity/scopes/SearchMetadata.h> | 25 | #include <unity/scopes/SearchMetadata.h> |
2969 | 23 | #include <unity/UnityExceptions.h> | 26 | #include <unity/UnityExceptions.h> |
2970 | 24 | #include <gtest/gtest.h> | 27 | #include <gtest/gtest.h> |
2971 | @@ -133,3 +136,72 @@ | |||
2972 | 133 | EXPECT_EQ("o1", option1->id()); | 136 | EXPECT_EQ("o1", option1->id()); |
2973 | 134 | } | 137 | } |
2974 | 135 | } | 138 | } |
2975 | 139 | |||
2976 | 140 | TEST(Filters, deserialize) | ||
2977 | 141 | { | ||
2978 | 142 | // check that FilterBaseImpl::deserialize() creates valid instances of all filter types | ||
2979 | 143 | { | ||
2980 | 144 | OptionSelectorFilter::SPtr filter1 = OptionSelectorFilter::create("f1", "Options", false); | ||
2981 | 145 | auto option1 = filter1->add_option("1", "Option 1"); | ||
2982 | 146 | auto var = filter1->serialize(); | ||
2983 | 147 | |||
2984 | 148 | auto f = internal::FilterBaseImpl::deserialize(var); | ||
2985 | 149 | EXPECT_TRUE(std::dynamic_pointer_cast<OptionSelectorFilter const>(f) != nullptr); | ||
2986 | 150 | EXPECT_EQ("option_selector", f->filter_type()); | ||
2987 | 151 | |||
2988 | 152 | const Filters filters {filter1}; | ||
2989 | 153 | EXPECT_NO_THROW(internal::FilterBaseImpl::validate_filters(filters)); | ||
2990 | 154 | } | ||
2991 | 155 | |||
2992 | 156 | { | ||
2993 | 157 | RadioButtonsFilter::SPtr filter1 = RadioButtonsFilter::create("f1", "Options"); | ||
2994 | 158 | auto option1 = filter1->add_option("1", "Option 1"); | ||
2995 | 159 | auto var = filter1->serialize(); | ||
2996 | 160 | |||
2997 | 161 | auto f = internal::FilterBaseImpl::deserialize(var); | ||
2998 | 162 | EXPECT_TRUE(std::dynamic_pointer_cast<RadioButtonsFilter const>(f) != nullptr); | ||
2999 | 163 | EXPECT_EQ("radio_buttons", f->filter_type()); | ||
3000 | 164 | |||
3001 | 165 | const Filters filters {filter1}; | ||
3002 | 166 | EXPECT_NO_THROW(internal::FilterBaseImpl::validate_filters(filters)); | ||
3003 | 167 | } | ||
3004 | 168 | |||
3005 | 169 | { | ||
3006 | 170 | RatingFilter::SPtr filter1 = RatingFilter::create("f1", "Options", 5); | ||
3007 | 171 | auto var = filter1->serialize(); | ||
3008 | 172 | |||
3009 | 173 | auto f = internal::FilterBaseImpl::deserialize(var); | ||
3010 | 174 | EXPECT_TRUE(std::dynamic_pointer_cast<RatingFilter const>(f) != nullptr); | ||
3011 | 175 | EXPECT_EQ("rating", f->filter_type()); | ||
3012 | 176 | |||
3013 | 177 | const Filters filters {filter1}; | ||
3014 | 178 | EXPECT_NO_THROW(internal::FilterBaseImpl::validate_filters(filters)); | ||
3015 | 179 | } | ||
3016 | 180 | |||
3017 | 181 | { | ||
3018 | 182 | // invalid data (no filter_type) | ||
3019 | 183 | VariantMap var; | ||
3020 | 184 | EXPECT_THROW(internal::FilterBaseImpl::deserialize(var), unity::LogicException); | ||
3021 | 185 | } | ||
3022 | 186 | } | ||
3023 | 187 | |||
3024 | 188 | TEST(Filters, validate) | ||
3025 | 189 | { | ||
3026 | 190 | { | ||
3027 | 191 | FilterBase::SPtr filter1 = OptionSelectorFilter::create("f1", "Options", false); | ||
3028 | 192 | const Filters filters {filter1}; | ||
3029 | 193 | EXPECT_THROW(internal::FilterBaseImpl::validate_filters(filters), unity::LogicException); | ||
3030 | 194 | } | ||
3031 | 195 | |||
3032 | 196 | { | ||
3033 | 197 | FilterBase::SPtr filter1 = RadioButtonsFilter::create("f1", "Options"); | ||
3034 | 198 | const Filters filters {filter1}; | ||
3035 | 199 | EXPECT_THROW(internal::FilterBaseImpl::validate_filters(filters), unity::LogicException); | ||
3036 | 200 | } | ||
3037 | 201 | |||
3038 | 202 | { | ||
3039 | 203 | FilterBase::SPtr filter1 = RatingFilter::create("f1", "Options"); | ||
3040 | 204 | const Filters filters {filter1}; | ||
3041 | 205 | EXPECT_THROW(internal::FilterBaseImpl::validate_filters(filters), unity::LogicException); | ||
3042 | 206 | } | ||
3043 | 207 | } | ||
3044 | 136 | 208 | ||
3045 | === modified file 'test/gtest/scopes/Filters/TestScope.h' | |||
3046 | --- test/gtest/scopes/Filters/TestScope.h 2014-03-07 01:07:28 +0000 | |||
3047 | +++ test/gtest/scopes/Filters/TestScope.h 2014-05-21 14:02:43 +0000 | |||
3048 | @@ -45,7 +45,7 @@ | |||
3049 | 45 | virtual void run(SearchReplyProxy const& reply) override | 45 | virtual void run(SearchReplyProxy const& reply) override |
3050 | 46 | { | 46 | { |
3051 | 47 | Filters filters; | 47 | Filters filters; |
3053 | 48 | auto filter = OptionSelectorFilter::create("f1", "Choose an option", false); | 48 | OptionSelectorFilter::SPtr filter = OptionSelectorFilter::create("f1", "Choose an option", false); |
3054 | 49 | filter->add_option("o1", "Option 1"); | 49 | filter->add_option("o1", "Option 1"); |
3055 | 50 | filter->add_option("o2", "Option 2"); | 50 | filter->add_option("o2", "Option 2"); |
3056 | 51 | filters.push_back(filter); | 51 | filters.push_back(filter); |
3057 | 52 | 52 | ||
3058 | === modified file 'test/gtest/scopes/IdleShutdown/IdleShutdown_test.cpp' | |||
3059 | --- test/gtest/scopes/IdleShutdown/IdleShutdown_test.cpp 2014-05-14 04:50:14 +0000 | |||
3060 | +++ test/gtest/scopes/IdleShutdown/IdleShutdown_test.cpp 2014-05-21 14:02:43 +0000 | |||
3061 | @@ -40,8 +40,12 @@ | |||
3062 | 40 | { | 40 | { |
3063 | 41 | } | 41 | } |
3064 | 42 | 42 | ||
3066 | 43 | virtual void finished(ListenerBase::Reason /* reason */, string const& /* error_message */) override | 43 | virtual void finished(ListenerBase::Reason reason, string const& error_message) override |
3067 | 44 | { | 44 | { |
3068 | 45 | EXPECT_EQ(ListenerBase::Reason::Error, reason); | ||
3069 | 46 | EXPECT_EQ("unity::scopes::MiddlewareException: unity::scopes::MiddlewareException: " | ||
3070 | 47 | "Cannot invoke operations while middleware is stopped", | ||
3071 | 48 | error_message); | ||
3072 | 45 | lock_guard<mutex> lock(mutex_); | 49 | lock_guard<mutex> lock(mutex_); |
3073 | 46 | query_complete_ = true; | 50 | query_complete_ = true; |
3074 | 47 | cond_.notify_one(); | 51 | cond_.notify_one(); |
3075 | @@ -81,10 +85,10 @@ | |||
3076 | 81 | } | 85 | } |
3077 | 82 | 86 | ||
3078 | 83 | // Check that the scope has indeed timed out. The server shuts down after 2 seconds, | 87 | // Check that the scope has indeed timed out. The server shuts down after 2 seconds, |
3080 | 84 | // so we allow between 2 and 3 seconds for it to time out. | 88 | // so we allow between 2 and 4 seconds for it to time out. |
3081 | 85 | auto duration = chrono::steady_clock::now() - start_time; | 89 | auto duration = chrono::steady_clock::now() - start_time; |
3082 | 86 | EXPECT_TRUE(duration > chrono::seconds(2)); | 90 | EXPECT_TRUE(duration > chrono::seconds(2)); |
3084 | 87 | EXPECT_TRUE(duration < chrono::seconds(3)); | 91 | EXPECT_TRUE(duration < chrono::seconds(4)); |
3085 | 88 | } | 92 | } |
3086 | 89 | 93 | ||
3087 | 90 | // Check that the idle timeout for a server waits for synchronous operations | 94 | // Check that the idle timeout for a server waits for synchronous operations |
3088 | @@ -122,11 +126,13 @@ | |||
3089 | 122 | 126 | ||
3090 | 123 | // Check that the run time doesn't shut down until | 127 | // Check that the run time doesn't shut down until |
3091 | 124 | // the search in the scope has completed, which takes 4 seconds. | 128 | // the search in the scope has completed, which takes 4 seconds. |
3094 | 125 | // We allow 4 - 5 seconds for things to shut down before failing | 129 | // We allow 4 - 6 seconds for things to shut down before failing |
3095 | 126 | // (or hanging). | 130 | // (or hanging). (On Arm, can be slow to shut down, so we allow |
3096 | 131 | // a full two seconds for the server to go away before failing | ||
3097 | 132 | // the test.) | ||
3098 | 127 | auto duration = chrono::steady_clock::now() - start_time; | 133 | auto duration = chrono::steady_clock::now() - start_time; |
3099 | 128 | EXPECT_TRUE(duration > chrono::seconds(4)); | 134 | EXPECT_TRUE(duration > chrono::seconds(4)); |
3101 | 129 | EXPECT_TRUE(duration < chrono::seconds(5)); | 135 | EXPECT_TRUE(duration < chrono::seconds(6)); |
3102 | 130 | } | 136 | } |
3103 | 131 | 137 | ||
3104 | 132 | int main(int argc, char **argv) | 138 | int main(int argc, char **argv) |
3105 | 133 | 139 | ||
3106 | === modified file 'test/gtest/scopes/IdleShutdown/SlowSearchScope.cpp' | |||
3107 | --- test/gtest/scopes/IdleShutdown/SlowSearchScope.cpp 2014-05-14 04:50:14 +0000 | |||
3108 | +++ test/gtest/scopes/IdleShutdown/SlowSearchScope.cpp 2014-05-21 14:02:43 +0000 | |||
3109 | @@ -64,7 +64,7 @@ | |||
3110 | 64 | 64 | ||
3111 | 65 | SearchQueryBase::UPtr SlowSearchScope::search(CannedQuery const&, SearchMetadata const &) | 65 | SearchQueryBase::UPtr SlowSearchScope::search(CannedQuery const&, SearchMetadata const &) |
3112 | 66 | { | 66 | { |
3114 | 67 | this_thread::sleep_for(chrono::seconds(4)); | 67 | this_thread::sleep_for(chrono::seconds(4)); |
3115 | 68 | return SearchQueryBase::UPtr(new TestQuery()); | 68 | return SearchQueryBase::UPtr(new TestQuery()); |
3116 | 69 | } | 69 | } |
3117 | 70 | 70 | ||
3118 | 71 | 71 | ||
3119 | === modified file 'test/gtest/scopes/IdleShutdown/Zmq.ini.in' | |||
3120 | --- test/gtest/scopes/IdleShutdown/Zmq.ini.in 2014-05-14 04:50:14 +0000 | |||
3121 | +++ test/gtest/scopes/IdleShutdown/Zmq.ini.in 2014-05-21 14:02:43 +0000 | |||
3122 | @@ -1,3 +1,7 @@ | |||
3123 | 1 | [Zmq] | 1 | [Zmq] |
3124 | 2 | EndpointDir = /tmp | 2 | EndpointDir = /tmp |
3126 | 3 | Default.Twoway.Timeout = 5000 | 3 | # We set the idle timeout to something much larger than the expected |
3127 | 4 | # time for the test to finish, so we don't see a bogus completion | ||
3128 | 5 | # of the slow call due to the timeout on the client side triggering, | ||
3129 | 6 | # rather than the server shutting down. | ||
3130 | 7 | Default.Twoway.Timeout = 10000 | ||
3131 | 4 | 8 | ||
3132 | === modified file 'test/gtest/scopes/OptionSelectorFilter/OptionSelectorFilter_test.cpp' | |||
3133 | --- test/gtest/scopes/OptionSelectorFilter/OptionSelectorFilter_test.cpp 2014-05-15 08:12:32 +0000 | |||
3134 | +++ test/gtest/scopes/OptionSelectorFilter/OptionSelectorFilter_test.cpp 2014-05-21 14:02:43 +0000 | |||
3135 | @@ -62,10 +62,12 @@ | |||
3136 | 62 | 62 | ||
3137 | 63 | FilterState fstate; | 63 | FilterState fstate; |
3138 | 64 | EXPECT_FALSE(fstate.has_filter("f1")); | 64 | EXPECT_FALSE(fstate.has_filter("f1")); |
3139 | 65 | EXPECT_FALSE(filter1->has_active_option(fstate)); | ||
3140 | 65 | 66 | ||
3141 | 66 | // enable option1 | 67 | // enable option1 |
3142 | 67 | filter1->update_state(fstate, option1, true); | 68 | filter1->update_state(fstate, option1, true); |
3143 | 68 | EXPECT_TRUE(fstate.has_filter("f1")); | 69 | EXPECT_TRUE(fstate.has_filter("f1")); |
3144 | 70 | EXPECT_TRUE(filter1->has_active_option(fstate)); | ||
3145 | 69 | auto active = filter1->active_options(fstate); | 71 | auto active = filter1->active_options(fstate); |
3146 | 70 | EXPECT_EQ(1u, active.size()); | 72 | EXPECT_EQ(1u, active.size()); |
3147 | 71 | EXPECT_TRUE(active.find(option1) != active.end()); | 73 | EXPECT_TRUE(active.find(option1) != active.end()); |
3148 | @@ -95,6 +97,7 @@ | |||
3149 | 95 | filter1->update_state(fstate, option1, true); | 97 | filter1->update_state(fstate, option1, true); |
3150 | 96 | filter1->update_state(fstate, option2, true); | 98 | filter1->update_state(fstate, option2, true); |
3151 | 97 | EXPECT_TRUE(fstate.has_filter("f1")); | 99 | EXPECT_TRUE(fstate.has_filter("f1")); |
3152 | 100 | EXPECT_TRUE(filter1->has_active_option(fstate)); | ||
3153 | 98 | auto active = filter1->active_options(fstate); | 101 | auto active = filter1->active_options(fstate); |
3154 | 99 | EXPECT_EQ(2u, active.size()); | 102 | EXPECT_EQ(2u, active.size()); |
3155 | 100 | EXPECT_TRUE(active.find(option1) != active.end()); | 103 | EXPECT_TRUE(active.find(option1) != active.end()); |
3156 | 101 | 104 | ||
3157 | === added directory 'test/gtest/scopes/RadioButtonsFilter' | |||
3158 | === added file 'test/gtest/scopes/RadioButtonsFilter/CMakeLists.txt' | |||
3159 | --- test/gtest/scopes/RadioButtonsFilter/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
3160 | +++ test/gtest/scopes/RadioButtonsFilter/CMakeLists.txt 2014-05-21 14:02:43 +0000 | |||
3161 | @@ -0,0 +1,4 @@ | |||
3162 | 1 | add_executable(RadioButtonsFilter_test RadioButtonsFilter_test.cpp) | ||
3163 | 2 | target_link_libraries(RadioButtonsFilter_test ${TESTLIBS}) | ||
3164 | 3 | |||
3165 | 4 | add_test(RadioButtonsFilter RadioButtonsFilter_test) | ||
3166 | 0 | 5 | ||
3167 | === added file 'test/gtest/scopes/RadioButtonsFilter/RadioButtonsFilter_test.cpp' | |||
3168 | --- test/gtest/scopes/RadioButtonsFilter/RadioButtonsFilter_test.cpp 1970-01-01 00:00:00 +0000 | |||
3169 | +++ test/gtest/scopes/RadioButtonsFilter/RadioButtonsFilter_test.cpp 2014-05-21 14:02:43 +0000 | |||
3170 | @@ -0,0 +1,71 @@ | |||
3171 | 1 | /* | ||
3172 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
3173 | 3 | * | ||
3174 | 4 | * This program is free software: you can redistribute it and/or modify | ||
3175 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
3176 | 6 | * published by the Free Software Foundation. | ||
3177 | 7 | * | ||
3178 | 8 | * This program is distributed in the hope that it will be useful, | ||
3179 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3180 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3181 | 11 | * GNU Lesser General Public License for more details. | ||
3182 | 12 | * | ||
3183 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
3184 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3185 | 15 | * | ||
3186 | 16 | * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com> | ||
3187 | 17 | */ | ||
3188 | 18 | |||
3189 | 19 | #include <gtest/gtest.h> | ||
3190 | 20 | #include <unity/scopes/FilterState.h> | ||
3191 | 21 | #include <unity/scopes/RadioButtonsFilter.h> | ||
3192 | 22 | #include <unity/UnityExceptions.h> | ||
3193 | 23 | |||
3194 | 24 | using namespace unity::scopes; | ||
3195 | 25 | using namespace unity::scopes::internal; | ||
3196 | 26 | |||
3197 | 27 | TEST(RadioButtonsFilter, basic) | ||
3198 | 28 | { | ||
3199 | 29 | auto filter1 = RadioButtonsFilter::create("f1", "Choose"); | ||
3200 | 30 | EXPECT_EQ("f1", filter1->id()); | ||
3201 | 31 | EXPECT_EQ("Choose", filter1->label()); | ||
3202 | 32 | EXPECT_EQ(0u, filter1->options().size()); | ||
3203 | 33 | |||
3204 | 34 | filter1->add_option("a", "A"); | ||
3205 | 35 | filter1->add_option("b", "B"); | ||
3206 | 36 | |||
3207 | 37 | auto opts = filter1->options(); | ||
3208 | 38 | EXPECT_EQ(2u, opts.size()); | ||
3209 | 39 | EXPECT_EQ("a", opts.front()->id()); | ||
3210 | 40 | EXPECT_EQ("A", opts.front()->label()); | ||
3211 | 41 | EXPECT_EQ("b", opts.back()->id()); | ||
3212 | 42 | EXPECT_EQ("B", opts.back()->label()); | ||
3213 | 43 | } | ||
3214 | 44 | |||
3215 | 45 | TEST(RadioButtonsFilter, selection) | ||
3216 | 46 | { | ||
3217 | 47 | auto filter1 = RadioButtonsFilter::create("f1", "Options"); | ||
3218 | 48 | auto option1 = filter1->add_option("1", "Option 1"); | ||
3219 | 49 | auto option2 = filter1->add_option("2", "Option 2"); | ||
3220 | 50 | |||
3221 | 51 | FilterState fstate; | ||
3222 | 52 | EXPECT_FALSE(fstate.has_filter("f1")); | ||
3223 | 53 | EXPECT_EQ(nullptr, filter1->active_option(fstate)); | ||
3224 | 54 | EXPECT_FALSE(filter1->has_active_option(fstate)); | ||
3225 | 55 | |||
3226 | 56 | // enable option1 | ||
3227 | 57 | filter1->update_state(fstate, option1, true); | ||
3228 | 58 | EXPECT_TRUE(fstate.has_filter("f1")); | ||
3229 | 59 | auto active = filter1->active_option(fstate); | ||
3230 | 60 | EXPECT_EQ("1", active->id()); | ||
3231 | 61 | |||
3232 | 62 | // enable option2, option1 get disabled | ||
3233 | 63 | filter1->update_state(fstate, option2, true); | ||
3234 | 64 | active = filter1->active_option(fstate); | ||
3235 | 65 | EXPECT_EQ("2", active->id()); | ||
3236 | 66 | |||
3237 | 67 | // disable option1; filter state remains in the FilterState, just no options are selected | ||
3238 | 68 | filter1->update_state(fstate, option2, false); | ||
3239 | 69 | EXPECT_TRUE(fstate.has_filter("f1")); | ||
3240 | 70 | EXPECT_EQ(nullptr, filter1->active_option(fstate)); | ||
3241 | 71 | } | ||
3242 | 0 | 72 | ||
3243 | === added directory 'test/gtest/scopes/RatingFilter' | |||
3244 | === added file 'test/gtest/scopes/RatingFilter/CMakeLists.txt' | |||
3245 | --- test/gtest/scopes/RatingFilter/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
3246 | +++ test/gtest/scopes/RatingFilter/CMakeLists.txt 2014-05-21 14:02:43 +0000 | |||
3247 | @@ -0,0 +1,4 @@ | |||
3248 | 1 | add_executable(RatingFilter_test RatingFilter_test.cpp) | ||
3249 | 2 | target_link_libraries(RatingFilter_test ${TESTLIBS}) | ||
3250 | 3 | |||
3251 | 4 | add_test(RatingFilter RatingFilter_test) | ||
3252 | 0 | 5 | ||
3253 | === added file 'test/gtest/scopes/RatingFilter/RatingFilter_test.cpp' | |||
3254 | --- test/gtest/scopes/RatingFilter/RatingFilter_test.cpp 1970-01-01 00:00:00 +0000 | |||
3255 | +++ test/gtest/scopes/RatingFilter/RatingFilter_test.cpp 2014-05-21 14:02:43 +0000 | |||
3256 | @@ -0,0 +1,111 @@ | |||
3257 | 1 | /* | ||
3258 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
3259 | 3 | * | ||
3260 | 4 | * This program is free software: you can redistribute it and/or modify | ||
3261 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
3262 | 6 | * published by the Free Software Foundation. | ||
3263 | 7 | * | ||
3264 | 8 | * This program is distributed in the hope that it will be useful, | ||
3265 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3266 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3267 | 11 | * GNU Lesser General Public License for more details. | ||
3268 | 12 | * | ||
3269 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
3270 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3271 | 15 | * | ||
3272 | 16 | * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com> | ||
3273 | 17 | */ | ||
3274 | 18 | |||
3275 | 19 | #include <gtest/gtest.h> | ||
3276 | 20 | #include <unity/scopes/FilterState.h> | ||
3277 | 21 | #include <unity/scopes/RatingFilter.h> | ||
3278 | 22 | #include <unity/UnityExceptions.h> | ||
3279 | 23 | |||
3280 | 24 | using namespace unity::scopes; | ||
3281 | 25 | using namespace unity::scopes::internal; | ||
3282 | 26 | |||
3283 | 27 | TEST(RatingFilter, basic) | ||
3284 | 28 | { | ||
3285 | 29 | { | ||
3286 | 30 | auto filter1 = RatingFilter::create("f1", "Rating"); | ||
3287 | 31 | filter1->set_on_icon("foo"); | ||
3288 | 32 | filter1->set_off_icon("bar"); | ||
3289 | 33 | EXPECT_EQ("f1", filter1->id()); | ||
3290 | 34 | EXPECT_EQ("Rating", filter1->label()); | ||
3291 | 35 | EXPECT_EQ("foo", filter1->on_icon()); | ||
3292 | 36 | EXPECT_EQ("bar", filter1->off_icon()); | ||
3293 | 37 | EXPECT_EQ(0u, filter1->options().size()); | ||
3294 | 38 | |||
3295 | 39 | auto o1 = filter1->add_option("a", "A"); | ||
3296 | 40 | auto o2 = filter1->add_option("b", "B"); | ||
3297 | 41 | EXPECT_EQ("a", o1->id()); | ||
3298 | 42 | EXPECT_EQ("b", o2->id()); | ||
3299 | 43 | |||
3300 | 44 | auto opts = filter1->options(); | ||
3301 | 45 | EXPECT_EQ(2u, opts.size()); | ||
3302 | 46 | EXPECT_EQ("a", opts.front()->id()); | ||
3303 | 47 | EXPECT_EQ("A", opts.front()->label()); | ||
3304 | 48 | EXPECT_EQ("b", opts.back()->id()); | ||
3305 | 49 | EXPECT_EQ("B", opts.back()->label()); | ||
3306 | 50 | } | ||
3307 | 51 | |||
3308 | 52 | { | ||
3309 | 53 | auto filter1 = RatingFilter::create("f1", "Rating", 3); | ||
3310 | 54 | EXPECT_EQ("f1", filter1->id()); | ||
3311 | 55 | EXPECT_EQ("Rating", filter1->label()); | ||
3312 | 56 | |||
3313 | 57 | auto opts = filter1->options(); | ||
3314 | 58 | EXPECT_EQ(3u, opts.size()); | ||
3315 | 59 | auto it = opts.begin(); | ||
3316 | 60 | EXPECT_EQ("1", (*it)->id()); | ||
3317 | 61 | EXPECT_EQ("1+", (*it)->label()); | ||
3318 | 62 | EXPECT_EQ("2", (*++it)->id()); | ||
3319 | 63 | EXPECT_EQ("2+", (*it)->label()); | ||
3320 | 64 | EXPECT_EQ("3", (*++it)->id()); | ||
3321 | 65 | EXPECT_EQ("3", (*it)->label()); | ||
3322 | 66 | } | ||
3323 | 67 | |||
3324 | 68 | { | ||
3325 | 69 | EXPECT_THROW(RatingFilter::create("f1", "Rating", 11), unity::LogicException); | ||
3326 | 70 | } | ||
3327 | 71 | |||
3328 | 72 | { | ||
3329 | 73 | auto filter1 = RatingFilter::create("f1", "Rating", 10); | ||
3330 | 74 | EXPECT_THROW(filter1->add_option("11", "11"), unity::LogicException); | ||
3331 | 75 | } | ||
3332 | 76 | } | ||
3333 | 77 | |||
3334 | 78 | TEST(RatingFilter, selection) | ||
3335 | 79 | { | ||
3336 | 80 | auto filter1 = RatingFilter::create("f1", "Rating", 2); | ||
3337 | 81 | |||
3338 | 82 | FilterState fstate; | ||
3339 | 83 | EXPECT_FALSE(fstate.has_filter("f1")); | ||
3340 | 84 | EXPECT_FALSE(filter1->has_active_rating(fstate)); | ||
3341 | 85 | EXPECT_EQ(nullptr, filter1->active_rating(fstate)); | ||
3342 | 86 | |||
3343 | 87 | auto opts = filter1->options(); | ||
3344 | 88 | EXPECT_EQ(2u, opts.size()); | ||
3345 | 89 | |||
3346 | 90 | auto it = opts.begin(); | ||
3347 | 91 | auto option1 = *(it++); | ||
3348 | 92 | auto option2 = *it; | ||
3349 | 93 | |||
3350 | 94 | // enable option1 | ||
3351 | 95 | filter1->update_state(fstate, option1, true); | ||
3352 | 96 | EXPECT_TRUE(fstate.has_filter("f1")); | ||
3353 | 97 | EXPECT_TRUE(filter1->has_active_rating(fstate)); | ||
3354 | 98 | auto active = filter1->active_rating(fstate); | ||
3355 | 99 | EXPECT_EQ("1", active->id()); | ||
3356 | 100 | |||
3357 | 101 | // enable option2, option1 get disabled | ||
3358 | 102 | filter1->update_state(fstate, option2, true); | ||
3359 | 103 | active = filter1->active_rating(fstate); | ||
3360 | 104 | EXPECT_EQ("2", active->id()); | ||
3361 | 105 | |||
3362 | 106 | // disable option1; filter state remains in the FilterState, just no options are selected | ||
3363 | 107 | filter1->update_state(fstate, option2, false); | ||
3364 | 108 | EXPECT_TRUE(fstate.has_filter("f1")); | ||
3365 | 109 | EXPECT_FALSE(filter1->has_active_rating(fstate)); | ||
3366 | 110 | EXPECT_EQ(nullptr, filter1->active_rating(fstate)); | ||
3367 | 111 | } | ||
3368 | 0 | 112 | ||
3369 | === modified file 'test/gtest/scopes/Registry/Registry_test.cpp' | |||
3370 | --- test/gtest/scopes/Registry/Registry_test.cpp 2014-05-06 04:29:02 +0000 | |||
3371 | +++ test/gtest/scopes/Registry/Registry_test.cpp 2014-05-21 14:02:43 +0000 | |||
3372 | @@ -77,25 +77,6 @@ | |||
3373 | 77 | Runtime::UPtr rt = Runtime::create(TEST_RUNTIME_FILE); | 77 | Runtime::UPtr rt = Runtime::create(TEST_RUNTIME_FILE); |
3374 | 78 | RegistryProxy r = rt->registry(); | 78 | RegistryProxy r = rt->registry(); |
3375 | 79 | 79 | ||
3376 | 80 | // wait for the registry to become available on middleware | ||
3377 | 81 | // FIXME: remove this once we have async queries and can set arbitrary timeout when calling registry | ||
3378 | 82 | const int num_retries = 10; | ||
3379 | 83 | bool registry_started = false; | ||
3380 | 84 | for (int i = 0; i < num_retries; ++i) | ||
3381 | 85 | { | ||
3382 | 86 | try | ||
3383 | 87 | { | ||
3384 | 88 | r->list(); // this will throw if the registry is not yet available on middleware | ||
3385 | 89 | registry_started = true; | ||
3386 | 90 | break; | ||
3387 | 91 | } | ||
3388 | 92 | catch (std::exception const&) | ||
3389 | 93 | { | ||
3390 | 94 | sleep(1); | ||
3391 | 95 | } | ||
3392 | 96 | } | ||
3393 | 97 | ASSERT_TRUE(registry_started); | ||
3394 | 98 | |||
3395 | 99 | auto meta = r->get_metadata("testscopeA"); | 80 | auto meta = r->get_metadata("testscopeA"); |
3396 | 100 | EXPECT_EQ("testscopeA", meta.scope_id()); | 81 | EXPECT_EQ("testscopeA", meta.scope_id()); |
3397 | 101 | EXPECT_EQ("Canonical Ltd.", meta.author()); | 82 | EXPECT_EQ("Canonical Ltd.", meta.author()); |
3398 | 102 | 83 | ||
3399 | === modified file 'test/gtest/scopes/Registry/Zmq.ini.in' | |||
3400 | --- test/gtest/scopes/Registry/Zmq.ini.in 2014-05-06 09:00:45 +0000 | |||
3401 | +++ test/gtest/scopes/Registry/Zmq.ini.in 2014-05-21 14:02:43 +0000 | |||
3402 | @@ -1,2 +1,3 @@ | |||
3403 | 1 | [Zmq] | 1 | [Zmq] |
3404 | 2 | EndpointDir = /tmp | 2 | EndpointDir = /tmp |
3405 | 3 | Default.Twoway.Timeout = 2000 | ||
3406 | 3 | 4 | ||
3407 | === modified file 'test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py' | |||
3408 | --- test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py 2014-05-09 09:56:09 +0000 | |||
3409 | +++ test/gtest/scopes/internal/smartscopes/SmartScopesClient/FakeSss.py 2014-05-21 14:02:43 +0000 | |||
3410 | @@ -60,7 +60,7 @@ | |||
3411 | 60 | [{"base_url": "http://127.0.0.1:' + str(port) + '/fail", "id" : "fail.scope", "name": "Fail Scope", "description": "Fails due to no author.", "icon": "icon" },\ | 60 | [{"base_url": "http://127.0.0.1:' + str(port) + '/fail", "id" : "fail.scope", "name": "Fail Scope", "description": "Fails due to no author.", "icon": "icon" },\ |
3412 | 61 | {"base_url": "http://127.0.0.1:' + str(port) + '/demo", "id" : "dummy.scope", "name": "Dummy Demo Scope", "description": "Dummy demo scope.", "author": "Mr.Fake", "icon": "icon" },\ | 61 | {"base_url": "http://127.0.0.1:' + str(port) + '/demo", "id" : "dummy.scope", "name": "Dummy Demo Scope", "description": "Dummy demo scope.", "author": "Mr.Fake", "icon": "icon" },\ |
3413 | 62 | {"base_url": "http://127.0.0.1:' + str(port) + '/fail2", "name": "Fail Scope 2", "description": "Fails due to no id.", "author": "Mr.Fake", "icon": "icon" },\ | 62 | {"base_url": "http://127.0.0.1:' + str(port) + '/fail2", "name": "Fail Scope 2", "description": "Fails due to no id.", "author": "Mr.Fake", "icon": "icon" },\ |
3415 | 63 | {"base_url": "http://127.0.0.1:' + str(port) + '/demo2", "id" : "dummy.scope.2", "name": "Dummy Demo Scope 2", "description": "Dummy demo scope 2.", "author": "Mr.Fake", "art": "art", "invisible": true },\ | 63 | {"base_url": "http://127.0.0.1:' + str(port) + '/demo2", "id" : "dummy.scope.2", "name": "Dummy Demo Scope 2", "description": "Dummy demo scope 2.", "author": "Mr.Fake", "art": "art", "invisible": true, "appearance": {"background": "#00BEEF"} },\ |
3416 | 64 | {"id" : "fail.scope.3", "name": "Fail Scope 3", "description": "Fails due to no base_url.", "author": "Mr.Fake", "art": "art" }]' | 64 | {"id" : "fail.scope.3", "name": "Fail Scope 3", "description": "Fails due to no base_url.", "author": "Mr.Fake", "art": "art" }]' |
3417 | 65 | 65 | ||
3418 | 66 | search_response = '\ | 66 | search_response = '\ |
3419 | 67 | 67 | ||
3420 | === modified file 'test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp' | |||
3421 | --- test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp 2014-05-09 09:56:09 +0000 | |||
3422 | +++ test/gtest/scopes/internal/smartscopes/SmartScopesClient/SmartScopesClient_test.cpp 2014-05-21 14:02:43 +0000 | |||
3423 | @@ -81,6 +81,7 @@ | |||
3424 | 81 | EXPECT_EQ("icon", *scopes[0].icon); | 81 | EXPECT_EQ("icon", *scopes[0].icon); |
3425 | 82 | EXPECT_EQ(nullptr, scopes[0].art); | 82 | EXPECT_EQ(nullptr, scopes[0].art); |
3426 | 83 | EXPECT_FALSE(scopes[0].invisible); | 83 | EXPECT_FALSE(scopes[0].invisible); |
3427 | 84 | EXPECT_EQ(nullptr, scopes[0].appearance); | ||
3428 | 84 | 85 | ||
3429 | 85 | EXPECT_EQ("dummy.scope.2", scopes[1].id); | 86 | EXPECT_EQ("dummy.scope.2", scopes[1].id); |
3430 | 86 | EXPECT_EQ("Dummy Demo Scope 2", scopes[1].name); | 87 | EXPECT_EQ("Dummy Demo Scope 2", scopes[1].name); |
3431 | @@ -90,6 +91,7 @@ | |||
3432 | 90 | EXPECT_EQ(nullptr, scopes[1].icon); | 91 | EXPECT_EQ(nullptr, scopes[1].icon); |
3433 | 91 | EXPECT_EQ("art", *scopes[1].art); | 92 | EXPECT_EQ("art", *scopes[1].art); |
3434 | 92 | EXPECT_TRUE(scopes[1].invisible); | 93 | EXPECT_TRUE(scopes[1].invisible); |
3435 | 94 | EXPECT_EQ("#00BEEF", (*scopes[1].appearance)["background"].get_string()); | ||
3436 | 93 | } | 95 | } |
3437 | 94 | 96 | ||
3438 | 95 | TEST_F(SmartScopesClientTest, search) | 97 | TEST_F(SmartScopesClientTest, search) |
3439 | 96 | 98 | ||
3440 | === modified file 'test/gtest/scopes/internal/zmq_middleware/CMakeLists.txt' | |||
3441 | --- test/gtest/scopes/internal/zmq_middleware/CMakeLists.txt 2014-04-14 23:47:33 +0000 | |||
3442 | +++ test/gtest/scopes/internal/zmq_middleware/CMakeLists.txt 2014-05-21 14:02:43 +0000 | |||
3443 | @@ -1,4 +1,5 @@ | |||
3444 | 1 | add_subdirectory(ObjectAdapter) | 1 | add_subdirectory(ObjectAdapter) |
3445 | 2 | add_subdirectory(PubSub) | ||
3446 | 2 | add_subdirectory(RegistryI) | 3 | add_subdirectory(RegistryI) |
3447 | 3 | add_subdirectory(ServantBase) | 4 | add_subdirectory(ServantBase) |
3448 | 4 | add_subdirectory(StopPublisher) | 5 | add_subdirectory(StopPublisher) |
3449 | 5 | 6 | ||
3450 | === modified file 'test/gtest/scopes/internal/zmq_middleware/ObjectAdapter/ObjectAdapter_test.cpp' | |||
3451 | --- test/gtest/scopes/internal/zmq_middleware/ObjectAdapter/ObjectAdapter_test.cpp 2014-05-02 00:00:08 +0000 | |||
3452 | +++ test/gtest/scopes/internal/zmq_middleware/ObjectAdapter/ObjectAdapter_test.cpp 2014-05-21 14:02:43 +0000 | |||
3453 | @@ -1071,8 +1071,7 @@ | |||
3454 | 1071 | { | 1071 | { |
3455 | 1072 | EXPECT_STREQ("unity::scopes::MiddlewareException: ObjectAdapter::run_workers(): broker thread failure " | 1072 | EXPECT_STREQ("unity::scopes::MiddlewareException: ObjectAdapter::run_workers(): broker thread failure " |
3456 | 1073 | "(adapter: testscope):\n" | 1073 | "(adapter: testscope):\n" |
3459 | 1074 | " unity::scopes::MiddlewareException: ObjectAdapter: broker thread failure " | 1074 | " unity::scopes::MiddlewareException: safe_bind(): address in use: ipc://testscope", e.what()); |
3458 | 1075 | "(adapter: testscope): address in use: ipc://testscope", e.what()); | ||
3460 | 1076 | } | 1075 | } |
3461 | 1077 | 1076 | ||
3462 | 1078 | { | 1077 | { |
3463 | @@ -1108,8 +1107,7 @@ | |||
3464 | 1108 | { | 1107 | { |
3465 | 1109 | EXPECT_STREQ("unity::scopes::MiddlewareException: ObjectAdapter::run_workers(): broker thread failure " | 1108 | EXPECT_STREQ("unity::scopes::MiddlewareException: ObjectAdapter::run_workers(): broker thread failure " |
3466 | 1110 | "(adapter: testscope):\n" | 1109 | "(adapter: testscope):\n" |
3469 | 1111 | " unity::scopes::MiddlewareException: ObjectAdapter: broker thread failure " | 1110 | " unity::scopes::MiddlewareException: safe_bind(): address in use: ipc://testscope", e.what()); |
3468 | 1112 | "(adapter: testscope): address in use: ipc://testscope", e.what()); | ||
3470 | 1113 | } | 1111 | } |
3471 | 1114 | 1112 | ||
3472 | 1115 | { | 1113 | { |
3473 | 1116 | 1114 | ||
3474 | === added directory 'test/gtest/scopes/internal/zmq_middleware/PubSub' | |||
3475 | === added file 'test/gtest/scopes/internal/zmq_middleware/PubSub/CMakeLists.txt' | |||
3476 | --- test/gtest/scopes/internal/zmq_middleware/PubSub/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
3477 | +++ test/gtest/scopes/internal/zmq_middleware/PubSub/CMakeLists.txt 2014-05-21 14:02:43 +0000 | |||
3478 | @@ -0,0 +1,6 @@ | |||
3479 | 1 | configure_file(Zmq.ini.in Zmq.ini) | ||
3480 | 2 | |||
3481 | 3 | add_executable(PubSub_test PubSub_test.cpp) | ||
3482 | 4 | target_link_libraries(PubSub_test ${LIBS} ${TESTLIBS}) | ||
3483 | 5 | |||
3484 | 6 | add_test(PubSub PubSub_test) | ||
3485 | 0 | 7 | ||
3486 | === added file 'test/gtest/scopes/internal/zmq_middleware/PubSub/PubSub_test.cpp' | |||
3487 | --- test/gtest/scopes/internal/zmq_middleware/PubSub/PubSub_test.cpp 1970-01-01 00:00:00 +0000 | |||
3488 | +++ test/gtest/scopes/internal/zmq_middleware/PubSub/PubSub_test.cpp 2014-05-21 14:02:43 +0000 | |||
3489 | @@ -0,0 +1,237 @@ | |||
3490 | 1 | /* | ||
3491 | 2 | * Copyright (C) 2014 Canonical Ltd | ||
3492 | 3 | * | ||
3493 | 4 | * This program is free software: you can redistribute it and/or modify | ||
3494 | 5 | * it under the terms of the GNU Lesser General Public License version 3 as | ||
3495 | 6 | * published by the Free Software Foundation. | ||
3496 | 7 | * | ||
3497 | 8 | * This program is distributed in the hope that it will be useful, | ||
3498 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3499 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3500 | 11 | * GNU Lesser General Public License for more details. | ||
3501 | 12 | * | ||
3502 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
3503 | 14 | * along with this program. If not, see <http://www.gnu.org/lzmqnses/>. | ||
3504 | 15 | * | ||
3505 | 16 | * Authored by: Michi Henning <michi.henning@canonical.com> | ||
3506 | 17 | */ | ||
3507 | 18 | |||
3508 | 19 | #include <scope-api-testconfig.h> | ||
3509 | 20 | #include <unity/scopes/internal/RuntimeImpl.h> | ||
3510 | 21 | #include <unity/scopes/internal/zmq_middleware/ZmqMiddleware.h> | ||
3511 | 22 | #include <unity/scopes/ScopeExceptions.h> | ||
3512 | 23 | |||
3513 | 24 | #include <gtest/gtest.h> | ||
3514 | 25 | #include <condition_variable> | ||
3515 | 26 | #include <mutex> | ||
3516 | 27 | |||
3517 | 28 | using namespace std::placeholders; | ||
3518 | 29 | using namespace unity::scopes; | ||
3519 | 30 | using namespace unity::scopes::internal; | ||
3520 | 31 | using namespace unity::scopes::internal::zmq_middleware; | ||
3521 | 32 | |||
3522 | 33 | TEST(PubSub, endpoints) | ||
3523 | 34 | { | ||
3524 | 35 | ZmqMiddleware mw("testscope", (RuntimeImpl*)0x1, | ||
3525 | 36 | TEST_BUILD_ROOT "/gtest/scopes/internal/zmq_middleware/ObjectAdapter/Zmq.ini"); | ||
3526 | 37 | |||
3527 | 38 | auto publisher = mw.create_publisher("testpublisher"); | ||
3528 | 39 | auto subscriber = mw.create_subscriber("testpublisher", ""); | ||
3529 | 40 | |||
3530 | 41 | EXPECT_EQ("ipc:///tmp/testpublisher-p", publisher->endpoint()); | ||
3531 | 42 | EXPECT_EQ(subscriber->endpoint(), publisher->endpoint()); | ||
3532 | 43 | } | ||
3533 | 44 | |||
3534 | 45 | TEST(PubSub, exceptions) | ||
3535 | 46 | { | ||
3536 | 47 | ZmqMiddleware mw("testscope", (RuntimeImpl*)0x1, | ||
3537 | 48 | TEST_BUILD_ROOT "/gtest/scopes/internal/zmq_middleware/ObjectAdapter/Zmq.ini"); | ||
3538 | 49 | |||
3539 | 50 | // Test that only one publisher can be created on a single endpoint | ||
3540 | 51 | auto publisher = mw.create_publisher("testpublisher"); | ||
3541 | 52 | try | ||
3542 | 53 | { | ||
3543 | 54 | auto publisher2 = mw.create_publisher("testpublisher"); | ||
3544 | 55 | FAIL(); | ||
3545 | 56 | } | ||
3546 | 57 | catch (MiddlewareException const& e) | ||
3547 | 58 | { | ||
3548 | 59 | EXPECT_STREQ("unity::scopes::MiddlewareException: ZmqPublisher(): publisher thread failed to start " | ||
3549 | 60 | "(endpoint: ipc:///tmp/testpublisher-p):\n unity::scopes::MiddlewareException: " | ||
3550 | 61 | "safe_bind(): address in use: ipc:///tmp/testpublisher-p", | ||
3551 | 62 | e.what()); | ||
3552 | 63 | } | ||
3553 | 64 | |||
3554 | 65 | // Test that multiple subscribers can be created on a single endpoint | ||
3555 | 66 | auto subscriber = mw.create_subscriber("testpublisher", ""); | ||
3556 | 67 | try | ||
3557 | 68 | { | ||
3558 | 69 | auto subscriber2 = mw.create_subscriber("testpublisher", "testtopic1"); | ||
3559 | 70 | auto subscriber3 = mw.create_subscriber("testpublisher", "testtopic2"); | ||
3560 | 71 | auto subscriber4 = mw.create_subscriber("testpublisher", "testtopic3"); | ||
3561 | 72 | auto subscriber5 = mw.create_subscriber("testpublisher", "testtopic4"); | ||
3562 | 73 | } | ||
3563 | 74 | catch (MiddlewareException const& e) | ||
3564 | 75 | { | ||
3565 | 76 | FAIL(); | ||
3566 | 77 | } | ||
3567 | 78 | |||
3568 | 79 | // Test that an invalid publisher_id throws | ||
3569 | 80 | try | ||
3570 | 81 | { | ||
3571 | 82 | auto publisher2 = mw.create_publisher("/test/"); | ||
3572 | 83 | FAIL(); | ||
3573 | 84 | } | ||
3574 | 85 | catch (MiddlewareException const& e) | ||
3575 | 86 | { | ||
3576 | 87 | EXPECT_STREQ("unity::scopes::MiddlewareException: ZmqPublisher(): A publisher cannot contain a '/' in its id", | ||
3577 | 88 | e.what()); | ||
3578 | 89 | } | ||
3579 | 90 | try | ||
3580 | 91 | { | ||
3581 | 92 | auto subscriber2 = mw.create_subscriber("/test/", "testtopic"); | ||
3582 | 93 | FAIL(); | ||
3583 | 94 | } | ||
3584 | 95 | catch (MiddlewareException const& e) | ||
3585 | 96 | { | ||
3586 | 97 | EXPECT_STREQ("unity::scopes::MiddlewareException: ZmqSubscriber(): A publisher cannot contain a '/' in its id", | ||
3587 | 98 | e.what()); | ||
3588 | 99 | } | ||
3589 | 100 | } | ||
3590 | 101 | |||
3591 | 102 | class SubMsgReceiver | ||
3592 | 103 | { | ||
3593 | 104 | public: | ||
3594 | 105 | void receive1(std::string const& message) | ||
3595 | 106 | { | ||
3596 | 107 | last_sub_index_ = 1; | ||
3597 | 108 | last_message_ = message; | ||
3598 | 109 | received(); | ||
3599 | 110 | } | ||
3600 | 111 | |||
3601 | 112 | void receive2(std::string const& message) | ||
3602 | 113 | { | ||
3603 | 114 | last_sub_index_ = 2; | ||
3604 | 115 | last_message_ = message; | ||
3605 | 116 | received(); | ||
3606 | 117 | } | ||
3607 | 118 | |||
3608 | 119 | void receive3(std::string const& message) | ||
3609 | 120 | { | ||
3610 | 121 | last_sub_index_ = 3; | ||
3611 | 122 | last_message_ = message; | ||
3612 | 123 | received(); | ||
3613 | 124 | } | ||
3614 | 125 | |||
3615 | 126 | void receive4(std::string const& message) | ||
3616 | 127 | { | ||
3617 | 128 | last_sub_index_ = 4; | ||
3618 | 129 | last_message_ = message; | ||
3619 | 130 | received(); | ||
3620 | 131 | } | ||
3621 | 132 | |||
3622 | 133 | void received() | ||
3623 | 134 | { | ||
3624 | 135 | // Signal wait_for_message | ||
3625 | 136 | std::lock_guard<std::mutex> lock(mutex_); | ||
3626 | 137 | message_received_ = true; | ||
3627 | 138 | cond_.notify_one(); | ||
3628 | 139 | } | ||
3629 | 140 | |||
3630 | 141 | bool wait_for_message() | ||
3631 | 142 | { | ||
3632 | 143 | std::unique_lock<std::mutex> lock(mutex_); | ||
3633 | 144 | bool message_received = cond_.wait_for(lock, std::chrono::milliseconds(500), [this] { return this->message_received_; }); | ||
3634 | 145 | message_received_ = false; | ||
3635 | 146 | return message_received; | ||
3636 | 147 | } | ||
3637 | 148 | |||
3638 | 149 | int last_sub_index_ = 0; | ||
3639 | 150 | std::string last_message_; | ||
3640 | 151 | |||
3641 | 152 | bool message_received_ = false; | ||
3642 | 153 | std::mutex mutex_; | ||
3643 | 154 | std::condition_variable cond_; | ||
3644 | 155 | }; | ||
3645 | 156 | |||
3646 | 157 | TEST(PubSub, send_receive) | ||
3647 | 158 | { | ||
3648 | 159 | SubMsgReceiver message_receiver; | ||
3649 | 160 | |||
3650 | 161 | ZmqMiddleware mw("testscope", (RuntimeImpl*)0x1, | ||
3651 | 162 | TEST_BUILD_ROOT "/gtest/scopes/internal/zmq_middleware/ObjectAdapter/Zmq.ini"); | ||
3652 | 163 | |||
3653 | 164 | // Create 2 publishers | ||
3654 | 165 | auto publisher = mw.create_publisher("testpublisher"); | ||
3655 | 166 | auto publisher2 = mw.create_publisher("testpublisher2"); | ||
3656 | 167 | |||
3657 | 168 | // Create a few subscribers | ||
3658 | 169 | auto subscriber1 = mw.create_subscriber("testpublisher", "testtopic1"); | ||
3659 | 170 | subscriber1->set_message_callback(std::bind(&SubMsgReceiver::receive1, &message_receiver, _1)); | ||
3660 | 171 | |||
3661 | 172 | auto subscriber2 = mw.create_subscriber("testpublisher", "testtopic2"); | ||
3662 | 173 | subscriber2->set_message_callback(std::bind(&SubMsgReceiver::receive2, &message_receiver, _1)); | ||
3663 | 174 | |||
3664 | 175 | auto subscriber3 = mw.create_subscriber("testpublisher", ""); | ||
3665 | 176 | subscriber3->set_message_callback(std::bind(&SubMsgReceiver::receive3, &message_receiver, _1)); | ||
3666 | 177 | |||
3667 | 178 | auto subscriber4 = mw.create_subscriber("testpublisher2", "testtopic4"); | ||
3668 | 179 | subscriber4->set_message_callback(std::bind(&SubMsgReceiver::receive4, &message_receiver, _1)); | ||
3669 | 180 | |||
3670 | 181 | // Give the subscribers some time to connect | ||
3671 | 182 | std::this_thread::sleep_for(std::chrono::milliseconds(500)); | ||
3672 | 183 | |||
3673 | 184 | // Send a "testtopic1" topic message (subscriber1) | ||
3674 | 185 | publisher->send_message("hello", "testtopic1"); | ||
3675 | 186 | EXPECT_TRUE(message_receiver.wait_for_message()); | ||
3676 | 187 | EXPECT_EQ(1, message_receiver.last_sub_index_); | ||
3677 | 188 | EXPECT_EQ("hello", message_receiver.last_message_); | ||
3678 | 189 | |||
3679 | 190 | // Send a blank "testtopic2" topic message (subscriber2) | ||
3680 | 191 | publisher->send_message("", "testtopic2"); | ||
3681 | 192 | EXPECT_TRUE(message_receiver.wait_for_message()); | ||
3682 | 193 | EXPECT_EQ(2, message_receiver.last_sub_index_); | ||
3683 | 194 | EXPECT_EQ("", message_receiver.last_message_); | ||
3684 | 195 | |||
3685 | 196 | // Send an empty topic message (subscriber3) | ||
3686 | 197 | publisher->send_message("hello again!", ""); | ||
3687 | 198 | EXPECT_TRUE(message_receiver.wait_for_message()); | ||
3688 | 199 | EXPECT_EQ(3, message_receiver.last_sub_index_); | ||
3689 | 200 | EXPECT_EQ("hello again!", message_receiver.last_message_); | ||
3690 | 201 | |||
3691 | 202 | // Send a "testtopic4" topic message (subscriber4) | ||
3692 | 203 | // (no message should be received as subscriber4 is subscribed to a different publisher) | ||
3693 | 204 | publisher->send_message("test", "testtopic4"); | ||
3694 | 205 | EXPECT_FALSE(message_receiver.wait_for_message()); | ||
3695 | 206 | |||
3696 | 207 | // Now send a "testtopic4" topic message from the correct publisher (subscriber4) | ||
3697 | 208 | publisher2->send_message("test", "testtopic4"); | ||
3698 | 209 | EXPECT_TRUE(message_receiver.wait_for_message()); | ||
3699 | 210 | EXPECT_EQ(4, message_receiver.last_sub_index_); | ||
3700 | 211 | EXPECT_EQ("test", message_receiver.last_message_); | ||
3701 | 212 | |||
3702 | 213 | // Send a "unknown" topic message | ||
3703 | 214 | // (no message should be received as none of the subscribers are listening for "unknown") | ||
3704 | 215 | publisher->send_message("hello?", "unknown"); | ||
3705 | 216 | EXPECT_FALSE(message_receiver.wait_for_message()); | ||
3706 | 217 | |||
3707 | 218 | publisher2->send_message("hello??", "unknown"); | ||
3708 | 219 | EXPECT_FALSE(message_receiver.wait_for_message()); | ||
3709 | 220 | } | ||
3710 | 221 | |||
3711 | 222 | TEST(PubSub, threading) | ||
3712 | 223 | { | ||
3713 | 224 | ZmqMiddleware mw("testscope", (RuntimeImpl*)0x1, | ||
3714 | 225 | TEST_BUILD_ROOT "/gtest/scopes/internal/zmq_middleware/ObjectAdapter/Zmq.ini"); | ||
3715 | 226 | |||
3716 | 227 | { | ||
3717 | 228 | // Create a publisher and a subscriber in seperate thread | ||
3718 | 229 | auto subscriber_future = std::async(std::launch::async, [&mw]{ return mw.create_subscriber("testpublisher", "testtopic"); }); | ||
3719 | 230 | auto publisher_future = std::async(std::launch::async, [&mw]{ return mw.create_publisher("testpublisher"); }); | ||
3720 | 231 | |||
3721 | 232 | // Obtain the publisher and subscriber handles | ||
3722 | 233 | MWSubscriber::UPtr subscriber = subscriber_future.get(); | ||
3723 | 234 | MWPublisher::UPtr publisher = publisher_future.get(); | ||
3724 | 235 | } | ||
3725 | 236 | // The publisher and subscriber are now destroyed in this thread (should not hang / crash) | ||
3726 | 237 | } | ||
3727 | 0 | 238 | ||
3728 | === added file 'test/gtest/scopes/internal/zmq_middleware/PubSub/Zmq.ini.in' | |||
3729 | --- test/gtest/scopes/internal/zmq_middleware/PubSub/Zmq.ini.in 1970-01-01 00:00:00 +0000 | |||
3730 | +++ test/gtest/scopes/internal/zmq_middleware/PubSub/Zmq.ini.in 2014-05-21 14:02:43 +0000 | |||
3731 | @@ -0,0 +1,2 @@ | |||
3732 | 1 | [Zmq] | ||
3733 | 2 | EndpointDir = /tmp | ||
3734 | 0 | 3 | ||
3735 | === modified file 'test/gtest/scopes/internal/zmq_middleware/RegistryI/RegistryI_test.cpp' | |||
3736 | --- test/gtest/scopes/internal/zmq_middleware/RegistryI/RegistryI_test.cpp 2014-05-09 08:51:19 +0000 | |||
3737 | +++ test/gtest/scopes/internal/zmq_middleware/RegistryI/RegistryI_test.cpp 2014-05-21 14:02:43 +0000 | |||
3738 | @@ -705,7 +705,7 @@ | |||
3739 | 705 | // check that we still have 1 child process | 705 | // check that we still have 1 child process |
3740 | 706 | EXPECT_EQ(1, process_count()); | 706 | EXPECT_EQ(1, process_count()); |
3741 | 707 | 707 | ||
3743 | 708 | std::this_thread::sleep_for(std::chrono::seconds{2}); | 708 | std::this_thread::sleep_for(std::chrono::seconds{3}); |
3744 | 709 | 709 | ||
3745 | 710 | // check now that the scope has shutdown automatically (timed out after 2s) | 710 | // check now that the scope has shutdown automatically (timed out after 2s) |
3746 | 711 | EXPECT_FALSE(reg->is_scope_running("testscopeB")); | 711 | EXPECT_FALSE(reg->is_scope_running("testscopeB")); |
FAILED: Continuous integration, rev:349 jenkins. qa.ubuntu. com/job/ unity-scopes- api-ci/ 378/ jenkins. qa.ubuntu. com/job/ unity-scopes- api-utopic- amd64-ci/ 5/console jenkins. qa.ubuntu. com/job/ unity-scopes- api-utopic- armhf-ci/ 5/console jenkins. qa.ubuntu. com/job/ unity-scopes- api-utopic- i386-ci/ 5/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity- scopes- api-ci/ 378/rebuild
http://