From a2d2fa53ef98e33fb45aeda6be10189f0ac298a9 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Wed, 16 Jun 2004 07:11:20 +0000 Subject: ** See #56479. 2004-06-16 Not Zed ** See #56479. * em-utils.c (em_utils_in_addressbook): use the main thread to setup the addressbook list. (em_utils_in_addressbook): only check against the "completion" sources, not all of them. 2004-06-15 Not Zed * em-folder-browser.c (emfb_mail_stop): call mail_cancel_all to implement the stop button. * em-utils.c (emu_addr_sources_refresh): don't unref the group list, otherwise the sources become broken now (?). (em_utils_in_addressbook): add some locking. add cancellation. this is almost certainly going to cause issues. * mail-mt.c (mail_cancel_hook_add, mail_cancel_hook_remove) (mail_cancel_all): new functions to implement a global mailer stop button. svn path=/trunk/; revision=26363 --- mail/mail-mt.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'mail/mail-mt.c') diff --git a/mail/mail-mt.c b/mail/mail-mt.c index 1581d283bb..457fd4c43f 100644 --- a/mail/mail-mt.c +++ b/mail/mail-mt.c @@ -352,6 +352,60 @@ void mail_msg_wait_all(void) } } +/* **************************************** */ +struct _cancel_hook_data { + struct _cancel_hook_data *next; + struct _cancel_hook_data *prev; + + GDestroyNotify func; + void *data; +}; + +static EDList cancel_hook_list = E_DLIST_INITIALISER(cancel_hook_list); + +void *mail_cancel_hook_add(GDestroyNotify func, void *data) +{ + struct _cancel_hook_data *d; + + d = g_malloc0(sizeof(*d)); + d->func = func; + d->data = data; + + MAIL_MT_LOCK(mail_msg_lock); + e_dlist_addtail(&cancel_hook_list, (EDListNode *)d); + MAIL_MT_UNLOCK(mail_msg_lock); + + return (void *)d; +} + +void mail_cancel_hook_remove(void *handle) +{ + struct _cancel_hook_data *d = handle; + + MAIL_MT_LOCK(mail_msg_lock); + e_dlist_remove((EDListNode *)d); + MAIL_MT_UNLOCK(mail_msg_lock); + g_free(d); +} + +void mail_cancel_all(void) +{ + struct _cancel_hook_data *d, *n; + + camel_operation_cancel(NULL); + + /* I can ssee a deadlock coming on ... */ + MAIL_MT_LOCK(mail_msg_lock); + d = (struct _cancel_hook_data *)cancel_hook_list.head; + n = d->next; + while (n) { + d->func(d->data); + d = n; + n = n->next; + } + MAIL_MT_UNLOCK(mail_msg_lock); +} + EMsgPort *mail_gui_port; static GIOChannel *mail_gui_channel; static guint mail_gui_watch; -- cgit v1.2.3