diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2014-02-06 11:58:48 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2014-09-05 11:30:24 +0200 |
commit | 9dc5cdf78e528603f52c56cd9da9bfe0dd41d746 (patch) | |
tree | a7e2cdc2285729c80a0416d35b03902f807ecc43 | |
parent | cd5ca169f1a4d9de1fd6802a4c735ffec634a245 (diff) | |
download | ModemManager-9dc5cdf78e528603f52c56cd9da9bfe0dd41d746.tar.gz |
cli,location: allow getting/setting SUPL server address
-rw-r--r-- | cli/mmcli-modem-location.c | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/cli/mmcli-modem-location.c b/cli/mmcli-modem-location.c index 586283b42..7a957590a 100644 --- a/cli/mmcli-modem-location.c +++ b/cli/mmcli-modem-location.c @@ -61,6 +61,7 @@ static gboolean get_cdma_bs_flag; static gboolean enable_gps_unmanaged_flag; static gboolean disable_gps_unmanaged_flag; static gboolean get_all_flag; +static gchar *set_supl_server_str; static GOptionEntry entries[] = { { "location-status", 0, 0, G_OPTION_ARG_NONE, &status_flag, @@ -127,6 +128,10 @@ static GOptionEntry entries[] = { "Disable unmanaged GPS location gathering.", NULL }, + { "location-set-supl-server", 0, 0, G_OPTION_ARG_STRING, &set_supl_server_str, + "Set SUPL server address", + "[IP:PORT] or [URL]" + }, { NULL } }; @@ -184,7 +189,8 @@ mmcli_modem_location_options_enabled (void) !!(get_3gpp_flag + get_gps_nmea_flag + get_gps_raw_flag + - get_cdma_bs_flag)); + get_cdma_bs_flag) + + !!set_supl_server_str); if (n_actions > 1) { g_printerr ("error: too many Location actions requested\n"); @@ -257,6 +263,13 @@ print_location_status (void) capabilities_str, enabled_str, mm_modem_location_signals_location (ctx->modem_location) ? "yes" : "no"); + + /* If A-GPS supported, show SUPL server setup */ + if (mm_modem_location_get_capabilities (ctx->modem_location) & MM_MODEM_LOCATION_SOURCE_AGPS) + g_print (" ----------------------------\n" + " A-GPS | SUPL server: '%s'\n", + mm_modem_location_get_supl_server (ctx->modem_location)); + g_free (capabilities_str); g_free (enabled_str); } @@ -287,6 +300,32 @@ setup_ready (MMModemLocation *modem_location, mmcli_async_operation_done (); } +static void +set_supl_server_process_reply (gboolean result, + const GError *error) +{ + if (!result) { + g_printerr ("error: couldn't set SUPL servert address: '%s'\n", + error ? error->message : "unknown error"); + exit (EXIT_FAILURE); + } + + g_print ("successfully set SUPL server address\n"); +} + +static void +set_supl_server_ready (MMModemLocation *modem_location, + GAsyncResult *result) +{ + gboolean operation_result; + GError *error = NULL; + + operation_result = mm_modem_location_set_supl_server_finish (modem_location, result, &error); + set_supl_server_process_reply (operation_result, error); + + mmcli_async_operation_done (); +} + static MMModemLocationSource build_sources_from_flags (void) { @@ -517,6 +556,17 @@ get_modem_ready (GObject *source, return; } + /* Request to set SUPL server? */ + if (set_supl_server_str) { + g_debug ("Asynchronously setting SUPL server..."); + mm_modem_location_set_supl_server (ctx->modem_location, + set_supl_server_str, + ctx->cancellable, + (GAsyncReadyCallback)set_supl_server_ready, + NULL); + return; + } + g_warn_if_reached (); } @@ -607,5 +657,18 @@ mmcli_modem_location_run_synchronous (GDBusConnection *connection) return; } + /* Request to set SUPL server? */ + if (set_supl_server_str) { + gboolean result; + + g_debug ("Synchronously setting SUPL server..."); + result = mm_modem_location_set_supl_server_sync (ctx->modem_location, + set_supl_server_str, + NULL, + &error); + set_supl_server_process_reply (result, error); + return; + } + g_warn_if_reached (); } |