�
@ia�`��$�ddlZ ddlmZn#e$r ddlmZYnwxYwddlZddlmZddlm Z m
Z
mZmZdZ
ejd��ZddlmZmZmZmZmZddlmZGd �d
��ZGd�d��ZGd
�de��ZGd�de��ZdS)�N)�RLock)�process_introspection_data)�
DBusException�IntrospectionParserException�MissingErrorHandlerException�MissingReplyHandlerException�restructuredtextzdbus.proxies)�BUS_DAEMON_IFACE�BUS_DAEMON_NAME�BUS_DAEMON_PATH�INTROSPECTABLE_IFACE�
LOCAL_PATH)�is_py2c�$�eZdZdZd�Zd�Zd�ZdS)�_DeferredMethodzXA proxy method which will only get called once we have its
introspection reply.
c�H�||_|j|_||_||_dS�N)�
_proxy_method�_method_name�_append�_block)�self�proxy_method�append�blocks �./usr/lib/python3/dist-packages/dbus/proxies.py�__init__z_DeferredMethod.__init__8s'��)���(�5�����������c��d|vs|�dd��r|�|j||��dS|���|j|i|��S)N�
reply_handler�ignore_replyF)�getrrr�r�args�keywordss r�__call__z_DeferredMethod.__call__?sj���x�'�'��L�L���/�/�
(�
�L�L��+�T�8�<�<�<��4�
�K�K�M�M�M�%�4�%�t�8�x�8�8�8rc�>�|�|j||��dSr)rrr#s r�
call_asyncz_DeferredMethod.call_asyncJs!�����T�'��x�8�8�8�8�8rN��__name__�
__module__�__qualname__�__doc__rr&r(�rrrr4sK����������� 9� 9� 9�9�9�9�9�9rrc�$�eZdZdZd�Zd�Zd�ZdS)�_ProxyMethodz�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���|tkrtdtz���||_||_||_||_t
j|��||_|�t
j |��||_
dS)Nz1Methods may not be called on the reserved path %s)rr�_proxy�_connection�_named_service�_object_path�_dbus_bindings�validate_member_namer�validate_interface_name�_dbus_interface)r�proxy�
connection�bus_name�object_path�method_name�ifaces rrz_ProxyMethod.__init__Us����*�$�$��!*�,6�!7�8�8�
8� %���)���'���*����+�K�8�8�8�*������2�5�9�9�9�$����rc
�p�|�dd��}|�dd��}|�dd��}|�dd��}|�|�1|�t���|�t���|rtd���|�d|j��}|�7|�|j}n
|dz|jz}|jj�|d��}|s|�+|j j
|j|j||j||||fi|��dS|j j
|j|j||j||fi|��S) Nr �
error_handlerr!F� signaturez6ignore_reply and reply_handler cannot be used together�dbus_interface�.)�poprr� TypeErrorr9rr2�_introspect_method_mapr"r3r(r4r5�
call_blocking) rr$r%r rAr!rBrC�keys rr&z_ProxyMethod.__call__is��� ���_�d�;�;�
� ���_�d�;�;�
��|�|�N�E�:�:���L�L��d�3�3� ��$�
�(A��$�2�4�4�4��&�2�4�4�4��
1��!0�1�1�1�"���&6��8L�M�M�����%��'���$�s�*�T�->�>����:�>�>�s�D�I�I�I�� >�=�4�'�D��'��(;�(,�(9�(6�(,�(9�(1�(,�(5�(5�
4�
4�+3�
4�
4�
4�
4�
4�2�4�#�1�$�2E�26�2C�2@�26�2C�2;�26�>�>�5=�
>�>�
>rc
��|�dd��}|�dd��}|�dd��}|�d|j��}|�7|r|dz|jz}n|j}|jj�|d��}|jj|j|j ||j||||fi|��dS)Nr rArBrCrD)
rEr9rr2rGr"r3r(r4r5)rr$r%r rArBrCrIs rr(z_ProxyMethod.call_async�s��� ���_�d�;�;�
� ���_�d�;�;�
��L�L��d�3�3� �!���&6��8L�M�M�����
(�$�s�*�T�->�>����'����:�>�>�s�D�I�I�I�#���#�D�$7�$(�$5�$2�$(�$5�$-�$(�$1�$1� 0� 0�'/� 0� 0� 0� 0� 0rNr)r.rrr0r0NsL��������%�%�%�(*>�*>�*>�X0�0�0�0�0rr0c���eZdZdZeZeZdZdZ dZ
dd�Zed �ddd
��Z
ed�ddd��Zed
�ddd��Zdd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�ZeZdS)�ProxyObjectz�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.
r��NTFc�R�|�dd��}|�,|�td���|}ddlm}|dtd���|�d d��} | �,|�td
���| }ddlm}|dtd���|r7tdd
�|�����z���|r|���||_|�tj
|��|x|_|_tj
|��||_|s|�|��|_d|_g|_i|_t'��|_|r|jt*kr|j|_dS|j|_|���|_dS)a�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
�busNz%conn and bus cannot both be specifiedr)�warnz`Passing the bus parameter to ProxyObject by name is deprecated: please use positional parametersrN)�
stacklevel�
named_servicez3bus_name and named_service cannot both be specifiedzjPassing the named_service parameter to ProxyObject by name is deprecated: please use positional parametersz>ProxyObject.__init__ does not take these keyword arguments: %sz, )rErF�warningsrQ�DeprecationWarning�join�keys�_require_main_loop�_busr6�validate_bus_namer4�_requested_bus_name�validate_object_path�__dbus_object_path__�activate_name_owner�_pending_introspect�_pending_introspect_queuerGr�_introspect_lockr� INTROSPECT_STATE_DONT_INTROSPECT�_introspect_state�'INTROSPECT_STATE_INTROSPECT_IN_PROGRESS�_Introspect)
r�connr<r=�
introspect�follow_name_owner_changes�kwargsrPrQrSs
rrzProxyObject.__init__�s��,�j�j���%�%���?���� G�H�H�H��D�%�%�%�%�%�%��D�@�#��
3�
3�
3�
3��
�
�?�D�9�9�
��$��#��!,�-�-�-�$�H�%�%�%�%�%�%��D�C�#��
3�
3�
3�
3�� 8��4�"�i�i����
�
�6�6�7�8�8�
8�%� &�
�#�#�%�%�%��� ����,�X�6�6�6�:B�A���d�6��+�K�8�8�8�$/��!�(� E�"&�":�":�8�"D�"D�D��$(�� �)+��&�&(��#�!&������ :�T�6�*�D�D�%)�%J�D�"�"�"�%)�%Q�D�"�'+�'7�'7�'9�'9�D�$�$�$rc��|jSr)r4�rs r�<lambda>zProxyObject.<lambda>s ��T�%8�ra�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��|jSr)r[rks rrlzProxyObject.<lambda> s ��t�/G�rz[The bus name which was requested when this proxy was
instantiated.
c��|jSr)r]rks rrlzProxyObject.<lambda>&s ���(A�rzThe object-path of this proxy.c�F�|jj|f|||j|jd�|��S)axArrange 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).
)�signal_namerCr<�path)rY�add_signal_receiverr4r]�rrp�handler_functionrCr%s r�connect_to_signalzProxyObject.connect_to_signal2sG��x &�� �%�&6� 2�2=�5C�/3�/B�+/�+D� 2� 2�
)1� 2� 2� 2rc
�p�i}|jj|j|jtddd|j|jfddi|��S)N�
Introspect�r.�require_main_loopF)rYr(r4r]r
�_introspect_reply_handler�_introspect_error_handler)rris rrezProxyObject._Introspectusa����#�t�y�#�D�$7�$(�$=�$8�,��B�$(�$B�$(�$B� G�G�
7<�G�
@F�G�G� Grc�@�|jD]\}}}||i|���g|_dSr)r`)rrr$r%s r�_introspect_execute_queuez%ProxyObject._introspect_execute_queue~sC��/3�.L� ,� ,�*�\�4���L�$�+�(�+�+�+�+�)+��&�&�&rc��|j��� t|��|_nF#t$r9}|�|��Yd}~|j���dSd}~wwxYw|j|_d|_ |�
��|j���dS#|j���wxYwr)ra�acquirerrGrr{�release� INTROSPECT_STATE_INTROSPECT_DONErcr_r})r�data�es rrzz%ProxyObject._introspect_reply_handler�s�����%�%�'�'�'� ,�
�.H��.N�.N��+�+��/�
�
�
��.�.�q�1�1�1�����
�!�)�)�+�+�+�+�+�����
����&*�%J�D�"�'+�D�$��*�*�,�,�,��!�)�)�+�+�+�+�+��D�!�)�)�+�+�+�+���s+�1�B9�
A4�A/�B9�/A4�4*B9�9Cc���tj��t�d|j|j|jj|jj|��|j �
�� t�d��|j|_
d|_|���|j ���dS#|j ���wxYw)Nz$Introspect error on %s:%s: %s.%s: %sz'Executing introspect queue due to error)�logging�basicConfig�_logger�errorr4r]� __class__r+r*rar�debugrbrcr_r}r�)rr�s rr{z%ProxyObject._introspect_error_handler�s���������
�
�<��)�4�+D��o�0�%�/�2J�� � � �
��%�%�'�'�'� ,��M�M�C�D�D�D�%)�%J�D�"�'+�D�$��*�*�,�,�,��!�)�)�+�+�+�+�+��D�!�)�)�+�+�+�+���s
�+AC�C"c���|j��� |j�|j���|j���dS#|j���wxYwr)rarr_rr�rks r�_introspect_blockzProxyObject._introspect_block�sr����%�%�'�'�'� ,��'�3��(�.�.�0�0�0�
�!�)�)�+�+�+�+�+��D�!�)�)�+�+�+�+���s� A�A1c��|j��� |j|jkr|j�|||f��n||i|��|j���dS#|j���wxYwr)rarrcrdr`rr�)r�callbackr$ris r�_introspect_add_to_queuez$ProxyObject._introspect_add_to_queue�s�����%�%�'�'�'� ,��%��)U�U�U��.�5�5�x��v�6N�O�O�O�O���$�)�&�)�)�)��!�)�)�+�+�+�+�+��D�!�)�)�+�+�+�+���s�6A,�,Bc��|�d��r$|�d��rt|���|�|��S�N�__)�
startswith�endswith�AttributeError�get_dbus_method�r�members r�__getattr__zProxyObject.__getattr__�sM�����T�"�"� 0�v���t�'<�'<� 0� ��(�(�(��'�'��/�/�/rc��|�||j|j|j||��}|j|jkr!|�||j|j��}|S)a,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.
) �ProxyMethodClassrYr4r]rcrd�DeferredMethodClassr�r�)rr�rC�rets rr�zProxyObject.get_dbus_method�sn��.�#�#�D�$�)�$(�$7�$(�$=�v�$2�4�4���!�T�%Q�Q�Q��*�*�3��0M�+/�+A�C�C�C��
rc�L�d|j|j|jt|��fzS)Nz&<ProxyObject wrapping %s %s %s at %#x>)rYr4r]�idrks r�__repr__zProxyObject.__repr__�s.��7��I�t�*�D�,E�r�$�x�x�9Q�Q� Qr)NNNTFr)r*r+r,r-r0r�rr�rbrdr�r�propertyr<�requested_bus_namer=rurer}rzr{r�r�r�r�r��__str__r.rrrLrL�sq��������
$��)��'(�$�./�+�'(�$�=A�<A�Q:�Q:�Q:�Q:�f�x�8�8�$��
���H�$"��"G�"G��$�
�����(�A�A��$�0�2�2�K�A2�A2�A2�A2�FG�G�G�,�,�,�
,�
,�
,�
,�
,�
,�,�,�,�
,�
,�
,�0�0�0�$�$�$�$�LQ�Q�Q��G�G�GrrLc���eZdZdZd�Zed�ddd��ZeZed�ddd��Zed�ddd ��Z ed
�ddd��Z
ed�ddd
��Z dd�Zd�Z
dd�Zd�ZeZdS)� Interfacez�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�f�t|t��r
|j|_n||_||_dS)a: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)�
isinstancer��proxy_object�_objr9)r�objectrCs rrzInterface.__init__�s7���f�i�(�(� ��+�D�I�I��D�I�-����rc��|jjSr)r�r=rks rrlzInterface.<lambda>s����)>�rNz.The D-Bus object path of the underlying objectc��|jjSr)r�r<rks rrlzInterface.<lambda>s��d�i�&8�rz:The bus name to which the underlying proxy object is boundc��|jjSr)r�r�rks rrlzInterface.<lambda> s��� �0L�rzGThe bus name which was requested when the underlying object was createdc��|jSr)r�rks rrlzInterface.<lambda>
s��$�)�rzThe underlying proxy objectc��|jSr)r9rks rrlzInterface.<lambda>s ��D�,@�rzThe D-Bus interface representedc�>�|s|j}|jj|||fi|��S)aaArrange 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.
)r9r�rurss rruzInterface.connect_to_signalsG��� 2�!�1�N�*�t�y�*�;�8H�+9�G�G�=E�G�G� Grc��|�d��r$|�d��rt|���|j�||j��Sr�)r�r�r�r�r�r9r�s rr�zInterface.__getattr__"sV�����T�"�"� K�v���t�'<�'<� K� ��(�(�(��9�,�,�V�T�5I�J�J�Jrc�J�|�|j}|j�||��S)a&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.
)r9r�r�)rr�rCs rr�zInterface.get_dbus_method(s*���!�!�1�N��y�(�(���@�@�@rc�@�d|j|jt|��fzS)Nz%<Interface %r implementing %r at %#x>)r�r9r�rks rr�zInterface.__repr__4s&��6�� �4�'��D���83�3� 3rr)r*r+r,r-rr�r=r]r<r�r�rCrur�r�r�r�r.rrr�r��s5��������
.�
.�
.��(�>�>��d�L�N�N�K�&���x�8�8�$��$�%�%�H�"��#L�#L�#'��$C�D�D���8�3�3�T�4�>�@�@�L��X�@�@�$��D�F�F�N�*.�G�G�G�G� K�K�K�
A�
A�
A�
A�3�3�3��G�G�Grr�)r�� threadingr�ImportError�dummy_threadingr6�dbus._expat_introspect_parserr�dbus.exceptionsrrrr�
__docformat__� getLoggerr�r
rrr
r�dbus._compatrrr0r�rLr�r.rr�<module>r�s���8����&����������&�&�&�%�%�%�%�%�%�%�%�&��������D�D�D�D�D�D�"�"�"�"�"�"�"�"�"�"�"�"�#�
��'�
�N�
+�
+���������������� ������9�9�9�9�9�9�9�9�4]0�]0�]0�]0�]0�]0�]0�]0�@{�{�{�{�{�&�{�{�{�| K�K�K�K�K��K�K�K�K�Ks�
�� |