aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-06-07 04:56:43 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-06-07 04:56:43 +0800
commite0a6088f3374aa60c176dcc058595c801d31351c (patch)
tree633e6d009b4042a8c32e8a2c5b345c1d23cf2ae9 /mail
parent2dd7e35afd3c0985aed13c80eb1f670c669a66aa (diff)
downloadgsoc2013-evolution-e0a6088f3374aa60c176dcc058595c801d31351c.tar.gz
gsoc2013-evolution-e0a6088f3374aa60c176dcc058595c801d31351c.tar.zst
gsoc2013-evolution-e0a6088f3374aa60c176dcc058595c801d31351c.zip
If this account is not a completely new account (ie, it is an edited
2002-06-06 Jeffrey Stedfast <fejj@ximian.com> * 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
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog10
-rw-r--r--mail/component-factory.c37
-rw-r--r--mail/mail-account-gui.c51
-rw-r--r--mail/mail.h1
4 files changed, 92 insertions, 7 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 89b47d9a49..449f891711 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,13 @@
+2002-06-06 Jeffrey Stedfast <fejj@ximian.com>
+
+ * 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.
+
2002-06-06 Radek Doulik <rodo@ximian.com>
* mail-composer-prefs.c (mail_composer_prefs_construct): disable
diff --git a/mail/component-factory.c b/mail/component-factory.c
index 668b1fef48..df4a08c9ae 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -1283,6 +1283,34 @@ add_storage (const char *name, const char *uri, CamelService *store,
}
}
+
+void
+mail_add_storage (CamelStore *store, const char *name, const char *uri)
+{
+ EvolutionShellClient *shell_client;
+ GNOME_Evolution_Shell shell;
+ CamelException ex;
+
+ g_return_if_fail (CAMEL_IS_STORE (store));
+
+ shell_client = evolution_shell_component_get_owner (shell_component);
+ shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client));
+
+ camel_exception_init (&ex);
+
+ if (name == NULL) {
+ char *service_name;
+
+ service_name = camel_service_get_name (store, TRUE);
+ add_storage (service_name, uri, store, shell, &ex);
+ g_free (service_name);
+ } else {
+ add_storage (name, uri, store, shell, &ex);
+ }
+
+ camel_exception_clear (&ex);
+}
+
void
mail_load_storage_by_uri (GNOME_Evolution_Shell shell, const char *uri, const char *name)
{
@@ -1338,7 +1366,8 @@ mail_load_storage_by_uri (GNOME_Evolution_Shell shell, const char *uri, const ch
camel_object_unref (CAMEL_OBJECT (store));
}
-/* FIXME: 'is_account_data' is an ugly hack, if we remove support for NNTP we can take it out -- fejj */
+/* FIXME: 'is_account_data' is an ugly hack, if we move support for
+ NNTP into the normal Account stuff, we can take it out -- fejj */
void
mail_load_storages (GNOME_Evolution_Shell shell, const GSList *sources, gboolean is_account_data)
{
@@ -1380,7 +1409,7 @@ mail_hash_storage (CamelService *store, EvolutionStorage *storage)
g_hash_table_insert (storages_hash, store, storage);
}
-EvolutionStorage*
+EvolutionStorage *
mail_lookup_storage (CamelStore *store)
{
EvolutionStorage *storage;
@@ -1423,7 +1452,7 @@ mail_remove_storage (CamelStore *store)
return;
g_hash_table_remove (storages_hash, store);
-
+
/* so i guess potentially we could have a race, add a store while one
being removed. ?? */
mail_note_store_remove(store);
@@ -1432,7 +1461,7 @@ mail_remove_storage (CamelStore *store)
corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client));
evolution_storage_deregister_on_shell (storage, corba_shell);
-
+
mail_async_event_emit(async_event, MAIL_ASYNC_THREAD, (MailAsyncFunc)store_disconnect, store, NULL, NULL);
}
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);
diff --git a/mail/mail.h b/mail/mail.h
index ce240153e0..ef8bedc952 100644
--- a/mail/mail.h
+++ b/mail/mail.h
@@ -71,6 +71,7 @@ char *mail_get_message_body (CamelDataWrapper *data, gboolean want_plain, gboole
char *mail_identify_mime_part (CamelMimePart *part, MailDisplay *md);
/* component factory for lack of a better place */
+void mail_add_storage (CamelStore *store, const char *name, const char *uri);
void mail_load_storage_by_uri (GNOME_Evolution_Shell shell, const char *uri, const char *name);
/*takes a GSList of MailConfigServices */
void mail_load_storages (GNOME_Evolution_Shell shell, const GSList *sources, gboolean is_account_data);