[evolution/express2] Listen for account added signal from the EAccountList. Helps to refresh account while loading from t



commit 5b21823d0e5c5a6ad927a180fb9aa8b9419f6612
Author: Srinivasa Ragavan <sragavan gnome org>
Date:   Tue Apr 27 16:48:51 2010 +0530

    Listen for account added signal from the EAccountList. Helps to refresh
    account while loading from the capplet externally.

 mail/em-folder-tree-model.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index 3daacc5..b779caf 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -37,10 +37,13 @@
 
 #include <camel/camel-file-utils.h>
 
+#include "e-mail-store.h"
+
 #include "mail-config.h"
 #include "mail-session.h"
 #include "mail-tools.h"
 #include "mail-mt.h"
+#include "mail-ops.h"
 
 /* sigh, these 2 only needed for outbox total count checking - a mess */
 #include "mail-folder-cache.h"
@@ -80,6 +83,7 @@ struct _EMFolderTreeModelPrivate {
 
 	gulong account_changed_id;
 	gulong account_removed_id;
+	gulong account_added_id;
 };
 
 enum {
@@ -256,6 +260,26 @@ account_removed_cb (EAccountList *accounts,
 	em_folder_tree_model_remove_store (model, si->store);
 }
 
+/* HACK: FIXME: the component should listen to the account object directly */
+static void
+add_new_store (gchar *uri, CamelStore *store, gpointer user_data)
+{
+	EAccount *account = user_data;
+
+	if (store == NULL)
+		return;
+
+	e_mail_store_add (store, account->name);
+}
+
+static void
+account_added_cb (EAccountList *accounts,
+                    EAccount *account,
+                    EMFolderTreeModel *model)
+{
+	mail_get_store (e_account_get_string (account, E_ACCOUNT_SOURCE_URL), NULL, add_new_store, account);
+}
+
 static void
 folder_tree_model_selection_finalized_cb (EMFolderTreeModel *model)
 {
@@ -332,6 +356,8 @@ folder_tree_model_finalize (GObject *object)
 		priv->accounts, priv->account_changed_id);
 	g_signal_handler_disconnect (
 		priv->accounts, priv->account_removed_id);
+	g_signal_handler_disconnect (
+		priv->accounts, priv->account_added_id);
 
 	/* Chain up to parent's finalize() method. */
 	G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -512,6 +538,9 @@ folder_tree_model_init (EMFolderTreeModel *model)
 	model->priv->account_removed_id = g_signal_connect (
 		model->priv->accounts, "account-removed",
 		G_CALLBACK (account_removed_cb), model);
+	model->priv->account_added_id = g_signal_connect (
+		model->priv->accounts, "account-added",
+		G_CALLBACK (account_added_cb), model);
 
 	g_signal_connect (mail_folder_cache_get_default (),
 			  "folder-unread-updated",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]