cli,location: new '--location-monitor' action
This action allows us to monitor location updates as signaled via the 'Location' property, only available if location signaling has been explicitly enabled (e.g. with --location-set-enable-signal)
This commit is contained in:
@@ -65,6 +65,7 @@ static gboolean disable_gps_unmanaged_flag;
|
||||
static gboolean set_enable_signal_flag;
|
||||
static gboolean set_disable_signal_flag;
|
||||
static gboolean get_flag;
|
||||
static gboolean monitor_flag;
|
||||
static gchar *set_supl_server_str;
|
||||
static gchar *inject_assistance_data_str;
|
||||
static gchar *set_gps_refresh_rate_str;
|
||||
@@ -78,6 +79,10 @@ static GOptionEntry entries[] = {
|
||||
"Get all available location information.",
|
||||
NULL
|
||||
},
|
||||
{ "location-monitor", 0, 0, G_OPTION_ARG_NONE, &monitor_flag,
|
||||
"Monitor all available location information.",
|
||||
NULL
|
||||
},
|
||||
{ "location-enable-3gpp", 0, 0, G_OPTION_ARG_NONE, &enable_3gpp_flag,
|
||||
"Enable 3GPP location gathering.",
|
||||
NULL
|
||||
@@ -210,6 +215,7 @@ mmcli_modem_location_options_enabled (void)
|
||||
n_actions = (status_flag +
|
||||
any_location_setup_flag +
|
||||
get_flag +
|
||||
monitor_flag +
|
||||
!!set_supl_server_str +
|
||||
!!inject_assistance_data_str +
|
||||
!!set_gps_refresh_rate_str);
|
||||
@@ -219,7 +225,9 @@ mmcli_modem_location_options_enabled (void)
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (status_flag)
|
||||
if (monitor_flag)
|
||||
mmcli_force_async_operation ();
|
||||
else if (status_flag)
|
||||
mmcli_force_sync_operation ();
|
||||
|
||||
checked = TRUE;
|
||||
@@ -575,6 +583,34 @@ get_location_process_reply (MMLocation3gpp *location_3gpp,
|
||||
g_clear_object (&location_cdma_bs);
|
||||
}
|
||||
|
||||
static void
|
||||
cancelled (GCancellable *cancellable)
|
||||
{
|
||||
mmcli_async_operation_done ();
|
||||
}
|
||||
|
||||
static void
|
||||
print_signaled_location (MMModemLocation *modem_location)
|
||||
{
|
||||
MMLocation3gpp *location_3gpp;
|
||||
MMLocationGpsNmea *location_gps_nmea;
|
||||
MMLocationGpsRaw *location_gps_raw;
|
||||
MMLocationCdmaBs *location_cdma_bs;
|
||||
|
||||
location_3gpp = mm_modem_location_get_signaled_3gpp (modem_location);
|
||||
location_gps_nmea = mm_modem_location_get_signaled_gps_nmea (modem_location);
|
||||
location_gps_raw = mm_modem_location_get_signaled_gps_raw (modem_location);
|
||||
location_cdma_bs = mm_modem_location_get_signaled_cdma_bs (modem_location);
|
||||
|
||||
get_location_process_reply (location_3gpp, location_gps_nmea, location_gps_raw, location_cdma_bs, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
signaled_location_updated (MMModemLocation *modem_location)
|
||||
{
|
||||
print_signaled_location (modem_location);
|
||||
}
|
||||
|
||||
static void
|
||||
get_location_ready (MMModemLocation *modem_location,
|
||||
GAsyncResult *result)
|
||||
@@ -635,6 +671,22 @@ get_modem_ready (GObject *source,
|
||||
return;
|
||||
}
|
||||
|
||||
/* Request to monitor location? */
|
||||
if (monitor_flag) {
|
||||
print_signaled_location (ctx->modem_location);
|
||||
g_signal_connect (ctx->modem_location,
|
||||
"notify::location",
|
||||
G_CALLBACK (signaled_location_updated),
|
||||
NULL);
|
||||
|
||||
/* If we get cancelled, operation done */
|
||||
g_cancellable_connect (ctx->cancellable,
|
||||
G_CALLBACK (cancelled),
|
||||
NULL,
|
||||
NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Request to set SUPL server? */
|
||||
if (set_supl_server_str) {
|
||||
g_debug ("Asynchronously setting SUPL server...");
|
||||
|
Reference in New Issue
Block a user