sms-part-cdma: support receiving SMS with Latin encoding
This commit is contained in:
@@ -862,6 +862,32 @@ read_bearer_data_user_data (MMSmsPart *sms_part,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ENCODING_LATIN: {
|
||||||
|
gchar *latin;
|
||||||
|
gchar *text;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
SUBPARAMETER_SIZE_CHECK (byte_offset + 1 + ((bit_offset + (num_fields * 8)) / 8));
|
||||||
|
|
||||||
|
latin = g_malloc (num_fields + 1);
|
||||||
|
for (i = 0; i < num_fields; i++) {
|
||||||
|
latin[i] = read_bits (&subparameter->parameter_value[byte_offset], bit_offset, 8);
|
||||||
|
OFFSETS_UPDATE (8);
|
||||||
|
}
|
||||||
|
latin[i] = '\0';
|
||||||
|
|
||||||
|
text = g_convert (latin, -1, "UTF-8", "ISO−8859−1", NULL, NULL, NULL);
|
||||||
|
if (!text) {
|
||||||
|
mm_dbg (" text/data: ignored (latin to UTF-8 conversion error)");
|
||||||
|
} else {
|
||||||
|
mm_dbg (" text: '%s'", text);
|
||||||
|
mm_sms_part_take_text (sms_part, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (latin);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
mm_dbg (" text/data: ignored (unsupported encoding)");
|
mm_dbg (" text/data: ignored (unsupported encoding)");
|
||||||
}
|
}
|
||||||
|
@@ -238,6 +238,50 @@ test_created_by_us (void)
|
|||||||
"AAAA");
|
"AAAA");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_latin_encoding (void)
|
||||||
|
{
|
||||||
|
static const guint8 pdu[] = {
|
||||||
|
/* message type */
|
||||||
|
0x00,
|
||||||
|
/* teleservice id */
|
||||||
|
0x00, 0x02,
|
||||||
|
0x10, 0x02,
|
||||||
|
/* originating address */
|
||||||
|
0x02, 0x07,
|
||||||
|
0x02, 0x8C, 0xE9, 0x5D, 0xCC, 0x65, 0x80,
|
||||||
|
/* bearer reply option */
|
||||||
|
0x06, 0x01,
|
||||||
|
0xFC,
|
||||||
|
/* bearer data */
|
||||||
|
0x08, 0x39,
|
||||||
|
/* message id */
|
||||||
|
0x00, 0x03,
|
||||||
|
0x13, 0x8D, 0x20,
|
||||||
|
/* user data */
|
||||||
|
0x01, 0x27,
|
||||||
|
0x41, 0x29, 0x19, 0x22, 0xE1, 0x19, 0x1A, 0xE1,
|
||||||
|
0x1A, 0x01, 0x19, 0xA1, 0x19, 0xA1, 0xA9, 0xB1,
|
||||||
|
0xB9, 0xE9, 0x53, 0x4B, 0x23, 0xAB, 0x53, 0x23,
|
||||||
|
0xAB, 0x23, 0x2B, 0xAB, 0xAB, 0x2B, 0x23, 0xAB,
|
||||||
|
0x53, 0x23, 0x2B, 0xAB, 0x53, 0xAB, 0x20,
|
||||||
|
/* message center timestamp */
|
||||||
|
0x03, 0x06,
|
||||||
|
0x13, 0x10, 0x23, 0x20, 0x06, 0x37,
|
||||||
|
/* priority indicator */
|
||||||
|
0x08, 0x01,
|
||||||
|
0x00
|
||||||
|
};
|
||||||
|
|
||||||
|
common_test_part_from_pdu (
|
||||||
|
pdu, sizeof (pdu),
|
||||||
|
MM_SMS_CDMA_TELESERVICE_ID_WMT,
|
||||||
|
MM_SMS_CDMA_SERVICE_CATEGORY_UNKNOWN,
|
||||||
|
"3305773196",
|
||||||
|
63,
|
||||||
|
"#$\\##\\#@#4#4567=*idujdudeuuedujdeujud");
|
||||||
|
}
|
||||||
|
|
||||||
/********************* PDU CREATOR TESTS *********************/
|
/********************* PDU CREATOR TESTS *********************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -341,6 +385,8 @@ int main (int argc, char **argv)
|
|||||||
g_test_add_func ("/MM/SMS/CDMA/PDU-Parser/invalid-parameter-length", test_invalid_parameter_length);
|
g_test_add_func ("/MM/SMS/CDMA/PDU-Parser/invalid-parameter-length", test_invalid_parameter_length);
|
||||||
g_test_add_func ("/MM/SMS/CDMA/PDU-Parser/invalid-address-length", test_invalid_address_length);
|
g_test_add_func ("/MM/SMS/CDMA/PDU-Parser/invalid-address-length", test_invalid_address_length);
|
||||||
g_test_add_func ("/MM/SMS/CDMA/PDU-Parser/created-by-us", test_created_by_us);
|
g_test_add_func ("/MM/SMS/CDMA/PDU-Parser/created-by-us", test_created_by_us);
|
||||||
|
g_test_add_func ("/MM/SMS/CDMA/PDU-Parser/latin-encoding", test_latin_encoding);
|
||||||
|
|
||||||
g_test_add_func ("/MM/SMS/CDMA/PDU-Creator/Text", test_create_pdu_text);
|
g_test_add_func ("/MM/SMS/CDMA/PDU-Creator/Text", test_create_pdu_text);
|
||||||
|
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
|
Reference in New Issue
Block a user