+
    Qiy  c                   s  a  R' t*0 t R tRtRtRtRtRt^ RIt^ RIt^ RI	H
t
 ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHt ^ RIHt ^RIHt ^RIHt ^RIHt ^RIHt ^RIHt  ! R R]P:                  4      tR tR t R t!R t"R R lt# ! R R4      t$]! R4       ! R R]4      4       t%]! R 4       ! R! R"]4      4       t& ! R# R$4      t']'! 4       t(] ^ k R% R& lt)R# )(z9Provides a D-Bus interface for remotely controlling Orca.z$Id$z
$Revision$z$Date$z%Copyright (c) 2025 Valve Corporation.ZLGPLN)Callable)SessionMessageBus)	DBusError)	EventLoop)dbus_interface)Publishable)GLib)debug)input_event)input_event_manager)orca_platform)script_managerc                   s    ] tR t^8tRt]P                  ! 4       t]P                  ! 4       t]P                  ! 4       t	]P                  ! 4       t
RtR# )HandlerTypez/Enumeration of handler types for D-Bus methods. N)__name__
__module____qualname____firstlineno____doc__enumZautoCOMMANDPARAMETERIZED_COMMANDGETTERSETTER__static_attributes__r       6/usr/lib/python3.14/site-packages/orca/dbus_service.pyr   r   8   s2    9iikG IIKYY[FYY[Fr   r   c                X    V P                   ;'       g    RV P                   2pWn        V # )zDecorator to mark a method as a D-Bus command using its docstring.

Usage:
    @command
    def toggle_speech(self, script=None, event=None):
        '''Toggles speech on and off.'''
        # method implementation
zD-Bus command: )r   r   dbus_command_descriptionfuncdescription   & r   commandr!   @   s+     ,,CCODMM?"CK$/!Kr   c                r   )a  Decorator to mark a method as a D-Bus parameterized command using its docstring.

Usage:
    @parameterized_command
    def get_voices_for_language(
        self,
        language,
        variant='',
        script=None,
        event=None,
        notify_user=False
    ):
        '''Returns a list of available voices for the specified language.'''
        # method implementation
zD-Bus parameterized command: )r   r   &dbus_parameterized_command_descriptionr   r    r   parameterized_commandr#   M   s,      ,,QQ$A$--"QK2=/Kr   c                r   )zDecorator to mark a method as a D-Bus getter using its docstring.

Usage:
    @getter
    def get_rate(self):
        '''Returns the current speech rate.'''
        # method implementation
zD-Bus getter: )r   r   dbus_getter_descriptionr   r    r   getterr%   a   +     ,,BBN4==/"BK#. Kr   c                r   )zDecorator to mark a method as a D-Bus setter using its docstring.

Usage:
    @setter
    def set_rate(self, value):
        '''Sets the current speech rate.'''
        # method implementation
zD-Bus setter: )r   r   dbus_setter_descriptionr   r    r   setterr(   n   r&   r   c                sh    V ^8  d   QhR\         R\        \        \        \        3,          ,          /# )   r   return)r    listtuplestrformat   "r   __annotate__r1   |   s'      x DsCx4I r   c                s   \         P                  ! V 4      p. p0 RmpVP                  P                  4        F  w  rEWC9   d   K  VP                  \         P
                  P                  8w  dZ   \        VP                  R4      '       d   VP                  P                  pM(\        VP                  4      P                  RR4      pMRpVP                  WF34       K  	  V# )z<Extract parameter names and types from a function signature.r   ztyping. ZAny>   selfeventscript)inspect	signature
parametersitemsZ
annotationZ	ParameterZemptyhasattrr   r-   Zreplaceappend)r   Zsigr8   Zskip_paramsZ
param_nameZparamZtype_str   &      r   _extract_function_parametersr=   |   s     

D
!CJ-K ^^113
$w00666u''44 ++44u//088BGH:01 4 r   c                   sR   a  ] tR t^t o Rt]P                  R3V 3R lR lltRtV t	R# )_HandlerInfoz@Stores processed information about a function exposed via D-Bus.Nc                s   < V ^8  d   QhRS[ RS[ RS[RS[3,          RS[RS[S[S[ S[ 3,          ,          R,          /# )r)   python_function_namer   action.handler_typer8   N)r-   r    boolr   r+   r,   r/   __classdict__   "r   r1   Z_HandlerInfo.__annotate__   s_     B B!B B d#	B
 "B sCx)D0Br   c                sX    Wn         W n        W0n        W@n        T;'       g    . V n        R # Nr?   r   r@   rA   r8   )r3   r?   r   r@   rA   r8   s   &&&&&&r   __init__Z_HandlerInfo.__init__   s*     *>! ++1)51;1A1Arr   )r@   r   rA   r8   r?   )
r   r   r   r   r   r   r   rH   r   __classdictcell__rD      @r   r>   r>      s(     J %0$7$737B B Br   r>   zorg.gnome.Orca.Modulec                   s  a a ] tR t^t oRtV3R lV 3R lltV3R lR ltV3R lR ltV3R lR	 ltV3R
 lR lt	V3R lR lt
