gsm: convert SMS text and number from current charset to UTF-8

This commit is contained in:
Aleksander Morgado
2012-02-07 18:01:28 +01:00
parent 00ce1d6874
commit 03678df6fd

View File

@@ -5200,9 +5200,12 @@ get_match_string_unquoted (GMatchInfo *m, guint match_index)
static gboolean static gboolean
text_parse_cmgl (MMGenericGsm *self, const char *response, GError **error) text_parse_cmgl (MMGenericGsm *self, const char *response, GError **error)
{ {
MMGenericGsmPrivate *priv;
GRegex *r; GRegex *r;
GMatchInfo *match_info = NULL; GMatchInfo *match_info = NULL;
priv = MM_GENERIC_GSM_GET_PRIVATE (self);
/* +CMGL: <index>,<stat>,<oa/da>,[alpha],<scts><CR><LF><data><CR><LF> */ /* +CMGL: <index>,<stat>,<oa/da>,[alpha],<scts><CR><LF><data><CR><LF> */
r = g_regex_new ("\\+CMGL:\\s*(\\d+)\\s*,\\s*([^,]*),\\s*([^,]*),\\s*([^,]*),\\s*([^\\r\\n]*)\\r\\n(.*)\\r\\n", 0, 0, NULL); r = g_regex_new ("\\+CMGL:\\s*(\\d+)\\s*,\\s*([^,]*),\\s*([^,]*),\\s*([^,]*),\\s*([^\\r\\n]*)\\r\\n(.*)\\r\\n", 0, 0, NULL);
g_assert (r); g_assert (r);
@@ -5235,16 +5238,21 @@ text_parse_cmgl (MMGenericGsm *self, const char *response, GError **error)
/* <stat is ignored for now> */ /* <stat is ignored for now> */
/* Get and parse number */
number = get_match_string_unquoted (match_info, 3); number = get_match_string_unquoted (match_info, 3);
if (!number) { if (!number) {
mm_dbg ("Failed to get message sender number"); mm_dbg ("Failed to get message sender number");
goto next; goto next;
} }
number = mm_charset_take_and_convert_to_utf8 (number,
priv->cur_charset);
/* Get and parse timestamp (always expected in ASCII) */
timestamp = get_match_string_unquoted (match_info, 5); timestamp = get_match_string_unquoted (match_info, 5);
text = g_match_info_fetch (match_info, 6); /* Get and parse text */
/* FIXME: Text is going to be in the character set we've set with +CSCS */ text = mm_charset_take_and_convert_to_utf8 (g_match_info_fetch (match_info, 6),
priv->cur_charset);
/* The raw SMS data can only be GSM, UCS2, or unknown (8-bit), so we /* The raw SMS data can only be GSM, UCS2, or unknown (8-bit), so we
* need to convert to UCS2 here. * need to convert to UCS2 here.