Blame docs/reference/gio/html/GDBusServer.html

Packit ae235b
Packit ae235b
<html>
Packit ae235b
<head>
Packit ae235b
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Packit ae235b
<title>GDBusServer: GIO Reference Manual</title>
Packit ae235b
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
Packit ae235b
<link rel="home" href="index.html" title="GIO Reference Manual">
Packit ae235b
<link rel="up" href="gdbus-lowlevel.html" title="Low-level D-Bus Support">
Packit ae235b
<link rel="prev" href="GDBusMethodInvocation.html" title="GDBusMethodInvocation">
Packit ae235b
<link rel="next" href="GDBusAuthObserver.html" title="GDBusAuthObserver">
Packit ae235b
<meta name="generator" content="GTK-Doc V1.27 (XML mode)">
Packit ae235b
<link rel="stylesheet" href="style.css" type="text/css">
Packit ae235b
</head>
Packit ae235b
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
Packit ae235b
Packit ae235b
Packit ae235b
Top  | 
Packit ae235b
                  Description  | 
Packit ae235b
                  Object Hierarchy  | 
Packit ae235b
                  Implemented Interfaces  | 
Packit ae235b
                  Properties  | 
Packit ae235b
                  Signals
Packit ae235b
Packit ae235b
Home
Packit ae235b
Up
Packit ae235b
Prev
Packit ae235b
Next
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

GDBusServer

Packit ae235b

GDBusServer — Helper for accepting connections

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GDBusServer *
Packit ae235b
Packit ae235b
Packit ae235b
g_dbus_server_new_sync ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_dbus_server_start ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_dbus_server_stop ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
Packit ae235b
Packit ae235b
g_dbus_server_is_active ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
const gchar *
Packit ae235b
Packit ae235b
Packit ae235b
g_dbus_server_get_guid ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GDBusServerFlags
Packit ae235b
Packit ae235b
Packit ae235b
g_dbus_server_get_flags ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
const gchar *
Packit ae235b
Packit ae235b
Packit ae235b
g_dbus_server_get_client_address ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Properties

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
active
Packit ae235b
Read
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gchar *
Packit ae235b
address
Packit ae235b
Read / Write / Construct Only
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GDBusAuthObserver *
Packit ae235b
authentication-observer
Packit ae235b
Read / Write / Construct Only
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gchar *
Packit ae235b
client-address
Packit ae235b
Read
Packit ae235b
Packit ae235b
Packit ae235b
GDBusServerFlags
Packit ae235b
flags
Packit ae235b
Read / Write / Construct Only
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gchar *
Packit ae235b
guid
Packit ae235b
Read / Write / Construct Only
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Signals

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
new-connection
Packit ae235b
Run Last
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
 
Packit ae235b
GDBusServer
Packit ae235b
Packit ae235b
Packit ae235b
enum
Packit ae235b
GDBusServerFlags
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Object Hierarchy

Packit ae235b
    GObject
Packit ae235b
    ╰── GDBusServer
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Implemented Interfaces

Packit ae235b

Packit ae235b
GDBusServer implements
Packit ae235b
 GInitable.

Packit ae235b
Packit ae235b
Packit ae235b

Includes

Packit ae235b
#include <gio/gio.h>
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Description

Packit ae235b

GDBusServer is a helper for listening to and accepting D-Bus

Packit ae235b
connections. This can be used to create a new D-Bus server, allowing two
Packit ae235b
peers to use the D-Bus protocol for their own specialized communication.
Packit ae235b
A server instance provided in this way will not perform message routing or
Packit ae235b
implement the org.freedesktop.DBus interface.

Packit ae235b

To just export an object on a well-known name on a message bus, such as the

Packit ae235b
session or system bus, you should instead use g_bus_own_name().

Packit ae235b

An example of peer-to-peer communication with G-DBus can be found

Packit ae235b
in gdbus-example-peer.c.

Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b

g_dbus_server_new_sync ()

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

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

Packit ae235b
address
Packit ae235b
 that works.

Packit ae235b

Once constructed, you can use g_dbus_server_get_client_address() to

Packit ae235b
get a D-Bus address string that clients can use to connect.

Packit ae235b

Connect to the “new-connection” signal to handle

Packit ae235b
incoming connections.

Packit ae235b

The returned GDBusServer isn't active - you have to start it with

Packit ae235b
g_dbus_server_start().

Packit ae235b

GDBusServer is used in this example.

Packit ae235b

This is a synchronous failable constructor. See

Packit ae235b
g_dbus_server_new() for the asynchronous version.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

address

Packit ae235b

A D-Bus address.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

flags

Packit ae235b

Flags from the GDBusServerFlags enumeration.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

guid

Packit ae235b

A D-Bus GUID.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

observer

Packit ae235b

A GDBusAuthObserver or NULL.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b

cancellable

Packit ae235b

A GCancellable or NULL.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b

error

Packit ae235b

Return location for server or NULL.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

A GDBusServer or NULL if error

Packit ae235b
is set. Free with
Packit ae235b
g_object_unref().

Packit ae235b
Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_dbus_server_start ()

Packit ae235b
void
Packit ae235b
g_dbus_server_start (GDBusServer *server);
Packit ae235b

Starts server

Packit ae235b
.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

server

Packit ae235b

A GDBusServer.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_dbus_server_stop ()

Packit ae235b
void
Packit ae235b
g_dbus_server_stop (GDBusServer *server);
Packit ae235b

Stops server

Packit ae235b
.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

server

Packit ae235b

A GDBusServer.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_dbus_server_is_active ()

Packit ae235b
gboolean
Packit ae235b
g_dbus_server_is_active (GDBusServer *server);
Packit ae235b

