grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a Êicb"ã@sºddlZddlmZddlmZmZddlmZddlm Z ddl Z e   dd¡ddl m Z e e¡Zd d gZd d „Ze jd œdd„ZGdd„deƒZGdd „d eƒZGdd „d e ƒZdS)éN)ÚDBUS_FLAG_NONE)ÚVariantUnpackingÚ get_variant)Ú GLibClient)Ú GLibServerÚGioz2.0)rÚGLibClientUnixÚGLibServerUnixcsD|dur dSg‰‡fdd„}t ||¡}ˆs4|dfS|tj ˆ¡fS)a«Acquire Unix file descriptors contained in a variant. Return a variant with indexes into a list of Unix file descriptors and the list of Unix file descriptors. If the variant is None, or the variant doesn't contain any Unix file descriptors, return None instead of the list. :param variant: a variant with Unix file descriptors :return: a variant with indexes and a list of Unix file descriptors N)NNcsˆ |¡tˆƒdS)Né)ÚappendÚlen)Úfd©Úfd_list©ú//usr/lib/python3.9/site-packages/dasbus/unix.pyÚ_get_idx9s zacquire_fds.._get_idx)Ú UnixFDSwapÚapplyrÚ UnixFDListZnew_from_array)ÚvariantrZvariant_without_fdsrrrÚ acquire_fds(s   rrcs@|dur dSˆdur|Sˆ ¡‰ˆs(|S‡fdd„}t ||¡S)a5Restore Unix file descriptors in a variant. If the variant is None, return None. Otherwise, return a variant with Unix file descriptors. :param variant: a variant with indexes into fd_list :param fd_list: a list of Unix file descriptors :return: a variant with Unix file descriptors Ncs$z ˆ|WStyYdS0dS)Néÿÿÿÿ)Ú IndexError)ÚindexrrrÚ_get_fdZs  zrestore_fds.._get_fd)Z steal_fdsrr)rrrrrrÚ restore_fdsEs  rc@s@eZdZdZedd„ƒZedd„ƒZedd„ƒZedd „ƒZd S) rz-Class for swapping values of the UnixFD type.cCs | ||¡S)aASwap unix file descriptors with indices. The provided function should swap a unix file descriptor with an index into an array of unix file descriptors or vice versa. :param variant: a variant to modify :param swap: a swapping function :return: a modified variant )Ú_recreate_variant)ÚclsrÚswaprrrrfs zUnixFDSwap.applycGs|j| ¡g|¢RŽS)zHandle a variant.)rr)rrÚextrasrrrÚ_handle_varianttszUnixFDSwap._handle_variantcGs,| ¡}|dkr$|^}}|| ¡ƒS| ¡S)zHandle a basic value.Úh)Úget_type_stringZ get_handleÚunpack)rrr Ú type_stringrÚ_rrrÚ _handle_valueys  zUnixFDSwap._handle_valuecGs8| ¡}d|vrd|vr|S|j|g|¢RŽ}t||ƒS)z%Create a variant with swapped values.r"Úv)r#Z_process_variantr)rrr r%Úvaluerrrr‡s zUnixFDSwap._recreate_variantN) Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú classmethodrr!r'rrrrrrcs   rc@sFeZdZdZeeejfdd„ƒZedeejfdd„ƒZ edd„ƒZ d S) rz0The low-level DBus client library based on GLib.c Cs0t|ƒ\}} | |||||||| | d¡ } t| ŽS)zVSynchronously call a DBus method. :return: a result of the DBus call N)rZcall_with_unix_fd_list_syncr) rÚ connectionÚ service_nameÚ object_pathÚinterface_nameÚ method_nameÚ parametersÚ reply_typeÚflagsÚtimeoutrÚresultrrrÚ sync_callšs özGLibClientUnix.sync_callrc Cs6t|ƒ\}} |j||||||| | | |j|| fd� dS)z"Asynchronously call a DBus method.)ÚcallbackÚ user_dataN)rZcall_with_unix_fd_listÚ_async_call_finish) rr/r0r1r2r3r4r5r:Ú callback_argsr6r7rrrrÚ async_call¶s õzGLibClientUnix.async_callcs*|\}}‡‡fdd„}||g|¢RŽdS)z(Finish an asynchronous DBus method call.csˆ ˆ¡}t|ŽS)N)Zcall_with_unix_fd_list_finishr)r8©Ú result_objectÚ source_objectrrÚ _finish_callÔsÿz7GLibClientUnix._async_call_finish.._finish_callNr)rrAr@r;r:r=rBrr?rr<Îs z!GLibClientUnix._async_call_finishN) r*r+r,r-r.rrZDBUS_TIMEOUT_NONEr9r>r<rrrrr—sþ ý c@s6eZdZdZed dd„ƒZedd„ƒZedd„ƒZdS) r zXThe low-level DBus server library based on GLib. Adds Unix FD Support to base classNcCs0t|ƒ\}}|rt d¡| |||||¡dS)aEmit a DBus signal. GLib doesn't seem to support Unix file descriptors in signals. Swap Unix file descriptors with indexes into a list of Unix file descriptors, but emit just the indexes. Log a warning to inform users about the limited support. z1Unix file descriptors in signals are unsupported.N)rÚlogZwarningÚ emit_signal)rr/r1r2Z signal_namer4Z destinationrrrrrDås  ûzGLibServerUnix.emit_signalcCs"| ||¡}t|ƒ}|j|ŽdS)zSet the reply of the DBus call.N)Z_get_reply_valuerZreturn_value_with_unix_fd_list)rÚ invocationZout_typeZ out_valueZ reply_valueZ reply_argsrrrÚset_call_replyþs zGLibServerUnix.set_call_replyc Cs8|\} } | ¡ ¡} t|| ƒ}| ||||g| ¢RŽdS)z'A method call closure of a DBus object.N)Z get_messageZget_unix_fd_listr) rr/Zsenderr1r2r3r4rEr;r:r=rrrrÚ_object_callbacks  üûzGLibServerUnix._object_callback)N)r*r+r,r-r.rDrFrGrrrrr àsÿ  )ZloggingZdasbus.constantsrZ dasbus.typingrrZdasbus.client.handlerrZdasbus.server.handlerrZgiZrequire_versionZ gi.repositoryrZ getLoggerr*rCÚ__all__rrrrrr rrrrÚs       þ4I