summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2013-09-12 18:19:28 +0200
committerAleksander Morgado <aleksander@lanedo.com>2013-09-12 18:19:28 +0200
commite7d0b5560fcc36d4f0592799dfa57b09113f9caf (patch)
treedb1f7b0dae95e906289f474d8728adbecbeb5a52
parent0fe57ba3f4749930b039bb1ec729addfe10dcda1 (diff)
downloadlibqmi-e7d0b5560fcc36d4f0592799dfa57b09113f9caf.tar.gz
cli,wds: new '--wds-get-default-settings'
-rw-r--r--src/qmicli/qmicli-wds.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/qmicli/qmicli-wds.c b/src/qmicli/qmicli-wds.c
index 3a199de3..622308d8 100644
--- a/src/qmicli/qmicli-wds.c
+++ b/src/qmicli/qmicli-wds.c
@@ -54,6 +54,7 @@ static gboolean get_packet_statistics_flag;
static gboolean get_data_bearer_technology_flag;
static gboolean get_current_data_bearer_technology_flag;
static gchar *get_profile_list_str;
+static gchar *get_default_settings_str;
static gboolean reset_flag;
static gboolean noop_flag;
@@ -90,6 +91,10 @@ static GOptionEntry entries[] = {
"Get profile list",
"[3gpp|3gpp2]"
},
+ { "wds-get-default-settings", 0, 0, G_OPTION_ARG_STRING, &get_default_settings_str,
+ "Get default settings",
+ "[3gpp|3gpp2]"
+ },
{ "wds-reset", 0, 0, G_OPTION_ARG_NONE, &reset_flag,
"Reset the service state",
NULL
@@ -132,6 +137,7 @@ qmicli_wds_options_enabled (void)
get_data_bearer_technology_flag +
get_current_data_bearer_technology_flag +
!!get_profile_list_str +
+ !!get_default_settings_str +
reset_flag +
noop_flag);
@@ -782,6 +788,68 @@ get_profile_list_ready (QmiClientWds *client,
}
static void
+get_default_settings_ready (QmiClientWds *client,
+ GAsyncResult *res)
+{
+ QmiMessageWdsGetDefaultSettingsOutput *output;
+ GError *error = NULL;
+ const gchar *str;
+ QmiWdsPdpType pdp_type;
+ QmiWdsAuthentication auth;
+
+ output = qmi_client_wds_get_default_settings_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_wds_get_default_settings_output_get_result (output, &error)) {
+ QmiWdsDsProfileError ds_profile_error;
+
+ if (g_error_matches (error,
+ QMI_PROTOCOL_ERROR,
+ QMI_PROTOCOL_ERROR_EXTENDED_INTERNAL) &&
+ qmi_message_wds_get_default_settings_output_get_extended_error_code (
+ output,
+ &ds_profile_error,
+ NULL)) {
+ g_printerr ("error: couldn't get default settings: ds default error: %s\n",
+ qmi_wds_ds_profile_error_get_string (ds_profile_error));
+ } else {
+ g_printerr ("error: couldn't get default settings: %s\n",
+ error->message);
+ }
+ g_error_free (error);
+ qmi_message_wds_get_default_settings_output_unref (output);
+ shutdown (FALSE);
+ return;
+ }
+
+ g_print ("Default settings retrieved:\n");
+
+ if (qmi_message_wds_get_default_settings_output_get_apn_name (output, &str, NULL))
+ g_print ("\tAPN: '%s'\n", str);
+ if (qmi_message_wds_get_default_settings_output_get_pdp_type (output, &pdp_type, NULL))
+ g_print ("\tPDP type: '%s'\n", qmi_wds_pdp_type_get_string (pdp_type));
+ if (qmi_message_wds_get_default_settings_output_get_username (output, &str, NULL))
+ g_print ("\tUsername: '%s'\n", str);
+ if (qmi_message_wds_get_default_settings_output_get_password (output, &str, NULL))
+ g_print ("\tPassword: '%s'\n", str);
+ if (qmi_message_wds_get_default_settings_output_get_authentication (output, &auth, NULL)) {
+ gchar *aux;
+
+ aux = qmi_wds_authentication_build_string_from_mask (auth);
+ g_print ("\tAuth: '%s'\n", aux);
+ g_free (aux);
+ }
+
+ qmi_message_wds_get_default_settings_output_unref (output);
+ shutdown (TRUE);
+}
+
+static void
reset_ready (QmiClientWds *client,
GAsyncResult *res)
{
@@ -969,6 +1037,7 @@ qmicli_wds_run (QmiDevice *device,
return;
}
+ /* Request to list profiles? */
if (get_profile_list_str) {
QmiMessageWdsGetProfileListInput *input;
@@ -995,6 +1064,33 @@ qmicli_wds_run (QmiDevice *device,
return;
}
+ /* Request to print default settings? */
+ if (get_default_settings_str) {
+ QmiMessageWdsGetDefaultSettingsInput *input;
+
+ input = qmi_message_wds_get_default_settings_input_new ();
+ if (g_str_equal (get_default_settings_str, "3gpp"))
+ qmi_message_wds_get_default_settings_input_set_profile_type (input, QMI_WDS_PROFILE_TYPE_3GPP, NULL);
+ else if (g_str_equal (get_default_settings_str, "3gpp2"))
+ qmi_message_wds_get_default_settings_input_set_profile_type (input, QMI_WDS_PROFILE_TYPE_3GPP2, NULL);
+ else {
+ g_printerr ("error: invalid default type '%s'. Expected '3gpp' or '3gpp2'.'\n",
+ get_default_settings_str);
+ shutdown (FALSE);
+ return;
+ }
+
+ g_debug ("Asynchronously get default settings...");
+ qmi_client_wds_get_default_settings (ctx->client,
+ input,
+ 10,
+ ctx->cancellable,
+ (GAsyncReadyCallback)get_default_settings_ready,
+ NULL);
+ qmi_message_wds_get_default_settings_input_unref (input);
+ return;
+ }
+
/* Request to reset WDS service? */
if (reset_flag) {
g_debug ("Asynchronously resetting WDS service...");