+
    >a :                        ^ RI t ^ RIHt ^ RIt^ RIHt ^ RIt^ RIHt  ^ RIH	t	 ^ RIHtHt ^ RIt^ RIHt ^ RIHtHt ^ R	IHt ^ R
IHtHt ^ RIHtHtHt ^ RIHtH t  ^ RI!H"t" ^RI#H$t$H%t%H&t&H't'H(t( ]PR                  ! ]*4      t+. ROt,]R 4       t- ! R R]4      t.R RR/R R lllt/ ! R R]%4      t0 ! R R4      t1 ! R R4      t2 ! R R]4      t3]	R RR/R ll4       t4R#   ]
 d
    ^ RIH	t	  Li ; i)!    N)contextmanager)count)Optional)asynccontextmanager)ValueError)Channel)AuthenticatorBEGIN)get_bus)FileDescriptorfds_buf_size)ParserMessageTypeMessage)	ProxyBase
unwrap_msg)message_bus)MessageFiltersFilterHandleReplyMatcherRouterClosedcheck_replyableProxyc               #     "    R x  R #   \          dr   p T P                  \        P                  \        P                  09   d   \        P
                  ! R4      R h\        P                  ! RP                  T 4      4      T hR p ? ii ; i5i)Nzthis socket was already closedzsocket connection broken: {})OSErrorerrnoEBADFENOTSOCKtrioClosedResourceErrorBrokenResourceErrorformat)excs    /lib/python3.14/site-packages/jeepney/io/trio.py)_translate_socket_errors_to_stream_errorsr&   0   sn     	 99enn55**+KLRVV**.55c:s%   B	
 B	BA,BBB	c                      a  ] tR t^?t o RtRR ltRR/V 3R lR lltV 3R lR ltRV 3R	 lR
 lltV 3R lR lt	R t
R tR t]R 4       tRtV tR# )DBusConnectionav  A plain D-Bus connection with no matching of replies.

This doesn't run any separate tasks: sending and receiving are done in
the task that calls those methods. It's suitable for implementing servers:
several worker tasks can receive requests and send replies.
For a typical client pattern, see :class:`DBusRouter`.

Implements trio's channel interface for Message objects.
c                    Wn         W n        \        4       V n        \	        ^R7      V n        RV n        \        P                  ! 4       V n	        \        P                  ! 4       V n
        RV n        R# )   )startN)socket
