U
    ÆZj…"  ã                   @   sÔ   d Z ddlmZ dZdZddlmZ ddlmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZ ddlmZ ddlmZ dd	lmZ er�dd
lmZ G dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZdS )z9Implementation for dbus.Bus. Not to be imported directly.é    )Ú
generators)ÚBusÚ	SystemBusÚ
SessionBusÚ
StarterBusZreStructuredText)ÚDBusException)ÚBUS_DAEMON_IFACEÚBUS_DAEMON_NAMEÚBUS_DAEMON_PATHÚBUS_SESSIONÚBUS_STARTERÚ
BUS_SYSTEMÚ DBUS_START_REPLY_ALREADY_RUNNINGÚDBUS_START_REPLY_SUCCESSÚvalidate_bus_nameÚvalidate_interface_nameÚvalidate_member_nameÚvalidate_object_path)ÚBusConnection)ÚSignalMessage)Úis_py2)Ú
UTF8Stringc                       sŽ   e Zd ZdZi Zejddfdd„Z‡ fdd„Zdd	„ Z	e
e	ddd
ƒZddd„ZeeƒZddd„ZeeƒZddd„ZeeƒZdd„ ZeZ‡  ZS )r   a   A connection to one of three possible standard buses, the SESSION,
    SYSTEM, or STARTER bus. This class manages shared connections to those
    buses.

    If you're trying to subclass `Bus`, you may be better off subclassing
    `BusConnection`, which doesn't have all this magic.
    FNc                 C   sv   |s|| j kr| j | S |tkr&t}n(|tkr4t}n|tkrBt}ntd| ƒ‚tj	|||d�}||_
|sr|| j |< |S )aË  Constructor, returning an existing instance where appropriate.

        The returned instance is actually always an instance of `SessionBus`,
        `SystemBus` or `StarterBus`.

        :Parameters:
            `bus_type` : cls.TYPE_SESSION, cls.TYPE_SYSTEM or cls.TYPE_STARTER
                Connect to the appropriate bus
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.

                :Deprecated: since 0.82.3. Use dbus.bus.BusConnection for
                    private connections.

            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        :Changed: in dbus-python 0.80:
            converted from a wrapper around a Connection to a Connection
            subclass.
        zinvalid bus_type %s)Úmainloop)Ú_shared_instancesr   r   r   r   r   r   Ú
ValueErrorr   Ú__new__Ú	_bus_type)ÚclsZbus_typeÚprivater   ÚsubclassZbus© r    úv/tmp/pip-install-y41owkxo/dbus-python_00acec02fc8440cb8a293f42bd5c4d44/build/lib.linux-x86_64-cpython-38/dbus/_dbus.pyr   <   s    

zBus.__new__c                    s4   | j }| jj |¡| kr"| jj|= tt| ƒ ¡  d S )N)r   Ú	__class__r   ÚgetÚsuperr   Úclose)ÚselfÚt©r"   r    r!   r%   o   s    
z	Bus.closec                 C   s   | S )zªReturn self, for backwards compatibility with earlier dbus-python
        versions where Bus was not a subclass of Connection.

        :Deprecated: since 0.80.0
        r    )r&   r    r    r!   Úget_connectionu   s    zBus.get_connectionz¹self._connection == self, for backwards
                           compatibility with earlier dbus-python versions
                           where Bus was not a subclass of Connection.c                 C   s
   t | d�S )z³Static method that returns a connection to the session bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        ©r   )r   r*   r    r    r!   Úget_session�   s    zBus.get_sessionc                 C   s
   t | d�S )z²Static method that returns a connection to the system bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        r*   )r   r*   r    r    r!   Ú
get_systemŒ   s    zBus.get_systemc                 C   s
   t | d�S )z³Static method that returns a connection to the starter bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        r*   )r   r*   r    r    r!   Úget_starter˜   s    zBus.get_starterc                 C   sP   | j tkrd}n$| j tkr d}n| j tkr0d}nd}d| jj| jj|t| ƒf S )NZsessionÚsystemZstarterzunknown bus typez<%s.%s (%s) at %#x>)r   r   r   r   r"   Ú
__module__Ú__name__Úid)r&   Únamer    r    r!   Ú__repr__£   s    


 þzBus.__repr__)F)F)F)r0   r/   Ú__qualname__Ú__doc__r   r   ÚTYPE_SESSIONr   r%   r)   ÚpropertyZ_connectionr+   Ústaticmethodr,   r-   r3   Ú__str__Ú__classcell__r    r    r(   r!   r   1   s$   ÿ
3ÿ
	
	
	r   c                   @   s   e Zd ZdZddd„ZdS )r   zThe system-wide message bus.FNc                 C   s   t j| t j||d�S )aÆ  Return a connection to the system bus.

        :Parameters:
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        )r   r   )r   r   ZTYPE_SYSTEM©r   r   r   r    r    r!   r   ·   s    ÿzSystemBus.__new__)FN©r0   r/   r4   r5   r   r    r    r    r!   r   µ   s   r   c                   @   s   e Zd ZdZddd„ZdS )r   z(The session (current login) message bus.FNc                 C   s   t j| t j||d�S )aÇ  Return a connection to the session bus.

        :Parameters:
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        ©r   r   )r   r   r6   r;   r    r    r!   r   È   s    ÿzSessionBus.__new__)FNr<   r    r    r    r!   r   Æ   s   r   c                   @   s   e Zd ZdZddd„ZdS )r   zjThe bus that activated this process (only valid if
    this process was launched by DBus activation).
    FNc                 C   s   t j| t j||d�S )aÛ  Return a connection to the bus that activated this process.

        :Parameters:
            `private` : bool
                If true, never return an existing shared instance, but instead
                return a private connection.
            `mainloop` : dbus.mainloop.NativeMainLoop
                The main loop to use. The default is to use the default
                main loop if one has been set up, or raise an exception
                if none has been.
        r=   )r   r   ZTYPE_STARTERr;   r    r    r!   r   Û   s    ÿzStarterBus.__new__)FNr<   r    r    r    r!   r   ×   s   r   N)r5   Z
__future__r   Ú__all__Z__docformat__Zdbus.exceptionsr   Z_dbus_bindingsr   r	   r
   r   r   r   r   r   r   r   r   r   Zdbus.busr   Zdbus.lowlevelr   Zdbus._compatr   r   r   r   r   r   r    r    r    r!   Ú<module>   s   8 