From 174d7c38d1ff4d1511301b1aa2effa87f7b6bc7f Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 16 Jun 2000 23:09:43 +0000 Subject: Move flag handling from CamelMimeMessage to CamelFolder. This simplifies several flag-handling pieces of code in the mailer, and lets you change a message's flags without having to fetch the message body. It also means that fully-constructed CamelMimeMessages are now essentially constant, which will help simplify locking issues later since it means two threads interested in the same message can just work with separate copies of it. * camel-mime-message.h (struct _CamelMimeMessage): Removed flags and user_flags (moved to summary). Removed expunged and message_number which were unused. Removed message_uid and folder which are no longer needed in the new scheme. (struct CamelMimeMessageClass): Removed message_changed signal and get/set_message_number methods. * camel-mime-message.c: Updates for CamelMimeMessage changes. (camel_mime_message_get/set_flags, camel_mime_message_get/set_user_flag): Replaced with methods in CamelFolder. (camel_flag_get, camel_flag_set, camel_flag_list_size, camel_flag_list_free): Moved verbatim to camel-folder-summary.c * camel-folder.c (camel_folder_get/set_message_flags, camel_folder_get/set_message_user_flag): New methods (and corresponding useless default implementations) (camel_folder_class_init): add a message_changed signal * camel-folder-summary.c (camel_flag_get, camel_flag_set, camel_flag_list_size, camel_flag_list_free): Moved here from camel-mime-message.c * providers/mbox/camel-mbox-folder.c (message_changed): Removed. (mbox_get_message_flags, mbox_set_message_flags, mbox_get_message_user_flag, mbox_set_message_user_flag): Tweak summary bits as appropriate. (Functionality moved here from message_changed.) (mbox_get_message_by_uid): Update for CamelMimeMessage changes (less stuff to initialize). * providers/imap/camel-imap-folder.c (message_changed): Remove this. It was just copied from the mbox provider and doesn't deal with the real IMAP flag stuff anyway. (So there's currently no flag support in the IMAP provider.) (imap_get_message_by_uid): Update for CamelMimeMessage changes. * providers/vee/camel-vee-folder.c: (message_changed): Remove old one. Add a new one to listen for message_changed on each folder and re-emit message_changed signals that correspond to messages in the vfolder. (vee_get/set_message_flags, vee_get/set_message_user_flag): Proxy flag setting to the underlying real messages. (vee_append_message): Removed for now; there's no way to translate this into the new CamelMimeMessage/CamelFolder scheme, but (a) there's also no code which would ever call it and (b) we're probably going want a better interface than append_message for message drag and drop to work anyway. To be revisited. svn path=/trunk/; revision=3598 --- camel/camel-folder-summary.c | 71 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) (limited to 'camel/camel-folder-summary.c') diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c index 26b7f2e413..d13d9da333 100644 --- a/camel/camel-folder-summary.c +++ b/camel/camel-folder-summary.c @@ -1300,6 +1300,75 @@ summary_build_content_info(CamelFolderSummary *s, CamelMimeParser *mp) return info; } +gboolean +camel_flag_get(CamelFlag **list, const char *name) +{ + CamelFlag *flag; + flag = *list; + while (flag) { + if (!strcmp(flag->name, name)) + return TRUE; + flag = flag->next; + } + return FALSE; +} + +void +camel_flag_set(CamelFlag **list, const char *name, gboolean value) +{ + CamelFlag *flag, *tmp; + + /* this 'trick' works because flag->next is the first element */ + flag = (CamelFlag *)list; + while (flag->next) { + tmp = flag->next; + if (!strcmp(flag->next->name, name)) { + if (!value) { + flag->next = tmp->next; + g_free(tmp); + } + return; + } + flag = tmp; + } + + if (value) { + tmp = g_malloc(sizeof(*tmp) + strlen(name)); + strcpy(tmp->name, name); + tmp->next = 0; + flag->next = tmp; + } +} + +int +camel_flag_list_size(CamelFlag **list) +{ + int count=0; + CamelFlag *flag; + + flag = *list; + while (flag) { + count++; + flag = flag->next; + } + return count; +} + +void +camel_flag_list_free(CamelFlag **list) +{ + CamelFlag *flag, *tmp; + flag = *list; + while (flag) { + tmp = flag->next; + g_free(flag); + flag = tmp; + } + *list = NULL; +} + + +#if 0 static void content_info_dump(CamelMessageContentInfo *ci, int depth) { @@ -1341,8 +1410,6 @@ message_info_dump(CamelMessageInfo *mi) content_info_dump(mi->content, 0); } - -#if 0 int main(int argc, char **argv) { CamelMimeParser *mp; -- cgit