ó
æö/Nc           @   s@  d Z  d Z d d l Z d d l 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 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! d e e e f Z" d	 Z# e j$ d
 ƒ Z% d e& f d „  ƒ  YZ' d  e f d „  ƒ  YZ( d S(   t   BusConnectiont   reStructuredTextiÿÿÿÿN(   t   validate_interface_namet   validate_member_namet   validate_bus_namet   validate_object_patht   validate_error_namet   BUS_SESSIONt   BUS_STARTERt
   BUS_SYSTEMt   DBUS_START_REPLY_SUCCESSt    DBUS_START_REPLY_ALREADY_RUNNINGt   BUS_DAEMON_NAMEt   BUS_DAEMON_PATHt   BUS_DAEMON_IFACEt   NAME_FLAG_ALLOW_REPLACEMENTt   NAME_FLAG_DO_NOT_QUEUEt   NAME_FLAG_REPLACE_EXISTINGt   RELEASE_NAME_REPLY_NON_EXISTENTt   RELEASE_NAME_REPLY_NOT_OWNERt   RELEASE_NAME_REPLY_RELEASEDt    REQUEST_NAME_REPLY_ALREADY_OWNERt   REQUEST_NAME_REPLY_EXISTSt   REQUEST_NAME_REPLY_IN_QUEUEt    REQUEST_NAME_REPLY_PRIMARY_OWNER(   t
   Connection(   t   DBusException(   t   HANDLER_RESULT_NOT_YET_HANDLEDsW   type='signal',sender='%s',interface='%s',member='NameOwnerChanged',path='%s',arg0='%%s's)   org.freedesktop.DBus.Error.NameHasNoOwners   dbus.bust   NameOwnerWatchc           B   s    e  Z d Z d „  Z d „  Z RS(   t   _matcht   _pending_callc            sƒ   t  ˆ  ƒ ‡ f d †  } ‡  ‡ f d †  } | j | d t t t d ˆ  ƒ|  _ | j t t t d d ˆ  f ˆ | d t ƒ|  _ d  S(   Nc            s   ˆ  | ƒ d  S(   N(    (   t   ownedt	   old_ownert	   new_owner(   t   callback(    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt	   signal_cbF   s    c            sO   |  j  ƒ  t k r ˆ d ƒ n, t j ƒ  t j d ˆ  d |  j |  d  f ƒd  S(   Nt    s   GetNameOwner(%s) failed:t   exc_info(   t   get_dbus_namet   _NAME_HAS_NO_OWNERt   loggingt   basicConfigt   _loggert   debugt	   __class__t   None(   t   e(   t   bus_nameR"   (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt   error_cbI   s
    
t   NameOwnerChangedt   arg0t   GetNameOwnert   st   utf8_strings(	   R   t   add_signal_receiverR   R   R   R   t
   call_asynct   TrueR   (   t   selft   bus_connR/   R"   R#   R0   (    (   R/   R"   s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt   __init__C   s     
				c         C   sT   |  j  d  k	 r |  j  j ƒ  n  |  j d  k	 r> |  j j ƒ  n  d  |  _  d  |  _ d  S(   N(   R   R-   t   removeR   t   cancel(   R9   (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyR=   _   s    	(   s   _matchs   _pending_call(   t   __name__t
   __module__t	   __slots__R;   R=   (    (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyR   @   s   	c           B   sì   e  Z d  Z e Z e Z e Z e	 Z
 e Z e d d „ Z d d d d d „ Z d „  Z d „  Z e e d „ Z d „  Z d d „ Z d d	 „ Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! RS(   sx   A connection to a D-Bus daemon that implements the
    ``org.freedesktop.DBus`` pseudo-service.

    :Since: 0.81.0
    c         C   s1   |  j  | d | ƒ} t j ƒ  | _ i  | _ | S(   Nt   mainloop(   t   _new_for_bust   weakreft   WeakValueDictionaryt
   _bus_namest   _signal_sender_matches(   t   clst   address_or_typeRA   t   bus(    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt   __new__|   s    	c            s  | j  d d  ƒ } | d  k	 re | d  k	 r9 t d ƒ ‚ n  | } d d l m } | d t d d ƒn  t t |  ƒ j | | | | | |  ‰  | d  k	 rñ | t	 k rñ | d  d	 k rÆ ‡  f d
 †  }	 n	 ˆ  j
 }	 |  j | |	 ƒ }
 |
 |  j ˆ  <n  |  j t ˆ  ƒ ƒ ˆ  S(   Nt   named_services3   bus_name and named_service cannot both be specifiediÿÿÿÿ(   t   warnsr   Passing the named_service parameter to add_signal_receiver by name is deprecated: please use positional parameterst
   stackleveli   i   t   :c            s   |  d k r ˆ  j  ƒ  n  d  S(   NR$   (   R<   (   R!   (   t   match(    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyR"   ›   s    (   t   popR-   t	   TypeErrort   warningsRL   t   DeprecationWarningt   superR    R6   R   t   set_sender_name_ownert   watch_name_ownerRF   t   add_match_stringt   str(   R9   t   handler_functiont   signal_namet   dbus_interfaceR/   t   patht   keywordsRK   RL   R"   t   watch(    (   RO   s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyR6   ‡   s&    	c         C   sE   |  j  t | ƒ ƒ |  j j | d  ƒ } | d  k	 rA | j ƒ  n  d  S(   N(   t    remove_match_string_non_blockingRX   RF   RP   R-   R=   (   R9   RO   R^   (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt   _clean_up_signal_match§   s    c         C   s‰   | d  k	 r | d  d k r | t k r y |  j | ƒ SWq… t k
 r} } | j ƒ  t k rc ‚  n  |  j | ƒ |  j | ƒ SXn | Sd  S(   Ni   RN   (   R-   R   t   get_name_ownerR   R&   R'   t   start_service_by_name(   R9   R/   R.   (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt   activate_name_owner®   s    c         K   s¿   | r |  j  ƒ  n  | j d d ƒ } | d k	 rx | d k	 rL t d ƒ ‚ n  d d l m } | d t d d ƒ| } n  | r  t d d	 j | j ƒ  ƒ ƒ ‚ n  |  j	 |  | | d
 | d | ƒS(   sJ  Return a local proxy for the given remote object.

        Method calls on the proxy are translated into method calls on the
        remote object.

        :Parameters:
            `bus_name` : str
                A bus name (either the unique name or a well-known name)
                of the application owning the object. The keyword argument
                named_service is a deprecated alias for this.
            `object_path` : str
                The object path of the desired object
            `introspect` : bool
                If true (default), attempt to introspect the remote
                object to find out supported methods and their signatures
            `follow_name_owner_changes` : bool
                If the object path is a well-known name and this parameter
                is false (default), resolve the well-known name to the unique
                name of its current owner and bind to that instead; if the
                ownership of the well-known name changes in future,
                keep communicating with the original owner.
                This is necessary if the D-Bus API used is stateful.

                If the object path is a well-known name and this parameter
                is true, whenever the well-known name changes ownership in
                future, bind to the new owner, if any.

                If the given object path is a unique name, this parameter
                has no effect.

        :Returns: a `dbus.proxies.ProxyObject`
        :Raises `DBusException`: if resolving the well-known name to a
            unique name fails
        RK   s3   bus_name and named_service cannot both be specifiediÿÿÿÿ(   RL   si   Passing the named_service parameter to get_object by name is deprecated: please use positional parametersRM   i   s4   get_object does not take these keyword arguments: %ss   , t
   introspectt   follow_name_owner_changesN(
   t   _require_main_loopRP   R-   RQ   RR   RL   RS   t   joint   iterkeyst   ProxyObjectClass(   R9   R/   t   object_pathRd   Re   t   kwargsRK   RL   (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt
   get_object½   s     $	c         C   s)   t  | ƒ |  j t t t d d | f ƒ S(   sê   Get the numeric uid of the process owning the given bus name.

        :Parameters:
            `bus_name` : str
                A bus name, either unique or well-known
        :Returns: a `dbus.UInt32`
        :Since: 0.80.0
        t   GetConnectionUnixUserR4   (   R   t   call_blockingR   R   R   (   R9   R/   (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt   get_unix_userö   s    	
i    c      	   C   s2   t  | ƒ t |  j t t t d d | | f ƒ f S(   s?  Start a service which will implement the given bus name on this Bus.

        :Parameters:
            `bus_name` : str
                The well-known bus name to be activated.
            `flags` : dbus.UInt32
                Flags to pass to StartServiceByName (currently none are
                defined)

        :Returns: A tuple of 2 elements. The first is always True, the
            second is either START_REPLY_SUCCESS or
            START_REPLY_ALREADY_RUNNING.

        :Raises `DBusException`: if the service could not be started.
        :Since: 0.80.0
        t   StartServiceByNamet   su(   R   R8   Rn   R   R   R   (   R9   R/   t   flags(    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyRb     s
    
c         C   s2   t  | d t ƒ|  j t t t d d | | f ƒ S(   s„  Request a bus name.

        :Parameters:
            `name` : str
                The well-known name to be requested
            `flags` : dbus.UInt32
                A bitwise-OR of 0 or more of the flags
                `NAME_FLAG_ALLOW_REPLACEMENT`,
                `NAME_FLAG_REPLACE_EXISTING`
                and `NAME_FLAG_DO_NOT_QUEUE`
        :Returns: `REQUEST_NAME_REPLY_PRIMARY_OWNER`,
            `REQUEST_NAME_REPLY_IN_QUEUE`,
            `REQUEST_NAME_REPLY_EXISTS` or
            `REQUEST_NAME_REPLY_ALREADY_OWNER`
        :Raises `DBusException`: if the bus daemon cannot be contacted or
            returns an error.
        t   allow_uniquet   RequestNameRq   (   R   t   FalseRn   R   R   R   (   R9   t   nameRr   (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt   request_name  s    c         C   s/   t  | d t ƒ|  j t t t d d | f ƒ S(   ss  Release a bus name.

        :Parameters:
            `name` : str
                The well-known name to be released
        :Returns: `RELEASE_NAME_REPLY_RELEASED`,
            `RELEASE_NAME_REPLY_NON_EXISTENT`
            or `RELEASE_NAME_REPLY_NOT_OWNER`
        :Raises `DBusException`: if the bus daemon cannot be contacted or
            returns an error.
        Rs   t   ReleaseNameR4   (   R   Ru   Rn   R   R   R   (   R9   Rv   (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt   release_name4  s    c      	   C   s"   |  j  t t t d d d d t ƒS(   s‰   Return a list of all currently-owned names on the bus.

        :Returns: a dbus.Array of dbus.UTF8String
        :Since: 0.81.0
        t	   ListNamesR$   R5   (    (   Rn   R   R   R   R8   (   R9   (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt
   list_namesE  s    c      	   C   s"   |  j  t t t d d d d t ƒS(   s   Return a list of all names that can be activated on the bus.

        :Returns: a dbus.Array of dbus.UTF8String
        :Since: 0.81.0
        t   ListActivatableNamesR$   R5   (    (   Rn   R   R   R   R8   (   R9   (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt   list_activatable_namesO  s    c      	   C   s5   t  | d t ƒ|  j t t t d d | f d t ƒS(   s²   Return the unique connection name of the primary owner of the
        given name.

        :Raises `DBusException`: if the `bus_name` has no owner
        :Since: 0.81.0
        Rs   R3   R4   R5   (   R   Ru   Rn   R   R   R   R8   (   R9   R/   (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyRa   Y  s    c         C   s   t  |  | | ƒ S(   s  Watch the unique connection name of the primary owner of the
        given name.

        `callback` will be called with one argument, which is either the
        unique connection name, or the empty string (meaning the name is
        not owned).

        :Since: 0.81.0
        (   R   (   R9   R/   R"   (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyRV   e  s    
c         C   s%   t  |  j t t t d d | f ƒ ƒ S(   s»   Return True iff the given bus name has an owner on this bus.

        :Parameters:
            `bus_name` : str
                The bus name to look up
        :Returns: a `bool`
        t   NameHasOwnerR4   (   t   boolRn   R   R   R   (   R9   R/   (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt   name_has_ownerq  s    c         C   s#   |  j  t t t d d | f ƒ d S(   s  Arrange for this application to receive messages on the bus that
        match the given rule. This version will block.

        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        t   AddMatchR4   N(   Rn   R   R   R   (   R9   t   rule(    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyRW   }  s    
c      	   C   s)   |  j  t t t d d | f d d ƒ d S(   s=  Arrange for this application to receive messages on the bus that
        match the given rule. This version will not block, but any errors
        will be ignored.


        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        R   R4   N(   R7   R   R   R   R-   (   R9   R‚   (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt   add_match_string_non_blockingŒ  s    c         C   s#   |  j  t t t d d | f ƒ d S(   s  Arrange for this application to receive messages on the bus that
        match the given rule. This version will block.

        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        t   RemoveMatchR4   N(   Rn   R   R   R   (   R9   R‚   (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt   remove_match_stringœ  s    
c      	   C   s)   |  j  t t t d d | f d d ƒ d S(   s=  Arrange for this application to receive messages on the bus that
        match the given rule. This version will not block, but any errors
        will be ignored.


        :Parameters:
            `rule` : str
                The match rule
        :Raises `DBusException`: on error.
        :Since: 0.80.0
        R„   R4   N(   R7   R   R   R   R-   (   R9   R‚   (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyR_   ©  s    N("   R>   R?   t   __doc__R   t   TYPE_SESSIONR	   t   TYPE_SYSTEMR   t   TYPE_STARTERR
   t   START_REPLY_SUCCESSR   t   START_REPLY_ALREADY_RUNNINGR-   RJ   R6   R`   Rc   R8   Ru   Rl   Ro   Rb   Rw   Ry   R{   R}   Ra   RV   R€   RW   Rƒ   R…   R_   (    (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyR    h   s6   		8			
	
						(   s   BusConnection()   t   __all__t   __docformat__R(   RC   t   _dbus_bindingsR   R   R   R   R   R   R   R	   R
   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   dbus.connectionR   t   dbus.exceptionsR   t   dbus.lowlevelR   t   _NAME_OWNER_CHANGE_MATCHR'   t	   getLoggerR*   t   objectR   R    (    (    (    s,   /usr/lib/python2.7/dist-packages/dbus/bus.pyt   <module>   s   ”
(