enable_fdsr   parserr   outgoing_serialunique_namer    Lock	send_lock	recv_lock_leftover_to_send)selfr,   r-   s   &&&r%   __init__DBusConnection.__init__I   sK    $h$1~!%    serialNc                    < V ^8  d   QhRS[ /# )   messager   )r#   __classdict__s   "r%   __annotate__DBusConnection.__annotate__S   s     - -' -r8   c                 "   V P                   ;_uu_4       GRj  xL
  Vf   \        V P                  4      pV P                  '       d   \        P                  ! R4      MRpVP                  W#R7      pV P                  WC4      G Rj  xL
  RRR4      GRj  xL
  R#  L L L
  + GRj  xL 
 '       g   i     R# ; i5i)z.Serialise and send a :class:`~.Message` objectNi)fds)r2   nextr/   r-   array	serialise
_send_data)r5   r<   r9   rC   datas   &&$  r%   sendDBusConnection.sendS   s{     >>>>~d223&*ooo%++c"4C$$V$5D//$,,, ">>
 - ">>>sb   CB C+B&>B&	B"
B&CB$C"B&$C&C 	,B/-
C 	8C 	:	Cc                    < V ^8  d   QhRS[ /# r;   rH   )bytes)r#   r>   s   "r%   r?   r@   ^   s     7 7U 7r8   c           
       "   V P                   P                  '       d   \        P                  ! R 4      h\	        4       ;_uu_ 4        V P
                  '       d$   V P                  V P
                  4      G Rj  xL
  \        V4      ;_uu_ 4       pV'       d[   V P                   P                  V.\        P                   P                  \        P                   P                  V3.4      G Rj  xL
 pM#V P                   P                  V4      G Rj  xL
 pV P                  W4      G Rj  xL
  RRR4       RRR4       R#  L LU L3 L  + '       g   i     L"; i  + '       g   i     R# ; i5i)z!can't send data after sending EOFN)r,   did_shutdown_SHUT_WRr    r!   r&   r4   _send_remainder
memoryviewsendmsg
SOL_SOCKET
SCM_RIGHTSrI   )r5   rH   rC   sents   &&& r%   rG   DBusConnection._send_data^   s	    ;;+++**+NOO688%%%**4+A+ABBBD!!T!%!4!4dV..0F0F? > " D "&!1!1$!77D**4666 " 98 C 86 "! 988s   AE01E8E9EAE		-E.#E		EE		*E+E		/E7
E0EE		E		E			EEE-	'	E0c                    < V ^8  d   QhRS[ /# rL   )rQ   )r#   r>   s   "r%   r?   r@   q   s      * r8   c                4  "    V\        V4      8  dD   WR  ;_uu_ 4       pV P                  P                  V4      G R j  xL
 pR R R 4       VX,          pKS  R V n        R #  L   + '       g   i     L&; i  \        P
                   d    YR  T n        h i ; i5iN)lenr,   rI   r4   r    	Cancelled)r5   rH   already_sent	remainingrU   s   &&&  r%   rP   DBusConnection._send_remainderq   s     	T*-((I!%!1!1)!<<D )$%)D" = )( ~~ 	 &*-%8D"	sD   BA5 A"A  A"A5 B A""A2	-A5 5 BBc                    < V ^8  d   QhRS[ /# r;   returnr=   )r#   r>   s   "r%   r?   r@      s     - -w -r8   c                  "   V P                   ;_uu_4       GRj  xL
   V P                  P                  4       pVe   TuuRRR4      GRj  xL
  # V P                  4       G Rj  xL
 w  r#V'       g   \        P
                  ! R4      hV P                  P                  W#4       K   L L\ LE  + GRj  xL 
 '       g   i     R# ; i5i)z5Return the next available message from the connectionNzSocket closed at the other end)r3   r.   get_next_message
_read_datar    EndOfChanneladd_data)r5   msgbrC   s   &   r%   receiveDBusConnection.receive   s     >>>>kk224?	 ">>  $00++,LMM$$Q, " 1 ">>>si   CB(C!B. CB*CB.&B,'AB.(C*C,B..C	4B75
C	 C		Cc                  "   V P                   '       d   V P                  P                  4       p\        4       ;_uu_ 4        V P                  P                  V\        4       4      G R j  xL
 w  r#rER R R 4       X\        \        P                  R^ 4      ,          '       d   V P                  4        \        R4      hX\        P                  ! X4      3# \        4       ;_uu_ 4        V P                  P                  R4      G R j  xL
 pR R R 4       V. 3#  L  + '       g   i     L; i L%  + '       g   i     X. 3# ; i5i)N
MSG_CTRUNCz&Unable to receive all file descriptorsi   )r-   r.   bytes_desiredr&   r,   recvmsgr   getattrr    _closeRuntimeErrorr   from_ancdatarecv)r5   nbytesrH   ancdataflags_s   &     r%   rd   DBusConnection._read_data   s     ???[[..0F:<<040C0CLN1 +'u = wt{{L!<<<"#KLL44W=== ;<<![[--d33 =8O+ =< 4 =<8OsZ   ?E(D)D*D1A5E&D-D+D-
EDD(	#E+D--E 	8Ec                H    V P                   P                  4        R V n        R # rY   )r,   closer4   r5   s   &r%   rp   DBusConnection._close   s    !%r8   c                .   "   V P                  4        R# 5i)zClose the D-Bus connectionN)rp   r{   s   &r%   acloseDBusConnection.aclose   s     s   c                 "   \         P                  ! 4       ;_uu_4       GRj  xL
 p\        V 4      pVP                  V4      G Rj  xL
   V5x  VP	                  4       G Rj  xL
  RRR4      GRj  xL
  R#  LX L6 L  TP	                  4       G Rj  xL 
  i ; i L*  + GRj  xL 
 '       g   i     R# ; i5i)a)  Temporarily wrap this connection as a :class:`DBusRouter`

To be used like::

    async with conn.router() as req:
        reply = await req.send_and_get_reply(msg)

While the router is running, you shouldn't use :meth:`receive`.
Once the router is closed, you can use the plain connection again.
N)r    open_nursery
DBusRouterr+   r~   )r5   nurseryrouters   &  r%   r   DBusConnection.router   s      $$&&&'%F,,w'''&mmo%% '&&' &fmmo%% '&&&s   "C A=C  B#A?	B#BB#&B'B#+C 6B!7C ?B#B#BBBB#!C #B=	)B,*
B=	5B=	7	C )r4   r-   r/   r.   r3   r2   r,   r0   )F)r   )__name__
__module____qualname____firstlineno____doc__r6   rI   rG   rP   ri   rd   rp   r~   r   r   __static_attributes____classdictcell__r>   s   @r%   r(   r(   ?   sa     &-T - -7 7& - -"&
 & &r8   r(   r-   Fc                $    V ^8  d   QhR\         /# r`   r(   )r#   s   "r%   r?   r?      s      n r8   c                 "   \        V 4      p\        P                  ! V4      G Rj  xL
 p\        VR7      pV FC  pVP	                  V4      G Rj  xL
  TP                  VP                  4       G Rj  xL
 4       KE  	  VP	                  \        4      G Rj  xL
  \        VP                  VR7      pVP                  4       ;_uu_4       GRj  xL
 pVP                  \        P                  ! 4       4      G Rj  xL
 pVP                  ^ ,          Vn        RRR4      GRj  xL
  V#  EL L L L Lc L9 L  + GRj  xL 
 '       g   i     T# ; i5i)z@Open a plain D-Bus connection

:return: :class:`DBusConnection`
Nr-   )r   r    open_unix_socketr
   send_allfeedreceive_somer   r(   r,   r   send_and_get_replyr   Hellobodyr0   )	busr-   bus_addrsockauthrreq_dataconnr   replys	   &$       r%   open_dbus_connectionr      s     
 s|H%)%:%:8%DDD Z0EmmH%%%

**,,-  --
$++*=D {{}}}//0A0A0CDD ::a= } K#  E
 	&, D }}} Ks   %ED,)ED/"E4D1
