class Gio::DBusObjectManagerClient

Overview

GDBusObjectManagerClient is used to create, monitor and delete object proxies for remote objects exported by a Gio::DBusObjectManagerServer (or any code implementing the org.freedesktop.DBus.ObjectManager interface).

Once an instance of this type has been created, you can connect to the [signal@Gio.DBusObjectManager::object-added] and [signal@Gio.DBusObjectManager::object-removed signals] and inspect the Gio::DBusObjectProxy objects returned by Gio::DBusObjectManager#objects.

If the name for a GDBusObjectManagerClient is not owned by anyone at object construction time, the default behavior is to request the message bus to launch an owner for the name. This behavior can be disabled using the G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START flag. It’s also worth noting that this only works if the name of interest is activatable in the first place. E.g. in some cases it is not possible to launch an owner for the requested name. In this case, GDBusObjectManagerClient object construction still succeeds but there will be no object proxies (e.g. Gio::DBusObjectManager#objects returns the empty list) and the [property@Gio.DBusObjectManagerClient:name-owner] property is NULL.

The owner of the requested name can come and go (for example consider a system service being restarted) – GDBusObjectManagerClient handles this case too; simply connect to the GObject::Object::#notify signal to watch for changes on the [property@Gio.DBusObjectManagerClient:name-owner] property. When the name owner vanishes, the behavior is that [property@Gio.DBusObjectManagerClient:name-owner] is set to NULL (this includes emission of the GObject::Object::#notify signal) and then [signal@Gio.DBusObjectManager::object-removed] signals are synthesized for all currently existing object proxies. Since [property@Gio.DBusObjectManagerClient:name-owner] is NULL when this happens, you can use this information to disambiguate a synthesized signal from a genuine signal caused by object removal on the remote Gio::DBusObjectManager. Similarly, when a new name owner appears, [signal@Gio.DBusObjectManager::object-added] signals are synthesized while [property@Gio.DBusObjectManagerClient:name-owner] is still NULL. Only when all object proxies have been added, the [property@Gio.DBusObjectManagerClient:name-owner] is set to the new name owner (this includes emission of the GObject::Object::#notify signal). Furthermore, you are guaranteed that [property@Gio.DBusObjectManagerClient:name-owner] will alternate between a name owner (e.g. :1.42) and NULL even in the case where the name of interest is atomically replaced

Ultimately, GDBusObjectManagerClient is used to obtain Gio::DBusProxy instances. All signals (including the org.freedesktop.DBus.Properties::PropertiesChanged signal) delivered to Gio::DBusProxy instances are guaranteed to originate from the name owner. This guarantee along with the behavior described above, means that certain race conditions including the “half the proxy is from the old owner and the other half is from the new owner” problem cannot happen.

To avoid having the application connect to signals on the returned Gio::DBusObjectProxy and Gio::DBusProxy objects, the [signal@Gio.DBusObject::interface-added], [signal@Gio.DBusObject::interface-removed], [signal@Gio.DBusProxy::g-properties-changed] and [signal@Gio.DBusProxy::g-signal] signals are also emitted on the GDBusObjectManagerClient instance managing these objects. The signals emitted are [signal@Gio.DBusObjectManager::interface-added], [signal@Gio.DBusObjectManager::interface-removed], [signal@Gio.DBusObjectManagerClient::interface-proxy-properties-changed] and [signal@Gio.DBusObjectManagerClient::interface-proxy-signal].

Note that all callbacks and signals are emitted in the thread-default main context (see GLib::MainContext#push_thread_default) that the GDBusObjectManagerClient object was constructed in. Additionally, the Gio::DBusObjectProxy and Gio::DBusProxy objects originating from the GDBusObjectManagerClient object will be created in the same context and, consequently, will deliver signals in the same main loop.

Included Modules

Defined in:

lib/gi-crystal/src/auto/gio-2.0/d_bus_object_manager_client.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Gio::Initable

init(cancellable : Gio::Cancellable | Nil) : Bool init, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter), cancellable : Gio::Cancellable | Nil) : GObject::Object newv, to_unsafe to_unsafe

Constructor methods inherited from module Gio::Initable

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gio::Initable

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gio::DBusObjectManager

interface(object_path : String, interface_name : String) : Gio::DBusInterface | Nil interface, interface_added_signal interface_added_signal, interface_removed_signal interface_removed_signal, object(object_path : String) : Gio::DBusObject | Nil object, object_added_signal object_added_signal, object_path : String object_path, object_removed_signal object_removed_signal, objects : GLib::List objects, to_unsafe to_unsafe

Constructor methods inherited from module Gio::DBusObjectManager

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gio::DBusObjectManager

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gio::AsyncInitable

