+
    icwL  c                   s    ^ RI t ^ RIHtHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
HtHt ^ RIHtHt ^ RIHtHtHt ^ RIt]P*                  ! R	R
4       ^ RIHt ] P0                  ! ]4      t. ROt ! R R]4      t ! R R]R7      t ! R R]4      tR# )i    N)ABCMetaabstractmethod)partial)ErrorMapper)Signal)get_xml"are_additional_arguments_supported)DBusSpecificationDBusSpecificationError)get_variantunwrap_variantis_tuple_of_oneGioz2.0)r   
GLibServerAbstractServerObjectHandlerServerObjectHandlerc                   s   a  ] tR t^,t o Rt]RR l4       t]RR l4       t]R 4       t]R 4       t	]R 4       t
]R 4       t]R	 4       t]R
 4       tRtV tR# )r   z0The low-level DBus server library based on GLib.Nc                s0    VP                  VVVVV4       R# )zEmit a DBus signal.N)emit_signal)cls
connectionobject_pathinterface_namesignal_name
parametersZdestinations   &&&&&&&:/usr/lib/python3.14/site-packages/dasbus/server/handler.pyr   ZGLibServer.emit_signal/   s!     		
    c                sN   \         P                  P                  V4      p\        V P                  WE3R7      p. pVP
                  '       g   \        R4      hVP
                   F)  p	VP                  VV	VRR4      p
VP                  V
4       K+  	  \        V P                  VV4      # )zRegister an object on DBus.)	user_dataz$No DBus interfaces for registration.N)
r   ZDBusNodeInfoZnew_for_xmlr   _object_callbackZ
interfacesr   register_objectappend_unregister_object)r   r   r   Z
object_xmlcallbackcallback_argsZ	node_infoZmethod_call_closureregistrationsZinterface_inforegistration_ids   &&&&&&     r   r   ZGLibServer.register_object;   s     $$00
	 &  /
 ###(6  (22N(88#O   1 3 ""
 	
r   c                s:    V F  pVP                  V4       K  	  R# )zUnregister an object from DBus.N)Zunregister_object)r   r   r    r!      &&& r   r   ZGLibServer._unregister_object]   s      -O((9  -r   c	                s(    Vw  rV	! VVVV.V
O5!   R # N )r   r   senderr   r   method_namer   
invocationr   r   r   s   &&&&&&&&&  r   r   ZGLibServer._object_callbackc   s,    
 #, 			

 	
r   c                s&    RVP                  4       /# )a	  Get information about the DBus call.

Supported items:

    sender str: The bus name that invoked the method

There can be more supported items in the future.

:param invocation: an invocation of a DBus call
:return: a dictionary of information about the DBus call
r%   )Z
get_sender)r   r'   s   &&r   get_call_infoZGLibServer.get_call_infos   s     j++-
 	
r   c                s(    VP                  W#4       R# )zSet the error of the DBus call.

:param invocation: an invocation of a DBus call
:param error_name: a DBus name of the error
:param error_message: an error message
N)Zreturn_dbus_error)r   r'   
error_nameZerror_message   &&&&r   set_call_errorZGLibServer.set_call_error   s     	$$Z?r   c                sJ    V P                  W#4      pVP                  V4       R# )zSet the reply of the DBus call.

:param invocation: an invocation of a DBus call
:param out_type: a type of the reply
:param out_value: a value of the reply
N)_get_reply_valueZreturn_value)r   r'   out_type	out_valueZreply_value   &&&& r   set_call_replyZGLibServer.set_call_reply   s"     **8?,r   c                sL    Vf   R# \        V4      '       d   V3p\        W4      # )z%Get the reply value of the DBus call.N)r   r	   )r   r-   r.      &&&r   r,   ZGLibServer._get_reply_value   s*     8$$"I8//r   r$   r#   )r$   )__name__
__module____qualname____firstlineno____doc__Zclassmethodr   r   r   r   r(   r+   r0   r,   __static_attributes____classdictcell____classdict__   @r   r   r   ,   s     :	
 	
 
 
B : :
 
 
 
 
  @ @ - - 0 0r   c                   s   a  ] tR t^t o Rt. ROtR t]R 4       tR t	]
R 4       t]
R 4       t]
R 4       t]
R 4       t]
R	 4       tR
 tR tR tR t]
R 4       tRtV tR# )r   z+The abstract handler of a published object.c                s8    Wn         W n        W0n        RV n        R# )zCreate a new handler.

