summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-07-30 12:55:14 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-07-30 12:55:14 +0200
commitba317fc234e9133764bb5cda5ffe8b57974081b0 (patch)
treee921f3315a6e23a2e50c0b0793de7f03a99e2f37
parentd9313aac3d473c4a5c5acd1dedd6ce564f97d95d (diff)
cli: new `--nas-get-technology-preference' action
-rw-r--r--cli/qmicli-nas.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/cli/qmicli-nas.c b/cli/qmicli-nas.c
index 457ff3d..39c563d 100644
--- a/cli/qmicli-nas.c
+++ b/cli/qmicli-nas.c
@@ -43,6 +43,7 @@ static Context *ctx;
/* Options */
static gboolean get_signal_strength_flag;
static gboolean get_signal_info_flag;
+static gboolean get_technology_preference_flag;
static gboolean network_scan_flag;
static gboolean reset_flag;
static gboolean noop_flag;
@@ -56,6 +57,10 @@ static GOptionEntry entries[] = {
"Get signal info",
NULL
},
+ { "nas-get-technology-preference", 0, 0, G_OPTION_ARG_NONE, &get_technology_preference_flag,
+ "Get technology preference",
+ NULL
+ },
{ "nas-network-scan", 0, 0, G_OPTION_ARG_NONE, &network_scan_flag,
"Scan networks",
NULL
@@ -97,6 +102,7 @@ qmicli_nas_options_enabled (void)
n_actions = (get_signal_strength_flag +
get_signal_info_flag +
+ get_technology_preference_flag +
network_scan_flag +
reset_flag +
noop_flag);
@@ -433,6 +439,61 @@ get_signal_strength_ready (QmiClientNas *client,
}
static void
+get_technology_preference_ready (QmiClientNas *client,
+ GAsyncResult *res)
+{
+ QmiMessageNasGetTechnologyPreferenceOutput *output;
+ GError *error = NULL;
+ QmiNasRadioTechnologyPreference preference;
+ QmiNasRadioTechnologyPreferenceDuration duration;
+ gchar *preference_string;
+
+ output = qmi_client_nas_get_technology_preference_finish (client, res, &error);
+ if (!output) {
+ g_printerr ("error: operation failed: %s\n", error->message);
+ g_error_free (error);
+ shutdown (FALSE);
+ return;
+ }
+
+ if (!qmi_message_nas_get_technology_preference_output_get_result (output, &error)) {
+ g_printerr ("error: couldn't get technology preference: %s\n", error->message);
+ g_error_free (error);
+ qmi_message_nas_get_technology_preference_output_unref (output);
+ shutdown (FALSE);
+ return;
+ }
+
+ qmi_message_nas_get_technology_preference_output_get_active (
+ output,
+ &preference,
+ &duration,
+ NULL);
+
+ preference_string = qmi_nas_radio_technology_preference_build_string_from_mask (preference);
+ g_print ("[%s] Successfully got technology preference\n"
+ "\tActive: '%s', duration: '%s'\n",
+ qmi_device_get_path_display (ctx->device),
+ preference_string,
+ qmi_nas_radio_technology_preference_duration_get_string (duration));
+ g_free (preference_string);
+
+ if (qmi_message_nas_get_technology_preference_output_get_persistent (
+ output,
+ &preference,
+ NULL)) {
+ preference_string = qmi_nas_radio_technology_preference_build_string_from_mask (preference);
+ g_print ("\tPersistent: '%s', duration: '%s'\n",
+ qmi_device_get_path_display (ctx->device),
+ preference_string);
+ g_free (preference_string);
+ }
+
+ qmi_message_nas_get_technology_preference_output_unref (output);
+ shutdown (TRUE);
+}
+
+static void
network_scan_ready (QmiClientNas *client,
GAsyncResult *res)
{
@@ -603,6 +664,18 @@ qmicli_nas_run (QmiDevice *device,
return;
}
+ /* Request to get technology preference? */
+ if (get_technology_preference_flag) {
+ g_debug ("Asynchronously getting technology preference...");
+ qmi_client_nas_get_technology_preference (ctx->client,
+ NULL,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback)get_technology_preference_ready,
+ NULL);
+ return;
+ }
+
/* Request to scan networks? */
if (network_scan_flag) {
g_debug ("Asynchronously scanning networks...");