Gio.DBusServer¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r |
|||
r/w/co |
|||
r/w/co |
|||
r |
|||
r/w/co |
|||
r/w/co |
Signals¶
- Inherited:
Name |
Short Description |
|---|---|
Emitted when a new authenticated connection has been made. |
Fields¶
- Inherited:
Class Details¶
- class Gio.DBusServer(**kwargs)¶
- Bases:
- Abstract:
No
GDBusServeris 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
GDBusServerwill 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 theGDBusServer. Since GLib 2.68 this can be achieved more simply by passing theG_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USERflag to the server.New in version 2.26.
- classmethod new_sync(address, flags, guid, observer, cancellable)[source]¶
- Parameters:
address (
str) – A D-Bus address.flags (
Gio.DBusServerFlags) – Flags from theGio.DBusServerFlagsenumeration.guid (
str) – A D-Bus GUID.observer (
Gio.DBusAuthObserverorNone) – AGio.DBusAuthObserverorNone.cancellable (
Gio.CancellableorNone) – AGio.CancellableorNone.
- Raises:
- Returns:
A
Gio.DBusServerorNoneif error is set. Free withGObject.Object.unref().- Return type:
Creates a new D-Bus server that listens on the first address in address that works.
Once constructed, you can use
Gio.DBusServer.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-
NoneGio.DBusAuthObserver.Connect to the
Gio.DBusServer::new-connectionsignal to handle incoming connections.The returned
Gio.DBusServerisn’t active - you have to start it withGio.DBusServer.start().Gio.DBusServeris used in this example.This is a synchronous failable constructor. There is currently no asynchronous version.
New in version 2.26.
- get_client_address()[source]¶
- Returns:
A D-Bus address string. Do not free, the string is owned by self.
- Return type:
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
Gio.DBusServersucceeded.New in version 2.26.
- get_flags()[source]¶
- Returns:
A set of flags from the
Gio.DBusServerFlagsenumeration.- Return type:
Gets the flags for self.
New in version 2.26.
- get_guid()[source]¶
- Returns:
A D-Bus GUID. Do not free this string, it is owned by self.
- Return type:
Gets the GUID for self, as provided to
Gio.DBusServer.new_sync().New in version 2.26.
Signal Details¶
- Gio.DBusServer.signals.new_connection(d_bus_server, connection)¶
- Signal Name:
new-connection- Flags:
- Parameters:
d_bus_server (
Gio.DBusServer) – The object which received the signalconnection (
Gio.DBusConnection) – AGio.DBusConnectionfor the new connection.
- Returns:
- Return type:
Emitted when a new authenticated connection has been made. Use
Gio.DBusConnection.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
True. When you are done with the connection callGio.DBusConnection.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 theGio.DBusConnection::closedsignal.If
Gio.DBusServer:flagscontainsGio.DBusServerFlags.RUN_IN_THREADthen the signal is emitted in a new thread dedicated to the connection. Otherwise the signal is emitted in the thread-default main context (see [method`GLib`.MainContext.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
Gio.DBusConnection.register_object() or similar from the signal handler.New in version 2.26.
Property Details¶
- Gio.DBusServer.props.active¶
-
Whether the server is currently active.
New in version 2.26.
- Gio.DBusServer.props.address¶
- Name:
address- Type:
- Default Value:
- Flags:
The D-Bus address to listen on.
New in version 2.26.
- Gio.DBusServer.props.authentication_observer¶
- Name:
authentication-observer- Type:
- Default Value:
- Flags:
A
Gio.DBusAuthObserverobject to assist in the authentication process orNone.New in version 2.26.
- Gio.DBusServer.props.client_address¶
-
The D-Bus address that clients can use.
New in version 2.26.
- Gio.DBusServer.props.flags¶
- Name:
flags- Type:
- Default Value:
- Flags:
Flags from the
Gio.DBusServerFlagsenumeration.New in version 2.26.
- Gio.DBusServer.props.guid¶
- Name:
guid- Type:
- Default Value:
- Flags:
The GUID of the server.
See
Gio.DBusConnection:guidfor more details.New in version 2.26.