ó
-È"Oc           @   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 n  d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   s9   Implementation for dbus.Bus. Not to be imported directly.iÿÿÿÿ(   t
   generatorst   Bust	   SystemBust
   SessionBust
   StarterBust   reStructuredText(   t   DBusException(   t   BUS_DAEMON_IFACEt   BUS_DAEMON_NAMEt   BUS_DAEMON_PATHt   BUS_SESSIONt   BUS_STARTERt
   BUS_SYSTEMt    DBUS_START_REPLY_ALREADY_RUNNINGt   DBUS_START_REPLY_SUCCESSt   validate_bus_namet   validate_interface_namet   validate_member_namet   validate_object_path(   t   BusConnection(   t   SignalMessage(   t   is_py2(   t
   UTF8Stringc           B   s§   e  Z d  Z i  Z e j e d	 d „ Z d „  Z	 d „  Z
 e e
 d	 d	 d ƒ Z e d „ Z e e ƒ Z e d „ Z e e ƒ Z e d „ Z e e ƒ Z d „  Z e Z RS(
   s   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.
    c         C   s«   | r! | |  j  k r! |  j  | S| t k r6 t } n: | t k rK t } n% | t k r` t } n t d | ƒ ‚ t j	 | | d | ƒ} | | _
 | s§ | |  j  | <n  | S(   sË  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.
        s   invalid bus_type %st   mainloop(   t   _shared_instancesR
   R   R   R   R   R   t
   ValueErrorR   t   __new__t	   _bus_type(   t   clst   bus_typet   privateR   t   subclasst   bus(    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   :   s    				c         C   sK   |  j  } |  j j j | ƒ |  k r4 |  j j | =n  t t |  ƒ j ƒ  d  S(   N(   R   t	   __class__R   t   gett   superR   t   close(   t   selft   t(    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR$   m   s    	c         C   s   |  S(   sª   Return self, for backwards compatibility with earlier dbus-python
        versions where Bus was not a subclass of Connection.

        :Deprecated: since 0.80.0
        (    (   R%   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyt   get_connections   s    s¹   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(   s³   Static method that returns a connection to the session bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        R   (   R   (   R   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyt   get_session   s    c         C   s   t  d |  ƒ S(   s²   Static method that returns a connection to the system bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        R   (   R   (   R   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyt
   get_systemŠ   s    c         C   s   t  d |  ƒ S(   s³   Static method that returns a connection to the starter bus.

        :Parameters:
            `private` : bool
                If true, do not return a shared connection.
        R   (   R   (   R   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyt   get_starter–   s    c         C   st   |  j  t k r d } n6 |  j  t k r0 d } n |  j  t k rH d } n d } d |  j j |  j j | t |  ƒ f S(   Nt   sessiont   systemt   starters   unknown bus types   <%s.%s (%s) at %#x>(   R   R
   R   R   R!   t
   __module__t   __name__t   id(   R%   t   name(    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyt   __repr__¡   s    				N(   R/   R.   t   __doc__R   R   t   TYPE_SESSIONt   Falset   NoneR   R$   R'   t   propertyt   _connectionR(   t   staticmethodR)   R*   R2   t   __str__(    (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   /   s    	2							c           B   s   e  Z d  Z e d d „ Z RS(   s   The system-wide message bus.c         C   s   t  j |  t  j d | d | ƒS(   sÆ  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   t   TYPE_SYSTEM(   R   R   R   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   µ   s    N(   R/   R.   R3   R5   R6   R   (    (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   ³   s   c           B   s   e  Z d  Z e d d „ Z RS(   s(   The session (current login) message bus.c         C   s   t  j |  t  j d | d | ƒS(   sÇ  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   R4   (   R   R   R   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   Æ   s    N(   R/   R.   R3   R5   R6   R   (    (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   Ä   s   c           B   s   e  Z d  Z e d d „ Z RS(   sj   The bus that activated this process (only valid if
    this process was launched by DBus activation).
    c         C   s   t  j |  t  j d | d | ƒS(   sÛ  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   R   t   TYPE_STARTER(   R   R   R   (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   Ù   s    N(   R/   R.   R3   R5   R6   R   (    (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyR   Õ   s   N(   s   Buss	   SystemBuss
   SessionBuss
   StarterBus(   R3   t
   __future__R    t   __all__t   __docformat__t   dbus.exceptionsR   t   _dbus_bindingsR   R   R	   R
   R   R   R   R   R   R   R   R   t   dbus.busR   t   dbus.lowlevelR   t   dbus._compatR   R   R   R   R   R   (    (    (    s.   /usr/lib/python2.7/dist-packages/dbus/_dbus.pyt   <module>   s   R„