It derives from <GObject>.
<GDBusServer> is a helper for listening to and
accepting D-Bus connections. This can be used to create a new D-Bus
server, allowing two peers to use the D-Bus protocol for their own
specialized communication. A server instance provided in this way will
not perform message routing or implement the
‘org.freedesktop.DBus‘
interface.
To just export an object on a well-known name on a message bus, such as
the session or system bus, you should instead use
bus-own-name.
An example of peer-to-peer communication with GDBus can be found in gdbus-example-peer.c.
Note that a minimal <GDBusServer> will accept
connections from any peer. In many use-cases it will be necessary to
add a <GDBusAuthObserver> that only
accepts connections that have successfully authenticated as the same
user that is running the <GDBusServer>. Since
GLib 2.68 this can be achieved more simply by passing the
authentication-require-same-user flag to
the server.
Whether the server is currently active.
Its value is a boolean.
It is read only.
The D-Bus address to listen on.
Its value is a string, or #f.
It can only be set when the object is made, with #:address.
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.
The D-Bus address that clients can use.
Its value is a string, or #f.
It is read only.
Flags from the <GDBusServerFlags>
enumeration.
Its value is a <GDBusServerFlags> (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 server.
See dbus-connection:guid for
more details.
Its value is a string, or #f.
It can only be set when the object is made, with #:guid.
Gets a D-Bus address string that can be used by clients to connect to self.
This is valid and non-empty if initializing the
<GDBusServer> succeeded.
Passed: a <GDBusServer>.
Returned: a string.
A D-Bus address string. Do not free, the string is owned by self.
Gets the flags for self.
Passed: a <GDBusServer>.
Returned: a <GDBusServerFlags>.
A set of flags from the <GDBusServerFlags>
enumeration.
Gets the GUID for self, as provided to dbus-server:new-sync.
Passed: a <GDBusServer>.
Returned: a string.
A D-Bus GUID. Do not free this string, it is owned by self.
Gets whether self is active.
Passed: a <GDBusServer>.
Returned: a boolean.
#t if server is active, #f otherwise.
Creates a new D-Bus server that listens on the first address in address that works.
Once constructed, you can use dbus-server:get-client-address to get a D-Bus
address string that clients can use to connect.
To have control over the available authentication mechanisms and the
users that are authorized to connect, it is strongly recommended to
provide a non-#f
<GDBusAuthObserver>.
Connect to the dbus-server:new-connection signal to handle incoming
connections.
The returned <GDBusServer> isn’t active - you
have to start it with dbus-server:start.
<GDBusServer> is used in this
example.
This is a synchronous failable constructor. There is currently no asynchronous version.
Passed: a string.
A D-Bus address.
Passed: a <GDBusServerFlags>, or a list of
its symbols, or one of them.
Flags from the <GDBusServerFlags>
enumeration.
Passed: a string.
A D-Bus GUID.
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 <GDBusServer>.
A <GDBusServer> or #f if error is
set. Free with object:unref.
Starts self.
Passed: a <GDBusServer>.
Stops self.
Passed: a <GDBusServer>.
Connect a handler with (connect object dbus-server:new-connection
handler). It is called as (handler self connection) ⇒ %return.
Emitted when a new authenticated connection has been made. Use
dbus-connection:get-peer-credentials to figure
out what identity (if any), was authenticated.
If you want to accept the connection, take a reference to the
connection object and return #t. When you are done with
the connection call dbus-connection:close and give up your reference. Note that
the other peer may disconnect at any time - a typical thing to do when
accepting a connection is to listen to the dbus-connection:closed signal.
If dbus-server:flags contains
run-in-thread then the signal is emitted
in a new thread dedicated to the connection. Otherwise the signal is
emitted in the thread-default main context (see main-context:push-thread-default) of the
thread that server was constructed in.
You are guaranteed that signal handlers for this signal runs before
incoming messages on connection are processed. This means that
it’s suitable to call dbus-connection:register-object or similar from the
signal handler.
Passed: a <GDBusServer>.
Passed: a <GDBusConnection>.
A <GDBusConnection> for the new connection.
Returned: a boolean.
#t to claim connection, #f to let other handlers
run.