cli,location: remove redundant --location-get-XXX actions

The --location-get action provides full location information from all
sources, which is better than per-source actions, as those were anyway
using the same API method to load location information as the global
one.
This commit is contained in:
Aleksander Morgado
2018-11-03 12:04:01 +01:00
committed by Dan Williams
parent 613aceabda
commit cafc40245d

View File

@@ -48,23 +48,19 @@ static Context *ctx;
static gboolean status_flag;
static gboolean enable_3gpp_flag;
static gboolean disable_3gpp_flag;
static gboolean get_3gpp_flag;
static gboolean enable_agps_flag;
static gboolean disable_agps_flag;
static gboolean enable_gps_nmea_flag;
static gboolean disable_gps_nmea_flag;
static gboolean get_gps_nmea_flag;
static gboolean enable_gps_raw_flag;
static gboolean disable_gps_raw_flag;
static gboolean get_gps_raw_flag;
static gboolean enable_cdma_bs_flag;
static gboolean disable_cdma_bs_flag;
static gboolean get_cdma_bs_flag;
static gboolean enable_gps_unmanaged_flag;
static gboolean disable_gps_unmanaged_flag;
static gboolean set_enable_signal_flag;
static gboolean set_disable_signal_flag;
static gboolean get_all_flag;
static gboolean get_flag;
static gchar *set_supl_server_str;
static gchar *inject_assistance_data_str;
static gchar *set_gps_refresh_rate_str;
@@ -74,7 +70,7 @@ static GOptionEntry entries[] = {
"Show status of location gathering.",
NULL
},
{ "location-get", 0, 0, G_OPTION_ARG_NONE, &get_all_flag,
{ "location-get", 0, 0, G_OPTION_ARG_NONE, &get_flag,
"Get all available location information.",
NULL
},
@@ -86,10 +82,6 @@ static GOptionEntry entries[] = {
"Disable 3GPP location gathering.",
NULL
},
{ "location-get-3gpp", 0, 0, G_OPTION_ARG_NONE, &get_3gpp_flag,
"Get 3GPP-based location.",
NULL
},
{ "location-enable-agps", 0, 0, G_OPTION_ARG_NONE, &enable_agps_flag,
"Enable A-GPS location gathering.",
NULL
@@ -106,10 +98,6 @@ static GOptionEntry entries[] = {
"Disable NMEA-based GPS location gathering.",
NULL
},
{ "location-get-gps-nmea", 0, 0, G_OPTION_ARG_NONE, &get_gps_nmea_flag,
"Get NMEA GPS traces.",
NULL
},
{ "location-enable-gps-raw", 0, 0, G_OPTION_ARG_NONE, &enable_gps_raw_flag,
"Enable raw GPS location gathering.",
NULL
@@ -118,10 +106,6 @@ static GOptionEntry entries[] = {
"Disable raw GPS location gathering.",
NULL
},
{ "location-get-gps-raw", 0, 0, G_OPTION_ARG_NONE, &get_gps_raw_flag,
"Get raw GPS location.",
NULL
},
{ "location-enable-cdma-bs", 0, 0, G_OPTION_ARG_NONE, &enable_cdma_bs_flag,
"Enable CDMA base station location gathering.",
NULL
@@ -130,10 +114,6 @@ static GOptionEntry entries[] = {
"Disable CDMA base station location gathering.",
NULL
},
{ "location-get-cdma-bs", 0, 0, G_OPTION_ARG_NONE, &get_cdma_bs_flag,
"Get CDMA base station location.",
NULL
},
{ "location-enable-gps-unmanaged", 0, 0, G_OPTION_ARG_NONE, &enable_gps_unmanaged_flag,
"Enable unmanaged GPS location gathering.",
NULL
@@ -204,13 +184,6 @@ mmcli_modem_location_options_enabled (void)
exit (EXIT_FAILURE);
}
if (get_all_flag) {
get_3gpp_flag = TRUE;
get_gps_nmea_flag = TRUE;
get_gps_raw_flag = TRUE;
get_cdma_bs_flag = TRUE;
}
n_actions = (status_flag +
!!(enable_3gpp_flag +
disable_3gpp_flag +
@@ -226,10 +199,7 @@ mmcli_modem_location_options_enabled (void)
disable_gps_unmanaged_flag +
set_enable_signal_flag +
set_disable_signal_flag) +
!!(get_3gpp_flag +
get_gps_nmea_flag +
get_gps_raw_flag +
get_cdma_bs_flag) +
get_flag +
!!set_supl_server_str +
!!inject_assistance_data_str +
!!set_gps_refresh_rate_str);
@@ -553,37 +523,9 @@ get_location_process_reply (MMLocation3gpp *location_3gpp,
MMLocationCdmaBs *location_cdma_bs,
const GError *error)
{
/* First, check for failures */
if (!get_all_flag) {
gboolean exit_error = FALSE;
gchar *full = NULL;
if (get_3gpp_flag && !location_3gpp) {
g_printerr ("error: couldn't get 3GPP-based location from the modem: '%s'\n",
error ? error->message : "not available");
exit_error = TRUE;
}
if (get_gps_nmea_flag && !location_gps_nmea) {
g_printerr ("error: couldn't get NMEA GPS traces from the modem: '%s'\n",
error ? error->message : "not available");
exit_error = TRUE;
}
if (get_gps_raw_flag && !location_gps_raw) {
g_printerr ("error: couldn't get raw GPS location from the modem: '%s'\n",
error ? error->message : "not available");
exit_error = TRUE;
}
if (get_cdma_bs_flag && !location_cdma_bs) {
g_printerr ("error: couldn't get CDMA base station location from the modem: '%s'\n",
error ? error->message : "not available");
exit_error = TRUE;
}
if (exit_error)
exit (EXIT_FAILURE);
} else if (error) {
if (error) {
g_printerr ("error: couldn't get location from the modem: '%s'\n",
error ? error->message : "unknown error");
exit (EXIT_FAILURE);
@@ -593,7 +535,6 @@ get_location_process_reply (MMLocation3gpp *location_3gpp,
"%s\n",
mm_modem_location_get_path (ctx->modem_location));
if (get_3gpp_flag) {
if (location_3gpp)
g_print (" -------------------------\n"
" 3GPP location | Mobile country code: '%u'\n"
@@ -609,10 +550,6 @@ get_location_process_reply (MMLocation3gpp *location_3gpp,
else
g_print (" -------------------------\n"
" 3GPP location | Not available\n");
}
if (get_gps_nmea_flag) {
gchar *full = NULL;
if (location_gps_nmea)
full = mm_location_gps_nmea_build_full (location_gps_nmea);
@@ -629,9 +566,7 @@ get_location_process_reply (MMLocation3gpp *location_3gpp,
} else
g_print (" -------------------------\n"
" GPS NMEA traces | Not available\n");
}
if (get_gps_raw_flag) {
if (location_gps_raw)
g_print (" -------------------------\n"
" Raw GPS | UTC time: '%s'\n"
@@ -645,9 +580,7 @@ get_location_process_reply (MMLocation3gpp *location_3gpp,
else
g_print (" -------------------------\n"
" Raw GPS | Not available\n");
}
if (get_cdma_bs_flag) {
if (location_cdma_bs)
g_print (" -------------------------\n"
" CDMA BS | Longitude: '%lf'\n"
@@ -657,16 +590,11 @@ get_location_process_reply (MMLocation3gpp *location_3gpp,
else
g_print (" -------------------------\n"
" CDMA BS | Not available\n");
}
if (location_3gpp)
g_object_unref (location_3gpp);
if (location_gps_nmea)
g_object_unref (location_gps_nmea);
if (location_gps_raw)
g_object_unref (location_gps_raw);
if (location_cdma_bs)
g_object_unref (location_cdma_bs);
g_clear_object (&location_3gpp);
g_clear_object (&location_gps_nmea);
g_clear_object (&location_gps_raw);
g_clear_object (&location_cdma_bs);
}
static void
@@ -681,13 +609,12 @@ get_location_ready (MMModemLocation *modem_location,
mm_modem_location_get_full_finish (modem_location,
result,
get_3gpp_flag ? &location_3gpp : NULL,
get_gps_nmea_flag ? &location_gps_nmea : NULL,
get_gps_raw_flag ? &location_gps_raw : NULL,
get_cdma_bs_flag ? &location_cdma_bs : NULL,
&location_3gpp,
&location_gps_nmea,
&location_gps_raw,
&location_cdma_bs,
&error);
get_location_process_reply (location_3gpp, location_gps_nmea, location_gps_raw, location_cdma_bs, error);
mmcli_async_operation_done ();
}
@@ -734,10 +661,7 @@ get_modem_ready (GObject *source,
}
/* Request to get location from the modem? */
if (get_3gpp_flag ||
get_gps_nmea_flag ||
get_gps_raw_flag ||
get_cdma_bs_flag) {
if (get_flag) {
g_debug ("Asynchronously getting location from the modem...");
mm_modem_location_get_full (ctx->modem_location,
ctx->cancellable,
@@ -869,10 +793,7 @@ mmcli_modem_location_run_synchronous (GDBusConnection *connection)
}
/* Request to get location from the modem? */
if (get_3gpp_flag ||
get_gps_nmea_flag ||
get_gps_raw_flag ||
get_cdma_bs_flag) {
if (get_flag) {
MMLocation3gpp *location_3gpp = NULL;
MMLocationGpsNmea *location_gps_nmea = NULL;
MMLocationGpsRaw *location_gps_raw = NULL;
@@ -880,10 +801,10 @@ mmcli_modem_location_run_synchronous (GDBusConnection *connection)
g_debug ("Synchronously getting location from the modem...");
mm_modem_location_get_full_sync (ctx->modem_location,
get_3gpp_flag ? &location_3gpp : NULL,
get_gps_nmea_flag ? &location_gps_nmea : NULL,
get_gps_raw_flag ? &location_gps_raw : NULL,
get_cdma_bs_flag ? &location_cdma_bs : NULL,
&location_3gpp,
&location_gps_nmea,
&location_gps_raw,
&location_cdma_bs,
NULL,
&error);
get_location_process_reply (location_3gpp, location_gps_nmea, location_gps_raw, location_cdma_bs, error);