5$ED37ED5E(D;=D7>D;E%D9&E/E1E3E5E7D;9E;E	E
E	E		Ec                   `   a a ] tR t^t oV3R lV 3R llt]R 4       tR tR tR t	Rt
VtV ;t# )TrioFilterHandlec                    < V ^8  d   QhRS[ /# )r;   filters)r   )r#   r>   s   "r%   r?   TrioFilterHandle.__annotate__   s     % % %r8   c                4   < \         SV `  WV4       W0n        R # rY   )superr6   send_channel)r5   r   rulesend_chnrecv_chn	__class__s   &&&&&r%   r6   TrioFilterHandle.__init__   s    1$r8   c                    V P                   # rY   queuer{   s   &r%   receive_channel TrioFilterHandle.receive_channel   s    zzr8   c                v   "   V P                  4        V P                  P                  4       G R j  xL
  R #  L5irY   )rz   r   r~   r{   s   &r%   r~   TrioFilterHandle.aclose   s&     

&&(((s   .979c                "   "   V P                   # 5irY   r   r{   s   &r%   
__aenter__TrioFilterHandle.__aenter__   s     zzs   c                B   "   V P                  4       G R j  xL
  R #  L5irY   )r~   )r5   exc_typeexc_valexc_tbs   &&&&r%   	__aexit__TrioFilterHandle.__aexit__   s     kkms   )r   )r   r   r   r   r6   propertyr   r~   r   r   r   r   __classcell__r   r>   s   @@r%   r   r      s7     % %  ) r8   r   c                   <   a  ] tR t^t o RtR tR tR tR tRt	V t
R# )Futurez4A very simple Future for trio based on `trio.Event`.c                H    R V n         \        P                  ! 4       V n        R # rY   )_outcomer    Event_eventr{   s   &r%   r6   Future.__init__   s    jjlr8   c                Z    \        V4      V n        V P                  P                  4        R # rY   )r   r   r   set)r5   results   &&r%   
set_resultFuture.set_result   s    fr8   c                Z    \        V4      V n        V P                  P                  4        R # rY   )r   r   r   r   )r5   r$   s   &&r%   set_exceptionFuture.set_exception   s    c
r8   c                   "   V P                   P                  4       G R j  xL
  V P                  P                  4       #  L5irY   )r   waitr   unwrapr{   s   &r%   get
Future.get   s3     kk   }}##%% 	!s   A?A)r   r   N)r   r   r   r   r   r6   r   r   r   r   r   r   s   @r%   r   r      s!     >#& &r8   r   c                      a  ] tR t^t o RtRtRtV 3R lR lt]R 4       t	RR/R lt
V 3R lR	 ltR
RR^/V 3R lR lltV 3R lR ltR tV 3R lR lt]P"                  3R ltRtV tR# )r   z|A client D-Bus connection which can wait for replies.

This runs a separate receiver task and dispatches received messages.
Nc                    < V ^8  d   QhRS[ /# )r;   r   r   )r#   r>   s   "r%   r?   DBusRouter.__annotate__  s     ) )^ )r8   c                N    Wn         \        4       V n        \        4       V n        R # rY   )_connr   _repliesr   _filters)r5   r   s   &&r%   r6   DBusRouter.__init__  s    
$&(r8   c                .    V P                   P                  # rY   )r   r0   r{   s   &r%   r0   DBusRouter.unique_name  s    zz%%%r8   r9   c               Z   "   V P                   P                  WR7      G Rj  xL
  R#  L5i)z/Send a message, don't wait for a reply
        r9   N)r   rI   )r5   r<   r9   s   &&$r%   rI   DBusRouter.send  s      jjoogo555s    +)+c                    < V ^8  d   QhRS[ /# r`   r=   )r#   r>   s   "r%   r?   r     s     + +7 +r8   c                  "   \        V4       V P                  f   \        R4      h\        V P                  P
                  4      pV P                  P                  V\        4       4      ;_uu_ 4       pV P                  WR7      G Rj  xL
  VP                  4       G Rj  xL
 uuRRR4       #  L& L  + '       g   i     R# ; i5i)ztSend a method call message and wait for the reply

Returns the reply message (method return or error message type).
NzThis DBusRouter has stoppedr   )r   _rcv_cancel_scoper   rD   r   r/   r   catchr   rI   r   )r5   r<   r9   	reply_futs   &&  r%   r   DBusRouter.send_and_get_reply  s     
 	 !!)<==djj001]]  22i))G)333#--/) 323) 322sB   A0C2B3B/	B3 B1!B3$C/B31B33C	>	Cchannelbufsizec                D   < V ^8  d   QhRS[ S[P                  ,          /# )r;   r   )r   r    MemorySendChannel)r#   r>   s   "r%   r?   r   #  s"     L Lx0F0F'G Lr8   c               n    Vf   \         P                  ! V4      w  r$MRp\        V P                  WV4      # )a  Create a filter for incoming messages

