// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*- /* Copyright (C) 2010 The giomm Development Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include "slot_async.h" namespace { extern "C" { static void DBusConnection_Signal_giomm_callback(GDBusConnection* connection, const char* sender_name, const char* object_path, const char* interface_name, const char* signal_name, GVariant* parameters, void* user_data) { Gio::DBusConnection::SlotSignal* the_slot = static_cast(user_data); try { (*the_slot)(Glib::wrap(connection, true), (sender_name ? sender_name : ""), (object_path ? object_path : ""), (interface_name ? interface_name : ""), (signal_name ? signal_name : ""), Glib::VariantBase(parameters, true)); } catch(...) { Glib::exception_handlers_invoke(); } } static void DBusConnection_Signal_giomm_callback_destroy(void* data) { delete static_cast(data); } static GDBusMessage* DBusConnection_Message_Filter_giomm_callback( GDBusConnection* connection, GDBusMessage* message, gboolean incoming, void* user_data) { Gio::DBusConnection::SlotMessageFilter* the_slot = static_cast(user_data); try { Glib::RefPtr result = (*the_slot)( Glib::wrap(connection, true), Glib::wrap(message, true), static_cast(incoming)); return (result) ? result->gobj_copy() : 0; } catch(...) { Glib::exception_handlers_invoke(); } return message; } static void DBusConnection_Message_Filter_giomm_callback_destroy(void* data) { delete static_cast(data); } static void DBusInterfaceVTable_MethodCall_giomm_callback( GDBusConnection* connection, const char* sender, const char* object_path, const char* interface_name, const char* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, void* user_data) { Gio::DBusInterfaceVTable* vtable = static_cast(user_data); Gio::DBusInterfaceVTable::SlotInterfaceMethodCall* the_slot = vtable->get_slot_method_call(); try { (*the_slot)(Glib::wrap(connection, true), (sender ? sender : ""), object_path, interface_name, method_name, Glib::VariantBase(parameters, true), Glib::wrap(invocation, true)); } catch(...) { Glib::exception_handlers_invoke(); } } static GVariant* DBusInterfaceVTable_GetProperty_giomm_callback( GDBusConnection* connection, const char* sender, const char* object_path, const char* interface_name, const char* property_name, GError** error, void* user_data) { Gio::DBusInterfaceVTable* vtable = static_cast(user_data); Gio::DBusInterfaceVTable::SlotInterfaceGetProperty* the_slot = vtable->get_slot_get_property(); try { Glib::VariantBase result; (*the_slot)(result, Glib::wrap(connection, true), sender, object_path, interface_name, property_name); return result.gobj_copy(); } catch(const Glib::Error& ex) { if(error) *error = const_cast(ex.gobj()); } catch(...) { Glib::exception_handlers_invoke(); } return 0; } static gboolean DBusInterfaceVTable_SetProperty_giomm_callback( GDBusConnection* connection, const char* sender, const char* object_path, const char* interface_name, const char* property_name, GVariant* value, GError** error, void* user_data) { Gio::DBusInterfaceVTable* vtable = static_cast(user_data); Gio::DBusInterfaceVTable::SlotInterfaceSetProperty* the_slot = vtable->get_slot_set_property(); try { return static_cast((*the_slot)(Glib::wrap(connection, true), sender, object_path, interface_name, property_name, Glib::VariantBase(value, true))); } catch(const Glib::Error& ex) { if(error) *error = const_cast(ex.gobj()); } catch(...) { Glib::exception_handlers_invoke(); } return false; } static char** DBusSubtreeVTable_Enumerate_giomm_callback( GDBusConnection* connection, const char* sender, const char* object_path, void* user_data) { Gio::DBusSubtreeVTable* vtable = static_cast(user_data); Gio::DBusSubtreeVTable::SlotSubtreeEnumerate* the_slot = vtable->get_slot_enumerate(); try { std::vector result = (*the_slot)(Glib::wrap(connection, true), sender, object_path); // This will be freed by the caller. char** ret = g_new(char*, result.size()); for(std::vector::size_type i = 0; i < result.size(); i++) { ret[i] = g_strdup(result[i].c_str()); } return ret; } catch(...) { Glib::exception_handlers_invoke(); } return 0; } static GDBusInterfaceInfo** DBusSubtreeVTable_Introspect_giomm_callback( GDBusConnection* connection, const char* sender, const char* object_path, const char* node, void* user_data) { Gio::DBusSubtreeVTable* vtable = static_cast(user_data); Gio::DBusSubtreeVTable::SlotSubtreeIntrospect* the_slot = vtable->get_slot_introspect(); try { std::vector< Glib::RefPtr > result = (*the_slot)(Glib::wrap(connection, true), sender, object_path, node); // This will be freed by the caller, along with unreferencing its members. GDBusInterfaceInfo** info = g_new(GDBusInterfaceInfo*, result.size()); for(std::vector< Glib::RefPtr >::size_type i = 0; i < result.size(); i++) { info[i] = static_cast( g_object_ref(result[i]->gobj())); } return info; } catch(...) { Glib::exception_handlers_invoke(); } return 0; } static const GDBusInterfaceVTable* DBusSubtreeVTable_Dispatch_giomm_callback( GDBusConnection* connection, const char* sender, const char* object_path, const char* interface_name, const char* node, void** out_user_data, void* user_data) { Gio::DBusSubtreeVTable* vtable = static_cast(user_data); Gio::DBusSubtreeVTable::SlotSubtreeDispatch* the_slot = vtable->get_slot_dispatch(); try { const Gio::DBusInterfaceVTable* vtable = (*the_slot)(Glib::wrap(connection, true), sender, object_path, interface_name, (node ? node : "")); *out_user_data = const_cast(vtable); return vtable->gobj(); } catch(...) { Glib::exception_handlers_invoke(); } return 0; } } // extern "C" } namespace Gio { DBusConnection::DBusConnection(const Glib::RefPtr& stream, const std::string& guid, const Glib::RefPtr& observer, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) : _CONSTRUCT("stream", Glib::unwrap(stream), "guid", (guid.empty() ? 0 : guid.c_str()), "flags", static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init_async(slot, cancellable); } DBusConnection::DBusConnection(const Glib::RefPtr& stream, const std::string& guid, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) : _CONSTRUCT("stream", Glib::unwrap(stream), "guid", (guid.empty() ? 0 : guid.c_str()), "flags", static_cast(flags), "authentication-observer", static_cast(0)) { init_async(slot, cancellable); } DBusConnection::DBusConnection(const Glib::RefPtr& stream, const std::string& guid, const Glib::RefPtr& observer, const SlotAsyncReady& slot, DBusConnectionFlags flags) : _CONSTRUCT("stream", Glib::unwrap(stream), "guid", (guid.empty() ? 0 : guid.c_str()), "flags", static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init_async(slot); } DBusConnection::DBusConnection(const Glib::RefPtr& stream, const std::string& guid, const SlotAsyncReady& slot, DBusConnectionFlags flags) : _CONSTRUCT("stream", Glib::unwrap(stream), "guid", (guid.empty() ? 0 : guid.c_str()), "flags", static_cast(flags), "authentication-observer", static_cast(0)) { init_async(slot); } DBusConnection::DBusConnection(const std::string& address, const Glib::RefPtr& observer, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) : _CONSTRUCT("address", (address.empty() ? 0 : address.c_str()), "flags", static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init_async(slot, cancellable); } DBusConnection::DBusConnection(const std::string& address, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) : _CONSTRUCT("address", (address.empty() ? 0 : address.c_str()), "flags", static_cast(flags), "authentication-observer", static_cast(0)) { init_async(slot, cancellable); } DBusConnection::DBusConnection(const std::string& address, const Glib::RefPtr& observer, const SlotAsyncReady& slot, DBusConnectionFlags flags) : _CONSTRUCT("address", (address.empty() ? 0 : address.c_str()), "flags", static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init_async(slot); } DBusConnection::DBusConnection(const std::string& address, const SlotAsyncReady& slot, DBusConnectionFlags flags) : _CONSTRUCT("address", (address.empty() ? 0 : address.c_str()), "flags", static_cast(flags), "authentication-observer", static_cast(0)) { init_async(slot); } DBusConnection::DBusConnection(const Glib::RefPtr& stream, const std::string& guid, const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) : _CONSTRUCT("stream", Glib::unwrap(stream), "guid", (guid.empty() ? 0 : guid.c_str()), "flags", static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init(cancellable); } DBusConnection::DBusConnection(const Glib::RefPtr& stream, const std::string& guid, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) : _CONSTRUCT("stream", Glib::unwrap(stream), "guid", (guid.empty() ? 0 : guid.c_str()), "flags", static_cast(flags), "authentication-observer", static_cast(0)) { init(cancellable); } DBusConnection::DBusConnection(const Glib::RefPtr& stream, const std::string& guid, const Glib::RefPtr& observer, DBusConnectionFlags flags) : _CONSTRUCT("stream", Glib::unwrap(stream), "guid", (guid.empty() ? 0 : guid.c_str()), "flags", static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init(); } DBusConnection::DBusConnection(const Glib::RefPtr& stream, const std::string& guid, DBusConnectionFlags flags) : _CONSTRUCT("stream", Glib::unwrap(stream), "guid", (guid.empty() ? 0 : guid.c_str()), "flags", static_cast(flags), "authentication-observer", static_cast(0)) { init(); } DBusConnection::DBusConnection(const std::string& address, const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) : _CONSTRUCT("address", (address.empty() ? 0 : address.c_str()), "flags", static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init(cancellable); } DBusConnection::DBusConnection(const std::string& address, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) : _CONSTRUCT("address", (address.empty() ? 0 : address.c_str()), "flags", static_cast(flags), "authentication-observer", static_cast(0)) { init(cancellable); } DBusConnection::DBusConnection(const std::string& address, const Glib::RefPtr& observer, DBusConnectionFlags flags) : _CONSTRUCT("address", (address.empty() ? 0 : address.c_str()), "flags", static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init(); } DBusConnection::DBusConnection(const std::string& address, DBusConnectionFlags flags) : _CONSTRUCT("address", (address.empty() ? 0 : address.c_str()), "flags", static_cast(flags), "authentication-observer", static_cast(0)) { init(); } //static void DBusConnection::create(const Glib::RefPtr& stream, const std::string& guid, const Glib::RefPtr& observer, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). DBusConnection(stream, guid, observer, slot, cancellable, flags); } //static void DBusConnection::create(const Glib::RefPtr& stream, const std::string& guid, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). DBusConnection(stream, guid, slot, cancellable, flags); } //static void DBusConnection::create(const Glib::RefPtr& stream, const std::string& guid, const Glib::RefPtr& observer, const SlotAsyncReady& slot, DBusConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). DBusConnection(stream, guid, observer, slot, flags); } //static void DBusConnection::create(const Glib::RefPtr& stream, const std::string& guid, const SlotAsyncReady& slot, DBusConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). DBusConnection(stream, guid, slot, flags); } //static Glib::RefPtr DBusConnection::create_sync( const Glib::RefPtr& stream, const std::string& guid, const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) { return Glib::RefPtr(new DBusConnection(stream, guid, observer, cancellable, flags)); } //static Glib::RefPtr DBusConnection::create_sync( const Glib::RefPtr& stream, const std::string& guid, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) { return Glib::RefPtr(new DBusConnection(stream, guid, cancellable, flags)); } //static Glib::RefPtr DBusConnection::create_sync( const Glib::RefPtr& stream, const std::string& guid, const Glib::RefPtr& observer, DBusConnectionFlags flags) { return Glib::RefPtr(new DBusConnection(stream, guid, observer, flags)); } //static Glib::RefPtr DBusConnection::create_sync( const Glib::RefPtr& stream, const std::string& guid, DBusConnectionFlags flags) { return Glib::RefPtr(new DBusConnection(stream, guid, flags)); } //static void DBusConnection::create_for_address(const std::string& address, const Glib::RefPtr& observer, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). DBusConnection(address, observer, slot, cancellable, flags); } //static void DBusConnection::create_for_address(const std::string& address, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). DBusConnection(address, slot, cancellable, flags); } //static void DBusConnection::create_for_address(const std::string& address, const Glib::RefPtr& observer, const SlotAsyncReady& slot, DBusConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). DBusConnection(address, observer, slot, flags); } //static void DBusConnection::create_for_address(const std::string& address, const SlotAsyncReady& slot, DBusConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). DBusConnection(address, slot, flags); } //static Glib::RefPtr DBusConnection::create_for_address_sync( const std::string& address, const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) { return Glib::RefPtr(new DBusConnection(address, observer, cancellable, flags)); } //static Glib::RefPtr DBusConnection::create_for_address_sync( const std::string& address, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) { return Glib::RefPtr(new DBusConnection(address, cancellable, flags)); } //static Glib::RefPtr DBusConnection::create_for_address_sync( const std::string& address, const Glib::RefPtr& observer, DBusConnectionFlags flags) { return Glib::RefPtr(new DBusConnection(address, observer, flags)); } //static Glib::RefPtr DBusConnection::create_for_address_sync( const std::string& address, DBusConnectionFlags flags) { return Glib::RefPtr(new DBusConnection(address, flags)); } //static void DBusConnection::get(BusType bus_type, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); g_bus_get(static_cast(bus_type), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } //static void DBusConnection::get(BusType bus_type, const SlotAsyncReady& slot) { SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); g_bus_get(static_cast(bus_type), 0, &SignalProxy_async_callback, slot_copy); } //static Glib::RefPtr DBusConnection::get_sync(BusType bus_type) { GError* gerror = 0; GDBusConnection* result = g_bus_get_sync(static_cast(bus_type), 0, & gerror); if(gerror) ::Glib::Error::throw_exception(gerror); return Glib::wrap(result); } void DBusConnection::close() { g_dbus_connection_close(gobj(), 0, 0, 0); } void DBusConnection::close(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); g_dbus_connection_close(gobj(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void DBusConnection::close(const SlotAsyncReady& slot) { SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); g_dbus_connection_close(gobj(), 0, &SignalProxy_async_callback, slot_copy); } void DBusConnection::close_sync() { GError* gerror = 0; g_dbus_connection_close_sync(gobj(), 0, &(gerror)); if(gerror) ::Glib::Error::throw_exception(gerror); } void DBusConnection::flush() { g_dbus_connection_flush(gobj(), 0, 0, 0); } void DBusConnection::flush(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); g_dbus_connection_flush(gobj(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void DBusConnection::flush(const SlotAsyncReady& slot) { SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); g_dbus_connection_flush(gobj(), 0, &SignalProxy_async_callback, slot_copy); } void DBusConnection::flush_sync() { GError* gerror = 0; g_dbus_connection_flush_sync(gobj(), 0, &(gerror)); if(gerror) ::Glib::Error::throw_exception(gerror); } bool DBusConnection::send_message(const Glib::RefPtr& message, DBusSendMessageFlags flags) { GError* gerror = 0; const bool result = g_dbus_connection_send_message(gobj(), Glib::unwrap(message), static_cast(flags), 0, &gerror); if(gerror) ::Glib::Error::throw_exception(gerror); return result; } void DBusConnection::send_message_with_reply(const Glib::RefPtr& message, int timeout_msec,const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); volatile guint32 out_serial = 0; g_dbus_connection_send_message_with_reply(gobj(), Glib::unwrap(message), static_cast(message->get_flags()), timeout_msec, &out_serial, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); message->set_serial(out_serial); } void DBusConnection::send_message_with_reply(const Glib::RefPtr& message, int timeout_msec,const SlotAsyncReady& slot) { SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); volatile guint32 out_serial = 0; g_dbus_connection_send_message_with_reply(gobj(), Glib::unwrap(message), static_cast(message->get_flags()), timeout_msec, &out_serial, 0, &SignalProxy_async_callback, slot_copy); message->set_serial(out_serial); } Glib::RefPtr DBusConnection::send_message_with_reply_sync( const Glib::RefPtr& message, const Glib::RefPtr& cancellable, gint timeout_msec ) { volatile guint32 out_serial = 0; GError* gerror = 0; GDBusMessage* result = g_dbus_connection_send_message_with_reply_sync(gobj(), Glib::unwrap(message), static_cast(message->get_flags()), timeout_msec, &out_serial, Glib::unwrap(cancellable), &gerror); if(gerror) ::Glib::Error::throw_exception(gerror); message->set_serial(out_serial); return Glib::wrap(result); } Glib::RefPtr DBusConnection::send_message_with_reply_sync( const Glib::RefPtr& message, gint timeout_msec ) { volatile guint32 out_serial = 0; GError* gerror = 0; GDBusMessage* result = g_dbus_connection_send_message_with_reply_sync(gobj(), Glib::unwrap(message), static_cast(message->get_flags()), timeout_msec, &out_serial, 0, &gerror); if(gerror) ::Glib::Error::throw_exception(gerror); message->set_serial(out_serial); return Glib::wrap(result); } void DBusConnection::call( const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& method_name, const Glib::VariantBase& parameters, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, const Glib::ustring& bus_name, int timeout_msec, DBusCallFlags flags, const Glib::VariantType& reply_type ) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); g_dbus_connection_call(gobj(), bus_name.c_str(), object_path.c_str(), interface_name.c_str(), method_name.c_str(), const_cast(parameters.gobj()), reply_type.gobj(), static_cast(flags), timeout_msec, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } // Non-cancellable version. void DBusConnection::call( const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& method_name, const Glib::VariantBase& parameters, const SlotAsyncReady& slot, const Glib::ustring& bus_name, int timeout_msec, DBusCallFlags flags, const Glib::VariantType& reply_type ) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); g_dbus_connection_call(gobj(), bus_name.c_str(), object_path.c_str(), interface_name.c_str(), method_name.c_str(), const_cast(parameters.gobj()), reply_type.gobj(), static_cast(flags), timeout_msec, 0, &SignalProxy_async_callback, slot_copy); } void DBusConnection::call_finish( Glib::VariantBase& output, const Glib::RefPtr& res ) { GError* gerror = 0; GVariant* const gvariant = g_dbus_connection_call_finish(gobj(), Glib::unwrap(res), &gerror); if(gerror) ::Glib::Error::throw_exception(gerror); output.init(gvariant); // No need for extra ref. } void DBusConnection::call_sync( Glib::VariantBase& output, const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& method_name, const Glib::VariantBase& parameters, const Glib::RefPtr& cancellable, const Glib::ustring& bus_name, int timeout_msec, DBusCallFlags flags, const Glib::VariantType& reply_type ) { GError* gerror = 0; GVariant* const gvariant = g_dbus_connection_call_sync(gobj(), bus_name.c_str(), object_path.c_str(), interface_name.c_str(), method_name.c_str(), const_cast(parameters.gobj()), reply_type.gobj(), static_cast(flags), timeout_msec, Glib::unwrap(cancellable), &gerror); if(gerror) ::Glib::Error::throw_exception(gerror); output.init(gvariant); // No need to take extra reference. } // Non-cancellable version. void DBusConnection::call_sync( Glib::VariantBase& output, const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& method_name, const Glib::VariantBase& parameters, const Glib::ustring& bus_name, int timeout_msec, DBusCallFlags flags, const Glib::VariantType& reply_type ) { GError* gerror = 0; GVariant* const gvariant = g_dbus_connection_call_sync(gobj(), bus_name.c_str(), object_path.c_str(), interface_name.c_str(), method_name.c_str(), const_cast(parameters.gobj()), reply_type.gobj(), static_cast(flags), timeout_msec, 0, &gerror); if(gerror) ::Glib::Error::throw_exception(gerror); output.init(gvariant); // No need to take extra reference. } void DBusConnection::emit_signal( const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& signal_name, const Glib::ustring& destination_bus_name, const Glib::VariantBase& parameters ) { GError* gerror = 0; g_dbus_connection_emit_signal(gobj(), destination_bus_name.c_str(), object_path.c_str(), interface_name.c_str(), signal_name.c_str(), const_cast(parameters.gobj()), &gerror); if(gerror) ::Glib::Error::throw_exception(gerror); } guint DBusConnection::signal_subscribe( const SlotSignal& slot, const Glib::ustring& sender, const Glib::ustring& interface_name, const Glib::ustring& member, const Glib::ustring& object_path, const Glib::ustring& arg0, DBusSignalFlags flags ) { SlotSignal* slot_copy = new SlotSignal(slot); return g_dbus_connection_signal_subscribe(gobj(), sender.c_str(), interface_name.c_str(), member.c_str(), object_path.c_str(), arg0.c_str(), static_cast(flags), &DBusConnection_Signal_giomm_callback, slot_copy, &DBusConnection_Signal_giomm_callback_destroy); } guint DBusConnection::add_filter(const SlotMessageFilter& slot) { SlotMessageFilter* slot_copy = new SlotMessageFilter(slot); return g_dbus_connection_add_filter(gobj(), &DBusConnection_Message_Filter_giomm_callback, slot_copy, DBusConnection_Message_Filter_giomm_callback_destroy); } guint DBusConnection::register_object(const Glib::ustring& object_path, const Glib::RefPtr& interface_info, const DBusInterfaceVTable* vtable) { GError* gerror = 0; const guint result = g_dbus_connection_register_object(gobj(), object_path.c_str(), Glib::unwrap(interface_info), vtable->gobj(), const_cast(vtable), 0, &gerror); if(gerror) ::Glib::Error::throw_exception(gerror); return result; } guint DBusConnection::register_subtree(const Glib::ustring& object_path, const DBusSubtreeVTable* vtable, DBusSubtreeFlags flags) { GError* gerror = 0; const guint result = g_dbus_connection_register_subtree(gobj(), object_path.c_str(), vtable->gobj(), static_cast(flags), const_cast(vtable), 0, &gerror); if(gerror) ::Glib::Error::throw_exception(gerror); return result; } DBusInterfaceVTable::DBusInterfaceVTable( const SlotInterfaceMethodCall& slot_method_call, const SlotInterfaceGetProperty& slot_get_property, const SlotInterfaceSetProperty& slot_set_property ) : slot_method_call_(new SlotInterfaceMethodCall(slot_method_call)), slot_get_property_(new SlotInterfaceGetProperty(slot_get_property)), slot_set_property_(new SlotInterfaceSetProperty(slot_set_property)) { gobject_.method_call = &DBusInterfaceVTable_MethodCall_giomm_callback; gobject_.get_property = &DBusInterfaceVTable_GetProperty_giomm_callback; gobject_.set_property = &DBusInterfaceVTable_SetProperty_giomm_callback; } DBusInterfaceVTable::~DBusInterfaceVTable() { delete slot_method_call_; delete slot_get_property_; delete slot_set_property_; } DBusInterfaceVTable::SlotInterfaceMethodCall* DBusInterfaceVTable::get_slot_method_call() const { return slot_method_call_; } DBusInterfaceVTable::SlotInterfaceGetProperty* DBusInterfaceVTable::get_slot_get_property() const { return slot_get_property_; } DBusInterfaceVTable::SlotInterfaceSetProperty* DBusInterfaceVTable::get_slot_set_property() const { return slot_set_property_; } DBusSubtreeVTable::DBusSubtreeVTable( const SlotSubtreeEnumerate& slot_enumerate, const SlotSubtreeIntrospect& slot_introspect, const SlotSubtreeDispatch& slot_dispatch ) : slot_enumerate_(new SlotSubtreeEnumerate(slot_enumerate)), slot_introspect_(new SlotSubtreeIntrospect(slot_introspect)), slot_dispatch_(new SlotSubtreeDispatch(slot_dispatch)) { gobject_.enumerate = &DBusSubtreeVTable_Enumerate_giomm_callback; gobject_.introspect = &DBusSubtreeVTable_Introspect_giomm_callback; gobject_.dispatch = &DBusSubtreeVTable_Dispatch_giomm_callback; } DBusSubtreeVTable::~DBusSubtreeVTable() { delete slot_enumerate_; delete slot_introspect_; delete slot_dispatch_; } DBusSubtreeVTable::SlotSubtreeEnumerate* DBusSubtreeVTable::get_slot_enumerate() const { return slot_enumerate_; } DBusSubtreeVTable::SlotSubtreeIntrospect* DBusSubtreeVTable::get_slot_introspect() const { return slot_introspect_; } DBusSubtreeVTable::SlotSubtreeDispatch* DBusSubtreeVTable::get_slot_dispatch() const { return slot_dispatch_; } } // namespace Gio