bool NokiaMaemoLocationInterfaceImpl::registerLbsClient() { //Init glib. Should probably only be done if not already initialized g_type_init(); // Check if g_thread already has been initialized. note that // all parts doing this init must check if its already initialized // i.e. WFAPITestClient does this init aswell. if (!g_thread_supported ()) g_thread_init(NULL); // Location Control setup m_control = location_gpsd_control_get_default(); // if(m_control->can_control) location_gpsd_control_start (m_control); // Location Device setup m_device = (LocationGPSDevice*)g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL); location_gps_device_reset_last_known (m_device); nav2log << "[Debug] GPS Device pointer adress: " << (unsigned int)m_device << endl; nav2log << "[Info] GPS Device object obtained\n" << endl; if (m_device == NULL) { // Could not register client nav2log << "NokiaMaemoLocationInterfaceImpl::registerLbsClient failed, invalid device id." << endl; return false; } return true; }
gps_liblocation_state_t::gps_liblocation_state_t(GpsCallback cb, void *context) : gps_state_t(cb, context) , device(static_cast<LocationGPSDevice *>(g_object_new(LOCATION_TYPE_GPS_DEVICE, nullptr))) , control(location_gpsd_control_get_default()) , gps_is_on(false) , fix(false) , enabled(false) { g_debug("GPS init: Using liblocation"); if(!device) { g_warning("Unable to connect to liblocation"); return; } idd_changed = g_signal_connect_swapped(device, "changed", G_CALLBACK(location_changed), this); }
nsresult MaemoLocationProvider::StartControl() { if (mGPSControl) return NS_OK; mGPSControl = location_gpsd_control_get_default(); NS_ENSURE_TRUE(mGPSControl, NS_ERROR_FAILURE); mControlError = g_signal_connect(mGPSControl, "error", G_CALLBACK(ControlError), this); mControlStopped = g_signal_connect(mGPSControl, "gpsd_stopped", G_CALLBACK(ControlStopped), this); location_gpsd_control_start(mGPSControl); return NS_OK; }
void gps_init(appdata_t *appdata) { gps_state_t *gps_state = appdata->gps_state = g_new0(gps_state_t, 1); printf("GPS init: Using liblocation\n"); gps_state->device = g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL); if(!gps_state->device) { printf("Unable to connect to liblocation\n"); return; } gps_state->idd_changed = g_signal_connect(gps_state->device, "changed", G_CALLBACK(location_changed), gps_state); #ifdef LL_CONTROL_GPSD gps_state->control = location_gpsd_control_get_default(); #endif }