diff options
Diffstat (limited to 'src/qmicli/qmicli-wms.c')
-rw-r--r-- | src/qmicli/qmicli-wms.c | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/src/qmicli/qmicli-wms.c b/src/qmicli/qmicli-wms.c index 4c58274..9cc7943 100644 --- a/src/qmicli/qmicli-wms.c +++ b/src/qmicli/qmicli-wms.c @@ -31,6 +31,7 @@ #include <libqmi-glib.h> #include "qmicli.h" +#include "qmicli-helpers.h" /* Context */ typedef struct { @@ -126,7 +127,7 @@ get_supported_messages_ready (QmiClientWms *client, QmiMessageWmsGetSupportedMessagesOutput *output; GError *error = NULL; GArray *bytearray = NULL; - GString *str = NULL; + gchar *str; output = qmi_client_wms_get_supported_messages_finish (client, res, &error); if (!output) { @@ -147,30 +148,11 @@ get_supported_messages_ready (QmiClientWms *client, g_print ("[%s] Successfully got supported WMS messages:\n", qmi_device_get_path_display (ctx->device)); - if (qmi_message_wms_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_wms_get_supported_messages_output_get_list (output, &bytearray, NULL); + str = qmicli_get_supported_messages_list (bytearray ? (const guint8 *)bytearray->data : NULL, + bytearray ? bytearray->len : 0); + g_print ("%s", str); + g_free (str); qmi_message_wms_get_supported_messages_output_unref (output); shutdown (TRUE); |