Usage::

    async with router.filter(rule) as receive_channel:
        matching_msg = await receive_channel.receive()

    # OR:
    send_chan, recv_chan = trio.open_memory_channel(1)
    async with router.filter(rule, channel=send_chan):
        matching_msg = await recv_chan.receive()

If the channel fills up,
The sending end of the channel is closed when leaving the ``async with``
block, whether or not it was passed in.

:param jeepney.MatchRule rule: Catch messages matching this rule
:param trio.MemorySendChannel channel: Send matching messages here
:param int bufsize: If no channel is passed in, create one with this size
N)r    open_memory_channelr   r   )r5   r   r   r   recv_channels   &&$$ r%   filterDBusRouter.filter#  s6    * ?$($<$<W$E!G\LtlKKr8   c                4   < V ^8  d   QhRS[ P                  /# )r;   r   )r    Nursery)r#   r>   s   "r%   r?   r   @  s     E E4<< Er8   c                   "   V P                   e   \        R4      hVP                  V P                  4      G R j  xL
 V n         R #  L5i)Nz+DBusRouter receiver task is already running)r   rq   r+   	_receiver)r5   r   s   &&r%   r+   DBusRouter.start@  s8     !!-LMM'.}}T^^'D!D!Ds   8AAAc                   "   V P                   e"   V P                   P                  4        RV n         \        P                  ! ^ 4      G Rj  xL
  R#  L5i)z Stop the sender & receiver tasksN)r   cancelr    sleepr{   s   &r%   r~   DBusRouter.acloseE  s@      !!-""))+%)D" jjms   A	AAAc                    < V ^8  d   QhRS[ /# )r;   rg   r=   )r#   r>   s   "r%   r?   r   R  s     	 	W 	r8   c                    V P                   P                  V4      '       d   R# V P                  P                  V4       F  p VP                  P                  V4       K!  	  R#   \        P                   d     K=  i ; i)zHandle one received messageN)r   dispatchr   matchesr   send_nowaitr    
