sms-part: don't keep track of the whole TP-DCS value

We already retrieve the bits we use from it, class and encoding.
This commit is contained in:
Aleksander Morgado
2012-09-12 11:27:30 +02:00
parent 64f728b375
commit baf3ed0c64
4 changed files with 17 additions and 35 deletions

View File

@@ -4955,7 +4955,6 @@ sms_text_part_list_ready (MMBroadbandModem *self,
mm_sms_part_take_timestamp (part, timestamp); mm_sms_part_take_timestamp (part, timestamp);
mm_sms_part_take_text (part, text); mm_sms_part_take_text (part, text);
mm_sms_part_take_data (part, raw); mm_sms_part_take_data (part, raw);
mm_sms_part_set_data_coding_scheme (part, 2); /* DCS = UCS2 */
mm_sms_part_set_class (part, 0); mm_sms_part_set_class (part, 0);
mm_dbg ("Correctly parsed SMS list entry (%d)", idx); mm_dbg ("Correctly parsed SMS list entry (%d)", idx);

View File

@@ -326,7 +326,6 @@ struct _MMSmsPart {
gchar *text; gchar *text;
MMSmsEncoding encoding; MMSmsEncoding encoding;
GByteArray *data; GByteArray *data;
guint data_coding_scheme;
guint class; guint class;
guint validity; guint validity;
gboolean delivery_report_request; gboolean delivery_report_request;
@@ -403,8 +402,6 @@ PART_GET_FUNC (guint, concat_sequence)
PART_SET_FUNC (guint, concat_sequence) PART_SET_FUNC (guint, concat_sequence)
PART_GET_FUNC (const gchar *, text) PART_GET_FUNC (const gchar *, text)
PART_SET_TAKE_STR_FUNC (text) PART_SET_TAKE_STR_FUNC (text)
PART_GET_FUNC (guint, data_coding_scheme)
PART_SET_FUNC (guint, data_coding_scheme)
PART_GET_FUNC (MMSmsEncoding, encoding) PART_GET_FUNC (MMSmsEncoding, encoding)
PART_SET_FUNC (MMSmsEncoding, encoding) PART_SET_FUNC (MMSmsEncoding, encoding)
PART_GET_FUNC (guint, class) PART_GET_FUNC (guint, class)
@@ -860,9 +857,6 @@ mm_sms_part_new_from_binary_pdu (guint index,
raw = g_byte_array_sized_new (tp_user_data_size_bytes); raw = g_byte_array_sized_new (tp_user_data_size_bytes);
g_byte_array_append (raw, &pdu[tp_user_data_offset], tp_user_data_size_bytes); g_byte_array_append (raw, &pdu[tp_user_data_offset], tp_user_data_size_bytes);
mm_sms_part_take_data (sms_part, raw); mm_sms_part_take_data (sms_part, raw);
mm_sms_part_set_data_coding_scheme (sms_part,
pdu[tp_dcs_offset] & 0xFF);
} }
return sms_part; return sms_part;

View File

@@ -92,10 +92,6 @@ void mm_sms_part_set_data (MMSmsPart *part,
void mm_sms_part_take_data (MMSmsPart *part, void mm_sms_part_take_data (MMSmsPart *part,
GByteArray *data); GByteArray *data);
guint mm_sms_part_get_data_coding_scheme (MMSmsPart *part);
void mm_sms_part_set_data_coding_scheme (MMSmsPart *part,
guint data_coding_scheme);
MMSmsEncoding mm_sms_part_get_encoding (MMSmsPart *part); MMSmsEncoding mm_sms_part_get_encoding (MMSmsPart *part);
void mm_sms_part_set_encoding (MMSmsPart *part, void mm_sms_part_set_encoding (MMSmsPart *part,
MMSmsEncoding encoding); MMSmsEncoding encoding);

View File

@@ -51,8 +51,7 @@ common_test_part_from_hexpdu (const gchar *hexpdu,
gboolean expected_multipart, gboolean expected_multipart,
const gchar *expected_text, const gchar *expected_text,
const guint8 *expected_data, const guint8 *expected_data,
gsize expected_data_size, gsize expected_data_size)
guint expected_data_coding_scheme)
{ {
MMSmsPart *part; MMSmsPart *part;
GError *error = NULL; GError *error = NULL;
@@ -76,13 +75,11 @@ common_test_part_from_hexpdu (const gchar *hexpdu,
const GByteArray *data; const GByteArray *data;
data = mm_sms_part_get_data (part); data = mm_sms_part_get_data (part);
g_assert_cmpuint (expected_data_coding_scheme, ==, mm_sms_part_get_data_coding_scheme (part));
g_assert_cmpuint ((guint)expected_data_size, ==, data->len); g_assert_cmpuint ((guint)expected_data_size, ==, data->len);
for (i = 0; i < data->len; i++) for (i = 0; i < data->len; i++)
g_assert_cmpuint ((guint)data->data[i], ==, expected_data[i]); g_assert_cmpuint ((guint)data->data[i], ==, expected_data[i]);
} }
mm_sms_part_free (part); mm_sms_part_free (part);
} }
@@ -95,8 +92,7 @@ common_test_part_from_pdu (const guint8 *pdu,
gboolean expected_multipart, gboolean expected_multipart,
const gchar *expected_text, const gchar *expected_text,
const guint8 *expected_data, const guint8 *expected_data,
gsize expected_data_size, gsize expected_data_size)
guint expected_data_coding_scheme)
{ {
gchar *hexpdu; gchar *hexpdu;
@@ -108,8 +104,7 @@ common_test_part_from_pdu (const guint8 *pdu,
expected_multipart, expected_multipart,
expected_text, expected_text,
expected_data, expected_data,
expected_data_size, expected_data_size);
expected_data_coding_scheme);
g_free (hexpdu); g_free (hexpdu);
} }
@@ -143,7 +138,7 @@ test_pdu1 (void)
FALSE, FALSE,
"Here's a longer message [{with some extended characters}] " "Here's a longer message [{with some extended characters}] "
"thrown in, such as £ and ΩΠΨ and §¿ as well.", /* text */ "thrown in, such as £ and ΩΠΨ and §¿ as well.", /* text */
NULL, 0, 0); NULL, 0);
} }
static void static void
@@ -163,7 +158,7 @@ test_pdu2 (void)
"110329192004+04", /* timestamp */ "110329192004+04", /* timestamp */
FALSE, FALSE,
"тест", /* text */ "тест", /* text */
NULL, 0, 0); NULL, 0);
} }
static void static void
@@ -183,7 +178,7 @@ test_pdu3 (void)
"110101123456+00", /* timestamp */ "110101123456+00", /* timestamp */
FALSE, FALSE,
"hellohello", /* text */ "hellohello", /* text */
NULL, 0, 0); NULL, 0);
} }
static void static void
@@ -204,7 +199,7 @@ test_pdu3_nzpid (void)
"110101123456+00", /* timestamp */ "110101123456+00", /* timestamp */
FALSE, FALSE,
"hellohello", /* text */ "hellohello", /* text */
NULL, 0, 0); NULL, 0);
} }
static void static void
@@ -225,7 +220,7 @@ test_pdu3_mms (void)
"110101123456+00", /* timestamp */ "110101123456+00", /* timestamp */
FALSE, FALSE,
"hellohello", /* text */ "hellohello", /* text */
NULL, 0, 0); NULL, 0);
} }
static void static void
@@ -246,7 +241,7 @@ test_pdu3_natl (void)
"110101123456+00", /* timestamp */ "110101123456+00", /* timestamp */
FALSE, FALSE,
"hellohello", /* text */ "hellohello", /* text */
NULL, 0, 0); NULL, 0);
} }
static void static void
@@ -269,8 +264,7 @@ test_pdu3_8bit (void)
FALSE, FALSE,
"", /* text */ "", /* text */
expected_data, /* data */ expected_data, /* data */
sizeof (expected_data), /* data size */ sizeof (expected_data)); /* data size */
0x04); /* data coding scheme */
} }
static void static void
@@ -319,7 +313,7 @@ test_pdu_dcsf1 (void)
"Info SFR - Confidentiel, à ne jamais transmettre -\r\n" "Info SFR - Confidentiel, à ne jamais transmettre -\r\n"
"Voici votre nouveau mot de passe : sw2ced pour gérer " "Voici votre nouveau mot de passe : sw2ced pour gérer "
"votre compte SFR sur www.sfr.fr ou par téléphone au 963", /* text */ "votre compte SFR sur www.sfr.fr ou par téléphone au 963", /* text */
NULL, 0, 0); NULL, 0);
} }
static void static void
@@ -342,8 +336,7 @@ test_pdu_dcsf_8bit (void)
FALSE, FALSE,
"", /* text */ "", /* text */
expected_data, /* data */ expected_data, /* data */
sizeof (expected_data), /* data size */ sizeof (expected_data)); /* data size */
0xF4); /* data coding scheme */
} }
static void static void
@@ -389,7 +382,7 @@ test_pdu_udhi (void)
"Welkom, bel om uw Voicemail te beluisteren naar +31612001233" "Welkom, bel om uw Voicemail te beluisteren naar +31612001233"
" (PrePay: *100*1233#). Voicemail ontvangen is altijd gratis." " (PrePay: *100*1233#). Voicemail ontvangen is altijd gratis."
" Voor gebruik van mobiel interne", /* text */ " Voor gebruik van mobiel interne", /* text */
NULL, 0, 0); NULL, 0);
} }
static void static void
@@ -413,7 +406,7 @@ test_pdu_multipart (void)
TRUE, /* multipart! */ TRUE, /* multipart! */
"This is a very long test designed to exercise multi part capability. It should " "This is a very long test designed to exercise multi part capability. It should "
"show up as one message, not as two, as the underlying encoding represents ", /* text */ "show up as one message, not as two, as the underlying encoding represents ", /* text */
NULL, 0, 0); NULL, 0);
common_test_part_from_hexpdu ( common_test_part_from_hexpdu (
hexpdu2, hexpdu2,
@@ -422,7 +415,7 @@ test_pdu_multipart (void)
"120425195651-04", /* timestamp */ "120425195651-04", /* timestamp */
TRUE, /* multipart! */ TRUE, /* multipart! */
"that the parts are related to one another. ", /* text */ "that the parts are related to one another. ", /* text */
NULL, 0, 0); NULL, 0);
} }
static void static void
@@ -439,7 +432,7 @@ test_pdu_stored_by_us (void)
NULL, /* timestamp */ NULL, /* timestamp */
FALSE, /* multipart! */ FALSE, /* multipart! */
"你好你好你好你好你好你好你好你好你", /* text */ "你好你好你好你好你好你好你好你好你", /* text */
NULL, 0, 0); NULL, 0);
} }
static void static void
@@ -455,7 +448,7 @@ test_pdu_not_stored (void)
"120911074036+02", /* timestamp */ "120911074036+02", /* timestamp */
FALSE, /* multipart! */ FALSE, /* multipart! */
NULL, /* text */ NULL, /* text */
NULL, 0, 0); NULL, 0);
} }
/********************* SMS ADDRESS ENCODER TESTS *********************/ /********************* SMS ADDRESS ENCODER TESTS *********************/