diff options
author | NotZed <NotZed@HelixCode.com> | 2000-05-02 03:47:12 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-05-02 03:47:12 +0800 |
commit | fed684880e2a47aaa0ee109bd8df0db1a5589c79 (patch) | |
tree | 548a551579178c78ea7f57a14e6f0d69ef57c1db /camel/camel-mime-message.c | |
parent | 0b889518d2fdfd0e296179bf581c7fbff4e5210e (diff) | |
download | gsoc2013-evolution-fed684880e2a47aaa0ee109bd8df0db1a5589c79.tar.gz gsoc2013-evolution-fed684880e2a47aaa0ee109bd8df0db1a5589c79.tar.zst gsoc2013-evolution-fed684880e2a47aaa0ee109bd8df0db1a5589c79.zip |
More message cleanup. Flags now work, are saved, and the delete
flag causes an expunge to expunge the deleted messages.
2000-05-01 NotZed <NotZed@HelixCode.com>
* providers/mbox/camel-mbox-summary.c
(camel_mbox_summary_set_flags_by_uid): New function to update the
flags in the summary.
(camel_mbox_summary_expunge): Expunge messages from a folder.
(offset_content): Re-align offsets of summary when messages
added/removed to an existing summary.
(camel_mbox_summary_remove_uid): Remove a message summary entry by
uid.
(index_folder): Restore flags from X-Evolution header, if they are set.
* providers/mbox/camel-mbox-folder.c (_get_message_by_uid):
Connect to the message_changed signal.
(_init): Set permanent flags to something reasonable. No user
flags yet ...
(message_changed): If the flags of the message change, update the
flags in the summary.
(mbox_expunge): Implement the expunge.
(camel_mbox_folder_class_init): Renamed all leading _'s to mbox_'s
* camel-folder.c (_finalize): Uh, dont free permanent_flags
anymore (this wouldn't failed anyway, it was a GList !!!)
* camel-folder.h (struct _CamelFolder): Change permanent_flags to
a bitfield.
(list_permanent_flags): Renamed to get_permanent_flags, and
returns a bitfield.
(camel_folder_expunge): Changed expunge to a void type. The
messages would no longer be useful after they have been removed
...
* camel-mime-message.c (set_flag): Removed.
(camel_mime_message_set_flag): Removed.
(get_flag): Removed.
(camel_mime_message_get_flag): Removed.
(add_flag_to_list): Removed.
(get_flag_list): Removed.
(camel_mime_message_get_flag_list): Removed.
(camel_mime_message_get_flags): New interface to get system flags.
(camel_mime_message_set_flags): " to set ".
(camel_mime_message_get_user_flag): To get a user flag.
(camel_mime_message_set_user_flag): To set a user flag.
(finalize): Hmm, the old one free'd the key and data, not good
when the data is a boolean ...
svn path=/trunk/; revision=2716
Diffstat (limited to 'camel/camel-mime-message.c')
-rw-r--r-- | camel/camel-mime-message.c | 121 |
1 files changed, 56 insertions, 65 deletions
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c index 39da00593a..c1cf13403a 100644 --- a/camel/camel-mime-message.c +++ b/camel/camel-mime-message.c @@ -58,10 +58,13 @@ static char *recipient_names[] = { "To", "Cc", "Bcc", NULL }; +enum SIGNALS { + MESSAGE_CHANGED, + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL] = { 0 }; -static void set_flag (CamelMimeMessage *mime_message, const gchar *flag, gboolean value); -static gboolean get_flag (CamelMimeMessage *mime_message, const gchar *flag); -static GList *get_flag_list (CamelMimeMessage *mime_message); 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); @@ -92,9 +95,6 @@ camel_mime_message_class_init (CamelMimeMessageClass *camel_mime_message_class) g_hash_table_insert (header_name_table, header_names[i], (gpointer)i+1); /* virtual method definition */ - camel_mime_message_class->set_flag = set_flag; - camel_mime_message_class->get_flag = get_flag; - camel_mime_message_class->get_flag_list = get_flag_list; camel_mime_message_class->set_message_number = set_message_number; camel_mime_message_class->get_message_number = get_message_number; @@ -107,6 +107,16 @@ 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; } @@ -126,7 +136,8 @@ camel_mime_message_init (gpointer object, gpointer klass) g_hash_table_insert(mime_message->recipients, recipient_names[i], camel_internet_address_new()); } - mime_message->flags = g_hash_table_new (g_strcase_hash, g_strcase_equal); + mime_message->user_flags = g_hash_table_new (g_strcase_hash, g_strcase_equal); + mime_message->flags = 0; mime_message->subject = NULL; mime_message->reply_to = NULL; @@ -168,6 +179,11 @@ static void g_lib_is_uber_crappy_shit(gpointer whocares, gpointer getlost, gpoin gtk_object_unref((GtkObject *)getlost); } +static void free_key_only(gpointer whocares, gpointer getlost, gpointer blah) +{ + g_free(whocares); +} + static void finalize (GtkObject *object) { @@ -179,13 +195,13 @@ finalize (GtkObject *object) g_free (message->from); g_hash_table_foreach (message->recipients, g_lib_is_uber_crappy_shit, NULL); + + if (message->user_flags) + g_hash_table_foreach (message->user_flags, free_key_only, NULL); + g_hash_table_destroy(message->user_flags); if (message->folder) gtk_object_unref (GTK_OBJECT (message->folder)); - - if (message->flags) - g_hash_table_foreach (message->flags, g_hash_table_generic_free, NULL); - g_hash_table_destroy(message->flags); GTK_OBJECT_CLASS (parent_class)->finalize (object); } @@ -413,81 +429,56 @@ camel_mime_message_get_recipients (CamelMimeMessage *mime_message, /* **** */ - -static void -set_flag (CamelMimeMessage *mime_message, const gchar *flag, gboolean value) +guint32 +camel_mime_message_get_flags (CamelMimeMessage *m) { - gchar *old_flags; - gboolean ptr_value; - - if (! g_hash_table_lookup_extended (mime_message->flags, - flag, - (gpointer)&(old_flags), - (gpointer)&(ptr_value)) ) { - - g_hash_table_insert (mime_message->flags, g_strdup (flag), GINT_TO_POINTER (value)); - } else - g_hash_table_insert (mime_message->flags, old_flags, GINT_TO_POINTER (value)); - + return m->flags; } void -camel_mime_message_set_flag (CamelMimeMessage *mime_message, const gchar *flag, gboolean value) +camel_mime_message_set_flags (CamelMimeMessage *m, guint32 flags, guint32 set) { - g_assert (mime_message); - g_return_if_fail (!mime_message->expunged); - CMM_CLASS (mime_message)->set_flag (mime_message, flag, value); -} + guint32 old; + printf("%p setting flags %x mask %x\n", m, flags, set); + old = m->flags; + m->flags = (m->flags & ~flags) | (set & flags); -static gboolean -get_flag (CamelMimeMessage *mime_message, const gchar *flag) -{ - return GPOINTER_TO_INT (g_hash_table_lookup (mime_message->flags, flag)); -} + printf("old = %x new = %x\n", old, m->flags); -gboolean -camel_mime_message_get_flag (CamelMimeMessage *mime_message, const gchar *flag) -{ - g_assert (mime_message); - g_return_val_if_fail (!mime_message->expunged, FALSE); - return CMM_CLASS (mime_message)->get_flag (mime_message, flag); + if (old != m->flags) + gtk_signal_emit((GtkObject *)m, signals[MESSAGE_CHANGED], MESSAGE_FLAGS_CHANGED); } - - -static void -add_flag_to_list (gpointer key, gpointer value, gpointer user_data) +gboolean +camel_mime_message_get_user_flag (CamelMimeMessage *m, const char *name) { - GList **flag_list = (GList **)user_data; - gchar *flag_name = (gchar *)key; - - if ((flag_name) && (flag_name[0] != '\0')) - *flag_list = g_list_append (*flag_list, flag_name); + return (gboolean)g_hash_table_lookup(m->user_flags, name); } -static GList * -get_flag_list (CamelMimeMessage *mime_message) +void +camel_mime_message_set_user_flag (CamelMimeMessage *m, const char *name, gboolean value) { - GList *flag_list = NULL; - - if (mime_message->flags) - g_hash_table_foreach (mime_message->flags, add_flag_to_list, &flag_list); - return flag_list; -} + gboolean there; + char *oldname; + gboolean oldvalue; + there = g_hash_table_lookup_extended(m->user_flags, name, &oldname, &oldvalue); -GList * -camel_mime_message_get_flag_list (CamelMimeMessage *mime_message) -{ - g_assert (mime_message); - g_return_val_if_fail (!mime_message->expunged, NULL); - return CMM_CLASS (mime_message)->get_flag_list (mime_message); + if (value && !there) { + g_hash_table_insert(m->user_flags, g_strdup(name), (void *)TRUE); + gtk_signal_emit((GtkObject *)m, signals[MESSAGE_CHANGED], MESSAGE_FLAGS_CHANGED); + } else if (there) { + g_hash_table_remove(m->user_flags, name); + g_free(oldname); + 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) { |