如何有选择地禁用GDBus“PropertiesChanged”信号?

时间:2018-01-23 18:14:37

标签: gdbus

我正在使用gdbus-codegen工具使用自动生成的GDBus工具为C中的应用程序构建MPRIS D-Bus Interface

当属性被更改时,会自动生成“PropertiesChanged”信号,这在大多数时候都很好,但在MPRIS规范中,它指出当“位置”属性发生变化时,the "PropertiesChanged" signal should not be emitted。< / p>

是否有任何阻止信号发送的好方法?

1 个答案:

答案 0 :(得分:0)

This is currently not possible, due to a missing feature in GLib. Once that feature is implemented, you should be able to annotate the Position property with org.freedesktop.DBus.Property.EmitsChangedSignal to cause gdbus-codegen to not emit signals for it.

This would use the following introspection XML, for example:

<property name="Position" type="x" access="read">
  <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false"/>
</property>

If you want to help out on the GLib bug, that would be appreciated (at the least, subscribe to it to hear when it’s fixed). I will try and find time to review the patch soon, but can make no guarantees.