Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: DBusProxyGsignalCallback

[567:7] extends: object

Generated low-level callback wrapper for GIR callback g-signal.

Members

  • callbackObj
  • userFn
  • userData
  • hasUserData

Methods

  • DBusProxyGsignalCallback (callback Fn, UserData = null)

    Creates one native callback wrapper. The wrapper owns a trampoline that converts native pointers into generated wrapper objects before invoking Fn.

    • @p Fn is the Aussom callback implementation.
    • @p UserData is retained and passed through to Fn on each invocation when provided.
  • trampoline (nativeSelf, sender_name, signal_name, parameters, nativeUserData)

    Internal trampoline. Converts native pointer arguments into generated wrapper instances, then invokes the user's callback.

  • callback ()

    Returns the wrapped NativeCallback.

  • handle ()

    Returns the callback as a NativeHandle.

  • close ()

    Closes the underlying NativeCallback.

  • isClosed ()

    Returns true when the callback has been closed.

class: DBusProxyCtors

[480:14] static extends: object

Alternate constructors for DBusProxy. Usage: DBusProxyCtors.<name>(...). The primary constructor lives directly on DBusProxy.

Methods

  • newForBusFinish (object res)

    Finishes creating a #GDBusProxy.

    • @p res is A #GAsyncResult obtained from the #GAsyncReadyCallback function passed to g_dbus_proxy_new_for_bus()..
    • @r A new DBusProxy.
  • newForBusSync (string bus_type, string flags, object info, string name, string object_path, string interface_name, object cancellable)

    Like g_dbus_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection. #GDBusProxy is used in this [example][class@Gio.DBusProxy#a-watch-proxy-example].

    • @p bus_type is A #GBusType..
    • @p flags is Flags used when constructing the proxy..
    • @p info is A #GDBusInterfaceInfo specifying the minimal interface that
    • @proxy conforms to or %NULL..
    • @p name is A bus name (well-known or unique)..
    • @p object_path is An object path..
    • @p interface_name is A D-Bus interface name..
    • @p cancellable is A #GCancellable or %NULL..
    • @r A new DBusProxy.
  • newSync (object connection, string flags, object info, string name, string object_path, string interface_name, object cancellable)

    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 #GDBusProxy::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. #GDBusProxy is used in this [example][class@Gio.DBusProxy#a-watch-proxy-example].
    • @p connection is A #GDBusConnection..
    • @p flags is Flags used when constructing the proxy..
    • @p info is A #GDBusInterfaceInfo specifying the minimal interface that
    • @proxy conforms to or %NULL..
    • @p name is A bus name (well-known or unique) or %NULL if @connection is not a message bus connection..
    • @p object_path is An object path..
    • @p interface_name is A D-Bus interface name..
    • @p cancellable is A #GCancellable or %NULL..
    • @r A new DBusProxy.

class: DBusProxyMeta

[638:14] static extends: object

Generated metadata helpers for DBusProxy class surfaces.

Methods

  • properties ()

    Returns property metadata for DBusProxy.

    • @r A list.
  • signals ()

    Returns signal metadata for DBusProxy.

    • @r A list.

class: DBusProxy

[48:7] extends: object

