From e0a6088f3374aa60c176dcc058595c801d31351c Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 6 Jun 2002 20:56:43 +0000 Subject: If this account is not a completely new account (ie, it is an edited 2002-06-06 Jeffrey Stedfast * mail-account-gui.c (mail_account_gui_save): If this account is not a completely new account (ie, it is an edited account), then remove any trace of it from the shell storages. If the new account belongs in the folder-tree, add it to the list of storages. * component-factory.c (mail_add_storage): New function to add a single storage. svn path=/trunk/; revision=17138 --- mail/mail-account-gui.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) (limited to 'mail/mail-account-gui.c') diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c index 80b27b0ff0..914b7d1cdf 100644 --- a/mail/mail-account-gui.c +++ b/mail/mail-account-gui.c @@ -39,6 +39,8 @@ #include "mail-send-recv.h" #include "mail-signature-editor.h" #include "mail-composer-prefs.h" +#include "mail-ops.h" +#include "mail.h" #define d(x) @@ -1765,11 +1767,32 @@ save_service (MailAccountGuiService *gsvc, GHashTable *extra_config, camel_url_free (url); } + +static void +add_new_store (char *uri, CamelStore *store, void *user_data) +{ + MailConfigAccount *account = user_data; + EvolutionStorage *storage; + + if (store == NULL) + return; + + storage = mail_lookup_storage (store); + if (storage) { + /* store is already in the folder tree, no need to fret... */ + bonobo_object_unref (BONOBO_OBJECT (storage)); + return; + } + + /* store is *not* in the folder tree, so lets add it. */ + mail_add_storage (store, account->name, account->source->url); +} + gboolean mail_account_gui_save (MailAccountGui *gui) { MailConfigAccount *account = gui->account; - const MailConfigAccount *old_account; + MailConfigAccount *old_account; CamelProvider *provider = NULL; CamelURL *source_url = NULL, *url; char *new_name; @@ -1786,7 +1809,7 @@ mail_account_gui_save (MailAccountGui *gui) * here. */ new_name = e_utf8_gtk_entry_get_text (gui->account_name); - old_account = mail_config_get_account_by_name (new_name); + old_account = (MailConfigAccount *) mail_config_get_account_by_name (new_name); if (old_account && old_account != account) { e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, @@ -1794,6 +1817,9 @@ mail_account_gui_save (MailAccountGui *gui) return FALSE; } + /* make a copy of the old account for later use... */ + old_account = account_copy (account); + g_free (account->name); account->name = new_name; @@ -1882,8 +1908,27 @@ mail_account_gui_save (MailAccountGui *gui) account->smime_always_sign = gtk_toggle_button_get_active (gui->smime_always_sign); #endif /* HAVE_NSS && SMIME_SUPPORTED */ - if (!mail_config_find_account (account)) + if (!mail_config_find_account (account)) { + /* this is a new account so it it to our account-list */ mail_config_add_account (account); + } else if (old_account->source && old_account->source->url) { + /* this means the account was edited */ + + /* remove the old store from the folder-tree as it is probably no longer valid */ + mail_remove_storage_by_uri (old_account->source->url); + } + + /* destroy the copy of the old account */ + account_destroy (old_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 shell storages */ + if (provider && (provider->flags & CAMEL_PROVIDER_IS_STORAGE) && + !(provider->flags & CAMEL_PROVIDER_IS_EXTERNAL)) + mail_get_store (account->source->url, add_new_store, account); + if (gtk_toggle_button_get_active (gui->default_account)) mail_config_set_default_account (account); -- cgit