glibmm  2.66.1
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gio::DBus::Connection Class Reference

A D-Bus Connection. More...

#include <giomm/dbusconnection.h>

Inheritance diagram for Gio::DBus::Connection:
Inheritance graph
[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 Member Functions

 Connection (Connection&& src) noexcept
 
Connectionoperator= (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< Messagesend_message_with_reply_finish (const Glib::RefPtr< AsyncResult >& res)
 Finishes an operation started with g_dbus_connection_send_message_with_reply(). More...
 
Glib::RefPtr< Messagesend_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< Messagesend_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< IOStreamget_stream ()
 Gets the underlying stream used for IO. More...
 
Glib::RefPtr< const IOStreamget_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< Credentialsget_peer_credentials ()
 Gets the credentials of the authenticated peer. More...
 
Glib::RefPtr< const Credentialsget_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< CapabilityFlagsproperty_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< ConnectionFlagsproperty_flags () const
 Flags from the DBusConnectionFlags enumeration. More...
 
Glib::PropertyProxy_ReadOnly< std::stringproperty_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::ustringproperty_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
 
Objectoperator= (const Object&)=delete
 
 Object (Object&& src) noexcept
 
Objectoperator= (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
 
ObjectBaseoperator= (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 Gio::Initable
 Initable (Initable&& src) noexcept
 
Initableoperator= (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
 
Interfaceoperator= (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
 
Interfaceoperator= (const Interface&)=delete
 
GObject* gobj ()
 
const GObject* gobj () const
 
- Public Member Functions inherited from Gio::AsyncInitable
 AsyncInitable (AsyncInitable&& src) noexcept
 
AsyncInitableoperator= (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< Connectionget_finish (const Glib::RefPtr< AsyncResult >& res)
 Finishes an operation started with g_bus_get(). More...
 
static Glib::RefPtr< Connectionget_sync (BusType bus_type, const Glib::RefPtr< Cancellable >& cancellable)
 Synchronously connects to the message bus specified by bus_type. More...
 
static Glib::RefPtr< Connectionget_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< Connectioncreate_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< Connectioncreate_for_address_finish (const Glib::RefPtr< AsyncResult >& res)
 Finishes an operation started with g_dbus_connection_new_for_address(). More...
 
static Glib::RefPtr< Connectioncreate_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< Connectioncreate_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< Connectioncreate_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< Connectioncreate_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< Connectioncreate_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< Connectioncreate_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< Connectioncreate_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< Connectioncreate_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
 
ObjectBaseoperator= (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::Objectcreate_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::Connectionwrap (GDBusConnection* 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

◆ SlotMessageFilter

Signature for slot used in add_filter().

For example,

Glib::RefPtr<Message> on_message_filter(const
message, bool incoming);.
RefPtr<> is a reference-counting shared smartpointer.
Definition: refptr.h:52

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.

◆ SlotSignal

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);.
The base class for multiple-item Variants, such as Variants containing tuples or arrays,...
Definition: variant.h:763
Glib::ustring has much the same interface as std::string, but contains Unicode characters encoded as ...
Definition: ustring.h:319

Constructor & Destructor Documentation

◆ Connection() [1/17]

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

◆ ~Connection()

Gio::DBus::Connection::~Connection ( )
overridenoexcept

◆ Connection() [2/17]

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

◆ Connection() [3/17]

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

◆ Connection() [4/17]

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

◆ Connection() [5/17]

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

◆ Connection() [6/17]

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

◆ Connection() [7/17]

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

◆ Connection() [8/17]

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

◆ Connection() [9/17]

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

◆ Connection() [10/17]

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

◆ Connection() [11/17]

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

◆ Connection() [12/17]

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

◆ Connection() [13/17]

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

◆ Connection() [14/17]

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

◆ Connection() [15/17]

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

◆ Connection() [16/17]

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

◆ Connection() [17/17]

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

Member Function Documentation

◆ add_filter()

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
slotA filter slot.
Returns
A filter identifier that can be used with remove_filter().
Since glibmm 2.28:

◆ call() [1/4]

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::Variant