## GypsyTime

GypsyTime — Object for obtaining GPS time from gypsy-daemon

## Synopsis

                        GypsyTime;
    #define             GYPSY_TIME_DBUS_SERVICE
    #define             GYPSY_TIME_DBUS_INTERFACE
    GypsyTime *         gypsy_time_new                      (const char *object_path);
    gboolean            gypsy_time_get_time                 (GypsyTime *gps_time,
                                                             int *timestamp,
                                                             GError **error);

## Description

GypsyTime is used whenever the client program wishes to know about GPS time changes. It can report the current GPS time, and has a signal to notify listeners of changes.

A GypsyTime object is created with `gypsy_time_new()` using the D-Bus path of the GPS device. This path is returned from the `gypsy_control_create()` function. The client can then find out about the GPS time with `gypsy_time_get_time()`.

As the GPS time information changes GypsyTime will emit the time-changed signal. This signal contains the GPS time of the most recent GPS update that it received.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17

    GypsyTime *gps_time;
    GError *error = NULL;

    . . .

    /* path comes from the gypsy_control_create() function */
    gps_time = gypsy_time_new (path);
    g_signal_connect (gps_time, "time-changed", G_CALLBACK (time_changed), NULL);

    . . .

    static void position_changed (GypsyTime *gps_time,
    int timestamp,
    gpointer userdata)
    {
      g_print ("timestamp: %d\n", timestamp);
    }

## Details

### GypsyTime

    typedef struct {
    	GObject parent_object;
    } GypsyTime;

There are no public fields in GypsyTime.

### GYPSY_TIME_DBUS_SERVICE

    #define GYPSY_TIME_DBUS_SERVICE "org.freedesktop.Gypsy"

A define containing the address of the Time service

### GYPSY_TIME_DBUS_INTERFACE

    #define GYPSY_TIME_DBUS_INTERFACE "org.freedesktop.Gypsy.Time"

A define containing the name of the Time interface

### gypsy_time_new ()

    GypsyTime *         gypsy_time_new                      (const char *object_path);

Creates a new GypsyTime object that listens for time changes from the GPS found at `object_path`.

`object_path` : | Object path to the GPS device
Returns : | A GypsyTime object

### gypsy_time_get_time ()

    gboolean            gypsy_time_get_time                 (GypsyTime *gps_time,
                                                             int *timestamp,
                                                             GError **error);

Obtains the current time, if known, from the GPS device.

`gps_time` : | A GypsyTime
`timestamp` : | Pointer to store the timestamp
`error` : | Pointer to store a GError
Returns : | TRUE on success, FALSE on error.