DBusServer

open class DBusServer(val gioDBusServerPointer: <Error class: unknown class><<Error class: unknown class>>) : Initable(source)

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 func@Gio.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 class@Gio.DBusAuthObserver 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 G_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER flag to the server.

Skipped during bindings generation

  • method active: Property has no getter nor setter

  • method address: Property has no getter nor setter

  • method authentication-observer: Property has no getter nor setter

Since

2.26

Constructors

Link copied to clipboard
constructor(address: String, flags: DBusServerFlags, guid: String, observer: DBusAuthObserver? = null, cancellable: Cancellable? = null)

Creates a new D-Bus server that listens on the first address in

constructor(gioDBusServerPointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The D-Bus address that clients can use.

Link copied to clipboard

Flags from the #GDBusServerFlags enumeration.

Link copied to clipboard
val gioDBusServerPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open override val gioInitablePointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
abstract val gioProxyPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open val guid: String

The GUID of the server.

Functions

Link copied to clipboard
open fun connect(connection: IoStream, proxyAddress: ProxyAddress, cancellable: Cancellable? = null): <Error class: unknown class><IoStream>

Given @connection to communicate with a proxy (eg, a #GSocketConnection that is connected to the proxy server), this does the necessary handshake to connect to @proxy_address, and if required, wraps the #GIOStream to handle proxy payload.

Link copied to clipboard
open fun connectAsync(connection: IoStream, proxyAddress: ProxyAddress, cancellable: Cancellable? = null, callback: AsyncReadyCallback?)

Asynchronous version of g_proxy_connect().

Link copied to clipboard
open fun connectFinish(result: AsyncResult): <Error class: unknown class><IoStream>

See g_proxy_connect().

Link copied to clipboard
open fun init(cancellable: Cancellable? = null): <Error class: unknown class><Boolean>

Initializes the object implementing the interface.

Link copied to clipboard
open fun isActive(): Boolean

Gets whether @server is active.

Link copied to clipboard
fun onNewConnection(    connectFlags: <Error class: unknown class> = ConnectFlags(0u),     handler: (connection: DBusConnection) -> Boolean): <Error class: unknown class>

Emitted when a new authenticated connection has been made. Use g_dbus_connection_get_peer_credentials() to figure out what identity (if any), was authenticated.

Link copied to clipboard
open fun start()

Starts @server.

Link copied to clipboard
open fun stop()

Stops @server.

Link copied to clipboard

Some proxy protocols expect to be passed a hostname, which they will resolve to an IP address themselves. Others, like SOCKS4, do not allow this. This function will return false if @proxy is implementing such a protocol. When false is returned, the caller should resolve the destination hostname first, and then pass a #GProxyAddress containing the stringified IP address to g_proxy_connect() or g_proxy_connect_async().