DBus API

This is the raw DBus API for the Zeitgeist engine. Applications written in Python are encouraged to use the ZeitgeistClient API instead.

Event Serialization Format

The wire representation of events is central to the DBus API of the Zeitgeist engine. An event has DBus signature asaasay. The Python client library includes an Event class that conforms, without manual mashalling, to the DBus wire format described here.

The first array of strings, as, contains the event metadata at the following offsets:

  1. Event id, which is guaranteed to be an unsigned integer. Applications must never set this field, it is an error to do so. The field will be filled out when you ask for events from the Zeitgeist engine.
  2. Timestamp in milliseconds since the Unix Epoch
  3. Interpretation - the abstract notion of “what happened” defined by a formal URI. There is a predefined set of event interpretations in the zeitgeist.datamodel.Interpretation class
  4. Manifestation - the abstract notion of “how did this happen” defined by a formal URI. There is a predefined set of event manifestations in the zeitgeist.datamodel.Manifestation class
  5. Actor - a URI defining the entity spawning the event. In most cases this will be an application. The URI of an application is defined as the app:// URI-scheme with the base filename of the application’s .desktop file (with the extension). Fx Firefox with .desktop file /usr/share/applications/firefox.desktop will have an actor URI of app://firefox.desktop.

The second component in the event datastructure is the list of subjects, aas, each subject being an as. Note that an event can have more than one subject - fx. when deleting a collection of files with one click in the file manager. The subject metadata is defined with the following offsets:

  1. URI - eg. http://example.com/myfile.pdf or file:///tmp/my.txt
  2. Interpretation - the abstract notion of what the subject is, eg. “this is a document” or “this is an image”. The interpretation is formally represented by a URI. The zeitgeist.datamodel.Interpretation class contains a collection of predefined subject interpretations. It is otherwise recommended to use Nepomuk Information Elements to describe subject interpretations.
  3. Manifestation - the abstract notion of how the subject is stored or available, eg. “this is file” or “this is a webpage”. The manifestation is formally represented by a URI. The zeitgeist.datamodel.Manifestation class contains a collection of predefined subject manifestations. It is otherwise recommended to use Nepomuk Data Objects to describe subject manifestations.
  4. Origin - the URI where the user accessed the subject from
  5. Mimetype - The mimetype of the subject, eg. text/plain
  6. Text - A short textual representation of the subject suitable for display
  7. Storage - the id storage device the subject is. For files this would be the UUID of the volume, for subjects requiring a network interface use the string “net”. If the subject has been deleted use the string “deleted”. The storage id of the subject is used internally in the Zeitgeist engine to keep track of subject availability. This way clients can request hits only on subjects that are currently available.

The third an last component of the event data structure is an array of bytes, ay, called the payload. The payload can be used to hold any kind of free form data and its intent and purpose is entirely up to the entity inserting the event into the log.

org.gnome.zeitgeist.Log

class _zeitgeist.engine.remote.RemoteInterface(start_dbus=True, mainloop=None)

Primary interface to the Zeitgeist engine. Used to update and query the log. It also provides means to listen for events matching certain criteria. All querying is heavily based around an “event template”-concept.

The main log of the Zeitgeist engine has DBus object path /org/gnome/zeitgeist/log/activity under the bus name org.gnome.zeitgeist.Engine.

InsertEvents(events)

Inserts events into the log. Returns an array containing the ids of the inserted events

Each event which failed to be inserted into the log (either by being blocked or because of an error) will be represented by 0 in the resulting array.

One way events may end up being blocked is if they match any of the blacklist templates.

Any monitors with matching templates will get notified about the insertion. Note that the monitors are notified after the events have been inserted.

Parameter:events – List of events to be inserted in the log. If you are using the Python bindings you may pass Event instances directly to this method
Returns:An array containing the event ids of the inserted events. In case any of the events where already logged, the id of the existing event will be returned. 0 as id indicates a failed insert into the log.
Return type:Array of unsigned 32 bits integers. DBus signature au.
GetEvents(event_ids)

Get full event data for a set of event ids

Each event which is not found in the event log is represented by the NULL_EVENT struct in the resulting array.

Parameter:event_ids (Array of unsigned 32 bit integers. DBus signature au) – An array of event ids. Fx. obtained by calling FindEventIds()
Returns:Full event data for all the requested ids. The event data can be conveniently converted into a list of Event instances by calling events = map(Event.new_for_struct, result)
Return type:A list of serialized events. DBus signature a(asaasay).
FindEventIds(time_range, event_templates, storage_state, num_events, result_type)

Search for events matching a given set of templates and return theids of matching events. Use GetEvents() passing in the returned ids to look up the full event data.

The matching is done where unset fields in the templates are treated as wildcards. If a template has more than one subject then events will match the template if any one of their subjects match any one of the subject templates.

Parameters:
  • time_range (tuple of 64 bit integers. DBus signature (xx)) – two timestamps defining the timerange for the query. When using the Python bindings for Zeitgeist you may pass a TimeRange instance directly to this method
  • event_templates (array of events. DBus signature a(asaasay)) – An array of event templates which the returned events should match at least one of. When using the Python bindings for Zeitgeist you may pass a list of Event instances directly to this method.
  • storage_state (unsigned integer) – whether the item is currently known to be available. The list of possible values is enumerated in StorageState class
  • num_events (unsigned integer) – maximal amount of returned events
  • order (unsigned integer) – unsigned integer representing a result type
