ó
æö/Nc           @   s!  d  d l  Z  d  d l Z y d  d l m Z Wn! e k
 rO d  d l m Z n Xd  d l Z d  d l m Z d  d l	 m
 Z
 m Z m Z m Z d Z e j d ƒ Z d  d l m Z m Z m Z m Z m Z d f  d	 „  ƒ  YZ d
 f  d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   RLock(   t   process_introspection_data(   t   MissingReplyHandlerExceptiont   MissingErrorHandlerExceptiont   IntrospectionParserExceptiont   DBusExceptiont   restructuredtexts   dbus.proxies(   t
   LOCAL_PATHt   BUS_DAEMON_NAMEt   BUS_DAEMON_PATHt   BUS_DAEMON_IFACEt   INTROSPECTABLE_IFACEt   _DeferredMethodc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   sX   A proxy method which will only get called once we have its
    introspection reply.
    c         C   s+   | |  _  | j |  _ | |  _ | |  _ d  S(   N(   t   _proxy_methodt   _method_namet   _appendt   _block(   t   selft   proxy_methodt   appendt   block(    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyt   __init__4   s    		c         O   sY   | j  d ƒ s! | j d t ƒ r; |  j |  j | | ƒ d  S|  j ƒ  |  j | | Ž  Sd  S(   Nt   reply_handlert   ignore_reply(   t   has_keyt   gett   FalseR   R   t   NoneR   (   R   t   argst   keywords(    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyt   __call__;   s    
c         O   s   |  j  |  j | | ƒ d  S(   N(   R   R   (   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyt
   call_asyncF   s    (   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyR   0   s   		t   _ProxyMethodc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s°   A proxy method.

    Typically a member of a ProxyObject. Calls to the
    method produce messages that travel over the Bus and are routed
    to a specific named Service.
    c         C   s‚   | t  k r t d t  ƒ ‚ n  | |  _ | |  _ | |  _ | |  _ t j | ƒ | |  _ | d  k	 ru t j
 | ƒ n  | |  _ d  S(   Ns1   Methods may not be called on the reserved path %s(   R   R   t   _proxyt   _connectiont   _named_servicet   _object_patht   _dbus_bindingst   validate_member_nameR   R   t   validate_interface_namet   _dbus_interface(   R   t   proxyt
   connectiont   bus_namet   object_patht   method_namet   iface(    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyR   Q   s    					c   	      O   s‚  | j  d d  ƒ } | j  d d  ƒ } | j  d t ƒ } | j  d d  ƒ } | d  k	 s` | d  k	 r¨ | d  k rx t ƒ  ‚ q¨ | d  k r t ƒ  ‚ q¨ | r¨ t d ƒ ‚ q¨ n  | j  d |  j ƒ } | d  k r| d  k rá |  j } n | d |  j } |  j j	 j
 | d  ƒ } n  | s| d  k	 rS|  j j |  j |  j | |  j | | | | |  n+ |  j j |  j |  j | |  j | | |  Sd  S(   NR   t   error_handlerR   t	   signatures6   ignore_reply and reply_handler cannot be used togethert   dbus_interfacet   .(   t   popR   R   R   R   t	   TypeErrorR+   R   R$   t   _introspect_method_mapR   R%   R   R&   R'   t   call_blocking(	   R   R   R   R   R2   R   R3   R4   t   key(    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyR   e   sD    
c      
   O   sÊ   | j  d d  ƒ } | j  d d  ƒ } | j  d d  ƒ } | j  d |  j ƒ } | d  k r• | rq | d |  j } n	 |  j } |  j j j | d  ƒ } n  |  j j |  j	 |  j
 | |  j | | | | |  d  S(   NR   R2   R3   R4   R5   (   R6   R   R+   R   R$   R8   R   R%   R   R&   R'   (   R   R   R   R   R2   R3   R4   R:   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyR   ‘   s$    	(   R    R!   R"   R   R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyR#   J   s   		,t   ProxyObjectc           B   sò   e  Z d  Z e Z e Z d Z d Z d Z	 d d d e e d „ Z e d „  d d d ƒ Z e d „  d d d ƒ Z e d	 „  d d d
 ƒ Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z d „  Z e Z RS(   s£   A proxy to the remote Object.

    A ProxyObject is provided by the Bus. ProxyObjects
    have member functions, and can be called like normal Python objects.
    i    i   i   c   
      K   sÖ  | j  d d ƒ } | d k	 re | d k	 r9 t d ƒ ‚ n  | } d d l m } | d t d d ƒn  | j  d d ƒ }	 |	 d k	 rÊ | d k	 rž t d	 ƒ ‚ n  |	 } d d l m } | d
 t d d ƒn  | rò t d d j | j ƒ  ƒ ƒ ‚ n  | r| j ƒ  n  | |  _	 | d k	 r*t
 j | ƒ n  | |  _ |  _ t
 j | ƒ | |  _ | sk| j | ƒ |  _ n  d |  _ g  |  _ i  |  _ t ƒ  |  _ | s¨|  j t k r·|  j |  _ n |  j |  _ |  j ƒ  |  _ d S(   sø  Initialize the proxy object.

        :Parameters:
            `conn` : `dbus.connection.Connection`
                The bus or connection on which to find this object.
                The keyword argument `bus` is a deprecated alias for this.
            `bus_name` : str
                A bus name for the application owning the object, to be used
                as the destination for method calls and the sender for
                signal matches. The keyword argument ``named_service`` is a
                deprecated alias for this.
            `object_path` : str
                The object path at which the application exports the 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 true (default is false) and the `bus_name` is a
                well-known name, follow ownership changes for that name
        t   buss%   conn and bus cannot both be specifiediÿÿÿÿ(   t   warns`   Passing the bus parameter to ProxyObject by name is deprecated: please use positional parameterst
   stackleveli   t   named_services3   bus_name and named_service cannot both be specifiedsj   Passing the named_service parameter to ProxyObject by name is deprecated: please use positional parameterss>   ProxyObject.__init__ does not take these keyword arguments: %ss   , N(   R6   R   R7   t   warningsR=   t   DeprecationWarningt   joint   iterkeyst   _require_main_loopt   _busR(   t   validate_bus_nameR&   t   _requested_bus_namet   validate_object_patht   __dbus_object_path__t   activate_name_ownert   _pending_introspectt   _pending_introspect_queueR8   R    t   _introspect_lockR   t    INTROSPECT_STATE_DONT_INTROSPECTt   _introspect_statet'   INTROSPECT_STATE_INTROSPECT_IN_PROGRESSt   _Introspect(
   R   t   connR.   R/   t
   introspectt   follow_name_owner_changest   kwargsR<   R=   R?   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyR   ·   sJ    					c         C   s   |  j  S(   N(   R&   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyt   <lambda>
  s    sè  The bus name to which this proxy is bound. (Read-only,
            may change.)

            If the proxy was instantiated using a unique name, this property
            is that unique name.

            If the proxy was instantiated with a well-known name and with
            ``follow_name_owner_changes`` set false (the default), this
            property is the unique name of the connection that owned that
            well-known name when the proxy was instantiated, which might
            not actually own the requested well-known name any more.

            If the proxy was instantiated with a well-known name and with
            ``follow_name_owner_changes`` set true, this property is that
            well-known name.
            c         C   s   |  j  S(   N(   RG   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyRV     s    s[   The bus name which was requested when this proxy was
            instantiated.
            c         C   s   |  j  S(   N(   RI   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyRV   "  s    s   The object-path of this proxy.c         K   s1   |  j  j | d | d | d |  j d |  j | S(   sx  Arrange for the given function to be called when the given signal
        is received.

        :Parameters:
            `signal_name` : str
                The name of the signal
            `handler_function` : callable
                A function to be called when the signal is emitted by
                the remote object. Its positional arguments will be the
                arguments of the signal; optionally, it may be given
                keyword arguments as described below.
            `dbus_interface` : str
                Optional interface with which to qualify the signal name.
                If None (the default) the handler will be called whenever a
                signal of the given member name is received, whatever
                its interface.
        :Keywords:
            `utf8_strings` : bool
                If True, the handler function will receive any string
                arguments as dbus.UTF8String objects (a subclass of str
                guaranteed to be UTF-8). If False (default) it will receive
                any string arguments as dbus.String objects (a subclass of
                unicode).
            `byte_arrays` : bool
                If True, the handler function will receive any byte-array
                arguments as dbus.ByteArray objects (a subclass of str).
                If False (default) it will receive any byte-array
                arguments as a dbus.Array of dbus.Byte (subclasses of:
                a list of ints).
            `sender_keyword` : str
                If not None (the default), the handler function will receive
                the unique name of the sending endpoint as a keyword
                argument with this name
            `destination_keyword` : str
                If not None (the default), the handler function will receive
                the bus name of the destination (or None if the signal is a
                broadcast, as is usual) as a keyword argument with this name.
            `interface_keyword` : str
                If not None (the default), the handler function will receive
                the signal interface as a keyword argument with this name.
            `member_keyword` : str
                If not None (the default), the handler function will receive
                the signal name as a keyword argument with this name.
            `path_keyword` : str
                If not None (the default), the handler function will receive
                the object-path of the sending object as a keyword argument
                with this name
            `message_keyword` : str
                If not None (the default), the handler function will receive
                the `dbus.lowlevel.SignalMessage` as a keyword argument with
                this name.
            `arg...` : unicode or UTF-8 str
                If there are additional keyword parameters of the form
                ``arg``\ *n*, match only signals where the *n*\ th argument
                is the value given for that keyword parameter. As of this time
                only string arguments can be matched (in particular,
                object paths and signatures can't).
        t   signal_nameR4   R.   t   path(   RE   t   add_signal_receiverR&   RI   (   R   RW   t   handler_functionR4   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyt   connect_to_signal.  s    <	c         C   s=   |  j  j |  j |  j t d d d |  j |  j d t d t ƒS(   Nt
   Introspectt    t   utf8_stringst   require_main_loop(    (	   RE   R   R&   RI   R   t   _introspect_reply_handlert   _introspect_error_handlert   TrueR   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyRQ   q  s    	c         C   s7   x' |  j  D] \ } } } | | | Ž  q
 Wg  |  _  d  S(   N(   RL   (   R   R   R   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyt   _introspect_execute_queuez  s    c         C   s|   |  j  j ƒ  zZ y t | ƒ |  _ Wn! t k
 rF } |  j | ƒ d  SX|  j |  _ d  |  _	 |  j
 ƒ  Wd  |  j  j ƒ  Xd  S(   N(   RM   t   acquireR   R8   R   Ra   t    INTROSPECT_STATE_INTROSPECT_DONERO   R   RK   Rc   t   release(   R   t   datat   e(    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyR`   ‚  s    	c         C   sŠ   t  j ƒ  t j d |  j |  j | j j | j j | ƒ |  j	 j
 ƒ  z0 t j d ƒ |  j |  _ d  |  _ |  j ƒ  Wd  |  j	 j ƒ  Xd  S(   Ns$   Introspect error on %s:%s: %s.%s: %ss'   Executing introspect queue due to error(   t   loggingt   basicConfigt   _loggert   errorR&   RI   t	   __class__R!   R    RM   Rd   t   debugRN   RO   R   RK   Rc   Rf   (   R   Rl   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyRa   ‘  s    
		c         C   sE   |  j  j ƒ  z# |  j d  k	 r/ |  j j ƒ  n  Wd  |  j  j ƒ  Xd  S(   N(   RM   Rd   RK   R   R   Rf   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyt   _introspect_block   s
    c         C   sa   |  j  j ƒ  z? |  j |  j k r> |  j j | | | f ƒ n | | | Ž  Wd  |  j  j ƒ  Xd  S(   N(   RM   Rd   RO   RP   RL   R   Rf   (   R   t   callbackR   RU   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyt   _introspect_add_to_queueª  s    c         C   s>   | j  d ƒ r- | j d ƒ r- t | ƒ ‚ n |  j | ƒ Sd  S(   Nt   __(   t
   startswitht   endswitht   AttributeErrort   get_dbus_method(   R   t   member(    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyt   __getattr__¶  s    c         C   s[   |  j  |  |  j |  j |  j | | ƒ } |  j |  j k rW |  j | |  j |  j ƒ } n  | S(   s,  Return a proxy method representing the given D-Bus method. The
        returned proxy method can be called in the usual way. For instance, ::

            proxy.get_dbus_method("Foo", dbus_interface='com.example.Bar')(123)

        is equivalent to::

            proxy.Foo(123, dbus_interface='com.example.Bar')

        or even::

            getattr(proxy, "Foo")(123, dbus_interface='com.example.Bar')

        However, using `get_dbus_method` is the only way to call D-Bus
        methods with certain awkward names - if the author of a service
        implements a method called ``connect_to_signal`` or even
        ``__getattr__``, you'll need to use `get_dbus_method` to call them.

        For services which follow the D-Bus convention of CamelCaseMethodNames
        this won't be a problem.
        (	   t   ProxyMethodClassRE   R&   RI   RO   RP   t   DeferredMethodClassRq   Ro   (   R   Rw   R4   t   ret(    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyRv   ¼  s    		c         C   s#   d |  j  |  j |  j t |  ƒ f S(   Ns&   <ProxyObject wrapping %s %s %s at %#x>(   RE   R&   RI   t   id(   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyt   __repr__â  s    N(   R    R!   R"   R#   Ry   R   Rz   RN   RP   Re   R   Rb   R   R   t   propertyR.   t   requested_bus_nameR/   R[   RQ   Rc   R`   Ra   Ro   Rq   Rx   Rv   R}   t   __str__(    (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyR;   ª   s6   	R					
C						
		&	t	   Interfacec           B   sÅ   e  Z d  Z d „  Z e d „  d d d ƒ Z e Z e d „  d d d ƒ Z e d „  d d d ƒ Z	 e d „  d d d	 ƒ Z
 e d
 „  d d d ƒ Z d d „ Z d „  Z d d „ Z d „  Z e Z RS(   s    An interface into a remote object.

    An Interface can be used to wrap ProxyObjects
    so that calls can be routed to their correct
    D-Bus interface.
    c         C   s4   t  | t ƒ r | j |  _ n	 | |  _ | |  _ d S(   s:  Construct a proxy for the given interface on the given object.

        :Parameters:
            `object` : `dbus.proxies.ProxyObject` or `dbus.Interface`
                The remote object or another of its interfaces
            `dbus_interface` : str
                An interface the `object` implements
        N(   t
   isinstanceR   t   proxy_objectt   _objR+   (   R   t   objectR4   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyR   ð  s    		c         C   s
   |  j  j S(   N(   R„   R/   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyRV   ÿ  s    s.   The D-Bus object path of the underlying objectc         C   s
   |  j  j S(   N(   R„   R.   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyRV     s    s:   The bus name to which the underlying proxy object is boundc         C   s
   |  j  j S(   N(   R„   R   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyRV     s    sG   The bus name which was requested when the underlying object was createdc         C   s   |  j  S(   N(   R„   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyRV   	  s    s   The underlying proxy objectc         C   s   |  j  S(   N(   R+   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyRV     s    s   The D-Bus interface representedc         K   s+   | s |  j  } n  |  j j | | | |  S(   sa  Arrange for a function to be called when the given signal is
        emitted.

        The parameters and keyword arguments are the same as for
        `dbus.proxies.ProxyObject.connect_to_signal`, except that if
        `dbus_interface` is None (the default), the D-Bus interface that
        was passed to the `Interface` constructor is used.
        (   R+   R„   R[   (   R   RW   RZ   R4   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyR[     s    
c         C   sG   | j  d ƒ r- | j d ƒ r- t | ƒ ‚ n |  j j | |  j ƒ Sd  S(   NRr   (   Rs   Rt   Ru   R„   Rv   R+   (   R   Rw   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyRx     s    c         C   s+   | d k r |  j } n  |  j j | | ƒ S(   s&  Return a proxy method representing the given D-Bus method.

        This is the same as `dbus.proxies.ProxyObject.get_dbus_method`
        except that if `dbus_interface` is None (the default),
        the D-Bus interface that was passed to the `Interface` constructor
        is used.
        N(   R   R+   R„   Rv   (   R   Rw   R4   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyRv   $  s    c         C   s   d |  j  |  j t |  ƒ f S(   Ns%   <Interface %r implementing %r at %#x>(   R„   R+   R|   (   R   (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyR}   0  s    N(   R    R!   R"   R   R~   R   R/   RI   R.   R   Rƒ   R4   R[   Rx   Rv   R}   R€   (    (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyR   è  s&   									(   t   sysRi   t	   threadingR    t   ImportErrort   dummy_threadingR(   t   dbus._expat_introspect_parserR   t   dbus.exceptionsR   R   R   R   t   __docformat__t	   getLoggerRk   R   R   R	   R
   R   R   R#   R…   R;   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/dbus/proxies.pyt   <module>   s    "(`ÿ ?