:param message_bus: a message bus
:param object_path: a DBus path of the object
:param obj: a Python instance of the object
N_message_bus_object_path_object_specification)selfmessage_busr   objr*   r   __init__Z$AbstractServerObjectHandler.__init__   s     ('"r   c                sh    V P                   '       g   V P                  4       V n         V P                   # )zDBus specification.)r@   _get_specificationrA      &r   specificationZ)AbstractServerObjectHandler.specification   s-     """"&"9"9";D"""r   c                sJ    \         P                  ! V P                  4       4      # )z;Get the DBus specification.

:return: a DBus specification
)r   Zfrom_xml_get_xml_specificationrF   rG   r   rE   Z.AbstractServerObjectHandler._get_specification   s#    
 !))'')
 	
r   c                    R# )9Get the XML specification.

:return: a XML specification
Z r$   rF   rG   r   rI   Z2AbstractServerObjectHandler._get_xml_specification   s     r   c                rJ   )zConnect the object to DBus.

Handle emitted signals of the object with the _emit_signal
method and handle incoming DBus calls with the _handle_call
method.
Nr$   rF   rG   r   connect_objectZ*AbstractServerObjectHandler.connect_object        	r   c                rJ   )zTDisconnect the object from DBus.

Unregister the object and disconnect all signals.
Nr$   rF   rG   r   disconnect_objectZ-AbstractServerObjectHandler.disconnect_object   s     	r   c                rJ   )zlConnect a DBus signal.

:param interface_name: a DBus interface name
:param signal_name: a DBus signal name
Nr$   rA   r   r   r1   r   _connect_signalZ+AbstractServerObjectHandler._connect_signal   s     	r   c                rJ   )zHandle a DBus signal.

:param interface_name: a DBus interface name
:param signal_name: a DBus name of the signal
:param parameters: a signal parameters
Nr$   )rA   r   r   r   s   &&&*r   _emit_signalZ(AbstractServerObjectHandler._emit_signal   rM   r   c                sZ    V P                  W4      p\        V4      '       g   / pV! V/ VB # )zHandle a DBus call.

:param interface_name: a name of the interface
:param method_name: a name of the called method
:param parameters: parameters of the call
:param additional_args: additional arguments of the call
:return: a result of the DBus call
)_find_handlerr   )rA   r   r&   r   additional_argshandlers   &&&*, r   _handle_callZ(AbstractServerObjectHandler._handle_call   s6     $$^A 2':: O
6o66r   c                s8    V P                   P                  W4      # )zFind a specification of the DBus member.

:param interface_name: a name of the interface
:param member_name: a name of the member
:return: a specification of the member
)rH   Z
get_memberrA   r   member_namer1   r   _find_member_specZ-AbstractServerObjectHandler._find_member_spec  s      !!,,
 	
r   c                s    V P                  W4      ;'       g    V P                  W4      pV'       g   \        RP                  W4      4      hV# )zFind a handler of a DBus member.

:param interface_name: a name of the interface
:param member_name: a name of the method
:return: a handler
z The member {}.{} has no handler.)_find_object_handler_find_default_handlerAttributeErrorformat)rA   r   rW   rT   r"   r   rR   Z)AbstractServerObjectHandler._find_handler  s[     ++NH G G)).F 	  !C!J!J"   r   c                s0    \        V P                  VR4      # )a-  Get an object handler of a DBus call.

By default, DBus interfaces with members of the same name are
not supported, so the given interface name is not used to find
the object handler.

:param interface_name: a name of the interface.
:param member_name: a name of the member
:return: a handler or None
N)getattrr?   rV   r1   r   rY   Z0AbstractServerObjectHandler._find_object_handler'  s     t||[$77r   c                rJ   )Find a default handler of a DBus call.

:param interface_name: a name of the interface
:param member_name: a name of the member
:return: a handler or None
Nr$   rV   r1   r   rZ   Z1AbstractServerObjectHandler._find_default_handler4  rM   r   )r=   r?   r>   r@   Nr<   )r2   r3   r4   r5   r6   	__slots__rD   propertyrH   rE   r   rI   rL   rN   rP   rQ   rU   rX   rR   rY   rZ   r7   r8   r9   r;   r   r   r      s     5I
# # #
          7$	
"8  r   )Z	metaclassc                   s   a a ] tR tRt oRt. ROtR]]3V 3R lltR t	R t
R tR tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR t]R 4       tRtVtV ;t# )r   i?  z+The handler of an object published on DBus.Nc                s   < \         SV `  WV4       WPn        W`n        T;'       g    \	        4       V n        . V n        R# )a	  Create a new handler.

