aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog23
-rw-r--r--mail/component-factory.c143
-rw-r--r--mail/mail-accounts.c35
-rw-r--r--mail/mail-config-druid.c5
-rw-r--r--mail/mail.h2
5 files changed, 127 insertions, 81 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 778273d447..f28576dddc 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,26 @@
+2001-08-08 Peter Williams <peterw@ximian.com>
+
+ * component-factory.c (mail_load_storages): Don't load the storage
+ if it isn't enabled.
+ (mail_remove_storage_by_uri): New function. Goes through the
+ gymnastics of getting a CamelStore from the URI and calling
+ mail_remove_storage. Copied from mail_delete().
+ (mail_load_storage_by_uri): Break out the storage-loading part of
+ mail_load_storages into a single function.
+ (mail_load_storages): Just call mail_load_storage_by_uri several
+ times.
+
+ * mail.h: Prototype our new _by_uri functions.
+
+ * mail-accounts.c (news_add_destroyed): Instead of hacking around
+ mail_load_storages, call mail_load_storage_by_uri.
+ (mail_delete): Move this chunk of code into
+ mail_remove_storage_by_uri.
+ (mail_able): Add or remove the storage as necessary, with our
+ new _by_uri functions.
+
+ * mail-config-druid.c (druid_finish): See news_add_destroyed above.
+
2001-08-10 Jeffrey Stedfast <fejj@ximian.com>
* mail-config.c (mail_config_get_show_preview): Free dbkey if we
diff --git a/mail/component-factory.c b/mail/component-factory.c
index 41cd6db365..0fd451be5f 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -896,6 +896,70 @@ add_storage (const char *name, const char *uri, CamelService *store,
}
}
+void
+mail_load_storage_by_uri (GNOME_Evolution_Shell shell, const char *uri, const char *name)
+{
+ CamelException ex;
+ CamelService *store;
+ CamelProvider *prov;
+
+ camel_exception_init (&ex);
+
+ /* Load the service (don't connect!). Check its provider and
+ * see if this belongs in the shell's folder list. If so, add
+ * it.
+ */
+
+ prov = camel_session_get_provider (session, uri, &ex);
+ if (prov == NULL) {
+ /* FIXME: real error dialog */
+ g_warning ("couldn't get service %s: %s\n", uri,
+ camel_exception_get_description (&ex));
+ camel_exception_clear (&ex);
+ return;
+ }
+
+ /* FIXME: this case is ambiguous for things like the
+ * mbox provider, which can really be a spool
+ * (/var/spool/mail/user) or a storage (~/mail/, eg).
+ * That issue can't be resolved on the provider level
+ * -- it's a per-URL problem.
+ * MPZ Added a hack to let spool protocol through temporarily ...
+ */
+ if ((!(prov->flags & CAMEL_PROVIDER_IS_STORAGE) ||
+ !(prov->flags & CAMEL_PROVIDER_IS_REMOTE))
+ && !((strcmp(prov->protocol, "spool") == 0)
+ || strcmp(prov->protocol, "maildir") == 0))
+ return;
+
+ store = camel_session_get_service (session, uri,
+ CAMEL_PROVIDER_STORE, &ex);
+ if (store == NULL) {
+ /* FIXME: real error dialog */
+ g_warning ("couldn't get service %s: %s\n", uri,
+ camel_exception_get_description (&ex));
+ camel_exception_clear (&ex);
+ return;
+ }
+
+ 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);
+
+ if (camel_exception_is_set (&ex)) {
+ /* FIXME: real error dialog */
+ g_warning ("Cannot load storage: %s",
+ camel_exception_get_description (&ex));
+ camel_exception_clear (&ex);
+ }
+
+ 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 */
void
@@ -914,68 +978,21 @@ mail_load_storages (GNOME_Evolution_Shell shell, const GSList *sources, gboolean
for (iter = sources; iter; iter = iter->next) {
const MailConfigAccount *account = NULL;
const MailConfigService *service = NULL;
- CamelService *store;
- CamelProvider *prov;
char *name;
if (is_account_data) {
account = iter->data;
service = account->source;
+ name = account->name;
} else {
service = iter->data;
+ name = NULL;
}
- if (service->url == NULL || service->url[0] == '\0')
+ if (service->url == NULL || service->url[0] == '\0' || !service->enabled)
continue;
- prov = camel_session_get_provider (session, service->url, &ex);
- if (prov == NULL) {
- /* FIXME: real error dialog */
- g_warning ("couldn't get service %s: %s\n", service->url,
- camel_exception_get_description (&ex));
- camel_exception_clear (&ex);
- continue;
- }
-
- /* FIXME: this case is ambiguous for things like the
- * mbox provider, which can really be a spool
- * (/var/spool/mail/user) or a storage (~/mail/, eg).
- * That issue can't be resolved on the provider level
- * -- it's a per-URL problem.
- * MPZ Added a hack to let spool protocol through temporarily ...
- */
- if ((!(prov->flags & CAMEL_PROVIDER_IS_STORAGE) ||
- !(prov->flags & CAMEL_PROVIDER_IS_REMOTE))
- && !((strcmp(prov->protocol, "spool") == 0)
- || strcmp(prov->protocol, "maildir") == 0))
- continue;
-
- store = camel_session_get_service (session, service->url,
- CAMEL_PROVIDER_STORE, &ex);
- if (store == NULL) {
- /* FIXME: real error dialog */
- g_warning ("couldn't get service %s: %s\n", service->url,
- camel_exception_get_description (&ex));
- camel_exception_clear (&ex);
- continue;
- }
-
- if (is_account_data)
- name = g_strdup (account->name);
- else
- name = camel_service_get_name (store, TRUE);
-
- add_storage (name, service->url, store, shell, &ex);
- g_free (name);
-
- if (camel_exception_is_set (&ex)) {
- /* FIXME: real error dialog */
- g_warning ("Cannot load storage: %s",
- camel_exception_get_description (&ex));
- camel_exception_clear (&ex);
- }
-
- camel_object_unref (CAMEL_OBJECT (store));
+ mail_load_storage_by_uri (shell, service->url, name);
}
}
@@ -1029,6 +1046,30 @@ mail_remove_storage (CamelStore *store)
camel_object_unref (CAMEL_OBJECT (store));
}
+void
+mail_remove_storage_by_uri (const char *uri)
+{
+ CamelProvider *prov;
+ CamelException ex;
+
+ camel_exception_init (&ex);
+ prov = camel_session_get_provider (session, uri, &ex);
+ if (prov != NULL && prov->flags & CAMEL_PROVIDER_IS_STORAGE &&
+ prov->flags & CAMEL_PROVIDER_IS_REMOTE) {
+ CamelService *store;
+
+ store = camel_session_get_service (session, uri,
+ CAMEL_PROVIDER_STORE, &ex);
+ if (store != NULL) {
+ g_warning ("removing storage: %s", uri);
+ mail_remove_storage (CAMEL_STORE (store));
+ camel_object_unref (CAMEL_OBJECT (store));
+ }
+ } else
+ g_warning ("%s is not a remote storage.", uri);
+ camel_exception_clear (&ex);
+}
+
int
mail_storages_count (void)
{
diff --git a/mail/mail-accounts.c b/mail/mail-accounts.c
index 605b7e2eb9..69a75d9cb2 100644
--- a/mail/mail-accounts.c
+++ b/mail/mail-accounts.c
@@ -280,28 +280,8 @@ mail_delete (GtkButton *button, gpointer data)
account = gtk_clist_get_row_data (dialog->mail_accounts, sel);
/* remove it from the folder-tree in the shell */
- if (account->source && account->source->url) {
- MailConfigService *service = account->source;
- CamelProvider *prov;
- CamelException ex;
-
- camel_exception_init (&ex);
- prov = camel_session_get_provider (session, service->url, &ex);
- if (prov != NULL && prov->flags & CAMEL_PROVIDER_IS_STORAGE &&
- prov->flags & CAMEL_PROVIDER_IS_REMOTE) {
- CamelService *store;
-
- store = camel_session_get_service (session, service->url,
- CAMEL_PROVIDER_STORE, &ex);
- if (store != NULL) {
- g_warning ("removing storage: %s", service->url);
- mail_remove_storage (CAMEL_STORE (store));
- camel_object_unref (CAMEL_OBJECT (store));
- }
- } else
- g_warning ("%s is not a remote storage.", service->url);
- camel_exception_clear (&ex);
- }
+ if (account->source && account->source->url)
+ mail_remove_storage_by_uri (account->source->url);
/* remove it from the config file */
dialog->accounts = mail_config_remove_account (account);
@@ -355,6 +335,12 @@ mail_able (GtkButton *button, gpointer data)
row = dialog->accounts_row;
account = gtk_clist_get_row_data (dialog->mail_accounts, row);
account->source->enabled = !account->source->enabled;
+
+ if (account->source->enabled)
+ mail_load_storage_by_uri (dialog->shell, account->source->url, account->name);
+ else
+ mail_remove_storage_by_uri (account->source->url);
+
mail_autoreceive_setup ();
mail_config_write ();
load_accounts (dialog);
@@ -457,7 +443,6 @@ news_add_destroyed (GtkWidget *widget, gpointer data)
gpointer *send = data;
MailAccountsDialog *dialog;
MailConfigService *service;
- GSList *mini;
service = send[0];
dialog = send[1];
@@ -466,9 +451,7 @@ news_add_destroyed (GtkWidget *widget, gpointer data)
dialog->news = mail_config_get_news ();
load_news (dialog);
- mini = g_slist_prepend(NULL, service);
- mail_load_storages(dialog->shell, mini, FALSE);
- g_slist_free(mini);
+ mail_load_storage_by_uri(dialog->shell, account->source->url, account->name);
dialog->news = mail_config_get_news ();
load_news (dialog);
diff --git a/mail/mail-config-druid.c b/mail/mail-config-druid.c
index 84730f3cf0..118fb76b43 100644
--- a/mail/mail-config-druid.c
+++ b/mail/mail-config-druid.c
@@ -174,7 +174,6 @@ druid_finish (GnomeDruidPage *page, gpointer arg1, gpointer user_data)
{
MailConfigDruid *druid = user_data;
MailAccountGui *gui = druid->gui;
- GSList *mini;
/* Add the account to our list (do it first because future
steps might want to access config->accounts) */
@@ -189,9 +188,7 @@ druid_finish (GnomeDruidPage *page, gpointer arg1, gpointer user_data)
mail_config_write ();
/* Load up this new account */
- mini = g_slist_prepend (NULL, gui->account);
- mail_load_storages (druid->shell, mini, TRUE);
- g_slist_free (mini);
+ mail_load_storages (druid->shell, gui->account->source->url, gui->account->name);
gtk_widget_destroy (GTK_WIDGET (druid));
}
diff --git a/mail/mail.h b/mail/mail.h
index b8254591c9..c1dc0d5acf 100644
--- a/mail/mail.h
+++ b/mail/mail.h
@@ -67,11 +67,13 @@ char *mail_identify_mime_part (CamelMimePart *part, MailDisplay *md);
GtkWidget *mail_view_create (CamelFolder *source, const char *uid, CamelMimeMessage *msg);
/* component factory for lack of a better place */
+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);
void mail_hash_storage (CamelService *store, EvolutionStorage *storage);
EvolutionStorage *mail_lookup_storage (CamelStore *store);
+void mail_remove_storage_by_uri (const char *uri);
void mail_remove_storage (CamelStore *store);
void mail_storages_foreach (GHFunc func, gpointer data);
int mail_storages_count (void);