diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2021-02-14 15:23:43 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2021-02-23 11:35:11 +0000 |
commit | 75b37e16b12ca3807852804fed668ba2fd7ca317 (patch) | |
tree | 6228e1622d604573767965e02a2e0a110c97e1c3 /plugins | |
parent | 9c613d33e1f60501cc8406f6429097d8bda87c59 (diff) |
charsets: make charset_utf8_to_unpacked_gsm() private
Use the generic mm_modem_charset_bytearray_from_utf8() instead.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/huawei/mm-broadband-modem-huawei.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c index dc8f758d..8e17d531 100644 --- a/plugins/huawei/mm-broadband-modem-huawei.c +++ b/plugins/huawei/mm-broadband-modem-huawei.c @@ -2301,11 +2301,11 @@ encode (MMIfaceModem3gppUssd *self, guint *scheme, GError **error) { - gchar *hex; - guint8 *gsm, *packed; - guint32 len = 0, packed_len = 0; + g_autoptr(GByteArray) gsm = NULL; + g_autofree guint8 *packed = NULL; + guint32 packed_len = 0; - gsm = mm_charset_utf8_to_unpacked_gsm (command, FALSE, &len, error); + gsm = mm_modem_charset_bytearray_from_utf8 (command, MM_MODEM_CHARSET_GSM, FALSE, error); if (!gsm) return NULL; @@ -2314,18 +2314,14 @@ encode (MMIfaceModem3gppUssd *self, /* If command is a multiple of 7 characters long, Huawei firmwares * apparently want that padded. Maybe all modems? */ - if (len % 7 == 0) { - gsm = g_realloc (gsm, len + 1); - gsm[len] = 0x0d; - len++; - } + if (gsm->len % 7 == 0) { + static const guint8 padding = 0x0d; - packed = mm_charset_gsm_pack (gsm, len, 0, &packed_len); - hex = mm_utils_bin2hexstr (packed, packed_len); - g_free (packed); - g_free (gsm); + g_byte_array_append (gsm, &padding, 1); + } - return hex; + packed = mm_charset_gsm_pack (gsm->data, gsm->len, 0, &packed_len); + return mm_utils_bin2hexstr (packed, packed_len); } static gchar * |