
    >a+                        d dl mZ d dlmZ ddlT 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dS )    )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dS )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                 0    || _         || _        || _        d S N)object_pathbus_name	interface)selfr   r   r   s       0lib/python3.11/site-packages/jeepney/wrappers.py__init__zDBusAddress.__init__   s    & "    c                 t    d                     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__    s6    8??T

@S$dmT^E E 	Er   c                 J     t          |           | j        | j        |          S r   )r   r   r   )r   r   s     r   with_interfacezDBusAddress.with_interface$   s!    tDzz$*DM9EEEr   NN)r   
__module____qualname____doc__r   r   r!    r   r   r   r      sX         # # # #
E E EF F F F Fr   r   c                         e Zd Zd fd	Z xZS )
DBusObjectNc                 p    t                                          |||           t          dd           d S )Nz)Deprecated alias, use DBusAddress instead   )
stacklevel)superr   r   )r   r   r   r   	__class__s       r   r   zDBusObject.__init__(   s9    h	:::8QGGGGGGr   r"   )r   r#   r$   r   __classcell__)r-   s   @r   r(   r(   '   sG        H H H H H H H H 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 8 8 8r   Nr&   c                 x   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)
    Nz3remote_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     /00F'1'=FM,#$"NOOO.8.AFM,*+'0:0Dl,-)/FM,%&09l,-64   r   c                 <   t          t          j                  }| j        j        |j        t          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22F/9/@/GFM,+,%)),*=tDDF28l./09l,-64   r   c                 d   t          t          j                  }| j        j        |j        t          j        <   ||j        t          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/@/GFM,+,-7FM,)*%)),*=tDDF28l./09l,-64   r   c                 8   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
    Nz,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'.':FM,#$ GHHH,3,=FM,())/FM,%&09l,-64   r   c                       e Zd ZdZd Zd ZdS )r   zSubclass this to define the methods available on a DBus interface.
    
    jeepney.bindgen can automatically create subclasses using introspection.
    c                 "    || _         || _        d S r   )r   r   )r   r   r   s      r   r   zMessageGenerator.__init__   s    & r   c                 h    d                     t          |           j        | j        | j                  S )Nz{}({!r}, bus_name={!r}))r   r   r   r   r   r   s    r   r   zMessageGenerator.__repr__   s2    (//T

0C040@$-Q Q 	Qr   N)r   r#   r$   r%   r   r   r&   r   r   r   r   ~   sA         ! ! !Q Q Q Q Qr   r   c                   $    e Zd ZdZd Zd Zd ZdS )	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                     || _         d S r   )_msggen)r   msggens     r   r   zProxyBase.__init__   s    r   c                     |                     d          rt          |          t          | j        |d           }t	          |          r|                     |          S t          |          )N__)
startswithAttributeErrorgetattrr[   callable_method_call)r   itemmake_msgs      r   __getattr__zProxyBase.__getattr__   si    ??4   	' &&&4<t4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HHr   N)r   r#   r$   r%   r   rf   rc   r&   r   r   rY   rY      sP         
  # # #I I I I Ir   rY   c                   @    e Zd ZdZdeeef         fdZd Zd Z	d Z
dS )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                 V    || _         t          |j        |j        d          | _        d S )Nzorg.freedesktop.DBus.Properties)r   r   )rj   r   r   r   props_if)r   rj   s     r   r   zProperties.__init__   s1    #COcl.OQ Q Qr   c                 H    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H&-/ / 	/r   c                 F    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46 6 	6r   c           	      N    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   s3    t}eUH&y%.@AC C 	Cr   N)r   r#   r$   r%   r   r   r   r   rL   ru   rz   r&   r   r   r   r      s{         QE+/?"?@ Q Q Q Q
/ / /
6 6 6
C C C C Cr   r   c                       e Zd ZdZd ZdS )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22r   N)r   r#   r$   r   r}   r&   r   r   r   r      s(        5I3 3 3 3 3r   r   c                       e Zd ZdZd Zd ZdS )r   z?Raised by proxy method calls when the reply is an error messagec                 z    |j         j                            t          j                  | _        |j        | _        d S r   )rH   r5   rL   r>   rQ   rq   rG   data)r   msgs     r   r   zDBusErrorResponse.__init__   s,    J%)),*ABB	H			r   c                 B    d                     | j        | j                  S )Nz[{}] {})r   rq   r   r   s    r   __str__zDBusErrorResponse.__str__   s    	49555r   N)r   r#   r$   r%   r   r   r&   r   r   r   r      s8        II  6 6 6 6 6r   r   r   c                 b    | 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      s,     z+"333$$$8Or   )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 F F F F F F*H H H H H H H H
8 8 8! ! ! !2! ! ! ! ! ! ! !$! ! ! !&Q Q Q Q Q Q Q QI I I I I I I I,C C C C C C C C83 3 3 3 3% 3 3 36 6 6 6 6	 6 6 6	G 	 	 	 	 	 	r   