diff options
Diffstat (limited to 'camel/providers/imap4')
-rw-r--r-- | camel/providers/imap4/camel-imap4-folder.c | 31 | ||||
-rw-r--r-- | camel/providers/imap4/camel-imap4-search.c | 2 | ||||
-rw-r--r-- | camel/providers/imap4/camel-imap4-store.c | 28 | ||||
-rw-r--r-- | camel/providers/imap4/camel-imap4-summary.c | 71 | ||||
-rw-r--r-- | camel/providers/imap4/camel-imap4-summary.h | 2 |
5 files changed, 63 insertions, 71 deletions
diff --git a/camel/providers/imap4/camel-imap4-folder.c b/camel/providers/imap4/camel-imap4-folder.c index 7ee109a5b4..921d7aa2ed 100644 --- a/camel/providers/imap4/camel-imap4-folder.c +++ b/camel/providers/imap4/camel-imap4-folder.c @@ -459,7 +459,7 @@ imap4_sync_changes (CamelFolder *folder, GPtrArray *sync, CamelException *ex) for (j = 0; j < sync->len; j++) { iinfo = (CamelIMAP4MessageInfo *) (info = sync->pdata[j]); - camel_imap4_flags_diff (&diff, iinfo->server_flags, info->flags); + camel_imap4_flags_diff (&diff, iinfo->server_flags, iinfo->info.flags); if (diff.changed & imap4_flags[i].flag) { if (diff.bits & imap4_flags[i].flag) { g_ptr_array_add (on_set, info); @@ -492,8 +492,8 @@ imap4_sync_changes (CamelFolder *folder, GPtrArray *sync, CamelException *ex) for (i = 0; i < sync->len; i++) { iinfo = (CamelIMAP4MessageInfo *) (info = sync->pdata[i]); - info->flags &= ~CAMEL_MESSAGE_FOLDER_FLAGGED; - iinfo->server_flags = info->flags & folder->permanent_flags; + iinfo->info.flags &= ~CAMEL_MESSAGE_FOLDER_FLAGGED; + iinfo->server_flags = iinfo->info.flags & folder->permanent_flags; } return 0; @@ -522,17 +522,17 @@ imap4_sync (CamelFolder *folder, gboolean expunge, CamelException *ex) max = camel_folder_summary_count (folder->summary); for (i = 0; i < max; i++) { iinfo = (CamelIMAP4MessageInfo *) (info = camel_folder_summary_index (folder->summary, i)); - if (info->flags & CAMEL_MESSAGE_FOLDER_FLAGGED) { - camel_imap4_flags_diff (&diff, iinfo->server_flags, info->flags); + if (iinfo->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED) { + camel_imap4_flags_diff (&diff, iinfo->server_flags, iinfo->info.flags); diff.changed &= folder->permanent_flags; /* weed out flag changes that we can't sync to the server */ if (!diff.changed) - camel_folder_summary_info_free (folder->summary, info); + camel_message_info_free(info); else g_ptr_array_add (sync, info); } else { - camel_folder_summary_info_free (folder->summary, info); + camel_message_info_free(info); } } @@ -540,7 +540,7 @@ imap4_sync (CamelFolder *folder, gboolean expunge, CamelException *ex) retval = imap4_sync_changes (folder, sync, ex); for (i = 0; i < sync->len; i++) - camel_folder_summary_info_free (folder->summary, sync->pdata[i]); + camel_message_info_free(sync->pdata[i]); g_ptr_array_free (sync, TRUE); @@ -695,7 +695,7 @@ untagged_fetch (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, if ((info = camel_folder_summary_index (summary, index - 1))) { iinfo = (CamelIMAP4MessageInfo *) info; - info->flags = camel_imap4_merge_flags (iinfo->server_flags, info->flags, flags); + iinfo->info.flags = camel_imap4_merge_flags (iinfo->server_flags, iinfo->info.flags, flags); iinfo->server_flags = flags; changes = camel_folder_change_info_new (); @@ -703,7 +703,7 @@ untagged_fetch (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_object_trigger_event (engine->folder, "folder_changed", changes); camel_folder_change_info_free (changes); - camel_folder_summary_info_free (summary, info); + camel_message_info_free(info); } } else { /* wtf? */ @@ -856,6 +856,7 @@ imap4_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelIMAP4Engine *engine = ((CamelIMAP4Store *) folder->parent_store)->engine; CamelSession *session = ((CamelService *) folder->parent_store)->session; CamelIMAP4Summary *summary = (CamelIMAP4Summary *) folder->summary; + const CamelIMAP4MessageInfo *iinfo = (const CamelIMAP4MessageInfo *)info; CamelIMAP4RespCode *resp; CamelIMAP4Command *ic; CamelFolderInfo *fi; @@ -873,11 +874,11 @@ imap4_append_message (CamelFolder *folder, CamelMimeMessage *message, CAMEL_SERVICE_LOCK (folder->parent_store, connect_lock); /* construct the option flags list */ - if (info->flags & folder->permanent_flags) { + if (iinfo->info.flags & folder->permanent_flags) { p = g_stpcpy (flags, " ("); for (i = 0; i < G_N_ELEMENTS (imap4_flags); i++) { - if ((info->flags & imap4_flags[i].flag) & folder->permanent_flags) { + if ((iinfo->info.flags & imap4_flags[i].flag) & folder->permanent_flags) { p = g_stpcpy (p, imap4_flags[i].name); *p++ = ' '; } @@ -890,13 +891,13 @@ imap4_append_message (CamelFolder *folder, CamelMimeMessage *message, } /* construct the optional date_time string */ - if (info->date_received != (time_t) -1) { + if (iinfo->info.date_received != (time_t) -1) { int tzone; #ifdef HAVE_LOCALTIME_R localtime_r (&info->date_received, &tm); #else - memcpy (&tm, localtime (&info->date_received), sizeof (tm)); + memcpy (&tm, localtime (&iinfo->info.date_received), sizeof (tm)); #endif #if defined (HAVE_TM_GMTOFF) @@ -1118,7 +1119,7 @@ imap4_transfer_messages_to (CamelFolder *src, GPtrArray *uids, CamelFolder *dest done: for (i = 0; i < infos->len; i++) - camel_folder_summary_info_free (src->summary, infos->pdata[i]); + camel_message_info_free(infos->pdata[i]); g_ptr_array_free (infos, TRUE); CAMEL_SERVICE_LOCK (src->parent_store, connect_lock); diff --git a/camel/providers/imap4/camel-imap4-search.c b/camel/providers/imap4/camel-imap4-search.c index f7cb5acb99..7102e2fa0f 100644 --- a/camel/providers/imap4/camel-imap4-search.c +++ b/camel/providers/imap4/camel-imap4-search.c @@ -123,7 +123,7 @@ untagged_search (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, sprintf (uid, "%u", token->v.number); if ((info = camel_folder_summary_uid (summary, uid))) { g_ptr_array_add (matches, (char *) camel_message_info_uid (info)); - camel_folder_summary_info_free (summary, info); + camel_message_info_free(info); } } diff --git a/camel/providers/imap4/camel-imap4-store.c b/camel/providers/imap4/camel-imap4-store.c index 4d2395b049..c8832b54a6 100644 --- a/camel/providers/imap4/camel-imap4-store.c +++ b/camel/providers/imap4/camel-imap4-store.c @@ -1112,28 +1112,12 @@ imap4_build_folder_info (CamelStore *store, const char *top, guint32 flags, GPtr fi->flags = list->flags; fi->unread = -1; fi->total = -1; - - if (!(flags & CAMEL_STORE_FOLDER_INFO_FAST)) { - if (folder && !strcmp (folder->full_name, fi->full_name)) { - /* can't STATUS this folder since it is SELECTED, besides - it would be wasteful */ - CamelMessageInfo *info; - int index; - - fi->total = camel_folder_summary_count (folder->summary); - - fi->unread = 0; - for (index = 0; index < fi->total; index++) { - if (!(info = camel_folder_summary_index (folder->summary, index))) - continue; - - if ((info->flags & CAMEL_MESSAGE_SEEN) == 0) - fi->unread++; - - camel_folder_summary_info_free (folder->summary, info); - } - } else { - imap4_status (store, fi); - } + + /* SELECTED folder, just get it from the folder */ + if (folder && !strcmp (folder->full_name, fi->full_name)) { + camel_object_get(folder, NULL, CAMEL_FOLDER_TOTAL, &fi->total, CAMEL_FOLDER_UNREAD, &fi->unread, 0); + } else if (!(flags & CAMEL_STORE_FOLDER_INFO_FAST)) { + imap4_status (store, fi); } g_free (list->name); diff --git a/camel/providers/imap4/camel-imap4-summary.c b/camel/providers/imap4/camel-imap4-summary.c index ef3e7e3bbc..ce31d87181 100644 --- a/camel/providers/imap4/camel-imap4-summary.c +++ b/camel/providers/imap4/camel-imap4-summary.c @@ -36,6 +36,7 @@ #include <e-util/md5-utils.h> #include <camel/camel-file-utils.h> +#include <camel/camel-string-utils.h> #include <camel/camel-i18n.h> #include "camel-imap4-store.h" @@ -57,7 +58,7 @@ static void camel_imap4_summary_finalize (CamelObject *object); static int imap4_header_load (CamelFolderSummary *summary, FILE *fin); static int imap4_header_save (CamelFolderSummary *summary, FILE *fout); -static CamelMessageInfo *imap4_message_info_new (CamelFolderSummary *summary, struct _camel_header_raw *header); +static CamelMessageInfo *imap4_message_info_new_from_header (CamelFolderSummary *summary, struct _camel_header_raw *header); static CamelMessageInfo *imap4_message_info_load (CamelFolderSummary *summary, FILE *fin); static int imap4_message_info_save (CamelFolderSummary *summary, FILE *fout, CamelMessageInfo *info); @@ -94,7 +95,7 @@ camel_imap4_summary_class_init (CamelIMAP4SummaryClass *klass) summary_class->summary_header_load = imap4_header_load; summary_class->summary_header_save = imap4_header_save; - summary_class->message_info_new = imap4_message_info_new; + summary_class->message_info_new_from_header = imap4_message_info_new_from_header; summary_class->message_info_load = imap4_message_info_load; summary_class->message_info_save = imap4_message_info_save; } @@ -430,7 +431,8 @@ decode_envelope (CamelIMAP4Engine *engine, CamelMessageInfo *info, camel_imap4_t { unsigned char md5sum[16]; char *nstring; - + CamelIMAP4MessageInfo *iinfo = (CamelIMAP4MessageInfo *)info; + if (camel_imap4_engine_next_token (engine, token, ex) == -1) return -1; @@ -439,18 +441,20 @@ decode_envelope (CamelIMAP4Engine *engine, CamelMessageInfo *info, camel_imap4_t return -1; } - if (envelope_decode_date (engine, &info->date_sent, ex) == -1) + if (envelope_decode_date (engine, &iinfo->info.date_sent, ex) == -1) goto exception; /* subject */ if (envelope_decode_nstring (engine, &nstring, TRUE, ex) == -1) goto exception; - camel_message_info_set_subject (info, nstring); + iinfo->info.subject = camel_pstring_strdup(nstring); + g_free(nstring); /* from */ if (envelope_decode_addresses (engine, &nstring, ex) == -1) goto exception; - camel_message_info_set_from (info, nstring); + iinfo->info.from = camel_pstring_strdup(nstring); + g_free(nstring); /* sender */ if (envelope_decode_addresses (engine, &nstring, ex) == -1) @@ -465,12 +469,14 @@ decode_envelope (CamelIMAP4Engine *engine, CamelMessageInfo *info, camel_imap4_t /* to */ if (envelope_decode_addresses (engine, &nstring, ex) == -1) goto exception; - camel_message_info_set_to (info, nstring); + iinfo->info.to = camel_pstring_strdup(nstring); + g_free(nstring); /* cc */ if (envelope_decode_addresses (engine, &nstring, ex) == -1) goto exception; - camel_message_info_set_cc (info, nstring); + iinfo->info.cc = camel_pstring_strdup(nstring); + g_free(nstring); /* bcc */ if (envelope_decode_addresses (engine, &nstring, ex) == -1) @@ -482,7 +488,7 @@ decode_envelope (CamelIMAP4Engine *engine, CamelMessageInfo *info, camel_imap4_t goto exception; if (nstring != NULL) { - info->references = decode_references (nstring); + iinfo->info.references = decode_references (nstring); g_free (nstring); } @@ -492,7 +498,7 @@ decode_envelope (CamelIMAP4Engine *engine, CamelMessageInfo *info, camel_imap4_t if (nstring != NULL) { md5_get_digest (nstring, strlen (nstring), md5sum); - memcpy (info->message_id.id.hash, md5sum, sizeof (info->message_id.id.hash)); + memcpy (iinfo->info.message_id.id.hash, md5sum, sizeof (iinfo->info.message_id.id.hash)); g_free (nstring); } @@ -666,7 +672,7 @@ imap4_fetch_all_free (struct imap4_fetch_all_t *fetch) if (!(envelope = fetch->added->pdata[i])) continue; - camel_folder_summary_info_free (fetch->summary, envelope->info); + camel_message_info_free(envelope->info); g_free (envelope); } @@ -714,13 +720,13 @@ imap4_fetch_all_add (struct imap4_fetch_all_t *fetch) if (envelope->changed != IMAP4_FETCH_ALL) { d(fprintf (stderr, "Hmmm, IMAP4 server didn't give us everything for message %d\n", i + 1)); - camel_folder_summary_info_free (fetch->summary, envelope->info); + camel_message_info_free(envelope->info); g_free (envelope); continue; } if ((info = camel_folder_summary_uid (fetch->summary, camel_message_info_uid (envelope->info)))) { - camel_folder_summary_info_free (fetch->summary, envelope->info); + camel_message_info_free(envelope->info); g_free (envelope); continue; } @@ -769,14 +775,14 @@ imap4_fetch_all_update (struct imap4_fetch_all_t *fetch) new_iinfo = (CamelIMAP4MessageInfo *) envelope->info; iinfo = (CamelIMAP4MessageInfo *) info; - flags = info->flags; - info->flags = camel_imap4_merge_flags (iinfo->server_flags, info->flags, new_iinfo->server_flags); + flags = iinfo->info.flags; + iinfo->info.flags = camel_imap4_merge_flags (iinfo->server_flags, iinfo->info.flags, new_iinfo->server_flags); iinfo->server_flags = new_iinfo->server_flags; - if (info->flags != flags) + if (iinfo->info.flags != flags) camel_folder_change_info_change_uid (changes, camel_message_info_uid (info)); } - camel_folder_summary_info_free (fetch->summary, info); + camel_message_info_free(info); } for (i = 0; i < fetch->added->len; i++) { @@ -788,13 +794,13 @@ imap4_fetch_all_update (struct imap4_fetch_all_t *fetch) info = envelope->info; if (!first && camel_message_info_uid (info)) { if ((info = camel_folder_summary_uid (fetch->summary, camel_message_info_uid (info)))) { - camel_folder_summary_info_free (fetch->summary, info); + camel_message_info_free(info); } else { first = i + fetch->first; } } - camel_folder_summary_info_free (fetch->summary, envelope->info); + camel_message_info_free(envelope->info); g_free (envelope); } @@ -835,7 +841,7 @@ untagged_fetch_all (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 ind g_ptr_array_set_size (added, index - fetch->first + 1); if (!(envelope = added->pdata[index - fetch->first])) { - iinfo = (CamelIMAP4MessageInfo *) (info = camel_folder_summary_info_new (summary)); + iinfo = (CamelIMAP4MessageInfo *) (info = camel_message_info_new (summary)); envelope = g_new (struct imap4_envelope_t, 1); added->pdata[index - fetch->first] = envelope; envelope->info = info; @@ -876,9 +882,9 @@ untagged_fetch_all (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 ind g_warning ("Hmmm, server is sending us ENVELOPE data for a message we didn't ask for (message %u)\n", index); - tmp = camel_folder_summary_info_new (summary); + tmp = camel_message_info_new (summary); rv = decode_envelope (engine, tmp, token, ex); - camel_folder_summary_info_free (summary, tmp); + camel_message_info_free(tmp); if (rv == -1) goto exception; @@ -889,7 +895,7 @@ untagged_fetch_all (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 ind if (camel_imap4_parse_flags_list (engine, &server_flags, ex) == -1) return -1; - info->flags = camel_imap4_merge_flags (iinfo->server_flags, info->flags, server_flags); + iinfo->info.flags = camel_imap4_merge_flags (iinfo->server_flags, iinfo->info.flags, server_flags); iinfo->server_flags = server_flags; changed |= IMAP4_FETCH_FLAGS; @@ -899,11 +905,11 @@ untagged_fetch_all (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 ind switch (token->token) { case CAMEL_IMAP4_TOKEN_NIL: - info->date_received = (time_t) -1; + iinfo->info.date_received = (time_t) -1; break; case CAMEL_IMAP4_TOKEN_ATOM: case CAMEL_IMAP4_TOKEN_QSTRING: - info->date_received = decode_internaldate (token->v.qstring); + iinfo->info.date_received = decode_internaldate (token->v.qstring); break; default: goto unexpected; @@ -917,7 +923,7 @@ untagged_fetch_all (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 ind if (token->token != CAMEL_IMAP4_TOKEN_NUMBER) goto unexpected; - info->size = token->v.number; + iinfo->info.size = token->v.number; changed |= IMAP4_FETCH_RFC822SIZE; } else if (!strcmp (token->v.atom, "UID")) { @@ -935,7 +941,8 @@ untagged_fetch_all (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 ind g_assert_not_reached (); } } else { - camel_message_info_set_uid (info, g_strdup (uid)); + g_free(info->uid); + info->uid = g_strdup (uid); g_hash_table_insert (fetch->uid_hash, (void *) camel_message_info_uid (info), envelope); changed |= IMAP4_FETCH_UID; } @@ -1071,11 +1078,11 @@ imap4_build_summary (CamelFolderSummary *summary, guint32 first, guint32 last) #endif static CamelMessageInfo * -imap4_message_info_new (CamelFolderSummary *summary, struct _camel_header_raw *header) +imap4_message_info_new_from_header (CamelFolderSummary *summary, struct _camel_header_raw *header) { CamelMessageInfo *info; - info = CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->message_info_new (summary, header); + info = CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->message_info_new_from_header (summary, header); ((CamelIMAP4MessageInfo *) info)->server_flags = 0; @@ -1100,7 +1107,7 @@ imap4_message_info_load (CamelFolderSummary *summary, FILE *fin) exception: - camel_folder_summary_info_free (summary, info); + camel_message_info_free(info); return NULL; } @@ -1178,7 +1185,7 @@ camel_imap4_summary_set_uidvalidity (CamelFolderSummary *summary, guint32 uidval continue; camel_folder_change_info_remove_uid (changes, camel_message_info_uid (info)); - camel_folder_summary_info_free (summary, info); + camel_message_info_free(info); } camel_folder_summary_clear (summary); @@ -1215,7 +1222,7 @@ camel_imap4_summary_expunge (CamelFolderSummary *summary, int seqid) changes = camel_folder_change_info_new (); camel_folder_change_info_remove_uid (changes, uid); - camel_folder_summary_info_free (summary, info); + camel_message_info_free(info); camel_folder_summary_remove_index (summary, seqid); camel_object_trigger_event (imap4_summary->folder, "folder_changed", changes); diff --git a/camel/providers/imap4/camel-imap4-summary.h b/camel/providers/imap4/camel-imap4-summary.h index 7de05a5cc6..9af962115b 100644 --- a/camel/providers/imap4/camel-imap4-summary.h +++ b/camel/providers/imap4/camel-imap4-summary.h @@ -45,7 +45,7 @@ typedef struct _CamelIMAP4SummaryClass CamelIMAP4SummaryClass; #define CAMEL_IMAP4_MESSAGE_RECENT (1 << 17) struct _CamelIMAP4MessageInfo { - CamelMessageInfo parent_info; + CamelMessageInfoBase info; guint32 server_flags; }; |