mm-base-sms: cmp by reference & number
Messages from different senders can have the same reference. Stale messages from the same sender can also conflict. Consider the number of the sender and also the max parts when assigning parts to a base sms. Ref 3gpp specification section 9.2.3.24.1 Fixes #757 Signed-off-by: Kyle Evans <kvans32@gmail.com>
This commit is contained in:
committed by
Aleksander Morgado
parent
d763b94677
commit
ae88eeed49
@@ -738,6 +738,12 @@ mm_base_sms_is_multipart (MMBaseSms *self)
|
||||
return self->priv->is_multipart;
|
||||
}
|
||||
|
||||
guint
|
||||
mm_base_sms_get_max_parts (MMBaseSms *self)
|
||||
{
|
||||
return self->priv->max_parts;
|
||||
}
|
||||
|
||||
guint
|
||||
mm_base_sms_get_multipart_reference (MMBaseSms *self)
|
||||
{
|
||||
@@ -1858,6 +1864,7 @@ mm_base_sms_multipart_new (MMBaseModem *modem,
|
||||
MM_BASE_SMS_IS_MULTIPART, TRUE,
|
||||
MM_BASE_SMS_MAX_PARTS, max_parts,
|
||||
MM_BASE_SMS_MULTIPART_REFERENCE, reference,
|
||||
"number", mm_sms_part_get_number (first_part),
|
||||
"state", state,
|
||||
"storage", storage,
|
||||
"validity", g_variant_new ("(uv)",
|
||||
|
||||
@@ -121,6 +121,7 @@ gboolean mm_base_sms_has_part_index (MMBaseSms *self,
|
||||
GList *mm_base_sms_get_parts (MMBaseSms *self);
|
||||
|
||||
gboolean mm_base_sms_is_multipart (MMBaseSms *self);
|
||||
guint mm_base_sms_get_max_parts (MMBaseSms *self);
|
||||
guint mm_base_sms_get_multipart_reference (MMBaseSms *self);
|
||||
gboolean mm_base_sms_multipart_is_complete (MMBaseSms *self);
|
||||
gboolean mm_base_sms_multipart_is_assembled (MMBaseSms *self);
|
||||
|
||||
+15
-7
@@ -219,14 +219,23 @@ mm_sms_list_add_sms (MMSmsList *self,
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static guint
|
||||
cmp_sms_by_concat_reference (MMBaseSms *sms,
|
||||
gpointer user_data)
|
||||
static gint
|
||||
cmp_sms_by_number_reference (MMBaseSms *sms,
|
||||
MMSmsPart *part)
|
||||
{
|
||||
if (!mm_base_sms_is_multipart (sms))
|
||||
return -1;
|
||||
|
||||
return (GPOINTER_TO_UINT (user_data) - mm_base_sms_get_multipart_reference (sms));
|
||||
if (mm_base_sms_get_multipart_reference (sms) != mm_sms_part_get_concat_reference (part))
|
||||
return -1;
|
||||
|
||||
if (g_strcmp0 (mm_gdbus_sms_get_number (MM_GDBUS_SMS (sms)), mm_sms_part_get_number (part)))
|
||||
return -1;
|
||||
|
||||
if (mm_base_sms_get_max_parts (sms) != mm_sms_part_get_concat_max (part))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
@@ -278,9 +287,8 @@ take_multipart (MMSmsList *self,
|
||||
guint concat_reference;
|
||||
|
||||
concat_reference = mm_sms_part_get_concat_reference (part);
|
||||
l = g_list_find_custom (self->priv->list,
|
||||
GUINT_TO_POINTER (concat_reference),
|
||||
(GCompareFunc)cmp_sms_by_concat_reference);
|
||||
l = g_list_find_custom (self->priv->list, part,
|
||||
(GCompareFunc)cmp_sms_by_number_reference);
|
||||
if (l) {
|
||||
/* Try to take the part */
|
||||
mm_obj_dbg (self, "found existing multipart SMS object with reference '%u': adding new part", concat_reference);
|
||||
|
||||
Reference in New Issue
Block a user