aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/em-folder-tree-model.c129
-rw-r--r--mail/mail-mt.c130
-rw-r--r--mail/mail-mt.h19
-rw-r--r--mail/message-list.c38
-rw-r--r--mail/message-list.h3
5 files changed, 30 insertions, 289 deletions
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index a7386b5471..aae547a23d 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -812,9 +812,9 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model,
}
static void
-folder_subscribed (CamelStore *store,
- CamelFolderInfo *fi,
- EMFolderTreeModel *model)
+folder_subscribed_cb (CamelStore *store,
+ CamelFolderInfo *fi,
+ EMFolderTreeModel *model)
{
EMFolderTreeModelStoreInfo *si;
GtkTreeRowReference *reference;
@@ -825,11 +825,11 @@ folder_subscribed (CamelStore *store,
si = em_folder_tree_model_lookup_store_info (model, store);
if (si == NULL)
- goto done;
+ return;
/* Make sure we don't already know about it? */
if (g_hash_table_lookup (si->full_hash, fi->full_name))
- goto done;
+ return;
/* Get our parent folder's path. */
dirname = g_alloca (strlen (fi->full_name)+1);
@@ -844,7 +844,7 @@ folder_subscribed (CamelStore *store,
}
if (!gtk_tree_row_reference_valid (reference))
- goto done;
+ return;
path = gtk_tree_row_reference_get_path (reference);
gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &parent, path);
@@ -855,38 +855,19 @@ folder_subscribed (CamelStore *store,
GTK_TREE_MODEL (model), &parent,
COL_BOOL_LOAD_SUBDIRS, &load, -1);
if (load)
- goto done;
+ return;
gtk_tree_store_append (GTK_TREE_STORE (model), &iter, &parent);
em_folder_tree_model_set_folder_info (model, &iter, si, fi, TRUE);
g_signal_emit (model, signals[FOLDER_ADDED], 0, fi->full_name, fi->uri);
-
-done:
- g_object_unref (store);
- camel_folder_info_free (fi);
-}
-
-static void
-folder_subscribed_cb (CamelStore *store,
- gpointer event_data,
- EMFolderTreeModel *model)
-{
- CamelFolderInfo *fi;
-
- g_object_ref (store);
- fi = camel_folder_info_clone (event_data);
-
- mail_async_event_emit (
- mail_async_event, (MailAsyncFunc)
- folder_subscribed, store, fi, model);
}
static void
-folder_unsubscribed (CamelStore *store,
- CamelFolderInfo *fi,
- EMFolderTreeModel *model)
+folder_unsubscribed_cb (CamelStore *store,
+ CamelFolderInfo *fi,
+ EMFolderTreeModel *model)
{
EMFolderTreeModelStoreInfo *si;
GtkTreeRowReference *reference;
@@ -895,76 +876,43 @@ folder_unsubscribed (CamelStore *store,
si = em_folder_tree_model_lookup_store_info (model, store);
if (si == NULL)
- goto done;
+ return;
reference = g_hash_table_lookup (si->full_hash, fi->full_name);
if (!gtk_tree_row_reference_valid (reference))
- goto done;
+ return;
path = gtk_tree_row_reference_get_path (reference);
gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
gtk_tree_path_free (path);
em_folder_tree_model_remove_folders (model, si, &iter);
-
-done:
- g_object_unref (store);
- camel_folder_info_free (fi);
-}
-
-static void
-folder_unsubscribed_cb (CamelStore *store,
- gpointer event_data,
- EMFolderTreeModel *model)
-{
- CamelFolderInfo *fi;
-
- g_object_ref (store);
- fi = camel_folder_info_clone (event_data);
-
- mail_async_event_emit (
- mail_async_event, (MailAsyncFunc)
- folder_unsubscribed, store, fi, model);
}
static void
folder_created_cb (CamelStore *store,
- gpointer event_data,
+ CamelFolderInfo *fi,
EMFolderTreeModel *model)
{
- CamelFolderInfo *fi;
-
/* We only want created events to do more
* work if we don't support subscriptions. */
if (camel_store_supports_subscriptions (store))
return;
- g_object_ref (store);
- fi = camel_folder_info_clone (event_data);
-
- mail_async_event_emit (
- mail_async_event, (MailAsyncFunc)
- folder_subscribed, store, fi, model);
+ folder_subscribed_cb (store, fi, model);
}
static void
folder_deleted_cb (CamelStore *store,
- gpointer event_data,
+ CamelFolderInfo *fi,
EMFolderTreeModel *model)
{
- CamelFolderInfo *fi;
-
/* We only want deleted events to do more
* work if we don't support subscriptions. */
if (camel_store_supports_subscriptions (store))
return;
- g_object_ref (store);
- fi = camel_folder_info_clone (event_data);
-
- mail_async_event_emit (
- mail_async_event, (MailAsyncFunc)
- folder_unsubscribed_cb, store, fi, model);
+ folder_unsubscribed_cb (store, fi, model);
}
typedef struct {
@@ -973,9 +921,10 @@ typedef struct {
} RenameInfo;
static void
-folder_renamed (CamelStore *store,
- RenameInfo *info,
- EMFolderTreeModel *model)
+folder_renamed_cb (CamelStore *store,
+ const gchar *old_name,
+ CamelFolderInfo *info,
+ EMFolderTreeModel *model)
{
EMFolderTreeModelStoreInfo *si;
GtkTreeRowReference *reference;
@@ -985,11 +934,11 @@ folder_renamed (CamelStore *store,
si = em_folder_tree_model_lookup_store_info (model, store);
if (si == NULL)
- goto done;
+ return;
- reference = g_hash_table_lookup (si->full_hash, info->old_base);
+ reference = g_hash_table_lookup (si->full_hash, old_name);
if (!gtk_tree_row_reference_valid (reference))
- goto done;
+ return;
path = gtk_tree_row_reference_get_path (reference);
gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
@@ -997,7 +946,7 @@ folder_renamed (CamelStore *store,
em_folder_tree_model_remove_folders (model, si, &iter);
- parent = g_strdup (info->new->full_name);
+ parent = g_strdup (info->full_name);
p = strrchr (parent, '/');
if (p)
*p = 0;
@@ -1010,40 +959,14 @@ folder_renamed (CamelStore *store,
g_free (parent);
if (!gtk_tree_row_reference_valid (reference))
- goto done;
+ return;
path = gtk_tree_row_reference_get_path (reference);
gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &root, path);
gtk_tree_path_free (path);
gtk_tree_store_append (GTK_TREE_STORE (model), &iter, &root);
- em_folder_tree_model_set_folder_info (model, &iter, si, info->new, TRUE);
-
-done:
- g_object_unref (store);
-
- g_free (info->old_base);
- camel_folder_info_free (info->new);
- g_free (info);
-}
-
-static void
-folder_renamed_cb (CamelStore *store,
- const gchar *old_name,
- CamelFolderInfo *info,
- EMFolderTreeModel *model)
-{
- RenameInfo *rinfo;
-
- g_object_ref (store);
-
- rinfo = g_new0 (RenameInfo, 1);
- rinfo->old_base = g_strdup (old_name);
- rinfo->new = camel_folder_info_clone (info);
-
- mail_async_event_emit (
- mail_async_event, (MailAsyncFunc)
- folder_renamed, store, rinfo, model);
+ em_folder_tree_model_set_folder_info (model, &iter, si, info, TRUE);
}
void
diff --git a/mail/mail-mt.c b/mail/mail-mt.c
index 45ab9a4df6..5a32e155fb 100644
--- a/mail/mail-mt.c
+++ b/mail/mail-mt.c
@@ -54,8 +54,6 @@ static GHashTable *mail_msg_active_table;
static GMutex *mail_msg_lock;
static GCond *mail_msg_cond;
-MailAsyncEvent *mail_async_event;
-
static void
mail_msg_cancelled (CamelOperation *operation,
gpointer user_data)
@@ -497,8 +495,6 @@ mail_msg_init (void)
mail_msg_active_table = g_hash_table_new (NULL, NULL);
main_thread = g_thread_self ();
-
- mail_async_event = mail_async_event_new ();
}
static gint
@@ -579,132 +575,6 @@ mail_in_main_thread (void)
/* ********************************************************************** */
-struct _proxy_msg {
- MailMsg base;
-
- MailAsyncEvent *ea;
-
- GThread *thread;
- guint idle_id;
-
- MailAsyncFunc func;
- gpointer o;
- gpointer event_data;
- gpointer data;
-};
-
-static void
-do_async_event (struct _proxy_msg *m)
-{
- m->thread = g_thread_self ();
- m->func (m->o, m->event_data, m->data);
- m->thread = NULL;
-
- g_mutex_lock (m->ea->lock);
- m->ea->tasks = g_slist_remove (m->ea->tasks, m);
- g_mutex_unlock (m->ea->lock);
-}
-
-static gint
-idle_async_event (struct _proxy_msg *m)
-{
- m->idle_id = 0;
- do_async_event (m);
- mail_msg_unref (m);
-
- return FALSE;
-}
-
-static MailMsgInfo async_event_info = {
- sizeof (struct _proxy_msg),
- (MailMsgDescFunc) NULL,
- (MailMsgExecFunc) do_async_event,
- (MailMsgDoneFunc) NULL,
- (MailMsgFreeFunc) NULL
-};
-
-MailAsyncEvent *
-mail_async_event_new (void)
-{
- MailAsyncEvent *ea;
-
- ea = g_malloc0 (sizeof (*ea));
- ea->lock = g_mutex_new ();
-
- return ea;
-}
-
-guint
-mail_async_event_emit (MailAsyncEvent *ea,
- MailAsyncFunc func,
- gpointer o,
- gpointer event_data,
- gpointer data)
-{
- struct _proxy_msg *m;
- guint id;
-
- /* We dont have a reply port for this, we dont
- * care when/if it gets executed, just queue it. */
- m = mail_msg_new (&async_event_info);
- m->func = func;
- m->o = o;
- m->event_data = event_data;
- m->data = data;
- m->ea = ea;
- m->thread = NULL;
-
- id = m->base.seq;
- g_mutex_lock (ea->lock);
- ea->tasks = g_slist_prepend (ea->tasks, m);
- g_mutex_unlock (ea->lock);
-
- /* We use an idle function instead of our own message port only
- * because the gui message ports's notification buffer might
- * overflow and deadlock us. */
- if (mail_in_main_thread ())
- m->idle_id = g_idle_add (
- (GSourceFunc) idle_async_event, m);
- else
- mail_msg_main_loop_push (m);
-
- return id;
-}
-
-gint
-mail_async_event_destroy (MailAsyncEvent *ea)
-{
- gint id;
- struct _proxy_msg *m;
-
- g_mutex_lock (ea->lock);
- while (ea->tasks) {
- m = ea->tasks->data;
- id = m->base.seq;
- if (m->thread == g_thread_self ()) {
- g_warning("Destroying async event from inside an event, returning EDEADLK");
- g_mutex_unlock (ea->lock);
- errno = EDEADLK;
- return -1;
- }
- if (m->idle_id > 0) {
- g_source_remove (m->idle_id);
- m->idle_id = 0;
- }
- g_mutex_unlock (ea->lock);
- mail_msg_wait (id);
- g_mutex_lock (ea->lock);
- }
- g_mutex_unlock (ea->lock);
-
- g_mutex_free (ea->lock);
- g_free (ea);
-
- return 0;
-}
-
-/* ********************************************************************** */
-
struct _call_msg {
MailMsg base;
diff --git a/mail/mail-mt.h b/mail/mail-mt.h
index 823f627b78..57b79ed5a4 100644
--- a/mail/mail-mt.h
+++ b/mail/mail-mt.h
@@ -83,21 +83,6 @@ void mail_msg_set_cancelable (gpointer msg, gboolean status);
gchar *mail_get_password (CamelService *service, const gchar *prompt,
gboolean secret, gboolean *cache);
-/* asynchronous event proxies */
-typedef struct _MailAsyncEvent {
- GMutex *lock;
- GSList *tasks;
-} MailAsyncEvent;
-
-typedef void (*MailAsyncFunc)(gpointer , gpointer , gpointer );
-
-/* create a new async event handler */
-MailAsyncEvent *mail_async_event_new (void);
-/* forward a camel event (or other call) to the gui thread */
-guint mail_async_event_emit (MailAsyncEvent *ea, MailAsyncFunc func, gpointer , gpointer , gpointer );
-/* wait for all outstanding async events to complete */
-gint mail_async_event_destroy (MailAsyncEvent *ea);
-
void mail_mt_set_backend (gchar *backend);
/* Call a function in the gui thread, wait for it to return, type is the marshaller to use */
@@ -114,8 +99,4 @@ typedef gpointer (*MailMainFunc)();
gpointer mail_call_main (mail_call_t type, MailMainFunc func, ...);
-/* A generic proxy event for anything that can be proxied during the life of the mailer (almost nothing) */
-/* Note that almost all objects care about the lifecycle of their events, so this cannot be used */
-extern MailAsyncEvent *mail_async_event;
-
#endif /* _MAIL_MT */
diff --git a/mail/message-list.c b/mail/message-list.c
index 3bd2413d32..eef110e3f0 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -2399,7 +2399,6 @@ message_list_init (MessageList *message_list)
message_list->ensure_uid = NULL;
message_list->uid_nodemap = g_hash_table_new (g_str_hash, g_str_equal);
- message_list->async_event = mail_async_event_new ();
message_list->cursor_uid = NULL;
message_list->last_sel_single = FALSE;
@@ -2438,11 +2437,6 @@ message_list_destroy (GtkObject *object)
p->destroyed = TRUE;
- if (message_list->async_event) {
- mail_async_event_destroy (message_list->async_event);
- message_list->async_event = NULL;
- }
-
if (message_list->folder) {
mail_regen_cancel (message_list);
@@ -3629,15 +3623,13 @@ mail_folder_hide_by_flag (CamelFolder *folder, MessageList *ml, CamelFolderChang
}
static void
-main_folder_changed (CamelObject *o, gpointer event_data, gpointer user_data)
+folder_changed (CamelFolder *folder,
+ CamelFolderChangeInfo *changes,
+ MessageList *ml)
{
- MessageList *ml = MESSAGE_LIST (user_data);
- CamelFolderChangeInfo *changes = (CamelFolderChangeInfo *)event_data;
- CamelFolder *folder = (CamelFolder *)o;
gint i;
- /* may be NULL if we're in the process of being destroyed */
- if (ml->async_event == NULL)
+ if (ml->priv->destroyed)
return;
d(printf("folder changed event, changes = %p\n", changes));
@@ -3675,28 +3667,6 @@ main_folder_changed (CamelObject *o, gpointer event_data, gpointer user_data)
mail_regen_list (ml, ml->search, NULL, changes);
}
-static void
-folder_changed (CamelFolder *folder,
- CamelFolderChangeInfo *info,
- MessageList *ml)
-{
- CamelFolderChangeInfo *changes;
-
- if (ml->priv->destroyed)
- return;
-
- if (info != NULL) {
- changes = camel_folder_change_info_new ();
- camel_folder_change_info_cat (changes, info);
- } else {
- changes = NULL;
- }
-
- mail_async_event_emit (
- ml->async_event, (MailAsyncFunc)
- main_folder_changed, folder, changes, ml);
-}
-
/**
* message_list_set_folder:
* @message_list: Message List widget
diff --git a/mail/message-list.h b/mail/message-list.h
index bf23ddf8eb..f8ac551279 100644
--- a/mail/message-list.h
+++ b/mail/message-list.h
@@ -159,9 +159,6 @@ struct _MessageList {
/* the current camel folder thread tree, if any */
CamelFolderThread *thread_tree;
-
- /* for message/folder chagned event handling */
- struct _MailAsyncEvent *async_event;
};
struct _MessageListClass {