Constructor

GioDBusServernew_sync

since: 2.26

Declaration [src]

GDBusServer*
g_dbus_server_new_sync (
  const gchar* address,
  GDBusServerFlags flags,
  const gchar* guid,
  GDBusAuthObserver* observer,
  GCancellable* cancellable,
  GError** error
)

Description [src]

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

Once constructed, you can use g_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-NULL GDBusAuthObserver.

Connect to the GDBusServer::new-connection signal to handle incoming connections.

The returned GDBusServer isn’t active - you have to start it with g_dbus_server_start().

GDBusServer is used in this [example][gdbus-peer-to-peer].

This is a synchronous failable constructor. There is currently no asynchronous version.

Available since: 2.26

Parameters

address

Type: const gchar*

A D-Bus address.

The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.
flags

Type: GDBusServerFlags

Flags from the GDBusServerFlags enumeration.

guid

Type: const gchar*

A D-Bus GUID.

The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.
observer

Type: GDBusAuthObserver

A GDBusAuthObserver or NULL.

The argument can be NULL.
The data is owned by the caller of the function.
cancellable

Type: GCancellable

A GCancellable or NULL.

The argument can be NULL.
The data is owned by the caller of the function.
error

Type: GError **

The return location for a recoverable error.

The argument can be NULL.
If the return location is not NULL, then you must initialize it to a NULL GError*.
The argument will be left initialized to NULL by the constructor if there are no errors.
In case of error, the argument will be set to a newly allocated GError; the caller will take ownership of the data, and be responsible for freeing it.

Return value

Type: GDBusServer

A GDBusServer or NULL if error is set. Free with g_object_unref().

The caller of the function takes ownership of the data, and is responsible for freeing it.