U
    º±K^1  ã                   @   s4   d Z dZddlmZ ddlmZ G dd„ deƒZdS ))ÚServerZreStructuredTexté    )Ú_Server)Ú
Connectionc                       sf   e Zd ZdZeddf‡ fdd„	Zdd„ Zdd„ Zd	d
„ Zdd„ Z	e
ejƒZe
ejƒZe
ejƒZ‡  ZS )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| ƒ | ||||¡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ÚaddressZconnection_classZmainloopZauth_mechanisms©Ú	__class__© ú-/usr/lib/python3/dist-packages/dbus/server.pyr   +   s     ÿzServer.__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    zServer.__init__c                 C   s   |  | j¡ |  |¡ d S r   )Zcall_on_disconnectionÚconnection_removedÚconnection_added)r   Úconnr   r   r   Ú_on_new_connectionN   s    zServer._on_new_connectionc                 C   s   | j r| j D ]}||ƒ qdS )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   R   s    
zServer.connection_addedc                 C   s   | j r| j D ]}||ƒ qdS )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   c   s    
zServer.connection_removed)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   Úpropertyr   Zget_addressr   Zget_idÚidZget_is_connectedZis_connectedÚ__classcell__r   r   r	   r   r       s   
 ÿ

r   N)Ú__all__Z__docformat__Z_dbus_bindingsr   Zdbus.connectionr   r   r   r   r   r   Ú<module>   s   