Gio.DBusServer¶
| Subclasses: | None |
|---|
Methods¶
| Inherited: | GObject.Object (37), Gio.Initable (2) |
|---|---|
| Structs: | GObject.ObjectClass (5) |
| class | new_sync (address, flags, guid, observer, cancellable) |
get_client_address () |
|
get_flags () |
|
get_guid () |
|
is_active () |
|
start () |
|
stop () |
Virtual Methods¶
| Inherited: | GObject.Object (7), Gio.Initable (1) |
|---|
Properties¶
| Name | Type | Flags | Short Description |
|---|---|---|---|
active |
bool |
r | Whether the server is currently active |
address |
str |
r/w/co | The address to listen on |
authentication-observer |
Gio.DBusAuthObserver |
r/w/co | Object used to assist in the authentication process |
client-address |
str |
r | The address clients can use |
flags |
Gio.DBusServerFlags |
r/w/co | Flags for the server |
guid |
str |
r/w/co | The guid of the server |
Signals¶
| Inherited: | GObject.Object (1) |
|---|
| Name | Short Description |
|---|---|
new-connection |
Emitted when a new authenticated connection has been made. |
Fields¶
| Inherited: | GObject.Object (1) |
|---|
Class Details¶
-
class
Gio.DBusServer(**kwargs)¶ Bases: GObject.Object,Gio.InitableAbstract: No Gio.DBusServeris 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
Gio.bus_own_name().An example of peer-to-peer communication with G-DBus can be found in gdbus-example-peer.c.
Note that a minimal
Gio.DBusServerwill accept connections from any peer. In many use-cases it will be necessary to add aGio.DBusAuthObserverthat only accepts connections that have successfully authenticated as the same user that is running theGio.DBusServer.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 [gdbus-peer-to-peer]’.This is a synchronous failable constructor. There is currently no asynchronous version.
New in version 2.26.
- address (
-
get_client_address()[source]¶ Returns: A D-Bus address string. Do not free, the string is owned by self. Return type: strGets a D-Bus address string that can be used by clients to connect to self.
New in version 2.26.
-
get_flags()[source]¶ Returns: A set of flags from the Gio.DBusServerFlagsenumeration.Return type: Gio.DBusServerFlagsGets 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: strGets the GUID for self.
New in version 2.26.
-
classmethod
Signal Details¶
-
Gio.DBusServer.signals.new_connection(d_bus_server, connection)¶ Signal Name: new-connectionFlags: Parameters: - d_bus_server (
Gio.DBusServer) – The object which received the signal - connection (
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 thethread-default main contextof 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.
- d_bus_server (
Property Details¶
-
Gio.DBusServer.props.active¶ Name: activeType: boolDefault Value: FalseFlags: READABLEWhether the server is currently active.
New in version 2.26.
-
Gio.DBusServer.props.address¶ Name: addressType: strDefault Value: NoneFlags: READABLE,WRITABLE,CONSTRUCT_ONLYThe D-Bus address to listen on.
New in version 2.26.
-
Gio.DBusServer.props.authentication_observer¶ Name: authentication-observerType: Gio.DBusAuthObserverDefault Value: NoneFlags: READABLE,WRITABLE,CONSTRUCT_ONLYA
Gio.DBusAuthObserverobject to assist in the authentication process orNone.New in version 2.26.
-
Gio.DBusServer.props.client_address¶ Name: client-addressType: strDefault Value: NoneFlags: READABLEThe D-Bus address that clients can use.
New in version 2.26.
-
Gio.DBusServer.props.flags¶ Name: flagsType: Gio.DBusServerFlagsDefault Value: Gio.DBusServerFlags.NONEFlags: READABLE,WRITABLE,CONSTRUCT_ONLYFlags from the
Gio.DBusServerFlagsenumeration.New in version 2.26.