3
iR�V � @ s4 dZ dZddlmZ ddlmZ G dd � d e�ZdS )�ServerZreStructuredText� )�_Server)�
Connectionc sf e Zd ZdZeddf� fdd� Zdd� Zdd� Zd d
� Zdd� Z e
ej�Z
e
ej�Ze
ej�Z� ZS )
r a% An opaque object representing a server that listens for connections from
other applications.
This class is not useful to instantiate directly: you must subclass it and
either extend the method connection_added, or append to the
list on_connection_added.
:Since: 0.83
Nc s t t| �j| ||||�S )a� Construct a new Server.
:Parameters:
`address` : str
Listen on this address.
`connection_class` : type
When new connections come in, instantiate this subclass
of dbus.connection.Connection to represent them.
The default is Connection.
`mainloop` : dbus.mainloop.NativeMainLoop or None
The main loop with which to associate the new connections.
`auth_mechanisms` : sequence of str
Authentication mechanisms to allow. The default is to allow
any authentication mechanism supported by ``libdbus``.
)�superr �__new__)�cls�addressZconnection_classZmainloopZauth_mechanisms)� __class__� �/usr/lib64/python3.6/server.pyr ) s zServer.__new__c O s i | _ g | _g | _d S )N)Z_Server__connections�on_connection_added�on_connection_removed)�self�args�kwargsr
r
r �__init__= s zServer.__init__c C s |j | j� | j|� d S )N)Zcall_on_disconnection�connection_removed�connection_added)r �connr
r
r �_on_new_connectionL s zServer._on_new_connectionc C s" | j rx| j D ]}||� qW dS )a� Respond to the creation of a new Connection.
This base-class implementation just invokes the callbacks in
the on_connection_added attribute.
:Parameters:
`conn` : dbus.connection.Connection
A D-Bus connection which has just been added.
The type of this parameter is whatever was passed
to the Server constructor as the ``connection_class``.
N)r )r r �cbr
r
r r P s
zServer.connection_addedc C s" | j rx| j D ]}||� qW dS )a� Respond to the disconnection of a Connection.
This base-class implementation just invokes the callbacks in
the on_connection_removed attribute.
:Parameters:
`conn` : dbus.connection.Connection
A D-Bus connection which has just become disconnected.
The type of this parameter is whatever was passed
to the Server constructor as the ``connection_class``.
N)r
)r r r r
r
r r a s
zServer.connection_removed)�__name__�
__module__�__qualname__�__doc__r r r r r r �propertyr Zget_addressr Zget_id�idZget_is_connectedZis_connected�
__classcell__r
r
)r r r s
N)r )�__all__Z
__docformat__Z_dbus_bindingsr Zdbus.connectionr r r
r
r
r �