
    +c+                         d dl mZ d dlmZ ddl g dZ G d d      Z G d d	e      Zd
 ZddZ	ddZ
ddZddZ G d d      Z G d d      Z G d d      Z G d de      Z G d de      ZdefdZy)    )Union)warn   )*)	DBusAddressnew_method_callnew_method_return	new_error
new_signalMessageGenerator
PropertiesIntrospectableDBusErrorResponsec                   $    e Zd ZdZddZd Zd Zy)r   aA  This identifies the object and interface a message is for.

    e.g. messages to display desktop notifications would have this address::

        DBusAddress('/org/freedesktop/Notifications',
                    bus_name='org.freedesktop.Notifications',
                    interface='org.freedesktop.Notifications')
    Nc                 .    || _         || _        || _        y N)object_pathbus_name	interface)selfr   r   r   s       2/usr/lib/python3/dist-packages/jeepney/wrappers.py__init__zDBusAddress.__init__   s    & "    c                     dj                  t        |       j                  | j                  | j                  | j
                        S )Nz'{}({!r}, bus_name={!r}, interface={!r}))formattype__name__r   r   r   r   s    r   __repr__zDBusAddress.__repr__    s8    8??T
@S@S$$dmmT^^E 	Er   c                 P     t        |       | j                  | j                  |      S r   )r   r   r   )r   r   s     r   with_interfacezDBusAddress.with_interface$   s!    tDz$**DMM9EEr   NN)r   
__module____qualname____doc__r   r   r!    r   r   r   r      s    #
EFr   r   c                         e Zd Zd fd	Z xZS )
DBusObjectc                 B    t         |   |||       t        dd       y )Nz)Deprecated alias, use DBusAddress instead   )
stacklevel)superr   r   )r   r   r   r   	__class__s       r   r   zDBusObject.__init__(   s    h	:8QGr   r"   )r   r#   r$   r   __classcell__)r-   s   @r   r(   r(   '   s    H Hr   r(   c           	      B    t        t        j                  | ddddi       S )Nr   r   )flagsprotocol_versionbody_lengthserialfields)Header
Endiannesslittle)msg_types    r   
new_headerr:   ,   s$    *##XQ B8 8r   Nc                    t        t        j                        }| j                  |j                  t
        j                  <   | j                  t        d      | j                  |j                  t
        j                  <   | j                  '| j                  |j                  t
        j                  <   ||j                  t
        j                  <   |||j                  t
        j                  <   t        ||      S )a  Construct a new method call message

    This is a relatively low-level method. In many cases, this will be called
    from a :class:`MessageGenerator` subclass which provides a more convenient
    API.

    :param DBusAddress remote_obj: The object to call a method on
    :param str method: The name of the method to call
    :param str signature: The DBus signature of the body data
    :param tuple body: Body data (i.e. method parameters)
    z3remote_obj.bus_name cannot be None for method calls)r:   MessageTypemethod_callr   r5   HeaderFieldspathr   
ValueErrordestinationr   member	signatureMessage)
remote_objmethodrC   bodyheaders        r   r   r   0   s     //0F'1'='=FMM,##$"NOO.8.A.AFMM,**+'0:0D0Dl,,-)/FMM,%%&09l,,-64  r   c                    t        t        j                        }| j                  j                  |j
                  t        j                  <   | j                  j
                  j                  t        j                  d      }|||j
                  t        j                  <   |||j
                  t        j                  <   t        ||      S )zConstruct a new response message

    :param Message parent_msg: The method call this is a reply to
    :param str signature: The DBus signature of the body data
    :param tuple body: Body data
    N)r:   r<   method_returnrH   r4   r5   r>   reply_serialgetsenderrA   rC   rD   )
parent_msgrC   rG   rH   rM   s        r   r	   r	   I   s     112F/9/@/@/G/GFMM,++,%%)),*=*=tDF28l../09l,,-64  r   c                    t        t        j                        }| j                  j                  |j
                  t        j                  <   ||j
                  t        j                  <   | j                  j
                  j                  t        j                  d      }|||j
                  t        j                  <   |||j
                  t        j                  <   t        ||      S )zConstruct a new error response message

    :param Message parent_msg: The method call this is a reply to
    :param str error_name: The name of the error
    :param str signature: The DBus signature of the body data
    :param tuple body: Body data
    N)r:   r<   errorrH   r4   r5   r>   rK   
