
    @iaO"                         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  G d
 de      Z G d de      Z G d de      Z G d de      Zy)z9Implementation for dbus.Bus. Not to be imported directly.    )
generators)Bus	SystemBus
SessionBus
StarterBus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_py2c                        e Zd ZdZi Zej                  ddfdZ fdZd Z	 e
e	ddd      ZddZ ee      Zdd	Z ee      Zdd
Z ee      Zd ZeZ x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                     |s|| j                   v r| j                   |   S |t        k(  rt        }n.|t        k(  rt        }n|t
        k(  rt        }nt        d|z        t        j                  |||      }||_
        |s|| 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)clsbus_typeprivater   subclassbuss         ,/usr/lib/python3/dist-packages/dbus/_dbus.pyr   zBus.__new__9   s    2 H(=(==((22 {"!H# H$!H2X=>>##HhJ .1C!!(+
    c                     | j                   }| j                  j                  j                  |      | u r| j                  j                  |= t        t
        |           y )N)r   	__class__r   getsuperr   close)selftr(   s     r%   r+   z	Bus.closel   sH    NN>>++//2d:003c4 r&   c                     | 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,   s    r%   get_connectionzBus.get_connectionr   s	     r&   zself._connection == self, for backwards
                           compatibility with earlier dbus-python versions
                           where Bus was not a subclass of Connection.c                     t        |       S )zStatic method that returns a connection to the session bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        r"   )r   r2   s    r%   get_sessionzBus.get_session~        '**r&   c                     t        |       S )zStatic method that returns a connection to the system bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        r2   )r   r2   s    r%   
get_systemzBus.get_system   s     ))r&   c                     t        |       S )zStatic method that returns a connection to the starter bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        r2   )r   r2   s    r%   get_starterzBus.get_starter   r4   r&   c                     | 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z  S )Nsessionsystemstarterzunknown bus typez<%s.%s (%s) at %#x>)r   r   r   r   r(   
__module____name__id)r,   names     r%   __repr__zBus.__repr__   sn    >>[(D^^z)D^^{*D%D$(A(A(,(?(?(,bh(8 8 	8r&   )F)r>   r=   __qualname____doc__r   r   TYPE_SESSIONr   r+   r0   property_connectionr3   staticmethodr6   r8   rA   __str____classcell__)r(   s   @r%   r   r   .   s     +88%1f! >4JKK
+ {+K* j)J+ {+K8 Gr&   r   c                       e Zd ZdZddZy)r   zThe system-wide message bus.Nc                 P    t         j                  | t         j                  ||      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   TYPE_SYSTEMr    r"   r   s      r%   r   zSystemBus.__new__   s'     {{3(#*  , 	,r&   FNr>   r=   rB   rC   r   r/   r&   r%   r   r      s
    &,r&   r   c                       e Zd ZdZddZy)r   z(The session (current login) message bus.Nc                 P    t         j                  | t         j                  ||      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   rD   rM   s      r%   r   zSessionBus.__new__   )     {{3 0 0'$,  . 	.r&   rN   rO   r/   r&   r%   r   r      s
    2.r&   r   c                       e Zd ZdZddZy)r   zjThe bus that activated this process (only valid if
    this process was launched by DBus activation).
    Nc                 P    t         j                  | t         j                  ||      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.
        rR   )r   r   TYPE_STARTERrM   s      r%   r   zStarterBus.__new__   rS   r&   rN   rO   r/   r&   r%   r   r      s    .r&   r   N)rC   
__future__r   __all____docformat__dbus.exceptionsr	   _dbus_bindingsr
   r   r   r   r   r   r   r   r   r   r   r   dbus.busr   dbus.lowlevelr   dbus._compatr   r   r   r   r   r/   r&   r%   <module>r_      sp    ?: "
:" )I I I I
 # ' - H, ,". .". .r&   