diff options
author | Dan Winship <danw@src.gnome.org> | 2000-06-17 07:09:43 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2000-06-17 07:09:43 +0800 |
commit | 174d7c38d1ff4d1511301b1aa2effa87f7b6bc7f (patch) | |
tree | edcbfcf1e6244d1f30e28e7dca2c14c7715ace38 /camel/camel-mime-message.c | |
parent | f0600c2ccbfbd5378cdf980e2d53210c0101639d (diff) | |
download | gsoc2013-evolution-174d7c38d1ff4d1511301b1aa2effa87f7b6bc7f.tar gsoc2013-evolution-174d7c38d1ff4d1511301b1aa2effa87f7b6bc7f.tar.gz gsoc2013-evolution-174d7c38d1ff4d1511301b1aa2effa87f7b6bc7f.tar.bz2 gsoc2013-evolution-174d7c38d1ff4d1511301b1aa2effa87f7b6bc7f.tar.lz gsoc2013-evolution-174d7c38d1ff4d1511301b1aa2effa87f7b6bc7f.tar.xz gsoc2013-evolution-174d7c38d1ff4d1511301b1aa2effa87f7b6bc7f.tar.zst gsoc2013-evolution-174d7c38d1ff4d1511301b1aa2effa87f7b6bc7f.zip |
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
Diffstat (limited to 'camel/camel-mime-message.c')
-rw-r--r-- | camel/camel-mime-message.c | 168 |
1 files changed, 1 insertions, 167 deletions
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c index 5959e59933..0e78ca6912 100644 --- a/camel/camel-mime-message.c +++ b/camel/camel-mime-message.c @@ -1,5 +1,5 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*- */ -/* camelMimeMessage.c : class for a mime_message */ +/* camel-mime-message.c : class for a mime_message */ /* * Authors: Bertrand Guiheneuf <bertrand@helixcode.com> @@ -57,15 +57,6 @@ static char *recipient_names[] = { "To", "Cc", "Bcc", NULL }; -enum SIGNALS { - MESSAGE_CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -static void set_message_number (CamelMimeMessage *mime_message, guint number); -static guint get_message_number (CamelMimeMessage *mime_message); static int write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream); static void finalize (GtkObject *object); static void add_header (CamelMedium *medium, const char *header_name, const void *header_value); @@ -93,10 +84,6 @@ camel_mime_message_class_init (CamelMimeMessageClass *camel_mime_message_class) for (i=0;header_names[i];i++) g_hash_table_insert (header_name_table, header_names[i], (gpointer)i+1); - /* virtual method definition */ - camel_mime_message_class->set_message_number = set_message_number; - camel_mime_message_class->get_message_number = get_message_number; - /* virtual method overload */ camel_data_wrapper_class->write_to_stream = write_to_stream; @@ -106,16 +93,6 @@ camel_mime_message_class_init (CamelMimeMessageClass *camel_mime_message_class) camel_mime_part_class->construct_from_parser = construct_from_parser; - signals[MESSAGE_CHANGED] = - gtk_signal_new ("message_changed", - GTK_RUN_LAST, - gtk_object_class->type, - GTK_SIGNAL_OFFSET (CamelMimeMessageClass, message_changed), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - gtk_object_class_add_signals (gtk_object_class, signals, LAST_SIGNAL); - gtk_object_class->finalize = finalize; } @@ -135,13 +112,9 @@ camel_mime_message_init (gpointer object, gpointer klass) g_hash_table_insert(mime_message->recipients, recipient_names[i], camel_internet_address_new()); } - mime_message->user_flags = NULL; - mime_message->flags = 0; - mime_message->subject = NULL; mime_message->reply_to = NULL; mime_message->from = NULL; - mime_message->folder = NULL; mime_message->date = CAMEL_MESSAGE_DATE_CURRENT; mime_message->date_offset = 0; mime_message->date_str = NULL; @@ -188,16 +161,9 @@ finalize (GtkObject *object) g_free (message->reply_to); g_free (message->from); - g_free (message->message_uid); - g_hash_table_foreach (message->recipients, g_lib_is_uber_crappy_shit, NULL); g_hash_table_destroy(message->recipients); - camel_flag_list_free(&message->user_flags); - - if (message->folder) - gtk_object_unref (GTK_OBJECT (message->folder)); - GTK_OBJECT_CLASS (parent_class)->finalize (object); } @@ -421,138 +387,6 @@ camel_mime_message_get_recipients (CamelMimeMessage *mime_message, -/* **** */ - - -guint32 -camel_mime_message_get_flags (CamelMimeMessage *m) -{ - return m->flags; -} - -void -camel_mime_message_set_flags (CamelMimeMessage *m, guint32 flags, guint32 set) -{ - guint32 old; - - printf("%p setting flags %x mask %x\n", m, flags, set); - - old = m->flags; - m->flags = (m->flags & ~flags) | (set & flags); - - printf("old = %x new = %x\n", old, m->flags); - - if (old != m->flags) - gtk_signal_emit((GtkObject *)m, signals[MESSAGE_CHANGED], MESSAGE_FLAGS_CHANGED); -} - -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; -} - -gboolean -camel_mime_message_get_user_flag (CamelMimeMessage *m, const char *name) -{ - g_return_val_if_fail(m->flags & CAMEL_MESSAGE_USER, FALSE); - - return camel_flag_get(&m->user_flags, name); -} - -void -camel_mime_message_set_user_flag (CamelMimeMessage *m, const char *name, gboolean value) -{ - g_return_if_fail(m->flags & CAMEL_MESSAGE_USER); - - camel_flag_set(&m->user_flags, name, value); - gtk_signal_emit((GtkObject *)m, signals[MESSAGE_CHANGED], MESSAGE_FLAGS_CHANGED); -} - - - -/* FIXME: to be removed??? */ -static void -set_message_number (CamelMimeMessage *mime_message, guint number) -{ - mime_message->message_number = number; -} - -static guint -get_message_number (CamelMimeMessage *mime_message) -{ - return mime_message->message_number; -} - - - -guint -camel_mime_message_get_message_number (CamelMimeMessage *mime_message) -{ - return CMM_CLASS (mime_message)->get_message_number (mime_message); -} - /* mime_message */ static int construct_from_parser(CamelMimePart *dw, CamelMimeParser *mp) |