diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-09-13 12:00:37 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-09-14 07:05:26 +0200 |
commit | e212f6b6edcd2b5678372bd0b05c70209c516f05 (patch) | |
tree | f28a596d95ed494ca667a351b78f42c50b60ab3a /src/mm-sms-part.c | |
parent | 2da9474d0c0e22044d7ab636e3336cab1a75bc22 (diff) |
sms: create SMS parts only when storing or sending
When a user creates an SMS object, we will expose all its properties in DBus
properly, but we will not create the internal list of SMS parts.
The list of SMS parts will be created when the SMS is stored or sent, whatever
comes first. When the message is sent and it was previously stored, the list of
parts is not re-created.
If the message requires multiple parts, the multipart reference is computed as
follows:
* If the SMS was not stored and is being sent, we just use a random number.
* If the SMS is being stored, we will use a multipart reference which is not
being used already in another SMS to the same destination.
Diffstat (limited to 'src/mm-sms-part.c')
-rw-r--r-- | src/mm-sms-part.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/mm-sms-part.c b/src/mm-sms-part.c index c779f235..7cac9b88 100644 --- a/src/mm-sms-part.c +++ b/src/mm-sms-part.c @@ -1255,7 +1255,8 @@ mm_sms_part_util_split_text (const gchar *text, } GByteArray ** -mm_sms_part_util_split_data (const GByteArray *data) +mm_sms_part_util_split_data (const guint8 *data, + gsize data_len) { GByteArray **out; @@ -1267,25 +1268,25 @@ mm_sms_part_util_split_data (const GByteArray *data) * bytes each, as we need place for the UDH header. */ - if (data->len <= 140) { + if (data_len <= 140) { out = g_new0 (GByteArray *, 2); - out[0] = g_byte_array_append (g_byte_array_sized_new (data->len), - data->data, - data->len); + out[0] = g_byte_array_append (g_byte_array_sized_new (data_len), + data, + data_len); } else { guint n_chunks; guint i; guint j; - n_chunks = data->len / 134; - if (data->len % 134 != 0) + n_chunks = data_len / 134; + if (data_len % 134 != 0) n_chunks ++; out = g_new0 (GByteArray *, n_chunks + 1); for (i = 0, j = 0; i < n_chunks; i++, j+= 134) { out[i] = g_byte_array_append (g_byte_array_sized_new (134), - &data->data[j], - MIN (data->len - j, 134)); + &data[j], + MIN (data_len - j, 134)); } } |