It derives from <GObject>.
The <GDBusConnection> type is used for
D-Bus connections to remote peers such as a message buses.
It is a low-level API that offers a lot of flexibility. For instance,
it lets you establish a connection over any transport that can by
represented as a <GIOStream>.
This class is rarely used directly in D-Bus clients. If you are writing
a D-Bus client, it is often easier to use the
bus-own-name,
bus-watch-name or dbus-proxy:new-for-bus APIs.
As an exception to the usual GLib rule that a particular object must not
be used by two threads at the same time,
<GDBusConnection>s methods may be called
from any thread. This is so that bus-get and
bus-get-sync can safely return the same
<GDBusConnection> when called from any
thread.
Most of the ways to obtain a
<GDBusConnection> automatically initialize
it (i.e. connect to D-Bus): for instance, dbus-connection:new and bus-get, and the
synchronous versions of those methods, give you an initialized
connection. Language bindings for GIO should use
Gio.Initable.new or Gio.AsyncInitable.new_async, which
also initialize the connection.
If you construct an uninitialized
<GDBusConnection>, such as via
GObject.Object.new, you must initialize it via
initable:init? or async-initable:init-async before using its methods or
properties. Calling methods or accessing properties on a
<GDBusConnection> that has not completed
initialization successfully is considered to be invalid, and leads to
undefined behaviour. In particular, if initialization fails with a
<GError>, the only valid thing you can do with
that <GDBusConnection> is to free it with
object:unref.
Here is an example for a D-Bus server: gdbus-example-server.c
Here is an example for exporting a subtree: gdbus-example-subtree.c
Here is an example for passing UNIX file descriptors: gdbus-unix-fd-client.c
Here is an example for exporting a #GObject: gdbus-example-export.c
A D-Bus address specifying potential endpoints that can be used when establishing the connection.
Its value is a string, or #f.
It can only be set when the object is made, with #:address. It
cannot be read.
A <GDBusAuthObserver> object to assist in
the authentication process or #f.
Its value is a <GDBusAuthObserver>, or
#f.
It can only be set when the object is made, with
#:authentication-observer. It cannot be read.
Flags from the <GDBusCapabilityFlags>
enumeration representing connection features negotiated with the other
peer.
Its value is a <GDBusCapabilityFlags>.
It is read only.
A boolean specifying whether the connection has been closed.
Its value is a boolean.
It is read only.
A boolean specifying whether the process will be terminated (by calling
raise(SIGTERM)) if the connection is closed by the remote peer.
Note that <GDBusConnection> objects
returned by bus-get-finish and
bus-get-sync will (usually) have this
property set to #t.
Its value is a boolean.
Set it with (set! (dbus-connection:exit-on-close self) value).
Flags from the <GDBusConnectionFlags>
enumeration.
Its value is a <GDBusConnectionFlags>
(or, to set it, a list of its symbols, or one of them).
It can only be set when the object is made, with #:flags.
The GUID of the peer performing the role of server when authenticating.
If you are constructing a <GDBusConnection>
and pass authentication-server in the
dbus-connection:flags
property then you must also set this property to a valid guid.
If you are constructing a <GDBusConnection>
and pass authentication-client in the
dbus-connection:flags
property you will be able to read the GUID of the other peer here after
the connection has been successfully initialized.
Note that the D-Bus specification uses the term ‘UUID’ to refer to this, whereas GLib consistently uses the term ‘GUID’ for historical reasons.
Despite its name, the format of dbus-connection:guid does not follow
RFC 4122 or the
Microsoft GUID format.
Its value is a string, or #f.
It can only be set when the object is made, with #:guid.
The underlying <GIOStream> used for I/O.
If this is passed on construction and is a
<GSocketConnection>, then the
corresponding <GSocket> will be put into
non-blocking mode.
While the <GDBusConnection> is active, it
will interact with this stream from a worker thread, so it is not safe
to interact with the stream directly.
Its value is a <GIOStream>, or #f.
It can only be set when the object is made, with #:stream.
The unique name as assigned by the message bus or #f if the
connection is not open or not a message bus connection.
Its value is a string, or #f.
It is read only.
Adds a message filter. Filters are handlers that are run on all incoming and outgoing messages, prior to standard dispatch. Filters are run in the order that they were added. The same handler can be added as a filter more than once, in which case it will be run more than once. Filters added during a filter callback won’t be run on the message being processed. Filter functions are allowed to modify and even drop messages.
Note that filters are run in a dedicated message handling thread so they
can’t block and, generally, can’t do anything but signal a worker
thread. Also note that filters are rarely needed - use API such as
dbus-connection:send-message-with-reply,
dbus-connection:signal-subscribe or
dbus-connection:call instead.
If a filter consumes an incoming message the message is not dispatched
anywhere else - not even the standard dispatch machinery (that API such
as dbus-connection:signal-subscribe and
dbus-connection:send-message-with-reply
relies on) will see the message. Similarly, if a filter consumes an
outgoing message, the message will not be sent to the other peer.
If user-data-free-func is non-#f, it will be called (in the
thread-default main context of the thread you are calling this method
from) at some point after user-data is no longer needed. (It is
not guaranteed to be called synchronously when the filter is removed,
and may be called after self has been destroyed.)
Passed: a <GDBusConnection>.
Passed: a procedure.
a filter function
See GDBusMessageFilterFunction
for how it is called.
Returned: an unsigned 32-bit integer.
a filter identifier that can be used with dbus-connection:remove-filter
Not passed: guile-gi supplies it.
user data to pass to filter-function
Not passed: guile-gi supplies it.
function to free user-data with when filter is removed or
#f
See GDestroyNotify for how it is
called.
Asynchronously invokes the method-name method on the interface-name D-Bus interface on the remote object at object-path owned by bus-name.
If self is closed then the operation will fail with
closed. If cancellable is canceled, the
operation will fail with cancelled. If
parameters contains a value not compatible with the D-Bus
protocol, the operation fails with
invalid-argument.
If reply-type is non-#f then the reply will be checked for
having this type and an error will be raised if it does not match. Said
another way, if you give a reply-type then any non-#f
return value will be of this type. Unless it’s
G_VARIANT_TYPE_UNIT, the reply-type will be a tuple
containing one or more values.
If the parameters <GVariant> is
floating, it is consumed. This allows convenient ’inline’ use of
g_variant_new(), e.g.:
g_dbus_connection_call (connection,
"org.freedesktop.StringThings",
"/org/freedesktop/StringThings",
"org.freedesktop.StringThings",
"TwoStrings",
g_variant_new ("(ss)",
"Thing One",
"Thing Two"),
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
(GAsyncReadyCallback) two_strings_done,
NULL);
This is an asynchronous method. When the operation is finished,
callback will be invoked in the thread-default main context (see
main-context:push-thread-default) of the
thread you are calling this method from. You can then call
dbus-connection:call-finish to
get the result of the operation. See dbus-connection:call-sync for the synchronous version of
this function.
If callback is #f then the D-Bus method call message will
be sent with the no-reply-expected flag
set.
Passed: a <GDBusConnection>.
Passed: a string, or #f.
a unique or well-known bus name or #f if self is not a
message bus connection
Passed: a string.
path of remote object
Passed: a string.
D-Bus interface to invoke method on
Passed: a string.
the name of the method to invoke
Passed: a <GVariant>, or #f.
a <GVariant> tuple with parameters for the
method or #f if not passing parameters
Passed: a <GVariantType>, or #f.
the expected type of the reply (which will be a tuple), or #f
Passed: a <GDBusCallFlags>, or a list of its
symbols, or one of them.
flags from the <GDBusCallFlags> enumeration
Passed: a 32-bit integer.
the timeout in milliseconds, -1 to use the default timeout or
G_MAXINT for no timeout
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable> or #f
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied or #f if you don’t care about the result of
the method invocation
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
the data to pass to callback
Finishes an operation started with dbus-connection:call.
Passed: a <GDBusConnection>.
Passed: a <GAsyncResult>.
a <GAsyncResult> obtained from the
GAsyncReadyCallback passed to
dbus-connection:call
Returned: a <GVariant>.
#f if error is set. Otherwise a non-floating
<GVariant> tuple with return values. Free
with variant:unref.
Synchronously invokes the method-name method on the interface-name D-Bus interface on the remote object at object-path owned by bus-name.
If self is closed then the operation will fail with
closed. If cancellable is canceled, the
operation will fail with cancelled. If
parameters contains a value not compatible with the D-Bus
protocol, the operation fails with
invalid-argument.
If reply-type is non-#f then the reply will be checked for
having this type and an error will be raised if it does not match. Said
another way, if you give a reply-type then any non-#f
return value will be of this type.
If the parameters <GVariant> is
floating, it is consumed. This allows convenient ’inline’ use of
g_variant_new(), e.g.:
g_dbus_connection_call_sync (connection,
"org.freedesktop.StringThings",
"/org/freedesktop/StringThings",
"org.freedesktop.StringThings",
"TwoStrings",
g_variant_new ("(ss)",
"Thing One",
"Thing Two"),
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
The calling thread is blocked until a reply is received. See
dbus-connection:call for the
asynchronous version of this method.
Passed: a <GDBusConnection>.
Passed: a string, or #f.
a unique or well-known bus name or #f if self is not a
message bus connection
Passed: a string.
path of remote object
Passed: a string.
D-Bus interface to invoke method on
Passed: a string.
the name of the method to invoke
Passed: a <GVariant>, or #f.
a <GVariant> tuple with parameters for the
method or #f if not passing parameters
Passed: a <GVariantType>, or #f.
the expected type of the reply, or #f
Passed: a <GDBusCallFlags>, or a list of its
symbols, or one of them.
flags from the <GDBusCallFlags> enumeration
Passed: a 32-bit integer.
the timeout in milliseconds, -1 to use the default timeout or
G_MAXINT for no timeout
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable> or #f
Returned: a <GVariant>.
#f if error is set. Otherwise a non-floating
<GVariant> tuple with return values. Free
with variant:unref.
Like dbus-connection:call but also
takes a <GUnixFDList> object.
The file descriptors normally correspond to G_VARIANT_TYPE_HANDLE
values in the body of the message. For example, if a message contains
two file descriptors, fd-list would have length 2, and
g_variant_new_handle (0) and g_variant_new_handle (1)
would appear somewhere in the body of the message (not necessarily in
that order!) to represent the file descriptors at indexes 0 and 1
respectively.
When designing D-Bus APIs that are intended to be interoperable, please
note that non-GDBus implementations of D-Bus can usually only access
file descriptors if they are referenced in this way by a value of type
G_VARIANT_TYPE_HANDLE in the body of the message.
This method is only available on UNIX.
Passed: a <GDBusConnection>.
Passed: a string, or #f.
a unique or well-known bus name or #f if self is not a
message bus connection
Passed: a string.
path of remote object
Passed: a string.
D-Bus interface to invoke method on
Passed: a string.
the name of the method to invoke
Passed: a <GVariant>, or #f.
a <GVariant> tuple with parameters for the
method or #f if not passing parameters
Passed: a <GVariantType>, or #f.
the expected type of the reply, or #f
Passed: a <GDBusCallFlags>, or a list of its
symbols, or one of them.
flags from the <GDBusCallFlags> enumeration
Passed: a 32-bit integer.
the timeout in milliseconds, -1 to use the default timeout or
G_MAXINT for no timeout
Passed, or left out: a <GUnixFDList>, or
#f.
a <GUnixFDList> or #f
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable> or #f
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied or #f if you don’t * care about the result
of the method invocation
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
The data to pass to callback.
Finishes an operation started with dbus-connection:call-with-unix-fd-list.
The file descriptors normally correspond to G_VARIANT_TYPE_HANDLE
values in the body of the message. For example, if variant:get-handle returns 5, that is intended to be
a reference to the file descriptor that can be accessed by
g_unix_fd_list_get (*out_fd_list, 5, ...).
When designing D-Bus APIs that are intended to be interoperable, please
note that non-GDBus implementations of D-Bus can usually only access
file descriptors if they are referenced in this way by a value of type
G_VARIANT_TYPE_HANDLE in the body of the message.
Passed: a <GDBusConnection>.
Passed: a <GAsyncResult>.
a <GAsyncResult> obtained from the
GAsyncReadyCallback passed to
dbus-connection:call-with-unix-fd-list
Returned: a <GVariant>.
#f if error is set. Otherwise a non-floating
<GVariant> tuple with return values. Free
with variant:unref.
Returned: a <GUnixFDList>, or #f.
return location for a <GUnixFDList> or
#f
Like dbus-connection:call-sync
but also takes and returns <GUnixFDList>
objects. See dbus-connection:call-with-unix-fd-list and
dbus-connection:call-with-unix-fd-list-finish
for more details.
This method is only available on UNIX.
Passed: a <GDBusConnection>.
Passed: a string, or #f.
a unique or well-known bus name or #f if self is not a
message bus connection
Passed: a string.
path of remote object
Passed: a string.
D-Bus interface to invoke method on
Passed: a string.
the name of the method to invoke
Passed: a <GVariant>, or #f.
a <GVariant> tuple with parameters for the
method or #f if not passing parameters
Passed: a <GVariantType>, or #f.
the expected type of the reply, or #f
Passed: a <GDBusCallFlags>, or a list of its
symbols, or one of them.
flags from the <GDBusCallFlags> enumeration
Passed: a 32-bit integer.
the timeout in milliseconds, -1 to use the default timeout or
G_MAXINT for no timeout
Passed, or left out: a <GUnixFDList>, or
#f.
a <GUnixFDList> or #f
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable> or #f
Returned: a <GVariant>.
#f if error is set. Otherwise a non-floating
<GVariant> tuple with return values. Free
with variant:unref.
Returned: a <GUnixFDList>, or #f.
return location for a <GUnixFDList> or
#f
Closes self. Note that this never causes the process to exit
(this might only happen if the other end of a shared message bus
connection disconnects, see dbus-connection:exit-on-close).
Once the connection is closed, operations such as sending a message will
return with the error closed. Closing a
connection will not automatically flush the connection so queued
messages may be lost. Use dbus-connection:flush if you need such guarantees.
If self is already closed, this method fails with
closed.
When self has been closed, the dbus-connection:closed signal is emitted in the thread-default
main context (see main-context:push-thread-default) of the
thread that self was constructed in.
This is an asynchronous method. When the operation is finished,
callback will be invoked in the thread-default main context (see
main-context:push-thread-default) of the
thread you are calling this method from. You can then call
dbus-connection:close-finish?
to get the result of the operation. See dbus-connection:close-sync? for the synchronous version.
Passed: a <GDBusConnection>.
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable> or #f
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied or #f if you don’t care about the result
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
The data to pass to callback
Finishes an operation started with dbus-connection:close.
Passed: a <GDBusConnection>.
Passed: a <GAsyncResult>.
a <GAsyncResult> obtained from the
GAsyncReadyCallback passed to
dbus-connection:close
Returned: a boolean.
#t if the operation succeeded, #f if error is set
Synchronously closes self. The calling thread is blocked until
this is done. See dbus-connection:close for the asynchronous version of this
method and more details about what it does.
Passed: a <GDBusConnection>.
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable> or #f
Returned: a boolean.
#t if the operation succeeded, #f if error is set
Emits a signal.
If the parameters GVariant is floating, it is consumed.
This can only fail if parameters is not compatible with the D-Bus
protocol (invalid-argument), or if self
has been closed (closed).
Passed: a <GDBusConnection>.
Passed: a string, or #f.
the unique bus name for the destination for the signal or #f to
emit to all listeners
Passed: a string.
path of remote object
Passed: a string.
D-Bus interface to emit a signal on
Passed: a string.
the name of the signal to emit
Passed, or left out: a <GVariant>, or
#f.
a <GVariant> tuple with parameters for the
signal or #f if not passing parameters
Returned: a boolean.
#t unless error is set
Exports action-group on self at object-path.
The implemented D-Bus API should be considered private. It is subject to change in the future.
A given object path can only have one action group exported on it. If this constraint is violated, the export will fail and 0 will be returned (with error set accordingly).
You can unexport the action group using dbus-connection:unexport-action-group with the
return value of this function.
The thread default main context is taken at the time of this call. All incoming action activations and state change requests are reported from this context. Any changes on the action group that cause it to emit signals must also come from this same context. Since incoming action activations and state change requests are rather likely to cause changes on the action group, this effectively limits a given action group to being exported from only one main context.
Passed: a <GDBusConnection>.
the D-Bus connection
Passed: a string.
a D-Bus object path
Passed: a <GActionGroup>.
an action group
Returned: an unsigned 32-bit integer.
the ID of the export (never zero), or 0 in case of failure
Exports menu on self at object-path.
The implemented D-Bus API should be considered private. It is subject to change in the future.
An object path can only have one menu model exported on it. If this constraint is violated, the export will fail and 0 will be returned (with error set accordingly).
Exporting menus with sections containing more than
G_MENU_EXPORTER_MAX_SECTION_SIZE items is not supported and
results in undefined behavior.
You can unexport the menu model using dbus-connection:unexport-menu-model with the
return value of this function.
Passed: a <GDBusConnection>.
Passed: a string.
a D-Bus object path
Passed: a <GMenuModel>.
Returned: an unsigned 32-bit integer.
the ID of the export (never zero), or 0 in case of failure
Asynchronously flushes self, that is, writes all queued outgoing
messages to the transport and then flushes the transport (using
output-stream:flush-async). This
is useful in programs that want to emit a D-Bus signal and then exit
immediately. Without flushing the connection, there is no guarantee
that the message has been sent to the networking buffers in the OS
kernel.
This is an asynchronous method. When the operation is finished,
callback will be invoked in the thread-default main context (see
main-context:push-thread-default) of the
thread you are calling this method from. You can then call
dbus-connection:flush-finish?
to get the result of the operation. See dbus-connection:flush-sync? for the synchronous version.
Passed: a <GDBusConnection>.
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable> or #f
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied or #f if you don’t care about the result
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
The data to pass to callback
Finishes an operation started with dbus-connection:flush.
Passed: a <GDBusConnection>.
Passed: a <GAsyncResult>.
a <GAsyncResult> obtained from the
GAsyncReadyCallback passed to
dbus-connection:flush
Returned: a boolean.
#t if the operation succeeded, #f if error is set
Synchronously flushes self. The calling thread is blocked until
this is done. See dbus-connection:flush for the asynchronous version of this
method and more details about what it does.
Passed: a <GDBusConnection>.
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable> or #f
Returned: a boolean.
#t if the operation succeeded, #f if error is set
Gets the capabilities negotiated with the remote peer
Passed: a <GDBusConnection>.
Returned: a <GDBusCapabilityFlags>.
zero or more flags from the
<GDBusCapabilityFlags> enumeration
Gets whether the process is terminated when self is closed by the
remote peer. See dbus-connection:exit-on-close for more details.
Passed: a <GDBusConnection>.
Returned: a boolean.
whether the process is terminated when self is closed by the remote peer
Gets the flags used to construct this connection
Passed: a <GDBusConnection>.
Returned: a <GDBusConnectionFlags>.
zero or more flags from the
<GDBusConnectionFlags> enumeration
The GUID of the peer performing the role of server when authenticating.
See dbus-connection:guid for
more details.
Passed: a <GDBusConnection>.
Returned: a string.
The GUID. Do not free this string, it is owned by self.
Retrieves the last serial number assigned to a
<GDBusMessage> on the current thread. This
includes messages sent via both low-level API such as
dbus-connection:send-message
as well as high-level API such as dbus-connection:emit-signal?, dbus-connection:call or dbus-proxy:call.
Passed: a <GDBusConnection>.
Returned: an unsigned 32-bit integer.
the last used serial or zero when no message has been sent within the current thread
Gets the credentials of the authenticated peer. This will always return
#f unless self acted as a server (e.g.
authentication-server was passed) when
set up and the client passed credentials as part of the authentication
process.
In a message bus setup, the message bus is always the server and each
application is a client. So this method will always return #f
for message bus clients.
Passed: a <GDBusConnection>.
Returned: a <GCredentials>, or #f.
a <GCredentials> or #f if not
available. Do not free this object, it is owned by self.
Gets the underlying stream used for IO.
While the <GDBusConnection> is active, it
will interact with this stream from a worker thread, so it is not safe
to interact with the stream directly.
Passed: a <GDBusConnection>.
Returned: a <GIOStream>.
the stream used for IO
Gets the unique name of self as assigned by the message bus. This can also be used to figure out if self is a message bus connection.
Passed: a <GDBusConnection>.
Returned: a string, or #f.
the unique name or #f if self is not a message bus
connection. Do not free this string, it is owned by self.
Gets whether self is closed.
Passed: a <GDBusConnection>.
Returned: a boolean.
#t if the connection is closed, #f otherwise
Asynchronously sets up a D-Bus connection for exchanging D-Bus messages with the end represented by stream.
If stream is a <GSocketConnection>,
then the corresponding <GSocket> will be put into
non-blocking mode.
The D-Bus connection will interact with stream from a worker
thread. As a result, the caller should not interact with stream
after this method has been called, except by calling object:unref on it.
If observer is not #f it may be used to control the
authentication process.
When the operation is finished, callback will be invoked. You can
then call dbus-connection:new-finish to get the result of the
operation.
This is an asynchronous failable constructor. See
dbus-connection:new-sync for the
synchronous version.
Passed: a <GIOStream>.
Passed: a string, or #f.
the GUID to use if authenticating as a server or #f
Passed: a <GDBusConnectionFlags>, or a
list of its symbols, or one of them.
flags describing how to make the connection
Passed, or left out: a
<GDBusAuthObserver>, or #f.
a <GDBusAuthObserver> or #f
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable> or #f
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
the data to pass to callback
Finishes an operation started with dbus-connection:new.
Passed: a <GAsyncResult>.
a <GAsyncResult> obtained from the
GAsyncReadyCallback passed to
dbus-connection:new.
Returned: a <GDBusConnection>.
a <GDBusConnection> or #f if
error is set. Free with object:unref.
Asynchronously connects and sets up a D-Bus client connection for exchanging D-Bus messages with an endpoint specified by address which must be in the D-Bus address format.
This constructor can only be used to initiate client-side connections -
use dbus-connection:new if you need to
act as the server. In particular, flags cannot contain the
authentication-server,
authentication-allow-anonymous or
authentication-require-same-user
flags.
When the operation is finished, callback will be invoked. You can
then call dbus-connection:new-for-address-finish to get
the result of the operation.
If observer is not #f it may be used to control the
authentication process.
This is an asynchronous failable constructor. See
dbus-connection:new-for-address-sync for the
synchronous version.
Passed: a string.
a D-Bus address
Passed: a <GDBusConnectionFlags>, or a
list of its symbols, or one of them.
flags describing how to make the connection
Passed, or left out: a
<GDBusAuthObserver>, or #f.
a <GDBusAuthObserver> or #f
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable> or #f
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied
See GAsyncReadyCallback for how it is
called.
Not passed: guile-gi supplies it.
the data to pass to callback
Finishes an operation started with dbus-connection:new-for-address.
Passed: a <GAsyncResult>.
a <GAsyncResult> obtained from the
GAsyncReadyCallback passed to
dbus-connection:new
Returned: a <GDBusConnection>.
a <GDBusConnection> or #f if
error is set. Free with object:unref.
Synchronously connects and sets up a D-Bus client connection for exchanging D-Bus messages with an endpoint specified by address which must be in the D-Bus address format.
This constructor can only be used to initiate client-side connections -
use dbus-connection:new-sync if
you need to act as the server. In particular, flags cannot
contain the authentication-server,
authentication-allow-anonymous or
authentication-require-same-user
flags.
This is a synchronous failable constructor. See
dbus-connection:new-for-address for the asynchronous
version.
If observer is not #f it may be used to control the
authentication process.
Passed: a string.
a D-Bus address
Passed: a <GDBusConnectionFlags>, or a
list of its symbols, or one of them.
flags describing how to make the connection
Passed, or left out: a
<GDBusAuthObserver>, or #f.
a <GDBusAuthObserver> or #f
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable> or #f
Returned: a <GDBusConnection>.
a <GDBusConnection> or #f if
error is set. Free with object:unref.
Synchronously sets up a D-Bus connection for exchanging D-Bus messages with the end represented by stream.
If stream is a <GSocketConnection>,
then the corresponding <GSocket> will be put into
non-blocking mode.
The D-Bus connection will interact with stream from a worker
thread. As a result, the caller should not interact with stream
after this method has been called, except by calling object:unref on it.
If observer is not #f it may be used to control the
authentication process.
This is a synchronous failable constructor. See
dbus-connection:new for the
asynchronous version.
Passed: a <GIOStream>.
Passed: a string, or #f.
the GUID to use if authenticating as a server or #f
Passed: a <GDBusConnectionFlags>, or a
list of its symbols, or one of them.
flags describing how to make the connection
Passed, or left out: a
<GDBusAuthObserver>, or #f.
a <GDBusAuthObserver> or #f
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable> or #f
Returned: a <GDBusConnection>.
a <GDBusConnection> or #f if
error is set. Free with object:unref.
Registers callbacks for exported objects at object-path with the D-Bus interface that is described in interface-info.
Calls to functions in vtable (and user-data-free-func) will
happen in the thread-default main context (see main-context:push-thread-default) of the
thread you are calling this method from.
Note that all <GVariant> values passed to
functions in vtable will match the signature given in
interface-info - if a remote caller passes incorrect values, the
org.freedesktop.DBus.Error.InvalidArgs is returned to the remote
caller.
Additionally, if the remote caller attempts to invoke methods or access
properties not mentioned in interface-info the
org.freedesktop.DBus.Error.UnknownMethod resp.
org.freedesktop.DBus.Error.InvalidArgs errors are returned to the
caller.
It is considered a programming error if the
GDBusInterfaceGetPropertyFunc
function in vtable returns a <GVariant>
of incorrect type.
If an existing callback is already registered at object-path and
interface-name, then error is set to
exists.
GDBus automatically implements the standard D-Bus interfaces org.freedesktop.DBus.Properties, org.freedesktop.DBus.Introspectable and org.freedesktop.Peer, so you don’t have to implement those for the objects you export. You can implement org.freedesktop.DBus.Properties yourself, e.g. to handle getting and setting of properties asynchronously.
Note that the reference count on interface-info will be
incremented by 1 (unless allocated statically, e.g. if the reference
count is -1, see dbus-interface-info:ref) for as long as the object is exported.
Also note that vtable will be copied.
See this [server][class@Gio.DBusConnection#an-example-d-bus-server] for an example of how to use this method.
Passed: a <GDBusConnection>.
Passed: a string.
the object path to register at
Passed: a <GDBusInterfaceInfo>.
introspection data for the interface
Passed, or left out: a <GClosure>, or
#f.
Passed, or left out: a <GClosure>, or
#f.
Passed, or left out: a <GClosure>, or
#f.
Returned: an unsigned 32-bit integer.
0 if error is set, otherwise a registration id (never 0) that can
be used with dbus-connection:unregister-object?
a GDBusInterfaceVTable to call into or #f
data to pass to functions in vtable
function to call when the object path is unregistered
See GDestroyNotify for how it is
called.
Version of dbus-connection:register-object using closures
instead of a <GDBusInterfaceVTable> for easier binding in other
languages.
In contrast to dbus-connection:register-object and
Gio.DBusConnection.register_object_with_closures, the reference
counting semantics of the function wrapped by method-call-closure
are not the same as those of
GDBusInterfaceMethodCallFunc.
Ownership of a reference to the
<GDBusMethodInvocation> is not
transferred to the function. Bindings must ensure that they add a
reference to the
<GDBusMethodInvocation> before
calling any g_dbus_method_invocation_return_*() methods on it.
This should be automatic as a result of the introspection annotations on
those methods.
Passed: a <GDBusConnection>.
Passed: a string.
The object path to register at.
Passed: a <GDBusInterfaceInfo>.
Introspection data for the interface.
Passed, or left out: a <GClosure>, or
#f.
<GClosure> for handling incoming method
calls.
Passed, or left out: a <GClosure>, or
#f.
<GClosure> for getting a property.
Passed, or left out: a <GClosure>, or
#f.
<GClosure> for setting a property.
Returned: an unsigned 32-bit integer.
0 if error is set, otherwise a registration ID (never
0) that can be used with dbus-connection:unregister-object?.
Removes a filter.
Note that since filters run in a different thread, there is a race
condition where it is possible that the filter will be running even
after calling dbus-connection:remove-filter, so you cannot just free
data that the filter might be using. Instead, you should pass a
GDestroyNotify to
dbus-connection:add-filter,
which will be called when it is guaranteed that the data is no longer
needed.
Passed: a <GDBusConnection>.
Passed: an unsigned 32-bit integer.
an identifier obtained from dbus-connection:add-filter
Asynchronously sends message to the peer represented by self.
Unless flags contain the
preserve-serial flag, the serial
number will be assigned by self and set on message via
dbus-message:set-serial. If
out-serial is not #f, then the serial number used will be
written to this location prior to submitting the message to the
underlying transport. While it has a volatile qualifier, this is
a historical artifact and the argument passed to it should not be
volatile.
If self is closed then the operation will fail with
closed. If message is not well-formed,
the operation fails with invalid-argument.
See this [server][class@Gio.DBusConnection#an-example-d-bus-server] and [client][class@Gio.DBusConnection#an-example-for-file-descriptor-passing] for an example of how to use this low-level API to send and receive UNIX file descriptors.
Note that message must be unlocked, unless flags contain the
preserve-serial flag.
Passed: a <GDBusConnection>.
Passed: a <GDBusMessage>.
Passed: a <GDBusSendMessageFlags>, or
a list of its symbols, or one of them.
flags affecting how the message is sent
Returned: a boolean.
#t if the message was well-formed and queued for transmission,
#f if error is set
Returned: an unsigned 32-bit integer.
return location for serial number assigned to message when sending
it or #f
Asynchronously sends message to the peer represented by self.
Unless flags contain the
preserve-serial flag, the serial
number will be assigned by self and set on message via
dbus-message:set-serial. If
out-serial is not #f, then the serial number used will be
written to this location prior to submitting the message to the
underlying transport. While it has a volatile qualifier, this is
a historical artifact and the argument passed to it should not be
volatile.
If self is closed then the operation will fail with
closed. If cancellable is canceled, the
operation will fail with cancelled. If
message is not well-formed, the operation fails with
invalid-argument.
This is an asynchronous method. When the operation is finished,
callback will be invoked in the thread-default main context (see
main-context:push-thread-default) of the
thread you are calling this method from. You can then call
dbus-connection:send-message-with-reply-finish
to get the result of the operation. See dbus-connection:send-message-with-reply-sync
for the synchronous version.
Note that message must be unlocked, unless flags contain the
preserve-serial flag.
See this [server][class@Gio.DBusConnection#an-example-d-bus-server] and [client][class@Gio.DBusConnection#an-example-for-file-descriptor-passing] for an example of how to use this low-level API to send and receive UNIX file descriptors.
Passed: a <GDBusConnection>.
Passed: a <GDBusMessage>.
Passed: a <GDBusSendMessageFlags>, or
a list of its symbols, or one of them.
flags affecting how the message is sent
Passed: a 32-bit integer.
the timeout in milliseconds, -1 to use the default timeout or
G_MAXINT for no timeout
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable> or #f
Passed, or left out: a procedure, or #f.
a GAsyncReadyCallback to call when the
request is satisfied or #f if you don’t care about the result
See GAsyncReadyCallback for how it is
called.
Returned: an unsigned 32-bit integer.
return location for serial number assigned to message when sending
it or #f
Not passed: guile-gi supplies it.
The data to pass to callback
Finishes an operation started with dbus-connection:send-message-with-reply.
Note that error is only set if a local in-process error occurred.
That is to say that the returned
<GDBusMessage> object may be of type
error. Use dbus-message:to-gerror? to transcode this to a
<GError>.
See this [server][class@Gio.DBusConnection#an-example-d-bus-server] and [client][class@Gio.DBusConnection#an-example-for-file-descriptor-passing] for an example of how to use this low-level API to send and receive UNIX file descriptors.
Passed: a <GDBusConnection>.
Passed: a <GAsyncResult>.
a <GAsyncResult> obtained from the
GAsyncReadyCallback passed to
dbus-connection:send-message-with-reply
Returned: a <GDBusMessage>.
a locked <GDBusMessage> or #f if
error is set
Synchronously sends message to the peer represented by self
and blocks the calling thread until a reply is received or the timeout
is reached. See dbus-connection:send-message-with-reply for
the asynchronous version of this method.
Unless flags contain the
preserve-serial flag, the serial
number will be assigned by self and set on message via
dbus-message:set-serial. If
out-serial is not #f, then the serial number used will be
written to this location prior to submitting the message to the
underlying transport. While it has a volatile qualifier, this is
a historical artifact and the argument passed to it should not be
volatile.
If self is closed then the operation will fail with
closed. If cancellable is canceled, the
operation will fail with cancelled. If
message is not well-formed, the operation fails with
invalid-argument.
Note that error is only set if a local in-process error occurred.
That is to say that the returned
<GDBusMessage> object may be of type
error. Use dbus-message:to-gerror? to transcode this to a
<GError>.
See this [server][class@Gio.DBusConnection#an-example-d-bus-server] and [client][class@Gio.DBusConnection#an-example-for-file-descriptor-passing] for an example of how to use this low-level API to send and receive UNIX file descriptors.
Note that message must be unlocked, unless flags contain the
preserve-serial flag.
Passed: a <GDBusConnection>.
Passed: a <GDBusMessage>.
Passed: a <GDBusSendMessageFlags>, or
a list of its symbols, or one of them.
flags affecting how the message is sent.
Passed: a 32-bit integer.
the timeout in milliseconds, -1 to use the default timeout or
G_MAXINT for no timeout
Passed, or left out: a <GCancellable>, or
#f.
a <GCancellable> or #f
Returned: a <GDBusMessage>.
a locked <GDBusMessage> that is the reply to
message or #f if error is set
Returned: an unsigned 32-bit integer.
return location for serial number assigned to message when sending
it or #f
Sets whether the process should be terminated when self is closed
by the remote peer. See dbus-connection:exit-on-close for more details.
Note that this function should be used with care. Most modern UNIX
desktops tie the notion of a user session with the session bus, and
expect all of a user’s applications to quit when their bus connection
goes away. If you are setting exit-on-close to #f for the
shared session bus connection, you should make sure that your
application exits when the user session ends.
Passed: a <GDBusConnection>.
Passed: a boolean.
whether the process should be terminated when self is closed by the remote peer
Subscribes to signals on self and invokes callback whenever
the signal is received. Note that callback will be invoked in the
thread-default main context (see main-context:push-thread-default) of the
thread you are calling this method from.
If self is not a message bus connection, sender must be
#f.
If sender is a well-known name note that callback is invoked with the unique name for the owner of sender, not the well-known name as one would expect. This is because the message bus rewrites the name. As such, to avoid certain race conditions, users should be tracking the name owner of the well-known name and use that when processing the received signal.
If one of match-arg0-namespace or
match-arg0-path are given, arg0 is
interpreted as part of a namespace or path. The first argument of a
signal is matched against that part as specified by D-Bus.
If user-data-free-func is non-#f, it will be called (in the
thread-default main context of the thread you are calling this method
from) at some point after user-data is no longer needed. (It is
not guaranteed to be called synchronously when the signal is
unsubscribed from, and may be called after self has been
destroyed.)
As callback is potentially invoked in a different thread from
where it’s emitted, it’s possible for this to happen after
dbus-connection:signal-unsubscribe has been called
in another thread. Due to this, user-data should have a strong
reference which is freed with user-data-free-func, rather than
pointing to data whose lifecycle is tied to the signal subscription. For
example, if a <GObject> is used to store
the subscription ID from dbus-connection:signal-subscribe, a strong reference
to that <GObject> must be passed to
user-data, and object:unref
passed to user-data-free-func. You are responsible for breaking
the resulting reference count cycle by explicitly unsubscribing from the
signal when dropping the last external reference to the
<GObject>. Alternatively, a weak reference
may be used.
It is guaranteed that if you unsubscribe from a signal using
dbus-connection:signal-unsubscribe from the same
thread which made the corresponding dbus-connection:signal-subscribe call,
callback will not be invoked after dbus-connection:signal-unsubscribe returns.
The returned subscription identifier is an opaque value which is guaranteed to never be zero.
This function can never fail.
Passed: a <GDBusConnection>.
Passed: a string, or #f.
sender name to match on (unique or well-known name) or #f to
listen from all senders
Passed: a string, or #f.
D-Bus interface name to match on or #f to match on all interfaces
Passed: a string, or #f.
D-Bus signal name to match on or #f to match on all signals
Passed: a string, or #f.
object path to match on or #f to match on all object paths
Passed: a string, or #f.
contents of first string argument to match on or #f to match on
all kinds of arguments
Passed: a <GDBusSignalFlags>, or a list of
its symbols, or one of them.
<GDBusSignalFlags> describing how arg0 is
used in subscribing to the signal
Passed: a procedure.
callback to invoke when there is a signal matching the requested data
See GDBusSignalCallback for how it is
called.
Returned: an unsigned 32-bit integer.
a subscription identifier that can be used with
dbus-connection:signal-unsubscribe
Not passed: guile-gi supplies it.
user data to pass to callback
Not passed: guile-gi supplies it.
function to free user-data with when subscription is removed or
#f
See GDestroyNotify for how it is
called.
Unsubscribes from signals.
Note that there may still be D-Bus traffic to process (relating to this
signal subscription) in the current thread-default
<GMainContext> after this function has
returned. You should continue to iterate the
<GMainContext> until the
GDestroyNotify function passed to
dbus-connection:signal-subscribe is called, in order
to avoid memory leaks through callbacks queued on the
<GMainContext> after it’s stopped being
iterated. Alternatively, any idle source with a priority lower than
G_PRIORITY_DEFAULT that was scheduled after unsubscription, also
indicates that all resources of this subscription are released.
Passed: a <GDBusConnection>.
Passed: an unsigned 32-bit integer.
a subscription id obtained from dbus-connection:signal-subscribe
If self was created with
delay-message-processing, this method
starts processing messages. Does nothing on if self wasn’t
created with this flag or if the method has already been called.
Passed: a <GDBusConnection>.
Reverses the effect of a previous call to dbus-connection:export-action-group.
It is an error to call this function with an ID that wasn’t returned
from dbus-connection:export-action-group or to call it
with the same ID more than once.
Passed: a <GDBusConnection>.
the D-Bus connection
Passed: an unsigned 32-bit integer.
the ID from dbus-connection:export-action-group
Reverses the effect of a previous call to dbus-connection:export-menu-model.
It is an error to call this function with an ID that wasn’t returned
from dbus-connection:export-menu-model or to call it
with the same ID more than once.
Passed: a <GDBusConnection>.
Passed: an unsigned 32-bit integer.
the ID from dbus-connection:export-menu-model
Unregisters an object.
Passed: a <GDBusConnection>.
Passed: an unsigned 32-bit integer.
a registration id obtained from dbus-connection:register-object
Returned: a boolean.
#t if the object was unregistered, #f otherwise
Unregisters a subtree.
Passed: a <GDBusConnection>.
Passed: an unsigned 32-bit integer.
a subtree registration id obtained from
g_dbus_connection_register_subtree()
Returned: a boolean.
#t if the subtree was unregistered, #f otherwise
Connect a handler with (connect object dbus-connection:closed
handler). It is called as (handler self remote-peer-vanished
error).
Emitted when the connection is closed.
The cause of this event can be
dbus-connection:close is called.
In this case remote-peer-vanished is set to #f and
error is #f.
#t and error is set.
#f and error is set.
Upon receiving this signal, you should give up your reference to connection. You are guaranteed that this signal is emitted only once.
Passed: a <GDBusConnection>.
Passed: a boolean.
#t if connection is closed because the remote peer closed
its end of the connection
Passed: a <GError>, or #f.
a <GError> with more details about the event or
#f