Connecting
3
LIBTRACKER-CLIENT Library

# Connecting

A client library for querying and inserting data in Tracker.

## Synopsis

    #include <libtracker-client/tracker.h>

                        TrackerClient;
    TrackerClient *     tracker_connect                     (gboolean enable_warnings,
                                                             gint timeout);
    void                tracker_disconnect                  (TrackerClient *client);

## Description

This API is for applications which want to integrate with Tracker either by storing their data or by querying it. They are also not limited to their application's data. Other data mined by other applications is also available in some cases.

## Details

### TrackerClient

    typedef struct {
    	DBusGProxy *proxy_statistics;
    	DBusGProxy *proxy_resources;

    	GHashTable *pending_calls;
    	guint last_call;
    } TrackerClient;

This structure is used by `tracker_connect()` and `tracker_disconnect()`.

DBusGProxy *proxy_statistics;

  a DBusGProxy for the connection to Tracker's statistics D-Bus service.

DBusGProxy *proxy_resources;

  a DBusGProxy for the connection to Tracker's resources D-Bus service.

GHashTable *pending_calls;

  a GHashTable with the D-Bus calls currently pending (used for the `tracker_cancel_call()` API).

guint last_call;

  a guint representing the last API call with this TrackerClient.

### tracker_connect ()

    TrackerClient *     tracker_connect                     (gboolean enable_warnings,
                                                             gint timeout);

Creates a connection over D-Bus to the Tracker store for doing data querying and inserting.

The `timeout` is only used if it is > 0. If it is, then it is used with `dbus_g_proxy_set_default_timeout()`.

`enable_warnings` :

  a gboolean to determine if warnings are issued in cases where they are found.

`timeout` :

  a gint used for D-Bus call timeouts.

Returns :

  the TrackerClient which should be used with `tracker_disconnect()` when finished with.

### tracker_disconnect ()

    void                tracker_disconnect                  (TrackerClient *client);

This will disconnect the D-Bus connections to Tracker services and free the allocated TrackerClient by `tracker_connect()`.

`client` :

  a TrackerClient.