WouldBlock)r5   rg   r   s   && r%   	_dispatchDBusRouter._dispatchR  sd    ==!!#&&mm++C0F##//4 1 ?? s   A$$A=<A=c                z  "   \         P                  ! 4       ;_uu_ 4       pRV n        VP                  V4         V P                  P                  4       G Rj  xL
 pV P                  V4       K6   L  RT n        T P                  P                  4        \         P                  ! ^4      ;_uu_ 4       pT P                  P                  P                  4        F-  pRTn        TP                  P                  4       G Rj  xL 
  K/  	  RRR4       i   + '       g   i     i ; i; i  + '       g   i     R# ; i5i)z'Receiver loop - runs in a separate taskTNF)r    CancelScope
is_runningstartedr   ri   r   r   drop_allmove_on_afterr   r   valuesshieldr   r~   )r5   task_statuscscoperg   cleanup_scoper   s   &&    r%   r   DBusRouter._receiver]  s     6"DO'; $

 2 2 44CNN3' 5 #(&&( ''**m"&--"7"7">">"@/3,$1188::: #A +***  sY   D;D'A2A0A22A D$2AD>D?	D	D$D!D$$D''D8	2	D;)r   r   r   r   r  )r   r   r   r   r   _nursery_mgrr   r6   r   r0   rI   r   r   r+   r~   r   r    TASK_STATUS_IGNOREDr   r   r   r   s   @r%   r   r      s      L) )
 & &6D 6
+ +L LVW L L:E E
		 	 +/*B*B ; ;r8   r   c                   <   a a ] tR tRt oRtV 3R ltR tRtVtV ;t	# )r   is  a  A trio proxy for calling D-Bus methods

You can call methods on the proxy object, such as ``await bus_proxy.Hello()``
to make a method call over D-Bus and wait for a reply. It will either
return a tuple of returned data, or raise :exc:`.DBusErrorResponse`.
The methods available are defined by the message generator you wrap.

:param msggen: A message generator object.
:param ~trio.DBusRouter router: Router to send and receive messages.
c                t   < \         SV `  V4       \        V\        4      '       g   \	        R 4      hW n        R# )z)Proxy can only be used with DBusRequesterN)r   r6   
isinstancer   	TypeError_router)r5   msggenr   r   s   &&&r%   r6   Proxy.__init__~  s.     &*--GHHr8   c                   a a VV 3R  lpV# )c                     <"   S! V / VB pVP                   P                  \        P                  J g   Q hSP                  P                  V4      G R j  xL
 p\        V4      #  L5irY   )headermessage_typer   method_callr  r   r   )argskwargsrg   r   make_msgr5   s   *,  r%   inner!Proxy._method_call.<locals>.inner  sZ     D+F+C::**k.E.EEEE,,99#>>Ee$$ ?s   AA&A$A& )r5   r  r  s   ff r%   _method_callProxy._method_call  s    	% r8   )r  )
r   r   r   r   r   r6   r"  r   r   r   r   s   @@r%   r   r   s  s     	 r8   c          
    n  "   \        WR7      G Rj  xL
 pT;_uu_4       GRj  xL
  VP                  4       ;_uu_4       GRj  xL
 pV5x  RRR4      GRj  xL
  RRR4      GRj  xL
  R#  L_ LN L/ L  + GRj  xL 
 '       g   i     L3; i L*  + GRj  xL 
 '       g   i     R# ; i5i)a{  Open a D-Bus 'router' to send and receive messages.

Use as an async context manager::

    async with open_dbus_router() as req:
        ...

:param str bus: 'SESSION' or 'SYSTEM' or a supported address.
:return: :class:`DBusRouter`

This is a shortcut for::

    conn = await open_dbus_connection()
    async with conn:
        async with conn.router() as req:
            ...
r   N)r   r   )r   r-   r   rtrs   &$  r%   open_dbus_routerr&    s]     & &cAADtt;;===CI != tt B === ttts   B5A2B5A4B5BA6B
A:	BA8B B5+B,B54B56B8B:B B
BBBB5B2	B!
B2	*B2	,	B5)r   r&  r   )SESSION)5rE   
contextlibr   r   	itertoolsr   loggingtypingr   r   ImportErrorasync_generatoroutcomer   r   r    trio.abcr	   jeepney.authr
   r   jeepney.busr   jeepney.fdsr   r   jeepney.low_levelr   r   r   jeepney.wrappersr   r   jeepney.bus_messagesr   commonr   r   r   r   r   	getLoggerr   log__all__r&   r(   r   r   r   r   r   r&  r!  r8   r%   <module>r:     s     %    4. !   -  4 : : 2 ,  !& 
 
{&W {&|E  4| (& &&r; r;jI 6   K  434s   C# #C32C3