diff options
author | Not Zed <NotZed@Ximian.com> | 2004-11-12 13:53:12 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-11-12 13:53:12 +0800 |
commit | 8e212824134c1740d05fb36799f78716c5059801 (patch) | |
tree | 47fc692dba176af4fa0ccfa45d31739886162c12 /camel/providers | |
parent | 55bead18b69fd4e7ad2b09700867add2ca7e9838 (diff) | |
download | gsoc2013-evolution-8e212824134c1740d05fb36799f78716c5059801.tar gsoc2013-evolution-8e212824134c1740d05fb36799f78716c5059801.tar.gz gsoc2013-evolution-8e212824134c1740d05fb36799f78716c5059801.tar.bz2 gsoc2013-evolution-8e212824134c1740d05fb36799f78716c5059801.tar.lz gsoc2013-evolution-8e212824134c1740d05fb36799f78716c5059801.tar.xz gsoc2013-evolution-8e212824134c1740d05fb36799f78716c5059801.tar.zst gsoc2013-evolution-8e212824134c1740d05fb36799f78716c5059801.zip |
** Merge in notzed-messageinfo-branch, fix some minor conflicts.
2004-11-12 Not Zed <NotZed@Ximian.com>
** Merge in notzed-messageinfo-branch, fix some minor conflicts.
svn path=/trunk/; revision=27898
Diffstat (limited to 'camel/providers')
41 files changed, 496 insertions, 507 deletions
diff --git a/camel/providers/Makefile.am b/camel/providers/Makefile.am index 22ea481954..4ae70e9926 100644 --- a/camel/providers/Makefile.am +++ b/camel/providers/Makefile.am @@ -14,3 +14,4 @@ endif SUBDIRS = pop3 sendmail smtp imap $(NNTP_DIR) local $(IMAPP_DIR) $(IMAP4_DIR) groupwise + diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index 6d6908e265..189844dfec 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -237,7 +237,7 @@ camel_imap_folder_new (CamelStore *parent, const char *folder_name, camel_folder_construct (folder, parent, folder_name, short_name); summary_file = g_strdup_printf ("%s/summary", folder_dir); - folder->summary = camel_imap_summary_new (summary_file); + folder->summary = camel_imap_summary_new (folder, summary_file); g_free (summary_file); if (!folder->summary) { camel_object_unref (CAMEL_OBJECT (folder)); @@ -387,7 +387,7 @@ camel_imap_folder_selected (CamelFolder *folder, CamelImapResponse *response, info = camel_folder_summary_index (folder->summary, count - 1); val = strtoul (camel_message_info_uid (info), NULL, 10); - camel_folder_summary_info_free (folder->summary, info); + camel_message_info_free(info); if (uid == 0 || uid != val) imap_folder->need_rescan = TRUE; } @@ -575,7 +575,7 @@ imap_rescan (CamelFolder *folder, int exists, CamelException *ex) ok = camel_imap_command_start (store, folder, ex, "UID FETCH 1:%s (FLAGS)", camel_message_info_uid (info)); - camel_folder_summary_info_free (folder->summary, info); + camel_message_info_free(info); if (!ok) { camel_operation_end (NULL); return; @@ -632,7 +632,7 @@ imap_rescan (CamelFolder *folder, int exists, CamelException *ex) iinfo = (CamelImapMessageInfo *)info; if (strcmp (camel_message_info_uid (info), new[i].uid) != 0) { - camel_folder_summary_info_free(folder->summary, info); + camel_message_info_free(info); seq = i + 1; g_array_append_val (removed, seq); i--; @@ -646,8 +646,8 @@ imap_rescan (CamelFolder *folder, int exists, CamelException *ex) server_set = new[i].flags & ~iinfo->server_flags; server_cleared = iinfo->server_flags & ~new[i].flags; - - info->flags = (info->flags | server_set) & ~server_cleared; + + iinfo->info.flags = (iinfo->info.flags | server_set) & ~server_cleared; iinfo->server_flags = new[i].flags; if (changes == NULL) @@ -655,7 +655,7 @@ imap_rescan (CamelFolder *folder, int exists, CamelException *ex) camel_folder_change_info_change_uid(changes, new[i].uid); } - camel_folder_summary_info_free (folder->summary, info); + camel_message_info_free(info); g_free (new[i].uid); } @@ -697,7 +697,7 @@ static GPtrArray * get_matching (CamelFolder *folder, guint32 flags, guint32 mask, char **set) { GPtrArray *matches; - CamelMessageInfo *info; + CamelImapMessageInfo *info; int i, max, range; GString *gset; @@ -706,11 +706,11 @@ get_matching (CamelFolder *folder, guint32 flags, guint32 mask, char **set) max = camel_folder_summary_count (folder->summary); range = -1; for (i = 0; i < max && !UID_SET_FULL (gset->len, UID_SET_LIMIT); i++) { - info = camel_folder_summary_index (folder->summary, i); + info = (CamelImapMessageInfo *)camel_folder_summary_index (folder->summary, i); if (!info) continue; - if ((info->flags & mask) != flags) { - camel_folder_summary_info_free (folder->summary, info); + if ((info->info.flags & mask) != flags) { + camel_message_info_free((CamelMessageInfo *)info); if (range != -1) { if (range != i - 1) { info = matches->pdata[matches->len - 1]; @@ -758,7 +758,7 @@ imap_sync_online (CamelFolder *folder, CamelException *ex) { CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store); CamelImapResponse *response = NULL; - CamelMessageInfo *info; + CamelImapMessageInfo *info; CamelException local_ex; GPtrArray *matches; char *set, *flaglist; @@ -779,33 +779,33 @@ imap_sync_online (CamelFolder *folder, CamelException *ex) */ max = camel_folder_summary_count (folder->summary); for (i = 0; i < max; i++) { - if (!(info = camel_folder_summary_index (folder->summary, i))) + if (!(info = (CamelImapMessageInfo *)camel_folder_summary_index (folder->summary, i))) continue; - if (!(info->flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) { - camel_folder_summary_info_free (folder->summary, info); + if (!(info->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) { + camel_message_info_free((CamelMessageInfo *)info); continue; } /* Note: Cyrus is broken and will not accept an empty-set of flags so... if this is true then we want to unset the previously set flags.*/ - unset = !(info->flags & folder->permanent_flags); + unset = !(info->info.flags & folder->permanent_flags); /* Note: get_matching() uses UID_SET_LIMIT to limit the size of the uid-set string. We don't have to loop here to flush all the matching uids because they will be scooped up later by our parent loop (I think?). -- Jeff */ - matches = get_matching (folder, info->flags & (folder->permanent_flags | CAMEL_MESSAGE_FOLDER_FLAGGED), + matches = get_matching (folder, info->info.flags & (folder->permanent_flags | CAMEL_MESSAGE_FOLDER_FLAGGED), folder->permanent_flags | CAMEL_MESSAGE_FOLDER_FLAGGED, &set); - camel_folder_summary_info_free (folder->summary, info); + camel_message_info_free(info); if (matches == NULL) continue; /* FIXME: since we don't know the previously set flags, if unset is TRUE then just unset all the flags? */ - flaglist = imap_create_flag_list (unset ? folder->permanent_flags : info->flags & folder->permanent_flags); + flaglist = imap_create_flag_list (unset ? folder->permanent_flags : info->info.flags & folder->permanent_flags); /* Note: to `unset' flags, use -FLAGS.SILENT (<flag list>) */ response = camel_imap_command (store, folder, &local_ex, @@ -820,16 +820,15 @@ imap_sync_online (CamelFolder *folder, CamelException *ex) if (!camel_exception_is_set (&local_ex)) { for (j = 0; j < matches->len; j++) { info = matches->pdata[j]; - info->flags &= ~CAMEL_MESSAGE_FOLDER_FLAGGED; - ((CamelImapMessageInfo *) info)->server_flags = - info->flags & CAMEL_IMAP_SERVER_FLAGS; + info->info.flags &= ~CAMEL_MESSAGE_FOLDER_FLAGGED; + ((CamelImapMessageInfo *) info)->server_flags = info->info.flags & CAMEL_IMAP_SERVER_FLAGS; } camel_folder_summary_touch (folder->summary); } for (j = 0; j < matches->len; j++) { info = matches->pdata[j]; - camel_folder_summary_info_free (folder->summary, info); + camel_message_info_free(&info->info); } g_ptr_array_free (matches, TRUE); @@ -1167,10 +1166,11 @@ do_append (CamelFolder *folder, CamelMimeMessage *message, CamelStreamFilter *streamfilter; GByteArray *ba; char *flagstr, *end; - - /* create flag string param */ - if (info && info->flags) - flagstr = imap_create_flag_list (info->flags); + guint32 flags; + + flags = camel_message_info_flags(info); + if (flags) + flagstr = imap_create_flag_list (flags); else flagstr = NULL; @@ -1357,7 +1357,7 @@ imap_transfer_offline (CamelFolder *source, GPtrArray *uids, camel_imap_summary_add_offline_uncached (dest->summary, destuid, mi); camel_imap_message_cache_copy (sc, uid, dc, destuid, ex); - camel_folder_summary_info_free (source->summary, mi); + camel_message_info_free(mi); camel_folder_change_info_add_uid (changes, destuid); if (transferred_uids) @@ -1968,12 +1968,12 @@ imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex) { CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder); CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store); - CamelMessageInfo *mi; + CamelImapMessageInfo *mi; CamelMimeMessage *msg = NULL; CamelStream *stream = NULL; int retry; - mi = camel_folder_summary_uid (folder->summary, uid); + mi = (CamelImapMessageInfo *)camel_folder_summary_uid (folder->summary, uid); if (mi == NULL) { camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, _("Cannot get message: %s\n %s"), uid, _("No such message")); @@ -2001,11 +2001,11 @@ imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex) /* If the message is small or only 1 part, or server doesn't do 4v1 (properly) fetch it in one piece. */ if (store->server_level < IMAP_LEVEL_IMAP4REV1 || store->braindamaged - || mi->size < IMAP_SMALL_BODY_SIZE - || (!content_info_incomplete(mi->content) && !mi->content->childs)) { + || mi->info.size < IMAP_SMALL_BODY_SIZE + || (!content_info_incomplete(mi->info.content) && !mi->info.content->childs)) { msg = get_message_simple (imap_folder, uid, NULL, ex); } else { - if (content_info_incomplete (mi->content)) { + if (content_info_incomplete (mi->info.content)) { /* For larger messages, fetch the structure and build a message * with offline parts. (We check mi->content->type rather than * mi->content because camel_folder_summary_info_new always creates @@ -2038,7 +2038,7 @@ imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex) } if (body) - imap_parse_body ((const char **) &body, folder, mi->content); + imap_parse_body ((const char **) &body, folder, mi->info.content); if (fetch_data) g_datalist_clear (&fetch_data); @@ -2049,7 +2049,7 @@ imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex) if (camel_debug_start("imap:folder")) { printf("Folder get message '%s' folder info ->\n", uid); - camel_message_info_dump(mi); + camel_message_info_dump((CamelMessageInfo *)mi); camel_debug_end(); } @@ -2059,10 +2059,10 @@ imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex) * fall back to fetching the entire thing and * let the mailer's "bad MIME" code handle it. */ - if (content_info_incomplete (mi->content)) + if (content_info_incomplete (mi->info.content)) msg = get_message_simple (imap_folder, uid, NULL, ex); else - msg = get_message (imap_folder, uid, mi->content, ex); + msg = get_message (imap_folder, uid, mi->info.content, ex); } } while (msg == NULL && retry < 2 @@ -2072,7 +2072,7 @@ done: /* FIXME, this shouldn't be done this way. */ if (msg) camel_medium_set_header (CAMEL_MEDIUM (msg), "X-Evolution-Source", store->base_url); fail: - camel_folder_summary_info_free (folder->summary, mi); + camel_message_info_free(&mi->info); return msg; } @@ -2201,7 +2201,7 @@ add_message_from_data (CamelFolder *folder, GPtrArray *messages, { CamelMimeMessage *msg; CamelStream *stream; - CamelMessageInfo *mi; + CamelImapMessageInfo *mi; const char *idate; int seq; @@ -2221,14 +2221,14 @@ add_message_from_data (CamelFolder *folder, GPtrArray *messages, return; } - mi = camel_folder_summary_info_new_from_message (folder->summary, msg); + mi = (CamelImapMessageInfo *)camel_folder_summary_info_new_from_message (folder->summary, msg); camel_object_unref (CAMEL_OBJECT (msg)); if ((idate = g_datalist_get_data (&data, "INTERNALDATE"))) - mi->date_received = decode_internaldate (idate); + mi->info.date_received = decode_internaldate (idate); - if (mi->date_received == -1) - mi->date_received = mi->date_sent; + if (mi->info.date_received == -1) + mi->info.date_received = mi->info.date_sent; messages->pdata[seq - first] = mi; } @@ -2253,7 +2253,7 @@ imap_update_summary (CamelFolder *folder, int exists, int i, seq, first, size, got; CamelImapResponseType type; const char *header_spec; - CamelMessageInfo *mi, *info; + CamelImapMessageInfo *mi, *info; CamelStream *stream; char *uid, *resp; GData *data; @@ -2272,9 +2272,9 @@ imap_update_summary (CamelFolder *folder, int exists, seq = camel_folder_summary_count (folder->summary); first = seq + 1; if (seq > 0) { - mi = camel_folder_summary_index (folder->summary, seq - 1); + mi = (CamelImapMessageInfo *)camel_folder_summary_index (folder->summary, seq - 1); uidval = strtoul(camel_message_info_uid (mi), NULL, 10); - camel_folder_summary_info_free (folder->summary, mi); + camel_message_info_free(&mi->info); } else uidval = 0; @@ -2433,24 +2433,23 @@ imap_update_summary (CamelFolder *folder, int exists, continue; } - mi = camel_message_info_new (); - camel_message_info_dup_to (pmi, mi); + mi = (CamelImapMessageInfo *)camel_message_info_clone(pmi); } uid = g_datalist_get_data (&data, "UID"); if (uid) - camel_message_info_set_uid (mi, g_strdup (uid)); + mi->info.uid = g_strdup (uid); flags = GPOINTER_TO_INT (g_datalist_get_data (&data, "FLAGS")); if (flags) { ((CamelImapMessageInfo *)mi)->server_flags = flags; /* "or" them in with the existing flags that may * have been set by summary_info_new_from_message. */ - mi->flags |= flags; + mi->info.flags |= flags; } size = GPOINTER_TO_INT (g_datalist_get_data (&data, "RFC822.SIZE")); if (size) - mi->size = size; + mi->info.size = size; g_datalist_clear (&data); } @@ -2474,7 +2473,7 @@ imap_update_summary (CamelFolder *folder, int exists, i + first); break; } - info = camel_folder_summary_uid(folder->summary, uid); + info = (CamelImapMessageInfo *)camel_folder_summary_uid(folder->summary, uid); if (info) { for (seq = 0; seq < camel_folder_summary_count (folder->summary); seq++) { if (folder->summary->messages->pdata[seq] == info) @@ -2486,20 +2485,20 @@ imap_update_summary (CamelFolder *folder, int exists, _("Unexpected server response: Identical UIDs provided for messages %d and %d"), seq + 1, i + first); - camel_folder_summary_info_free(folder->summary, info); + camel_message_info_free(&info->info); break; } - camel_folder_summary_add (folder->summary, mi); + camel_folder_summary_add (folder->summary, (CamelMessageInfo *)mi); camel_folder_change_info_add_uid (changes, camel_message_info_uid (mi)); - if ((mi->flags & CAMEL_IMAP_MESSAGE_RECENT)) + if ((mi->info.flags & CAMEL_IMAP_MESSAGE_RECENT)) camel_folder_change_info_recent_uid(changes, camel_message_info_uid (mi)); } for ( ; i < messages->len; i++) { if ((mi = messages->pdata[i])) - camel_folder_summary_info_free(folder->summary, mi); + camel_message_info_free(&mi->info); } g_ptr_array_free (messages, TRUE); @@ -2517,7 +2516,7 @@ imap_update_summary (CamelFolder *folder, int exists, if (messages) { for (i = 0; i < messages->len; i++) { if (messages->pdata[i]) - camel_folder_summary_info_free (folder->summary, messages->pdata[i]); + camel_message_info_free(messages->pdata[i]); } g_ptr_array_free (messages, TRUE); } @@ -2553,7 +2552,7 @@ camel_imap_folder_changed (CamelFolder *folder, int exists, camel_imap_message_cache_remove (imap_folder->cache, camel_message_info_uid (info)); CAMEL_IMAP_FOLDER_UNLOCK (imap_folder, cache_lock); camel_folder_summary_remove (folder->summary, info); - camel_folder_summary_info_free(folder->summary, info); + camel_message_info_free(info); } } diff --git a/camel/providers/imap/camel-imap-message-cache.c b/camel/providers/imap/camel-imap-message-cache.c index 17fa9ca5c8..3099602613 100644 --- a/camel/providers/imap/camel-imap-message-cache.c +++ b/camel/providers/imap/camel-imap-message-cache.c @@ -176,7 +176,7 @@ camel_imap_message_cache_new (const char *path, CamelFolderSummary *summary, info = camel_folder_summary_uid (summary, uid); if (info) { - camel_folder_summary_info_free (summary, info); + camel_message_info_free(info); cache_put (cache, uid, d->d_name, NULL); } else g_ptr_array_add (deletes, g_strdup_printf ("%s/%s", cache->path, d->d_name)); diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index b22743e72a..a2ecb71b91 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -1047,7 +1047,7 @@ imap_forget_folder (CamelImapStore *imap_store, const char *folder_name, CamelEx } summary_file = g_strdup_printf ("%s/summary", folder_dir); - summary = camel_imap_summary_new (summary_file); + summary = camel_imap_summary_new (NULL, summary_file); if (!summary) { g_free (summary_file); g_free (folder_dir); @@ -1597,14 +1597,17 @@ imap_disconnect_online (CamelService *service, gboolean clean, CamelException *e static gboolean imap_summary_is_dirty (CamelFolderSummary *summary) { - CamelMessageInfo *info; + CamelImapMessageInfo *info; int max, i; - + int found = FALSE; + max = camel_folder_summary_count (summary); - for (i = 0; i < max; i++) { - info = camel_folder_summary_index (summary, i); - if (info && (info->flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) - return TRUE; + for (i = 0; i < max && !found; i++) { + info = (CamelImapMessageInfo *)camel_folder_summary_index (summary, i); + if (info) { + found = info->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED; + camel_message_info_free(info); + } } return FALSE; diff --git a/camel/providers/imap/camel-imap-summary.c b/camel/providers/imap/camel-imap-summary.c index 6251f8b85b..3e1d024ab4 100644 --- a/camel/providers/imap/camel-imap-summary.c +++ b/camel/providers/imap/camel-imap-summary.c @@ -71,6 +71,21 @@ camel_imap_summary_get_type (void) return type; } +static CamelMessageInfo * +imap_message_info_clone(CamelFolderSummary *s, const CamelMessageInfo *mi) +{ + CamelImapMessageInfo *to; + const CamelImapMessageInfo *from = (const CamelImapMessageInfo *)mi; + + to = (CamelImapMessageInfo *)camel_imap_summary_parent->message_info_clone(s, mi); + to->server_flags = from->server_flags; + + /* FIXME: parent clone should do this */ + to->info.content = camel_folder_summary_content_info_new(s); + + return (CamelMessageInfo *)to; +} + static void camel_imap_summary_class_init (CamelImapSummaryClass *klass) { @@ -78,6 +93,8 @@ camel_imap_summary_class_init (CamelImapSummaryClass *klass) camel_imap_summary_parent = CAMEL_FOLDER_SUMMARY_CLASS (camel_type_get_global_classfuncs (camel_folder_summary_get_type())); + cfs_class->message_info_clone = imap_message_info_clone; + cfs_class->summary_header_load = summary_header_load; cfs_class->summary_header_save = summary_header_save; cfs_class->message_info_load = message_info_load; @@ -98,6 +115,7 @@ camel_imap_summary_init (CamelImapSummary *obj) /** * camel_imap_summary_new: + * @folder: Parent folder. * @filename: the file to store the summary in. * * This will create a new CamelImapSummary object and read in the @@ -106,10 +124,11 @@ camel_imap_summary_init (CamelImapSummary *obj) * Return value: A new CamelImapSummary object. **/ CamelFolderSummary * -camel_imap_summary_new (const char *filename) +camel_imap_summary_new (struct _CamelFolder *folder, const char *filename) { - CamelFolderSummary *summary = CAMEL_FOLDER_SUMMARY ( - camel_object_new (camel_imap_summary_get_type ())); + CamelFolderSummary *summary = CAMEL_FOLDER_SUMMARY (camel_object_new (camel_imap_summary_get_type ())); + + summary->folder = folder; camel_folder_summary_set_build_content (summary, TRUE); camel_folder_summary_set_filename (summary, filename); @@ -177,7 +196,7 @@ message_info_load (CamelFolderSummary *s, FILE *in) return info; error: - camel_folder_summary_info_free (s, info); + camel_message_info_free(info); return NULL; } @@ -218,52 +237,40 @@ camel_imap_summary_add_offline (CamelFolderSummary *summary, const char *uid, CamelMimeMessage *message, const CamelMessageInfo *info) { - CamelMessageInfo *mi; - CamelFlag *flag; - CamelTag *tag; + CamelImapMessageInfo *mi; + const CamelFlag *flag; + const CamelTag *tag; /* Create summary entry */ - mi = camel_folder_summary_info_new_from_message (summary, message); + mi = (CamelImapMessageInfo *)camel_folder_summary_info_new_from_message (summary, message); /* Copy flags 'n' tags */ - mi->flags = info->flags; - flag = info->user_flags; + mi->info.flags = camel_message_info_flags(info); + + flag = camel_message_info_user_flags(info); while (flag) { - camel_flag_set (&mi->user_flags, flag->name, TRUE); + camel_message_info_set_user_flag((CamelMessageInfo *)mi, flag->name, TRUE); flag = flag->next; } - tag = info->user_tags; + tag = camel_message_info_user_tags(info); while (tag) { - camel_tag_set (&mi->user_tags, tag->name, tag->value); + camel_message_info_set_user_tag((CamelMessageInfo *)mi, tag->name, tag->value); tag = tag->next; } - mi->size = info->size; + mi->info.size = camel_message_info_size(info); + mi->info.uid = g_strdup (uid); - /* Set uid and add to summary */ - camel_message_info_set_uid (mi, g_strdup (uid)); - camel_folder_summary_add (summary, mi); + camel_folder_summary_add (summary, (CamelMessageInfo *)mi); } void camel_imap_summary_add_offline_uncached (CamelFolderSummary *summary, const char *uid, const CamelMessageInfo *info) { - CamelMessageInfo *mi; - CamelMessageContentInfo *ci; - - /* Create summary entry */ - mi = camel_folder_summary_info_new (summary); - ci = camel_folder_summary_content_info_new (summary); - - camel_message_info_dup_to (info, mi); - mi->content = ci; - - /* copy our private fields */ - ((CamelImapMessageInfo *)mi)->server_flags = - ((CamelImapMessageInfo *)info)->server_flags; + CamelImapMessageInfo *mi; - /* Set uid and add to summary */ - camel_message_info_set_uid (mi, g_strdup (uid)); - camel_folder_summary_add (summary, mi); + mi = camel_message_info_clone(info); + mi->info.uid = g_strdup(uid); + camel_folder_summary_add (summary, (CamelMessageInfo *)mi); } diff --git a/camel/providers/imap/camel-imap-summary.h b/camel/providers/imap/camel-imap-summary.h index e7402aac84..04fb9b829a 100644 --- a/camel/providers/imap/camel-imap-summary.h +++ b/camel/providers/imap/camel-imap-summary.h @@ -47,7 +47,7 @@ typedef struct _CamelImapMessageContentInfo { } CamelImapMessageContentInfo; typedef struct _CamelImapMessageInfo { - CamelMessageInfo info; + CamelMessageInfoBase info; guint32 server_flags; } CamelImapMessageInfo; @@ -65,7 +65,7 @@ struct _CamelImapSummaryClass { }; CamelType camel_imap_summary_get_type (void); -CamelFolderSummary *camel_imap_summary_new (const char *filename); +CamelFolderSummary *camel_imap_summary_new (struct _CamelFolder *folder, const char *filename); void camel_imap_summary_add_offline (CamelFolderSummary *summary, const char *uid, diff --git a/camel/providers/imap/camel-imap-utils.c b/camel/providers/imap/camel-imap-utils.c index ca94c180ec..a557f7fcae 100644 --- a/camel/providers/imap/camel-imap-utils.c +++ b/camel/providers/imap/camel-imap-utils.c @@ -1061,7 +1061,7 @@ get_summary_uid_numeric (CamelFolderSummary *summary, int index) info = camel_folder_summary_index (summary, index); uid = strtoul (camel_message_info_uid (info), NULL, 10); - camel_folder_summary_info_free (summary, info); + camel_message_info_free(info); return uid; } 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; }; diff --git a/camel/providers/imapp/ChangeLog b/camel/providers/imapp/ChangeLog index 9c70d8d7b9..63b46ae57a 100644 --- a/camel/providers/imapp/ChangeLog +++ b/camel/providers/imapp/ChangeLog @@ -1,3 +1,7 @@ +2004-11-11 Not Zed <NotZed@Ximian.com> + + * updates for camel folder summary api changes. + 2004-09-30 Not Zed <NotZed@Ximian.com> * camel-imapp-engine.c: make the build again, warnings, doesn't diff --git a/camel/providers/imapp/camel-imapp-driver.c b/camel/providers/imapp/camel-imapp-driver.c index aa1f2a273e..c9a9e45042 100644 --- a/camel/providers/imapp/camel-imapp-driver.c +++ b/camel/providers/imapp/camel-imapp-driver.c @@ -332,7 +332,7 @@ imapp_write_flags(CamelIMAPPDriver *id, guint32 orset, gboolean on, CamelFolderS ic = camel_imapp_engine_command_new(id->engine, "STORE", NULL, "UID STORE "); flush = imapp_uidset_add(&ss, ic, camel_message_info_uid(info)); } - camel_folder_summary_info_free(summary, (CamelMessageInfo *)info); + camel_message_info_free((CamelMessageInfo *)info); } if (i == count-1 && ic != NULL) @@ -391,7 +391,7 @@ camel_imapp_driver_sync(CamelIMAPPDriver *id, gboolean expunge, CamelIMAPPFolder off_orset |= ( flags ^ sflags ) & ~flags; on_orset |= (flags ^ sflags) & flags; } - camel_folder_summary_info_free(summary, (CamelMessageInfo *)info); + camel_message_info_free((CamelMessageInfo *)info); } if (on_orset || off_orset) { @@ -407,7 +407,7 @@ camel_imapp_driver_sync(CamelIMAPPDriver *id, gboolean expunge, CamelIMAPPFolder if (info == NULL) continue; info->server_flags = info->info.flags & CAMEL_IMAPP_SERVER_FLAGS; - camel_folder_summary_info_free(summary, (CamelMessageInfo *)info); + camel_message_info_free((CamelMessageInfo *)info); } camel_folder_summary_touch(summary); /* could save summary here, incase of failure? */ @@ -656,7 +656,7 @@ driver_resp_expunge(CamelIMAPPEngine *ie, guint32 id, CamelIMAPPDriver *sdata) if (info) { printf("expunging msg %d\n", id); camel_folder_summary_remove(summary, info); - camel_folder_summary_info_free(summary, info); + camel_message_info_free(info); camel_folder_change_info_remove_uid(sdata->folder->changes, camel_message_info_uid(info)); } else { printf("can not find msg %u from expunge\n", id); @@ -670,7 +670,7 @@ static int driver_resp_fetch(CamelIMAPPEngine *ie, guint32 id, CamelIMAPPDriver *sdata) { struct _fetch_info *finfo = NULL; - CamelMessageInfo *info, *uinfo; + CamelIMAPPMessageInfo *info, *uinfo; unsigned int i; CamelFolderSummary *summary; @@ -684,36 +684,36 @@ driver_resp_fetch(CamelIMAPPEngine *ie, guint32 id, CamelIMAPPDriver *sdata) finfo = imap_parse_fetch(ie->stream); imap_dump_fetch(finfo); - info = camel_folder_summary_index(summary, id-1); + info = (CamelIMAPPMessageInfo *)camel_folder_summary_index(summary, id-1); if (info == NULL) { if (finfo->uid == NULL) { printf("got fetch response for currently unknown message %u\n", id); goto done; } - uinfo = camel_folder_summary_uid(summary, finfo->uid); + uinfo = (CamelIMAPPMessageInfo *)camel_folder_summary_uid(summary, finfo->uid); if (uinfo) { /* we have a problem ... index mismatch */ printf("index mismatch, uid '%s' not at index '%u'\n", finfo->uid, id); - camel_folder_summary_info_free(summary, uinfo); + camel_message_info_free(uinfo); } /* pad out the summary till we have enough indexes */ for (i=camel_folder_summary_count(summary);i<id;i++) { - info = camel_folder_summary_info_new(summary); + info = camel_message_info_new(summary); if (i == id-1) { printf("inserting new info @ %u\n", i); - camel_message_info_set_uid(info, g_strdup(finfo->uid)); + info->info.uid = g_strdup(finfo->uid); } else { char uidtmp[32]; sprintf(uidtmp, "blank-%u", i); - camel_message_info_set_uid(info, g_strdup(uidtmp)); + info->info.uid = g_strdup(uidtmp); printf("inserting empty uid %s\n", uidtmp); } - camel_folder_summary_add(summary, info); + camel_folder_summary_add(summary, (CamelMessageInfo *)info); } - info = camel_folder_summary_index(summary, id-1); + info = (CamelIMAPPMessageInfo *)camel_folder_summary_index(summary, id-1); g_assert(info != NULL); } else { if (finfo->uid) { @@ -723,9 +723,9 @@ driver_resp_fetch(CamelIMAPPEngine *ie, guint32 id, CamelIMAPPDriver *sdata) finfo->uid, id, camel_message_info_uid(info)); camel_folder_change_info_remove_uid(sdata->folder->changes, camel_message_info_uid(info)); - camel_folder_summary_remove(summary, info); - camel_folder_summary_info_free(summary, info); - info = camel_folder_summary_index(summary, id-1); + camel_folder_summary_remove(summary, (CamelMessageInfo *)info); + camel_message_info_free(info); + info = (CamelIMAPPMessageInfo *)camel_folder_summary_index(summary, id-1); } } else { printf("got info for unknown message %u\n", id); @@ -735,19 +735,19 @@ driver_resp_fetch(CamelIMAPPEngine *ie, guint32 id, CamelIMAPPDriver *sdata) if (info) { if (finfo->got & FETCH_MINFO) { /* if we only use ENVELOPE? */ - camel_message_info_set_subject(info, g_strdup(camel_message_info_subject(finfo->minfo))); - camel_message_info_set_from(info, g_strdup(camel_message_info_from(finfo->minfo))); - camel_message_info_set_to(info, g_strdup(camel_message_info_to(finfo->minfo))); - camel_message_info_set_cc(info, g_strdup(camel_message_info_cc(finfo->minfo))); - info->date_sent = finfo->minfo->date_sent; + info->info.subject = g_strdup(camel_message_info_subject(finfo->minfo)); + info->info.from = g_strdup(camel_message_info_from(finfo->minfo)); + info->info.to = g_strdup(camel_message_info_to(finfo->minfo)); + info->info.cc = g_strdup(camel_message_info_cc(finfo->minfo)); + info->info.date_sent = camel_message_info_date_sent(finfo->minfo); camel_folder_change_info_add_uid(sdata->folder->changes, camel_message_info_uid(info)); printf("adding change info uid '%s'\n", camel_message_info_uid(info)); } if (finfo->got & FETCH_FLAGS) { - if ((info->flags & CAMEL_IMAPP_SERVER_FLAGS) != (finfo->flags & CAMEL_IMAPP_SERVER_FLAGS)) { + if ((info->info.flags & CAMEL_IMAPP_SERVER_FLAGS) != (camel_message_info_flags(finfo) & CAMEL_IMAPP_SERVER_FLAGS)) { camel_folder_change_info_change_uid(sdata->folder->changes, camel_message_info_uid(info)); - info->flags = (info->flags & ~(CAMEL_IMAPP_SERVER_FLAGS)) | (finfo->flags & CAMEL_IMAPP_SERVER_FLAGS); + info->info.flags = (info->info.flags & ~(CAMEL_IMAPP_SERVER_FLAGS)) | (camel_message_info_flags(finfo) & CAMEL_IMAPP_SERVER_FLAGS); camel_folder_summary_touch(summary); } ((CamelIMAPPMessageInfo *)info)->server_flags = finfo->flags & CAMEL_IMAPP_SERVER_FLAGS; @@ -770,7 +770,7 @@ driver_resp_fetch(CamelIMAPPEngine *ie, guint32 id, CamelIMAPPDriver *sdata) } } - camel_folder_summary_info_free(summary, info); + camel_message_info_free(info); } else { printf("dont know what to do with message\n"); } diff --git a/camel/providers/imapp/camel-imapp-folder.c b/camel/providers/imapp/camel-imapp-folder.c index aed7534afe..e85048d92c 100644 --- a/camel/providers/imapp/camel-imapp-folder.c +++ b/camel/providers/imapp/camel-imapp-folder.c @@ -68,7 +68,6 @@ imap_folder_class_init (CamelIMAPPFolderClass *camel_imapp_folder_class) camel_folder_class->sync = imap_sync; camel_folder_class->get_message = imap_get_message; - /*camel_folder_class->set_message_flags = imap_set_message_flags;*/ } static void diff --git a/camel/providers/imapp/camel-imapp-store.c b/camel/providers/imapp/camel-imapp-store.c index 23b6d3ca32..60d2816096 100644 --- a/camel/providers/imapp/camel-imapp-store.c +++ b/camel/providers/imapp/camel-imapp-store.c @@ -810,7 +810,7 @@ static int store_resp_fetch(CamelIMAPPEngine *ie, guint32 id, void *data) if (strcmp(finfo->uid, camel_message_info_uid(info)) != 0) { printf("summary at index %d has uid %s expected %s\n", id, camel_message_info_uid(info), finfo->uid); /* uid mismatch??? try do it based on uid instead? try to reorder? i dont know? */ - camel_folder_summary_info_free(((CamelFolder *)istore->selected)->summary, info); + camel_message_info_free(info); info = camel_folder_summary_uid(((CamelFolder *)istore->selected)->summary, finfo->uid); } } @@ -859,7 +859,7 @@ static int store_resp_fetch(CamelIMAPPEngine *ie, guint32 id, void *data) CamelMimeParser *mp; if (pending == NULL) - camel_folder_summary_info_free(((CamelFolder *)istore->selected)->summary, info); + camel_message_info_free(info); mp = camel_mime_parser_new(); camel_mime_parser_init_with_stream(mp, finfo->header); info = camel_folder_summary_info_new_from_parser(((CamelFolder *)istore->selected)->summary, mp); @@ -872,7 +872,7 @@ static int store_resp_fetch(CamelIMAPPEngine *ie, guint32 id, void *data) /* FIXME: use a dlist */ e_dlist_remove((EDListNode *)pending); g_hash_table_remove(istore->pending_fetch_table, camel_message_info_uid(pending->info)); - camel_folder_summary_info_free(((CamelFolder *)istore->selected)->summary, pending->info); + camel_message_info_free(pending->info); /*e_memchunk_free(istore->pending_fetch_chunks, pending);*/ } } else if (finfo->got & FETCH_FLAGS) { @@ -884,7 +884,7 @@ static int store_resp_fetch(CamelIMAPPEngine *ie, guint32 id, void *data) } } else { if (pending == NULL) - camel_folder_summary_info_free(((CamelFolder *)istore->selected)->summary, info); + camel_message_info_free(info); printf("got unexpected fetch response?\n"); imap_dump_fetch(finfo); } @@ -974,7 +974,7 @@ camel_imapp_store_folder_selected(CamelIMAPPStore *store, CamelIMAPPFolder *fold if (info) { printf("message info [%d] =\n", i); camel_message_info_dump(info); - camel_folder_summary_info_free(((CamelFolder *)istore->selected)->summary, info); + camel_message_info_free(info); } } } CAMEL_CATCH (e) { diff --git a/camel/providers/imapp/camel-imapp-store.h b/camel/providers/imapp/camel-imapp-store.h index 97b7afd1d1..ace5288986 100644 --- a/camel/providers/imapp/camel-imapp-store.h +++ b/camel/providers/imapp/camel-imapp-store.h @@ -44,7 +44,7 @@ struct _pending_fetch { struct _pending_fetch *next; struct _pending_fetch *prev; - CamelMessageInfo *info; + struct _CamelMessageInfo *info; }; typedef struct { diff --git a/camel/providers/imapp/camel-imapp-summary.c b/camel/providers/imapp/camel-imapp-summary.c index 05f0ec55c7..1b5a2c7155 100644 --- a/camel/providers/imapp/camel-imapp-summary.c +++ b/camel/providers/imapp/camel-imapp-summary.c @@ -168,7 +168,7 @@ message_info_load(CamelFolderSummary *s, FILE *in) return info; error: - camel_folder_summary_info_free(s, info); + camel_message_info_free(info); return NULL; } diff --git a/camel/providers/imapp/camel-imapp-summary.h b/camel/providers/imapp/camel-imapp-summary.h index 215ad2465a..1189bac075 100644 --- a/camel/providers/imapp/camel-imapp-summary.h +++ b/camel/providers/imapp/camel-imapp-summary.h @@ -42,7 +42,7 @@ typedef struct _CamelIMAPPSummaryClass CamelIMAPPSummaryClass; typedef struct _CamelIMAPPSummary CamelIMAPPSummary; typedef struct _CamelIMAPPMessageInfo { - CamelMessageInfo info; + CamelMessageInfoBase info; guint32 server_flags; } CamelIMAPPMessageInfo; diff --git a/camel/providers/imapp/camel-imapp-utils.c b/camel/providers/imapp/camel-imapp-utils.c index 19bdb3b036..51e0fe19b0 100644 --- a/camel/providers/imapp/camel-imapp-utils.c +++ b/camel/providers/imapp/camel-imapp-utils.c @@ -6,6 +6,7 @@ #include <camel/camel-folder-summary.h> #include <camel/camel-store.h> #include <camel/camel-utf8.h> +#include <camel/camel-string-utils.h> #include "camel-imapp-folder.h" #include "camel-imapp-stream.h" @@ -585,7 +586,7 @@ imap_parse_envelope(CamelIMAPPStream *is) unsigned char *token; struct _camel_header_address *addr, *addr_from; char *addrstr; - struct _CamelMessageInfo *minfo; + struct _CamelMessageInfoBase *minfo; /* envelope ::= "(" env_date SPACE env_subject SPACE env_from SPACE env_sender SPACE env_reply_to SPACE env_to @@ -594,7 +595,7 @@ imap_parse_envelope(CamelIMAPPStream *is) p(printf("envelope\n")); - minfo = camel_message_info_new(); + minfo = (CamelMessageInfoBase *)camel_message_info_new(NULL); CAMEL_TRY { tok = camel_imapp_stream_token(is, &token, &len); @@ -607,8 +608,7 @@ imap_parse_envelope(CamelIMAPPStream *is) /* env_subject ::= nstring */ tok = camel_imapp_stream_nstring(is, &token); - /* DUH: this free's it!: camel_message_info_set_subject(minfo, token); */ - e_poolv_set(minfo->strings, CAMEL_MESSAGE_INFO_SUBJECT, token, FALSE); + minfo->subject = camel_pstring_strdup(token); /* we merge from/sender into from, append should probably merge more smartly? */ @@ -630,7 +630,8 @@ imap_parse_envelope(CamelIMAPPStream *is) if (addr_from) { addrstr = camel_header_address_list_format(addr_from); - camel_message_info_set_from(minfo, addrstr); + minfo->from = camel_pstring_strdup(addrstr); + g_free(addrstr); camel_header_address_list_clear(&addr_from); } @@ -644,7 +645,8 @@ imap_parse_envelope(CamelIMAPPStream *is) addr = imap_parse_address_list(is); if (addr) { addrstr = camel_header_address_list_format(addr); - camel_message_info_set_to(minfo, addrstr); + minfo->to = camel_pstring_strdup(addrstr); + g_free(addrstr); camel_header_address_list_clear(&addr); } @@ -652,7 +654,8 @@ imap_parse_envelope(CamelIMAPPStream *is) addr = imap_parse_address_list(is); if (addr) { addrstr = camel_header_address_list_format(addr); - camel_message_info_set_cc(minfo, addrstr); + minfo->cc = camel_pstring_strdup(addrstr); + g_free(addrstr); camel_header_address_list_clear(&addr); } @@ -680,7 +683,7 @@ imap_parse_envelope(CamelIMAPPStream *is) camel_exception_throw_ex(ex); } CAMEL_DONE; - return minfo; + return (CamelMessageInfo *)minfo; } struct _CamelMessageContentInfo * @@ -771,7 +774,7 @@ imap_parse_body(CamelIMAPPStream *is) /* what do we do with the envelope?? */ minfo = imap_parse_envelope(is); /* what do we do with the message content info?? */ - minfo->content = imap_parse_body(is); + ((CamelMessageInfoBase *)minfo)->content = imap_parse_body(is); camel_message_info_free(minfo); minfo = NULL; d(printf("Scanned envelope - what do i do with it?\n")); diff --git a/camel/providers/imapp/camel-imapp-utils.h b/camel/providers/imapp/camel-imapp-utils.h index e0974bdc96..2734cd0dc3 100644 --- a/camel/providers/imapp/camel-imapp-utils.h +++ b/camel/providers/imapp/camel-imapp-utils.h @@ -65,8 +65,8 @@ struct _fetch_info { CamelStream *body; /* BODY[.*](<.*>)? */ CamelStream *text; /* RFC822.TEXT */ CamelStream *header; /* RFC822.HEADER */ - CamelMessageInfo *minfo; /* ENVELOPE */ - CamelMessageContentInfo *cinfo; /* BODYSTRUCTURE,BODY */ + struct _CamelMessageInfo *minfo; /* ENVELOPE */ + struct _CamelMessageContentInfo *cinfo; /* BODYSTRUCTURE,BODY */ guint32 size; /* RFC822.SIZE */ guint32 offset; /* start offset of a BODY[]<offset.length> request */ guint32 flags; /* FLAGS */ diff --git a/camel/providers/local/camel-local-summary.c b/camel/providers/local/camel-local-summary.c index e515dd54c6..0a4f96b552 100644 --- a/camel/providers/local/camel-local-summary.c +++ b/camel/providers/local/camel-local-summary.c @@ -46,10 +46,10 @@ static int summary_header_load (CamelFolderSummary *, FILE *); static int summary_header_save (CamelFolderSummary *, FILE *); -static CamelMessageInfo * message_info_new (CamelFolderSummary *, struct _camel_header_raw *); +static CamelMessageInfo * message_info_new_from_header (CamelFolderSummary *, struct _camel_header_raw *); -static int local_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelMessageInfo *mi); -static char *local_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelMessageInfo *mi); +static int local_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelLocalMessageInfo *mi); +static char *local_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelLocalMessageInfo *mi); static int local_summary_load(CamelLocalSummary *cls, int forceindex, CamelException *ex); static int local_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, CamelException *ex); @@ -89,7 +89,7 @@ camel_local_summary_class_init(CamelLocalSummaryClass *klass) sklass->summary_header_load = summary_header_load; sklass->summary_header_save = summary_header_save; - sklass->message_info_new = message_info_new; + sklass->message_info_new_from_header = message_info_new_from_header; klass->load = local_summary_load; klass->check = local_summary_check; @@ -106,7 +106,7 @@ camel_local_summary_init(CamelLocalSummary *obj) struct _CamelFolderSummary *s = (CamelFolderSummary *)obj; /* subclasses need to set the right instance data sizes */ - s->message_info_size = sizeof(CamelMessageInfo); + s->message_info_size = sizeof(CamelLocalMessageInfo); s->content_info_size = sizeof(CamelMessageContentInfo); /* and a unique file version */ @@ -166,13 +166,13 @@ void camel_local_summary_check_force(CamelLocalSummary *cls) } char * -camel_local_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelMessageInfo *info) +camel_local_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelLocalMessageInfo *info) { return ((CamelLocalSummaryClass *)(CAMEL_OBJECT_GET_CLASS(cls)))->encode_x_evolution(cls, info); } int -camel_local_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelMessageInfo *info) +camel_local_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelLocalMessageInfo *info) { return ((CamelLocalSummaryClass *)(CAMEL_OBJECT_GET_CLASS(cls)))->decode_x_evolution(cls, xev, info); } @@ -273,7 +273,7 @@ camel_local_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changei for (i=0;i<camel_folder_summary_count(s);i++) { CamelMessageInfo *info = camel_folder_summary_index(s, i); do_stat_mi(cls, &stats, info); - camel_folder_summary_info_free(s, info); + camel_message_info_free(info); } printf("\nMemory used by summary:\n\n"); @@ -418,43 +418,42 @@ local_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeIn static CamelMessageInfo * local_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *ci, CamelException *ex) { - CamelMessageInfo *mi; + CamelLocalMessageInfo *mi; char *xev; d(printf("Adding message to summary\n")); - mi = camel_folder_summary_add_from_message((CamelFolderSummary *)cls, msg); + mi = (CamelLocalMessageInfo *)camel_folder_summary_add_from_message((CamelFolderSummary *)cls, msg); if (mi) { d(printf("Added, uid = %s\n", mi->uid)); if (info) { - CamelTag *tag = info->user_tags; - CamelFlag *flag = info->user_flags; + const CamelTag *tag = camel_message_info_user_tags(info); + const CamelFlag *flag = camel_message_info_user_flags(info); while (flag) { - camel_flag_set(&mi->user_flags, flag->name, TRUE); + camel_message_info_set_user_flag((CamelMessageInfo *)mi, flag->name, TRUE); flag = flag->next; } while (tag) { - camel_tag_set(&mi->user_tags, tag->name, tag->value); + camel_message_info_set_user_tag((CamelMessageInfo *)mi, tag->name, tag->value); tag = tag->next; } - mi->flags = mi->flags | (info->flags & 0xffff); - if (info->size) - mi->size = info->size; + mi->info.flags |= (camel_message_info_flags(info) & 0xffff); + mi->info.size = camel_message_info_size(info); } /* we need to calculate the size ourselves */ - if (mi->size == 0) { + if (mi->info.size == 0) { CamelStreamNull *sn = (CamelStreamNull *)camel_stream_null_new(); camel_data_wrapper_write_to_stream((CamelDataWrapper *)msg, (CamelStream *)sn); - mi->size = sn->written; + mi->info.size = sn->written; camel_object_unref((CamelObject *)sn); } - mi->flags &= ~(CAMEL_MESSAGE_FOLDER_NOXEV|CAMEL_MESSAGE_FOLDER_FLAGGED); + mi->info.flags &= ~(CAMEL_MESSAGE_FOLDER_NOXEV|CAMEL_MESSAGE_FOLDER_FLAGGED); xev = camel_local_summary_encode_x_evolution(cls, mi); camel_medium_set_header((CamelMedium *)msg, "X-Evolution", xev); g_free(xev); @@ -464,17 +463,17 @@ local_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMess camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, _("Unable to add message to summary: unknown reason")); } - return mi; + return (CamelMessageInfo *)mi; } static char * -local_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelMessageInfo *mi) +local_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelLocalMessageInfo *mi) { GString *out = g_string_new(""); struct _camel_header_param *params = NULL; GString *val = g_string_new(""); - CamelFlag *flag = mi->user_flags; - CamelTag *tag = mi->user_tags; + CamelFlag *flag = mi->info.user_flags; + CamelTag *tag = mi->info.user_tags; char *ret; const char *p, *uidstr; guint32 uid; @@ -485,9 +484,9 @@ local_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelMessageInfo while (*p && isdigit(*p)) p++; if (*p == 0 && sscanf (uidstr, "%u", &uid) == 1) { - g_string_printf (out, "%08x-%04x", uid, mi->flags & 0xffff); + g_string_printf (out, "%08x-%04x", uid, mi->info.flags & 0xffff); } else { - g_string_printf (out, "%s-%04x", uidstr, mi->flags & 0xffff); + g_string_printf (out, "%s-%04x", uidstr, mi->info.flags & 0xffff); } if (flag || tag) { @@ -525,23 +524,22 @@ local_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelMessageInfo } static int -local_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelMessageInfo *mi) +local_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelLocalMessageInfo *mi) { struct _camel_header_param *params, *scan; guint32 uid, flags; char *header; int i; + char uidstr[20]; + + uidstr[0] = 0; /* check for uid/flags */ header = camel_header_token_decode(xev); if (header && strlen(header) == strlen("00000000-0000") && sscanf(header, "%08x-%04x", &uid, &flags) == 2) { - char uidstr[20]; - if (mi) { + if (mi) sprintf(uidstr, "%u", uid); - camel_message_info_set_uid(mi, g_strdup(uidstr)); - mi->flags = flags; - } } else { g_free(header); return -1; @@ -560,9 +558,8 @@ local_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelM if (!strcasecmp(scan->name, "flags")) { char **flagv = g_strsplit(scan->value, ",", 1000); - for (i=0;flagv[i];i++) { - camel_flag_set(&mi->user_flags, flagv[i], TRUE); - } + for (i=0;flagv[i];i++) + camel_message_info_set_user_flag((CamelMessageInfo *)mi, flagv[i], TRUE); g_strfreev(flagv); } else if (!strcasecmp(scan->name, "tags")) { char **tagv = g_strsplit(scan->value, ",", 10000); @@ -572,7 +569,7 @@ local_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelM val = strchr(tagv[i], '='); if (val) { *val++ = 0; - camel_tag_set(&mi->user_tags, tagv[i], val); + camel_message_info_set_user_tag((CamelMessageInfo *)mi, tagv[i], val); val[-1]='='; } } @@ -582,6 +579,10 @@ local_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelM } camel_header_param_list_free(params); } + + mi->info.uid = g_strdup(uidstr); + mi->info.flags = flags; + return 0; } @@ -615,12 +616,12 @@ summary_header_save(CamelFolderSummary *s, FILE *out) } static CamelMessageInfo * -message_info_new(CamelFolderSummary *s, struct _camel_header_raw *h) +message_info_new_from_header(CamelFolderSummary *s, struct _camel_header_raw *h) { - CamelMessageInfo *mi; + CamelLocalMessageInfo *mi; CamelLocalSummary *cls = (CamelLocalSummary *)s; - mi = ((CamelFolderSummaryClass *)camel_local_summary_parent)->message_info_new(s, h); + mi = (CamelLocalMessageInfo *)((CamelFolderSummaryClass *)camel_local_summary_parent)->message_info_new_from_header(s, h); if (mi) { const char *xev; int doindex = FALSE; @@ -628,8 +629,8 @@ message_info_new(CamelFolderSummary *s, struct _camel_header_raw *h) xev = camel_header_raw_find(&h, "X-Evolution", NULL); if (xev==NULL || camel_local_summary_decode_x_evolution(cls, xev, mi) == -1) { /* to indicate it has no xev header */ - mi->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED | CAMEL_MESSAGE_FOLDER_NOXEV; - camel_message_info_set_uid(mi, camel_folder_summary_next_uid_string(s)); + mi->info.flags |= CAMEL_MESSAGE_FOLDER_FLAGGED | CAMEL_MESSAGE_FOLDER_NOXEV; + mi->info.uid = camel_folder_summary_next_uid_string(s); /* shortcut, no need to look it up in the index library */ doindex = TRUE; @@ -647,5 +648,5 @@ message_info_new(CamelFolderSummary *s, struct _camel_header_raw *h) } } - return mi; + return (CamelMessageInfo *)mi; } diff --git a/camel/providers/local/camel-local-summary.h b/camel/providers/local/camel-local-summary.h index 99a520f243..cc7dc3eb2d 100644 --- a/camel/providers/local/camel-local-summary.h +++ b/camel/providers/local/camel-local-summary.h @@ -40,6 +40,12 @@ enum { CAMEL_MESSAGE_FOLDER_NOTSEEN = 1<<19, /* have we seen this in processing this loop? */ }; +typedef struct _CamelLocalMessageInfo CamelLocalMessageInfo; + +struct _CamelLocalMessageInfo { + CamelMessageInfoBase info; +}; + struct _CamelLocalSummary { CamelFolderSummary parent; @@ -60,8 +66,8 @@ struct _CamelLocalSummaryClass { int (*sync)(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex); CamelMessageInfo *(*add)(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *, CamelException *ex); - char *(*encode_x_evolution)(CamelLocalSummary *cls, const CamelMessageInfo *info); - int (*decode_x_evolution)(CamelLocalSummary *cls, const char *xev, CamelMessageInfo *info); + char *(*encode_x_evolution)(CamelLocalSummary *cls, const CamelLocalMessageInfo *info); + int (*decode_x_evolution)(CamelLocalSummary *cls, const char *xev, CamelLocalMessageInfo *info); }; CamelType camel_local_summary_get_type (void); @@ -80,8 +86,8 @@ CamelMessageInfo *camel_local_summary_add(CamelLocalSummary *cls, CamelMimeMessa void camel_local_summary_check_force(CamelLocalSummary *cls); /* generate an X-Evolution header line */ -char *camel_local_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelMessageInfo *info); -int camel_local_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelMessageInfo *info); +char *camel_local_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelLocalMessageInfo *info); +int camel_local_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelLocalMessageInfo *info); /* utility functions - write headers to a file with optional X-Evolution header and/or status header */ int camel_local_summary_write_headers(int fd, struct _camel_header_raw *header, const char *xevline, const char *status, const char *xstatus); diff --git a/camel/providers/local/camel-maildir-folder.c b/camel/providers/local/camel-maildir-folder.c index 669e636527..b74f6e5ace 100644 --- a/camel/providers/local/camel-maildir-folder.c +++ b/camel/providers/local/camel-maildir-folder.c @@ -153,7 +153,7 @@ camel_maildir_folder_new(CamelStore *parent_store, const char *full_name, guint3 static CamelLocalSummary *maildir_create_summary(CamelLocalFolder *lf, const char *path, const char *folder, CamelIndex *index) { - return (CamelLocalSummary *)camel_maildir_summary_new(path, folder, index); + return (CamelLocalSummary *)camel_maildir_summary_new((CamelFolder *)lf, path, folder, index); } static void @@ -251,7 +251,7 @@ static CamelMimeMessage *maildir_get_message(CamelFolder * folder, const gchar * /* what do we do if the message flags (and :info data) changes? filename mismatch - need to recheck I guess */ name = g_strdup_printf("%s/cur/%s", lf->folder_path, camel_maildir_info_filename(mdi)); - camel_folder_summary_info_free(folder->summary, info); + camel_message_info_free(info); if ((message_stream = camel_stream_fs_new_with_name(name, O_RDONLY, 0)) == NULL) { camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c index 9c4097a3cb..eac22d23c6 100644 --- a/camel/providers/local/camel-maildir-store.c +++ b/camel/providers/local/camel-maildir-store.c @@ -283,7 +283,7 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags) root = camel_local_store_get_toplevel_dir((CamelLocalStore *)store); path = g_strdup_printf("%s/%s.ev-summary", root, fi->full_name); folderpath = g_strdup_printf("%s/%s", root, fi->full_name); - s = (CamelFolderSummary *)camel_maildir_summary_new(path, folderpath, NULL); + s = (CamelFolderSummary *)camel_maildir_summary_new(NULL, path, folderpath, NULL); if (camel_folder_summary_header_load(s) != -1) { fi->unread = s->unread_count; fi->total = s->saved_count; diff --git a/camel/providers/local/camel-maildir-summary.c b/camel/providers/local/camel-maildir-summary.c index 8b15c2b991..07183d2cb4 100644 --- a/camel/providers/local/camel-maildir-summary.c +++ b/camel/providers/local/camel-maildir-summary.c @@ -49,7 +49,7 @@ #define CAMEL_MAILDIR_SUMMARY_VERSION (0x2000) static CamelMessageInfo *message_info_load(CamelFolderSummary *s, FILE *in); -static CamelMessageInfo *message_info_new(CamelFolderSummary *, struct _camel_header_raw *); +static CamelMessageInfo *message_info_new_from_header(CamelFolderSummary *, struct _camel_header_raw *); static void message_info_free(CamelFolderSummary *, CamelMessageInfo *mi); static int maildir_summary_load(CamelLocalSummary *cls, int forceindex, CamelException *ex); @@ -58,8 +58,8 @@ static int maildir_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelF static CamelMessageInfo *maildir_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *, CamelException *ex); static char *maildir_summary_next_uid_string(CamelFolderSummary *s); -static int maildir_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelMessageInfo *mi); -static char *maildir_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelMessageInfo *mi); +static int maildir_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelLocalMessageInfo *mi); +static char *maildir_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelLocalMessageInfo *mi); static void camel_maildir_summary_class_init (CamelMaildirSummaryClass *class); static void camel_maildir_summary_init (CamelMaildirSummary *gspaper); @@ -104,7 +104,7 @@ camel_maildir_summary_class_init (CamelMaildirSummaryClass *class) /* override methods */ sklass->message_info_load = message_info_load; - sklass->message_info_new = message_info_new; + sklass->message_info_new_from_header = message_info_new_from_header; sklass->message_info_free = message_info_free; sklass->next_uid_string = maildir_summary_next_uid_string; @@ -151,15 +151,20 @@ camel_maildir_summary_finalise(CamelObject *obj) /** * camel_maildir_summary_new: + * @folder: parent folder. + * @filename: Path to root of this maildir directory (containing new/tmp/cur directories). + * @index: Index if one is reqiured. * * Create a new CamelMaildirSummary object. * * Return value: A new #CamelMaildirSummary object. **/ -CamelMaildirSummary *camel_maildir_summary_new (const char *filename, const char *maildirdir, CamelIndex *index) +CamelMaildirSummary *camel_maildir_summary_new(struct _CamelFolder *folder, const char *filename, const char *maildirdir, CamelIndex *index) { CamelMaildirSummary *o = (CamelMaildirSummary *)camel_object_new(camel_maildir_summary_get_type ()); + ((CamelFolderSummary *)o)->folder = folder; + camel_local_summary_construct((CamelLocalSummary *)o, filename, maildirdir, index); return o; } @@ -178,17 +183,17 @@ static struct { }; /* convert the uid + flags into a unique:info maildir format */ -char *camel_maildir_summary_info_to_name(const CamelMessageInfo *info) +char *camel_maildir_summary_info_to_name(const CamelMaildirMessageInfo *info) { const char *uid; char *p, *buf; int i; - + uid = camel_message_info_uid (info); buf = g_alloca (strlen (uid) + strlen (":2,") + (sizeof (flagbits) / sizeof (flagbits[0])) + 1); p = buf + sprintf (buf, "%s:2,", uid); for (i = 0; i < sizeof (flagbits) / sizeof (flagbits[0]); i++) { - if (info->flags & flagbits[i].flagbit) + if (info->info.info.flags & flagbits[i].flagbit) *p++ = flagbits[i].flag; } *p = 0; @@ -197,7 +202,7 @@ char *camel_maildir_summary_info_to_name(const CamelMessageInfo *info) } /* returns 0 if the info matches (or there was none), otherwise we changed it */ -int camel_maildir_summary_name_to_info(CamelMessageInfo *info, const char *name) +int camel_maildir_summary_name_to_info(CamelMaildirMessageInfo *info, const char *name) { char *p, c; guint32 set = 0; /* what we set */ @@ -210,7 +215,7 @@ int camel_maildir_summary_name_to_info(CamelMessageInfo *info, const char *name) while ((c = *p++)) { /* we could assume that the flags are in order, but its just as easy not to require */ for (i=0;i<sizeof(flagbits)/sizeof(flagbits[0]);i++) { - if (flagbits[i].flag == c && (info->flags & flagbits[i].flagbit) == 0) { + if (flagbits[i].flag == c && (info->info.info.flags & flagbits[i].flagbit) == 0) { set |= flagbits[i].flagbit; } /*all |= flagbits[i].flagbit;*/ @@ -219,10 +224,10 @@ int camel_maildir_summary_name_to_info(CamelMessageInfo *info, const char *name) /* changed? */ /*if ((info->flags & all) != set) {*/ - if ((info->flags & set) != set) { + if ((info->info.info.flags & set) != set) { /* ok, they did change, only add the new flags ('merge flags'?) */ /*info->flags &= all; if we wanted to set only the new flags, which we probably dont */ - info->flags |= set; + info->info.info.flags |= set; return 1; } } @@ -231,12 +236,12 @@ int camel_maildir_summary_name_to_info(CamelMessageInfo *info, const char *name) } /* for maildir, x-evolution isn't used, so dont try and get anything out of it */ -static int maildir_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelMessageInfo *mi) +static int maildir_summary_decode_x_evolution(CamelLocalSummary *cls, const char *xev, CamelLocalMessageInfo *mi) { return -1; } -static char *maildir_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelMessageInfo *mi) +static char *maildir_summary_encode_x_evolution(CamelLocalSummary *cls, const CamelLocalMessageInfo *mi) { return NULL; } @@ -246,9 +251,9 @@ static char *maildir_summary_encode_x_evolution(CamelLocalSummary *cls, const Ca */ static CamelMessageInfo *maildir_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *changes, CamelException *ex) { - CamelMessageInfo *mi; + CamelMaildirMessageInfo *mi; - mi = ((CamelLocalSummaryClass *) parent_class)->add(cls, msg, info, changes, ex); + mi = (CamelMaildirMessageInfo *)((CamelLocalSummaryClass *) parent_class)->add(cls, msg, info, changes, ex); if (mi) { if (info) { camel_maildir_info_set_filename(mi, camel_maildir_summary_info_to_name(mi)); @@ -256,35 +261,35 @@ static CamelMessageInfo *maildir_summary_add(CamelLocalSummary *cls, CamelMimeMe } } - return mi; + return (CamelMessageInfo *)mi; } -static CamelMessageInfo *message_info_new(CamelFolderSummary * s, struct _camel_header_raw *h) +static CamelMessageInfo *message_info_new_from_header(CamelFolderSummary * s, struct _camel_header_raw *h) { CamelMessageInfo *mi, *info; CamelMaildirSummary *mds = (CamelMaildirSummary *)s; CamelMaildirMessageInfo *mdi; const char *uid; - mi = ((CamelFolderSummaryClass *) parent_class)->message_info_new(s, h); + mi = ((CamelFolderSummaryClass *) parent_class)->message_info_new_from_header(s, h); /* assign the uid and new filename */ if (mi) { mdi = (CamelMaildirMessageInfo *)mi; uid = camel_message_info_uid(mi); if (uid==NULL || uid[0] == 0) - camel_message_info_set_uid(mi, camel_folder_summary_next_uid_string(s)); + mdi->info.info.uid = camel_folder_summary_next_uid_string(s); /* handle 'duplicates' */ info = camel_folder_summary_uid(s, uid); if (info) { d(printf("already seen uid '%s', just summarising instead\n", uid)); - camel_folder_summary_info_free(s, mi); + camel_message_info_free(mi); mdi = (CamelMaildirMessageInfo *)(mi = info); } /* with maildir we know the real received date, from the filename */ - mi->date_received = strtoul(camel_message_info_uid(mi), NULL, 10); + mdi->info.info.date_received = strtoul(camel_message_info_uid(mi), NULL, 10); if (mds->priv->current_file) { #if 0 @@ -293,7 +298,7 @@ static CamelMessageInfo *message_info_new(CamelFolderSummary * s, struct _camel_ #endif /* if setting from a file, grab the flags from it */ camel_maildir_info_set_filename(mi, g_strdup(mds->priv->current_file)); - camel_maildir_summary_name_to_info(mi, mds->priv->current_file); + camel_maildir_summary_name_to_info(mdi, mds->priv->current_file); #if 0 /* Actually, I dont think all this effort is worth it at all ... */ @@ -313,7 +318,7 @@ static CamelMessageInfo *message_info_new(CamelFolderSummary * s, struct _camel_ #endif } else { /* if creating a file, set its name from the flags we have */ - camel_maildir_info_set_filename(mdi, camel_maildir_summary_info_to_name(mi)); + camel_maildir_info_set_filename(mdi, camel_maildir_summary_info_to_name(mdi)); d(printf("Setting filename to %s\n", camel_maildir_info_filename(mi))); } } @@ -393,7 +398,7 @@ message_info_load(CamelFolderSummary *s, FILE *in) && (name = g_hash_table_lookup(mds->priv->load_map, camel_message_info_uid(mi)))) { d(printf("Setting filename of %s to %s\n", camel_message_info_uid(mi), name)); camel_maildir_info_set_filename(mi, g_strdup(name)); - camel_maildir_summary_name_to_info(mi, name); + camel_maildir_summary_name_to_info((CamelMaildirMessageInfo *)mi, name); } } @@ -502,19 +507,19 @@ remove_summary(char *key, CamelMessageInfo *info, struct _remove_data *rd) if (rd->changes) camel_folder_change_info_remove_uid(rd->changes, key); camel_folder_summary_remove((CamelFolderSummary *)rd->cls, info); - camel_folder_summary_info_free((CamelFolderSummary *)rd->cls, info); + camel_message_info_free(info); } static int sort_receive_cmp(const void *ap, const void *bp) { - const CamelMessageInfo - *a = *((CamelMessageInfo **)ap), - *b = *((CamelMessageInfo **)bp); + const CamelMaildirMessageInfo + *a = *((CamelMaildirMessageInfo **)ap), + *b = *((CamelMaildirMessageInfo **)bp); - if (a->date_received < b->date_received) + if (a->info.info.date_received < b->info.info.date_received) return -1; - else if (a->date_received > b->date_received) + else if (a->info.info.date_received > b->info.info.date_received) return 1; return 0; @@ -594,7 +599,7 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca info = g_hash_table_lookup(left, uid); if (info) { - camel_folder_summary_info_free((CamelFolderSummary *)cls, info); + camel_message_info_free(info); g_hash_table_remove(left, uid); } @@ -634,7 +639,7 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca # endif #endif } - camel_folder_summary_info_free((CamelFolderSummary *)cls, info); + camel_message_info_free(info); } g_free(uid); } @@ -669,7 +674,7 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca /* already in summary? shouldn't happen, but just incase ... */ if ((info = camel_folder_summary_uid((CamelFolderSummary *)cls, name))) { - camel_folder_summary_info_free((CamelFolderSummary *)cls, info); + camel_message_info_free(info); newname = destname = camel_folder_summary_next_uid_string(s); } else { newname = NULL; @@ -741,7 +746,7 @@ maildir_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChange info = camel_folder_summary_index((CamelFolderSummary *)cls, i); mdi = (CamelMaildirMessageInfo *)info; - if (info && (info->flags & CAMEL_MESSAGE_DELETED) && expunge) { + if (mdi && (mdi->info.info.flags & CAMEL_MESSAGE_DELETED) && expunge) { name = g_strdup_printf("%s/cur/%s", cls->folder_path, camel_maildir_info_filename(mdi)); d(printf("deleting %s\n", name)); if (unlink(name) == 0 || errno==ENOENT) { @@ -754,8 +759,8 @@ maildir_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChange camel_folder_summary_remove((CamelFolderSummary *)cls, info); } g_free(name); - } else if (info && (info->flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) { - char *newname = camel_maildir_summary_info_to_name(info); + } else if (mdi && (mdi->info.info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) { + char *newname = camel_maildir_summary_info_to_name(mdi); char *dest; /* do we care about additional metainfo stored inside the message? */ @@ -798,9 +803,9 @@ maildir_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChange } /* strip FOLDER_MESSAGE_FLAGED, etc */ - info->flags &= 0xffff; + mdi->info.info.flags &= 0xffff; } - camel_folder_summary_info_free((CamelFolderSummary *)cls, info); + camel_message_info_free(info); } camel_operation_end(NULL); diff --git a/camel/providers/local/camel-maildir-summary.h b/camel/providers/local/camel-maildir-summary.h index 0cae785c6c..4ecaf368f5 100644 --- a/camel/providers/local/camel-maildir-summary.h +++ b/camel/providers/local/camel-maildir-summary.h @@ -37,19 +37,15 @@ typedef struct _CamelMaildirMessageContentInfo { CamelMessageContentInfo info; } CamelMaildirMessageContentInfo; -#if defined (DOEPOOLV) || defined (DOESTRV) enum { CAMEL_MAILDIR_INFO_FILENAME = CAMEL_MESSAGE_INFO_LAST, CAMEL_MAILDIR_INFO_LAST, }; -#endif typedef struct _CamelMaildirMessageInfo { - CamelMessageInfo info; + CamelLocalMessageInfo info; -#if !defined (DOEPOOLV) && !defined (DOESTRV) char *filename; /* maildir has this annoying status shit on the end of the filename, use this to get the real message id */ -#endif } CamelMaildirMessageInfo; struct _CamelMaildirSummary { @@ -66,19 +62,15 @@ struct _CamelMaildirSummaryClass { }; CamelType camel_maildir_summary_get_type (void); -CamelMaildirSummary *camel_maildir_summary_new (const char *filename, const char *maildirdir, CamelIndex *index); +CamelMaildirSummary *camel_maildir_summary_new (struct _CamelFolder *folder, const char *filename, const char *maildirdir, CamelIndex *index); /* convert some info->flags to/from the messageinfo */ -char *camel_maildir_summary_info_to_name(const CamelMessageInfo *info); -int camel_maildir_summary_name_to_info(CamelMessageInfo *info, const char *name); +char *camel_maildir_summary_info_to_name(const CamelMaildirMessageInfo *info); +int camel_maildir_summary_name_to_info(CamelMaildirMessageInfo *info, const char *name); -#if defined (DOEPOOLV) || defined (DOESTRV) -#define camel_maildir_info_filename(x) camel_message_info_string((const CamelMessageInfo *)(x), CAMEL_MAILDIR_INFO_FILENAME) -#define camel_maildir_info_set_filename(x, s) camel_message_info_set_string((CamelMessageInfo *)(x), CAMEL_MAILDIR_INFO_FILENAME, s) -#else +/* TODO: could proably use get_string stuff */ #define camel_maildir_info_filename(x) (((CamelMaildirMessageInfo *)x)->filename) #define camel_maildir_info_set_filename(x, s) (g_free(((CamelMaildirMessageInfo *)x)->filename),((CamelMaildirMessageInfo *)x)->filename = s) -#endif #endif /* ! _CAMEL_MAILDIR_SUMMARY_H */ diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c index b4926b9b04..d213b444fc 100644 --- a/camel/providers/local/camel-mbox-folder.c +++ b/camel/providers/local/camel-mbox-folder.c @@ -56,13 +56,6 @@ static CamelLocalFolderClass *parent_class = NULL; static int mbox_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex); static void mbox_unlock(CamelLocalFolder *lf); -#ifdef STATUS_PINE -static gboolean mbox_set_message_flags(CamelFolder *folder, const char *uid, guint32 flags, guint32 set); -#endif - -static void mbox_set_message_user_flag(CamelFolder *folder, const char *uid, const char *name, gboolean value); -static void mbox_set_message_user_tag(CamelFolder *folder, const char *uid, const char *name, const char *value); - static void mbox_append_message(CamelFolder *folder, CamelMimeMessage * message, const CamelMessageInfo * info, char **appended_uid, CamelException *ex); static CamelMimeMessage *mbox_get_message(CamelFolder *folder, const gchar * uid, CamelException *ex); static CamelLocalSummary *mbox_create_summary(CamelLocalFolder *lf, const char *path, const char *folder, CamelIndex *index); @@ -83,12 +76,6 @@ camel_mbox_folder_class_init(CamelMboxFolderClass * camel_mbox_folder_class) camel_folder_class->append_message = mbox_append_message; camel_folder_class->get_message = mbox_get_message; -#ifdef STATUS_PINE - camel_folder_class->set_message_flags = mbox_set_message_flags; -#endif - camel_folder_class->set_message_user_flag = mbox_set_message_user_flag; - camel_folder_class->set_message_user_tag = mbox_set_message_user_tag; - lclass->get_full_path = camel_mbox_folder_get_full_path; lclass->get_meta_path = camel_mbox_folder_get_meta_path; lclass->create_summary = mbox_create_summary; @@ -207,7 +194,7 @@ camel_mbox_folder_get_meta_path (CamelLocalFolder *lf, const char *toplevel_dir, static CamelLocalSummary *mbox_create_summary(CamelLocalFolder *lf, const char *path, const char *folder, CamelIndex *index) { - return (CamelLocalSummary *)camel_mbox_summary_new(path, folder, index); + return (CamelLocalSummary *)camel_mbox_summary_new((CamelFolder *)lf, path, folder, index); } static int mbox_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex) @@ -421,7 +408,7 @@ retry: g_assert(info->frompos != -1); frompos = info->frompos; - camel_folder_summary_info_free(folder->summary, (CamelMessageInfo *)info); + camel_message_info_free((CamelMessageInfo *)info); /* we use an fd instead of a normal stream here - the reason is subtle, camel_mime_part will cache the whole message in memory if the stream is non-seekable (which it is when built from a parser @@ -493,66 +480,3 @@ fail: return message; } - -#ifdef STATUS_PINE -static gboolean -mbox_set_message_flags(CamelFolder *folder, const char *uid, guint32 flags, guint32 set) -{ - /* Basically, if anything could change the Status line, presume it does */ - if (((CamelMboxSummary *)folder->summary)->xstatus - && (flags & (CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_FLAGGED|CAMEL_MESSAGE_ANSWERED|CAMEL_MESSAGE_DELETED))) { - flags |= CAMEL_MESSAGE_FOLDER_XEVCHANGE|CAMEL_MESSAGE_FOLDER_FLAGGED; - set |= CAMEL_MESSAGE_FOLDER_XEVCHANGE|CAMEL_MESSAGE_FOLDER_FLAGGED; - } - - return ((CamelFolderClass *)parent_class)->set_message_flags(folder, uid, flags, set); -} -#endif - -static void -mbox_set_message_user_flag(CamelFolder *folder, const char *uid, const char *name, gboolean value) -{ - CamelMessageInfo *info; - - g_return_if_fail(folder->summary != NULL); - - info = camel_folder_summary_uid(folder->summary, uid); - if (info == NULL) - return; - - if (camel_flag_set(&info->user_flags, name, value)) { - CamelFolderChangeInfo *changes = camel_folder_change_info_new(); - - info->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED|CAMEL_MESSAGE_FOLDER_XEVCHANGE; - camel_folder_summary_touch(folder->summary); - - camel_folder_change_info_change_uid(changes, uid); - camel_object_trigger_event(folder, "folder_changed", changes); - camel_folder_change_info_free(changes); - } - camel_folder_summary_info_free(folder->summary, info); -} - -static void -mbox_set_message_user_tag(CamelFolder *folder, const char *uid, const char *name, const char *value) -{ - CamelMessageInfo *info; - - g_return_if_fail(folder->summary != NULL); - - info = camel_folder_summary_uid(folder->summary, uid); - if (info == NULL) - return; - - if (camel_tag_set(&info->user_tags, name, value)) { - CamelFolderChangeInfo *changes = camel_folder_change_info_new(); - - info->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED|CAMEL_MESSAGE_FOLDER_XEVCHANGE; - camel_folder_summary_touch(folder->summary); - - camel_folder_change_info_change_uid(changes, uid); - camel_object_trigger_event (folder, "folder_changed", changes); - camel_folder_change_info_free(changes); - } - camel_folder_summary_info_free(folder->summary, info); -} diff --git a/camel/providers/local/camel-mbox-store.c b/camel/providers/local/camel-mbox-store.c index f98c87a8ea..a9e581cdd7 100644 --- a/camel/providers/local/camel-mbox-store.c +++ b/camel/providers/local/camel-mbox-store.c @@ -618,7 +618,7 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags) path = camel_mbox_folder_get_meta_path(NULL, root, fi->full_name, ".ev-summary"); folderpath = camel_mbox_folder_get_full_path(NULL, root, fi->full_name); - mbs = (CamelMboxSummary *)camel_mbox_summary_new(path, folderpath, NULL); + mbs = (CamelMboxSummary *)camel_mbox_summary_new(NULL, path, folderpath, NULL); if (camel_folder_summary_header_load((CamelFolderSummary *)mbs) != -1) { fi->unread = ((CamelFolderSummary *)mbs)->unread_count; fi->total = ((CamelFolderSummary *)mbs)->saved_count; diff --git a/camel/providers/local/camel-mbox-summary.c b/camel/providers/local/camel-mbox-summary.c index 60dcf34c1c..9dcee0a9c8 100644 --- a/camel/providers/local/camel-mbox-summary.c +++ b/camel/providers/local/camel-mbox-summary.c @@ -51,13 +51,13 @@ static int summary_header_load (CamelFolderSummary *, FILE *); static int summary_header_save (CamelFolderSummary *, FILE *); -static CamelMessageInfo * message_info_new (CamelFolderSummary *, struct _camel_header_raw *); -static CamelMessageInfo * message_info_new_from_parser (CamelFolderSummary *, CamelMimeParser *); +static CamelMessageInfo * message_info_new_from_header(CamelFolderSummary *, struct _camel_header_raw *); +static CamelMessageInfo * message_info_new_from_parser(CamelFolderSummary *, CamelMimeParser *); static CamelMessageInfo * message_info_load (CamelFolderSummary *, FILE *); static int message_info_save (CamelFolderSummary *, FILE *, CamelMessageInfo *); /*static void message_info_free (CamelFolderSummary *, CamelMessageInfo *);*/ -static char *mbox_summary_encode_x_evolution (CamelLocalSummary *cls, const CamelMessageInfo *mi); +static char *mbox_summary_encode_x_evolution (CamelLocalSummary *cls, const CamelLocalMessageInfo *mi); static int mbox_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, CamelException *ex); static int mbox_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changeinfo, CamelException *ex); @@ -100,6 +100,44 @@ camel_mbox_summary_get_type(void) return type; } +static gboolean +mbox_info_set_user_flag(CamelMessageInfo *mi, const char *name, gboolean value) +{ + int res; + + res = ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->info_set_user_flag(mi, name, value); + if (res) + ((CamelLocalMessageInfo *)mi)->info.flags |= CAMEL_MESSAGE_FOLDER_FLAGGED|CAMEL_MESSAGE_FOLDER_XEVCHANGE; + + return res; +} + +static gboolean +mbox_info_set_user_tag(CamelMessageInfo *mi, const char *name, const char *value) +{ + int res; + + res = ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->info_set_user_tag(mi, name, value); + if (res) + ((CamelLocalMessageInfo *)mi)->info.flags |= CAMEL_MESSAGE_FOLDER_FLAGGED|CAMEL_MESSAGE_FOLDER_XEVCHANGE; + + return res; +} + +#ifdef STATUS_PINE +static gboolean +mbox_info_set_flags(CamelMessageInfo *mi, guint32 flags, guint32 set) +{ + /* Basically, if anything could change the Status line, presume it does */ + if (((CamelMboxSummary *)mi->summary)->xstatus + && (flags & (CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_FLAGGED|CAMEL_MESSAGE_ANSWERED|CAMEL_MESSAGE_DELETED))) { + flags |= CAMEL_MESSAGE_FOLDER_XEVCHANGE|CAMEL_MESSAGE_FOLDER_FLAGGED; + set |= CAMEL_MESSAGE_FOLDER_XEVCHANGE|CAMEL_MESSAGE_FOLDER_FLAGGED; + } + + return ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->info_set_flags(mi, flags, set); +} +#endif static void camel_mbox_summary_class_init(CamelMboxSummaryClass *klass) @@ -112,11 +150,17 @@ camel_mbox_summary_class_init(CamelMboxSummaryClass *klass) sklass->summary_header_load = summary_header_load; sklass->summary_header_save = summary_header_save; - sklass->message_info_new = message_info_new; + sklass->message_info_new_from_header = message_info_new_from_header; sklass->message_info_new_from_parser = message_info_new_from_parser; sklass->message_info_load = message_info_load; sklass->message_info_save = message_info_save; /*sklass->message_info_free = message_info_free;*/ + + sklass->info_set_user_flag = mbox_info_set_user_flag; + sklass->info_set_user_tag = mbox_info_set_user_tag; +#ifdef STATUS_PINE + sklass->info_set_flags = mbox_info_set_flags; +#endif lklass->encode_x_evolution = mbox_summary_encode_x_evolution; lklass->check = mbox_summary_check; @@ -156,10 +200,12 @@ camel_mbox_summary_finalise(CamelObject *obj) * Return value: A new CamelMboxSummary widget. **/ CamelMboxSummary * -camel_mbox_summary_new(const char *filename, const char *mbox_name, CamelIndex *index) +camel_mbox_summary_new(struct _CamelFolder *folder, const char *filename, const char *mbox_name, CamelIndex *index) { CamelMboxSummary *new = (CamelMboxSummary *)camel_object_new(camel_mbox_summary_get_type()); + ((CamelFolderSummary *)new)->folder = folder; + camel_local_summary_construct((CamelLocalSummary *)new, filename, mbox_name, index); return new; } @@ -170,19 +216,20 @@ void camel_mbox_summary_xstatus(CamelMboxSummary *mbs, int state) } static char * -mbox_summary_encode_x_evolution (CamelLocalSummary *cls, const CamelMessageInfo *mi) +mbox_summary_encode_x_evolution (CamelLocalSummary *cls, const CamelLocalMessageInfo *mi) { const char *p, *uidstr; guint32 uid; - - p = uidstr = camel_message_info_uid (mi); - while (*p && isdigit (*p)) + + /* This is busted, it is supposed to encode ALL DATA */ + p = uidstr = camel_message_info_uid(mi); + while (*p && isdigit(*p)) p++; - if (*p == 0 && sscanf (uidstr, "%u", &uid) == 1) { - return g_strdup_printf ("%08x-%04x", uid, mi->flags & 0xffff); + if (*p == 0 && sscanf(uidstr, "%u", &uid) == 1) { + return g_strdup_printf("%08x-%04x", uid, mi->info.flags & 0xffff); } else { - return g_strdup_printf ("%s-%04x", uidstr, mi->flags & 0xffff); + return g_strdup_printf("%s-%04x", uidstr, mi->info.flags & 0xffff); } } @@ -220,16 +267,15 @@ summary_header_save(CamelFolderSummary *s, FILE *out) } static CamelMessageInfo * -message_info_new(CamelFolderSummary *s, struct _camel_header_raw *h) +message_info_new_from_header(CamelFolderSummary *s, struct _camel_header_raw *h) { - CamelMessageInfo *mi; + CamelMboxMessageInfo *mi; CamelMboxSummary *mbs = (CamelMboxSummary *)s; - mi = ((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_new(s, h); + mi = (CamelMboxMessageInfo *)((CamelFolderSummaryClass *)camel_mbox_summary_parent)->message_info_new_from_header(s, h); if (mi) { - CamelMboxMessageInfo *mbi = (CamelMboxMessageInfo *)mi; const char *xev, *uid; - CamelMessageInfo *info = NULL; + CamelMboxMessageInfo *info = NULL; int add = 0; /* bitmask of things to add, 1 assign uid, 2, just add as new, 4 = recent */ #ifdef STATUS_PINE const char *status = NULL, *xstatus = NULL; @@ -248,19 +294,19 @@ message_info_new(CamelFolderSummary *s, struct _camel_header_raw *h) /* if we have an xev header, use it, else assign a new one */ xev = camel_header_raw_find(&h, "X-Evolution", NULL); if (xev != NULL - && camel_local_summary_decode_x_evolution((CamelLocalSummary *)s, xev, mi) == 0) { + && camel_local_summary_decode_x_evolution((CamelLocalSummary *)s, xev, &mi->info) == 0) { uid = camel_message_info_uid(mi); d(printf("found valid x-evolution: %s\n", uid)); - info = camel_folder_summary_uid(s, uid); + info = (CamelMboxMessageInfo *)camel_folder_summary_uid(s, uid); if (info) { - if ((info->flags & CAMEL_MESSAGE_FOLDER_NOTSEEN)) { - info->flags &= ~CAMEL_MESSAGE_FOLDER_NOTSEEN; - camel_folder_summary_info_free(s, mi); - mbi = (CamelMboxMessageInfo *)(mi = info); + if ((info->info.info.flags & CAMEL_MESSAGE_FOLDER_NOTSEEN)) { + info->info.info.flags &= ~CAMEL_MESSAGE_FOLDER_NOTSEEN; + camel_message_info_free(mi); + mi = info; } else { add = 7; d(printf("seen '%s' before, adding anew\n", uid)); - camel_folder_summary_info_free(s, info); + camel_message_info_free(info); } } else { add = 2; @@ -272,8 +318,8 @@ message_info_new(CamelFolderSummary *s, struct _camel_header_raw *h) } if (add&1) { - mi->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED | CAMEL_MESSAGE_FOLDER_NOXEV; - camel_message_info_set_uid(mi, camel_folder_summary_next_uid_string(s)); + mi->info.info.flags |= CAMEL_MESSAGE_FOLDER_FLAGGED | CAMEL_MESSAGE_FOLDER_NOXEV; + mi->info.info.uid = camel_folder_summary_next_uid_string(s); } else { camel_folder_summary_set_uid(s, strtoul(camel_message_info_uid(mi), NULL, 10)); } @@ -281,9 +327,9 @@ message_info_new(CamelFolderSummary *s, struct _camel_header_raw *h) if (mbs->xstatus && add&2) { /* use the status as the flags when we read it the first time */ if (status) - mi->flags = (mi->flags & ~(STATUS_STATUS)) | (flags & STATUS_STATUS); + mi->info.info.flags = (mi->info.info.flags & ~(STATUS_STATUS)) | (flags & STATUS_STATUS); if (xstatus) - mi->flags = (mi->flags & ~(STATUS_XSTATUS)) | (flags & STATUS_XSTATUS); + mi->info.info.flags = (mi->info.info.flags & ~(STATUS_XSTATUS)) | (flags & STATUS_XSTATUS); } #endif if (mbs->changes) { @@ -293,10 +339,10 @@ message_info_new(CamelFolderSummary *s, struct _camel_header_raw *h) camel_folder_change_info_recent_uid(mbs->changes, camel_message_info_uid(mi)); } - mbi->frompos = -1; + mi->frompos = -1; } - return mi; + return (CamelMessageInfo *)mi; } static CamelMessageInfo * @@ -331,7 +377,7 @@ message_info_load(CamelFolderSummary *s, FILE *in) return mi; error: - camel_folder_summary_info_free(s, mi); + camel_message_info_free(mi); return NULL; } @@ -357,7 +403,7 @@ summary_update(CamelLocalSummary *cls, off_t offset, CamelFolderChangeInfo *chan CamelFolderSummary *s = (CamelFolderSummary *)cls; CamelMboxSummary *mbs = (CamelMboxSummary *)cls; CamelMimeParser *mp; - CamelMessageInfo *mi; + CamelMboxMessageInfo *mi; int fd; int ok = 0; struct stat st; @@ -404,12 +450,12 @@ summary_update(CamelLocalSummary *cls, off_t offset, CamelFolderChangeInfo *chan from the old end, so everything must be treated as new */ count = camel_folder_summary_count(s); for (i=0;i<count;i++) { - mi = camel_folder_summary_index(s, i); + mi = (CamelMboxMessageInfo *)camel_folder_summary_index(s, i); if (offset == 0) - mi->flags |= CAMEL_MESSAGE_FOLDER_NOTSEEN; + mi->info.info.flags |= CAMEL_MESSAGE_FOLDER_NOTSEEN; else - mi->flags &= ~CAMEL_MESSAGE_FOLDER_NOTSEEN; - camel_folder_summary_info_free(s, mi); + mi->info.info.flags &= ~CAMEL_MESSAGE_FOLDER_NOTSEEN; + camel_message_info_free(mi); } mbs->changes = changeinfo; @@ -434,17 +480,17 @@ summary_update(CamelLocalSummary *cls, off_t offset, CamelFolderChangeInfo *chan count = camel_folder_summary_count(s); for (i=0;i<count;i++) { - mi = camel_folder_summary_index(s, i); + mi = (CamelMboxMessageInfo *)camel_folder_summary_index(s, i); /* must've dissapeared from the file? */ - if (mi->flags & CAMEL_MESSAGE_FOLDER_NOTSEEN) { + if (mi->info.info.flags & CAMEL_MESSAGE_FOLDER_NOTSEEN) { d(printf("uid '%s' vanished, removing", camel_message_info_uid(mi))); if (changeinfo) camel_folder_change_info_remove_uid(changeinfo, camel_message_info_uid(mi)); - camel_folder_summary_remove(s, mi); + camel_folder_summary_remove(s, (CamelMessageInfo *)mi); count--; i--; } - camel_folder_summary_info_free(s, mi); + camel_message_info_free(mi); } mbs->changes = NULL; @@ -495,7 +541,7 @@ mbox_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Camel if (info) { camel_folder_change_info_remove_uid(changes, camel_message_info_uid(info)); - camel_folder_summary_info_free(s, info); + camel_message_info_free(info); } } camel_folder_summary_clear(s); @@ -661,8 +707,8 @@ mbox_summary_sync_quick(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChan d(printf("Checking message %s %08x\n", camel_message_info_uid(info), info->info.flags)); - if ((info->info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED) == 0) { - camel_folder_summary_info_free(s, (CamelMessageInfo *)info); + if ((info->info.info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED) == 0) { + camel_message_info_free((CamelMessageInfo *)info); info = NULL; continue; } @@ -696,7 +742,7 @@ mbox_summary_sync_quick(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChan g_warning("We're supposed to have a valid x-ev header, but we dont"); goto error; } - xevnew = camel_local_summary_encode_x_evolution(cls, (CamelMessageInfo *)info); + xevnew = camel_local_summary_encode_x_evolution(cls, &info->info); /* SIGH: encode_param_list is about the only function which folds headers by itself. This should be fixed somehow differently (either parser doesn't fold headers, or param_list doesn't, or something */ @@ -725,8 +771,8 @@ mbox_summary_sync_quick(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChan camel_mime_parser_drop_step(mp); camel_mime_parser_drop_step(mp); - info->info.flags &= 0xffff; - camel_folder_summary_info_free(s, (CamelMessageInfo *)info); + info->info.info.flags &= 0xffff; + camel_message_info_free((CamelMessageInfo *)info); } d(printf("Closing folders\n")); @@ -751,7 +797,7 @@ mbox_summary_sync_quick(CamelMboxSummary *mbs, gboolean expunge, CamelFolderChan if (mp) camel_object_unref((CamelObject *)mp); if (info) - camel_folder_summary_info_free(s, (CamelMessageInfo *)info); + camel_message_info_free((CamelMessageInfo *)info); camel_operation_end(NULL); @@ -778,14 +824,15 @@ mbox_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInf /* check what work we have to do, if any */ for (i=0;quick && i<count; i++) { - CamelMessageInfo *info = camel_folder_summary_index(s, i); + CamelMboxMessageInfo *info = (CamelMboxMessageInfo *)camel_folder_summary_index(s, i); + g_assert(info); - if ((expunge && (info->flags & CAMEL_MESSAGE_DELETED)) || - (info->flags & (CAMEL_MESSAGE_FOLDER_NOXEV|CAMEL_MESSAGE_FOLDER_XEVCHANGE))) + if ((expunge && (info->info.info.flags & CAMEL_MESSAGE_DELETED)) || + (info->info.info.flags & (CAMEL_MESSAGE_FOLDER_NOXEV|CAMEL_MESSAGE_FOLDER_XEVCHANGE))) quick = FALSE; else - work |= (info->flags & CAMEL_MESSAGE_FOLDER_FLAGGED) != 0; - camel_folder_summary_info_free(s, info); + work |= (info->info.info.flags & CAMEL_MESSAGE_FOLDER_FLAGGED) != 0; + camel_message_info_free(info); } /* yuck i hate this logic, but its to simplify the 'all ok, update summary' and failover cases */ @@ -888,7 +935,7 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh } lastdel = FALSE; - if ((flags&1) && info->info.flags & CAMEL_MESSAGE_DELETED) { + if ((flags&1) && info->info.info.flags & CAMEL_MESSAGE_DELETED) { const char *uid = camel_message_info_uid(info); d(printf("Deleting %s\n", uid)); @@ -899,7 +946,7 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh /* remove it from the change list */ camel_folder_change_info_remove_uid(changeinfo, uid); camel_folder_summary_remove(s, (CamelMessageInfo *)info); - camel_folder_summary_info_free(s, (CamelMessageInfo *)info); + camel_message_info_free((CamelMessageInfo *)info); count--; i--; info = NULL; @@ -915,7 +962,7 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh write(fdout, fromline, strlen(fromline)); } - if (info && info->info.flags & (CAMEL_MESSAGE_FOLDER_NOXEV | CAMEL_MESSAGE_FOLDER_FLAGGED)) { + if (info && info->info.info.flags & (CAMEL_MESSAGE_FOLDER_NOXEV | CAMEL_MESSAGE_FOLDER_FLAGGED)) { d(printf("Updating header for %s flags = %08x\n", camel_message_info_uid(info), info->info.flags)); if (camel_mime_parser_step(mp, &buffer, &len) == CAMEL_MIME_PARSER_STATE_FROM_END) { @@ -923,11 +970,11 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh goto error; } - xevnew = camel_local_summary_encode_x_evolution((CamelLocalSummary *)cls, (CamelMessageInfo *)info); + xevnew = camel_local_summary_encode_x_evolution((CamelLocalSummary *)cls, &info->info); #ifdef STATUS_PINE if (mbs->xstatus) { - encode_status(((CamelMessageInfo *)info)->flags & STATUS_STATUS, statnew); - encode_status(((CamelMessageInfo *)info)->flags & STATUS_XSTATUS, xstatnew); + encode_status(info->info.info.flags & STATUS_STATUS, statnew); + encode_status(info->info.info.flags & STATUS_XSTATUS, xstatnew); len = camel_local_summary_write_headers(fdout, camel_mime_parser_headers_raw(mp), xevnew, statnew, xstatnew); } else { #endif @@ -942,7 +989,7 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh g_strerror (errno)); goto error; } - info->info.flags &= 0xffff; + info->info.info.flags &= 0xffff; g_free(xevnew); xevnew = NULL; camel_mime_parser_drop_step(mp); @@ -972,7 +1019,7 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh d(printf("we are now at %d, from = %d\n", (int)camel_mime_parser_tell(mp), (int)camel_mime_parser_tell_start_from(mp))); camel_mime_parser_unstep(mp); - camel_folder_summary_info_free(s, (CamelMessageInfo *)info); + camel_message_info_free((CamelMessageInfo *)info); info = NULL; } } @@ -992,7 +1039,7 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh if (mp) camel_object_unref((CamelObject *)mp); if (info) - camel_folder_summary_info_free(s, (CamelMessageInfo *)info); + camel_message_info_free((CamelMessageInfo *)info); return -1; } @@ -1001,20 +1048,20 @@ camel_mbox_summary_sync_mbox(CamelMboxSummary *cls, guint32 flags, CamelFolderCh static CamelMessageInfo * mbox_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *ci, CamelException *ex) { - CamelMessageInfo *mi; + CamelMboxMessageInfo *mi; - mi = ((CamelLocalSummaryClass *)camel_mbox_summary_parent)->add(cls, msg, info, ci, ex); + mi = (CamelMboxMessageInfo *)((CamelLocalSummaryClass *)camel_mbox_summary_parent)->add(cls, msg, info, ci, ex); if (mi && ((CamelMboxSummary *)cls)->xstatus) { char status[8]; /* we snoop and add status/x-status headers to suit */ - encode_status(mi->flags & STATUS_STATUS, status); + encode_status(mi->info.info.flags & STATUS_STATUS, status); camel_medium_set_header((CamelMedium *)msg, "Status", status); - encode_status(mi->flags & STATUS_XSTATUS, status); + encode_status(mi->info.info.flags & STATUS_XSTATUS, status); camel_medium_set_header((CamelMedium *)msg, "X-Status", status); } - return mi; + return (CamelMessageInfo *)mi; } static struct { diff --git a/camel/providers/local/camel-mbox-summary.h b/camel/providers/local/camel-mbox-summary.h index 34402ad264..9089fe7c8e 100644 --- a/camel/providers/local/camel-mbox-summary.h +++ b/camel/providers/local/camel-mbox-summary.h @@ -38,7 +38,7 @@ typedef struct _CamelMboxMessageContentInfo { } CamelMboxMessageContentInfo; typedef struct _CamelMboxMessageInfo { - CamelMessageInfo info; + CamelLocalMessageInfo info; off_t frompos; } CamelMboxMessageInfo; @@ -64,7 +64,7 @@ struct _CamelMboxSummaryClass { }; CamelType camel_mbox_summary_get_type (void); -CamelMboxSummary *camel_mbox_summary_new (const char *filename, const char *mbox_name, CamelIndex *index); +CamelMboxSummary *camel_mbox_summary_new (struct _CamelFolder *, const char *filename, const char *mbox_name, CamelIndex *index); /* do we honour/use xstatus headers, etc */ void camel_mbox_summary_xstatus(CamelMboxSummary *mbs, int state); diff --git a/camel/providers/local/camel-mh-folder.c b/camel/providers/local/camel-mh-folder.c index fd054933c5..1b054a4547 100644 --- a/camel/providers/local/camel-mh-folder.c +++ b/camel/providers/local/camel-mh-folder.c @@ -117,7 +117,7 @@ camel_mh_folder_new(CamelStore *parent_store, const char *full_name, guint32 fla static CamelLocalSummary *mh_create_summary(CamelLocalFolder *lf, const char *path, const char *folder, CamelIndex *index) { - return (CamelLocalSummary *)camel_mh_summary_new(path, folder, index); + return (CamelLocalSummary *)camel_mh_summary_new((CamelFolder *)lf, path, folder, index); } static void @@ -205,7 +205,7 @@ static CamelMimeMessage *mh_get_message(CamelFolder * folder, const gchar * uid, } /* we only need it to check the message exists */ - camel_folder_summary_info_free(folder->summary, info); + camel_message_info_free(info); name = g_strdup_printf("%s/%s", lf->folder_path, uid); if ((message_stream = camel_stream_fs_new_with_name(name, O_RDONLY, 0)) == NULL) { diff --git a/camel/providers/local/camel-mh-store.c b/camel/providers/local/camel-mh-store.c index cc2f3ce9c9..03b6db92bd 100644 --- a/camel/providers/local/camel-mh-store.c +++ b/camel/providers/local/camel-mh-store.c @@ -324,7 +324,7 @@ fill_fi(CamelStore *store, CamelFolderInfo *fi, guint32 flags) root = camel_local_store_get_toplevel_dir((CamelLocalStore *)store); path = g_strdup_printf("%s/%s.ev-summary", root, fi->full_name); folderpath = g_strdup_printf("%s/%s", root, fi->full_name); - s = (CamelFolderSummary *)camel_mh_summary_new(path, folderpath, NULL); + s = (CamelFolderSummary *)camel_mh_summary_new(NULL, path, folderpath, NULL); if (camel_folder_summary_header_load(s) != -1) { fi->unread = s->unread_count; fi->total = s->saved_count; diff --git a/camel/providers/local/camel-mh-summary.c b/camel/providers/local/camel-mh-summary.c index d51bf7a108..fe0201e4f2 100644 --- a/camel/providers/local/camel-mh-summary.c +++ b/camel/providers/local/camel-mh-summary.c @@ -123,10 +123,12 @@ camel_mh_summary_finalise(CamelObject *obj) * * Return value: A new #CamelMhSummary object. **/ -CamelMhSummary *camel_mh_summary_new (const char *filename, const char *mhdir, CamelIndex *index) +CamelMhSummary *camel_mh_summary_new(struct _CamelFolder *folder, const char *filename, const char *mhdir, CamelIndex *index) { CamelMhSummary *o = (CamelMhSummary *)camel_object_new(camel_mh_summary_get_type ()); + ((CamelFolderSummary *)o)->folder = folder; + camel_local_summary_construct((CamelLocalSummary *)o, filename, mhdir, index); return o; } @@ -204,7 +206,7 @@ remove_summary(char *key, CamelMessageInfo *info, CamelLocalSummary *cls) if (cls->index) camel_index_delete_name(cls->index, camel_message_info_uid(info)); camel_folder_summary_remove((CamelFolderSummary *)cls, info); - camel_folder_summary_info_free((CamelFolderSummary *)cls, info); + camel_message_info_free(info); } static int @@ -272,7 +274,7 @@ mh_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, Came if (info != NULL) { g_hash_table_remove(left, camel_message_info_uid(info)); camel_folder_summary_remove((CamelFolderSummary *)cls, info); - camel_folder_summary_info_free((CamelFolderSummary *)cls, info); + camel_message_info_free(info); } camel_mh_summary_add(cls, d->d_name, forceindex); } else { @@ -280,10 +282,10 @@ mh_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, Came CamelMessageInfo *old = g_hash_table_lookup(left, uid); if (old) { - camel_folder_summary_info_free((CamelFolderSummary *)cls, old); + camel_message_info_free(old); g_hash_table_remove(left, uid); } - camel_folder_summary_info_free((CamelFolderSummary *)cls, info); + camel_message_info_free(info); } } } @@ -300,7 +302,7 @@ mh_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, Came } static int -mh_summary_sync_message(CamelLocalSummary *cls, CamelMessageInfo *info, CamelException *ex) +mh_summary_sync_message(CamelLocalSummary *cls, CamelLocalMessageInfo *info, CamelException *ex) { CamelMimeParser *mp; const char *xev, *buffer; @@ -378,7 +380,7 @@ static int mh_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo *changes, CamelException *ex) { int count, i; - CamelMessageInfo *info; + CamelLocalMessageInfo *info; char *name; const char *uid; @@ -391,9 +393,9 @@ mh_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo count = camel_folder_summary_count((CamelFolderSummary *)cls); for (i=count-1;i>=0;i--) { - info = camel_folder_summary_index((CamelFolderSummary *)cls, i); + info = (CamelLocalMessageInfo *)camel_folder_summary_index((CamelFolderSummary *)cls, i); g_assert(info); - if (expunge && (info->flags & CAMEL_MESSAGE_DELETED)) { + if (expunge && (info->info.flags & CAMEL_MESSAGE_DELETED)) { uid = camel_message_info_uid(info); name = g_strdup_printf("%s/%s", cls->folder_path, uid); d(printf("deleting %s\n", name)); @@ -404,17 +406,17 @@ mh_summary_sync(CamelLocalSummary *cls, gboolean expunge, CamelFolderChangeInfo camel_index_delete_name(cls->index, (char *)uid); camel_folder_change_info_remove_uid(changes, uid); - camel_folder_summary_remove((CamelFolderSummary *)cls, info); + camel_folder_summary_remove((CamelFolderSummary *)cls, (CamelMessageInfo *)info); } g_free(name); - } else if (info->flags & (CAMEL_MESSAGE_FOLDER_NOXEV|CAMEL_MESSAGE_FOLDER_FLAGGED)) { + } else if (info->info.flags & (CAMEL_MESSAGE_FOLDER_NOXEV|CAMEL_MESSAGE_FOLDER_FLAGGED)) { if (mh_summary_sync_message(cls, info, ex) != -1) { - info->flags &= 0xffff; + info->info.flags &= 0xffff; } else { g_warning("Problem occured when trying to expunge, ignored"); } } - camel_folder_summary_info_free((CamelFolderSummary *)cls, info); + camel_message_info_free(info); } return ((CamelLocalSummaryClass *)parent_class)->sync(cls, expunge, changes, ex); diff --git a/camel/providers/local/camel-mh-summary.h b/camel/providers/local/camel-mh-summary.h index 4ee30df63b..d2fdcd1e4a 100644 --- a/camel/providers/local/camel-mh-summary.h +++ b/camel/providers/local/camel-mh-summary.h @@ -47,7 +47,7 @@ struct _CamelMhSummaryClass { }; CamelType camel_mh_summary_get_type (void); -CamelMhSummary *camel_mh_summary_new (const char *filename, const char *mhdir, CamelIndex *index); +CamelMhSummary *camel_mh_summary_new(struct _CamelFolder *, const char *filename, const char *mhdir, CamelIndex *index); #endif /* ! _CAMEL_MH_SUMMARY_H */ diff --git a/camel/providers/local/camel-spool-folder.c b/camel/providers/local/camel-spool-folder.c index b9cb643189..c4c7da91b6 100644 --- a/camel/providers/local/camel-spool-folder.c +++ b/camel/providers/local/camel-spool-folder.c @@ -160,7 +160,7 @@ spool_get_meta_path(CamelLocalFolder *lf, const char *toplevel_dir, const char * static CamelLocalSummary * spool_create_summary(CamelLocalFolder *lf, const char *path, const char *folder, CamelIndex *index) { - return (CamelLocalSummary *)camel_spool_summary_new(folder); + return (CamelLocalSummary *)camel_spool_summary_new((CamelFolder *)lf, folder); } static int diff --git a/camel/providers/local/camel-spool-summary.c b/camel/providers/local/camel-spool-summary.c index 3e4fb533ab..c8e074ae99 100644 --- a/camel/providers/local/camel-spool-summary.c +++ b/camel/providers/local/camel-spool-summary.c @@ -106,10 +106,12 @@ camel_spool_summary_finalise(CamelObject *obj) } CamelSpoolSummary * -camel_spool_summary_new(const char *mbox_name) +camel_spool_summary_new(struct _CamelFolder *folder, const char *mbox_name) { CamelSpoolSummary *new = (CamelSpoolSummary *)camel_object_new(camel_spool_summary_get_type()); + ((CamelFolderSummary *)new)->folder = folder; + camel_local_summary_construct((CamelLocalSummary *)new, NULL, mbox_name, NULL); return new; } @@ -318,10 +320,10 @@ spool_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changeinfo, C work = FALSE; count = camel_folder_summary_count(s); for (i=0;!work && i<count; i++) { - CamelMessageInfo *info = camel_folder_summary_index(s, i); + CamelMboxMessageInfo *info = (CamelMboxMessageInfo *)camel_folder_summary_index(s, i); g_assert(info); - work = (info->flags & (CAMEL_MESSAGE_FOLDER_NOXEV)) != 0; - camel_folder_summary_info_free(s, info); + work = (info->info.info.flags & (CAMEL_MESSAGE_FOLDER_NOXEV)) != 0; + camel_message_info_free((CamelMessageInfo *)info); } /* if we do, then write out the headers using sync_full, etc */ diff --git a/camel/providers/local/camel-spool-summary.h b/camel/providers/local/camel-spool-summary.h index b72aeda527..2849c8cc20 100644 --- a/camel/providers/local/camel-spool-summary.h +++ b/camel/providers/local/camel-spool-summary.h @@ -47,7 +47,7 @@ CamelType camel_spool_summary_get_type (void); void camel_spool_summary_construct (CamelSpoolSummary *new, const char *filename, const char *spool_name, CamelIndex *index); /* create the summary, in-memory only */ -CamelSpoolSummary *camel_spool_summary_new(const char *filename); +CamelSpoolSummary *camel_spool_summary_new(struct _CamelFolder *, const char *filename); /* load/check the summary */ int camel_spool_summary_load(CamelSpoolSummary *cls, int forceindex, CamelException *ex); diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c index 7f06555b43..de0f4cd222 100644 --- a/camel/providers/nntp/camel-nntp-folder.c +++ b/camel/providers/nntp/camel-nntp-folder.c @@ -511,7 +511,7 @@ camel_nntp_folder_new (CamelStore *parent, const char *folder_name, CamelExcepti g_free(root); root = g_strdup_printf("%s.ev-summary", nntp_folder->storage_path); - folder->summary = (CamelFolderSummary *) camel_nntp_summary_new (root); + folder->summary = (CamelFolderSummary *) camel_nntp_summary_new (folder, root); g_free(root); camel_folder_summary_load (folder->summary); diff --git a/camel/providers/nntp/camel-nntp-summary.c b/camel/providers/nntp/camel-nntp-summary.c index bb2dda8809..213c6f9045 100644 --- a/camel/providers/nntp/camel-nntp-summary.c +++ b/camel/providers/nntp/camel-nntp-summary.c @@ -60,7 +60,7 @@ struct _CamelNNTPSummaryPrivate { #define _PRIVATE(o) (((CamelNNTPSummary *)(o))->priv) -static CamelMessageInfo * message_info_new (CamelFolderSummary *, struct _camel_header_raw *); +static CamelMessageInfo * message_info_new_from_header (CamelFolderSummary *, struct _camel_header_raw *); static int summary_header_load(CamelFolderSummary *, FILE *); static int summary_header_save(CamelFolderSummary *, FILE *); @@ -94,7 +94,7 @@ camel_nntp_summary_class_init(CamelNNTPSummaryClass *klass) camel_nntp_summary_parent = CAMEL_FOLDER_SUMMARY_CLASS(camel_type_get_global_classfuncs(camel_folder_summary_get_type())); - sklass->message_info_new = message_info_new; + sklass->message_info_new_from_header = message_info_new_from_header; sklass->summary_header_load = summary_header_load; sklass->summary_header_save = summary_header_save; } @@ -108,7 +108,7 @@ camel_nntp_summary_init(CamelNNTPSummary *obj) p = _PRIVATE(obj) = g_malloc0(sizeof(*p)); /* subclasses need to set the right instance data sizes */ - s->message_info_size = sizeof(CamelMessageInfo); + s->message_info_size = sizeof(CamelMessageInfoBase); s->content_info_size = sizeof(CamelMessageContentInfo); /* and a unique file version */ @@ -124,10 +124,12 @@ camel_nntp_summary_finalise(CamelObject *obj) } CamelNNTPSummary * -camel_nntp_summary_new(const char *path) +camel_nntp_summary_new(struct _CamelFolder *folder, const char *path) { CamelNNTPSummary *cns = (CamelNNTPSummary *)camel_object_new(camel_nntp_summary_get_type()); + ((CamelFolderSummary *)cns)->folder = folder; + camel_folder_summary_set_filename((CamelFolderSummary *)cns, path); camel_folder_summary_set_build_content((CamelFolderSummary *)cns, FALSE); @@ -135,9 +137,9 @@ camel_nntp_summary_new(const char *path) } static CamelMessageInfo * -message_info_new(CamelFolderSummary *s, struct _camel_header_raw *h) +message_info_new_from_header(CamelFolderSummary *s, struct _camel_header_raw *h) { - CamelMessageInfo *mi; + CamelMessageInfoBase *mi; CamelNNTPSummary *cns = (CamelNNTPSummary *)s; /* error to call without this setup */ @@ -147,13 +149,13 @@ message_info_new(CamelFolderSummary *s, struct _camel_header_raw *h) /* we shouldn't be here if we already have this uid */ g_assert(camel_folder_summary_uid(s, cns->priv->uid) == NULL); - mi = ((CamelFolderSummaryClass *)camel_nntp_summary_parent)->message_info_new(s, h); + mi = (CamelMessageInfoBase *)((CamelFolderSummaryClass *)camel_nntp_summary_parent)->message_info_new_from_header(s, h); if (mi) { - camel_message_info_set_uid(mi, cns->priv->uid); + mi->uid = g_strdup(cns->priv->uid); cns->priv->uid = NULL; } - return mi; + return (CamelMessageInfo *)mi; } static int @@ -207,7 +209,7 @@ static int add_range_xover(CamelNNTPSummary *cns, CamelNNTPStore *store, unsigned int high, unsigned int low, CamelFolderChangeInfo *changes, CamelException *ex) { CamelFolderSummary *s; - CamelMessageInfo *mi; + CamelMessageInfoBase *mi; struct _camel_header_raw *headers = NULL; char *line, *tab; int len, ret; @@ -271,16 +273,16 @@ add_range_xover(CamelNNTPSummary *cns, CamelNNTPStore *store, unsigned int high, /* truncated line? ignore? */ if (xover == NULL) { - mi = camel_folder_summary_uid(s, cns->priv->uid); + mi = (CamelMessageInfoBase *)camel_folder_summary_uid(s, cns->priv->uid); if (mi == NULL) { - mi = camel_folder_summary_add_from_header(s, headers); + mi = (CamelMessageInfoBase *)camel_folder_summary_add_from_header(s, headers); if (mi) { mi->size = size; cns->high = n; camel_folder_change_info_add_uid(changes, camel_message_info_uid(mi)); } } else { - camel_folder_summary_info_free(s, mi); + camel_message_info_free(mi); } } @@ -352,7 +354,7 @@ add_range_head(CamelNNTPSummary *cns, CamelNNTPStore *store, unsigned int high, camel_folder_change_info_add_uid(changes, camel_message_info_uid(mi)); } else { /* already have, ignore */ - camel_folder_summary_info_free(s, mi); + camel_message_info_free(mi); } if (cns->priv->uid) { g_free(cns->priv->uid); @@ -445,7 +447,7 @@ camel_nntp_summary_check(CamelNNTPSummary *cns, CamelNNTPStore *store, char *lin i--; } - camel_folder_summary_info_free(s, mi); + camel_message_info_free(mi); } } cns->low = f; @@ -473,12 +475,12 @@ update: count = camel_folder_summary_count(s); for (i = 0; i < count; i++) { - CamelMessageInfo *mi = camel_folder_summary_index(s, i); + CamelMessageInfoBase *mi = (CamelMessageInfoBase *)camel_folder_summary_index(s, i); if (mi) { if ((mi->flags & CAMEL_MESSAGE_SEEN) == 0) unread++; - camel_folder_summary_info_free(s, mi); + camel_message_info_free(mi); } } diff --git a/camel/providers/nntp/camel-nntp-summary.h b/camel/providers/nntp/camel-nntp-summary.h index fb58cea75a..2aff4319e1 100644 --- a/camel/providers/nntp/camel-nntp-summary.h +++ b/camel/providers/nntp/camel-nntp-summary.h @@ -48,7 +48,7 @@ struct _CamelNNTPSummaryClass { }; CamelType camel_nntp_summary_get_type (void); -CamelNNTPSummary *camel_nntp_summary_new(const char *path); +CamelNNTPSummary *camel_nntp_summary_new(struct _CamelFolder *folder, const char *path); int camel_nntp_summary_check(CamelNNTPSummary *cns, struct _CamelNNTPStore *store, char *line, struct _CamelFolderChangeInfo *changes, struct _CamelException *ex); |