summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2013-09-12 18:11:49 +0200
committerAleksander Morgado <aleksander@lanedo.com>2013-09-12 18:11:49 +0200
commit0fe57ba3f4749930b039bb1ec729addfe10dcda1 (patch)
tree00440490e2c867fcf98056ca5d90689e3253a3ed
parent2db8bb2537354467bd27db3e2dcebe18e2eeca4a (diff)
downloadlibqmi-0fe57ba3f4749930b039bb1ec729addfe10dcda1.tar.gz
cli,wds: add profile contents in the '--wds-get-profile-list' reply
-rw-r--r--src/qmicli/qmicli-wds.c126
1 files changed, 110 insertions, 16 deletions
diff --git a/src/qmicli/qmicli-wds.c b/src/qmicli/qmicli-wds.c
index 6de28a96..3a199de3 100644
--- a/src/qmicli/qmicli-wds.c
+++ b/src/qmicli/qmicli-wds.c
@@ -623,12 +623,113 @@ get_current_data_bearer_technology_ready (QmiClientWds *client,
shutdown (TRUE);
}
+typedef struct {
+ guint i;
+ GArray *profile_list;
+} GetProfileListContext;
+
+static void get_next_profile_settings (GetProfileListContext *inner_ctx);
+
+static void
+get_profile_settings_ready (QmiClientWds *client,
+ GAsyncResult *res,
+ GetProfileListContext *inner_ctx)
+{
+ QmiMessageWdsGetProfileSettingsOutput *output;
+ GError *error = NULL;
+
+ output = qmi_client_wds_get_profile_settings_finish (client, res, &error);
+ if (!output) {
+ g_printerr ("error: operation failed: %s\n", error->message);
+ g_error_free (error);
+ } else if (!qmi_message_wds_get_profile_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_profile_settings_output_get_extended_error_code (
+ output,
+ &ds_profile_error,
+ NULL)) {
+ g_printerr ("error: couldn't get profile settings: ds profile error: %s\n",
+ qmi_wds_ds_profile_error_get_string (ds_profile_error));
+ } else {
+ g_printerr ("error: couldn't get profile settings: %s\n",
+ error->message);
+ }
+ g_error_free (error);
+ qmi_message_wds_get_profile_settings_output_unref (output);
+ } else {
+ const gchar *str;
+ QmiWdsPdpType pdp_type;
+ QmiWdsAuthentication auth;
+
+ if (qmi_message_wds_get_profile_settings_output_get_apn_name (output, &str, NULL))
+ g_print ("\t\tAPN: '%s'\n", str);
+ if (qmi_message_wds_get_profile_settings_output_get_pdp_type (output, &pdp_type, NULL))
+ g_print ("\t\tPDP type: '%s'\n", qmi_wds_pdp_type_get_string (pdp_type));
+ if (qmi_message_wds_get_profile_settings_output_get_username (output, &str, NULL))
+ g_print ("\t\tUsername: '%s'\n", str);
+ if (qmi_message_wds_get_profile_settings_output_get_password (output, &str, NULL))
+ g_print ("\t\tPassword: '%s'\n", str);
+ if (qmi_message_wds_get_profile_settings_output_get_authentication (output, &auth, NULL)) {
+ gchar *aux;
+
+ aux = qmi_wds_authentication_build_string_from_mask (auth);
+ g_print ("\t\tAuth: '%s'\n", aux);
+ g_free (aux);
+ }
+ qmi_message_wds_get_profile_settings_output_unref (output);
+ }
+
+ /* Keep on */
+ inner_ctx->i++;
+ get_next_profile_settings (inner_ctx);
+}
+
+static void
+get_next_profile_settings (GetProfileListContext *inner_ctx)
+{
+ QmiMessageWdsGetProfileListOutputProfileListProfile *profile;
+ QmiMessageWdsGetProfileSettingsInput *input;
+
+ if (inner_ctx->i >= inner_ctx->profile_list->len) {
+ /* All done */
+ g_array_unref (inner_ctx->profile_list);
+ g_slice_free (GetProfileListContext, inner_ctx);
+ shutdown (TRUE);
+ return;
+ }
+
+ profile = &g_array_index (inner_ctx->profile_list, QmiMessageWdsGetProfileListOutputProfileListProfile, inner_ctx->i);
+ g_print ("\t[%u] %s - %s\n",
+ profile->profile_index,
+ qmi_wds_profile_type_get_string (profile->profile_type),
+ profile->profile_name);
+
+ input = qmi_message_wds_get_profile_settings_input_new ();
+ qmi_message_wds_get_profile_settings_input_set_profile_id (
+ input,
+ profile->profile_type,
+ profile->profile_index,
+ NULL);
+ qmi_client_wds_get_profile_settings (ctx->client,
+ input,
+ 3,
+ NULL,
+ (GAsyncReadyCallback)get_profile_settings_ready,
+ inner_ctx);
+ qmi_message_wds_get_profile_settings_input_unref (input);
+}
+
static void
get_profile_list_ready (QmiClientWds *client,
GAsyncResult *res)
{
GError *error = NULL;
QmiMessageWdsGetProfileListOutput *output;
+ GetProfileListContext *inner_ctx;
GArray *profile_list = NULL;
output = qmi_client_wds_get_profile_list_finish (client, res, &error);
@@ -667,24 +768,17 @@ get_profile_list_ready (QmiClientWds *client,
if (!profile_list || !profile_list->len) {
g_print ("Profile list empty\n");
- } else {
- guint i;
-
- g_print ("Profile list retrieved:\n");
-
- for (i = 0; i < profile_list->len; i++) {
- QmiMessageWdsGetProfileListOutputProfileListProfile *profile;
-
- profile = &g_array_index (profile_list, QmiMessageWdsGetProfileListOutputProfileListProfile, i);
- g_print ("\t[%u] %s - %s\n",
- profile->profile_index,
- qmi_wds_profile_type_get_string (profile->profile_type),
- profile->profile_name);
- }
+ qmi_message_wds_get_profile_list_output_unref (output);
+ shutdown (TRUE);
+ return;
}
- qmi_message_wds_get_profile_list_output_unref (output);
- shutdown (TRUE);
+ g_print ("Profile list retrieved:\n");
+
+ inner_ctx = g_slice_new (GetProfileListContext);
+ inner_ctx->profile_list = g_array_ref (profile_list);
+ inner_ctx->i = 0;
+ get_next_profile_settings (inner_ctx);
}
static void