diff options
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 21 | ||||
-rw-r--r-- | mail/mail-callbacks.c | 31 | ||||
-rw-r--r-- | mail/mail-format.c | 3 | ||||
-rw-r--r-- | mail/mail-threads.c | 34 | ||||
-rw-r--r-- | mail/mail-threads.h | 7 | ||||
-rw-r--r-- | mail/message-list.c | 21 |
6 files changed, 100 insertions, 17 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index b410bf75cd..1d93dc62ee 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,24 @@ +2000-08-11 Peter Williams <peterw@helixcode.com> + + * mail-threads.c (mail_op_forward_event): New function that + writes a FORWARD_EVENT signal to the compipe, to allow Camel + events to be handled in the main thread. + (read_msg): Handle a FORWARD_EVENT. + + * mail-callbacks.c (select_first_unread): Forward the + event into the main thread to prevent the GTK calls in the + dispatcher thread. + (main_select_first_unread): New name of old select_first_unread. + + * message-list.c (folder_changed): Same as above. + (main_folder_changed): Same as above. + (message_changed): Same as above. + (main_message_changed): Same as above. + + + * mail-format.c (free_byte_array): Note about using + mail_op_forward_event. (cmm_destroyed): Same. + 2000-08-11 Dan Winship <danw@helixcode.com> * message-list.c (message_list_select): If the caller passes "-1" diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index 77143c9258..d67c9d90ad 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -69,7 +69,7 @@ check_configured (void) } static void -select_first_unread (CamelFolder *folder, gpointer event_data, gpointer data) +main_select_first_unread (CamelFolder *folder, gpointer event_data, gpointer data) { FolderBrowser *fb = FOLDER_BROWSER (data); ETable *table = E_TABLE_SCROLLED (fb->message_list->etable)->table; @@ -78,11 +78,16 @@ select_first_unread (CamelFolder *folder, gpointer event_data, gpointer data) 0, CAMEL_MESSAGE_SEEN); } +static void +select_first_unread (CamelFolder *folder, gpointer event_data, gpointer data) +{ + mail_op_forward_event (main_select_first_unread, folder, event_data, data); +} + void fetch_mail (GtkWidget *button, gpointer user_data) { - MailConfigService *source; - char *url = NULL; + GSList *sources; if (!check_configured ()) { GtkWidget *win = gtk_widget_get_ancestor (GTK_WIDGET (user_data), @@ -93,10 +98,9 @@ fetch_mail (GtkWidget *button, gpointer user_data) return; } - source = mail_config_get_default_source (); - url = source->url; + sources = mail_config_get_sources (); - if (!url) { + if (!sources || !sources->data) { GtkWidget *win = gtk_widget_get_ancestor (GTK_WIDGET (user_data), GTK_TYPE_WINDOW); @@ -105,7 +109,20 @@ fetch_mail (GtkWidget *button, gpointer user_data) return; } - mail_do_fetch_mail (url, source->keep_on_server, NULL, select_first_unread, user_data); + while (sources) { + MailConfigService *source; + + source = (MailConfigService *) sources->data; + sources = sources->next; + + if (!source || !source->url) { + g_warning ("Bad source in fetch_mail??"); + continue; + } + + mail_do_fetch_mail (source->url, source->keep_on_server, + NULL, select_first_unread, user_data); + } } static gboolean diff --git a/mail/mail-format.c b/mail/mail-format.c index b0f813610c..5ec2fe68b0 100644 --- a/mail/mail-format.c +++ b/mail/mail-format.c @@ -118,6 +118,8 @@ static void cmm_destroyed (CamelObject *cmm, gpointer event_data, gpointer user_ { GHashTable *ht; + /* We don't have to do a forward_event here right now. */ + g_return_if_fail (cmm); ht = g_hash_table_lookup (cmm_to_urls, cmm); @@ -807,6 +809,7 @@ try_inline_binhex (char *start, struct mail_format_data *mfd) static void free_byte_array (CamelObject *obj, gpointer event_data, gpointer user_data) { + /* We don't have to do a forward event here right now */ g_byte_array_free (user_data, TRUE); } diff --git a/mail/mail-threads.c b/mail/mail-threads.c index bdfa7b260f..7bd98a6912 100644 --- a/mail/mail-threads.c +++ b/mail/mail-threads.c @@ -26,6 +26,7 @@ #include <string.h> #include <glib.h> +#include "camel/camel-object.h" #include "mail.h" #include "mail-threads.h" @@ -68,6 +69,7 @@ typedef struct com_msg_s MESSAGE, PASSWORD, ERROR, + FORWARD_EVENT, FINISHED } type; gfloat percentage; @@ -79,6 +81,12 @@ typedef struct com_msg_s gchar **reply; gboolean secret; gboolean *success; + + /* Event stuff */ + CamelObjectEventHookFunc event_hook; + CamelObject *event_obj; + gpointer event_event_data; + gpointer event_user_data; } com_msg_t; @@ -484,6 +492,25 @@ mail_op_error (gchar * fmt, ...) } /** + * mail_op_forward_event: + * + * Communicate a camel event over to the main thread. + **/ + +void +mail_op_forward_event (CamelObjectEventHookFunc func, CamelObject *o, + gpointer event_data, gpointer user_data) +{ + com_msg_t msg; + + msg.type = FORWARD_EVENT; + msg.event_hook = func; + msg.event_obj = o; + msg.event_event_data = event_data; + msg.event_user_data = user_data; + write (MAIN_WRITER, &msg, sizeof (msg)); +} +/** * mail_operation_wait_for_finish: * * Waits for the currently executing async operations @@ -887,6 +914,13 @@ read_msg (GIOChannel * source, GIOCondition condition, gpointer userdata) * call for us */ + case FORWARD_EVENT: + DEBUG (("*** Message -- FORWARD_EVENT %p", msg->event_hook)); + + g_assert (msg->event_hook); + (msg->event_hook) (msg->event_obj, msg->event_event_data, msg->event_user_data); + break; + case FINISHED: DEBUG ( ("*** Message -- FINISH %s\n", diff --git a/mail/mail-threads.h b/mail/mail-threads.h index 1aeb486935..ab745c2ee3 100644 --- a/mail/mail-threads.h +++ b/mail/mail-threads.h @@ -26,6 +26,7 @@ #define _MAIL_THREADS_H_ #include <camel/camel-exception.h> +#include <camel/camel-object.h> #include <stdlib.h> /*size_t */ /* Returns a g_strdup'ed string that describes what's going to happen, @@ -54,12 +55,12 @@ gboolean mail_operation_queue (const mail_operation_spec * spec, void mail_op_set_percentage (gfloat percentage); void mail_op_hide_progressbar (void); void mail_op_show_progressbar (void); -void -mail_op_set_message (gchar * fmt, ...) G_GNUC_PRINTF (1, 2); +void mail_op_set_message (gchar * fmt, ...) G_GNUC_PRINTF (1, 2); void mail_op_error (gchar * fmt, ...) G_GNUC_PRINTF (1, 2); gboolean mail_op_get_password (gchar * prompt, gboolean secret, gchar ** dest); - +void mail_op_forward_event (CamelObjectEventHookFunc func, CamelObject *o, + gpointer event_data, gpointer user_data); /* Wait for the async operations to finish */ void mail_operation_wait_for_finish (void); gboolean mail_operations_are_executing (void); diff --git a/mail/message-list.c b/mail/message-list.c index a25c449174..3f63c55478 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -836,28 +836,35 @@ build_flat (MessageList *ml, ETreePath *parent, GPtrArray *uids) } static void -folder_changed (CamelObject *o, gpointer event_data, gpointer user_data) +main_folder_changed (CamelObject *o, gpointer event_data, gpointer user_data) { MessageList *message_list = MESSAGE_LIST (user_data); - GDK_THREADS_ENTER(); /* Very important!!!! */ + mail_do_regenerate_messagelist (message_list, message_list->search); - GDK_THREADS_LEAVE(); /* Very important!!!! */ } static void -message_changed (CamelObject *o, gpointer uid, gpointer user_data) +folder_changed (CamelObject *o, gpointer event_data, gpointer user_data) +{ + mail_op_forward_event (main_folder_changed, o, event_data, user_data); +} + +static void +main_message_changed (CamelObject *o, gpointer uid, gpointer user_data) { MessageList *message_list = MESSAGE_LIST (user_data); int row; - GDK_THREADS_ENTER(); /* Very important!!!! */ - row = GPOINTER_TO_INT (g_hash_table_lookup (message_list->uid_rowmap, uid)); if (row != -1) e_table_model_row_changed (message_list->table_model, row); +} - GDK_THREADS_LEAVE(); /* Very important!!!! */ +static void +message_changed (CamelObject *o, gpointer event_data, gpointer user_data) +{ + mail_op_forward_event (main_message_changed, o, event_data, user_data); } void |