Returns:

An array containing the ids of all matching events, up to a maximum of num_events events. Sorted and grouped as defined by the result_type parameter.

Return type:

Array of unsigned 32 bit integers

FindRelatedUris(time_range, event_templates, result_event_templates, storage_state)

Warning: This API is EXPERIMENTAL and is not fully supported yet.

Get a list of URIs of subjects which frequently occur together with events matching event_templates within time_range. The resulting URIs must occur as subjects of events matching result_event_templates and have storage state storage_state.

Parameters:
  • time_range (tuple of 64 bit integers, DBus signature (xx)) – two timestamps defining the timerange for the query. When using the Python bindings for Zeitgeist you may pass a TimeRange instance directly to this method.
  • event_templates (array of events, DBus signature a(asaasay)) – An array of event templates which you want URIs that relate to. When using the Python bindings for Zeitgeist you may pass a list of Event instances directly to this method.
  • result_event_templates (array of events, DBus signature a(asaasay)) – An array of event templates which the returned URIs must occur as subjects of. When using the Python bindings for Zeitgeist you may pass a list of Event instances directly to this method.
  • storage_state (unsigned 32 bit integer, DBus signature u) – whether the item is currently known to be available. The list of possible values is enumerated in the StorageState class
Returns:

A list of URIs matching the described criteria

Return type:

An array of strings, DBus signature as.

DeleteEvents(event_ids)

Delete a set of events from the log given their ids

Parameter:event_ids – list of event ids obtained, for example, by calling FindEventIds()
DeleteLog()

Delete the log file and all its content

This method is used to delete the entire log file and all its content in one go. To delete specific subsets use FindEventIds() combined with DeleteEvents().

Quit()
Terminate the running Zeitgeist engine process; use with caution, this action must only be triggered with the user’s explicit consent, as it will affect all applications using Zeitgeist
InstallMonitor(monitor_path, time_range, event_templates, owner=None)

Register a client side monitor object to receive callbacks when events matching time_range and event_templates are inserted or deleted.

The monitor object must implement the interface org.gnome.zeitgeist.Monitor

Parameters:
  • monitor_path – DBus object path to the client side monitor object. DBus signature o.
  • time_range – A two-tuple with the time range monitored events must fall within. Recall that time stamps are in milliseconds since the Epoch. DBus signature (xx)
  • event_templates – Event templates that events must match in order to trigger the monitor. Just like FindEventIds(). DBus signature a(asaasay)
RemoveMonitor(monitor_path, owner=None)

Remove a monitor installed with InstallMonitor()

Parameter:monitor_path – DBus object path of monitor to remove as supplied to InstallMonitor().

org.gnome.zeitgeist.Monitor

class zeitgeist.client.Monitor(time_range, event_templates, insert_callback, delete_callback, monitor_path=None)

DBus interface for monitoring the Zeitgeist log for certain types of events.

When using the Python bindings monitors are normally instantiated indirectly by calling ZeitgeistClient.install_monitor().

It is important to understand that the Monitor instance lives on the client side, and expose a DBus service there, and the Zeitgeist engine calls back to the monitor when matching events are registered.

NotifyInsert(time_range, events)

Receive notification that a set of events matching the monitor’s templates has been recorded in the log.

This method is the raw DBus callback and should normally not be overridden. Events are received via the insert_callback argument given in the constructor to this class.

Parameters:
  • time_range – A two-tuple of 64 bit integers with the minimum and maximum timestamps found in events. DBus signature (xx)
  • events – A list of DBus event structs, signature a(asaasay) with the events matching the monitor. See ZeitgeistClient.install_monitor()
NotifyDelete(time_range, event_ids)

Receive notification that a set of events within the monitor’s matched time range has been deleted. Note that this notification will also be emitted for deleted events that doesn’t match the event templates of the monitor. It’s just the time range which is considered here.

This method is the raw DBus callback and should normally not be overridden. Events are received via the delete_callback argument given in the constructor to this class.

Parameters:
  • time_range – A two-tuple of 64 bit integers with the minimum and maximum timestamps found in events. DBus signature (xx)
  • event_ids – A list of event ids. An event id is simply and unsigned 32 bit integer. DBus signature au.

org.gnome.zeitgeist.Blacklist

class _zeitgeist.engine.extensions.blacklist.Blacklist(engine)

The Zeitgeist engine maintains a list of event templates that is known as the blacklist. When inserting events via org.gnome.zeitgeist.Log.InsertEvents they will be checked against the blacklist templates and if they match they will not be inserted in the log, and any matching monitors will not be signalled.

The blacklist of the Zeitgeist engine has DBus object path /org/gnome/zeitgeist/blacklist under the bus name org.gnome.zeitgeist.Engine.

SetBlacklist(event_templates)

Set the blacklist to event_templates. Events matching any these templates will be blocked from insertion into the log. It is still possible to find and look up events matching the blacklist which was inserted before the blacklist banned them.

Parameter:event_templates – A list of Events
GetBlacklist()

Get the current blacklist templates.

Returns:A list of Events

Table Of Contents

Previous topic

Zeitgeist Client API

Next topic

Data Model

This Page