:param message_bus: a message bus
:param object_path: a DBus path of the object
:param obj: a Python instance of the object
:param error_mapper: a DBus error mapper
:param server: a DBus server library
:param signal_factory: a signal factory
N)ZsuperrD   _server_signal_factoryr   _error_mapper_registrations)rA   rB   r   rC   Zerror_mapperZserverZsignal_factory	__class__s   &&&&&&&r   rD   ZServerObjectHandler.__init__I  s9     	37-)::[] r   c                s,    \        V P                  4      # )rK   )r   r?   rF   rG   r   rI   Z*ServerObjectHandler._get_xml_specificationZ  s    
 t||$$r   c                sF    V P                  4        V P                  4        R# )zConnect the object to DBus.N)_register_object_connect_signalsrF   rG   r   rL   Z"ServerObjectHandler.connect_objecta  s    r   c                sp    V P                   '       d$   V P                   P                  4       pV! 4        K5  R# )z Disconnect the object from DBus.N)rd   Zpop)rA   r      & r   rN   Z%ServerObjectHandler.disconnect_objectf  s,    !!!**..0HJ "r   c                s    V P                   P                  V P                  P                  V P                  V P                  4       V P                  4      pV P                  P                  V4       R# )z<Register to DBus calls.

:return: an unregistering callback
N)	ra   r   r=   r   r>   rI   _method_callbackrd   r   )rA   Z
unregisterrh   r   rf   Z$ServerObjectHandler._register_objectl  s[    
 \\11(('')!!	

 	"":.r   c                s    V P                   P                   FK  p\        V\        P                  4      '       g   K%  V P                  VP                  VP                  4       KM  	  R# )zConnect all DBus signals.N)rH   members
isinstancer   r   rP   r   name)rA   memberrh   r   rg   Z$ServerObjectHandler._connect_signalsz  sM    ((00Ff&7&>&>??  %%	 1r   c                s    V P                  W4      pV P                  W4      pVP                  V4       \        VP                  V4      pV P
                  P                  V4       R# )zConnect a DBus signal.

:param interface_name: a DBus interface name
:param signal_name: a DBus signal name
:return: a disconnecting callback
N)_find_emitterrR   Zconnectr   
disconnectrd   r   )rA   r   r   r   Zsignalro   s   &&&   r   rP   Z#ServerObjectHandler._connect_signal  sV     %%nB##N@x V..9
"":.r   c                s.    \        V P                  W4      # )zFind an emitter of a DBus signal.

:param interface_name: a DBus interface name
:param signal_name: a DBus signal name
:return: a callback
)r   rQ   rO   r1   r   rn   Z!ServerObjectHandler._find_emitter  s     t((.FFr   c                s    V P                  W4      pV'       g   RpVP                  e   \        VP                  V4      pV P                  P	                  V P
                  P                  V P                  VVV4       R# )zHandle a DBus signal.

:param interface_name: a DBus interface name
:param signal_name: a DBus signal name
:param parameters: a signal parameters
N)rX   typer	   ra   r   r=   r   r>   )rA   r   r   r   rm   s   &&&* r   rQ   Z ServerObjectHandler._emit_signal  si     ''DJ;;"$V[[*=J  ((	
r   c                s    V P                  VVVV4      pV P                  VV4      pV P                  ! VV.\        V4      O5/ VB pV P	                  VVV4       R#   \
         d    pT P                  TTTT4        Rp?R# Rp?ii ; i)zThe callback for a DBus call.

:param invocation: an invocation of the DBus call
:param interface_name: a DBus interface name
:param method_name: a DBus method name
:param parameters: a variant of DBus arguments
N)_get_additional_argumentsrX   rU   r
   _handle_method_resultZ	Exception_handle_method_error)	rA   r'   r   r&   r   rS   rm   Zresulterrors	   &&&&&    r   ri   Z$ServerObjectHandler._method_callback  s    	"<<	O ++F &&  
+ "	F &&
  	%%	 	s   AA B(BBc                s<    RV P                   P                  V4      /# )a  Get additional arguments of a DBus call.

Supported items:

    call_info dict: Information about the DBus call

This method is useful for customizations. It shouldn't be changed
in this library unless we make sure that the change won't break
the existing use cases.

:param invocation: an invocation of the DBus call
:param interface_name: a DBus interface name
:param method_name: a DBus method name
:param parameters: a variant of DBus arguments
:return: a dictionary of additional info
Z	call_info)ra   r(   )rA   r'   r   r&   r   s   &&&&&r   rq   Z-ServerObjectHandler._get_additional_arguments  s"    & 33J?
 	
r   c                s    \         P                  RW#RR7       V P                  P                  \	        V4      4      pV P
                  P                  VV\        V4      4       R# )zHandle an error of a DBus call.

