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 %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::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 %NULL (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 %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 #GDBusObjectManager. Similarly, when a new name owner appears, #GDBusObjectManager::object-added signals are synthesized while #GDBusObjectManagerClient:name-owner is still %NULL. 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 %NULL 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?) : Bool init, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter), cancellable : Gio::Cancellable?) : GObject::Object newv, to_unsafe to_unsafe

Class methods inherited from module Gio::Initable

g_type : UInt64 g_type

Instance methods inherited from module Gio::DBusObjectManager

interface(object_path : String, interface_name : String) : Gio::DBusInterface? interface, interface_added_signal interface_added_signal, interface_removed_signal interface_removed_signal, object(object_path : String) : Gio::DBusObject? 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

Class methods inherited from module Gio::DBusObjectManager

g_type : UInt64 g_type

Instance methods inherited from module Gio::AsyncInitable

init_async(io_priority : Int32, cancellable : Gio::Cancellable?, callback : Gio::AsyncReadyCallback?, user_data : Pointer(Void)?) : Nil init_async, init_finish(res : Gio::AsyncResult) : Bool init_finish, new_finish(res : Gio::AsyncResult) : GObject::Object new_finish, to_unsafe to_unsafe

Class methods inherited from module Gio::AsyncInitable

g_type : UInt64 g_type, newv_async(object_type : UInt64, n_parameters : UInt32, parameters : GObject::Parameter, io_priority : Int32, cancellable : Gio::Cancellable?, callback : Gio::AsyncReadyCallback?, user_data : Pointer(Void)?) : Nil newv_async

Instance methods inherited from class GObject::Object

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)? data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, 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)? qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void)?) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void)? steal_data, steal_qdata(quark : UInt32) : Pointer(Void)? 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, cast?(obj : GObject::Object) : self? cast?, new(pointer, transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

compat_control(what : UInt64, data : Pointer(Void)?) : 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

Constructor Detail

def self.new(connection : Gio::DBusConnection, flags : Gio::DBusObjectManagerClientFlags, name : String, object_path : String, get_proxy_type_func : Gio::DBusProxyTypeFunc?, get_proxy_type_user_data : Pointer(Void)?, get_proxy_type_destroy_notify : GLib::DestroyNotify?, cancellable : Gio::Cancellable?, callback : Gio::AsyncReadyCallback?, user_data : Pointer(Void)?) : 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.


def self.new #

Initialize a new DBusObjectManagerClient.


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

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?, get_proxy_type_user_data : Pointer(Void)?, get_proxy_type_destroy_notify : GLib::DestroyNotify?, cancellable : Gio::Cancellable?) : 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?, object_path : String, get_proxy_type_func : Gio::DBusProxyTypeFunc?, get_proxy_type_user_data : Pointer(Void)?, get_proxy_type_destroy_notify : GLib::DestroyNotify?, cancellable : Gio::Cancellable?) : 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?, get_proxy_type_user_data : Pointer(Void)?, get_proxy_type_destroy_notify : GLib::DestroyNotify?, cancellable : Gio::Cancellable?, callback : Gio::AsyncReadyCallback?, user_data : Pointer(Void)?) : 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.


Instance Method Detail

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

def connection : Gio::DBusConnection #

Gets the #GDBusConnection used by @manager.


def connection=(value : Gio::DBusConnection?) : Gio::DBusConnection? #

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 interface_proxy_properties_changed_signal #

def interface_proxy_signal_signal #

def name : String #

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


def name=(value : String) : String #

def name_owner : String? #

The unique name that owns the name that @manager is for or %NULL 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 object_path : String #

def object_path=(value : String) : String #