QVariantMap LocatoinData::Private::geoLocationEvent(bps_event_t *event) { static int count = 0; /* Double check that the event is valid */ if (event == NULL || bps_event_get_code(event) != GEOLOCATION_INFO) { qDebug() << Q_FUNC_INFO << "Invalid geo location data"; return QVariantMap(); } QVariantMap dataMap; dataMap["latitude"] = QVariant(geolocation_event_get_latitude(event)); dataMap["longitude"] = geolocation_event_get_longitude(event); dataMap["accuracy"] = geolocation_event_get_accuracy(event); dataMap["altitude"] = geolocation_event_get_altitude(event); dataMap["altitude_valid"] = geolocation_event_is_altitude_valid(event); dataMap["altitude_accuracy"] = geolocation_event_get_altitude_accuracy(event); dataMap["altitude_accuracy_valid"] = geolocation_event_is_altitude_accuracy_valid(event); dataMap["heading"] = geolocation_event_get_heading(event); dataMap["heading_valid"] = geolocation_event_is_heading_valid(event); dataMap["speed"] = geolocation_event_get_speed(event); dataMap["speed_valid"] = geolocation_event_is_speed_valid(event); dataMap["num_satellites_used"] = geolocation_event_get_num_satellites_used(event); dataMap["num_satellites_valid"] = geolocation_event_is_num_satellites_valid(event); qDebug() << Q_FUNC_INFO << dataMap; return dataMap; }
/** * Handle a geolocation response. */ static void handle_geolocation_response(bps_event_t *event) { static int count = 0; /* Double check that the event is valid */ if (event == NULL || bps_event_get_code(event) != GEOLOCATION_INFO) { return; } double latitude = geolocation_event_get_latitude(event); double longitude = geolocation_event_get_longitude(event); double accuracy = geolocation_event_get_accuracy(event); double altitude = geolocation_event_get_altitude(event); bool altitude_valid = geolocation_event_is_altitude_valid(event); double altitude_accuracy = geolocation_event_get_altitude_accuracy(event); bool altitude_accuracy_valid = geolocation_event_is_altitude_accuracy_valid(event); double heading = geolocation_event_get_heading(event); bool heading_valid = geolocation_event_is_heading_valid(event); double speed = geolocation_event_get_speed(event); bool speed_valid = geolocation_event_is_speed_valid(event); double num_satellites_used = geolocation_event_get_num_satellites_used(event); bool num_satellites_valid = geolocation_event_is_num_satellites_valid(event); display_geolocation_data(count++, latitude, longitude, accuracy, altitude, altitude_valid, altitude_accuracy, altitude_accuracy_valid, heading, heading_valid, speed, speed_valid, num_satellites_used, num_satellites_valid); }
void StatusEventHandler::event(bps_event_t *event) { bool status = false; const char* language = ""; const char* country = ""; const char* locale = ""; const char* interface = ""; const char* type = "none"; double latitude = 0; double longitude= 0; if (bps_event_get_domain(event) == geolocation_get_domain()) { if(event == NULL || bps_event_get_code(event) != GEOLOCATION_INFO) { qDebug() << "NO INFORMATION PROVIDED"; return; } latitude = geolocation_event_get_latitude(event); longitude = geolocation_event_get_longitude(event); double accuracy = geolocation_event_get_accuracy(event); double altitude = geolocation_event_get_altitude(event); bool altitude_valid = geolocation_event_is_altitude_valid(event); double altitude_accuracy = geolocation_event_get_altitude_accuracy(event); bool altitude_accuracy_valid = geolocation_event_is_altitude_accuracy_valid(event); double heading = geolocation_event_get_heading(event); bool heading_valid = geolocation_event_is_heading_valid(event); double speed = geolocation_event_get_speed(event); bool speed_valid = geolocation_event_is_speed_valid(event); double num_satellites = geolocation_event_get_num_satellites_used(event); bool num_satellites_valid = geolocation_event_is_num_satellites_valid(event); emit geolocationUpdated(latitude,longitude); } if (bps_event_get_domain(event) == netstatus_get_domain()) { if (NETSTATUS_INFO == bps_event_get_code(event)) { netstatus_info_t *info = netstatus_event_get_info(event); if (info) { status = netstatus_info_get_availability(info); interface = netstatus_info_get_default_interface(info); netstatus_interface_details_t *details; int success = netstatus_get_interface_details(interface, &details); if (success == BPS_SUCCESS) { switch (netstatus_interface_get_type(details)) { case NETSTATUS_INTERFACE_TYPE_UNKNOWN: type = "Unknown"; break; case NETSTATUS_INTERFACE_TYPE_WIRED: type = "Wired"; break; case NETSTATUS_INTERFACE_TYPE_WIFI: type = "Wi-Fi"; break; case NETSTATUS_INTERFACE_TYPE_BLUETOOTH_DUN: type = "Bluetooth"; break; case NETSTATUS_INTERFACE_TYPE_USB: type = "USB"; break; case NETSTATUS_INTERFACE_TYPE_VPN: type = "VPN"; break; case NETSTATUS_INTERFACE_TYPE_BB: type = "BB"; break; case NETSTATUS_INTERFACE_TYPE_CELLULAR: type = "Cellular"; break; case NETSTATUS_INTERFACE_TYPE_P2P: type = "P2P"; break; } } netstatus_free_interface_details(&details); emit networkStatusUpdated(status, type); } } } else if (bps_event_get_domain(event) == locale_get_domain()) { if (LOCALE_INFO == bps_event_get_code(event)) { language = locale_event_get_language(event); country = locale_event_get_country(event); locale = locale_event_get_locale(event); emit localeUpdated(language, country, locale); } } }