This is a documentation preview for the next version of Tracker, generated from tracker.git commit c585703.

See the Tracker website for more documentation.

TrackerNotifier

TrackerNotifier — Listen to changes in the Tracker database

Functions

Properties

TrackerSparqlConnection * connection Read / Write / Construct Only

Signals

void events  

Types and Values

Object Hierarchy

    GBoxed
    ╰── TrackerNotifierEvent
    GEnum
    ╰── TrackerNotifierEventType
    GObject
    ╰── TrackerNotifier

Includes

#include <libtracker-sparql/tracker-sparql.h>

Description

TrackerNotifier is an object that receives notifications about changes to the Tracker database. A TrackerNotifier is created through tracker_sparql_connection_create_notifier(), after the notifier is created, events can be listened for by connecting to the “events” signal. This object was added in Tracker 1.12.

Known caveats

  • The TRACKER_NOTIFIER_EVENT_DELETE events will be received after the resource has been deleted. At that time queries on those elements will not bring any metadata. Only the ID/URN obtained through the event remain meaningful.

  • Notifications of files being moved across indexed folders will appear as TRACKER_NOTIFIER_EVENT_UPDATE events, containing the new location (if requested). The older location is no longer known to Tracker, this may make tracking of elements in specific folders hard using solely the TrackerNotifier/Tracker data available at event notification time.

Functions

tracker_notifier_event_get_event_type ()

TrackerNotifierEventType
tracker_notifier_event_get_event_type (TrackerNotifierEvent *event);

Returns the event type.

Parameters

Returns

The event type


tracker_notifier_event_get_id ()

gint64
tracker_notifier_event_get_id (TrackerNotifierEvent *event);

Returns the tracker:id of the element being notified upon. This is a gint64 which is used as efficient internal identifier for the resource.

Parameters

Returns

the resource ID


tracker_notifier_event_get_urn ()

const gchar *
tracker_notifier_event_get_urn (TrackerNotifierEvent *event);

Returns the Uniform Resource Name of the element. This is Tracker's public identifier for the resource.

This URN is an unique string identifier for the resource being notified upon, typically of the form "urn:uuid:...".

Parameters

Returns

The element URN


tracker_notifier_signal_subscribe ()

guint
tracker_notifier_signal_subscribe (TrackerNotifier *notifier,
                                   GDBusConnection *connection,
                                   const gchar *service,
                                   const gchar *object_path,
                                   const gchar *graph);

Listens to notification events from a remote SPARQL endpoint as a DBus service (see TrackerEndpointDBus). If the object_path argument is NULL, the default "/org/freedesktop/Tracker3/Endpoint" path will be used. If graph is NULL, all graphs will be listened for.

The signal subscription can be removed with tracker_notifier_signal_unsubscribe().

Parameters

notifier

a TrackerNotifier

 

connection

a GDBusConnection

 

service

DBus service name to subscribe to events for

 

object_path

DBus object path to subscribe to events for, or NULL.

[nullable]

graph

graph to listen events for, or NULL.

[nullable]

Returns

An ID for this subscription

Since: 3.0


tracker_notifier_signal_unsubscribe ()

void
tracker_notifier_signal_unsubscribe (TrackerNotifier *notifier,
                                     guint handler_id);

Undoes a DBus signal subscription, the handler_id argument was previously obtained with a tracker_notifier_signal_subscribe() call.

Parameters

notifier

a TrackerNotifier

 

handler_id

a handler ID obtained with tracker_notifier_signal_subscribe()

 

Since: 3.0

Types and Values

TrackerNotifier

typedef struct _TrackerNotifier TrackerNotifier;

The TrackerNotifier object allows subscribing to changes in the stored data.


enum TrackerNotifierEventType

Notifier event types.

Members

TRACKER_NOTIFIER_EVENT_CREATE

An element was created.

 

TRACKER_NOTIFIER_EVENT_DELETE

An element was deleted.

 

TRACKER_NOTIFIER_EVENT_UPDATE

An element was updated.

 

TrackerNotifierEvent

typedef struct _TrackerNotifierEvent TrackerNotifierEvent;

The TrackerNotifierEvent struct represents a change event in the stored data.

Property Details

The “connection” property

  “connection”               TrackerSparqlConnection *

SPARQL connection to listen to.

Owner: TrackerNotifier

Flags: Read / Write / Construct Only

Signal Details

The “events” signal

void
user_function (TrackerNotifier *self,
               char            *service,
               char            *graph,
               GPtrArray       *events,
               gpointer         user_data)

Notifies of changes in the Tracker database.

Parameters

self

The TrackerNotifier

 

service

The SPARQL service that originated the events, NULL for the local store

 

graph

The graph where the events happened on, NULL for the default anonymous graph

 

events

A GPtrArray of TrackerNotifierEvent.

[element-type TrackerNotifierEvent]

user_data

user data set when the signal handler was connected.