+
    ic  c                   s    ^ RI 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Ht . ROtR
 t ! R R]4      t ! R R]4      t ! R R	]R7      tR# )i    )ABCMeta)defaultdictwraps)Dict)dbus_signalget_xml)DBusSpecificationDBusSpecificationError)get_variantStrVariantListPropertiesExceptionPropertiesInterfacec                s0   a  \        S 4      V 3R l4       pV# )a  Decorator for emitting properties changes.

The decorated method has to be a member of a class that
inherits PropertiesInterface.

:param method: a DBus method of a class that inherits PropertiesInterface
:return: a wrapper of a DBus method that emits PropertiesChanged
c                 s@   < S! V .VO5/ VB pV P                  4        V# )N)flush_changes)objZargsZkwargsZresultmethods   &*, ;/usr/lib/python3.14/site-packages/dasbus/server/property.pywrapperZ)emits_properties_changed.<locals>.wrapper1   s(    -d-f-    r   )r   r   s   f r   emits_properties_changedr   (   s"     6] 
 Nr   c                   s    ] tR t^:tRtRtR# )r   zException for DBus properties. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r   r   r   r   r   :   s    (r   c                   sB   a  ] tR t^?t o RtR tR tR tR tR t	Rt
V tR# )	PropertiesChangeszCache for properties changes.

This class is useful to collect the changed properties
and their values, before they are emitted on DBus.
c                s\    Wn         \        4       V n        V P                  V4      V n        R# )z>Create the cache.

:param obj: an object with DBus properties
N)_objectset_properties_names_find_properties_specs_properties_specs)selfr      &&r   __init__ZPropertiesChanges.__init__F   s&    
 !$!%!<!<S!Ar   c                s8   \         P                  ! \        V4      4      p/ pVP                   Fh  p\	        V\         P
                  4      '       g   K%  VP                  V9   d%   \        RP                  VP                  4      4      hWCVP                  &   Kj  	  V# )zFind specifications of DBus properties.

:param obj: an object with DBus properties
:return: a map of property names and their specifications
z9DBus property '{}' is defined in more than one interface.)	r   Zfrom_xmlr   ZmembersZ
isinstanceZPropertynamer   format)r#   r   ZspecificationZproperties_specsmembers   &&   r   r!   Z(PropertiesChanges._find_properties_specsO   s     *2273<@#++Ff&7&@&@AA{{..,%%+VFKK%8 
 -3V[[) ,  r   c                sD   V P                   p\        4       V n         \        \        4      pV Fa  pV P                  V,          p\        V P                  V4      p\        VP                  V4      pWbVP                  ,          VP                  &   Kc  	  VP                  4       # )a.  Flush the cache.

The content of the cache will be composed to requests
and the cache will be cleared.

The requests can be used to emit the PropertiesChanged
signal. The requests are a list of tuples, that contain
an interface name and a dictionary of properties changes.

:return: a list of requests
)r    r   r   Zdictr"   Zgetattrr   r	   ZtypeZinterface_namer&   Zitems)r#   Zcontentrequestsproperty_namer(   ZvalueZvariants   &      r   flushZPropertiesChanges.flushf   s     ((!$t$$M++M:F DLL-8E!&++u5G <CV**+FKK8 % ~~r   c                sZ    WP                   9  d   \        RP                  V4      4      hR# )z$Check if the property name is valid.z!DBus object has no property '{}'.N)r"   r   r'   r#   r*   r$   r   check_propertyZ PropertiesChanges.check_property   s1     6 66%3::!  7r   c                s^    V P                  V4       V P                  P                  V4       R# )zUpdate the cache.N)r-   r    Zaddr,   r$   r   updateZPropertiesChanges.update   s$    M*""=1r   )r   r    r"   N)r   r   r   r   r   r%   r!   r+   r-   r.   r   __classdictcell____classdict__   @r   r   r   ?   s)     B . :2 2r   r   c                   sR   a  ] tR t^t o RtR t]V 3R lR l4       tR tR t	Rt
V tR# )	r   a  Standard DBus interface org.freedesktop.DBus.Properties.

DBus objects don't have to inherit this class, because the
DBus library provides support for this interface by default.
This class only extends this support.

Report the changed property:

.. code-block:: python

    self.report_changed_property('X')

Emit all changes when the method is done:

.. code-block:: python

    @emits_properties_changed
    def SetX(x: Int):
        self.set_x(x)

c                s&    \        V 4      V n        R# )zInitialize the interface.N)r   _properties_changes)r#   s   &r   r%   ZPropertiesInterface.__init__   s    #4T#: r   c                sR   < V ^8  d   QhRS[ RS[S[ S[3,          RS[S[ ,          /# )i   	interfacechangedinvalid)r
   r   r   r   )r'   r1   s   "r   Z__annotate__Z PropertiesInterface.__annotate__   s0     	 	3 	c7l9K 	#'9	r   c                s    R# )zStandard signal properties changed.

:param interface: a name of an interface
:param changed: a dictionary of changed properties
:param invalid: a list of invalidated properties
:return:
Nr   )r#   r4   r5   r6   s   &&&&r   PropertiesChangedZ%PropertiesInterface.PropertiesChanged   s     	r   c                s<    V P                   P                  V4       R# )zPReports changed DBus property.

:param property_name: a name of a DBus property
N)r3   r.   r,   r$   r   report_changed_propertyZ+PropertiesInterface.report_changed_property   s    
 	  ''6r   c                st    V P                   P                  4       pV F  w  r#V P                  W#. 4       K  	  R# )zFlush properties changes.N)r3   r+   r7   )r#   r)   r4   Zchangess   &   r   r   Z!PropertiesInterface.flush_changes   s3    ++113"*I""9r: #+r   )r3   N)r   r   r   r   r   r%   r   r7   r8   r   r   r/   r0   r2   r   r   r      s2     ,; 	 	7; ;r   )Z	metaclassN)r   r   r   )Zabcr    Zcollectionsr   Z	functoolsr   Ztypingr   Zdasbus.server.interfacer   r   Zdasbus.specificationr   r   Zdasbus.typingr	   r
   r   r   Z__all__r   Z	Exceptionr   Zobjectr   r   r   r   r   <module>r9      sR   0  #   8 J 9 9$	) 	
P2 P2f3;G 3;r   