Gypsy Reference Manual | ||||
---|---|---|---|---|
GypsyPosition; #define GYPSY_POSITION_DBUS_INTERFACE #define GYPSY_POSITION_DBUS_SERVICE enum GypsyPositionFields; GypsyPosition* gypsy_position_new (const char *object_path); GypsyPositionFields gypsy_position_get_position (GypsyPosition *position, int *timestamp, double *latitude, double *longitude, double *altitude, GError **error);
GypsyPosition is used whenever the client program wishes to know about GPS position changes. It can report the current position, and has a signal to notify listeners of changes.
A GypsyPosition object is created using gypsy_position_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
position with gypsy_position_get_position()
.
As the position information changes GypsyPosition will emit the position-changed signal. This signal contains the fix position if gypsy-daemon knows it. It has a fields paramater which is a bitmask of GypsyPositionFields which indicates which of the latitude, longitude or altitude contains valid information. The timestamp will always be valid if it is greater than 0.
GypsyPosition *position; GError *error = NULL; . . . / * path comes from the gypsy_control_create() function * / position = gypsy_position_new (path); g_signal_connect (position, "position-changed", G_CALLBACK (position_changed), NULL); . . . static void position_changed (GypsyPosition *position, GypsyPositionFields fields, int timestamp, double latitude, double longitude, double altitude, gpointer userdata) { g_print ("latitude, longitude (%f, %f)\n", (fields & GYPSY_POSITION_FIELDS_LATITUDE) ? latitude : -1.0, (fields & GYPSY_POSITION_FIELDS_LONGITUDE) ? longitude : -1.0); }
typedef struct _GypsyPosition GypsyPosition;
There are no public fields in GypsyPosition.
#define GYPSY_POSITION_DBUS_INTERFACE "org.freedesktop.Gypsy.Position"
A define containing the name of the Position interface
#define GYPSY_POSITION_DBUS_SERVICE "org.freedesktop.Gypsy"
A define containing the address of the Position service
typedef enum { GYPSY_POSITION_FIELDS_NONE = 1 << 0, GYPSY_POSITION_FIELDS_LATITUDE = 1 << 1, GYPSY_POSITION_FIELDS_LONGITUDE = 1 << 2, GYPSY_POSITION_FIELDS_ALTITUDE = 1 << 3 } GypsyPositionFields;
A bitmask telling which fields in the position_changed callback are valid
GypsyPosition* gypsy_position_new (const char *object_path);
Creates a new GypsyPosition object that listens for position changes
from the GPS found at object_path
.
object_path : |
Object path to the GPS device |
Returns : | A GypsyPosition object |
GypsyPositionFields gypsy_position_get_position (GypsyPosition *position, int *timestamp, double *latitude, double *longitude, double *altitude, GError **error);
Obtains the current position, if known, from the GPS device.
timestamp
, latitude
, longitude
and altitude
can be NULL if the result
is not required.
position : |
A GypsyPosition |
timestamp : |
Pointer to store the timestamp |
latitude : |
Pointer to store the latitude |
longitude : |
Pointer to store the longitude |
altitude : |
Pointer to store the altitude |
error : |
Pointer to store a GError |
Returns : | Bitmask of GypsyPositionFields indicating what field was set |
void user_function (GypsyPosition *fields, gint timestamp, gint latitude, gdouble longitude, gdouble altitude, gdouble arg5, gpointer user_data) : Run First / No Recursion
The ::position-changed signal is emitted when the GPS device
indicates that one or more of the position fields has changed.
The fields which have changed will be indicated in the fields
bitmask.
fields : |
A bitmask of GypsyPositionFields indicating which of the following fields are valid |
timestamp : |
The timestamp when this change occurred |
latitude : |
The new latitude |
longitude : |
The new longitude |
altitude : |
The new altitude |
user_data : |
user data set when the signal handler was connected. |