aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog18
-rw-r--r--mail/em-folder-tree-model.c68
-rw-r--r--mail/em-folder-tree-model.h14
-rw-r--r--mail/mail-account-gui.c23
4 files changed, 103 insertions, 20 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 2b758dc489..c78512df1e 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,23 @@
2004-01-30 Jeffrey Stedfast <fejj@ximian.com>
+ Fixes for bug #53348
+
+ * mail-account-gui.c (mail_account_gui_save): Only add the new
+ store to the mail-component if the mail-component doesn't already
+ know about it (ie. only if we are adding a new account).
+
+ * em-folder-tree-model.c (em_folder_tree_model_add_store): Hash
+ our store-info based on account here.
+ (em_folder_tree_model_init): Listen for
+ account_changed/account_removed signals.
+ (em_folder_tree_model_finalize): Disconnect above handlers.
+ (account_changed): Tear down the account store node and replace it
+ with the new store (assuming it belongs in the tree after the
+ changes).
+ (account_removed): Remove the account store from the tree.
+
+2004-01-30 Jeffrey Stedfast <fejj@ximian.com>
+
* em-folder-tree.c (emft_tree_row_expanded): Get recursive folder
listing (needed or folders that have as-of-yet-unloaded-subfolders
that contain unread mail will not be bolded). Fixes bug #51045.
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index e9f8493974..5c7ca7333e 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -100,6 +100,8 @@ static void em_folder_tree_model_finalize (GObject *obj);
static void tree_model_iface_init (GtkTreeModelIface *iface);
static void tree_sortable_iface_init (GtkTreeSortableIface *iface);
+static void account_changed (EAccountList *accounts, EAccount *account, gpointer user_data);
+static void account_removed (EAccountList *accounts, EAccount *account, gpointer user_data);
enum {
LOADING_ROW,
@@ -261,6 +263,11 @@ em_folder_tree_model_init (EMFolderTreeModel *model)
model->expanded = g_hash_table_new (g_str_hash, g_str_equal);
gtk_tree_sortable_set_default_sort_func ((GtkTreeSortable *) model, sort_cb, NULL, NULL);
+
+ model->accounts = mail_config_get_accounts ();
+ model->account_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
+ model->account_changed_id = g_signal_connect (model->accounts, "account-changed", G_CALLBACK (account_changed), model);
+ model->account_removed_id = g_signal_connect (model->accounts, "account-removed", G_CALLBACK (account_removed), model);
}
static void
@@ -322,6 +329,10 @@ em_folder_tree_model_finalize (GObject *obj)
g_hash_table_foreach (model->expanded, (GHFunc) expanded_free, NULL);
g_hash_table_destroy (model->expanded);
+ g_hash_table_destroy (model->account_hash);
+ g_signal_handler_disconnect (model->accounts, model->account_changed_id);
+ g_signal_handler_disconnect (model->accounts, model->account_removed_id);
+
g_free (model->filename);
G_OBJECT_CLASS (parent_class)->finalize (obj);
@@ -379,6 +390,56 @@ em_folder_tree_model_new (const char *evolution_dir)
}
+static void
+account_changed (EAccountList *accounts, EAccount *account, gpointer user_data)
+{
+ EMFolderTreeModel *model = user_data;
+ struct _EMFolderTreeModelStoreInfo *si;
+ CamelProvider *provider;
+ CamelStore *store;
+ CamelException ex;
+ char *uri;
+
+ if (!(si = g_hash_table_lookup (model->account_hash, account)))
+ return;
+
+ em_folder_tree_model_remove_store (model, si->store);
+
+ if (!(uri = account->source->url))
+ return;
+
+ camel_exception_init (&ex);
+ if (!(provider = camel_session_get_provider (session, uri, &ex))) {
+ camel_exception_clear (&ex);
+ return;
+ }
+
+ /* make sure the new store belongs in the tree */
+ if (!(provider->flags & CAMEL_PROVIDER_IS_STORAGE))
+ return;
+
+ if (!(store = (CamelStore *) camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, &ex))) {
+ camel_exception_clear (&ex);
+ return;
+ }
+
+ em_folder_tree_model_add_store (model, store, account->name);
+ camel_object_unref (store);
+}
+
+static void
+account_removed (EAccountList *accounts, EAccount *account, gpointer user_data)
+{
+ EMFolderTreeModel *model = user_data;
+ struct _EMFolderTreeModelStoreInfo *si;
+
+ if (!(si = g_hash_table_lookup (model->account_hash, account)))
+ return;
+
+ em_folder_tree_model_remove_store (model, si->store);
+}
+
+
void
em_folder_tree_model_set_folder_info (EMFolderTreeModel *model, GtkTreeIter *iter,
struct _EMFolderTreeModelStoreInfo *si,
@@ -665,6 +726,7 @@ em_folder_tree_model_add_store (EMFolderTreeModel *model, CamelStore *store, con
GtkTreeRowReference *row;
GtkTreeIter root, iter;
GtkTreePath *path;
+ EAccount *account;
char *uri;
g_return_if_fail (EM_IS_FOLDER_TREE_MODEL (model));
@@ -676,6 +738,8 @@ em_folder_tree_model_add_store (EMFolderTreeModel *model, CamelStore *store, con
uri = camel_url_to_string (((CamelService *) store)->url, CAMEL_URL_HIDE_ALL);
+ account = mail_config_get_account_by_source_url (uri);
+
/* add the store to the tree */
gtk_tree_store_append ((GtkTreeStore *) model, &iter, NULL);
gtk_tree_store_set ((GtkTreeStore *) model, &iter,
@@ -694,9 +758,11 @@ em_folder_tree_model_add_store (EMFolderTreeModel *model, CamelStore *store, con
si->display_name = g_strdup (display_name);
camel_object_ref (store);
si->store = store;
+ si->account = account;
si->row = row;
si->path_hash = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (model->store_hash, store, si);
+ g_hash_table_insert (model->account_hash, account, si);
/* each store has folders... but we don't load them until the user demands them */
root = iter;
@@ -750,6 +816,7 @@ em_folder_tree_model_remove_store_info (EMFolderTreeModel *model, CamelStore *st
return;
g_hash_table_remove (model->store_hash, si->store);
+ g_hash_table_remove (model->account_hash, si->account);
store_info_free (si);
}
@@ -1417,4 +1484,3 @@ em_folder_tree_model_set_drag_drop_types (EMFolderTreeModel *model, GtkWidget *w
gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_ALL, drop_types,
NUM_DROP_TYPES, GDK_ACTION_COPY | GDK_ACTION_MOVE);
}
-
diff --git a/mail/em-folder-tree-model.h b/mail/em-folder-tree-model.h
index fb0f54a9f0..2dbe7a2a5b 100644
--- a/mail/em-folder-tree-model.h
+++ b/mail/em-folder-tree-model.h
@@ -29,6 +29,8 @@
#include <camel/camel-store.h>
+#include <e-util/e-account-list.h>
+
#ifdef __cplusplus
extern "C" {
#pragma }
@@ -65,6 +67,7 @@ struct _EMFolderTreeModelStoreInfo {
CamelStore *store;
GtkTreeRowReference *row;
GHashTable *path_hash; /* maps CamelFolderInfo::path's to GtkTreeRowReferences */
+ EAccount *account;
char *display_name;
@@ -80,9 +83,14 @@ struct _EMFolderTreeModel {
char *filename; /* state filename */
- GHashTable *store_hash; /* maps CamelStore's to store-info's */
- GHashTable *uri_hash; /* maps URI's to GtkTreeRowReferences */
- GHashTable *expanded; /* saved expanded state from previous session */
+ GHashTable *store_hash; /* maps CamelStore's to store-info's */
+ GHashTable *uri_hash; /* maps URI's to GtkTreeRowReferences */
+ GHashTable *expanded; /* saved expanded state from previous session */
+
+ EAccountList *accounts;
+ GHashTable *account_hash; /* maps accounts to store-info's */
+ gulong account_changed_id;
+ gulong account_removed_id;
};
struct _EMFolderTreeModelClass {
diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c
index b24ac827d5..6e35041438 100644
--- a/mail/mail-account-gui.c
+++ b/mail/mail-account-gui.c
@@ -2046,15 +2046,6 @@ mail_account_gui_save (MailAccountGui *gui)
if (!mail_config_find_account (account)) {
/* this is a new account so add it to our account-list */
is_new = TRUE;
- } else if (account->source->url) {
- /* this means the account was edited - if the old and
- new source urls are not identical, replace the old
- store with the new store */
-#define sources_equal(old,new) (new->url && !strcmp (old->url, new->url))
- if (!sources_equal (account->source, new->source)) {
- /* Remove the old store from the folder-tree */
- mail_component_remove_store_by_uri (mail_component_peek (), account->source->url);
- }
}
/* update the old account with the new settings */
@@ -2063,17 +2054,17 @@ mail_account_gui_save (MailAccountGui *gui)
if (is_new) {
mail_config_add_account (account);
+
+ /* if the account provider is something we can stick
+ in the folder-tree and not added by some other
+ component, then get the CamelStore and add it to
+ the folder-tree */
+ if (is_storage && account->enabled)
+ mail_get_store (account->source->url, NULL, add_new_store, account);
} else {
e_account_list_change (mail_config_get_accounts (), account);
}
- /* if the account provider is something we can stick
- in the folder-tree and not added by some other
- component, then get the CamelStore and add it to
- the folder-tree */
- if (is_storage && account->enabled)
- mail_get_store (account->source->url, NULL, add_new_store, account);
-
if (gtk_toggle_button_get_active (gui->default_account))
mail_config_set_default_account (account);