Tracker: Signals On Changes
Contents
About
Applications want to subscribe to changes in Tracker's RDF store. This way they can know when would be a good time to update their views.
API for applications
This runs in the tracker-store Daemon and is made available as DBus API for applications.
- DBus service : org.freedesktop.Tracker1
- DBus interface : org.freedesktop.Tracker1.Resources.Class
org.freedesktop.Tracker1.Resources.Class
<node name="/org/freedesktop/Tracker1/Resources/Classes/$pfx/$class_name">
<interface name="org.freedesktop.Tracker1.Resources.Class">
<signal name="SubjectsChanged">
<arg type="as" name="subject" />
<arg type="as" name="predicate" />
</signal>
<signal name="SubjectsAdded">
<arg type="as" name="subject" />
</signal>
<signal name="SubjectsRemoved">
<arg type="as" name="subject" />
</signal>
</interface>
</node>
DBus objects
The allowance filter is a query that matches every class that has tracker:notify set to true.
allowance_filter = SELECT ?class WHERE { ?class tracker:notify true }
foreach $pfx_colon_class_name in $allowance_filter.exec ():
/org/freedesktop/Tracker1/Resources/Classes/$pfx_colon_class_name
(with : replaced by / in $pfx_colon_class_name)Examples (of some classes that have tracker:notify set to true):
/org/freedesktop/Tracker1/Resources/Classes/nfo/Document /org/freedesktop/Tracker1/Resources/Classes/nie/InformationElement
Application developers can use the SPARQL query, or can use the DBus method ListNames combined with strstr, to get all classes that they can monitor.
Example when and how to use
If you have made a SPARQL query you can start listening for changes on types that you used in the query. If a change occurs (added or removed resources) you can for example repeat your SPARQL query. You can also keep a list of subjects that came from your query; In the updated signal you perform a SPARQL query to get your state up to date with the store for the subject that changed.
