
    Ki%                     x   d dl Z d dlmZ d dlmZ ddl g dZ e j                  d      Zd Z	 e j                  d	      Z
d
 Z e j                  d      Z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)#    N)Union)warn   )*)	DBusAddressnew_method_callnew_method_return	new_error
new_signalMessageGenerator
PropertiesIntrospectableDBusErrorResponsezZ([A-Za-z_-][A-Za-z0-9_-]*(\.[A-Za-z_-][A-Za-z0-9_-]*)+|:[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+))$c                     t        |       dkD  r| d d dz   }t        d|d      t        j                  |       st        d| d      y )N      ...z
Bus name ( ) is too long (> 255 characters)) is not valid)len
ValueErrorbus_name_patmatchnameabbrs     \/home/jay/workspace/scripts/.codegraph-venv/lib/python3.12/site-packages/jeepney/wrappers.pycheck_bus_namer      sY    
4y3BQx%:dX-MNOOd#:dX^<== $    z2[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)+$c                     t        |       dkD  r| d d dz   }t        d|d      t        j                  |       st        d| d      y )Nr   r   r   zInterface name (r   r   )r   r   interface_patr   r   s     r   check_interfacer"   !   s[    
4y3BQx%+D83STUUt$+D8>BCC %r   z[A-Za-z_][A-Za-z0-9_]*$c                     t        |       dkD  r| d d dz   }t        d|d      t        j                  |       st        d| d      y )Nr   r   r   zMember name (r   z is not valid)r   r   member_name_patr   r   s     r   check_member_namer%   *   sY    
4y3BQx%=0PQRR  &=>?? 'r   c                   $    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                     t               j                  |       || _        |t        |       || _        |t        |       || _        y N)ObjectPathType
check_dataobject_pathr   bus_namer"   	interface)selfr+   r,   r-   s       r   __init__zDBusAddress.__init__;   sE    ##K0&8$  I&"r   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__G   s8    8??T
@S@S$$dmmT^^E 	Er   c                 f    t        |        t        |       | j                  | j                  |      S r(   )r"   r2   r+   r,   )r.   r-   s     r   with_interfacezDBusAddress.with_interfaceK   s)    	"tDz$**DMM9EEr   NN)r3   
__module____qualname____doc__r/   r5   r7    r   r   r   r   2   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__P   s    h	:8QGr   r8   )r3   r9   r:   r/   __classcell__)rC   s   @r   r>   r>   O   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_headerrP   T   s$    *##XQ B8 8r   c                 
   t        |       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%   rP   MessageTypemethod_callr+   rK   HeaderFieldspathr,   r   destinationr-   member	signatureMessage)
remote_objmethodrX   bodyheaders        r   r   r   X   s     f//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)rP   rR   method_returnr]   rJ   rK   rT   reply_serialgetsenderrV   rX   rY   )
parent_msgrX   r\   r]   rb   s        r   r	   r	   r   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)rP   rR   errorr]   rJ   rK   rT   r`   
error_namera   rb   rV   rX   rY   )rc   rf   rX   r\   r]   rb   s         r   r
   r
      s     ))*F/9/@/@/G/GFMM,++,-7FMM,))*%%)),*=*=tDF28l../09l,,-64  r   c                    t        |       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%   rP   rR   signalr+   rK   rT   rU   r-   r   rW   rX   rY   )emitterrh   rX   r\   r]   s        r   r   r      s     f**+F'.':':FMM,##$ GHH,3,=,=FMM,(())/FMM,%%&09l,,-64  r   c                   2    e Zd ZU dZdZee   ed<   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.
    Nr-   c                     t               j                  |       t        |       | j                  t	        | j                         || _        || _        y r(   )r)   r*   r   r-   r"   r+   r,   )r.   r+   r,   s      r   r/   zMessageGenerator.__init__   s@    ##K0x >>%DNN+& r   c                 v    dj                  t        |       j                  | j                  | j                        S )Nz{}({!r}, bus_name={!r}))r1   r2   r3   r+   r,   r4   s    r   r5   zMessageGenerator.__repr__   s2    (//T
0C0C040@0@$--Q 	Qr   )
r3   r9   r:   r;   r-   Optionalstr__annotations__r/   r5   r<   r   r   r   r      s"      $Ix}#!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getattrrs   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.   r}   s     r   r{   zProxyBase._method_call   s    !"GHHr   N)r3   r9   r:   r;   r/   r~   r{   r<   r   r   rq   rq      s    
#Ir   rq   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-   )r   r   r+   r,   props_if)r.   r   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   r   r   r-   )r.   r   s     r   ra   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sr   r4   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ssvr   )r.   r   rX   values       r   setzProperties.set   s4    t}}eUHH&&y%.@AC 	Cr   N)r3   r9   r:   r;   r   r   r   r/   ra   r   r   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   r4   s    r   r   zIntrospectable.Introspect   s    t\22r   N)r3   r9   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(   )r]   rK   ra   rT   rf   r   r\   data)r.   msgs     r   r/   zDBusErrorResponse.__init__   s/    JJ%%)),*A*AB	HH	r   c                 N    dj                  | j                  | j                        S )Nz[{}] {})r1   r   r   r4   s    r   __str__zDBusErrorResponse.__str__   s    		49955r   N)r3   r9   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.
    )r]   message_typerR   re   r   r\   )r   s    r   
unwrap_msgr      s0     zz+"3"33$$88Or   )Nr<   )retypingr   warningsr   	low_level__all__compiler   r   r!   r"   r$   r%   r   r>   rP   r   r	   r
   r   r   rq   r   r   	Exceptionr   rY   r   r<   r   r   <module>r      s    	   
 rzz,
> 

PQD "**78@F F:H H
8!4! !$!(Q Q*I I,C C83% 36	 6	G 	r   