GDBusProxy is a base class used for proxies to access a D-Bus interface on a remote object. A GDBusProxy can be constructed for both well-known and unique names. By default, GDBusProxy will cache all properties (and listen to changes) of the remote object, and proxy all signals that get emitted. This behaviour can be changed by passing suitable [flags@Gio.DBusProxyFlags] when the proxy is created. If the proxy is for a well-known name, the property cache is flushed when the name owner vanishes and reloaded when a name owner appears. The unique name owner of the proxy’s name is tracked and can be read from [property@Gio.DBusProxy:g-name-owner]. Connect to the [signal@GObject.Object::notify] signal to get notified of changes. Additionally, only signals and property changes emitted from the current name owner are considered and calls are always sent to the current name owner. This avoids a number of race conditions when the name is lost by one owner and claimed by another. However, if no name owner currently exists, then calls will be sent to the well-known name which may result in the message bus launching an owner (unless G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START is set). If the proxy is for a stateless D-Bus service, where the name owner may be started and stopped between calls, the [property@Gio.DBusProxy:g-name-owner] tracking of GDBusProxy will cause the proxy to drop signal and property changes from the service after it has restarted for the first time. When interacting with a stateless D-Bus service, do not use GDBusProxy — use direct D-Bus method calls and signal connections. The generic [signal@Gio.DBusProxy::g-properties-changed] and [signal@Gio.DBusProxy::g-signal] signals are not very convenient to work with. Therefore, the recommended way of working with proxies is to subclass GDBusProxy, and have more natural properties and signals in your derived class. This example shows how this can easily be done using the gdbus-codegen tool. A GDBusProxy instance can be used from multiple threads but note that all signals (e.g. [signal@Gio.DBusProxy::g-signal], [signal@Gio.DBusProxy::g-properties-changed] and [signal@GObject.Object::notify]) are emitted in the thread-default main context (see [method@GLib.MainContext.push_thread_default]) of the thread where the instance was constructed. ## A watch proxy example An example using a proxy for a well-known name can be found in gdbus-example-watch-proxy.c.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • DBusProxy (res = null)

    Finishes creating a #GDBusProxy.

    • @p res is A #GAsyncResult obtained from the #GAsyncReadyCallback function passed to g_dbus_proxy_new()..
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asObject ()

    Wraps this handle as Object.

    • @r A Object object.
  • asAsyncInitable ()

    Wraps this handle as AsyncInitable.

    • @r A AsyncInitable object.
  • asDBusInterface ()

    Wraps this handle as DBusInterface.

    • @r A DBusInterface object.
  • asInitable ()

    Wraps this handle as Initable.

    • @r A Initable object.
  • connectSignal (string Name, CallbackObj)

    Connects one generated callback wrapper to a named signal.

    • @p Name is the signal name.
    • @p CallbackObj is the generated callback wrapper to connect.
    • @r The connected handler id.
  • disconnectSignalHandler (int HandlerId)

    Disconnects one retained signal handler id.

    • @p HandlerId is the signal handler id to disconnect.
    • @r None.
  • setOnGsignal (callback Fn, UserData = null)

    Emitted when a signal from the remote object and interface that @proxy is for, has been received. Since 2.72 this signal supports detailed connections. You can connect to the detailed signal g-signal::x in order to receive callbacks only when signal x is received from the remote object.

    • @p Fn is the Aussom callback.
    • @p Fn is called with (DBusProxy Self, string Sender_name, string Signal_name, Variant Parameters).
    • @p UserData is retained and passed through to the generated callback wrapper when provided.
    • @r The connected handler id.
  • getProperty (string Name)

    Reads one generated property by name.

  • setProperty (string Name, Value)

    Writes one generated property by name.

  • setGdefaulttimeout (int Value)

    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.
    • @p Value is the new property value.
    • @r None.
  • setGinterfaceinfo (object Value)

    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 #GDBusInterfaceInfo 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 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 #GDBusInterfaceInfo, since extending a D-Bus interface on the service-side is not considered an ABI break.

    • @p Value is the new property value.
    • @r None.
  • call_finish (object res)

    Finishes an operation started with g_dbus_proxy_call().

    • @p res is A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_proxy_call()..
  • call_sync (string method_name, object parameters, string flags, int timeout_msec, object cancellable)

    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 #GDBusConnection 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 #GDBusProxy:g-interface-info) and @method_name is referenced by it, then the return value is checked against the return type.

    • @p method_name is Name of method to invoke..
    • @p parameters is A #GVariant tuple with parameters for the signal or %NULL if not passing parameters..
    • @p flags is Flags from the #GDBusCallFlags enumeration..
    • @p timeout_msec is The timeout in milliseconds (with %G_MAXINT meaning "infinite") or -1 to use the proxy default timeout..
    • @p cancellable is A #GCancellable or %NULL..
  • get_cached_property (string property_name)

    Looks up the value for a property from the cache. This call does no blocking IO. If @proxy has an expected interface (see #GDBusProxy:g-interface-info) and @property_name is referenced by it, then @value is checked against the type of the property.

    • @p property_name is Property name..
  • get_cached_property_names ()

    Gets the names of all cached properties on @proxy.

  • get_connection ()

    Gets the connection @proxy is for.

  • get_default_timeout ()

    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 #GDBusProxy:g-default-timeout property for more details.
  • get_flags ()

    Gets the flags that @proxy was constructed with.

  • get_interface_info ()

    Returns the #GDBusInterfaceInfo, if any, specifying the interface that

    • @proxy conforms to. See the #GDBusProxy:g-interface-info property for more details.
  • get_interface_name ()

    Gets the D-Bus interface name @proxy is for.

  • get_name ()

    Gets the name that @proxy was constructed for. When connected to a message bus, this will usually be non-%NULL. However, it may be %NULL for a proxy that communicates using a peer-to-peer pattern.

  • get_name_owner ()

    The unique name that owns the name that @proxy is for or %NULL if no-one currently owns that name. You may connect to the #GObject::notify signal to track changes to the #GDBusProxy:g-name-owner property.

  • get_object_path ()

    Gets the object path @proxy is for.

  • set_cached_property (string property_name, object value)

    If @value is not %NULL, sets the cached value for the property with name

    • @property_name to the value in @value. If @value is %NULL, then the cached value is removed from the property cache. If @proxy has an expected interface (see #GDBusProxy: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).
    • @p property_name is Property name..
    • @p value is Value for the property or %NULL to remove it from the cache..
    • @r None.
  • set_default_timeout (int timeout_msec)

    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 #GDBusProxy:g-default-timeout property for more details.
    • @p timeout_msec is Timeout in milliseconds..
    • @r None.
  • set_interface_info (object info)

    Ensure that interactions with @proxy conform to the given interface. See the #GDBusProxy:g-interface-info property for more details.

    • @p info is Minimum interface this proxy conforms to or %NULL to unset..
    • @r None.