Merge lp:~dobey/dbus-cpp/merge-vivid into lp:dbus-cpp
- merge-vivid
- Merge into trunk
Proposed by
dobey
Status: | Merged |
---|---|
Merge reported by: | dobey |
Merged at revision: | not available |
Proposed branch: | lp:~dobey/dbus-cpp/merge-vivid |
Merge into: | lp:dbus-cpp |
Diff against target: |
610 lines (+253/-61) 15 files modified
debian/changelog (+47/-0) debian/libdbus-cpp5.symbols.32bit (+3/-2) debian/libdbus-cpp5.symbols.64bit (+3/-2) include/core/dbus/impl/object.h (+95/-34) include/core/dbus/impl/property.h (+21/-0) include/core/dbus/impl/signal.h (+7/-4) include/core/dbus/message.h (+2/-0) include/core/dbus/object.h (+8/-7) include/core/dbus/property.h (+8/-0) include/core/dbus/signal.h (+5/-2) src/core/dbus/bus.cpp (+13/-1) src/core/dbus/match_rule.cpp (+1/-8) src/core/dbus/message.cpp (+19/-0) src/core/dbus/service.cpp (+1/-1) tests/message_test.cpp (+20/-0) |
To merge this branch: | bzr merge lp:~dobey/dbus-cpp/merge-vivid |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phablet Team | Pending | ||
Review via email: mp+301712@code.launchpad.net |
Commit message
Merge newer code from vivid branch to trunk.
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'debian/changelog' |
2 | --- debian/changelog 2015-10-22 07:17:01 +0000 |
3 | +++ debian/changelog 2016-08-01 20:07:50 +0000 |
4 | @@ -23,6 +23,53 @@ |
5 | |
6 | -- Thomas Voß <thomas.voss@canonical.com> Tue, 21 Jul 2015 12:36:46 +0200 |
7 | |
8 | +dbus-cpp (4.3.0+15.04.20160114.2-0ubuntu1) vivid; urgency=medium |
9 | + |
10 | + [ CI Train Bot ] |
11 | + * debian/libdbus-cpp4.symbols.32bit: update to released version. |
12 | + * debian/libdbus-cpp4.symbols.64bit: update to released version. |
13 | + |
14 | + [ Thomas Voß ] |
15 | + * Add a proper operator<< for dbus::Message::Type. (LP: #1524131) |
16 | + |
17 | + -- Thomas Voß <ci-train-bot@canonical.com> Thu, 14 Jan 2016 21:51:19 +0000 |
18 | + |
19 | +dbus-cpp (4.3.0+15.04.20160112-0ubuntu1) vivid; urgency=medium |
20 | + |
21 | + * Only run dbus_shutdown if explicitly requested by env var. (LP: |
22 | + #1422304, #1526877) |
23 | + |
24 | + -- Thomas Voß <ci-train-bot@canonical.com> Tue, 12 Jan 2016 16:28:02 +0000 |
25 | + |
26 | +dbus-cpp (4.3.0+15.04.20151126-0ubuntu1) vivid; urgency=medium |
27 | + |
28 | + [ CI Train Bot ] |
29 | + * New rebuild forced. |
30 | + |
31 | + [ Thomas Voß ] |
32 | + * Ensure that Signal with non-void argument types correctly narrow |
33 | + their match rules. (LP: #1480877) |
34 | + |
35 | + -- Thomas Voß <ci-train-bot@canonical.com> Thu, 26 Nov 2015 07:31:37 +0000 |
36 | + |
37 | +dbus-cpp (4.3.0+15.04.20151023-0ubuntu1) vivid; urgency=medium |
38 | + |
39 | + [ CI Train Bot ] |
40 | + * New rebuild forced. |
41 | + |
42 | + [ Thomas Voß ] |
43 | + * Do not cache emitted values for stub signals. (LP: #1509285) |
44 | + |
45 | + -- Jim Hodapp <ci-train-bot@canonical.com> Fri, 23 Oct 2015 10:01:27 +0000 |
46 | + |
47 | +dbus-cpp (4.3.0+15.04.20151020-0ubuntu1) vivid; urgency=medium |
48 | + |
49 | + [ Manuel de la Pena ] |
50 | + * Ensure that the signals are correctly emitted for when the services |
51 | + appear and go. |
52 | + |
53 | + -- Thomas Voß <ci-train-bot@canonical.com> Tue, 20 Oct 2015 10:55:11 +0000 |
54 | + |
55 | dbus-cpp (4.3.0+15.04.20150505-0ubuntu1) vivid; urgency=medium |
56 | |
57 | [ CI Train Bot ] |
58 | |
59 | === modified file 'debian/libdbus-cpp5.symbols.32bit' |
60 | --- debian/libdbus-cpp5.symbols.32bit 2015-10-21 08:00:49 +0000 |
61 | +++ debian/libdbus-cpp5.symbols.32bit 2016-08-01 20:07:50 +0000 |
62 | @@ -1,5 +1,6 @@ |
63 | - (c++)"core::dbus::Fixture::system_bus_address[abi:cxx11]()@Base" 4.3.0+15.04.20150505 |
64 | - (c++)"core::dbus::Fixture::session_bus_address[abi:cxx11]()@Base" 4.3.0+15.04.20150505 |
65 | + (c++)"core::dbus::operator<<(std::basic_ostream<char, std::char_traits<char> >&, core::dbus::Message::Type)@Base" 4.3.0+15.04.20160114.2 |
66 | + (c++)"core::dbus::Fixture::system_bus_address()@Base" 4.3.0+15.04.20150505 |
67 | + (c++)"core::dbus::Fixture::session_bus_address()@Base" 4.3.0+15.04.20150505 |
68 | (c++)"core::dbus::Fixture::default_daemon_timeout()@Base" 4.0.0+14.10.20140730 |
69 | (c++)"core::dbus::asio::make_executor(std::shared_ptr<core::dbus::Bus> const&)@Base" 2.0.0+14.04.20140310 |
70 | (c++)"core::dbus::asio::make_executor(std::shared_ptr<core::dbus::Bus> const&, boost::asio::io_service&)@Base" 3.1.0+14.10.20140711 |
71 | |
72 | === modified file 'debian/libdbus-cpp5.symbols.64bit' |
73 | --- debian/libdbus-cpp5.symbols.64bit 2015-10-21 08:00:49 +0000 |
74 | +++ debian/libdbus-cpp5.symbols.64bit 2016-08-01 20:07:50 +0000 |
75 | @@ -1,5 +1,6 @@ |
76 | - (c++)"core::dbus::Fixture::system_bus_address[abi:cxx11]()@Base" 4.3.0+15.04.20150505 |
77 | - (c++)"core::dbus::Fixture::session_bus_address[abi:cxx11]()@Base" 4.3.0+15.04.20150505 |
78 | + (c++)"core::dbus::operator<<(std::basic_ostream<char, std::char_traits<char> >&, core::dbus::Message::Type)@Base" 4.3.0+15.04.20160114.2 |
79 | + (c++)"core::dbus::Fixture::system_bus_address()@Base" 4.3.0+15.04.20150505 |
80 | + (c++)"core::dbus::Fixture::session_bus_address()@Base" 4.3.0+15.04.20150505 |
81 | (c++)"core::dbus::Fixture::default_daemon_timeout()@Base" 4.0.0+14.10.20140730 |
82 | (c++)"core::dbus::asio::make_executor(std::shared_ptr<core::dbus::Bus> const&)@Base" 2.0.0+14.04.20140310 |
83 | (c++)"core::dbus::asio::make_executor(std::shared_ptr<core::dbus::Bus> const&, boost::asio::io_service&)@Base" 3.1.0+14.10.20140711 |
84 | |
85 | === modified file 'include/core/dbus/impl/object.h' |
86 | --- include/core/dbus/impl/object.h 2014-10-30 13:22:52 +0000 |
87 | +++ include/core/dbus/impl/object.h 2016-08-01 20:07:50 +0000 |
88 | @@ -19,7 +19,6 @@ |
89 | #define CORE_DBUS_IMPL_OBJECT_H_ |
90 | |
91 | #include <core/dbus/bus.h> |
92 | -#include <core/dbus/lifetime_constrained_cache.h> |
93 | #include <core/dbus/match_rule.h> |
94 | #include <core/dbus/message_router.h> |
95 | #include <core/dbus/message_streaming_operators.h> |
96 | @@ -37,6 +36,7 @@ |
97 | |
98 | #include <functional> |
99 | #include <future> |
100 | +#include <iostream> |
101 | #include <map> |
102 | #include <memory> |
103 | #include <string> |
104 | @@ -70,17 +70,17 @@ |
105 | object_path.as_string(), |
106 | traits::Service<typename Method::Interface>::interface_name().c_str(), |
107 | Method::name()); |
108 | - |
109 | + |
110 | if (!msg) |
111 | throw std::runtime_error("No memory available to allocate DBus message"); |
112 | - |
113 | + |
114 | auto writer = msg->writer(); |
115 | encode_message(writer, args...); |
116 | - |
117 | + |
118 | auto reply = parent->get_connection()->send_with_reply_and_block_for_at_most( |
119 | msg, |
120 | Method::default_timeout()); |
121 | - |
122 | + |
123 | return Result<ResultType>::from_message(reply); |
124 | } |
125 | |
126 | @@ -153,40 +153,57 @@ |
127 | inline std::shared_ptr<Property<PropertyDescription>> |
128 | Object::get_property() |
129 | { |
130 | - // If this is a proxy object we set up listening for property changes the |
131 | - // first time someone accesses properties. |
132 | - if (parent->is_stub()) |
133 | - { |
134 | - if (!signal_properties_changed) |
135 | - { |
136 | - signal_properties_changed |
137 | - = get_signal<interfaces::Properties::Signals::PropertiesChanged>(); |
138 | - |
139 | - signal_properties_changed->connect( |
140 | - std::bind( |
141 | - &Object::on_properties_changed, |
142 | - shared_from_this(), |
143 | - std::placeholders::_1)); |
144 | - } |
145 | - } |
146 | - |
147 | typedef Property<PropertyDescription> PropertyType; |
148 | - auto property = |
149 | - PropertyType::make_property( |
150 | - shared_from_this()); |
151 | |
152 | + // Creating a stub property for a remote object/property instance |
153 | + // requires the following steps: |
154 | + // [1.] Look up if we already have a property instance available in the cache, |
155 | + // leveraging the tuple (path, interface, name) as key. |
156 | + // [1.1] If yes: return the property. |
157 | + // [1.2] If no: Create a new proeprty instance and: |
158 | + // [1.2.1] Make it known to the cache. |
159 | + // [1.2.2] Wire it up for property_changed signal receiving. |
160 | + // [1.2.3] Communicate a new match rule to the dbus daemon to enable reception. |
161 | if (parent->is_stub()) |
162 | { |
163 | - auto tuple = std::make_tuple( |
164 | - traits::Service<typename PropertyDescription::Interface>::interface_name(), |
165 | - PropertyDescription::name()); |
166 | - |
167 | - property_changed_vtable[tuple] = std::bind( |
168 | - &Property<PropertyDescription>::handle_changed, |
169 | - property, |
170 | - std::placeholders::_1); |
171 | + auto itf = traits::Service<typename PropertyDescription::Interface>::interface_name(); |
172 | + auto name = PropertyDescription::name(); |
173 | + auto ekey = std::make_tuple(path(), itf, name); |
174 | + |
175 | + auto property = Object::property_cache<PropertyDescription>().retrieve_value_for_key(ekey); |
176 | + if (property) |
177 | + { |
178 | + return property; |
179 | + } |
180 | + |
181 | + auto mr = MatchRule() |
182 | + .type(Message::Type::signal) |
183 | + .interface(traits::Service<interfaces::Properties>::interface_name()) |
184 | + .member(interfaces::Properties::Signals::PropertiesChanged::name()); |
185 | + |
186 | + property = PropertyType::make_property(shared_from_this()); |
187 | + |
188 | + Object::property_cache<PropertyDescription>().insert_value_for_key(ekey, property); |
189 | + |
190 | + // We only ever do this once per object. |
191 | + std::call_once(add_match_once, [&]() |
192 | + { |
193 | + // [1.2.4] Inform the dbus daemon that we would like to receive the respective signals. |
194 | + add_match(mr); |
195 | + }); |
196 | + |
197 | + // [1.2.2] Enable dispatching of changes. |
198 | + std::weak_ptr<PropertyType> wp{property}; |
199 | + property_changed_vtable[std::make_tuple(itf, name)] = [wp](const types::Variant& arg) |
200 | + { |
201 | + if (auto sp = wp.lock()) |
202 | + sp->handle_changed(arg); |
203 | + }; |
204 | + |
205 | + return property; |
206 | } |
207 | - return property; |
208 | + |
209 | + return PropertyType::make_property(shared_from_this()); |
210 | } |
211 | |
212 | template<typename Interface> |
213 | @@ -312,6 +329,23 @@ |
214 | &MessageRouter<PropertyKey>::operator(), |
215 | std::ref(set_property_router), |
216 | std::placeholders::_1)); |
217 | + } else |
218 | + { |
219 | + // We centrally route org.freedesktop.DBus.Properties.PropertiesChanged |
220 | + // through the object, which in turn routes via a custom Property cache. |
221 | + signal_router.install_route( |
222 | + SignalKey{ |
223 | + traits::Service<interfaces::Properties>::interface_name(), |
224 | + interfaces::Properties::Signals::PropertiesChanged::name() |
225 | + }, |
226 | + // Passing 'this' is fine as the lifetime of the signal_router is upper limited |
227 | + // by the lifetime of 'this'. |
228 | + [this](const Message::Ptr& msg) |
229 | + { |
230 | + interfaces::Properties::Signals::PropertiesChanged::ArgumentType arg; |
231 | + msg->reader() >> arg; |
232 | + on_properties_changed(arg); |
233 | + }); |
234 | } |
235 | } |
236 | |
237 | @@ -319,6 +353,20 @@ |
238 | { |
239 | parent->get_connection()->access_signal_router().uninstall_route(object_path); |
240 | parent->get_connection()->unregister_object_path(object_path); |
241 | + |
242 | + auto mr = MatchRule() |
243 | + .type(Message::Type::signal) |
244 | + .interface(traits::Service<interfaces::Properties>::interface_name()) |
245 | + .member(interfaces::Properties::Signals::PropertiesChanged::name()); |
246 | + |
247 | + try |
248 | + { |
249 | + remove_match(mr); |
250 | + } catch(...) |
251 | + { |
252 | + // We consciously drop all possible exceptions here. There is hardly |
253 | + // anything we can do about the error anyway. |
254 | + } |
255 | } |
256 | |
257 | inline void Object::add_match(const MatchRule& rule) |
258 | @@ -346,6 +394,19 @@ |
259 | } |
260 | } |
261 | } |
262 | + |
263 | +template<typename PropertyDescription> |
264 | +inline core::dbus::ThreadSafeLifetimeConstrainedCache< |
265 | + core::dbus::Object::CacheKey, |
266 | + core::dbus::Property<PropertyDescription>>& |
267 | +core::dbus::Object::property_cache() |
268 | +{ |
269 | + static core::dbus::ThreadSafeLifetimeConstrainedCache< |
270 | + core::dbus::Object::CacheKey, |
271 | + core::dbus::Property<PropertyDescription> |
272 | + > cache; |
273 | + return cache; |
274 | +} |
275 | } |
276 | } |
277 | |
278 | |
279 | === modified file 'include/core/dbus/impl/property.h' |
280 | --- include/core/dbus/impl/property.h 2014-06-10 08:44:17 +0000 |
281 | +++ include/core/dbus/impl/property.h 2016-08-01 20:07:50 +0000 |
282 | @@ -64,6 +64,13 @@ |
283 | } |
284 | |
285 | template<typename PropertyType> |
286 | +const core::Signal<void>& |
287 | +Property<PropertyType>::about_to_be_destroyed() const |
288 | +{ |
289 | + return signal_about_to_be_destroyed; |
290 | +} |
291 | + |
292 | +template<typename PropertyType> |
293 | std::shared_ptr<Property<PropertyType>> |
294 | Property<PropertyType>::make_property(const std::shared_ptr<Object>& parent) |
295 | { |
296 | @@ -109,6 +116,20 @@ |
297 | } |
298 | |
299 | template<typename PropertyType> |
300 | +Property<PropertyType>::~Property() |
301 | +{ |
302 | + try |
303 | + { |
304 | + signal_about_to_be_destroyed(); |
305 | + } catch(...) |
306 | + { |
307 | + // Consciously dropping all exceptions here. |
308 | + // There is hardly anything we can do about it while |
309 | + // tearing down the object anyway. |
310 | + } |
311 | +} |
312 | + |
313 | +template<typename PropertyType> |
314 | void |
315 | Property<PropertyType>::handle_get(const Message::Ptr& msg) |
316 | { |
317 | |
318 | === modified file 'include/core/dbus/impl/signal.h' |
319 | --- include/core/dbus/impl/signal.h 2014-11-10 08:14:45 +0000 |
320 | +++ include/core/dbus/impl/signal.h 2016-08-01 20:07:50 +0000 |
321 | @@ -121,8 +121,8 @@ |
322 | &Signal<SignalDescription>::operator(), |
323 | this, |
324 | std::placeholders::_1)); |
325 | - parent->add_match( |
326 | - rule.type(Message::Type::signal).interface(interface).member(name)); |
327 | + rule = rule.type(Message::Type::signal).interface(interface).member(name); |
328 | + parent->add_match(rule); |
329 | } |
330 | |
331 | template<typename SignalDescription, typename Argument> |
332 | @@ -309,6 +309,8 @@ |
333 | &Signal<SignalDescription, typename SignalDescription::ArgumentType>::operator(), |
334 | this, |
335 | std::placeholders::_1)); |
336 | + |
337 | + d->rule = d->rule.type(Message::Type::signal).interface(interface).member(name); |
338 | } |
339 | |
340 | template<typename SignalDescription> |
341 | @@ -322,7 +324,8 @@ |
342 | { |
343 | try |
344 | { |
345 | - msg->reader() >> d->value; |
346 | + typename SignalDescription::ArgumentType value; |
347 | + msg->reader() >> value; |
348 | std::lock_guard<std::mutex> lg(d->handlers_guard); |
349 | for (auto it : d->handlers) |
350 | { |
351 | @@ -356,7 +359,7 @@ |
352 | continue; |
353 | } |
354 | |
355 | - handler(d->value); |
356 | + handler(value); |
357 | } |
358 | } |
359 | catch (const std::runtime_error& e) |
360 | |
361 | === modified file 'include/core/dbus/message.h' |
362 | --- include/core/dbus/message.h 2014-01-05 18:58:19 +0000 |
363 | +++ include/core/dbus/message.h 2016-08-01 20:07:50 +0000 |
364 | @@ -439,6 +439,8 @@ |
365 | }; |
366 | typedef std::shared_ptr<Message> MessagePtr; |
367 | typedef std::unique_ptr<Message> MessageUPtr; |
368 | + |
369 | +ORG_FREEDESKTOP_DBUS_DLL_PUBLIC std::ostream& operator<<(std::ostream&, Message::Type); |
370 | } |
371 | } |
372 | |
373 | |
374 | === modified file 'include/core/dbus/object.h' |
375 | --- include/core/dbus/object.h 2014-10-23 21:09:56 +0000 |
376 | +++ include/core/dbus/object.h 2016-08-01 20:07:50 +0000 |
377 | @@ -19,12 +19,14 @@ |
378 | #define CORE_DBUS_OBJECT_H_ |
379 | |
380 | #include <core/dbus/bus.h> |
381 | +#include <core/dbus/lifetime_constrained_cache.h> |
382 | #include <core/dbus/service.h> |
383 | |
384 | #include <functional> |
385 | #include <future> |
386 | #include <map> |
387 | #include <memory> |
388 | +#include <mutex> |
389 | #include <ostream> |
390 | #include <string> |
391 | |
392 | @@ -82,10 +84,14 @@ |
393 | class Object : public std::enable_shared_from_this<Object> |
394 | { |
395 | private: |
396 | + typedef std::tuple<types::ObjectPath, std::string, std::string> CacheKey; |
397 | typedef std::tuple<std::string, std::string> MethodKey; |
398 | typedef std::tuple<std::string, std::string> PropertyKey; |
399 | typedef std::tuple<std::string, std::string> SignalKey; |
400 | |
401 | + template<typename PropertyDescription> |
402 | + static ThreadSafeLifetimeConstrainedCache<CacheKey, Property<PropertyDescription>>& property_cache(); |
403 | + |
404 | public: |
405 | typedef std::shared_ptr<Object> Ptr; |
406 | typedef std::function<void(const Message::Ptr&)> MethodHandler; |
407 | @@ -173,7 +179,7 @@ |
408 | * @param [in] path The path to associate the object with. |
409 | * @return An object instance or nullptr in case of errors. |
410 | */ |
411 | - std::shared_ptr<Object> |
412 | + std::shared_ptr<Object> |
413 | inline add_object_for_path(const types::ObjectPath& path); |
414 | |
415 | /** |
416 | @@ -227,16 +233,11 @@ |
417 | MessageRouter<MethodKey> method_router; |
418 | MessageRouter<PropertyKey> get_property_router; |
419 | MessageRouter<PropertyKey> set_property_router; |
420 | + std::once_flag add_match_once; |
421 | std::map< |
422 | std::tuple<std::string, std::string>, |
423 | std::function<void(const types::Variant&)> |
424 | > property_changed_vtable; |
425 | - std::shared_ptr< |
426 | - Signal< |
427 | - interfaces::Properties::Signals::PropertiesChanged, |
428 | - interfaces::Properties::Signals::PropertiesChanged::ArgumentType |
429 | - > |
430 | - > signal_properties_changed; |
431 | }; |
432 | } |
433 | } |
434 | |
435 | === modified file 'include/core/dbus/property.h' |
436 | --- include/core/dbus/property.h 2014-01-20 21:22:02 +0000 |
437 | +++ include/core/dbus/property.h 2016-08-01 20:07:50 +0000 |
438 | @@ -43,6 +43,8 @@ |
439 | typedef typename PropertyType::ValueType ValueType; |
440 | typedef core::Property<ValueType> Super; |
441 | |
442 | + inline ~Property(); |
443 | + |
444 | /** |
445 | * @brief Non-mutable access to the contained value. |
446 | * @return Non-mutable reference to the contained value. |
447 | @@ -61,6 +63,11 @@ |
448 | */ |
449 | inline bool is_writable() const; |
450 | |
451 | + /** |
452 | + * @brief Emitted during destruction of an object instance. |
453 | + */ |
454 | + inline const core::Signal<void>& about_to_be_destroyed() const; |
455 | + |
456 | protected: |
457 | friend class Object; |
458 | |
459 | @@ -82,6 +89,7 @@ |
460 | std::string interface; |
461 | std::string name; |
462 | bool writable; |
463 | + core::Signal<void> signal_about_to_be_destroyed; |
464 | }; |
465 | } |
466 | } |
467 | |
468 | === modified file 'include/core/dbus/signal.h' |
469 | --- include/core/dbus/signal.h 2014-01-24 11:17:26 +0000 |
470 | +++ include/core/dbus/signal.h 2016-08-01 20:07:50 +0000 |
471 | @@ -189,8 +189,11 @@ |
472 | const std::shared_ptr<Object>& parent, |
473 | const std::string& interface, |
474 | const std::string& name); |
475 | - |
476 | - typename SignalDescription::ArgumentType value; |
477 | + |
478 | + // We do not need this member anymore, but keep it in place for |
479 | + // the sake of binary compatibility. Leaving a TODO(tvoss) to clean |
480 | + // up on next ABI bump. |
481 | + typename SignalDescription::ArgumentType pad; |
482 | std::shared_ptr<Object> parent; |
483 | std::string interface; |
484 | std::string name; |
485 | |
486 | === modified file 'src/core/dbus/bus.cpp' |
487 | --- src/core/dbus/bus.cpp 2014-11-27 16:38:44 +0000 |
488 | +++ src/core/dbus/bus.cpp 2016-08-01 20:07:50 +0000 |
489 | @@ -24,6 +24,8 @@ |
490 | #include <core/dbus/traits/timeout.h> |
491 | #include <core/dbus/traits/watch.h> |
492 | |
493 | +#include <core/posix/this_process.h> |
494 | + |
495 | #include "message_p.h" |
496 | #include "message_factory_impl.h" |
497 | #include "pending_call_impl.h" |
498 | @@ -76,8 +78,18 @@ |
499 | |
500 | void init_libdbus_thread_support_and_install_shutdown_handler() |
501 | { |
502 | + static const bool install_dbus_shutdown_handler |
503 | + { |
504 | + not core::posix::this_process::env::get("DBUS_CPP_INSTALL_DBUS_SHUTDOWN_HANDLER").empty() |
505 | + }; |
506 | + |
507 | static std::once_flag once; |
508 | - std::call_once(once, []() { dbus_threads_init_default(); std::atexit(dbus_shutdown); }); |
509 | + std::call_once(once, []() |
510 | + { |
511 | + dbus_threads_init_default(); |
512 | + if (install_dbus_shutdown_handler) |
513 | + std::atexit(dbus_shutdown); |
514 | + }); |
515 | } |
516 | } |
517 | |
518 | |
519 | === modified file 'src/core/dbus/match_rule.cpp' |
520 | --- src/core/dbus/match_rule.cpp 2014-01-21 13:48:54 +0000 |
521 | +++ src/core/dbus/match_rule.cpp 2016-08-01 20:07:50 +0000 |
522 | @@ -151,17 +151,10 @@ |
523 | |
524 | std::string dbus::MatchRule::as_string() const |
525 | { |
526 | - static const std::map<Message::Type, std::string> lut = |
527 | - { |
528 | - {Message::Type::signal, "signal"}, |
529 | - {Message::Type::method_call, "method_call"}, |
530 | - {Message::Type::method_return, "method_return"}, |
531 | - {Message::Type::error, "error"} |
532 | - }; |
533 | Comma comma; |
534 | std::stringstream ss; |
535 | if (d->type != Message::Type::invalid) |
536 | - ss << "type='" << lut.at(d->type) << "'" << comma; |
537 | + ss << "type='" << d->type << "'" << comma; |
538 | if (!d->sender.empty()) |
539 | ss << comma << "sender='" << d->sender << "'" << comma; |
540 | if (!d->interface.empty()) |
541 | |
542 | === modified file 'src/core/dbus/message.cpp' |
543 | --- src/core/dbus/message.cpp 2015-07-21 18:30:23 +0000 |
544 | +++ src/core/dbus/message.cpp 2016-08-01 20:07:50 +0000 |
545 | @@ -652,5 +652,24 @@ |
546 | { |
547 | return std::shared_ptr<Message>(new Message(d->clone())); |
548 | } |
549 | + |
550 | +std::ostream& operator<<(std::ostream& out, Message::Type type) |
551 | +{ |
552 | + switch (type) |
553 | + { |
554 | + case Message::Type::error: |
555 | + return out << "error"; |
556 | + case Message::Type::invalid: |
557 | + return out << "invalid"; |
558 | + case Message::Type::method_call: |
559 | + return out << "method_call"; |
560 | + case Message::Type::method_return: |
561 | + return out << "method_return"; |
562 | + case Message::Type::signal: |
563 | + return out << "signal"; |
564 | + } |
565 | + |
566 | + return out; |
567 | +} |
568 | } |
569 | } |
570 | |
571 | === modified file 'src/core/dbus/service.cpp' |
572 | --- src/core/dbus/service.cpp 2014-06-30 04:57:08 +0000 |
573 | +++ src/core/dbus/service.cpp 2016-08-01 20:07:50 +0000 |
574 | @@ -79,7 +79,7 @@ |
575 | |
576 | void Service::remove_match(const MatchRule& rule) |
577 | { |
578 | - connection->remove_match(rule); |
579 | + connection->remove_match(rule.sender(name)); |
580 | } |
581 | |
582 | Service::Service(const Bus::Ptr& connection, const std::string& name) |
583 | |
584 | === modified file 'tests/message_test.cpp' |
585 | --- tests/message_test.cpp 2014-01-10 07:34:59 +0000 |
586 | +++ tests/message_test.cpp 2016-08-01 20:07:50 +0000 |
587 | @@ -175,3 +175,23 @@ |
588 | } |
589 | } |
590 | } |
591 | + |
592 | +namespace |
593 | +{ |
594 | +class MessageType : public testing::TestWithParam<std::pair<core::dbus::Message::Type, std::string>> |
595 | +{ |
596 | +}; |
597 | +} |
598 | + |
599 | +TEST_P(MessageType, IsPrintedCorrectly) |
600 | +{ |
601 | + std::stringstream ss; ss << GetParam().first; |
602 | + EXPECT_EQ(GetParam().second, ss.str()); |
603 | +} |
604 | + |
605 | +INSTANTIATE_TEST_CASE_P(MessageType, MessageType, ::testing::Values( |
606 | + std::make_pair(core::dbus::Message::Type::error, "error"), |
607 | + std::make_pair(core::dbus::Message::Type::invalid, "invalid"), |
608 | + std::make_pair(core::dbus::Message::Type::method_call, "method_call"), |
609 | + std::make_pair(core::dbus::Message::Type::method_return, "method_return"), |
610 | + std::make_pair(core::dbus::Message::Type::signal, "signal"))); |