From 0625feef4df403e6ae02e76631ea49ced17158b6 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 25 Feb 2015 14:44:42 +0100 Subject: [PATCH] voice: implement 'Get Supported Messages' --- data/qmi-service-voice.json | 16 ++++ .../libqmi-glib/libqmi-glib-docs.xml | 1 + src/qmicli/qmicli-voice.c | 75 +++++++++++++++++++ 3 files changed, 92 insertions(+) diff --git a/data/qmi-service-voice.json b/data/qmi-service-voice.json index 2631136..1c4f115 100644 --- a/data/qmi-service-voice.json +++ b/data/qmi-service-voice.json @@ -16,6 +16,22 @@ { "name" : "QMI Indication Voice", "type" : "Indication-ID-Enum" }, + // ********************************************************************************* + { "name" : "Get Supported Messages", + "type" : "Message", + "service" : "VOICE", + "id" : "0x001E", + "version" : "2.21", + "output" : [ { "common-ref" : "Operation Result" }, + { "name" : "List", + "id" : "0x10", + "mandatory" : "no", + "type" : "TLV", + "format" : "array", + "size-prefix-format" : "guint16", + "array-element" : { "format" : "guint8" }, + "prerequisites" : [ { "common-ref" : "Success" } ] } ] }, + // ********************************************************************************* { "name" : "Dial Call", "type" : "Message", diff --git a/docs/reference/libqmi-glib/libqmi-glib-docs.xml b/docs/reference/libqmi-glib/libqmi-glib-docs.xml index 44b6a2e..bc7b26f 100644 --- a/docs/reference/libqmi-glib/libqmi-glib-docs.xml +++ b/docs/reference/libqmi-glib/libqmi-glib-docs.xml @@ -293,6 +293,7 @@ + diff --git a/src/qmicli/qmicli-voice.c b/src/qmicli/qmicli-voice.c index 36b4280..33b27a4 100644 --- a/src/qmicli/qmicli-voice.c +++ b/src/qmicli/qmicli-voice.c @@ -43,6 +43,7 @@ static Context *ctx; /* Options */ static gboolean get_config_flag; +static gboolean get_supported_messages_flag; static gboolean noop_flag; static GOptionEntry entries[] = { @@ -50,6 +51,10 @@ static GOptionEntry entries[] = { "Get Voice service configuration", NULL }, + { "voice-get-supported-messages", 0, 0, G_OPTION_ARG_NONE, &get_supported_messages_flag, + "Get supported messages", + NULL + }, { "voice-noop", 0, 0, G_OPTION_ARG_NONE, &noop_flag, "Just allocate or release a VOICE client. Use with `--client-no-release-cid' and/or `--client-cid'", NULL @@ -82,6 +87,7 @@ qmicli_voice_options_enabled (void) return !!n_actions; n_actions = (get_config_flag + + get_supported_messages_flag + noop_flag); if (n_actions > 1) { @@ -246,6 +252,63 @@ get_config_ready (QmiClientVoice *client, shutdown (TRUE); } +static void +get_supported_messages_ready (QmiClientVoice *client, + GAsyncResult *res) +{ + QmiMessageVoiceGetSupportedMessagesOutput *output; + GError *error = NULL; + GArray *bytearray = NULL; + GString *str = NULL; + + output = qmi_client_voice_get_supported_messages_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_voice_get_supported_messages_output_get_result (output, &error)) { + g_printerr ("error: couldn't get supported VOICE messages: %s\n", error->message); + g_error_free (error); + qmi_message_voice_get_supported_messages_output_unref (output); + shutdown (FALSE); + return; + } + + g_print ("[%s] Successfully got supported VOICE messages:\n", + qmi_device_get_path_display (ctx->device)); + + if (qmi_message_voice_get_supported_messages_output_get_list (output, &bytearray, NULL)) { + + guint bytearray_i; + + for (bytearray_i = 0; bytearray_i < bytearray->len; bytearray_i++) { + guint bit_i; + guint8 bytevalue; + + bytevalue = g_array_index (bytearray, guint8, bytearray_i); + for (bit_i = 0; bit_i < 8; bit_i++) { + if (bytevalue & (1 << bit_i)) { + if (!str) + str = g_string_new (""); + g_string_append_printf (str, "\t0x%04X\n", (bit_i + (8 * bytearray_i))); + } + } + } + } + + if (str) { + g_print ("%s", str->str); + g_string_free (str, TRUE); + } else + g_print ("\tnone\n"); + + qmi_message_voice_get_supported_messages_output_unref (output); + shutdown (TRUE); +} + static gboolean noop_cb (gpointer unused) { @@ -292,6 +355,18 @@ qmicli_voice_run (QmiDevice *device, return; } + /* Request to list supported messages? */ + if (get_supported_messages_flag) { + g_debug ("Asynchronously getting supported voice messages..."); + qmi_client_voice_get_supported_messages (ctx->client, + NULL, + 10, + ctx->cancellable, + (GAsyncReadyCallback)get_supported_messages_ready, + NULL); + return; + } + /* Just client allocate/release? */ if (noop_flag) { g_idle_add (noop_cb, NULL);