From 64f728b375f494a31dcbe978ffa864a1f96e4713 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 12 Sep 2012 11:19:21 +0200 Subject: [PATCH] sms-part: read message class only if TP-DCS available --- src/mm-sms-part.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mm-sms-part.c b/src/mm-sms-part.c index 4f21e3a7..8c8e361c 100644 --- a/src/mm-sms-part.c +++ b/src/mm-sms-part.c @@ -727,9 +727,11 @@ mm_sms_part_new_from_binary_pdu (guint index, mm_dbg (" PID: %u", (guint)pdu[tp_pid_offset]); } - /* Grab user data encoding */ + /* Grab user data encoding and message class */ if (tp_dcs_offset > 0) { PDU_SIZE_CHECK (tp_dcs_offset + 1, "cannot read TP-DCS"); + + /* Encoding given in the 'alphabet' bits */ user_data_encoding = sms_encoding_type(pdu[tp_dcs_offset]); switch (user_data_encoding) { case MM_SMS_ENCODING_GSM7: @@ -746,6 +748,11 @@ mm_sms_part_new_from_binary_pdu (guint index, break; } mm_sms_part_set_encoding (sms_part, user_data_encoding); + + /* Class */ + if (pdu[tp_dcs_offset] & SMS_DCS_CLASS_VALID) + mm_sms_part_set_class (sms_part, + pdu[tp_dcs_offset] & SMS_DCS_CLASS_MASK); } if (tp_user_data_len_offset > 0) { @@ -856,9 +863,6 @@ mm_sms_part_new_from_binary_pdu (guint index, mm_sms_part_set_data_coding_scheme (sms_part, pdu[tp_dcs_offset] & 0xFF); - if (pdu[tp_dcs_offset] & SMS_DCS_CLASS_VALID) - mm_sms_part_set_class (sms_part, - pdu[tp_dcs_offset] & SMS_DCS_CLASS_MASK); } return sms_part;