X-Git-Url: http://git.maemo.org/git/?p=googlelatitude;a=blobdiff_plain;f=src%2Fgps.cpp;h=b7ed3367f2be269c922abda2926d8e43f7450232;hp=f01639ab0f9fa7decf2f7be5267646b8ed07633b;hb=c0df4cf5c73d03efed976bc718261f5afc78cab9;hpb=abef4a68ff7980d48560e387a8e126a33c2b7ec2;ds=sidebyside diff --git a/src/gps.cpp b/src/gps.cpp index f01639a..b7ed336 100644 --- a/src/gps.cpp +++ b/src/gps.cpp @@ -1,22 +1,28 @@ #include "gps.h" -gps::gps(QObject *parent) : QObject(parent) { +GpsMaemo5::GpsMaemo5(QObject *parent) : QObject(parent) { latitude = 0; longitude = 0; accuracy = 0; -} -void gps::get() { -} + control = location_gpsd_control_get_default(); + device = (LocationGPSDevice*) g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL); -void gps::set_acwp() { -} - -void gps::set_agnss() { -} + g_signal_connect(device, "changed", G_CALLBACK(GpsMaemo5_changed), this); + g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_ACWP, NULL); + g_object_set(G_OBJECT(control), "preferred-interval", LOCATION_INTERVAL_120S, NULL); -void gps::start() { + location_gpsd_control_start(control); } -void gps::stop() { +void GpsMaemo5_changed(LocationGPSDevice *device, GpsMaemo5 *gps) { + if (device->fix) { + if (device->fix->fields) { + g_print("lat = %f, long = %f, eph = %f\n", gps->device->fix->latitude, gps->device->fix->longitude, gps->device->fix->eph/100.); + gps->latitude = gps->device->fix->latitude; + gps->longitude = gps->device->fix->longitude; + gps->accuracy = gps->device->fix->eph/100.; + emit gps->fix(); + } + } }