diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-02 12:52:24 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-03 16:08:58 +0200 |
commit | 0fed725f411c686c24bc087bb2a882ec97792600 (patch) | |
tree | 106ae25717b98ef8da055c119ca9e5fcd3724ff5 | |
parent | eefe0a0ece79bfea305d46ed9ad9212154aa41f6 (diff) |
cli: new `--dms-uim-get-iccid' action
-rw-r--r-- | cli/qmicli-dms.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/cli/qmicli-dms.c b/cli/qmicli-dms.c index cbd9240..2741442 100644 --- a/cli/qmicli-dms.c +++ b/cli/qmicli-dms.c @@ -53,6 +53,7 @@ static gchar *uim_verify_pin_str; static gchar *uim_unblock_pin_str; static gchar *uim_change_pin_str; static gboolean uim_get_pin_status_flag; +static gboolean uim_get_iccid_flag; static gboolean get_hardware_revision_flag; static gboolean get_operating_mode_flag; static gchar *set_operating_mode_str; @@ -107,6 +108,10 @@ static GOptionEntry entries[] = { "Get PIN status", NULL }, + { "dms-uim-get-iccid", 0, 0, G_OPTION_ARG_NONE, &uim_get_iccid_flag, + "Get ICCID", + NULL + }, { "dms-get-hardware-revision", 0, 0, G_OPTION_ARG_NONE, &get_hardware_revision_flag, "Get the HW revision", NULL @@ -162,6 +167,7 @@ qmicli_dms_options_enabled (void) !!uim_unblock_pin_str + !!uim_change_pin_str + uim_get_pin_status_flag + + uim_get_iccid_flag + get_hardware_revision_flag + get_operating_mode_flag + !!set_operating_mode_str + @@ -878,6 +884,44 @@ uim_get_pin_status_ready (QmiClientDms *client, } static void +uim_get_iccid_ready (QmiClientDms *client, + GAsyncResult *res) +{ + const gchar *str = NULL; + QmiMessageDmsUimGetIccidOutput *output; + GError *error = NULL; + + output = qmi_client_dms_uim_get_iccid_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_dms_uim_get_iccid_output_get_result (output, &error)) { + g_printerr ("error: couldn't get ICCID: %s\n", error->message); + g_error_free (error); + qmi_message_dms_uim_get_iccid_output_unref (output); + shutdown (FALSE); + return; + } + +#undef VALIDATE_UNKNOWN +#define VALIDATE_UNKNOWN(str) (str ? str : "unknown") + + qmi_message_dms_uim_get_iccid_output_get_iccid (output, &str, NULL); + + g_print ("[%s] UIM ICCID retrieved:\n" + "\tICCID: '%s'\n", + qmi_device_get_path_display (ctx->device), + VALIDATE_UNKNOWN (str)); + + qmi_message_dms_uim_get_iccid_output_unref (output); + shutdown (TRUE); +} + +static void get_hardware_revision_ready (QmiClientDms *client, GAsyncResult *res) { @@ -1202,6 +1246,18 @@ qmicli_dms_run (QmiDevice *device, return; } + /* Request to get UIM ICCID? */ + if (uim_get_iccid_flag) { + g_debug ("Asynchronously getting UIM ICCID..."); + qmi_client_dms_uim_get_iccid (ctx->client, + NULL, + 10, + ctx->cancellable, + (GAsyncReadyCallback)uim_get_iccid_ready, + NULL); + return; + } + /* Request to get hardware revision? */ if (get_hardware_revision_flag) { g_debug ("Asynchronously getting hardware revision..."); |