Revert "Changed the old code to work as a daemon"
[googlelatitude] / src / gps.cpp
1 #include "gps.h"
2
3 #ifdef Q_WS_MAEMO_5
4
5 GpsMaemo5::GpsMaemo5(QObject *parent) : QObject(parent) {
6     latitude = 0;
7     longitude = 0;
8     accuracy = 0;
9
10     control = location_gpsd_control_get_default();
11     device = (LocationGPSDevice*) g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL);
12
13     g_signal_connect(device, "changed", G_CALLBACK(GpsMaemo5_changed), this);
14     g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_ACWP, NULL);
15     g_object_set(G_OBJECT(control), "preferred-interval", LOCATION_INTERVAL_120S, NULL);
16
17     location_gpsd_control_start(control);
18 }
19
20 void GpsMaemo5_changed(LocationGPSDevice *device, GpsMaemo5 *gps) {
21     if (device->fix) {
22         if (device->fix->fields) {
23             g_print("lat = %f, long = %f, eph = %f\n", gps->device->fix->latitude, gps->device->fix->longitude, gps->device->fix->eph/100.);
24             gps->latitude = gps->device->fix->latitude;
25             gps->longitude = gps->device->fix->longitude;
26             gps->accuracy = gps->device->fix->eph/100.;
27             emit gps->fix();
28         }
29     }
30 }
31
32 #endif // Q_WS_MAEMO_5