class Gio::DBusObjectManagerClient

Overview

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

Once an instance of this type has been created, you can connect to the #GDBusObjectManager::object-added and #GDBusObjectManager::object-removed signals and inspect the #GDBusObjectProxy objects returned by g_dbus_object_manager_get_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. g_dbus_object_manager_get_objects() returns the empty list) and the #GDBusObjectManagerClient:name-owner property is nil.

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::notify signal to watch for changes on the #GDBusObjectManagerClient:name-owner property. When the name owner vanishes, the behavior is that #GDBusObjectManagerClient:name-owner is set to nil (this includes emission of the #GObject::notify signal) and then #GDBusObjectManager::object-removed signals are synthesized for all currently existing object proxies. Since #GDBusObjectManagerClient:name-owner is nil when this happens, you can use this information to disambiguate a synthesized signal from a genuine signal caused by object removal on the remote #GDBusObjectManager. Similarly, when a new name owner appears, #GDBusObjectManager::object-added signals are synthesized while #GDBusObjectManagerClient:name-owner is still nil. Only when all object proxies have been added, the #GDBusObjectManagerClient:name-owner is set to the new name owner (this includes emission of the #GObject::notify signal). Furthermore, you are guaranteed that #GDBusObjectManagerClient:name-owner will alternate between a name owner (e.g. :1.42) and nil even in the case where the name of interest is atomically replaced

Ultimately, #GDBusObjectManagerClient is used to obtain #GDBusProxy instances. All signals (including the org.freedesktop.DBus.Properties::PropertiesChanged signal) delivered to #GDBusProxy 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 #GDBusObjectProxy and #GDBusProxy objects, the #GDBusObject::interface-added, #GDBusObject::interface-removed, #GDBusProxy::g-properties-changed and #GDBusProxy::g-signal signals are also emitted on the #GDBusObjectManagerClient instance managing these objects. The signals emitted are #GDBusObjectManager::interface-added, #GDBusObjectManager::interface-removed, #GDBusObjectManagerClient::interface-proxy-properties-changed and #GDBusObjectManagerClient::interface-proxy-signal.

Note that all callbacks and signals are emitted in the [thread-default main context][g-main-context-push-thread-default] that the #GDBusObjectManagerClient object was constructed in. Additionally, the #GDBusObjectProxy and #GDBusProxy 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, user_data : Pointer(Void) | Nil) : 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, user_data : Pointer(Void) | Nil) : 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(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, user_data : Pointer(Void) | Nil) : 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][g-main-context-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.


[View source]
def self.new #

Initialize a new DBusObjectManagerClient.


[View source]
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) #

[View source]
def self.new_finish(res : Gio::AsyncResult) : self #

Finishes an operation started with g_dbus_object_manager_client_new().


[View source]
def self.new_for_bus_finish(res : Gio::AsyncResult) : self #

Finishes an operation started with g_dbus_object_manager_client_new_for_bus().


[View source]
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.


[View source]
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.


[View source]

Class Method Detail

def self.g_type : UInt64 #

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


[View source]
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, user_data : Pointer(Void) | Nil) : 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 loop][g-main-context-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.


[View source]

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 #

[View source]
def connection : Gio::DBusConnection #

Gets the #GDBusConnection used by manager.


[View source]
def connection=(value : Gio::DBusConnection | Nil) : Gio::DBusConnection | Nil #

[View source]

Gets the flags that manager was constructed with.


[View source]

[View source]
def get_proxy_type_destroy_notify : Pointer(Void) #

[View source]
def get_proxy_type_destroy_notify=(value : Pointer(Void)) : Pointer(Void) #

[View source]
def get_proxy_type_func : Pointer(Void) #

[View source]
def get_proxy_type_func=(value : Pointer(Void)) : Pointer(Void) #

[View source]
def get_proxy_type_user_data : Pointer(Void) #

[View source]
def get_proxy_type_user_data=(value : Pointer(Void)) : Pointer(Void) #

[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def interface_proxy_properties_changed_signal #

[View source]
def interface_proxy_signal_signal #

[View source]
def name : String #

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


[View source]
def name=(value : String) : String #

[View source]
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.


[View source]
def object_path : String #

[View source]
def object_path=(value : String) : String #

[View source]