messaging: part index may be repeated in different storages
This commit is contained in:
@@ -211,11 +211,17 @@ cmp_sms_by_concat_reference (MMSms *sms,
|
|||||||
return (GPOINTER_TO_UINT (user_data) - mm_sms_get_multipart_reference (sms));
|
return (GPOINTER_TO_UINT (user_data) - mm_sms_get_multipart_reference (sms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
guint part_index;
|
||||||
|
MMSmsStorage storage;
|
||||||
|
} PartIndexAndStorage;
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
cmp_sms_by_part_index (MMSms *sms,
|
cmp_sms_by_part_index_and_storage (MMSms *sms,
|
||||||
gpointer user_data)
|
PartIndexAndStorage *ctx)
|
||||||
{
|
{
|
||||||
return !mm_sms_has_part_index (sms, GPOINTER_TO_UINT (user_data));
|
return !(mm_sms_get_storage (sms) == ctx->storage &&
|
||||||
|
mm_sms_has_part_index (sms, ctx->part_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -295,10 +301,15 @@ mm_sms_list_take_part (MMSmsList *self,
|
|||||||
MMSmsStorage storage,
|
MMSmsStorage storage,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
PartIndexAndStorage ctx;
|
||||||
|
|
||||||
|
ctx.part_index = mm_sms_part_get_index (part);
|
||||||
|
ctx.storage = storage;
|
||||||
|
|
||||||
/* Ensure we don't have already taken a part with the same index */
|
/* Ensure we don't have already taken a part with the same index */
|
||||||
if (g_list_find_custom (self->priv->list,
|
if (g_list_find_custom (self->priv->list,
|
||||||
GUINT_TO_POINTER (mm_sms_part_get_index (part)),
|
&ctx,
|
||||||
(GCompareFunc)cmp_sms_by_part_index)) {
|
(GCompareFunc)cmp_sms_by_part_index_and_storage)) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
MM_CORE_ERROR,
|
MM_CORE_ERROR,
|
||||||
MM_CORE_ERROR_FAILED,
|
MM_CORE_ERROR_FAILED,
|
||||||
|
11
src/mm-sms.c
11
src/mm-sms.c
@@ -347,6 +347,17 @@ mm_sms_get_path (MMSms *self)
|
|||||||
return self->priv->path;
|
return self->priv->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMSmsStorage
|
||||||
|
mm_sms_get_storage (MMSms *self)
|
||||||
|
{
|
||||||
|
MMSmsStorage storage = MM_SMS_STORAGE_UNKNOWN;
|
||||||
|
|
||||||
|
g_object_get (self,
|
||||||
|
"storage", &storage,
|
||||||
|
NULL);
|
||||||
|
return storage;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mm_sms_is_multipart (MMSms *self)
|
mm_sms_is_multipart (MMSms *self)
|
||||||
{
|
{
|
||||||
|
@@ -106,6 +106,7 @@ gboolean mm_sms_multipart_take_part (MMSms *self,
|
|||||||
void mm_sms_export (MMSms *self);
|
void mm_sms_export (MMSms *self);
|
||||||
void mm_sms_unexport (MMSms *self);
|
void mm_sms_unexport (MMSms *self);
|
||||||
const gchar *mm_sms_get_path (MMSms *self);
|
const gchar *mm_sms_get_path (MMSms *self);
|
||||||
|
MMSmsStorage mm_sms_get_storage (MMSms *self);
|
||||||
|
|
||||||
gboolean mm_sms_has_part_index (MMSms *self,
|
gboolean mm_sms_has_part_index (MMSms *self,
|
||||||
guint index);
|
guint index);
|
||||||
|
Reference in New Issue
Block a user