1 #include "maemo5locationprivate.h"
5 *Default constructor of this class.
6 *@param Maemo5Location pointer to public interface.
8 Maemo5LocationPrivate::Maemo5LocationPrivate(Maemo5Location* location):QObject(location)
10 //Initialize variables
14 //Get gps control object
15 control = location_gpsd_control_get_default();
17 device = (LocationGPSDevice*) g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL);
18 g_signal_connect(device, "changed", G_CALLBACK(gps_data_changed), this);
19 g_signal_connect(device, "connected", G_CALLBACK(gps_data_connected), this);
22 *Destructor of this class. Should be used to release all allocated resources.
24 Maemo5LocationPrivate::~Maemo5LocationPrivate()
29 *This function is used to start to poll with gprs
31 void Maemo5LocationPrivate::get_acwp()
33 g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_ACWP, NULL);
39 *This function starts to poll via gps interface
41 void Maemo5LocationPrivate::get_agnss()
43 g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_AGNSS, NULL);
51 void Maemo5LocationPrivate::stop()
53 location_gpsd_control_stop(control);
57 *Stop and restart polling
59 void Maemo5LocationPrivate::restart()
61 location_gpsd_control_stop(control);
62 location_gpsd_control_start(control);
65 void gps_data_connected(LocationGPSDevice *device, Maemo5LocationPrivate *gps)
67 emit gps->connected();
70 *Callback function to catch gps signals
72 void gps_data_changed(LocationGPSDevice *device, Maemo5LocationPrivate *gps)
74 //First check that LocationGpsDeviceFix can be found...this data structure contains the location info.
77 //Check that there are fields
78 if(gps->device->fix->fields)
80 //Store values and emit signal
81 gps->latitude = gps->device->fix->latitude;
82 gps->longitude = gps->device->fix->longitude;
87 else if(gps->usegps == 1)
93 emit gps->locationUpdated();