X-Git-Url: http://git.maemo.org/git/?p=googlelatitude;a=blobdiff_plain;f=src%2Fgps.cpp;h=5c52eb96a1cc917d7b5b9fbb4f747399ce37e666;hp=f01639ab0f9fa7decf2f7be5267646b8ed07633b;hb=68a393779a3cb7be3636dc3045eed820a82a4c8e;hpb=abef4a68ff7980d48560e387a8e126a33c2b7ec2 diff --git a/src/gps.cpp b/src/gps.cpp index f01639a..5c52eb9 100644 --- a/src/gps.cpp +++ b/src/gps.cpp @@ -1,22 +1,60 @@ #include "gps.h" -gps::gps(QObject *parent) : QObject(parent) { +#ifdef Q_WS_MAEMO_5 + +GpsMaemo5::GpsMaemo5(QObject *parent) : QObject(parent) { latitude = 0; longitude = 0; accuracy = 0; + usegps = -1; + + control = location_gpsd_control_get_default(); + device = (LocationGPSDevice*) g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL); + g_signal_connect(device, "changed", G_CALLBACK(GpsMaemo5_changed), this); } -void gps::get() { +void GpsMaemo5::get_acwp() { + g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_ACWP, NULL); + usegps = 0; + restart(); } -void gps::set_acwp() { +void GpsMaemo5::get_agnss() { + g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_AGNSS, NULL); + usegps = 1; + restart(); } -void gps::set_agnss() { +void GpsMaemo5::stop() { + location_gpsd_control_stop(control); } -void gps::start() { +void GpsMaemo5::restart() { + location_gpsd_control_stop(control); + location_gpsd_control_start(control); } -void gps::stop() { +void GpsMaemo5_changed(LocationGPSDevice *device, GpsMaemo5 *gps) { + if (gps->device->fix) { + if (gps->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.; + + if ( gps->usegps == 0) { + emit gps->getOK_acwp(); + // if ( gps->accuracy < 100*1000 ) gps->stop(); + if ( gps->accuracy < 640*1000 ) gps->stop(); + } else if ( gps->usegps == 1 ) { + emit gps->getOK_agnss(); + // if ( device->satellites_in_use > 0 ) gps->stop(); + if ( gps->device->fix->mode == LOCATION_GPS_DEVICE_MODE_3D ) gps->stop(); + } else { + emit gps->getOK(); + } + } + } } + +#endif