Gets whether server

Packit ae235b
 is active.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

server

Packit ae235b

A GDBusServer.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE if server is active, FALSE otherwise.

Packit ae235b
Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_dbus_server_get_guid ()

Packit ae235b
const gchar *
Packit ae235b
g_dbus_server_get_guid (GDBusServer *server);
Packit ae235b

Gets the GUID for server

Packit ae235b
.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

server

Packit ae235b

A GDBusServer.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

A D-Bus GUID. Do not free this string, it is owned by server

Packit ae235b
.

Packit ae235b
Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_dbus_server_get_flags ()

Packit ae235b
GDBusServerFlags
Packit ae235b
g_dbus_server_get_flags (GDBusServer *server);
Packit ae235b

Gets the flags for server

Packit ae235b
.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

server

Packit ae235b

A GDBusServer.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

A set of flags from the GDBusServerFlags enumeration.

Packit ae235b
Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_dbus_server_get_client_address ()

Packit ae235b
const gchar *
Packit ae235b
g_dbus_server_get_client_address (GDBusServer *server);
Packit ae235b

Gets a

Packit ae235b
D-Bus address
Packit ae235b
string that can be used by clients to connect to server
Packit ae235b
.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

server

Packit ae235b

A GDBusServer.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

A D-Bus address string. Do not free, the string is owned

Packit ae235b
by server
Packit ae235b
.

Packit ae235b
Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b

GDBusServer

Packit ae235b
typedef struct _GDBusServer GDBusServer;
Packit ae235b

The GDBusServer structure contains only private data and

Packit ae235b
should only be accessed using the provided API.

Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

enum GDBusServerFlags

Packit ae235b

Flags used when creating a GDBusServer.

Packit ae235b
Packit ae235b

Members

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

G_DBUS_SERVER_FLAGS_NONE

Packit ae235b
Packit ae235b

No flags set.

Packit ae235b
Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

G_DBUS_SERVER_FLAGS_RUN_IN_THREAD

Packit ae235b
Packit ae235b

All “new-connection”

Packit ae235b
signals will run in separated dedicated threads (see signal for
Packit ae235b
details).

Packit ae235b
Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS

Packit ae235b
Packit ae235b

Allow the anonymous

Packit ae235b
authentication method.

Packit ae235b
Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Property Details

Packit ae235b
Packit ae235b

The “active” property

Packit ae235b
  “active”                   gboolean
Packit ae235b

Whether the server is currently active.

Packit ae235b

Flags: Read

Packit ae235b

Default value: FALSE

Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

The “address” property

Packit ae235b
  “address”                  gchar *
Packit ae235b

The D-Bus address to listen on.

Packit ae235b

Flags: Read / Write / Construct Only

Packit ae235b

Default value: NULL

Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

The “authentication-observer” property

Packit ae235b
  “authentication-observer”  GDBusAuthObserver *
Packit ae235b

A GDBusAuthObserver object to assist in the authentication process or NULL.

Packit ae235b

Flags: Read / Write / Construct Only

Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

The “client-address” property

Packit ae235b
  “client-address”           gchar *
Packit ae235b

The D-Bus address that clients can use.

Packit ae235b

Flags: Read

Packit ae235b

Default value: NULL

Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

The “flags” property

Packit ae235b
  “flags”                    GDBusServerFlags
Packit ae235b

Flags from the GDBusServerFlags enumeration.

Packit ae235b

Flags: Read / Write / Construct Only

Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

The “guid” property

Packit ae235b
  “guid”                     gchar *
Packit ae235b

The guid of the server.

Packit ae235b

Flags: Read / Write / Construct Only

Packit ae235b

Default value: NULL

Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Signal Details

Packit ae235b
Packit ae235b

The “new-connection” signal

Packit ae235b
gboolean
Packit ae235b
user_function (GDBusServer     *server,
Packit ae235b
               GDBusConnection *connection,
Packit ae235b
               gpointer         user_data)
Packit ae235b

Emitted when a new authenticated connection has been made. Use

Packit ae235b
g_dbus_connection_get_peer_credentials() to figure out what
Packit ae235b
identity (if any), was authenticated.

Packit ae235b

If you want to accept the connection, take a reference to the

Packit ae235b
connection
Packit ae235b
 object and return TRUE. When you are done with the
Packit ae235b
connection call g_dbus_connection_close() and give up your
Packit ae235b
reference. Note that the other peer may disconnect at any time -
Packit ae235b
a typical thing to do when accepting a connection is to listen to
Packit ae235b
the “closed” signal.

Packit ae235b

If “flags” contains G_DBUS_SERVER_FLAGS_RUN_IN_THREAD

Packit ae235b
then the signal is emitted in a new thread dedicated to the
Packit ae235b
connection. Otherwise the signal is emitted in the
Packit ae235b
thread-default main context
Packit ae235b
of the thread that server
Packit ae235b
 was constructed in.

Packit ae235b

You are guaranteed that signal handlers for this signal runs

Packit ae235b
before incoming messages on connection
Packit ae235b
 are processed. This means
Packit ae235b
that it's suitable to call g_dbus_connection_register_object() or
Packit ae235b
similar from the signal handler.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

server

Packit ae235b

The GDBusServer emitting the signal.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

connection

Packit ae235b

A GDBusConnection for the new connection.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

user_data

Packit ae235b

user data set when the signal handler was connected.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE to claim connection

Packit ae235b
, FALSE to let other handlers
Packit ae235b
run.

Packit ae235b
Packit ae235b

Flags: Run Last

Packit ae235b

Since: 2.26

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Generated by GTK-Doc V1.27
Packit ae235b
</body>
Packit ae235b
</html>