Gio::DBus::Connection Class Reference
D-Bus API

A D-Bus Connection. More...

`#include <giomm/dbusconnection.h>`

Inheritance diagram for Gio::DBus::Connection:
[legend]

## Public Types

using | SlotSignal = sigc::slot< void, const Glib::RefPtr< Connection >&, const Glib::ustring&, const Glib::ustring&, const Glib::ustring&, const Glib::ustring&, const Glib::VariantContainerBase& >
| Signature for slot used in signal_subscribe(). More...
using | SlotMessageFilter = sigc::slot< Glib::RefPtr< Message >, const Glib::RefPtr< Connection >&, const Glib::RefPtr< Message >&, bool >
| Signature for slot used in add_filter(). More...
Public Types inherited from Glib::Object
using | DestroyNotify = void(*)(gpointer data)
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify

## Public Member Functions

| Connection (Connection&& src) noexcept
Connection& | operator= (Connection&& src) noexcept
| ~Connection () noexcept override
GDBusConnection* | gobj ()
| Provides access to the underlying C GObject. More...
const GDBusConnection* | gobj () const
| Provides access to the underlying C GObject. More...
GDBusConnection* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
void | close ()
| Closes the connection. More...
void | close (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable)
| Closes the connection. More...
void | close (const SlotAsyncReady& slot)
| Closes the connection. More...
bool | close_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an operation started with g_dbus_connection_close(). More...
void | close_sync (const Glib::RefPtr< Cancellable >& cancellable)
| Synchronously closes connection. More...
void | close_sync ()
| A close_sync() convenience overload. More...
void | flush ()
| Asynchronously flushes the connection, that is, writes all queued outgoing message to the transport and then flushes the transport (using Gio::OutputStream::flush_async()). More...
void | flush (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable)
| Asynchronously flushes the connection, that is, writes all queued outgoing message to the transport and then flushes the transport (using Gio::OutputStream::flush_async()). More...
void | flush (const SlotAsyncReady& slot)
| Asynchronously flushes the connection, that is, writes all queued outgoing message to the transport and then flushes the transport (using Gio::OutputStream::flush_async()). More...
bool | flush_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an operation started with g_dbus_connection_flush(). More...
void | flush_sync (const Glib::RefPtr< Cancellable >& cancellable)
| Synchronously flushes connection. More...
void | flush_sync ()
| A flush_sync() convenience overload. More...
bool | get_exit_on_close () const
| Gets whether the process is terminated when connection is closed by the remote peer. More...
void | set_exit_on_close (bool exit_on_close=true)
| Sets whether the process should be terminated when connection is closed by the remote peer. More...
bool | send_message (const Glib::RefPtr< Message >& message, SendMessageFlags flags, guint32& out_serial)
| Asynchronously sends message to the peer represented by connection. More...
bool | send_message (const Glib::RefPtr< Message >& message, SendMessageFlags flags=Gio::DBus::SEND_MESSAGE_FLAGS_NONE)
| A send_message() without an "out_serial" parameter. More...
void | send_message_with_reply (const Glib::RefPtr< Message >& message, int timeout_msec, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable)
| Asynchronously sends message to the peer represented by the connection. More...
void | send_message_with_reply (const Glib::RefPtr< Message >& message, int timeout_msec, const SlotAsyncReady& slot)
| Non-cancellable version of send_message_with_reply(). More...
Glib::RefPtr< Message > | send_message_with_reply_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an operation started with g_dbus_connection_send_message_with_reply(). More...
Glib::RefPtr< Message > | send_message_with_reply_sync (const Glib::RefPtr< Message >& message, const Glib::RefPtr< Cancellable >& cancellable, gint timeout_msec)
| Synchronously sends message to the peer represented by the connection and blocks the calling thread until a reply is received or the timeout is reached. More...
Glib::RefPtr< Message > | send_message_with_reply_sync (const Glib::RefPtr< Message >& message, gint timeout_msec)
| A non-cancellable version of send_message_with_reply_sync(). More...
void | start_message_processing ()
| If connection was created with DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING, this method starts processing messages. More...
bool | is_closed () const
| Gets whether connection is closed. More...
Glib::RefPtr< IOStream > | get_stream ()
| Gets the underlying stream used for IO. More...
Glib::RefPtr< const IOStream > | get_stream () const
| Gets the underlying stream used for IO. More...
std::string | get_guid () const
| The GUID of the peer performing the role of server when authenticating. More...
Glib::ustring | get_unique_name () const
| Gets the unique name of connection as assigned by the message bus. More...
CapabilityFlags | get_capabilities () const
| Gets the capabilities negotiated with the remote peer. More...
ConnectionFlags | get_flags () const
| Gets the flags used to construct this connection. More...
Glib::RefPtr< Credentials > | get_peer_credentials ()
| Gets the credentials of the authenticated peer. More...
Glib::RefPtr< const Credentials > | get_peer_credentials () const
| Gets the credentials of the authenticated peer. More...
guint32 | get_last_serial () const
| Retrieves the last serial number assigned to a DBusMessage on the current thread. More...

void

call (const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, const Glib::ustring& bus_name=Glib::ustring(), int timeout_msec=-1, CallFlags flags=Gio::DBus::CALL_FLAGS_NONE, const Glib::VariantType& reply_type=Glib::VariantType())

| Asynchronously invokes the method_name method on the interface_name D-Bus interface on the remote object at object_path owned by bus_name. More...
void | call (const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, const SlotAsyncReady& slot, const Glib::ustring& bus_name=Glib::ustring(), int timeout_msec=-1, CallFlags flags=Gio::DBus::CALL_FLAGS_NONE, const Glib::VariantType& reply_type=Glib::VariantType())
| A non-cancellable version of call(). More...
Glib::VariantContainerBase | call_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an operation started with call(). More...

Glib::VariantContainerBase

call_sync (const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, const Glib::RefPtr< Cancellable >& cancellable, const Glib::ustring& bus_name=Glib::ustring(), int timeout_msec=-1, CallFlags flags=Gio::DBus::CALL_FLAGS_NONE, const Glib::VariantType& reply_type=Glib::VariantType())

| Synchronously invokes the method_name method on the interface_name D-Bus interface on the remote object at object_path owned by bus_name. More...
Glib::VariantContainerBase | call_sync (const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, const Glib::ustring& bus_name=Glib::ustring(), int timeout_msec=-1, CallFlags flags=Gio::DBus::CALL_FLAGS_NONE, const Glib::VariantType& reply_type=Glib::VariantType())
| A non-cancellable version of call_sync(). More...

void

call (const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, const Glib::RefPtr< UnixFDList >& fd_list, const Glib::ustring& bus_name=Glib::ustring(), int timeout_msec=-1, CallFlags flags=Gio::DBus::CALL_FLAGS_NONE, const Glib::VariantType& reply_type=Glib::VariantType())

| Like call() but also takes a GUnixFDList object. More...

void

call (const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, const SlotAsyncReady& slot, const Glib::RefPtr< UnixFDList >& fd_list, const Glib::ustring& bus_name=Glib::ustring(), int timeout_msec=-1, CallFlags flags=Gio::DBus::CALL_FLAGS_NONE, const Glib::VariantType& reply_type=Glib::VariantType())

| A non-cancellable version of call() (with a UnixFDList). More...
Glib::VariantContainerBase | call_finish (const Glib::RefPtr< AsyncResult >& res, Glib::RefPtr< UnixFDList >& out_fd_list)
| Finishes an operation started with call() (with a UnixFDList). More...

Glib::VariantContainerBase

call_sync (const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, const Glib::RefPtr< Cancellable >& cancellable, const Glib::RefPtr< UnixFDList >& fd_list, Glib::RefPtr< UnixFDList >& out_fd_list, const Glib::ustring& bus_name=Glib::ustring(), int timeout_msec=-1, CallFlags flags=Gio::DBus::CALL_FLAGS_NONE, const Glib::VariantType& reply_type=Glib::VariantType())

| Like g_dbus_connection_call_sync() but also takes and returns UnixFDList objects. More...

Glib::VariantContainerBase

call_sync (const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, const Glib::RefPtr< UnixFDList >& fd_list, Glib::RefPtr< UnixFDList >& out_fd_list, const Glib::ustring& bus_name=Glib::ustring(), int timeout_msec=-1, CallFlags flags=Gio::DBus::CALL_FLAGS_NONE, const Glib::VariantType& reply_type=Glib::VariantType())