error_namerL   rM   rA   rC   rD   )rN   rQ   rC   rG   rH   rM   s         r   r
   r
   Y   s     ))*F/9/@/@/G/GFMM,++,-7FMM,))*%%)),*=*=tDF28l../09l,,-64  r   c                    t        t        j                        }| j                  |j                  t
        j                  <   | j                  t        d      | j                  |j                  t
        j                  <   ||j                  t
        j                  <   |||j                  t
        j                  <   t        ||      S )zConstruct a new signal message

    :param DBusAddress emitter: The object sending the signal
    :param str signal: The name of the signal
    :param str signature: The DBus signature of the body data
    :param tuple body: Body data
    z,emitter.interface cannot be None for signals)r:   r<   signalr   r5   r>   r?   r   r@   rB   rC   rD   )emitterrS   rC   rG   rH   s        r   r   r   k   s     **+F'.':':FMM,##$ GHH,3,=,=FMM,(())/FMM,%%&09l,,-64  r   c                       e Zd ZdZd Zd Zy)r   zSubclass this to define the methods available on a DBus interface.
    
    jeepney.bindgen can automatically create subclasses using introspection.
    c                      || _         || _        y r   )r   r   )r   r   r   s      r   r   zMessageGenerator.__init__   s    & r   c                 v    dj                  t        |       j                  | j                  | j                        S )Nz{}({!r}, bus_name={!r}))r   r   r   r   r   r   s    r   r   zMessageGenerator.__repr__   s2    (//T
0C0C040@0@$--Q 	Qr   N)r   r#   r$   r%   r   r   r&   r   r   r   r   ~   s    !Qr   r   c                   "    e Zd ZdZd Zd Zd Zy)	ProxyBasezA proxy is an IO-aware wrapper around a MessageGenerator
    
    Calling methods on a proxy object will send a message and wait for the
    reply. This is a base class for proxy implementations in jeepney.io.
    c                     || _         y r   )_msggen)r   msggens     r   r   zProxyBase.__init__   s	    r   c                     |j                  d      rt        |      t        | j                  |d       }t	        |      r| j                  |      S t        |      )N__)
startswithAttributeErrorgetattrr[   callable_method_call)r   itemmake_msgs      r   __getattr__zProxyBase.__getattr__   sO    ??4  &&4<<t4H$$X..T""r   c                     t        d      )Nz#Needs to be implemented in subclass)NotImplementedError)r   re   s     r   rc   zProxyBase._method_call   s    !"GHHr   N)r   r#   r$   r%   r   rf   rc   r&   r   r   rY   rY      s    
#Ir   rY   c                   8    e Zd ZdZdeeef   fdZd Zd Z	d Z
y)r   zBuild messages for accessing object properties

    If a D-Bus object has multiple interfaces, each interface has its own
    set of properties.

    This uses the standard DBus interface ``org.freedesktop.DBus.Properties``
    objc                 `    || _         t        |j                  |j                  d      | _        y )Nzorg.freedesktop.DBus.Properties)r   r   )rj   r   r   r   props_if)r   rj   s     r   r   zProperties.__init__   s%    #COOcll.OQr   c                 ^    t        | j                  dd| j                  j                  |f      S )z$Get the value of the property *name*Getssr   rl   rj   r   )r   names     r   rL   zProperties.get   s+    t}}eTHH&&-/ 	/r   c                 \    t        | j                  dd| j                  j                  f      S )z*Get all property values for this interfaceGetAllsrp   r   s    r   get_allzProperties.get_all   s)    t}}h $ 2 246 	6r   c           	      d    t        | j                  dd| j                  j                  |||ff      S )z?Set the property *name* to *value* (with appropriate signature)Setssvrp   )r   rq   rC   values       r   setzProperties.set   s4    t}}eUHH&&y%.@AC 	Cr   N)r   r#   r$   r%   r   r   r   r   rL   ru   rz   r&   r   r   r   r      s0    QE+/?"?@ Q
/
6
Cr   r   c                       e Zd ZdZd Zy)r   z#org.freedesktop.DBus.Introspectablec                     t        | d      S )z3Request D-Bus introspection XML for a remote object
Introspect)r   r   s    r   r}   zIntrospectable.Introspect   s    t\22r   N)r   r#   r$   r   r}   r&   r   r   r   r      s    5I3r   r   c                       e Zd ZdZd Zd Zy)r   z?Raised by proxy method calls when the reply is an error messagec                     |j                   j                  j                  t        j                        | _        |j                  | _        y r   )rH   r5   rL   r>   rQ   rq   rG   data)r   msgs     r   r   zDBusErrorResponse.__init__   s/    JJ%%)),*A*AB	HH	r   c                 N    dj                  | j                  | j                        S )Nz[{}] {})r   rq   r   r   s    r   __str__zDBusErrorResponse.__str__   s    		49955r   N)r   r#   r$   r%   r   r   r&   r   r   r   r      s    I6r   r   r   c                 ~    | j                   j                  t        j                  k(  rt	        |       | j
                  S )zGet the body of a message, raising DBusErrorResponse for error messages

    This is to be used with replies to method_call messages, which may be
    method_return or error.
    )rH   message_typer<   rP   r   rG   )r   s    r   
unwrap_msgr      s0     zz+"3"33$$88Or   )Nr&   )typingr   warningsr   	low_level__all__r   r(   r:   r   r	   r
   r   r   rY   r   r   	Exceptionr   rD   r   r&   r   r   <module>r      s      
F F*H H
8!2! !$!&Q QI I,C C83% 36	 6	G 	r   