Class: Gio::DBusProxy
- Inherits:
-
Object
- Object
- Gio::DBusProxy
- Defined in:
- (unknown)
Overview
Class structure for GDBus::Proxy.
Instance Method Summary collapse
-
#cached_property_names ⇒ Array<String>
Gets the names of all cached properties on proxy.
-
#call(method_name, parameters, flags, timeout_msec, cancellable, callback, user_data) ⇒ nil
Asynchronously invokes the method_name method on proxy.
-
#call_finish(res) ⇒ GLib::Variant
Finishes an operation started with g_dbus_proxy_call().
-
#call_sync(method_name, parameters, flags, timeout_msec, cancellable) ⇒ GLib::Variant
Synchronously invokes the method_name method on proxy.
-
#call_with_unix_fd_list(method_name, parameters, flags, timeout_msec, fd_list, cancellable, callback, user_data) ⇒ nil
Like g_dbus_proxy_call() but also takes a GUnix::FDList object.
-
#call_with_unix_fd_list_finish(out_fd_list, res) ⇒ GLib::Variant
Finishes an operation started with g_dbus_proxy_call_with_unix_fd_list().
-
#call_with_unix_fd_list_sync(method_name, parameters, flags, timeout_msec, fd_list, out_fd_list, cancellable) ⇒ GLib::Variant
Like g_dbus_proxy_call_sync() but also takes and returns GUnix::FDList objects.
-
#connection ⇒ Gio::DBusConnection
Gets the connection proxy is for.
-
#default_timeout ⇒ Integer
Gets the timeout to use if -1 (specifying default timeout) is passed as timeout_msec in the g_dbus_proxy_call() and g_dbus_proxy_call_sync() functions.
-
#default_timeout=(timeout_msec) ⇒ nil
Sets the timeout to use if -1 (specifying default timeout) is passed as timeout_msec in the g_dbus_proxy_call() and g_dbus_proxy_call_sync() functions.
-
#flags ⇒ Gio::DBusProxyFlags
Gets the flags that proxy was constructed with.
-
#g_bus_type=(g_bus_type) ⇒ Gio::BusType
If this property is not %G_BUS_TYPE_NONE, then GDBus::Proxy:g-connection must be nil and will be set to the GDBus::Connection obtained by calling g_bus_get() with the value of this property.
-
#g_connection ⇒ Gio::DBusConnection
The GDBus::Connection the proxy is for.
-
#g_connection=(g_connection) ⇒ Gio::DBusConnection
The GDBus::Connection the proxy is for.
-
#g_default_timeout ⇒ Integer
The timeout to use if -1 (specifying default timeout) is passed as timeout_msec in the g_dbus_proxy_call() and g_dbus_proxy_call_sync() functions.
-
#g_default_timeout=(g_default_timeout) ⇒ Integer
The timeout to use if -1 (specifying default timeout) is passed as timeout_msec in the g_dbus_proxy_call() and g_dbus_proxy_call_sync() functions.
-
#g_flags ⇒ Gio::DBusProxyFlags
Flags from the GDBus::ProxyFlags enumeration.
-
#g_flags=(g_flags) ⇒ Gio::DBusProxyFlags
Flags from the GDBus::ProxyFlags enumeration.
-
#g_interface_info ⇒ Gio::DBusInterfaceInfo
Ensure that interactions with this proxy conform to the given interface.
-
#g_interface_info=(g_interface_info) ⇒ Gio::DBusInterfaceInfo
Ensure that interactions with this proxy conform to the given interface.
-
#g_interface_name ⇒ String
The D-Bus interface name the proxy is for.
-
#g_interface_name=(g_interface_name) ⇒ String
The D-Bus interface name the proxy is for.
-
#g_name ⇒ String
The well-known or unique name that the proxy is for.
-
#g_name=(g_name) ⇒ String
The well-known or unique name that the proxy is for.
-
#g_name_owner ⇒ String
The unique name that owns GDBus::Proxy:g-name or nil if no-one currently owns that name.
-
#g_name_owner=(g_name_owner) ⇒ String
The unique name that owns GDBus::Proxy:g-name or nil if no-one currently owns that name.
-
#g_object_path ⇒ String
The object path the proxy is for.
-
#g_object_path=(g_object_path) ⇒ String
The object path the proxy is for.
-
#get_cached_property(property_name) ⇒ GLib::Variant
Looks up the value for a property from the cache.
-
#interface_info ⇒ Gio::DBusInterfaceInfo
Returns the GDBus::InterfaceInfo, if any, specifying the interface that proxy conforms to.
-
#interface_info=(info) ⇒ nil
Ensure that interactions with proxy conform to the given interface.
-
#interface_name ⇒ String
Gets the D-Bus interface name proxy is for.
-
#name ⇒ String
Gets the name that proxy was constructed for.
-
#name_owner ⇒ String
The unique name that owns the name that proxy is for or nil if no-one currently owns that name.
-
#new_finish(res) ⇒ Gio::DBusProxy
Finishes creating a GDBus::Proxy.
-
#new_for_bus_finish(res) ⇒ Gio::DBusProxy
Finishes creating a GDBus::Proxy.
-
#new_for_bus_sync(bus_type, flags, info, name, object_path, interface_name, cancellable) ⇒ Gio::DBusProxy
Like g_dbus_proxy_new_sync() but takes a GBus::Type instead of a #GDBusConnection.
-
#new_sync(connection, flags, info, name, object_path, interface_name, cancellable) ⇒ Gio::DBusProxy
Creates a proxy for accessing interface_name on the remote object at object_path owned by name at connection and synchronously loads D-Bus properties unless the %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used.
-
#object_path ⇒ String
Gets the object path proxy is for.
-
#set_cached_property(property_name, value) ⇒ nil
If value is not nil, sets the cached value for the property with name property_name to the value in value.
Instance Method Details
#cached_property_names ⇒ Array<String>
Gets the names of all cached properties on proxy.
#call(method_name, parameters, flags, timeout_msec, cancellable, callback, user_data) ⇒ nil
Asynchronously invokes the method_name method on proxy.
If method_name contains any dots, then name is split into interface and method name parts. This allows using proxy for invoking methods on other interfaces.
If the GDBus::Connection associated with proxy is closed then the operation will fail with %G_IO_ERROR_CLOSED. If cancellable is canceled, the operation will fail with %G_IO_ERROR_CANCELLED. If parameters contains a value not compatible with the D-Bus protocol, the operation fails with %G_IO_ERROR_INVALID_ARGUMENT.
If the parameters #GVariant is floating, it is consumed. This allows convenient ‘inline’ use of g_variant_new(), e.g.:
g_dbus_proxy_call (proxy,
"TwoStrings",
g_variant_new ("(ss)",
"Thing One",
"Thing Two"),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
(GAsyncReadyCallback) two_strings_done,
&data);
If proxy has an expected interface (see GDBus::Proxy:g-interface-info) and method_name is referenced by it, then the return value is checked against the return type.
This is an asynchronous method. When the operation is finished, 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_proxy_call_finish() to get the result of the operation. See g_dbus_proxy_call_sync() for the synchronous version of this method.
If callback is nil then the D-Bus method call message will be sent with the %G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED flag set. care about the result of the method invocation.
#call_finish(res) ⇒ GLib::Variant
Finishes an operation started with g_dbus_proxy_call(). return values. Free with g_variant_unref().
#call_sync(method_name, parameters, flags, timeout_msec, cancellable) ⇒ GLib::Variant
Synchronously invokes the method_name method on proxy.
If method_name contains any dots, then name is split into interface and method name parts. This allows using proxy for invoking methods on other interfaces.
If the GDBus::Connection associated with proxy is disconnected then the operation will fail with %G_IO_ERROR_CLOSED. If cancellable is canceled, the operation will fail with %G_IO_ERROR_CANCELLED. If parameters contains a value not compatible with the D-Bus protocol, the operation fails with %G_IO_ERROR_INVALID_ARGUMENT.
If the parameters #GVariant is floating, it is consumed. This allows convenient ‘inline’ use of g_variant_new(), e.g.:
g_dbus_proxy_call_sync (proxy,
"TwoStrings",
g_variant_new ("(ss)",
"Thing One",
"Thing Two"),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
The calling thread is blocked until a reply is received. See g_dbus_proxy_call() for the asynchronous version of this method.
If proxy has an expected interface (see GDBus::Proxy:g-interface-info) and method_name is referenced by it, then the return value is checked against the return type. return values. Free with g_variant_unref().
#call_with_unix_fd_list(method_name, parameters, flags, timeout_msec, fd_list, cancellable, callback, user_data) ⇒ nil
Like g_dbus_proxy_call() but also takes a GUnix::FDList object.
This method is only available on UNIX. care about the result of the method invocation.
#call_with_unix_fd_list_finish(out_fd_list, res) ⇒ GLib::Variant
Finishes an operation started with g_dbus_proxy_call_with_unix_fd_list(). return values. Free with g_variant_unref().
#call_with_unix_fd_list_sync(method_name, parameters, flags, timeout_msec, fd_list, out_fd_list, cancellable) ⇒ GLib::Variant
Like g_dbus_proxy_call_sync() but also takes and returns GUnix::FDList objects.
This method is only available on UNIX. return values. Free with g_variant_unref().
#connection ⇒ Gio::DBusConnection
Gets the connection proxy is for.
#default_timeout ⇒ Integer
Gets the timeout to use if -1 (specifying default timeout) is passed as timeout_msec in the g_dbus_proxy_call() and g_dbus_proxy_call_sync() functions.
See the GDBus::Proxy:g-default-timeout property for more details.
#default_timeout=(timeout_msec) ⇒ nil
Sets the timeout to use if -1 (specifying default timeout) is passed as timeout_msec in the g_dbus_proxy_call() and g_dbus_proxy_call_sync() functions.
See the GDBus::Proxy:g-default-timeout property for more details.
#flags ⇒ Gio::DBusProxyFlags
Gets the flags that proxy was constructed with.
#g_bus_type=(g_bus_type) ⇒ Gio::BusType
If this property is not %G_BUS_TYPE_NONE, then GDBus::Proxy:g-connection must be nil and will be set to the GDBus::Connection obtained by calling g_bus_get() with the value of this property.
#g_connection ⇒ Gio::DBusConnection
The GDBus::Connection the proxy is for.
#g_connection=(g_connection) ⇒ Gio::DBusConnection
The GDBus::Connection the proxy is for.
#g_default_timeout ⇒ Integer
The timeout to use if -1 (specifying default timeout) is passed as timeout_msec in the g_dbus_proxy_call() and g_dbus_proxy_call_sync() functions.
This allows applications to set a proxy-wide timeout for all remote method invocations on the proxy. If this property is -1, the default timeout (typically 25 seconds) is used. If set to %G_MAXINT, then no timeout is used.
#g_default_timeout=(g_default_timeout) ⇒ Integer
The timeout to use if -1 (specifying default timeout) is passed as timeout_msec in the g_dbus_proxy_call() and g_dbus_proxy_call_sync() functions.
This allows applications to set a proxy-wide timeout for all remote method invocations on the proxy. If this property is -1, the default timeout (typically 25 seconds) is used. If set to %G_MAXINT, then no timeout is used.
#g_flags ⇒ Gio::DBusProxyFlags
Flags from the GDBus::ProxyFlags enumeration.
#g_flags=(g_flags) ⇒ Gio::DBusProxyFlags
Flags from the GDBus::ProxyFlags enumeration.
#g_interface_info ⇒ Gio::DBusInterfaceInfo
Ensure that interactions with this proxy conform to the given interface. This is mainly to ensure that malformed data received from the other peer is ignored. The given GDBus::InterfaceInfo is said to be the “expected interface”.
The checks performed are:
-
When completing a method call, if the type signature of the reply message isn’t what’s expected, the reply is discarded and the #GError is set to %G_IO_ERROR_INVALID_ARGUMENT.
-
Received signals that have a type signature mismatch are dropped and a warning is logged via g_warning().
-
Properties received via the initial ‘GetAll()` call or via the `::PropertiesChanged` signal (on the [org.freedesktop.DBus.Properties](dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties) interface) or set using g_dbus_proxy_set_cached_property() with a type signature mismatch are ignored and a warning is logged via g_warning().
Note that these checks are never done on methods, signals and properties that are not referenced in the given GDBus::InterfaceInfo, since extending a D-Bus interface on the service-side is not considered an ABI break.
#g_interface_info=(g_interface_info) ⇒ Gio::DBusInterfaceInfo
Ensure that interactions with this proxy conform to the given interface. This is mainly to ensure that malformed data received from the other peer is ignored. The given GDBus::InterfaceInfo is said to be the “expected interface”.
The checks performed are:
-
When completing a method call, if the type signature of the reply message isn’t what’s expected, the reply is discarded and the #GError is set to %G_IO_ERROR_INVALID_ARGUMENT.
-
Received signals that have a type signature mismatch are dropped and a warning is logged via g_warning().
-
Properties received via the initial ‘GetAll()` call or via the `::PropertiesChanged` signal (on the [org.freedesktop.DBus.Properties](dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties) interface) or set using g_dbus_proxy_set_cached_property() with a type signature mismatch are ignored and a warning is logged via g_warning().
Note that these checks are never done on methods, signals and properties that are not referenced in the given GDBus::InterfaceInfo, since extending a D-Bus interface on the service-side is not considered an ABI break.
#g_interface_name ⇒ String
The D-Bus interface name the proxy is for.
#g_interface_name=(g_interface_name) ⇒ String
The D-Bus interface name the proxy is for.
#g_name ⇒ String
The well-known or unique name that the proxy is for.
#g_name=(g_name) ⇒ String
The well-known or unique name that the proxy is for.
#g_name_owner ⇒ String
The unique name that owns GDBus::Proxy:g-name or nil if no-one currently owns that name. You may connect to #GObject::notify signal to track changes to this property.
#g_name_owner=(g_name_owner) ⇒ String
The unique name that owns GDBus::Proxy:g-name or nil if no-one currently owns that name. You may connect to #GObject::notify signal to track changes to this property.
#g_object_path ⇒ String
The object path the proxy is for.
#g_object_path=(g_object_path) ⇒ String
The object path the proxy is for.
#get_cached_property(property_name) ⇒ GLib::Variant
Looks up the value for a property from the cache. This call does no blocking IO.
If proxy has an expected interface (see GDBus::Proxy:g-interface-info) and property_name is referenced by it, then value is checked against the type of the property.
#interface_info ⇒ Gio::DBusInterfaceInfo
Returns the GDBus::InterfaceInfo, if any, specifying the interface that proxy conforms to. See the GDBus::Proxy:g-interface-info property for more details.
#interface_info=(info) ⇒ nil
Ensure that interactions with proxy conform to the given interface. See the GDBus::Proxy:g-interface-info property for more details.
#interface_name ⇒ String
Gets the D-Bus interface name proxy is for.
#name ⇒ String
Gets the name that proxy was constructed for.
#name_owner ⇒ String
The unique name that owns the name that proxy is for or nil if no-one currently owns that name. You may connect to the #GObject::notify signal to track changes to the GDBus::Proxy:g-name-owner property.
#new_finish(res) ⇒ Gio::DBusProxy
Finishes creating a GDBus::Proxy.
#new_for_bus_finish(res) ⇒ Gio::DBusProxy
Finishes creating a GDBus::Proxy.
#new_for_bus_sync(bus_type, flags, info, name, object_path, interface_name, cancellable) ⇒ Gio::DBusProxy
Like g_dbus_proxy_new_sync() but takes a GBus::Type instead of a #GDBusConnection.
GDBus::Proxy is used in this [example].
#new_sync(connection, flags, info, name, object_path, interface_name, cancellable) ⇒ Gio::DBusProxy
Creates a proxy for accessing interface_name on the remote object at object_path owned by name at connection and synchronously loads D-Bus properties unless the %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used.
If the %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS flag is not set, also sets up match rules for signals. Connect to the GDBus::Proxy::g-signal signal to handle signals from the remote object.
If both %G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES and %G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS are set, this constructor is guaranteed to return immediately without blocking.
If name is a well-known name and the %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START and %G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION flags aren’t set and no name owner currently exists, the message bus will be requested to launch a name owner for the name.
This is a synchronous failable constructor. See g_dbus_proxy_new() and g_dbus_proxy_new_finish() for the asynchronous version.
GDBus::Proxy is used in this [example].
#object_path ⇒ String
Gets the object path proxy is for.
#set_cached_property(property_name, value) ⇒ nil
If value is not nil, sets the cached value for the property with name property_name to the value in value.
If value is nil, then the cached value is removed from the property cache.
If proxy has an expected interface (see GDBus::Proxy:g-interface-info) and property_name is referenced by it, then value is checked against the type of the property.
If the value #GVariant is floating, it is consumed. This allows convenient ‘inline’ use of g_variant_new(), e.g.
g_dbus_proxy_set_cached_property (proxy,
"SomeProperty",
g_variant_new ("(si)",
"A String",
42));
Normally you will not need to use this method since proxy is tracking changes using the ‘org.freedesktop.DBus.Properties.PropertiesChanged` D-Bus signal. However, for performance reasons an object may decide to not use this signal for some properties and instead use a proprietary out-of-band mechanism to transmit changes.
As a concrete example, consider an object with a property ‘ChatroomParticipants` which is an array of strings. Instead of transmitting the same (long) array every time the property changes, it is more efficient to only transmit the delta using e.g. signals `ChatroomParticipantJoined(String name)` and `ChatroomParticipantParted(String name)`.