aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/imap/camel-imap-folder.c
diff options
context:
space:
mode:
Diffstat (limited to 'camel/providers/imap/camel-imap-folder.c')
-rw-r--r--camel/providers/imap/camel-imap-folder.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 48ae72d032..954e103c8f 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -398,34 +398,44 @@ imap_expunge (CamelFolder *folder, CamelException *ex)
}
/* else we have a message id? */
- if (*word >= '0' && *word <= '9') {
+ if (*word >= '0' && *word <= '9' && !strncmp ("EXPUNGE", imap_next_word (word), 7)) {
int id;
id = atoi (word);
-
- d(fprintf (stderr, "Expunging message %d from the summary\n", id + i));
- if (id < imap_folder->summary->len) {
+ d(fprintf (stderr, "Expunging message %d from the summary (i = %d)\n", id + i, i));
+
+ if (id <= imap_folder->summary->len) {
CamelMessageInfo *info;
- info = (CamelMessageInfo *) imap_folder->summary->pdata[id];
+ info = (CamelMessageInfo *) imap_folder->summary->pdata[id - 1];
/* remove from the lookup table and summary */
g_hash_table_remove (imap_folder->summary_hash, info->uid);
- g_ptr_array_remove_index (imap_folder->summary, id);
+ g_ptr_array_remove_index (imap_folder->summary, id - 1);
+
+ /* free the info data */
+ g_free (info->subject);
+ g_free (info->from);
+ g_free (info->to);
+ g_free (info->cc);
+ g_free (info->uid);
+ g_free (info->message_id);
+ header_references_list_clear (&info->references);
+ g_free (info);
+ info = NULL;
} else {
/* Hopefully this should never happen */
d(fprintf (stderr, "imap expunge-error: message %d is out of range\n", id));
}
- } else {
- /* Huh? */
- d(fprintf (stderr, "imap expunge-warning: unexpected token: '%s'\n", word));
}
} else {
break;
}
for ( ; *node && *node != '\n'; node++);
+ if (*node)
+ node++;
}
g_free (result);
@@ -836,20 +846,20 @@ imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
status != CAMEL_IMAP_FAIL && result ? result :
"Unknown error");
g_free (result);
- return camel_mime_message_new ();
+ return NULL;
}
for (p = result; *p && *p != '{' && *p != '\n'; p++);
if (*p != '{') {
g_free (result);
- return camel_mime_message_new ();
+ return NULL;
}
part_len = atoi (p + 1);
for ( ; *p && *p != '\n'; p++);
if (*p != '\n') {
g_free (result);
- return camel_mime_message_new ();
+ return NULL;
}
/* calculate the new part-length */
@@ -884,22 +894,23 @@ imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex)
"Unknown error");
g_free (result);
g_free (header);
- return camel_mime_message_new ();
+ return NULL;
}
for (p = result; *p && *p != '{' && *p != '\n'; p++);
if (*p != '{') {
- g_free (result);
- g_free (header);
- return camel_mime_message_new ();
- }
-
- part_len = atoi (p + 1);
- for ( ; *p && *p != '\n'; p++);
- if (*p != '\n') {
- g_free (result);
- g_free (header);
- return camel_mime_message_new ();
+ /* this is a hack for when the part length isn't in {}'s */
+ part_len = 1;
+ for ( ; *p && *p != '\n'; p++);
+ p++;
+ } else {
+ part_len = atoi (p + 1);
+ for ( ; *p && *p != '\n'; p++);
+ if (*p != '\n') {
+ g_free (result);
+ g_free (header);
+ return NULL;
+ }
}
/* calculate the new part-length */