:param invocation: an invocation of the DBus call
:param interface_name: a DBus interface name
:param method_name: a DBus method name
:param error: an exception raised during the call
z,The call %s.%s has failed with an exception:T)Zexc_infoN)logZwarningrc   Zget_error_namerp   ra   r+   Zstr)rA   r'   r   r&   rt   r)   s   &&&&& r   rs   Z(ServerObjectHandler._handle_method_error  s]     	:$ 	 	
 ''66K

 	##J	
r   c                sT    V P                   P                  VVP                  V4       R# )zHandle a result of a DBus call.

:param invocation: an invocation of a DBus call
:param method_spec: a method specification
:param method_reply: a method reply
N)ra   r0   r-   )rA   r'   Zmethod_specZmethod_replyr*   r   rr   Z)ServerObjectHandler._handle_method_result  s%     	##  	
r   c                s    VR8X  dM   VR8X  d   V P                   # VR8X  d   V P                  # VR8X  d   V P                  # VR8X  d   V P                  # R# )r^   zorg.freedesktop.DBus.PropertiesZGetZSetZGetAllZPropertiesChangedN)_get_property_set_property_get_all_properties_properties_changedrV   r1   r   rZ   Z)ServerObjectHandler._find_default_handler  sa     >>e#)))%)))(/// 33///r   c                s    V P                  W4      pVP                  '       g   \        RP                  W4      4      h\	        V P
                  V4      p\        VP                  V4      # )zThe default handler of the Get method.

:param interface_name: an interface name
:param property_name: a property name
:return: a variant with a property value
z#The property {}.{} is not readable.)rX   readabler[   r\   r]   r?   r	   rp   )rA   r   property_namerm   Zvalues   &&&  r   rv   Z!ServerObjectHandler._get_property&  s^     ''F !F!M!M"   m46;;..r   c                s    V P                  W4      pVP                  '       g   \        RP                  W4      4      h\	        V P
                  V\        V4      4       R# )zThe default handler of the Set method.

:param interface_name: an interface name
:param property_name: a property name
:param property_value: a variant with a property value
z#The property {}.{} is not writable.N)rX   Zwritabler[   r\   Zsetattrr?   r
   )rA   r   r{   Zproperty_valuerm   r/   r   rw   Z!ServerObjectHandler._set_property7  sR     ''F !F!M!M"   	m^N-KLr   c                s    V P                   P                   Uu. uFX  p\        V\        P                  4      '       g   K%  VP
                  V8X  g   K8  VP                  '       g   KL  VP                  NKZ  	  up# u upi )zxFind all properties of the given interface.

:param interface_name: an interface name
:return: a list of property names
)rH   rj   rk   r   ZPropertyr   rz   rl   )rA   r   rm      && r   _find_all_propertiesZ(ServerObjectHandler._find_all_propertiesG  sm     '+&8&8&@&@
&@F&"3"<"<= %%7   FKK&@
 	
 
s   "A: A:A:'A:c                sl    V P                  V4       Uu/ uF  pW P                  W4      bK  	  up# u upi )zxThe default handler of the GetAll method.

:param interface_name: an interface name
:return: a dictionary of properties
)r}   rv   )rA   r   r{   r|   r   rx   Z'ServerObjectHandler._get_all_propertiesT  sB     "&!:!:>!J
!J --nLL!J
 	
 
s   1c                s"    V P                  4       # )zHThe default handler of the PropertiesChanged method.

:return: a signal
)rb   rF   rG   r   ry   Z'ServerObjectHandler._properties_changed_  s     ##%%r   )rc   rd   ra   rb   )ra   rb   rc   rd   )r2   r3   r4   r5   r6   r_   r   r   rD   rI   rL   rN   rf   rg   rP   rn   rQ   ri   rq   rs   rr   rZ   rv   rw   r}   rx   r`   ry   r7   r8   Z__classcell__)re   r:   s   @@r   r   r   ?  s     5I DH"6!"% 
/	/G
.%N
,
,
&/"M 
	
 & & &r   )r   r   r   ) ZloggingZabcr    r   Z	functoolsr   Zdasbus.errorr   Zdasbus.signalr   Zdasbus.server.interfacer   r   Zdasbus.specificationr   r   Zdasbus.typingr	   r
   r   ZgiZrequire_versionZgi.repositoryr   Z	getLoggerr2   ru   Z__all__Zobjectr   r   r   r$   r   r   <module>r~      s|   *  '  $   O J F F 	   5%   !v0 v0rWG Wtf&5 f&r   