1// Copyright (c) Benjamin Kietzman (github.com/bkietz) 2// 3// Distributed under the Boost Software License, Version 1.0. (See accompanying 4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6#ifndef DBUS_FILTER_IPP 7#define DBUS_FILTER_IPP 8 9namespace dbus { 10namespace impl { 11 12inline DBusHandlerResult filter_callback(DBusConnection* c, DBusMessage* m, 13 void* userdata) { 14 try { 15 filter& f = *static_cast<filter*>(userdata); 16 message m_(m); 17 if (f.offer(m_)) { 18 return DBUS_HANDLER_RESULT_HANDLED; 19 } 20 } catch (...) { 21 // do not throw in C callbacks. Just don't. 22 } 23 24 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 25} 26 27} // namespace impl 28 29void connection_service::new_filter(implementation_type& impl, filter& f) { 30 dbus_connection_add_filter(impl, &impl::filter_callback, &f, NULL); 31} 32 33void connection_service::delete_filter(implementation_type& impl, filter& f) { 34 dbus_connection_remove_filter(impl, &impl::filter_callback, &f); 35} 36 37} // namespace dbus 38 39#endif // DBUS_FILTER_IPP 40