o
    t3b"                     @   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rHd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 v r| j | S |tkrt}n|tkrt}n|tkr!t}ntd| tj	|||d}||_
|s9|| 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    ,/usr/lib/python3/dist-packages/dbus/_dbus.pyr   <   s   

zBus.__new__c                    s4   | j }| jj|| u 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 )zReturn 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_connectionzself._connection == self, for backwards
                           compatibility with earlier dbus-python versions
                           where Bus was not a subclass of Connection.c                 C   
   t | dS )zStatic 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      
zBus.get_sessionc                 C   r*   )zStatic 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   r-   zBus.get_systemc                 C   r*   )zStatic 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   r-   zBus.get_starterc                 C   sP   | j tkrd}n| j tkrd}n
| j tkrd}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)r2   r1   __qualname____doc__r   r   TYPE_SESSIONr   r%   r)   propertyZ_connectionr,   staticmethodr.   r/   r5   __str____classcell__r    r    r(   r!   r   1   s&    
3
	
	
	r   c                   @      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         zSystemBus.__new__FNr2   r1   r6   r7   r   r    r    r    r!   r          r   c                   @   r=   )r   z(The session (current login) message bus.FNc                 C      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   r8   r>   r    r    r!   r      r?   zSessionBus.__new__r@   rA   r    r    r    r!   r      rB   r   c                   @   r=   )r   zjThe bus that activated this process (only valid if
    this process was launched by DBus activation).
    FNc                 C   rC   )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.
        rD   )r   r   ZTYPE_STARTERr>   r    r    r!   r      r?   zStarterBus.__new__r@   rA   r    r    r    r!   r      s    r   N)r7   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 