sms-part-cdma: read 7-bit ASCII text or raw data
This commit is contained in:
@@ -744,7 +744,7 @@ read_bearer_data_user_data (MMSmsPart *sms_part,
|
||||
const struct Parameter *subparameter)
|
||||
{
|
||||
guint8 message_encoding;
|
||||
guint8 message_type;
|
||||
guint8 message_type = 0;
|
||||
guint8 num_fields;
|
||||
guint byte_offset = 0;
|
||||
guint bit_offset = 0;
|
||||
@@ -824,6 +824,48 @@ read_bearer_data_user_data (MMSmsPart *sms_part,
|
||||
OFFSETS_UPDATE (8);
|
||||
mm_dbg (" num fields: %u", num_fields);
|
||||
|
||||
/* Now, process actual text or data */
|
||||
switch (message_encoding) {
|
||||
case ENCODING_OCTET: {
|
||||
GByteArray *data;
|
||||
guint i;
|
||||
|
||||
SUBPARAMETER_SIZE_CHECK (byte_offset + 1 + ((bit_offset + (num_fields * 8)) / 8));
|
||||
|
||||
data = g_byte_array_sized_new (num_fields);
|
||||
g_byte_array_set_size (data, num_fields);
|
||||
for (i = 0; i < num_fields; i++) {
|
||||
data->data[i] = read_bits (&subparameter->parameter_value[byte_offset], bit_offset, 8);
|
||||
OFFSETS_UPDATE (8);
|
||||
}
|
||||
|
||||
mm_dbg (" data: (%u bytes)", num_fields);
|
||||
mm_sms_part_take_data (sms_part, data);
|
||||
break;
|
||||
}
|
||||
|
||||
case ENCODING_ASCII_7BIT: {
|
||||
gchar *text;
|
||||
guint i;
|
||||
|
||||
SUBPARAMETER_SIZE_CHECK (byte_offset + 1 + ((bit_offset + (num_fields * 7)) / 8));
|
||||
|
||||
text = g_malloc (num_fields + 1);
|
||||
for (i = 0; i < num_fields; i++) {
|
||||
text[i] = read_bits (&subparameter->parameter_value[byte_offset], bit_offset, 7);
|
||||
OFFSETS_UPDATE (7);
|
||||
}
|
||||
text[i] = '\0';
|
||||
|
||||
mm_dbg (" text: '%s'", text);
|
||||
mm_sms_part_take_text (sms_part, text);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
mm_dbg (" text/data: ignored (unsupported encoding)");
|
||||
}
|
||||
|
||||
#undef OFFSETS_UPDATE
|
||||
#undef SUBPARAMETER_SIZE_CHECK
|
||||
}
|
||||
|
@@ -49,7 +49,8 @@ common_test_part_from_hexpdu (const gchar *hexpdu,
|
||||
MMSmsCdmaTeleserviceId expected_teleservice_id,
|
||||
MMSmsCdmaServiceCategory expected_service_category,
|
||||
const gchar *expected_address,
|
||||
guint8 expected_bearer_reply_option)
|
||||
guint8 expected_bearer_reply_option,
|
||||
const gchar *expected_text)
|
||||
{
|
||||
MMSmsPart *part;
|
||||
GError *error = NULL;
|
||||
@@ -71,6 +72,8 @@ common_test_part_from_hexpdu (const gchar *hexpdu,
|
||||
}
|
||||
if (expected_bearer_reply_option)
|
||||
g_assert_cmpuint (expected_bearer_reply_option, ==, mm_sms_part_get_message_reference (part));
|
||||
if (expected_text)
|
||||
g_assert_cmpstr (expected_text, ==, mm_sms_part_get_text (part));
|
||||
|
||||
mm_sms_part_free (part);
|
||||
}
|
||||
@@ -81,7 +84,8 @@ common_test_part_from_pdu (const guint8 *pdu,
|
||||
MMSmsCdmaTeleserviceId expected_teleservice_id,
|
||||
MMSmsCdmaServiceCategory expected_service_category,
|
||||
const gchar *expected_address,
|
||||
guint8 expected_bearer_reply_option)
|
||||
guint8 expected_bearer_reply_option,
|
||||
const gchar *expected_text)
|
||||
{
|
||||
gchar *hexpdu;
|
||||
|
||||
@@ -90,7 +94,8 @@ common_test_part_from_pdu (const guint8 *pdu,
|
||||
expected_teleservice_id,
|
||||
expected_service_category,
|
||||
expected_address,
|
||||
expected_bearer_reply_option);
|
||||
expected_bearer_reply_option,
|
||||
expected_text);
|
||||
g_free (hexpdu);
|
||||
}
|
||||
|
||||
@@ -146,7 +151,8 @@ test_pdu1 (void)
|
||||
MM_SMS_CDMA_TELESERVICE_ID_WMT,
|
||||
MM_SMS_CDMA_SERVICE_CATEGORY_UNKNOWN,
|
||||
"3305773196",
|
||||
63);
|
||||
63,
|
||||
"AAAA");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -201,7 +207,8 @@ test_invalid_address_length (void)
|
||||
MM_SMS_CDMA_TELESERVICE_ID_WMT,
|
||||
MM_SMS_CDMA_SERVICE_CATEGORY_UNKNOWN,
|
||||
"",
|
||||
63);
|
||||
63,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/************************************************************/
|
||||
|
Reference in New Issue
Block a user