V3R lR ltV3R lR ltV3R lR ltR t]]P"                  3V3R lR ll4       t]R 4       tRtVtV ;t# )OrcaModuleDBusInterfacezHA D-Bus interface representing a specific Orca module (e.g., a manager).c                s6   < V ^8  d   QhRS[ RS[S[,          /# )r)   module_namehandlers_info)r-   r+   r>   rC   rE   r   r1   $OrcaModuleDBusInterface.__annotate__   s"     9 9!9 $\ 29r   c                s  < \         SV `  4        Wn        / V n        / V n        / V n        / V n        V F  p\        VR \        P                  4      pV P                  VP                  V4      pV\        P                  8X  d   W0P
                  V&   K_  V\        P                  8X  d   W0P                  V&   K  V\        P                  8X  d   W0P                  V&   K  W0P                  V&   K  	  RV R\        V P                  4       R\        V P                  4       R\        V P
                  4       R\        V P                  4       R2p\         P"                  ! \         P$                  VR4       R# )	rA   z*DBUS SERVICE: OrcaModuleDBusInterface for z initialized with z command(s), z parameterized command(s), z getter(s), z setter(s).TN)superrH   _module_name	_commands_parameterized_commands_getters_settersgetattrr   r   _normalize_handler_namer?   r   r   r   lenr   print_message
LEVEL_INFO)r3   rM   rN   inforA   Znormalized_namemsg	__class__s   &&&    r   rH   Z OrcaModuleDBusInterface.__init__   s@    	'24@B$1313!D"49L9LML"::4;T;TVbcO{11115o.!3!3315o.!B!BB@D,,_=26/ " 9 F'(4//011L4==!",s4==/A.B+O 	 	E,,c48r   c                s:   < V ^8  d   QhRS[ RS[P                  /# )r)   getter_namer*   )r-   r   VariantrC   rE   r   r1   rO      s     ( ( ( (r   c                s   V P                   P                  V4      pV'       gf   RV RV P                   R2p\        P                  ! \        P
                  VR4       \        P                  ! R\        P                  ! RR4      4      # VP                  4       pRV R	V 2p\        P                  ! \        P
                  VR4       V P                  V4      # )
zVExecutes the named getter returning the value as a GLib.Variant for D-Bus marshalling.zDBUS SERVICE: Unknown getter '' for ''.Tvsr2   zDBUS SERVICE: Getter '' returned: )
rT   getrQ   r   rY   rZ   r   r_   r@   _to_variant)r3   r^   handler_infor\   result   &&   r   ExecuteRuntimeGetterZ,OrcaModuleDBusInterface.ExecuteRuntimeGetter   s     }}((52;-wtGXGXFYY[\C 0 0#t<<<T\\#r%:;;$$&&{m<xHE,,c48''r   c                s@   < V ^8  d   QhRS[ RS[P                  RS[/# )r)   setter_namevaluer*   )r-   r   r_   rB   rC   rE   r   r1   rO      s&       DLL T r   c                s^   V P                   P                  V4      pVf<   RV RV P                   R2p\        P                  ! \        P
                  VR4       R# VP                  4       pVP                  V4      pRV RV RV 2p\        P                  ! \        P
                  VR4       V# )	z7Executes the named setter, returning True if succeeded.zDBUS SERVICE: Unknown setter 'r`   ra   TFzDBUS SERVICE: Setter 'z' with value 'rd   )rU   re   rQ   r   rY   rZ   unpackr@   )r3   rk   rl   rg   r\   Zunpackedrh      &&&    r   ExecuteRuntimeSetterZ,OrcaModuleDBusInterface.ExecuteRuntimeSetter   s     }}((52;-wtGXGXFYY[\C 0 0#t<<<>$$X.&{m>(<X^W_`E,,c48r   c                F   < V ^8  d   QhRS[ S[S[S[3,          ,          /# r)   r*   r+   r,   r-   rC   rE   r   r1   rO      s!      d5c?3 r   c                    . pV P                   P                  4        F!  w  r#VP                  W#P                  34       K#  	  V# )zNReturns a list of (command_name, description) for this module (commands only).)rR   r9   r;   r   r3   Zcommand_listcamel_case_namer[      &   r   ListCommandsZ$OrcaModuleDBusInterface.ListCommands   s@     %)^^%9%9%;!O2B2B CD &<r   c          	      sp   < V ^8  d   QhRS[ S[S[S[S[ S[S[S[3,          ,          3,          ,          /# rq   rr   rC   rE   r   r1   rO      s3      	eCd5c?334	5r   c                s    . pV P                   P                  4        F,  w  r#VP                  W#P                  VP                  34       K.  	  V# )zJReturns a list of (command_name, description, parameters) for this module.)rS   r9   r;   r   r8   rt   rv   r   ListParameterizedCommandsZ1OrcaModuleDBusInterface.ListParameterizedCommands   sI    
 %)%A%A%G%G%I!O2B2BDOO TU &Jr   c                rp   rq   rr   rC   rE   r   r1   rO      !      DsCx$9 r   c                rs   )z=Returns a list of (getter_name, description) for this module.)rT   r9   r;   r   )r3   Zgetter_listru   r[   rv   r   ListRuntimeGettersZ*OrcaModuleDBusInterface.ListRuntimeGetters   @     %)]]%8%8%:!O1A1ABC &;r   c                rp   rq   rr   rC   rE   r   r1   rO      ry   r   c                rs   )z=Returns a list of (setter_name, description) for this module.)rU   r9   r;   r   )r3   Zsetter_listru   r[   rv   r   ListRuntimeSettersZ*OrcaModuleDBusInterface.ListRuntimeSetters   r{   r   c                s,   < V ^8  d   QhRS[ RS[RS[/# )r)   command_namenotify_userr*   r-   rB   rC   rE   r   r1   rO     s"      3 T d r   c                s   WP                   9  d<   RV RV P                   R2p\        P                  ! \        P                  VR4       R# V P                   V,          pRV RV P                   R2p\        P                  ! \        P
                  VR4       VP                  V4      pRV RV P                   R	V R
V 2p\        P                  ! \        P
                  VR4       V# )zEExecutes the named command and returns True if the command succeeded.zDBUS SERVICE: Unknown command 'r`   ra   TF DBUS SERVICE: About to execute '' in 'DBUS SERVICE: 'z' executed. Result: z, notify_user: )rR   rQ   r   rY   LEVEL_WARNINGrZ   r@   )r3   r}   r~   r\   rg   rh   s   &&&   r   ExecuteCommandZ&OrcaModuleDBusInterface.ExecuteCommand  s     ~~-3L>IZIZH[[]^C 3 3S$?~~l30fTEVEVDWWYZE,,c48$$[1l^6$2C2C1D Ehok]< 	 	E,,c48r   c                sp   < V ^8  d   QhRS[ RS[S[ S[P                  3,          RS[RS[P                  /# )r)   r}   r8   r~   r*   )r-   dictr   r_   rB   rC   rE   r   r1   rO     sE     ( (( dll*+( 	(
 
(r   c                s   V P                   P                  V4      pV'       gQ   RV RV P                   R2p\        P                  ! \        P
                  VR4       \        P                  ! RR4      # VP                  4        UUu/ uF  w  rgWgP                  4       bK  	  pppW8R&   RV R	V P                   R2p\        P                  ! \        P                  VR4       VP                  ! R/ VB p	R
V R	V P                   R2p\        P                  ! \        P                  VR4       V P                  V	4      # u uppi )zBExecutes the named command with parameters and returns the result.z-DBUS SERVICE: Unknown parameterized command 'r`   ra   TbFr~   r   r   r   z' executed.r   )rS   re   rQ   r   rY   r   r   r_   r9   rm   rZ   r@   rf   )
r3   r}   r8   r~   rg   r\   ZnameZvariantkwargsrh   s
   &&&&      r   ExecuteParameterizedCommandZ3OrcaModuleDBusInterface.ExecuteParameterizedCommand  s1    3377E?~ N%%&b*   3 3S$?<<U++>H>N>N>PQ>P]T$((>PQ +}0fTEVEVDWWYZE,,c48$$.v.~VD4E4E3FkRE,,c48'' Rs   D>c                    V P                   # z0Returns the D-Bus interface XML for publication.Z__dbus_xml__r3      &r   for_publicationZ'OrcaModuleDBusInterface.for_publication3          r   c                s,   < V ^8  d   QhRS[ RS[RS[ /# )r)   function_namerA   r*   )r-   r   rC   rE   r   r1   rO   9  s,     
O 
O
O!
O 

Or   c                s   V\         P                  \         P                  39   d8   V P                  R4      '       g   V P                  R4      '       d
   V R,          p RP	                  R V P                  R4       4       4      # )zMNormalizes a Python function name for D-Bus exposure (getter/setter/command).Zget_Zset_:i   NNr2   c              3   s@   "   T F  qP                  4       x  K  	  R # 5irF   )Z
capitalize).0Zwordr    r   	<genexpr>ZBOrcaModuleDBusInterface._normalize_handler_name.<locals>.<genexpr>C  s     N5MT((5Ms   _)r   r   r   
startswithZjoinZsplit)r   rA   s   &&r   rW   Z/OrcaModuleDBusInterface._normalize_handler_name8  sh     K..0B0BCC''//=3K3KF3S3S -b 1wwN]5H5H5MNNNr   c                s   \        V \        4      '       d   \        P                  ! RV 4      # \        V \        4      '       d   \        P                  ! RV 4      # \        V \
        4      '       d   \        P                  ! RV 4      # \        V \        4      '       d   \        P                  ! RV 4      # \        V \        4      '       dY   \        P                  ! RV P                  4        UUu/ uF&  w  r\        V4      \        P                  ! RV4      bK(  	  upp4      # \        V \        \        34      '       Ed"   \        ;QJ d    R V  4       F  '       d   K   RM	  R	M! R V  4       4      '       d!   \        P                  ! R
\        V 4      4      # \        ;QJ d    R V  4       F  '       d   K   RM	  R	M! R V  4       4      '       d!   \        P                  ! R\        V 4      4      # \        ;QJ d    R V  4       F  '       d   K   RM	  R	M! R V  4       4      '       d!   \        P                  ! R\        V 4      4      # \        ;QJ d    R V  4       F  '       d   K   RM	  R	M! R V  4       4      '       d   V '       g   \        P                  ! R. 4      # \        V ^ ,          4      pV  Uu. uF/  p\        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      NK1  	  ppRRV,          ,           R,           p\        P                  ! RV 2V4      # \        P                  ! RV  Uu. uF  p\        P                  ! RV4      NK  	  up4      # V f-   \        P                  ! R\        P                  ! RR4      4      # \        P                  ! R\        V 4      4      # u uppi u upi u upi )zPConverts a Python value to a correctly-typed GLib.Variant for D-Bus marshalling.r   ZiZdrc   za{sv}rb   c              3   B   "   T F  p\        V\        4      x  K  	  R # 5irF   )
isinstancer-   r   xr    r   r   6OrcaModuleDBusInterface._to_variant.<locals>.<genexpr>U       6v!:a%%v   FTZasc              3   r   rF   )r   rB   r   r    r   r   r   W  s     71:a&&r   Zabc              3   r   rF   )r   intr   r    r   r   r   Y  r   r   Zaxc              3   sN   "   T F  p\        V\        \        34      x  K  	  R # 5irF   )r   r+   r,   r   r    r   r   r   [  s     @A:a$//s   #%Zavc              3   sL   "   T F  p\        T;'       g    R 4      x  K  	  R# 5i)r2   Nr-   )r   Zitemr    r   r   r   _  s     "Aqt3tzzr??qs   $$Z()Zar2   )r   rB   r   r_   r   Zfloatr-   r   r9   r+   r,   ZallrX   )rh   Zkrb   Z	first_lenr   Z	convertedr7   r<   r   rf   Z#OrcaModuleDBusInterface._to_variantE  s    fd##<<V,,fc""<<V,,fe$$<<V,,fc""<<V,,fd##<<6<<>R>41#a&$,,sA"66>RT TftUm,,s6v6sss6v666||D$v,77s77sss7777||D$v,77s6v6sss6v666||D$v,77s@@sss@@@@<<b11q	N	KQR6aUU"Aq"AUU"Aq"AA6	R#	/1C7	||a	{OY??<<V&LVt||C';V&LMM><<T\\#r%:;;||CV--% S S 'Ms   /,N1=N7%N7: N<
)rR   rT   rQ   rS   rU   )r   r   r   r   r   rH   rj   ro   rw   rx   rz   r|   r   r   r   Zstaticmethodr   r   rW   rf   r   rI   __classcell__r]   rD      @@r   rL   rL      s     R9 9<( (      &( (4!
  %0$7$7
O 
O 
O . . .r   rL   org.gnome.Orca.Servicec                   s   a a ] tR tRt oRtV3R lV 3R lltR tV3R lR ltV3R lR	 ltV3R
 lR lt	V3R lR lt
V3R lR ltV3R lR ltV3R lR ltV3R lR ltV3R lR ltRtVtV ;t# )OrcaDBusServiceInterfaceih  z;Internal D-Bus service object that handles D-Bus specifics.c                   < V ^8  d   QhRR/# r)   r*   Nr   rC   rE   r   r1   %OrcaDBusServiceInterface.__annotate__l  s     3 3$ 3r   c                sB   < \         SV `  4        \        4       V n        R # rF   )rP   rH   Zset_registered_modules)r3   r]      &r   rH   Z!OrcaDBusServiceInterface.__init__l  s    -0U r   c                r   r   r   r   r   r   r   Z(OrcaDBusServiceInterface.for_publicationp  r   r   c          
      sF   < V ^8  d   QhRS[ RS[S[,          RS[RS[ RR/# )r)   rM   rN   busobject_path_baser*   N)r-   r+   r>   r   rC   rE   r   r1   r   u  sB     ? ?? L)? 	?
 ? 
?r   c                s   V RV 2pWP                   9   dZ   RV R2p\        P                  ! \        P                  VR4        VP	                  V4       V P                   P                  V4        \        W4      pVP                  WX4       V P                   P                  V4       RV R	V R
2p\        P                  ! \        P                  VR4       R#   \
         d9   pRT RT 2p\        P                  ! \        P                  TR4        Rp?LRp?ii ; i  \
         d=   pRT R	T RT 2p\        P                  ! \        P                  TR4        Rp?R# Rp?ii ; i)z:Creates and prepares a D-Bus interface for an Orca module./zDBUS SERVICE: Interface z already registered. Replacing.Tz3DBUS SERVICE: Error unpublishing old interface for : Nz%DBUS SERVICE: Successfully published z at .zEDBUS SERVICE: Failed to create or publish D-Bus interface for module )r   r   rY   rZ   unpublish_objectr   discardrL   publish_objectZaddLEVEL_SEVERE)	r3   rM   rN   r   r   object_pathr\   eZmodule_ifaces	   &&&&&    r   add_module_interfaceZ-OrcaDBusServiceInterface.add_module_interfaceu  sb    **!K=9222,[M9XYC 0 0#t<A$$[1 $$,,[9	?2;NL{9$$((59+d;-WXYC 0 0#t<  AKK=XZ[\Z]^##E$4$4c4@@A  	?%d;-r!>   2 2C>>	?s1   C 2A&D  D%.DD E'+1E""E'c                s2   < V ^8  d   QhRS[ RS[RS[ RS[/# )r)   rM   r   r   r*   )r-   r   rB   rC   rE   r   r1   r     s3        	
 
r   c                s   WP                   9  d/   RV R2p\        P                  ! \        P                  VR4       R# V RV 2p VP	                  V4       V P                   P                  V4       RV RV R2p\        P                  ! \        P                  VR4       R#   \         d:   pR	T R
T 2p\        P                  ! \        P                  TR4        Rp?R# Rp?ii ; i)z=Removes and unpublishes a D-Bus interface for an Orca module.zDBUS SERVICE: Module z is not registered.TFr   z#DBUS SERVICE: Successfully removed z from r   z+DBUS SERVICE: Error removing interface for r   N)r   r   rY   r   r   r   rZ   r   )r3   rM   r   r   r\   r   r   s   &&&&   r   remove_module_interfaceZ0OrcaDBusServiceInterface.remove_module_interface  s     666)+6IJC 3 3S$?)*!K=9		  -$$,,[97}F;-WXYC 0 0#t< 	?}BqcRC 3 3S$?	s   AB$ $C(/.C##C(c                s0   < V ^8  d   QhRS[ S[,          /# rq   )r+   r-   rC   rE   r   r1   r     s     . .T#Y .r   c                s,    \        V P                  4      # )z*Returns a list of registered module names.)r+   r   r   r   r   ListModulesZ$OrcaDBusServiceInterface.ListModules  s     D,,--r   c                rp   rq   rr   rC   rE   r   r1   r     s!        d5c?3  r   c                s   . p\        V 4       F  pVP                  R4      '       d   K  V^ ,          P                  4       '       g   K;  \        W4      p\	        V4      '       g   KY  \        VR4      '       g   Km  VP                  '       d   VP                  P                  4       MRV 2pVP                  W$34       K  	  \        V4      # )z9Returns available commands on the main service interface.r   r   zService command: )
dirr   isupperrV   callabler:   r   Zstripr;   Zsorted)r3   Zcommands	attr_nameattrr   s   &    r   rw   Z%OrcaDBusServiceInterface.ListCommands  s     TI'',,11E1E1G1Gt/D>>gdI&>&>;?<<<4<<#5#5#7(9)&E  OOY$<= # hr   c                    < V ^8  d   QhRS[ /# rq   rB   rC   rE   r   r1   r     s       r   c                sL   Rp\         P                  ! \         P                  VR4       \        P                  ! 4       pVP                  4       ;'       g    VP                  4       pVf+   Rp\         P                  ! \         P                  VR4       R# VP                  4        R# )zShows Orca's preferences GUI.z%DBUS SERVICE: ShowPreferences called.T!DBUS SERVICE: No script availableF)	r   rY   rZ   r   get_managerget_active_scriptget_default_scriptr   Zshow_preferences_gui)r3   r\   managerr5   rv   r   ShowPreferencesZ(OrcaDBusServiceInterface.ShowPreferences  s     6E,,c48 ,,.**,LL0J0J0L>5C 3 3S$?##%r   c                &   < V ^8  d   QhRS[ RS[/# )r)   messager*   r   rC   rE   r   r1   r     s      c d r   c                sV   RV R2p\         P                  ! \         P                  VR4       \        P                  ! 4       pVP                  4       ;'       g    VP                  4       pVf+   Rp\         P                  ! \         P                  VR4       R# VP                  V4       R# )zPresents message to the user.z+DBUS SERVICE: PresentMessage called with: 'Z'Tr   F)	r   rY   rZ   r   r   r   r   r   Zpresent_message)r3   r   r\   r   r5   ri   r   PresentMessageZ'OrcaDBusServiceInterface.PresentMessage  s     <G9AFE,,c48 ,,.**,LL0J0J0L>5C 3 3S$?w'r   c                r   rq   r   rC   rE   r   r1   r     s     	 	C 	r   c                s    \         P                  p\         P                  '       d   VR\         P                   R2,          pRV 2p\        P                  ! \        P
                  VR4       V# )z1Returns Orca's version and revision if available.z (rev r   z,DBUS SERVICE: GetVersion called, returning: T)r
   ZversionZrevisionr   rY   rZ   )r3   rh   r\      &  r   
GetVersionZ#OrcaDBusServiceInterface.GetVersion  s^     &&!!!}556a88F<VHEE,,c48r   c                r   rq   r   rC   rE   r   r1   r     s      d r   c                s   a Rp\         P                  ! \         P                  VR4       ^RIHo V3R lp\
        P                  ! ^dV4       R# )z:Quits Orca. Returns True if the quit request was accepted.zDBUS SERVICE: Quit called.Torcac                  s(   < S P                  4        R # )F)shutdownr   s   r   _delayed_shutdownZ8OrcaDBusServiceInterface.Quit.<locals>._delayed_shutdown  s    MMOr   )r   rY   rZ   r2   r   r   Ztimeout_add)r3   r\   r   r   s   &  @r   QuitZOrcaDBusServiceInterface.Quit  s@     +E,,c48	 	/0r   c                s*   < V ^8  d   QhRS[ RS[RR/# )r)   r   r   r*   N)r   r-   rC   rE   r   r1   r     s$     ) )$5 ) )QU )r   c                s   Rp\         P                  ! \         P                  VR4       \        V P                  4       FH  pV RV 2pRV R2p\         P                  ! \         P                  VR4        VP                  V4       KJ  	  V P                  P                  4        R#   \         d:   pRT RT 2p\         P                  ! \         P                  TR4        Rp?K  Rp?ii ; i)	z>Releases D-Bus resources held by this service and its modules.z4DBUS SERVICE: Releasing D-Bus resources for service.Tr   z4DBUS SERVICE: Shutting down and unpublishing module z from main service.z/DBUS SERVICE: Error unpublishing interface for r   N)r   rY   rZ   r+   r   r   r   clear)r3   r   r   r\   rM   Zmodule_object_pathr   rn   r   shutdown_serviceZ)OrcaDBusServiceInterface.shutdown_service  s     EE,,c48 8 89K$4#5Q{m!DF{m T% &   0 0#t<A$$%78 : 	  &&(  AG}TVWXVYZ##E$4$4c4@@As   5B&&C*1.C%%C*)r   )r   r   r   r   r   rH   r   r   r   r   rw   r   r   r   r   r   r   rI   r   r   r   r   r   r   h  sw     E3 3!
? ?@ 2. .
       	 	 ") ) )r   r   c                   s   a  ] tR tRt o RtRtRtV 3R lR ltV 3R lR ltV 3R	 lR
 lt	V 3R lR lt
V 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltRtV tR# )OrcaRemoteControlleri  z0Manages Orca's D-Bus service for remote control.r   z/org/gnome/Orca/Servicec                r   r   r   rC   rE   r   r1   !OrcaRemoteController.__annotate__  s     	% 	%$ 	%r   c                s    R V n         RV n        R V n        R V n        / V n        ^ V n        ^ V n        ^ V n        ^ V n        R # )NF)	_dbus_service_interface_is_running_bus_event_loop_pending_registrations_total_commands_total_getters_total_setters_total_modulesr   r   r   rH   ZOrcaRemoteController.__init__  sI    HL$!&.2	-19;#$%#$#$#$r   c                r   rq   r   rC   rE   r   r1   r   "  s     0 0t 0r   c                s   V P                   '       d+   Rp\        P                  ! \        P                  VR4       R# Rp\        P                  ! \        P                  VR4        \	        4       V n        RV P
                  P                  P                  4        2p\        P                  ! \        P                  VR4       \        4       T n         T P
                  P                  T P                  T P                  4       T P
                  P                  T P                  4       RT n         R	T P                   R
T P                   R2p\        P                  ! \        P                  TR4       T P#                  4        T P%                  4        R#   \         d>   pRT n        RT 2p\        P                  ! \        P                  TR4        Rp?R# Rp?ii ; i  \         d   pRT 2p\        P                  ! \        P                  TR4       T P                  '       dK   T P
                  '       d9    T P
                  P!                  T P                  4       M  \         d     Mi ; iRT n        RT n         Rp?R# Rp?ii ; i)zStarts the D-Bus service.z?REMOTE CONTROLLER: Start called but service is already running.Tz5REMOTE CONTROLLER: Attempting to start D-Bus service.z/REMOTE CONTROLLER: SessionMessageBus acquired: Nz8REMOTE CONTROLLER: Failed to acquire D-Bus session bus: Fz>REMOTE CONTROLLER: Failed to publish service or request name: z(REMOTE CONTROLLER: Service started name=z path=r   )r   r   rY   rZ   r   r   Z
connectionZget_unique_namer   r   r   r   r   OBJECT_PATHZregister_serviceSERVICE_NAMEr   _process_pending_registrations_print_registration_summaryr3   r\   r   r   r   startZOrcaRemoteController.start"  s    SC 0 0#t<EE,,c48	)+DIA99''779:<   0 0#t< (@'A$	II$$T%5%5t7S7STII&&t'8'89  6t7H7H6I J$$%Q( 	 	E,,c48++-((*=  	DILQCPC 2 2C>		  
	RSTRUVC 2 2C>+++			II..t/?/?@  +/D(DI
	sW   &AF AG G2GGJ	)AJ9%IJI-*J,I--JJ	c                r   r   r   rC   rE   r   r1   r   T  s     , , ,r   c                s   V P                   '       g   R# R\        V P                   4       R2p\        P                  ! \        P                  VR4       V P                   P                  4        FB  w  r#RV R2p\        P                  ! \        P                  VR4       V P                  W#4       KD  	  V P                   P                  4        R# )zQProcesses any module registrations that were queued before the service was ready.NzREMOTE CONTROLLER: Processing z pending module registrations.Tz7REMOTE CONTROLLER: Processing pending registration for r   )r   rX   r   rY   rZ   r9   %_register_decorated_commands_internalr   )r3   r\   rM   module_instancerv   r   r   Z3OrcaRemoteController._process_pending_registrationsT  s     *** -S1L1L-M,N O, - 	 	E,,c48,0,G,G,M,M,O(KKK=XYZC 0 0#t<66{T -P
 	##))+r   c                $   < V ^8  d   QhRS[ RR/# r)   rM   r*   Nr   rC   rE   r   r1   r   f  s     Q QS Qd Qr   c                s   V P                   '       d%   V P                  '       d   V P                  '       g=   RV R2p\        P                  ! \        P
                  VR4       W P                  V&   R# V P                  W4       R# )z.Registers a module's decorated D-Bus commands.zIREMOTE CONTROLLER: Service not ready; queuing decorated registration for r   TN)r   r   r   r   rY   rZ   r   r   )r3   rM   r   r\   s   &&& r   register_decorated_moduleZ.OrcaRemoteController.register_decorated_modulef  sr     t'C'C'C4999"m1&   0 0#t<7F''422;Pr   c                r   r   r   rC   rE   r   r1   r   t  s      n9 n9 n9Z^ n9r   c           
     s   V P                   '       d%   V P                  '       d   V P                  '       g/   RV R2p\        P                  ! \        P
                  VR4       R# . p^ p^ p^ p\        V4       EF  p\        W(4      p	\        V	4      '       dc   \        V	R4      '       dQ   V	P                  p
V	3R lp\        VV
V! 4       \        P                  R7      pVP                  V4       V^,          pK  \        V	4      '       dm   \        V	R4      '       d[   V	P                  p
V	3R	 lp\        VV
V! 4       \        P                   \#        V	4      R
7      pVP                  V4       V^,          pK  \        V	4      '       dd   \        V	R4      '       dR   V	P$                  p
V	3R lp\        VV
V! 4       \        P&                  R7      pVP                  V4       V^,          pEKs  \        V	4      '       g   EK  \        V	R4      '       g   EK  V	P(                  p
V	3R lp\        VV
V! 4       \        P*                  R7      pVP                  V4       V^,          pEK  	  V'       g   R# V ;P,                  V,          un        V ;P.                  V,          un        V ;P0                  V,          un        V ;P2                  ^,          un        V P                  P5                  WV P                  V P6                  4       R\9        V4       RV R2p\        P                  ! \        P:                  VR4       R# )zIInternal method that registers decorated commands from a module instance.zUREMOTE CONTROLLER: Internal error - _register_decorated_commands_internal called for z but service is not ready.TNr   c                    a  V 3R  lpV# )c                 s"  < \         P                  ! 4       p\        P                  ! 4       P	                  4       pVf$   \        P                  ! 4       P                  4       pS! W!V R7      p\        P                  ! 4       P                  V4       V# )N)r5   r4   r~   r   ZRemoteControllerEventr   r   r   r   r	   Zprocess_remote_controller_event)r~   r4   r5   rvmethods   &   r   _wrapperZeOrcaRemoteController._register_decorated_commands_internal.<locals>._create_wrapper.<locals>._wrapper  so     + A A C!/!;!;!=!O!O!Q!>%3%?%?%A%T%T%VF#6KX ,779YYZ_`!	r   r   r   r      f r   _create_wrapperZSOrcaRemoteController._register_decorated_commands_internal.<locals>._create_wrapper      	" $Or   )r?   r   r@   rA   r"   c                 r   )c                  s&  < \         P                  ! 4       p\        P                  ! 4       P	                  4       pVf$   \        P                  ! 4       P                  4       pS! RRVRV/V B p\        P                  ! 4       P                  V4       V# )Nr5   r4   r   r   )r   r4   r5   r   r   s   ,   r   r   ZsOrcaRemoteController._register_decorated_commands_internal.<locals>._create_parameterized_wrapper.<locals>._wrapper  sz     + A A C!/!;!;!=!O!O!Q!>%3%?%?%A%T%T%VF#I6II&I ,779YYZ_`!	r   r   r   r   r   _create_parameterized_wrapperZaOrcaRemoteController._register_decorated_commands_internal.<locals>._create_parameterized_wrapper  r   r   rG   r$   c                 s   a  RV 3R llpV# )Nc                 s   < S! 4       # rF   r   )Z_notify_userr   r   r   r   ZlOrcaRemoteController._register_decorated_commands_internal.<locals>._create_getter_wrapper.<locals>._wrapper  s
    %xr   rF   r   r   r   r   _create_getter_wrapperZZOrcaRemoteController._register_decorated_commands_internal.<locals>._create_getter_wrapper  s    (#Or   r'   c                 r   )c                 s   < S! V 4      # rF   r   )rl   r   r   r   r   ZlOrcaRemoteController._register_decorated_commands_internal.<locals>._create_setter_wrapper.<locals>._wrapper  s    %e},r   r   r   r   r   _create_setter_wrapperZZOrcaRemoteController._register_decorated_commands_internal.<locals>._create_setter_wrapper  s    -#Or   z+REMOTE CONTROLLER: Successfully registered z% commands/getters/setters for module r   )r   r   r   r   rY   r   r   rV   r   r:   r   r>   r   r   r;   r"   r   r=   r$   r   r'   r   r   r   r   r   r   r   rX   rZ   )r3   rM   r   r\   rN   Zcommands_countZgetters_countZsetters_countr   r   r   r   rg   r   r   r   s   &&&             r   r   Z:OrcaRemoteController._register_decorated_commands_internalt  s    t'C'C'C4999)]*DF   2 2C>_-I?6D~~'$0J"K"K";;+/ $  ,)2 +*,!,!4!4	  $$\2!#$GD2Z$[$["II9= $  ,)2 +8:!,!B!B;DA  $$\2!#$GD2K$L$L"::26 $  ,)2 +13!,!3!3	  $$\2"$GD2K$L$L"::26 $  ,)2 +13!,!3!3	  $$\2"] .` .},},q $$99		43C3C	E :#m:L9M N33>-qB 	 	E,,c48r   c                r   )r)   rM   r*   r   rC   rE   r   r1   r     s     6 6c 6d 6r   c                s   WP                   9   d<   RV R2p\        P                  ! \        P                  VR4       V P                   V R# V P                  '       d%   V P
                  '       d   V P                  '       g/   RV R2p\        P                  ! \        P                  VR4       R# V P
                  P                  WP                  V P                  4      # )z.Deregisters D-Bus commands for an Orca module.z5REMOTE CONTROLLER: Removing pending registration for r   Tz2REMOTE CONTROLLER: Cannot deregister commands for z+; service not running or bus not available.F)
r   r   rY   rZ   r   r   r   r   r   r   )r3   rM   r\   s   && r   deregister_module_commandsZ/OrcaRemoteController.deregister_module_commands  s     555I+VWXC 0 0#t<++K8t'C'C'C4999D[M R< <   3 3S$?++CCD$4$46 	6r   c                r   r   r   rC   rE   r   r1   r     s     #  # $ # r   c                s\   V P                   '       g+   Rp\        P                  ! \        P                  VR4       R# Rp\        P                  ! \        P                  VR4       V P                  '       dp   V P
                  '       d^   V P                  P                  V P
                  V P                  4        V P
                  P                  V P                  4       RV n        V P
                  '       dH    V P
                  P                  V P                  4       V P
                  P                  4        RV n        RV n         Rp\        P                  ! \        P                  VR4       V P                  P                  4        ^ V n        ^ V n        ^ V n        ^ V n        R#   \         d7   pRT 2p\        P                  ! \        P                  TR4        Rp?ELRp?ii ; i  \         d7   pRT 2p\        P                  ! \        P                  TR4        Rp?ELRp?ii ; i)	zShuts down the D-Bus service.z>REMOTE CONTROLLER: Shutdown called but service is not running.TNz9REMOTE CONTROLLER: Attempting to shut down D-Bus service.z;REMOTE CONTROLLER: Error unpublishing main service object: z-REMOTE CONTROLLER: Error releasing bus name: Fz+REMOTE CONTROLLER: D-Bus service shut down.)r   r   rY   rZ   r   r   r   r   r   r   Zunregister_servicer   Z
disconnectr   r   r   r   r   r   r   r   r   r   ZOrcaRemoteController.shutdown  s    RC 0 0#t<IE,,c48'''DIII((99$))TEUEUVA		**4+;+;< ,0D(999A		,,T->->? II  "DI ;E,,c48##))+ +  ASTUSVW##E$4$4c4@@A  AEaSI##E$4$4c4@@As0   :%F& 9%G* &G'1+G""G'*H+5+H&&H+c                r   rq   r   rC   rE   r   r1   r     s        D  r   c                r   )z1Checks if the D-Bus service is currently running.)r   r   r   r   
is_runningZOrcaRemoteController.is_running  s     r   c                r   rq   )r   rC   rE   r   r1   r   "  s       r   c                sf   V P                   '       g   ^ # ^ p\        V P                   4       F  pVP                  R4      '       d   K  V^ ,          P                  4       '       g   K;  \	        V P                   V4      p\        V4      '       g   Kd  \        VR4      '       g   Kx  V^,          pK  	  V# )zNCounts the system-wide D-Bus commands available on the main service interface.r   r   )r   r   r   r   rV   r   r:   )r3   Zsystem_commandsr   r   rv   r   _count_system_commandsZ+OrcaRemoteController._count_system_commands"  s     +++T99:I'',,11E1E1G1Gt;;YGD>>gdI&>&>#q(O	 ;
 r   c                r   r   r   rC   rE   r   r1   r   0  s     9 9T 9r   c                sT   V P                  4       pV P                  V P                  ,           V P                  ,           pRV P                   RV P                   RV P                   RV P                   RV RW!,            R2p\
        P                  ! \
        P                  VR4       R	# )
z2Prints a summary of all registered D-Bus handlers.z3REMOTE CONTROLLER: Registration complete. Summary: z
 modules, z module commands, z module getters, z module setters, z" system commands. Total handlers: r   TN)r   r   r   r   r   r   rY   rZ   )r3   Zsystem_commands_countZtotal_handlersr\   rv   r   r   Z0OrcaRemoteController._print_registration_summary0  s     !% ; ; =--0C0CCdFYFYYA""#:##$$6""##4""##4$% &-EFaI 	 	E,,c48r   )	r   r   r   r   r   r   r   r   r   N)r   r   r   r   r   r   r   rH   r   r   r   r   r   r   r   r   r   r   rI   rJ   rK   r   r   r     s}     :+L+K	% 	%0 0d, ,$Q Qn9 n9`6 6(#  # J   
 9 9r   r   c                s$    V ^8  d   QhR\         /# rq   )r   r.   r0   r   r1   r1   B  s      3 r   c                 s    \         # )z+Returns the OrcaRemoteController singleton.)_remote_controllerr   r   r   get_remote_controllerr   B  s
     r   c                s@    V ^8  d   Qh/ ^ \         9   d
   \        ;R&   # )r)   r   )__conditional_annotations__r   r.   r0   r   r1   r1      s     ? ?B B A( AC @r   )+r   r   Z__id__Z__version__Z__date__Z__copyright__Z__license__r   r6   Ztypingr    Zdasbus.connectionr   Zdasbus.errorr   Zdasbus.loopr   Zdasbus.server.interfacer   Zdasbus.server.publishabler   Zgi.repositoryr   r2   r   r   r	   r
   r   ZEnumr   r!   r#   r%   r(   r=   r>   rL   r   r   r   r   r1   )r   rK   r   <module>r      s   > @7    / " ! 2 1    !  $)) (.B B$ '(.k . ).D ()f){ f) *f)Pm9 m9^	 ,@+A  Ar   