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.Initable- Abstract: - 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 a- Gio.DBusAuthObserverthat only accepts connections that have successfully authenticated as the same user that is running the- Gio.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.DBusServeror- Noneif error is set. Free with- GObject.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- - None- Gio.DBusAuthObserver.- Connect to the - Gio.DBusServer- ::new-connectionsignal to handle incoming connections.- The returned - Gio.DBusServerisn’t active - you have to start it with- Gio.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: - str- Gets 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.DBusServerFlags- 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: - str- Gets the GUID for self. - New in version 2.26. 
 
- 
classmethod 
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 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 call- Gio.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 the- Gio.DBusConnection- ::closedsignal.- If - Gio.DBusServer- :flagscontains- Gio.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 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: - active- Type: - bool- Default Value: - False- Flags: - READABLE- Whether the server is currently active. - New in version 2.26. 
- 
Gio.DBusServer.props.address¶
- Name: - address- Type: - str- Default Value: - None- Flags: - READABLE,- WRITABLE,- CONSTRUCT_ONLY- The D-Bus address to listen on. - New in version 2.26. 
- 
Gio.DBusServer.props.authentication_observer¶
- Name: - authentication-observer- Type: - Gio.DBusAuthObserver- Default Value: - None- Flags: - READABLE,- WRITABLE,- CONSTRUCT_ONLY- A - Gio.DBusAuthObserverobject to assist in the authentication process or- None.- New in version 2.26. 
- 
Gio.DBusServer.props.client_address¶
- Name: - client-address- Type: - str- Default Value: - None- Flags: - READABLE- The D-Bus address that clients can use. - New in version 2.26. 
- 
Gio.DBusServer.props.flags¶
- Name: - flags- Type: - Gio.DBusServerFlags- Default Value: - Gio.DBusServerFlags.NONE- Flags: - READABLE,- WRITABLE,- CONSTRUCT_ONLY- Flags from the - Gio.DBusServerFlagsenumeration.- New in version 2.26.