diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-05-04 14:26:19 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-03 16:08:50 +0200 |
commit | 9c59c3c3c1586db7c63159d4b039bb96ae6ca1e6 (patch) | |
tree | e8654940a3d603db45ec48cee3302196655b4ccf /cli | |
parent | c9f54f62bd39c732931646c5e48cb6d3166132b1 (diff) | |
download | external_libqmi-9c59c3c3c1586db7c63159d4b039bb96ae6ca1e6.zip external_libqmi-9c59c3c3c1586db7c63159d4b039bb96ae6ca1e6.tar.gz external_libqmi-9c59c3c3c1586db7c63159d4b039bb96ae6ca1e6.tar.bz2 |
cli: new `--wds-get-packet-service-status' operation
Diffstat (limited to 'cli')
-rw-r--r-- | cli/qmicli-wds.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/cli/qmicli-wds.c b/cli/qmicli-wds.c index 93a6b0b..d52ea64 100644 --- a/cli/qmicli-wds.c +++ b/cli/qmicli-wds.c @@ -47,12 +47,17 @@ static Context *ctx; /* Options */ static gboolean start_network_flag; +static gboolean get_packet_service_status_flag; static GOptionEntry entries[] = { { "wds-start-network", 0, 0, G_OPTION_ARG_NONE, &start_network_flag, "Start network", NULL }, + { "wds-get-packet-service-status", 0, 0, G_OPTION_ARG_NONE, &get_packet_service_status_flag, + "Get packet service status", + NULL + }, { NULL } }; @@ -80,7 +85,8 @@ qmicli_wds_options_enabled (void) if (checked) return !!n_actions; - n_actions = (start_network_flag); + n_actions = (start_network_flag + + get_packet_service_status_flag); if (n_actions > 1) { g_printerr ("error: too many WDS actions requested\n"); @@ -279,6 +285,35 @@ start_network_ready (QmiClientWds *client, } static void +get_packet_service_status_ready (QmiClientWds *client, + GAsyncResult *res) +{ + GError *error = NULL; + QmiWdsGetPacketServiceStatusOutput *output; + + output = qmi_client_wds_get_packet_service_status_finish (client, res, &error); + if (!output) { + g_printerr ("error: operation failed: %s\n", + error->message); + exit (EXIT_FAILURE); + } + + if (!qmi_wds_get_packet_service_status_output_get_result (output, &error)) { + g_printerr ("error: couldn't get packet service status: %s\n", error->message); + exit (EXIT_FAILURE); + } + + g_print ("[%s] Connection status: '%s'\n", + qmi_device_get_path_display (ctx->device), + qmi_wds_connection_status_get_string ( + qmi_wds_get_packet_service_status_output_get_connection_status ( + output))); + + qmi_wds_get_packet_service_status_output_unref (output); + shutdown (); +} + +static void allocate_client_ready (QmiDevice *device, GAsyncResult *res) { @@ -303,6 +338,18 @@ allocate_client_ready (QmiDevice *device, return; } + /* Request to get packet service status? */ + if (get_packet_service_status_flag) { + g_debug ("Asynchronously getting packet service status..."); + qmi_client_wds_get_packet_service_status (ctx->client, + NULL, + 10, + ctx->cancellable, + (GAsyncReadyCallback)get_packet_service_status_ready, + NULL); + return; + } + g_warn_if_reached (); } |