| A call_sync() convenience overload. More...
void | emit_signal (const Glib::ustring& object_path, const Glib::ustring& interface_name, const Glib::ustring& signal_name, const Glib::ustring& destination_bus_name=Glib::ustring(), const Glib::VariantContainerBase& parameters=Glib::VariantContainerBase())
| Emits a signal. More...
guint | signal_subscribe (const SlotSignal& slot, const Glib::ustring& sender=Glib::ustring(), const Glib::ustring& interface_name=Glib::ustring(), const Glib::ustring& member=Glib::ustring(), const Glib::ustring& object_path=Glib::ustring(), const Glib::ustring& arg0=Glib::ustring(), SignalFlags flags=Gio::DBus::SIGNAL_FLAGS_NONE)
| Subscribes to signals on the connection and invokes slot with a whenever the signal is received. More...
void | signal_unsubscribe (guint subscription_id)
| Unsubscribes from signals. More...
guint | add_filter (const SlotMessageFilter& slot)
| Adds a message filter. More...
void | remove_filter (guint filter_id)
| Removes a filter. More...
guint | register_object (const Glib::ustring& object_path, const Glib::RefPtr< InterfaceInfo >& interface_info, const InterfaceVTable& vtable)
| Registers slots for exported objects at object_path with the D-Bus interface that is described in interface_info. More...
guint | register_object (const Glib::ustring& object_path, const Glib::RefPtr< InterfaceInfo >& interface_info)
| Registers exported objects at object_path with the D-Bus interface that is described in interface_info. More...
bool | unregister_object (guint registration_id)
| Unregisters an object. More...
guint | register_subtree (const Glib::ustring& object_path, const SubtreeVTable& vtable, SubtreeFlags flags=Gio::DBus::SUBTREE_FLAGS_NONE)
| Registers a whole subtree of “dynamic” objects. More...
bool | unregister_subtree (guint registration_id)
| Unregisters a subtree. More...
guint | export_action_group (const Glib::ustring& object_path, const Glib::RefPtr< ActionGroup >& action_group)
| Exports action_group on connection at object_path. More...
void | unexport_action_group (guint export_id)
| Reverses the effect of a previous call to g_dbus_connection_export_action_group(). More...
guint | export_menu_model (const Glib::ustring& object_path, const Glib::RefPtr< MenuModel >& menu)
| Exports menu on connection at object_path. More...
void | unexport_menu_model (guint export_id)
| Reverses the effect of a previous call to g_dbus_connection_export_menu_model(). More...
Glib::PropertyProxy_ReadOnly< CapabilityFlags > | property_capabilities () const
| Flags from the DBusCapabilityFlags enumeration representing connection features negotiated with the other peer. More...
Glib::PropertyProxy_ReadOnly< bool > | property_closed () const
| A boolean specifying whether the connection has been closed. More...
Glib::PropertyProxy< bool > | property_exit_on_close ()
| A boolean specifying whether the process will be terminated (by calling `raise(SIGTERM)`) if the connection is closed by the remote peer. More...
Glib::PropertyProxy_ReadOnly< bool > | property_exit_on_close () const
| A boolean specifying whether the process will be terminated (by calling `raise(SIGTERM)`) if the connection is closed by the remote peer. More...
Glib::PropertyProxy_ReadOnly< ConnectionFlags > | property_flags () const
| Flags from the DBusConnectionFlags enumeration. More...
Glib::PropertyProxy_ReadOnly< std::string > | property_guid () const
| The GUID of the peer performing the role of server when authenticating. More...
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< IOStream > > | property_stream () const
| The underlying IOStream used for I/O. More...
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_unique_name () const
| The unique name as assigned by the message bus or `nullptr` if the connection is not open or not a message bus connection. More...
Glib::SignalProxy< void, bool, const Glib::Error& > | signal_closed ()
Public Member Functions inherited from Glib::Object
| Object (const Object&)=delete
Object& | operator= (const Object&)=delete
| Object (Object&& src) noexcept
Object& | operator= (Object&& src) noexcept
void* | get_data (const QueryQuark& key)
void | set_data (const Quark& key, void* data)
void | set_data (const Quark& key, void* data, DestroyNotify notify)
void | remove_data (const QueryQuark& quark)
void* | steal_data (const QueryQuark& quark)
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase&)=delete
ObjectBase& | operator= (const ObjectBase&)=delete
void | set_property_value (const Glib::ustring& property_name, const Glib::ValueBase& value)
| You probably want to use a specific property_*() accessor method instead. More...
void | get_property_value (const Glib::ustring& property_name, Glib::ValueBase& value) const
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | set_property (const Glib::ustring& property_name, const PropertyType& value)
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | get_property (const Glib::ustring& property_name, PropertyType& value) const
| You probably want to use a specific property_*() accessor method instead. More...
void | connect_property_changed (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
void | connect_property_changed (const Glib::ustring& property_name, sigc::slot< void >&& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, sigc::slot< void >&& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
void | freeze_notify ()
| Increases the freeze count on object. More...
void | thaw_notify ()
| Reverts the effect of a previous call to freeze_notify(). More...
virtual void | reference () const
| Increment the reference count for this object. More...
virtual void | unreference () const
| Decrement the reference count for this object. More...
GObject* | gobj ()
| Provides access to the underlying C GObject. More...
const GObject* | gobj () const
| Provides access to the underlying C GObject. More...
GObject* | gobj_copy () const
| Give a ref-ed copy to someone. Use for direct struct access. More...
Public Member Functions inherited from sigc::trackable
| trackable () noexcept
| trackable (const trackable &src) noexcept
| trackable (trackable &&src)
| ~trackable ()
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const
void | notify_callbacks ()
trackable & | operator= (const trackable &src)
trackable & | operator= (trackable &&src)
void | remove_destroy_notify_callback (void *data) const
Public Member Functions inherited from Gio::Initable
| Initable (Initable&& src) noexcept
Initable& | operator= (Initable&& src) noexcept
| ~Initable () noexcept override
GInitable* | gobj ()
| Provides access to the underlying C GObject. More...
const GInitable* | gobj () const
| Provides access to the underlying C GObject. More...
Public Member Functions inherited from Glib::Interface
| Interface ()
| A Default constructor. More...
| Interface (Interface&& src) noexcept
Interface& | operator= (Interface&& src) noexcept
| Interface (const Glib::Interface_Class& interface_class)
| Called by constructors of derived classes. More...
| Interface (GObject* castitem)
| Called by constructors of derived classes. More...
| ~Interface () noexcept override
| Interface (const Interface&)=delete
Interface& | operator= (const Interface&)=delete
GObject* | gobj ()
const GObject* | gobj () const
Public Member Functions inherited from Gio::AsyncInitable
| AsyncInitable (AsyncInitable&& src) noexcept
AsyncInitable& | operator= (AsyncInitable&& src) noexcept
| ~AsyncInitable () noexcept override
GAsyncInitable* | gobj ()
| Provides access to the underlying C GObject. More...
const GAsyncInitable* | gobj () const
| Provides access to the underlying C GObject. More...

## Static Public Member Functions

static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
static void | get (BusType bus_type, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable)
| Asynchronously connects to the message bus specified by bus_type. More...
static void | get (BusType bus_type, const SlotAsyncReady& slot)
| Non-cancellable version of get(). More...
static Glib::RefPtr< Connection > | get_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an operation started with g_bus_get(). More...
static Glib::RefPtr< Connection > | get_sync (BusType bus_type, const Glib::RefPtr< Cancellable >& cancellable)
| Synchronously connects to the message bus specified by bus_type. More...
static Glib::RefPtr< Connection > | get_sync (BusType bus_type)
| A get_sync() convenience overload. More...
static void | create (const Glib::RefPtr< IOStream >& stream, const std::string& guid, const Glib::RefPtr< AuthObserver >& observer, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Asynchronously sets up a D-Bus connection for exchanging D-Bus messages with the end represented by stream. More...
static void | create (const Glib::RefPtr< IOStream >& stream, const std::string& guid, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Asynchronously sets up a D-Bus connection for exchanging D-Bus messages with the end represented by stream. More...
static void | create (const Glib::RefPtr< IOStream >& stream, const std::string& guid, const Glib::RefPtr< AuthObserver >& observer, const SlotAsyncReady& slot, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Non-cancellable version of create(). More...
static void | create (const Glib::RefPtr< IOStream >& stream, const std::string& guid, const SlotAsyncReady& slot, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Non-cancellable version of create(). More...
static Glib::RefPtr< Connection > | create_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an operation started with g_dbus_connection_new(). More...
static void | create_for_address (const std::string& address, const Glib::RefPtr< AuthObserver >& observer, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Asynchronously connects and sets up a D-Bus client connection for exchanging D-Bus messages with an endpoint specified by address which must be in the D-Bus address format. More...
static void | create_for_address (const std::string& address, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Asynchronously connects and sets up a D-Bus client connection for exchanging D-Bus messages with an endpoint specified by address which must be in the D-Bus address format. More...
static void | create_for_address (const std::string& address, const Glib::RefPtr< AuthObserver >& observer, const SlotAsyncReady& slot, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Non-cancellable version of create_for_address(). More...
static void | create_for_address (const std::string& address, const SlotAsyncReady& slot, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Non-cancellable version of create_for_address(). More...
static Glib::RefPtr< Connection > | create_for_address_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes an operation started with g_dbus_connection_new_for_address(). More...
static Glib::RefPtr< Connection > | create_sync (const Glib::RefPtr< IOStream >& stream, const std::string& guid, const Glib::RefPtr< AuthObserver >& observer, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Synchronously sets up a D-Bus connection for exchanging D-Bus messages with the end represented by stream. More...
static Glib::RefPtr< Connection > | create_sync (const Glib::RefPtr< IOStream >& stream, const std::string& guid, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Synchronously sets up a D-Bus connection for exchanging D-Bus messages with the end represented by stream. More...
static Glib::RefPtr< Connection > | create_sync (const Glib::RefPtr< IOStream >& stream, const std::string& guid, const Glib::RefPtr< AuthObserver >& observer, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Non-cancellable version of create_sync(). More...
static Glib::RefPtr< Connection > | create_sync (const Glib::RefPtr< IOStream >& stream, const std::string& guid, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Non-cancellable version of create_sync(). More...
static Glib::RefPtr< Connection > | create_for_address_sync (const std::string& address, const Glib::RefPtr< AuthObserver >& observer, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Synchronously connects and sets up a D-Bus client connection for exchanging D-Bus messages with an endpoint specified by address which must be in the D-Bus address format. More...
static Glib::RefPtr< Connection > | create_for_address_sync (const std::string& address, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Synchronously connects and sets up a D-Bus client connection for exchanging D-Bus messages with an endpoint specified by address which must be in the D-Bus address format. More...
static Glib::RefPtr< Connection > | create_for_address_sync (const std::string& address, const Glib::RefPtr< AuthObserver >& observer, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Non-cancellable version of create_for_address_sync(). More...
static Glib::RefPtr< Connection > | create_for_address_sync (const std::string& address, ConnectionFlags flags=Gio::DBus::CONNECTION_FLAGS_NONE)
| Non-cancellable version of create_for_address_sync(). More...
Static Public Member Functions inherited from Gio::Initable
static void | add_interface (GType gtype_implementer)
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
Static Public Member Functions inherited from Gio::AsyncInitable
static void | add_interface (GType gtype_implementer)
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...

## Protected Member Functions

| Connection (const Glib::RefPtr< IOStream >& stream, const std::string& guid, const Glib::RefPtr< AuthObserver >& observer, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags)
| Connection (const Glib::RefPtr< IOStream >& stream, const std::string& guid, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags)
| Connection (const Glib::RefPtr< IOStream >& stream, const std::string& guid, const Glib::RefPtr< AuthObserver >& observer, const SlotAsyncReady& slot, ConnectionFlags flags)
| Connection (const Glib::RefPtr< IOStream >& stream, const std::string& guid, const SlotAsyncReady& slot, ConnectionFlags flags)
| Connection (const Glib::RefPtr< IOStream >& stream, const std::string& guid, const Glib::RefPtr< AuthObserver >& observer, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags)
| Connection (const Glib::RefPtr< IOStream >& stream, const std::string& guid, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags)
| Connection (const Glib::RefPtr< IOStream >& stream, const std::string& guid, const Glib::RefPtr< AuthObserver >& observer, ConnectionFlags flags)
| Connection (const Glib::RefPtr< IOStream >& stream, const std::string& guid, ConnectionFlags flags)
| Connection (const std::string& address, const Glib::RefPtr< AuthObserver >& observer, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags)
| Connection (const std::string& address, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags)
| Connection (const std::string& address, const Glib::RefPtr< AuthObserver >& observer, const SlotAsyncReady& slot, ConnectionFlags flags)
| Connection (const std::string& address, const SlotAsyncReady& slot, ConnectionFlags flags)
| Connection (const std::string& address, const Glib::RefPtr< AuthObserver >& observer, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags)
| Connection (const std::string& address, const Glib::RefPtr< Cancellable >& cancellable, ConnectionFlags flags)
| Connection (const std::string& address, const Glib::RefPtr< AuthObserver >& observer, ConnectionFlags flags)
| Connection (const std::string& address, ConnectionFlags flags)
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams& construct_params)
| Object (GObject* castitem)
| ~Object () noexcept override
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor. More...
| ObjectBase (const char* custom_type_name)
| A derived constructor always overrides this choice. More...
| ObjectBase (const std::type_info& custom_type_info)
| This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually. More...
| ObjectBase (ObjectBase&& src) noexcept
ObjectBase& | operator= (ObjectBase&& src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject* castitem)
void | initialize_move (GObject* castitem, Glib::ObjectBase* previous_wrapper)
Protected Member Functions inherited from Gio::Initable
| Initable ()
| You should derive from this class to use it. More...
void | init (const Glib::RefPtr< Cancellable >& cancellable)
| Initializes the object implementing the interface. More...
void | init ()
| A init() convenience overload. More...
virtual bool | init_vfunc (const Glib::RefPtr< Cancellable >& cancellable, GError** error)
Protected Member Functions inherited from Gio::AsyncInitable
| AsyncInitable ()
| You should derive from this class to use it. More...
void | init_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, int io_priority=Glib::PRIORITY_DEFAULT)
| Starts asynchronous initialization of the object implementing the interface. More...
void | init_async (const SlotAsyncReady& slot, int io_priority=Glib::PRIORITY_DEFAULT)
| Non-cancellable version of init_async(). More...
bool | init_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes asynchronous initialization and returns the result. More...
Glib::RefPtr< Glib::Object > | create_finish (const Glib::RefPtr< AsyncResult >& res)
| Finishes the async construction for the various g_async_initable_new calls, returning the created object or `nullptr` on error. More...
virtual void | init_async_vfunc (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, int io_priority=Glib::PRIORITY_DEFAULT)
virtual bool | init_finish_vfunc (const Glib::RefPtr< AsyncResult >& res)

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr< Gio::DBus::Connection > | wrap (GDBusConnection* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...
Related Functions inherited from Glib::Object
Glib::RefPtr< Glib::Object > | wrap (GObject* object, bool take_copy=false)
Related Functions inherited from Gio::Initable
Glib::RefPtr< Gio::Initable > | wrap (GInitable* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...
Related Functions inherited from Gio::AsyncInitable
Glib::RefPtr< Gio::AsyncInitable > | wrap (GAsyncInitable* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Detailed Description

A D-Bus Connection.

The Connection type is used for D-Bus connections to remote peers such as a message buses. It is a low-level API that offers a lot of flexibility. For instance, it lets you establish a connection over any transport that can by represented as an IOStream.

This class is rarely used directly in D-Bus clients. If you are writing a D-Bus client, it is often easier to use the Gio::DBus::own_name(), Gio::DBus::watch_name() or Gio::DBus::Proxy::create_for_bus() APIs.

Since glibmm 2.28:

## Member Typedef Documentation

using Gio::DBus::Connection::SlotMessageFilter = sigc::slot<Glib::RefPtr<Message>, const Glib::RefPtr<Connection>&, const Glib::RefPtr<Message>&, bool>

Signature for slot used in add_filter().

For example,

Glib::RefPtr<Message> on_message_filter(const
Glib::RefPtr<Connection> connection, const Glib::RefPtr<Message>&
message, bool incoming);.

A filter function is passed a Message and expected to return a Message too. Passive filter functions that don't modify the message can simply return the message object. Filter functions that wants to drop a message can simply return `0`. And filter function may modify a message by copying it and return the copy.

using Gio::DBus::Connection::SlotSignal = sigc::slot<void, const Glib::RefPtr<Connection>&, const Glib::ustring&, const Glib::ustring&, const Glib::ustring&, const Glib::ustring&, const Glib::VariantContainerBase&>

Signature for slot used in signal_subscribe().

For example,

void on_signal(const Glib::RefPtr<Connection>& connection, const
Glib::ustring& sender_name, const Glib::ustring& object_path, const
Glib::ustring& object_path, const Glib::ustring& interface_name, const
Glib::ustring& signal_name, const Glib::VariantContainerBase& parameters);.

## Constructor & Destructor Documentation

Gio::DBus::Connection::Connection | ( | Connection&& | src | ) |

noexcept

Gio::DBus::Connection::~Connection | ( |  | ) |

overridenoexcept

Gio::DBus::Connection::Connection | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags
| ) |  |

protected

Gio::DBus::Connection::Connection | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags
| ) |  |

protected

Gio::DBus::Connection::Connection | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | const SlotAsyncReady& | slot,
|  | ConnectionFlags | flags
| ) |  |

protected

Gio::DBus::Connection::Connection | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | const SlotAsyncReady& | slot,
|  | ConnectionFlags | flags
| ) |  |

protected

Gio::DBus::Connection::Connection | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags
| ) |  |

protected

Gio::DBus::Connection::Connection | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags
| ) |  |

protected

Gio::DBus::Connection::Connection | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | ConnectionFlags | flags
| ) |  |

protected

Gio::DBus::Connection::Connection | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | ConnectionFlags | flags
| ) |  |

protected

Gio::DBus::Connection::Connection | ( | const std::string & | address,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags
| ) |  |

protected

Gio::DBus::Connection::Connection | ( | const std::string & | address,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags
| ) |  |

protected

Gio::DBus::Connection::Connection | ( | const std::string & | address,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | const SlotAsyncReady& | slot,
|  | ConnectionFlags | flags
| ) |  |

protected

Gio::DBus::Connection::Connection | ( | const std::string & | address,
|  | const SlotAsyncReady& | slot,
|  | ConnectionFlags | flags
| ) |  |

protected

Gio::DBus::Connection::Connection | ( | const std::string & | address,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags
| ) |  |

protected

Gio::DBus::Connection::Connection | ( | const std::string & | address,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags
| ) |  |

protected

Gio::DBus::Connection::Connection | ( | const std::string & | address,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | ConnectionFlags | flags
| ) |  |

protected

Gio::DBus::Connection::Connection | ( | const std::string & | address,
|  | ConnectionFlags | flags
| ) |  |

protected

## Member Function Documentation

guint Gio::DBus::Connection::add_filter | ( | const SlotMessageFilter& | slot | ) |

Adds a message filter.

Filters are handlers that are run on all incoming and outgoing messages, prior to standard dispatch. Filters are run in the order that they were added. The same handler can be added as a filter more than once, in which case it will be run more than once. Filters added during a filter slot won't be run on the message being processed. Filter slots are allowed to modify and even drop messages.

Note that filters are run in a dedicated message handling thread so they can't block and, generally, can't do anything but signal a worker thread. Also note that filters are rarely needed - use API such as send_message_with_reply(), signal_subscribe() or call() instead.

If a filter consumes an incoming message the message is not dispatched anywhere else - not even the standard dispatch machinery (that API such as signal_subscribe() and send_message_with_reply() relies on) will see the message. Similary, if a filter consumes an outgoing message, the message will not be sent to the other peer.

Parameters

  slot | A filter slot.

Returns
  A filter identifier that can be used with remove_filter().

Since glibmm 2.28:

void Gio::DBus::Connection::call | ( | const Glib::ustring& | object_path,
|  | const Glib::ustring& | interface_name,
|  | const Glib::ustring& | method_name,
|  | const Glib::VariantContainerBase& | parameters,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const Glib::ustring& | bus_name = `Glib::ustring()`,
|  | int | timeout_msec = `-1`,
|  | CallFlags | flags = `Gio::DBus::CALL_FLAGS_NONE`,
|  | const Glib::VariantType& | reply_type = `Glib::VariantType()`
| ) |  |

Asynchronously invokes the method_name method on the interface_name D-Bus interface on the remote object at object_path owned by bus_name.

If the connection is closed then the operation will fail with Gio::IO_ERROR_CLOSED. If cancellable is cancelled, the operation will fail with Gio::IO_ERROR_CANCELLED. If parameters contains a value not compatible with the D-Bus protocol, the operation fails with Gio::IO_ERROR_INVALID_ARGUMENT.

If reply_type is non-`0` then the reply will be checked for having this type and an error will be raised if it does not match. Said another way, if you give a reply_type then any non-`0` return value will be of this type.

This is an asynchronous method. When the operation is finished, callback will be invoked in the thread-default main loop of the thread you are calling this method from. You can then call call_finish() to get the result of the operation. See call_sync() for the synchronous version of this function.

Parameters

  object_path | Path of remote object.
  interface_name | D-Bus interface to invoke method on.
  method_name | The name of the method to invoke.
  parameters | A Glib::VariantContainerBase tuple with parameters for the method or `0` if not passing parameters.
  slot | A SlotAsyncReady to call when the request is satisfied.
  cancellable | A Cancellable.
  bus_name | A unique or well-known bus name or an empty string if the connection is not a message bus connection.
  timeout_msec | The timeout in milliseconds, -1 to use the default timeout or G_MAXINT for no timeout.
  flags | Flags from the Gio::DBus::CallFlags enumeration.
  reply_type | The expected type of the reply, or `0`.

Since glibmm 2.28:

void Gio::DBus::Connection::call | ( | const Glib::ustring& | object_path,
|  | const Glib::ustring& | interface_name,
|  | const Glib::ustring& | method_name,
|  | const Glib::VariantContainerBase& | parameters,
|  | const SlotAsyncReady& | slot,
|  | const Glib::ustring& | bus_name = `Glib::ustring()`,
|  | int | timeout_msec = `-1`,
|  | CallFlags | flags = `Gio::DBus::CALL_FLAGS_NONE`,
|  | const Glib::VariantType& | reply_type = `Glib::VariantType()`
| ) |  |

A non-cancellable version of call().

void Gio::DBus::Connection::call | ( | const Glib::ustring& | object_path,
|  | const Glib::ustring& | interface_name,
|  | const Glib::ustring& | method_name,
|  | const Glib::VariantContainerBase& | parameters,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const Glib::RefPtr< UnixFDList >& | fd_list,
|  | const Glib::ustring& | bus_name = `Glib::ustring()`,
|  | int | timeout_msec = `-1`,
|  | CallFlags | flags = `Gio::DBus::CALL_FLAGS_NONE`,
|  | const Glib::VariantType& | reply_type = `Glib::VariantType()`
| ) |  |

Like call() but also takes a GUnixFDList object.

This method is only available on UNIX.

This is an asynchronous method. When the operation is finished, callback will be invoked in the thread-default main loop of the thread you are calling this method from. You can then call call_with_unix_fd_finish() to get the result of the operation. See call_sync() for the synchronous version of this function.

Parameters

  object_path | Path of remote object.
  interface_name | D-Bus interface to invoke method on.
  method_name | The name of the method to invoke.
  parameters | A Glib::VariantContainerBase tuple with parameters for the method or `0` if not passing parameters.
  slot | A SlotAsyncReady to call when the request is satisfied.
  cancellable | A Cancellable.
  fd_list | A UnixFDList.
  bus_name | A unique or well-known bus name or an empty string if the connection is not a message bus connection.
  timeout_msec | The timeout in milliseconds, -1 to use the default timeout or G_MAXINT for no timeout.
  flags | Flags from the Gio::DBus::CallFlags enumeration.
  reply_type | The expected type of the reply, or `0`.

Since glibmm 2.34:

void Gio::DBus::Connection::call | ( | const Glib::ustring& | object_path,
|  | const Glib::ustring& | interface_name,
|  | const Glib::ustring& | method_name,
|  | const Glib::VariantContainerBase& | parameters,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< UnixFDList >& | fd_list,
|  | const Glib::ustring& | bus_name = `Glib::ustring()`,
|  | int | timeout_msec = `-1`,
|  | CallFlags | flags = `Gio::DBus::CALL_FLAGS_NONE`,
|  | const Glib::VariantType& | reply_type = `Glib::VariantType()`
| ) |  |

A non-cancellable version of call() (with a UnixFDList).

Since glibmm 2.34:

Glib::VariantContainerBase Gio::DBus::Connection::call_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes an operation started with call().

Parameters

  res | A AsyncResult obtained from the SlotAsyncReady passed to call().

Returns
  A Variant tuple with return values.

Exceptions

  Glib::Error. |

Since glibmm 2.28:

Glib::VariantContainerBase Gio::DBus::Connection::call_finish | ( | const Glib::RefPtr< AsyncResult >& | res,
|  | Glib::RefPtr< UnixFDList >& | out_fd_list
| ) |  |

Finishes an operation started with call() (with a UnixFDList).

Parameters

  res | A AsyncResult obtained from the SlotAsyncReady passed to call().
  out_fd_list | Return location for a UnixFDList.

Returns
  A Variant tuple with return values.

Exceptions

  Glib::Error. |

Since glibmm 2.34:

Glib::VariantContainerBase Gio::DBus::Connection::call_sync | ( | const Glib::ustring& | object_path,
|  | const Glib::ustring& | interface_name,
|  | const Glib::ustring& | method_name,
|  | const Glib::VariantContainerBase& | parameters,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const Glib::ustring& | bus_name = `Glib::ustring()`,
|  | int | timeout_msec = `-1`,
|  | CallFlags | flags = `Gio::DBus::CALL_FLAGS_NONE`,
|  | const Glib::VariantType& | reply_type = `Glib::VariantType()`
| ) |  |

Synchronously invokes the method_name method on the interface_name D-Bus interface on the remote object at object_path owned by bus_name.

If the connection is closed then the operation will fail with Gio::IO_ERROR_CLOSED. If cancellable is cancelled, the operation will fail with Gio::IO_ERROR_CANCELLED. If parameters contains a value not compatible with the D-Bus protocol, the operation fails with Gio::IO_ERROR_INVALID_ARGUMENT.

If reply_type is non-`0` then the reply will be checked for having this type and an error will be raised if it does not match. Said another way, if you give a reply_type then any non-`0` return value will be of this type.

The calling thread is blocked until a reply is received. See call() for the asynchronous version of this method.

Parameters

  object_path | Path of remote object.
  interface_name | D-Bus interface to invoke method on.
  method_name | The name of the method to invoke.
  parameters | A Glib::VariantContainerBase tuple with parameters for the method or `0` if not passing parameters.
  cancellable | A Cancellable.
  bus_name | A unique or well-known bus name or an empty string if the connection is not a message bus connection.
  timeout_msec | The timeout in milliseconds, -1 to use the default timeout or G_MAXINT for no timeout.
  flags | Flags from the Gio::DBus::CallFlags enumeration.
  reply_type | The expected type of the reply, or `0`.

Returns
  A Variant tuple with return values.

Exceptions

  Glib::Error. |

Since glibmm 2.28:

Glib::VariantContainerBase Gio::DBus::Connection::call_sync | ( | const Glib::ustring& | object_path,
|  | const Glib::ustring& | interface_name,
|  | const Glib::ustring& | method_name,
|  | const Glib::VariantContainerBase& | parameters,
|  | const Glib::ustring& | bus_name = `Glib::ustring()`,
|  | int | timeout_msec = `-1`,
|  | CallFlags | flags = `Gio::DBus::CALL_FLAGS_NONE`,
|  | const Glib::VariantType& | reply_type = `Glib::VariantType()`
| ) |  |

A non-cancellable version of call_sync().

Glib::VariantContainerBase Gio::DBus::Connection::call_sync | ( | const Glib::ustring& | object_path,
|  | const Glib::ustring& | interface_name,
|  | const Glib::ustring& | method_name,
|  | const Glib::VariantContainerBase& | parameters,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | const Glib::RefPtr< UnixFDList >& | fd_list,
|  | Glib::RefPtr< UnixFDList >& | out_fd_list,
|  | const Glib::ustring& | bus_name = `Glib::ustring()`,
|  | int | timeout_msec = `-1`,
|  | CallFlags | flags = `Gio::DBus::CALL_FLAGS_NONE`,
|  | const Glib::VariantType& | reply_type = `Glib::VariantType()`
| ) |  |

Like g_dbus_connection_call_sync() but also takes and returns UnixFDList objects.

This method is only available on UNIX.

Since glibmm 2.30:

Parameters

  bus_name | A unique or well-known bus name or `nullptr` if connection is not a message bus connection.
  object_path | Path of remote object.
  interface_name | D-Bus interface to invoke method on.
  method_name | The name of the method to invoke.
  parameters | A Variant tuple with parameters for the method or `nullptr` if not passing parameters.
  reply_type | The expected type of the reply, or `nullptr`.
  flags | Flags from the DBusCallFlags enumeration.
  timeout_msec | The timeout in milliseconds, -1 to use the default timeout or G_MAXINT for no timeout.
  fd_list | A UnixFDList or `nullptr`.
  out_fd_list | Return location for a UnixFDList or `nullptr`.
  cancellable | A Cancellable or `nullptr`.

Returns
  `nullptr` if error is set. Otherwise a Variant tuple with return values. Free with Glib::variant_unref().

Exceptions

  Glib::Error |

Glib::VariantContainerBase Gio::DBus::Connection::call_sync | ( | const Glib::ustring& | object_path,
|  | const Glib::ustring& | interface_name,
|  | const Glib::ustring& | method_name,
|  | const Glib::VariantContainerBase& | parameters,
|  | const Glib::RefPtr< UnixFDList >& | fd_list,
|  | Glib::RefPtr< UnixFDList >& | out_fd_list,
|  | const Glib::ustring& | bus_name = `Glib::ustring()`,
|  | int | timeout_msec = `-1`,
|  | CallFlags | flags = `Gio::DBus::CALL_FLAGS_NONE`,
|  | const Glib::VariantType& | reply_type = `Glib::VariantType()`
| ) |  |

A call_sync() convenience overload.

void Gio::DBus::Connection::close | ( |  | ) |

Closes the connection.

Note that this never causes the process to exit (this might only happen if the other end of a shared message bus connection disconnects, see property_exit_on_close()).

Once the connection is closed, operations such as sending a message will return with the error Gio::IO_ERROR_CLOSED. Closing a connection will not automatically flush the connection so queued messages may be lost. Use flush() if you need such guarantees.

If the connection is already closed, this method fails with Gio::IO_ERROR_CLOSED.

When the connection has been closed, the "closed" signal is emitted in the thread-default main loop of the thread that connection was constructed in.

This is an asynchronous method. See close_sync() for the synchronous version.

Since glibmm 2.28:

void Gio::DBus::Connection::close | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Closes the connection.

Note that this never causes the process to exit (this might only happen if the other end of a shared message bus connection disconnects, see property_exit_on_close()).

Once the connection is closed, operations such as sending a message will return with the error Gio::IO_ERROR_CLOSED. Closing a connection will not automatically flush the connection so queued messages may be lost. Use flush() if you need such guarantees.

If the connection is already closed, this method fails with Gio::IO_ERROR_CLOSED.

When the connection has been closed, the "closed" signal is emitted in the thread-default main loop of the thread that connection was constructed in.

This is an asynchronous method. When the operation is finished, slot will be invoked in the thread-default main loop of the thread you are calling this method from. You can then call close_finish() to get the result of the operation. See close_sync() for the synchronous version.

Parameters

  slot | A SlotAsyncReady to call when the request is satisfied.
  cancellable | A Cancellable.

Since glibmm 2.28:

void Gio::DBus::Connection::close | ( | const SlotAsyncReady& | slot | ) |

Closes the connection.

Note that this never causes the process to exit (this might only happen if the other end of a shared message bus connection disconnects, see property_exit_on_close()).

Once the connection is closed, operations such as sending a message will return with the error Gio::IO_ERROR_CLOSED. Closing a connection will not automatically flush the connection so queued messages may be lost. Use flush() if you need such guarantees.

If the connection is already closed, this method fails with Gio::IO_ERROR_CLOSED.

When the connection has been closed, the "closed" signal is emitted in the thread-default main loop of the thread that connection was constructed in.

This is an asynchronous method. When the operation is finished, slot will be invoked in the thread-default main loop of the thread you are calling this method from. You can then call close_finish() to get the result of the operation. See close_sync() for the synchronous version.

Parameters

  slot | A SlotAsyncReady to call when the request is satisfied.

Since glibmm 2.28:

bool Gio::DBus::Connection::close_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes an operation started with g_dbus_connection_close().

Since glibmm 2.26:

Parameters

  res | A AsyncResult obtained from the SlotAsyncReady passed to g_dbus_connection_close().

Returns
  `true` if the operation succeeded, `false` if error is set.

Exceptions

  Glib::Error |

void Gio::DBus::Connection::close_sync | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Synchronously closes connection.

The calling thread is blocked until this is done. See g_dbus_connection_close() for the asynchronous version of this method and more details about what it does.

Since glibmm 2.26:

Parameters

  cancellable | A Cancellable or `nullptr`.

Exceptions

  Glib::Error |

void Gio::DBus::Connection::close_sync | ( |  | ) |

A close_sync() convenience overload.

static void Gio::DBus::Connection::create | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Asynchronously sets up a D-Bus connection for exchanging D-Bus messages with the end represented by stream.

If stream is a SocketConnection, then the corresponding Socket will be put into non-blocking mode.

The D-Bus connection will interact with stream from a worker thread. As a result, the caller should not interact with stream after this method has been called, except by calling Glib::object_unref() on it.

If observer is not `nullptr` it may be used to control the authentication process.

When the operation is finished, slot will be invoked. You can then call g_dbus_connection_new_finish() to get the result of the operation.

This is an asynchronous failable constructor. See g_dbus_connection_new_sync() for the synchronous version.

Since glibmm 2.26:

Parameters

  stream | A IOStream.
  guid | The GUID to use if authenticating as a server or `nullptr`.
  flags | Flags describing how to make the connection.
  observer | A DBusAuthObserver or `nullptr`.
  cancellable | A Cancellable or `nullptr`.
  slot | A SlotAsyncReady to call when the request is satisfied.
  user_data | The data to pass to slot.

static void Gio::DBus::Connection::create | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Asynchronously sets up a D-Bus connection for exchanging D-Bus messages with the end represented by stream.

If stream is a SocketConnection, then the corresponding Socket will be put into non-blocking mode.

The D-Bus connection will interact with stream from a worker thread. As a result, the caller should not interact with stream after this method has been called, except by calling Glib::object_unref() on it.

If observer is not `nullptr` it may be used to control the authentication process.

When the operation is finished, slot will be invoked. You can then call g_dbus_connection_new_finish() to get the result of the operation.

This is an asynchronous failable constructor. See g_dbus_connection_new_sync() for the synchronous version.

Since glibmm 2.26:

Parameters

  stream | A IOStream.
  guid | The GUID to use if authenticating as a server or `nullptr`.
  flags | Flags describing how to make the connection.
  observer | A DBusAuthObserver or `nullptr`.
  cancellable | A Cancellable or `nullptr`.
  slot | A SlotAsyncReady to call when the request is satisfied.
  user_data | The data to pass to slot.

static void Gio::DBus::Connection::create | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | const SlotAsyncReady& | slot,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Non-cancellable version of create().

static void Gio::DBus::Connection::create | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | const SlotAsyncReady& | slot,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Non-cancellable version of create().

static Glib::RefPtr<Connection> Gio::DBus::Connection::create_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

static

Finishes an operation started with g_dbus_connection_new().

Since glibmm 2.26:

Parameters

  res | A AsyncResult obtained from the SlotAsyncReady passed to g_dbus_connection_new().

Returns
  A DBusConnection or `nullptr` if error is set. Free with Glib::object_unref().

Exceptions

  Glib::Error. |

static void Gio::DBus::Connection::create_for_address | ( | const std::string & | address,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Asynchronously connects and sets up a D-Bus client connection for exchanging D-Bus messages with an endpoint specified by address which must be in the D-Bus address format.

This constructor can only be used to initiate client-side connections - use g_dbus_connection_new() if you need to act as the server. In particular, flags cannot contain the DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER or DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS flags.

When the operation is finished, slot will be invoked. You can then call g_dbus_connection_new_for_address_finish() to get the result of the operation.

If observer is not `nullptr` it may be used to control the authentication process.

This is an asynchronous failable constructor. See g_dbus_connection_new_for_address_sync() for the synchronous version.

Since glibmm 2.26:

Parameters

  address | A D-Bus address.
  flags | Flags describing how to make the connection.
  observer | A DBusAuthObserver or `nullptr`.
  cancellable | A Cancellable or `nullptr`.
  slot | A SlotAsyncReady to call when the request is satisfied.
  user_data | The data to pass to slot.

static void Gio::DBus::Connection::create_for_address | ( | const std::string & | address,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Asynchronously connects and sets up a D-Bus client connection for exchanging D-Bus messages with an endpoint specified by address which must be in the D-Bus address format.

This constructor can only be used to initiate client-side connections - use g_dbus_connection_new() if you need to act as the server. In particular, flags cannot contain the DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER or DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS flags.

When the operation is finished, slot will be invoked. You can then call g_dbus_connection_new_for_address_finish() to get the result of the operation.

If observer is not `nullptr` it may be used to control the authentication process.

This is an asynchronous failable constructor. See g_dbus_connection_new_for_address_sync() for the synchronous version.

Since glibmm 2.26:

Parameters

  address | A D-Bus address.
  flags | Flags describing how to make the connection.
  observer | A DBusAuthObserver or `nullptr`.
  cancellable | A Cancellable or `nullptr`.
  slot | A SlotAsyncReady to call when the request is satisfied.
  user_data | The data to pass to slot.

static void Gio::DBus::Connection::create_for_address | ( | const std::string & | address,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | const SlotAsyncReady& | slot,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Non-cancellable version of create_for_address().

static void Gio::DBus::Connection::create_for_address | ( | const std::string & | address,
|  | const SlotAsyncReady& | slot,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Non-cancellable version of create_for_address().

static Glib::RefPtr<Connection> Gio::DBus::Connection::create_for_address_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

static

Finishes an operation started with g_dbus_connection_new_for_address().

Since glibmm 2.26:

Parameters

  res | A AsyncResult obtained from the SlotAsyncReady passed to g_dbus_connection_new().

Returns
  A DBusConnection or `nullptr` if error is set. Free with Glib::object_unref().

Exceptions

  Glib::Error. |

static Glib::RefPtr<Connection> Gio::DBus::Connection::create_for_address_sync | ( | const std::string & | address,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Synchronously connects and sets up a D-Bus client connection for exchanging D-Bus messages with an endpoint specified by address which must be in the D-Bus address format.

This constructor can only be used to initiate client-side connections - use g_dbus_connection_new_sync() if you need to act as the server. In particular, flags cannot contain the DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER or DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS flags.

This is a synchronous failable constructor. See g_dbus_connection_new_for_address() for the asynchronous version.

If observer is not `nullptr` it may be used to control the authentication process.

Since glibmm 2.26:

Parameters

  address | A D-Bus address.
  flags | Flags describing how to make the connection.
  observer | A DBusAuthObserver or `nullptr`.
  cancellable | A Cancellable or `nullptr`.

Returns
  A DBusConnection or `nullptr` if error is set. Free with Glib::object_unref().

Exceptions

  Glib::Error. |

static Glib::RefPtr<Connection> Gio::DBus::Connection::create_for_address_sync | ( | const std::string & | address,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Synchronously connects and sets up a D-Bus client connection for exchanging D-Bus messages with an endpoint specified by address which must be in the D-Bus address format.

This constructor can only be used to initiate client-side connections - use g_dbus_connection_new_sync() if you need to act as the server. In particular, flags cannot contain the DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER or DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS flags.

This is a synchronous failable constructor. See g_dbus_connection_new_for_address() for the asynchronous version.

If observer is not `nullptr` it may be used to control the authentication process.

Since glibmm 2.26:

Parameters

  address | A D-Bus address.
  flags | Flags describing how to make the connection.
  observer | A DBusAuthObserver or `nullptr`.
  cancellable | A Cancellable or `nullptr`.

Returns
  A DBusConnection or `nullptr` if error is set. Free with Glib::object_unref().

Exceptions

  Glib::Error. |

static Glib::RefPtr<Connection> Gio::DBus::Connection::create_for_address_sync | ( | const std::string & | address,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Non-cancellable version of create_for_address_sync().

static Glib::RefPtr<Connection> Gio::DBus::Connection::create_for_address_sync | ( | const std::string & | address,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Non-cancellable version of create_for_address_sync().

static Glib::RefPtr<Connection> Gio::DBus::Connection::create_sync | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Synchronously sets up a D-Bus connection for exchanging D-Bus messages with the end represented by stream.

If stream is a SocketConnection, then the corresponding Socket will be put into non-blocking mode.

The D-Bus connection will interact with stream from a worker thread. As a result, the caller should not interact with stream after this method has been called, except by calling Glib::object_unref() on it.

If observer is not `nullptr` it may be used to control the authentication process.

This is a synchronous failable constructor. See g_dbus_connection_new() for the asynchronous version.

Since glibmm 2.26:

Parameters

  stream | A IOStream.
  guid | The GUID to use if authenticating as a server or `nullptr`.
  flags | Flags describing how to make the connection.
  observer | A DBusAuthObserver or `nullptr`.
  cancellable | A Cancellable or `nullptr`.

Returns
  A DBusConnection or `nullptr` if error is set. Free with Glib::object_unref().

Exceptions

  Glib::Error. |

static Glib::RefPtr<Connection> Gio::DBus::Connection::create_sync | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Synchronously sets up a D-Bus connection for exchanging D-Bus messages with the end represented by stream.

If stream is a SocketConnection, then the corresponding Socket will be put into non-blocking mode.

The D-Bus connection will interact with stream from a worker thread. As a result, the caller should not interact with stream after this method has been called, except by calling Glib::object_unref() on it.

If observer is not `nullptr` it may be used to control the authentication process.

This is a synchronous failable constructor. See g_dbus_connection_new() for the asynchronous version.

Since glibmm 2.26:

Parameters

  stream | A IOStream.
  guid | The GUID to use if authenticating as a server or `nullptr`.
  flags | Flags describing how to make the connection.
  observer | A DBusAuthObserver or `nullptr`.
  cancellable | A Cancellable or `nullptr`.

Returns
  A DBusConnection or `nullptr` if error is set. Free with Glib::object_unref().

Exceptions

  Glib::Error. |

static Glib::RefPtr<Connection> Gio::DBus::Connection::create_sync | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | const Glib::RefPtr< AuthObserver >& | observer,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Non-cancellable version of create_sync().

static Glib::RefPtr<Connection> Gio::DBus::Connection::create_sync | ( | const Glib::RefPtr< IOStream >& | stream,
|  | const std::string & | guid,
|  | ConnectionFlags | flags = `Gio::DBus::CONNECTION_FLAGS_NONE`
| ) |  |

static

Non-cancellable version of create_sync().

void Gio::DBus::Connection::emit_signal | ( | const Glib::ustring& | object_path,
|  | const Glib::ustring& | interface_name,
|  | const Glib::ustring& | signal_name,
|  | const Glib::ustring& | destination_bus_name = `Glib::ustring()`,
|  | const Glib::VariantContainerBase& | parameters = `Glib::VariantContainerBase()`
| ) |  |

Emits a signal.

This can only fail if parameters is not compatible with the D-Bus protocol.

Parameters

  object_path | Path of remote object.
  interface_name | D-Bus interface to emit a signal on.
  signal_name | The name of the signal to emit.
  destination_bus_name | The unique bus name for the destination for the signal or an empty string to emit to all listeners.
  parameters | A Glib::VariantContainerBase tuple with parameters for the signal or `0` if not passing parameters.

Exceptions

  Glib::Error. |

Since glibmm 2.28:

guint Gio::DBus::Connection::export_action_group | ( | const Glib::ustring& | object_path,
|  | const Glib::RefPtr< ActionGroup >& | action_group
| ) |  |

Exports action_group on connection at object_path.

The implemented D-Bus API should be considered private. It is subject to change in the future.

A given object path can only have one action group exported on it. If this constraint is violated, the export will fail and 0 will be returned (with error set accordingly).

You can unexport the action group using g_dbus_connection_unexport_action_group() with the return value of this function.

The thread default main context is taken at the time of this call. All incoming action activations and state change requests are reported from this context. Any changes on the action group that cause it to emit signals must also come from this same context. Since incoming action activations and state change requests are rather likely to cause changes on the action group, this effectively limits a given action group to being exported from only one main context.

Since glibmm 2.32:

Parameters

  object_path | A D-Bus object path.
  action_group | A ActionGroup.

Returns
  The ID of the export (never zero), or 0 in case of failure.

Exceptions

  Glib::Error |

guint Gio::DBus::Connection::export_menu_model | ( | const Glib::ustring& | object_path,
|  | const Glib::RefPtr< MenuModel >& | menu
| ) |  |

Exports menu on connection at object_path.

The implemented D-Bus API should be considered private. It is subject to change in the future.

An object path can only have one menu model exported on it. If this constraint is violated, the export will fail and 0 will be returned (with error set accordingly).

You can unexport the menu model using g_dbus_connection_unexport_menu_model() with the return value of this function.

Since glibmm 2.32:

Parameters

  object_path | A D-Bus object path.
  menu | A MenuModel.

Returns
  The ID of the export (never zero), or 0 in case of failure.

Exceptions

  Glib::Error |

void Gio::DBus::Connection::flush | ( |  | ) |

Asynchronously flushes the connection, that is, writes all queued outgoing message to the transport and then flushes the transport (using Gio::OutputStream::flush_async()).

This is useful in programs that wants to emit a D-Bus signal and then exit immediately. Without flushing the connection, there is no guarantee that the message has been sent to the networking buffers in the OS kernel.

This is an asynchronous method. See flush_sync() for the synchronous version.

Since glibmm 2.28:

void Gio::DBus::Connection::flush | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Asynchronously flushes the connection, that is, writes all queued outgoing message to the transport and then flushes the transport (using Gio::OutputStream::flush_async()).

This is useful in programs that wants to emit a D-Bus signal and then exit immediately. Without flushing the connection, there is no guarantee that the message has been sent to the networking buffers in the OS kernel.

This is an asynchronous method. When the operation is finished, slot will be invoked in the thread-default main loop of the thread you are calling this method from. You can then call flush_finish() to get the result of the operation. See flush_sync() for the synchronous version.

Parameters

  slot | A SlotAsyncReady to call when the request is satisfied.
  cancellable | A Cancellable.

Since glibmm 2.28:

void Gio::DBus::Connection::flush | ( | const SlotAsyncReady& | slot | ) |

Asynchronously flushes the connection, that is, writes all queued outgoing message to the transport and then flushes the transport (using Gio::OutputStream::flush_async()).

This is useful in programs that wants to emit a D-Bus signal and then exit immediately. Without flushing the connection, there is no guarantee that the message has been sent to the networking buffers in the OS kernel.

This is an asynchronous method. When the operation is finished, slot will be invoked in the thread-default main loop of the thread you are calling this method from. You can then call flush_finish() to get the result of the operation. See flush_sync() for the synchronous version.

Parameters

  slot | A SlotAsyncReady to call when the request is satisfied.

Since glibmm 2.28:

bool Gio::DBus::Connection::flush_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes an operation started with g_dbus_connection_flush().

Since glibmm 2.26:

Parameters

  res | A AsyncResult obtained from the SlotAsyncReady passed to g_dbus_connection_flush().

Returns
  `true` if the operation succeeded, `false` if error is set.

Exceptions

  Glib::Error |

void Gio::DBus::Connection::flush_sync | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Synchronously flushes connection.

The calling thread is blocked until this is done. See g_dbus_connection_flush() for the asynchronous version of this method and more details about what it does.

Since glibmm 2.26:

Parameters

  cancellable | A Cancellable or `nullptr`.

Exceptions

  Glib::Error |

void Gio::DBus::Connection::flush_sync | ( |  | ) |

A flush_sync() convenience overload.

static void Gio::DBus::Connection::get | ( | BusType | bus_type,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

static

Asynchronously connects to the message bus specified by bus_type.

When the operation is finished, slot will be invoked. You can then call get_finish() to get the result of the operation.

This is a asynchronous failable function. See get_sync() for the synchronous version.

Parameters

  bus_type | A BusType.
  slot | A SlotAsyncReady to call when the request is satisfied.
  cancellable | A Cancellable.

Since glibmm 2.28:

static void Gio::DBus::Connection::get | ( | BusType | bus_type,
|  | const SlotAsyncReady& | slot
| ) |  |

static

Non-cancellable version of get().

CapabilityFlags Gio::DBus::Connection::get_capabilities | ( |  | ) | const

Gets the capabilities negotiated with the remote peer.

Since glibmm 2.26:

Returns
  Zero or more flags from the DBusCapabilityFlags enumeration.

bool Gio::DBus::Connection::get_exit_on_close | ( |  | ) | const

Gets whether the process is terminated when connection is closed by the remote peer.

See DBusConnection::property_exit_on_close() for more details.

Since glibmm 2.26:

Returns
  Whether the process is terminated when connection is closed by the remote peer.

static Glib::RefPtr<Connection> Gio::DBus::Connection::get_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

static

Finishes an operation started with g_bus_get().

The returned object is a singleton, that is, shared with other callers of g_bus_get() and g_bus_get_sync() for bus_type. In the event that you need a private message bus connection, use g_dbus_address_get_for_bus_sync() and g_dbus_connection_new_for_address().

Note that the returned DBusConnection object will (usually) have the DBusConnection::property_exit_on_close() property set to `true`.

Since glibmm 2.26:

Parameters

  res | A AsyncResult obtained from the SlotAsyncReady passed to g_bus_get().

Returns
  A DBusConnection or `nullptr` if error is set. Free with Glib::object_unref().

Exceptions

  Glib::Error |

ConnectionFlags Gio::DBus::Connection::get_flags | ( |  | ) | const

Gets the flags used to construct this connection.

Since glibmm 2.60:

Returns
  Zero or more flags from the DBusConnectionFlags enumeration.

std::string Gio::DBus::Connection::get_guid | ( |  | ) | const

The GUID of the peer performing the role of server when authenticating.

See DBusConnection::property_guid() for more details.

Since glibmm 2.26:

Returns
  The GUID. Do not free this string, it is owned by connection.

guint32 Gio::DBus::Connection::get_last_serial | ( |  | ) | const

Retrieves the last serial number assigned to a DBusMessage on the current thread.

This includes messages sent via both low-level API such as g_dbus_connection_send_message() as well as high-level API such as g_dbus_connection_emit_signal(), g_dbus_connection_call() or g_dbus_proxy_call().

Since glibmm 2.34:

Returns
  The last used serial or zero when no message has been sent within the current thread.

Glib::RefPtr<Credentials> Gio::DBus::Connection::get_peer_credentials | ( |  | ) |

Gets the credentials of the authenticated peer.

This will always return `nullptr` unless connection acted as a server (e.g. DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER was passed) when set up and the client passed credentials as part of the authentication process.

In a message bus setup, the message bus is always the server and each application is a client. So this method will always return `nullptr` for message bus clients.

Since glibmm 2.26:

Returns
  A Credentials or `nullptr` if not available. Do not free this object, it is owned by connection.

Glib::RefPtr<const Credentials> Gio::DBus::Connection::get_peer_credentials | ( |  | ) | const

Gets the credentials of the authenticated peer.

This will always return `nullptr` unless connection acted as a server (e.g. DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER was passed) when set up and the client passed credentials as part of the authentication process.

In a message bus setup, the message bus is always the server and each application is a client. So this method will always return `nullptr` for message bus clients.

Since glibmm 2.26:

Returns
  A Credentials or `nullptr` if not available. Do not free this object, it is owned by connection.

Glib::RefPtr<IOStream> Gio::DBus::Connection::get_stream | ( |  | ) |

Gets the underlying stream used for IO.

While the DBusConnection is active, it will interact with this stream from a worker thread, so it is not safe to interact with the stream directly.

Since glibmm 2.26:

Returns
  The stream used for IO.

Glib::RefPtr<const IOStream> Gio::DBus::Connection::get_stream | ( |  | ) | const

Gets the underlying stream used for IO.

While the DBusConnection is active, it will interact with this stream from a worker thread, so it is not safe to interact with the stream directly.

Since glibmm 2.26:

Returns
  The stream used for IO.

static Glib::RefPtr<Connection> Gio::DBus::Connection::get_sync | ( | BusType | bus_type,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

static

Synchronously connects to the message bus specified by bus_type.

Note that the returned object may shared with other callers, e.g. if two separate parts of a process calls this function with the same bus_type, they will share the same object.

This is a synchronous failable function. See g_bus_get() and g_bus_get_finish() for the asynchronous version.

The returned object is a singleton, that is, shared with other callers of g_bus_get() and g_bus_get_sync() for bus_type. In the event that you need a private message bus connection, use g_dbus_address_get_for_bus_sync() and g_dbus_connection_new_for_address().

Note that the returned DBusConnection object will (usually) have the DBusConnection::property_exit_on_close() property set to `true`.

Since glibmm 2.26:

Parameters

  bus_type | A BusType.
  cancellable | A Cancellable or `nullptr`.

Returns
  A DBusConnection or `nullptr` if error is set. Free with Glib::object_unref().

Exceptions

  Glib::Error |

static Glib::RefPtr<Connection> Gio::DBus::Connection::get_sync | ( | BusType | bus_type | ) |

static

A get_sync() convenience overload.

static GType Gio::DBus::Connection::get_type | ( |  | ) |

static

Get the GType for this class, for use with the underlying GObject type system.

Glib::ustring Gio::DBus::Connection::get_unique_name | ( |  | ) | const

Gets the unique name of connection as assigned by the message bus.

This can also be used to figure out if connection is a message bus connection.

Since glibmm 2.26:

Returns
  The unique name or `nullptr` if connection is not a message bus connection. Do not free this string, it is owned by connection.

GDBusConnection* Gio::DBus::Connection::gobj | ( |  | ) |

inline

Provides access to the underlying C GObject.

const GDBusConnection* Gio::DBus::Connection::gobj | ( |  | ) | const

inline

Provides access to the underlying C GObject.

GDBusConnection* Gio::DBus::Connection::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

bool Gio::DBus::Connection::is_closed | ( |  | ) | const

Gets whether connection is closed.

Since glibmm 2.26:

Returns
  `true` if the connection is closed, `false` otherwise.

Connection& Gio::DBus::Connection::operator= | ( | Connection&& | src | ) |

noexcept

Glib::PropertyProxy_ReadOnly< CapabilityFlags > Gio::DBus::Connection::property_capabilities | ( |  | ) | const

Flags from the DBusCapabilityFlags enumeration representing connection features negotiated with the other peer.

Since glibmm 2.26:

Default value: DBUS_CAPABILITY_FLAGS_NONE

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< bool > Gio::DBus::Connection::property_closed | ( |  | ) | const

A boolean specifying whether the connection has been closed.

Since glibmm 2.26:

Default value: `false`

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy< bool > Gio::DBus::Connection::property_exit_on_close | ( |  | ) |

A boolean specifying whether the process will be terminated (by calling `raise(SIGTERM)`) if the connection is closed by the remote peer.

Note that DBusConnection objects returned by g_bus_get_finish() and g_bus_get_sync() will (usually) have this property set to `true`.

Since glibmm 2.26:

Default value: `false`

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< bool > Gio::DBus::Connection::property_exit_on_close | ( |  | ) | const

A boolean specifying whether the process will be terminated (by calling `raise(SIGTERM)`) if the connection is closed by the remote peer.

Note that DBusConnection objects returned by g_bus_get_finish() and g_bus_get_sync() will (usually) have this property set to `true`.

Since glibmm 2.26:

Default value: `false`

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< ConnectionFlags > Gio::DBus::Connection::property_flags | ( |  | ) | const

Flags from the DBusConnectionFlags enumeration.

Since glibmm 2.60:

Default value: DBUS_CONNECTION_FLAGS_NONE

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< std::string > Gio::DBus::Connection::property_guid | ( |  | ) | const

The GUID of the peer performing the role of server when authenticating.

If you are constructing a DBusConnection and pass DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER in the DBusConnection::property_flags() property then you MUST also set this property to a valid guid.

If you are constructing a DBusConnection and pass DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT in the DBusConnection::property_flags() property you will be able to read the GUID of the other peer here after the connection has been successfully initialized.

Since glibmm 2.26:

Default value: ""

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< Glib::RefPtr<IOStream> > Gio::DBus::Connection::property_stream | ( |  | ) | const

The underlying IOStream used for I/O.

If this is passed on construction and is a SocketConnection, then the corresponding Socket will be put into non-blocking mode.

While the DBusConnection is active, it will interact with this stream from a worker thread, so it is not safe to interact with the stream directly.

Since glibmm 2.26:

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gio::DBus::Connection::property_unique_name | ( |  | ) | const

The unique name as assigned by the message bus or `nullptr` if the connection is not open or not a message bus connection.

Since glibmm 2.26:

Default value: ""

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

guint Gio::DBus::Connection::register_object | ( | const Glib::ustring& | object_path,
|  | const Glib::RefPtr< InterfaceInfo >& | interface_info,
|  | const InterfaceVTable& | vtable
| ) |  |

Registers slots for exported objects at object_path with the D-Bus interface that is described in interface_info.

Calls to slots in vtable will happen in the thread-default main loop of the thread you are calling this method from.

Note that all Glib::VariantBase values passed to functions in vtable will match the signature given in interface_info - if a remote caller passes incorrect values, the `org.freedesktop.DBus.Error.InvalidArgs` is returned to the remote caller.

Additionally, if the remote caller attempts to invoke methods or access properties not mentioned in interface_info the `org.freedesktop.DBus.Error.UnknownMethod` resp. `org.freedesktop.DBus.Error.InvalidArgs` errors are returned to the caller.

It is considered a programming error if the SlotDBusInterfaceGetProperty slot in vtable returns a Glib::VariantBase of incorrect type.

If an existing slot is already registered at object_path and interface_name, then a Glib::Error is thrown.

GDBus automatically implements the standard D-Bus interfaces org.freedesktop.DBus.Properties, org.freedesktop.DBus.Introspectable and org.freedesktop.Peer, so you don't have to implement those for the objects you export. You can implement org.freedesktop.DBus.Properties yourself, e.g. to handle getting and setting of properties asynchronously.

Parameters

  object_path | The object path to register at.
  interface_info | Introspection data for the interface.
  vtable | An InterfaceVTable to call into.

Returns
  A registration id (never 0) that can be used with unregister_object() if no Glib::Error is thrown.

Exceptions

  Glib::Error. |

Since glibmm 2.28:

guint Gio::DBus::Connection::register_object | ( | const Glib::ustring& | object_path,
|  | const Glib::RefPtr< InterfaceInfo >& | interface_info
| ) |  |

Registers exported objects at object_path with the D-Bus interface that is described in interface_info.

This method overload, which does not take a VTable, is useful for marker interfaces.

If an existing slot is already registered at object_path and interface_name, then a Glib::Error is thrown.

GDBus automatically implements the standard D-Bus interfaces org.freedesktop.DBus.Properties, org.freedesktop.DBus.Introspectable and org.freedesktop.Peer, so you don't have to implement those for the objects you export.

Parameters

  object_path | The object path to register at.
  interface_info | Introspection data for the interface.

Returns
  A registration id (never 0) that can be used with unregister_object() if no Glib::Error is thrown.

Exceptions

  Glib::Error. |

Since glibmm 2.28:

guint Gio::DBus::Connection::register_subtree | ( | const Glib::ustring& | object_path,
|  | const SubtreeVTable& | vtable,
|  | SubtreeFlags | flags = `Gio::DBus::SUBTREE_FLAGS_NONE`
| ) |  |

Registers a whole subtree of “dynamic” objects.

Copies of the enumerate and introspection slots usted to create vtable are used to convey, to remote callers, what nodes exist in the subtree rooted by object_path.

When handling remote calls into any node in the subtree, first the enumerate slot is used to check if the node exists. If the node exists or the Gio::DBus::SUBTREE_FLAGS_DISPATCH_TO_UNENUMERATED_NODES flag is set the introspection slot is used to check if the node supports the requested method. If so, the dispatch function is used to determine where to dispatch the call. The collected InterfaceVTable will be used to call into the interface vtable for processing the request.

All calls into user-provided code will be invoked in the thread-default main loop of the thread you are calling this method from.

If an existing subtree is already registered at object_path or then a Glib::Error is thrown.

Note that it is valid to register regular objects (using register_object()) in a subtree registered with register_subtree() - if so, the subtree handler is tried as the last resort. One way to think about a subtree handler is to consider it a “fallback handler” for object paths not registered via register_object().

Parameters

  object_path | The object path to register the subtree at.
  vtable | A SubtreeVTable to enumerate, introspect and dispatch nodes in the subtree.
  flags | Flags used to fine tune the behavior of the subtree.

Returns
  A subtree registration id (never 0) that can be used with unregister_subtree() if no Glib::Error is thrown.

Since glibmm 2.28:

void Gio::DBus::Connection::remove_filter | ( | guint | filter_id | ) |

Removes a filter.

Note that since filters run in a different thread, there is a race condition where it is possible that the filter will be running even after calling g_dbus_connection_remove_filter(), so you cannot just free data that the filter might be using. Instead, you should pass a DestroyNotify to g_dbus_connection_add_filter(), which will be called when it is guaranteed that the data is no longer needed.

Since glibmm 2.26:

Parameters

  filter_id | An identifier obtained from g_dbus_connection_add_filter().

bool Gio::DBus::Connection::send_message | ( | const Glib::RefPtr< Message >& | message,
|  | SendMessageFlags | flags,
|  | guint32 & | out_serial
| ) |  |

Asynchronously sends message to the peer represented by connection.

Unless flags contain the DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number will be assigned by connection and set on message via g_dbus_message_set_serial(). If out_serial is not `nullptr`, then the serial number used will be written to this location prior to submitting the message to the underlying transport.

If connection is closed then the operation will fail with IO_ERROR_CLOSED. If message is not well-formed, the operation fails with IO_ERROR_INVALID_ARGUMENT.

See this [server][gdbus-server] and [client][gdbus-unix-fd-client] for an example of how to use this low-level API to send and receive UNIX file descriptors.

Note that message must be unlocked, unless flags contain the DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag.

Since glibmm 2.26:

Parameters

  message | A DBusMessage.
  flags | Flags affecting how the message is sent.
  out_serial | Return location for serial number assigned to message when sending it or `nullptr`.

Returns
  `true` if the message was well-formed and queued for transmission, `false` if error is set.

Exceptions

  Glib::Error |

bool Gio::DBus::Connection::send_message | ( | const Glib::RefPtr< Message >& | message,
|  | SendMessageFlags | flags = `Gio::DBus::SEND_MESSAGE_FLAGS_NONE`
| ) |  |

A send_message() without an "out_serial" parameter.

void Gio::DBus::Connection::send_message_with_reply | ( | const Glib::RefPtr< Message >& | message,
|  | int | timeout_msec,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Asynchronously sends message to the peer represented by the connection.

Unless flags contain the Gio::DBus::SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number will be assigned by the connection and set on message via Gio::DBus::Message::set_serial().

If the connection is closed then the operation will fail with Gio::IO_ERROR_CLOSED. If cancellable is canceled, the operation will fail with Gio::IO_ERROR_CANCELLED. If message is not well-formed, the operation fails with Gio::IO_ERROR_INVALID_ARGUMENT.

This is an asynchronous method. When the operation is finished, slot will be invoked in the thread-default main loop of the thread you are calling this method from. You can then call send_message_with_reply_finish() to get the result of the operation. See send_message_with_reply_sync() for the synchronous version.

Note that message must be unlocked, unless flags contain the Gio::DBus::SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag.

See the C API docs for examples.

Parameters

  message | A Message.
  timeout_msec | The timeout in milliseconds or -1 to use the default timeout.
  slot | A SlotAsyncReady to call when the request is satisfied.
  cancellable | A Cancellable.

Since glibmm 2.28:

void Gio::DBus::Connection::send_message_with_reply | ( | const Glib::RefPtr< Message >& | message,
|  | int | timeout_msec,
|  | const SlotAsyncReady& | slot
| ) |  |

Non-cancellable version of send_message_with_reply().

Glib::RefPtr<Message> Gio::DBus::Connection::send_message_with_reply_finish | ( | const Glib::RefPtr< AsyncResult >& | res | ) |

Finishes an operation started with g_dbus_connection_send_message_with_reply().

Note that error is only set if a local in-process error occurred. That is to say that the returned DBusMessage object may be of type DBUS_MESSAGE_TYPE_ERROR. Use g_dbus_message_to_gerror() to transcode this to a Error.

See this [server][gdbus-server] and [client][gdbus-unix-fd-client] for an example of how to use this low-level API to send and receive UNIX file descriptors.

Since glibmm 2.26:

Parameters

  res | A AsyncResult obtained from the SlotAsyncReady passed to g_dbus_connection_send_message_with_reply().

Returns
  A locked DBusMessage or `nullptr` if error is set.

Exceptions

  Glib::Error. |

Glib::RefPtr<Message> Gio::DBus::Connection::send_message_with_reply_sync | ( | const Glib::RefPtr< Message >& | message,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | gint | timeout_msec
| ) |  |

Synchronously sends message to the peer represented by the connection and blocks the calling thread until a reply is received or the timeout is reached.

See send_message_with_reply() for the asynchronous version of this method.

Unless flags contain the Gio::DBus::SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag, the serial number will be assigned by the connection and set on message via Gio::DBus::Message::set_serial().

If the connection is closed then the operation will fail with Gio::IO_ERROR_CLOSED. If cancellable is canceled, the operation will fail with Gio::IO_ERROR_CANCELLED. If message is not well-formed, the operation fails with Gio::IO_ERROR_INVALID_ARGUMENT.

Note that a Glib::Error is thrown if a local in-process error occured. That is to say that the returned Message object may be of type G_DBUS_MESSAGE_TYPE_ERROR. Use Gio::DBus::Message::to_exception() to transcode this to a Glib::Error.

See the C API docs for examples.

Note that message must be unlocked, unless flags contain the Gio::DBus::SEND_MESSAGE_FLAGS_PRESERVE_SERIAL flag.

Parameters

  message | A Message.
  cancellable | A Cancellable.
  timeout_msec | The timeout in milliseconds or -1 to use the default timeout.

Returns
  A locked Message that is the reply to message or `0` if a Glib::Error is thrown.

Exceptions

  Glib::Error. |

Since glibmm 2.28:

Glib::RefPtr<Message> Gio::DBus::Connection::send_message_with_reply_sync | ( | const Glib::RefPtr< Message >& | message,
|  | gint | timeout_msec
| ) |  |

A non-cancellable version of send_message_with_reply_sync().

void Gio::DBus::Connection::set_exit_on_close | ( | bool | exit_on_close = `true` | ) |

Sets whether the process should be terminated when connection is closed by the remote peer.

See DBusConnection::property_exit_on_close() for more details.

Note that this function should be used with care. Most modern UNIX desktops tie the notion of a user session with the session bus, and expect all of a user's applications to quit when their bus connection goes away. If you are setting exit_on_close to `false` for the shared session bus connection, you should make sure that your application exits when the user session ends.

Since glibmm 2.26:

Parameters

  exit_on_close | Whether the process should be terminated when connection is closed by the remote peer.

Glib::SignalProxy< void,bool,const Glib::Error& > Gio::DBus::Connection::signal_closed | ( |  | ) |

Slot Prototype:
  `void on_my_closed(bool remote_peer_vanished, const Glib::Error& error)`

Flags: Run Last

Emitted when the connection is closed.

The cause of this event can be

- If g_dbus_connection_close() is called. In this case remote_peer_vanished is set to `false` and error is `nullptr`.
- If the remote peer closes the connection. In this case remote_peer_vanished is set to `true` and error is set.
- If the remote peer sends invalid or malformed data. In this case remote_peer_vanished is set to `false` and error is set.

Upon receiving this signal, you should give up your reference to connection. You are guaranteed that this signal is emitted only once.

Since glibmm 2.26:

Parameters

  remote_peer_vanished | `true` if connection is closed because the remote peer closed its end of the connection.

guint Gio::DBus::Connection::signal_subscribe | ( | const SlotSignal& | slot,
|  | const Glib::ustring& | sender = `Glib::ustring()`,
|  | const Glib::ustring& | interface_name = `Glib::ustring()`,
|  | const Glib::ustring& | member = `Glib::ustring()`,
|  | const Glib::ustring& | object_path = `Glib::ustring()`,
|  | const Glib::ustring& | arg0 = `Glib::ustring()`,
|  | SignalFlags | flags = `Gio::DBus::SIGNAL_FLAGS_NONE`
| ) |  |

Subscribes to signals on the connection and invokes slot with a whenever the signal is received.

Note that slot will be invoked in the thread-default main loop of the thread you are calling this method from.

If the connection is not a message bus connection, sender must be `0`.

If sender is a well-known name note that slot is invoked with the unique name for the owner of sender, not the well-known name as one would expect. This is because the message bus rewrites the name. As such, to avoid certain race conditions, users should be tracking the name owner of the well-known name and use that when processing the received signal.

Parameters

  slot | Slot to invoke when there is a signal matching the requested data.
  sender | Sender name to match on (unique or well-known name) or `0` to listen from all senders.
  interface_name | D-Bus interface name to match on or `0` to match on all interfaces.
  member | D-Bus signal name to match on or `0` to match on all signals.
  object_path | Object path to match on or `0` to match on all object paths.
  arg0 | Contents of first string argument to match on or `0` to match on all kinds of arguments.
  flags | Flags describing how to subscribe to the signal (currently unused).

Returns
  A subscription identifier that can be used with signal_unsubscribe().

Since glibmm 2.28:

void Gio::DBus::Connection::signal_unsubscribe | ( | guint | subscription_id | ) |

Unsubscribes from signals.

Since glibmm 2.26:

Parameters

  subscription_id | A subscription id obtained from g_dbus_connection_signal_subscribe().

void Gio::DBus::Connection::start_message_processing | ( |  | ) |

If connection was created with DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING, this method starts processing messages.

Does nothing on if connection wasn't created with this flag or if the method has already been called.

Since glibmm 2.26:

void Gio::DBus::Connection::unexport_action_group | ( | guint | export_id | ) |

Reverses the effect of a previous call to g_dbus_connection_export_action_group().

It is an error to call this function with an ID that wasn't returned from g_dbus_connection_export_action_group() or to call it with the same ID more than once.

Since glibmm 2.32:

Parameters

  export_id | The ID from g_dbus_connection_export_action_group().

void Gio::DBus::Connection::unexport_menu_model | ( | guint | export_id | ) |

Reverses the effect of a previous call to g_dbus_connection_export_menu_model().

It is an error to call this function with an ID that wasn't returned from g_dbus_connection_export_menu_model() or to call it with the same ID more than once.

Since glibmm 2.32:

Parameters

  export_id | The ID from g_dbus_connection_export_menu_model().

bool Gio::DBus::Connection::unregister_object | ( | guint | registration_id | ) |

Unregisters an object.

Since glibmm 2.26:

Parameters

  registration_id | A registration id obtained from g_dbus_connection_register_object().

Returns
  `true` if the object was unregistered, `false` otherwise.

bool Gio::DBus::Connection::unregister_subtree | ( | guint | registration_id | ) |

Unregisters a subtree.

Since glibmm 2.26:

Parameters

  registration_id | A subtree registration id obtained from g_dbus_connection_register_subtree().

Returns
  `true` if the subtree was unregistered, `false` otherwise.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::DBus::Connection > wrap | ( | GDBusConnection * | object,
|  | bool | take_copy = `false`
| ) |  |

related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.