200
204
g_free (unpacked);
201
205
} else if (encoding == MM_SMS_ENCODING_UCS2)
202
206
utf8 = g_convert ((char *) text, len, "UTF8", "UCS-2BE", NULL, NULL, NULL);
203
else if (encoding == MM_SMS_ENCODING_8BIT)
204
utf8 = g_strndup ((const char *)text, len);
207
else if (encoding == MM_SMS_ENCODING_8BIT) {
208
/* DBus requires UTF-8 strings, so we have some sanitizing to do */
211
utf8 = g_malloc0 (4*len+1); /* Worst case: Every byte becomes "\xFF" */
213
for (i = 0 ; i < len ; i++) {
214
if (isascii (text[i]) && text[i] != '\0')
217
sprintf(p, "\\x%02x", text[i]);
206
224
utf8 = g_strdup ("");
344
properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
338
347
smsc_addr = sms_decode_address (&pdu[1], 2 * (pdu[0] - 1));
348
g_hash_table_insert (properties, "smsc",
349
simple_string_value (smsc_addr));
339
352
sender_addr = sms_decode_address (&pdu[msg_start_offset + 2],
340
353
pdu[msg_start_offset + 1]);
354
g_hash_table_insert (properties, "number",
355
simple_string_value (sender_addr));
356
g_free (sender_addr);
341
358
sc_timestamp = sms_decode_timestamp (&pdu[tp_dcs_offset + 1]);
359
g_hash_table_insert (properties, "timestamp",
360
simple_string_value (sc_timestamp));
361
g_free (sc_timestamp);
343
364
if (pdu[msg_start_offset] & SMS_TP_UDHI) {
365
int udhl, end, offset;
366
udhl = pdu[user_data_offset] + 1;
367
end = user_data_offset + udhl;
369
for (offset = user_data_offset + 1; offset < end;) {
370
guint8 ie_id, ie_len;
372
ie_id = pdu[offset++];
373
ie_len = pdu[offset++];
378
* Ignore the IE if one of the following is true:
379
* - it claims to be part 0 of M
380
* - it claims to be part N of M, N > M
382
if (pdu[offset + 2] == 0 ||
383
pdu[offset + 2] > pdu[offset + 1])
386
g_hash_table_insert (properties, "concat-reference",
387
simple_uint_value (pdu[offset]));
388
g_hash_table_insert (properties, "concat-max",
389
simple_uint_value (pdu[offset + 1]));
390
g_hash_table_insert (properties, "concat-sequence",
391
simple_uint_value (pdu[offset + 2]));
394
/* Concatenated short message, 16-bit reference */
395
if (pdu[offset + 3] == 0 ||
396
pdu[offset + 3] > pdu[offset + 2])
399
g_hash_table_insert (properties, "concat-reference",
403
g_hash_table_insert (properties, "concat-max",
404
simple_uint_value (pdu[offset + 2]));
405
g_hash_table_insert (properties, "concat-sequence",
406
simple_uint_value (pdu[offset + 3]));
345
* Skip over the user data headers to prevent it from being
414
* Move past the user data headers to prevent it from being
346
415
* decoded into garbage text.
349
udhl = pdu[user_data_offset] + 1;
350
417
user_data_offset += udhl;
351
418
if (user_data_encoding == MM_SMS_ENCODING_GSM7) {
362
429
msg_text = sms_decode_text (&pdu[user_data_offset], user_data_len,
363
430
user_data_encoding, bit_offset);
365
properties = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
367
g_hash_table_insert (properties, "number",
368
simple_string_value (sender_addr));
369
431
g_hash_table_insert (properties, "text",
370
432
simple_string_value (msg_text));
371
g_hash_table_insert (properties, "smsc",
372
simple_string_value (smsc_addr));
373
g_hash_table_insert (properties, "timestamp",
374
simple_string_value (sc_timestamp));
375
435
if (pdu[tp_dcs_offset] & SMS_DCS_CLASS_VALID)
376
436
g_hash_table_insert (properties, "class",
377
437
simple_uint_value (pdu[tp_dcs_offset] &
378
438
SMS_DCS_CLASS_MASK));
379
g_hash_table_insert (properties, "completed", simple_boolean_value (TRUE));
382
g_free (sender_addr);
383
g_free (sc_timestamp);
388
441
return properties;