init_async(io_priority : Int32, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : Nil init_async, init_finish(res : Gio::AsyncResult) : Bool init_finish, new_finish(res : Gio::AsyncResult) : GObject::Object new_finish, to_unsafe to_unsafe

Constructor methods inherited from module Gio::AsyncInitable

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gio::AsyncInitable

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type, newv_async(object_type : UInt64, n_parameters : UInt32, parameters : GObject::Parameter, io_priority : Int32, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : Nil newv_async

Instance methods inherited from class GObject::Object

==(other : self) ==, bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

Constructor Detail

def self.new #

Initialize a new DBusObjectManagerClient.


def self.new(*, bus_type : Gio::BusType | Nil = nil, connection : Gio::DBusConnection | Nil = nil, flags : Gio::DBusObjectManagerClientFlags | Nil = nil, get_proxy_type_destroy_notify : Pointer(Void) | Nil = nil, get_proxy_type_func : Pointer(Void) | Nil = nil, get_proxy_type_user_data : Pointer(Void) | Nil = nil, name : String | Nil = nil, name_owner : String | Nil = nil, object_path : String | Nil = nil) #

def self.new(connection : Gio::DBusConnection, flags : Gio::DBusObjectManagerClientFlags, name : String, object_path : String, get_proxy_type_func : Gio::DBusProxyTypeFunc | Nil, get_proxy_type_user_data : Pointer(Void) | Nil, get_proxy_type_destroy_notify : GLib::DestroyNotify | Nil, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : Nil #

Asynchronously creates a new #GDBusObjectManagerClient object.

This is an asynchronous failable constructor. When the result is ready, callback will be invoked in the thread-default main context (see GLib::MainContext#push_thread_default) of the thread you are calling this method from. You can then call g_dbus_object_manager_client_new_finish() to get the result. See g_dbus_object_manager_client_new_sync() for the synchronous version.


def self.new_finish(res : Gio::AsyncResult) : self #

Finishes an operation started with g_dbus_object_manager_client_new().


def self.new_for_bus_finish(res : Gio::AsyncResult) : self #

Finishes an operation started with g_dbus_object_manager_client_new_for_bus().


def self.new_for_bus_sync(bus_type : Gio::BusType, flags : Gio::DBusObjectManagerClientFlags, name : String, object_path : String, get_proxy_type_func : Gio::DBusProxyTypeFunc | Nil, get_proxy_type_user_data : Pointer(Void) | Nil, get_proxy_type_destroy_notify : GLib::DestroyNotify | Nil, cancellable : Gio::Cancellable | Nil) : self #

Like g_dbus_object_manager_client_new_sync() but takes a #GBusType instead of a #GDBusConnection.

This is a synchronous failable constructor - the calling thread is blocked until a reply is received. See g_dbus_object_manager_client_new_for_bus() for the asynchronous version.


def self.new_sync(connection : Gio::DBusConnection, flags : Gio::DBusObjectManagerClientFlags, name : String | Nil, object_path : String, get_proxy_type_func : Gio::DBusProxyTypeFunc | Nil, get_proxy_type_user_data : Pointer(Void) | Nil, get_proxy_type_destroy_notify : GLib::DestroyNotify | Nil, cancellable : Gio::Cancellable | Nil) : self #

Creates a new #GDBusObjectManagerClient object.

This is a synchronous failable constructor - the calling thread is blocked until a reply is received. See g_dbus_object_manager_client_new() for the asynchronous version.


Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


def self.new_for_bus(bus_type : Gio::BusType, flags : Gio::DBusObjectManagerClientFlags, name : String, object_path : String, get_proxy_type_func : Gio::DBusProxyTypeFunc | Nil, get_proxy_type_user_data : Pointer(Void) | Nil, get_proxy_type_destroy_notify : GLib::DestroyNotify | Nil, cancellable : Gio::Cancellable | Nil, &callback : Gio::AsyncReadyCallback) : Nil #

Like g_dbus_object_manager_client_new() but takes a #GBusType instead of a #GDBusConnection.

This is an asynchronous failable constructor. When the result is ready, callback will be invoked in the thread-default main context (see GLib::MainContext#push_thread_default) of the thread you are calling this method from. You can then call g_dbus_object_manager_client_new_for_bus_finish() to get the result. See g_dbus_object_manager_client_new_for_bus_sync() for the synchronous version.


Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def bus_type=(value : Gio::BusType) : Gio::BusType #

def connection : Gio::DBusConnection #

Gets the #GDBusConnection used by manager.


def connection=(value : Gio::DBusConnection | Nil) : Gio::DBusConnection | Nil #

Gets the flags that manager was constructed with.



def get_proxy_type_destroy_notify : Pointer(Void) #

def get_proxy_type_destroy_notify=(value : Pointer(Void)) : Pointer(Void) #

def get_proxy_type_func : Pointer(Void) #

def get_proxy_type_func=(value : Pointer(Void)) : Pointer(Void) #

def get_proxy_type_user_data : Pointer(Void) #

def get_proxy_type_user_data=(value : Pointer(Void)) : Pointer(Void) #

def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def interface_proxy_properties_changed_signal #

def interface_proxy_signal_signal #

def name : String #

Gets the name that manager is for, or nil if not a message bus connection.


def name=(value : String) : String #

def name=(value : Nil) : Nil #

Set #name property to nil.


def name? : String | Nil #

Same as #name, but can return nil.


def name_owner : String | Nil #

The unique name that owns the name that manager is for or nil if no-one currently owns that name. You can connect to the #GObject::notify signal to track changes to the #GDBusObjectManagerClient:name-owner property.


def name_owner? : String | Nil #

Same as #name_owner, but can return nil.


def object_path : String #

def object_path=(value : String) : String #

def object_path=(value : Nil) : Nil #

Set #object_path property to nil.


def object_path? : String | Nil #

Same as #object_path, but can return nil.