location: update the status before running enabling/disabling sequences
This will allow implementations of location source enabling to actually update the location information during the enabling phase.
This commit is contained in:
@@ -454,6 +454,8 @@ enable_location_gathering_ready (MMIfaceModemLocation *self,
|
||||
if (!MM_IFACE_MODEM_LOCATION_GET_INTERFACE (self)->enable_location_gathering_finish (self, res, &error)) {
|
||||
gchar *str;
|
||||
|
||||
update_location_source_status (ctx->self, ctx->current, FALSE);
|
||||
|
||||
str = mm_modem_location_source_build_string_from_mask (ctx->current);
|
||||
g_prefix_error (&error,
|
||||
"Couldn't enable location '%s' gathering: ",
|
||||
@@ -464,8 +466,6 @@ enable_location_gathering_ready (MMIfaceModemLocation *self,
|
||||
return;
|
||||
}
|
||||
|
||||
update_location_source_status (self, ctx->current, TRUE);
|
||||
|
||||
/* Keep on with next ones... */
|
||||
ctx->current = ctx->current << 1;
|
||||
setup_gathering_step (ctx);
|
||||
@@ -481,6 +481,9 @@ disable_location_gathering_ready (MMIfaceModemLocation *self,
|
||||
if (!MM_IFACE_MODEM_LOCATION_GET_INTERFACE (self)->disable_location_gathering_finish (self, res, &error)) {
|
||||
gchar *str;
|
||||
|
||||
/* Back to enabled then */
|
||||
update_location_source_status (ctx->self, ctx->current, TRUE);
|
||||
|
||||
str = mm_modem_location_source_build_string_from_mask (ctx->current);
|
||||
g_prefix_error (&error,
|
||||
"Couldn't disable location '%s' gathering: ",
|
||||
@@ -491,8 +494,6 @@ disable_location_gathering_ready (MMIfaceModemLocation *self,
|
||||
return;
|
||||
}
|
||||
|
||||
update_location_source_status (self, ctx->current, FALSE);
|
||||
|
||||
/* Keep on with next ones... */
|
||||
ctx->current = ctx->current << 1;
|
||||
setup_gathering_step (ctx);
|
||||
@@ -516,6 +517,12 @@ setup_gathering_step (SetupGatheringContext *ctx)
|
||||
/* Remove from mask */
|
||||
ctx->to_enable &= ~ctx->current;
|
||||
|
||||
/* We update the location source status before launching the
|
||||
* specific actions to enable the gathering, so that we are
|
||||
* able to get location updates while the gathering gets
|
||||
* enabled. */
|
||||
update_location_source_status (ctx->self, ctx->current, TRUE);
|
||||
|
||||
/* Plugins can run custom actions to enable location gathering */
|
||||
if (MM_IFACE_MODEM_LOCATION_GET_INTERFACE (ctx->self)->enable_location_gathering &&
|
||||
MM_IFACE_MODEM_LOCATION_GET_INTERFACE (ctx->self)->enable_location_gathering_finish) {
|
||||
@@ -527,8 +534,6 @@ setup_gathering_step (SetupGatheringContext *ctx)
|
||||
return;
|
||||
}
|
||||
|
||||
update_location_source_status (ctx->self, ctx->current, TRUE);
|
||||
|
||||
source_str = mm_modem_location_source_build_string_from_mask (ctx->current);
|
||||
mm_dbg ("Enabled location '%s' gathering...", source_str);
|
||||
g_free (source_str);
|
||||
@@ -536,6 +541,8 @@ setup_gathering_step (SetupGatheringContext *ctx)
|
||||
/* Remove from mask */
|
||||
ctx->to_disable &= ~ctx->current;
|
||||
|
||||
update_location_source_status (ctx->self, ctx->current, FALSE);
|
||||
|
||||
/* Plugins can run custom actions to disable location gathering */
|
||||
if (MM_IFACE_MODEM_LOCATION_GET_INTERFACE (ctx->self)->disable_location_gathering &&
|
||||
MM_IFACE_MODEM_LOCATION_GET_INTERFACE (ctx->self)->disable_location_gathering_finish) {
|
||||
@@ -547,8 +554,6 @@ setup_gathering_step (SetupGatheringContext *ctx)
|
||||
return;
|
||||
}
|
||||
|
||||
update_location_source_status (ctx->self, ctx->current, FALSE);
|
||||
|
||||
source_str = mm_modem_location_source_build_string_from_mask (ctx->current);
|
||||
mm_dbg ("Disabled location '%s' gathering...", source_str);
|
||||
g_free (source_str);
|
||||
|
||||
Reference in New Issue
Block a user