libmm-common,location-gps-raw: don't build dictionary if mandatory parameters missing
This commit is contained in:
@@ -203,11 +203,13 @@ mm_location_gps_raw_get_dictionary (MMLocationGpsRaw *self)
|
||||
|
||||
g_return_val_if_fail (MM_IS_LOCATION_GPS_RAW (self), NULL);
|
||||
|
||||
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
|
||||
/* If mandatory parameters are not found, return NULL */
|
||||
if (!self->priv->utc_time ||
|
||||
self->priv->longitude == MM_LOCATION_GPS_RAW_LONGITUDE_UNKNOWN ||
|
||||
self->priv->latitude == MM_LOCATION_GPS_RAW_LATITUDE_UNKNOWN)
|
||||
return NULL;
|
||||
|
||||
if (self->priv->utc_time &&
|
||||
self->priv->longitude != MM_LOCATION_GPS_RAW_LONGITUDE_UNKNOWN &&
|
||||
self->priv->latitude != MM_LOCATION_GPS_RAW_LATITUDE_UNKNOWN) {
|
||||
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
|
||||
g_variant_builder_add (&builder,
|
||||
"{sv}",
|
||||
PROPERTY_UTC_TIME,
|
||||
@@ -227,7 +229,6 @@ mm_location_gps_raw_get_dictionary (MMLocationGpsRaw *self)
|
||||
"{sv}",
|
||||
PROPERTY_ALTITUDE,
|
||||
g_variant_new_double (self->priv->altitude));
|
||||
}
|
||||
|
||||
return g_variant_ref_sink (g_variant_builder_end (&builder));
|
||||
}
|
||||
|
Reference in New Issue
Block a user