aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog35
-rw-r--r--mail/mail-account-gui.c24
-rw-r--r--mail/mail-config-druid.c13
-rw-r--r--mail/mail-config.c140
-rw-r--r--mail/mail-send-recv.c26
-rw-r--r--mail/mail-send-recv.h3
6 files changed, 223 insertions, 18 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 7389e9368f..7a7492f765 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,38 @@
+2001-08-13 Peter Williams <peterw@ximian.com>
+
+ * mail-send-recv.c (mail_autoreceive_setup): Break most of the
+ functionality into a separate function.
+ (autoreceive_setup_list): Rename of mail_autoreceive_setup that is
+ passed a list of accounts.
+ (mail_autoreceive_setup_account): New function. Set up a single
+ account using autoreceive_setup_account.
+
+ * mail-send-receive.h: Prototype mail_autoreceive_setup_account.
+
+ * mail-account-gui.c (mail_account_gui_save): Instead of setting
+ up all accounts, set up only this source with the new
+ mail_autoreceive_setup_account.
+
+ * mail-config-druid.c (druid_finish): ... which means we can call
+ mail_config_add_account() after the MailConfigAccount has been
+ created by mail_account_gui_save() because we no longer need the
+ account to be in the list for mail_autoreceive_setup()
+
+ * mail-config.c (mail_config_add_account): ... which means we can
+ possibly add a shortcut to the account's sources's Inbox here.
+ (maybe_add_shortcut): New function. If the store is a storage, add
+ a shortcut to its inbox. Hope that /INBOX exists.
+ (add_shortcut_entry): New function. Creates a shortcut if it doesn't
+ yet exist.
+
+2001-08-13 Peter Williams <peterw@ximian.com>
+
+ * mail-account-gui.c (service_complete): Take account of the fact that
+ service->path may be NULL (if service is a transport.)
+
+ * mail-config-druid.c (druid_finish): Bleah, bugfix in case the
+ account has no source.
+
2001-08-13 Anna Marie Dirks <anna@ximian.com>
* mail-config.glade: Changed all instances of "Wizard" and "Druid"
diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c
index 0078d25175..7117eacf47 100644
--- a/mail/mail-account-gui.c
+++ b/mail/mail-account-gui.c
@@ -117,17 +117,24 @@ service_complete (MailAccountGuiService *service, GtkWidget **incomplete)
{
const CamelProvider *prov = service->provider;
char *text;
-
+ GtkWidget *path;
+
if (!prov)
return TRUE;
-
+
+ /* transports don't have a path */
+ if (service->path)
+ path = GTK_WIDGET (service->path);
+ else
+ path = NULL;
+
if (CAMEL_PROVIDER_NEEDS (prov, CAMEL_URL_PART_HOST)) {
text = gtk_entry_get_text (service->hostname);
if (!text || !*text) {
if (incomplete)
*incomplete = get_focused_widget (GTK_WIDGET (service->hostname),
GTK_WIDGET (service->username),
- GTK_WIDGET (service->path),
+ path,
NULL);
return FALSE;
}
@@ -138,14 +145,19 @@ service_complete (MailAccountGuiService *service, GtkWidget **incomplete)
if (!text || !*text) {
if (incomplete)
*incomplete = get_focused_widget (GTK_WIDGET (service->username),
- GTK_WIDGET (service->path),
GTK_WIDGET (service->hostname),
+ path,
NULL);
return FALSE;
}
}
if (CAMEL_PROVIDER_NEEDS (prov, CAMEL_URL_PART_PATH)) {
+ if (!path) {
+ printf ("aagh, transports aren't supposed to have paths.\n");
+ return TRUE;
+ }
+
text = gtk_entry_get_text (service->path);
if (!text || !*text) {
if (incomplete)
@@ -1618,8 +1630,8 @@ mail_account_gui_save (MailAccountGui *gui)
account->smime_encrypt_to_self = gtk_toggle_button_get_active (gui->smime_encrypt_to_self);
account->smime_always_sign = gtk_toggle_button_get_active (gui->smime_always_sign);
- mail_autoreceive_setup ();
-
+ mail_autoreceive_setup_account (account->source);
+
return TRUE;
}
diff --git a/mail/mail-config-druid.c b/mail/mail-config-druid.c
index a60ba37c09..07468733c9 100644
--- a/mail/mail-config-druid.c
+++ b/mail/mail-config-druid.c
@@ -175,20 +175,21 @@ druid_finish (GnomeDruidPage *page, gpointer arg1, gpointer user_data)
MailConfigDruid *druid = user_data;
MailAccountGui *gui = druid->gui;
- /* Add the account to our list (do it first because future
- steps might want to access config->accounts) */
- mail_config_add_account (gui->account);
-
/* Save the settings for that account */
mail_account_gui_save (gui);
if (gui->account->source)
gui->account->source->enabled = TRUE;
+ /* Add the account to our list (do it early because future
+ steps might want to access config->accounts) */
+ mail_config_add_account (gui->account);
+
/* Write out the config info */
mail_config_write ();
- /* Load up this new account */
- mail_load_storage_by_uri (druid->shell, gui->account->source->url, gui->account->name);
+ /* Load up this new account if necessary */
+ if (gui->account->source && gui->account->source->url)
+ mail_load_storage_by_uri (druid->shell, gui->account->source->url, gui->account->name);
gtk_widget_destroy (GTK_WIDGET (druid));
}
diff --git a/mail/mail-config.c b/mail/mail-config.c
index 5f2d7f1ab1..f40d999b0a 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -50,7 +50,6 @@
#include <e-util/e-url.h>
#include "mail.h"
#include "mail-config.h"
-#include "mail-ops.h"
#include "mail-mt.h"
#include "Mail.h"
@@ -1403,10 +1402,149 @@ mail_config_get_accounts (void)
return config->accounts;
}
+static void
+add_shortcut_entry (const char *name, const char *uri, const char *type)
+{
+ extern EvolutionShellClient *global_shell_client;
+ CORBA_Environment ev;
+ GNOME_Evolution_Shortcuts shortcuts_interface;
+ GNOME_Evolution_Shortcuts_GroupList *groups;
+ GNOME_Evolution_Shortcuts_Group *the_group;
+ GNOME_Evolution_Shortcuts_Shortcut *the_shortcut;
+ int i, group_num;
+
+ CORBA_exception_init (&ev);
+
+ shortcuts_interface = evolution_shell_client_get_shortcuts_interface (global_shell_client);
+ if (CORBA_Object_is_nil (shortcuts_interface, &ev)) {
+ g_warning ("No ::Shortcut interface on the shell");
+ CORBA_exception_free (&ev);
+ return;
+ }
+
+ groups = GNOME_Evolution_Shortcuts__get_groups (shortcuts_interface, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Exception getting the groups: %s", ev._repo_id);
+ CORBA_exception_free (&ev);
+ return;
+ }
+
+ the_group = NULL;
+ group_num = 0;
+
+ for (i = 0; i < groups->_length; i++) {
+ GNOME_Evolution_Shortcuts_Group *iter;
+
+ iter = groups->_buffer + i;
+ if (!strcmp (iter->name, "Evolution Shortcuts")) {
+ the_group = iter;
+ group_num = i;
+ break;
+ }
+ }
+
+ if (the_group == NULL) {
+ /* Bleah, just create it. Probably not the best
+ * course of action. */
+
+ GNOME_Evolution_Shortcuts_addGroup (shortcuts_interface,
+ group_num,
+ "Evolution Shortcuts",
+ &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Exception recreating \"Evolution Shortcuts\" group: %s", ev._repo_id);
+ goto cleanup;
+ }
+
+ the_group = GNOME_Evolution_Shortcuts_getGroup (shortcuts_interface,
+ group_num,
+ &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Exception getting newly created \"Evolution Shortcuts\" group: %s", ev._repo_id);
+ goto cleanup;
+ }
+ }
+
+ the_shortcut = NULL;
+
+ for (i = 0; i < the_group->shortcuts._length; i++) {
+ GNOME_Evolution_Shortcuts_Shortcut *iter;
+
+ iter = the_group->shortcuts._buffer + i;
+ if (!strcmp (iter->name, name)) {
+ the_shortcut = iter;
+ break;
+ }
+ }
+
+ if (the_shortcut == NULL) {
+ the_shortcut =
+ GNOME_Evolution_Shortcuts_Shortcut__alloc ();
+
+ the_shortcut->name = CORBA_string_dup (name);
+ the_shortcut->uri = CORBA_string_dup (uri);
+ the_shortcut->type = CORBA_string_dup (type);
+
+ GNOME_Evolution_Shortcuts_add (shortcuts_interface,
+ group_num,
+ the_group->shortcuts._length,
+ the_shortcut,
+ &ev);
+
+ CORBA_free (the_shortcut);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("Exception creating shortcut \"%s\": %s", name, ev._repo_id);
+ goto cleanup;
+ }
+
+ }
+
+ cleanup:
+ CORBA_exception_free (&ev);
+ CORBA_free (groups);
+}
+
+static void
+maybe_add_shortcut (MailConfigAccount *account)
+{
+ CamelProvider *prov;
+ gchar *name;
+ gchar *url;
+
+ /* no source, don't bother. */
+ if (!account->source || !account->source->url)
+ return;
+
+ prov = camel_session_get_provider (session, account->source->url, NULL);
+
+ /* not a storage, don't bother. */
+
+ if (!(prov->flags & CAMEL_PROVIDER_IS_STORAGE))
+ return;
+
+ /* right now, the URL always works basically as a matter of luck...
+ * both IMAP and mbox spool stores have INBOX as their inbox folder
+ * name. I don't think this will work with maildir. How can we figure out
+ * what shortcut to insert?
+ */
+
+ name = g_strdup_printf (_("%s: Inbox"), account->name);
+ url = g_strdup_printf ("evolution:/%s/INBOX", account->name);
+ add_shortcut_entry (name, url, "mail");
+ g_free (name);
+ g_free (url);
+}
+
void
mail_config_add_account (MailConfigAccount *account)
{
config->accounts = g_slist_append (config->accounts, account);
+
+ if (account->source && account->source->url)
+ maybe_add_shortcut (account);
}
static void
diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c
index 7012b5fd35..e70eade3e5 100644
--- a/mail/mail-send-recv.c
+++ b/mail/mail-send-recv.c
@@ -696,13 +696,11 @@ static void auto_clean_set(void *key, struct _auto_data *info, GHashTable *set)
/* call to setup initial, and after changes are made to the config */
/* FIXME: Need a cleanup funciton for when object is deactivated */
-void
-mail_autoreceive_setup(void)
+static void
+autoreceive_setup_list(GSList *sources, gboolean clear_absent)
{
- GSList *sources;
GHashTable *set_hash;
- sources = mail_config_get_sources();
if (!sources)
return;
@@ -744,10 +742,28 @@ mail_autoreceive_setup(void)
sources = sources->next;
}
- g_hash_table_foreach(set_hash, (GHFunc)auto_clean_set, auto_active);
+ if (clear_absent)
+ g_hash_table_foreach(set_hash, (GHFunc)auto_clean_set, auto_active);
g_hash_table_destroy(set_hash);
}
+void
+mail_autoreceive_setup (void)
+{
+ autoreceive_setup_list (mail_config_get_sources(), TRUE);
+}
+
+void
+mail_autoreceive_setup_account (MailConfigService *service)
+{
+ GSList list;
+
+ list.data = service;
+ list.next = NULL;
+
+ autoreceive_setup_list (&list, FALSE);
+}
+
/* we setup the download info's in a hashtable, if we later need to build the gui, we insert
them in to add them. */
void mail_receive_uri(const char *uri, int keep)
diff --git a/mail/mail-send-recv.h b/mail/mail-send-recv.h
index 6ea0bc4757..8cfea07f60 100644
--- a/mail/mail-send-recv.h
+++ b/mail/mail-send-recv.h
@@ -28,12 +28,15 @@ extern "C" {
#pragma }
#endif /* __cplusplus }*/
+#include "mail-config.h"
+
/* send/receive all uri's */
void mail_send_receive(void);
/* receive a single uri */
void mail_receive_uri(const char *uri, int keep);
/* setup auto receive stuff */
void mail_autoreceive_setup(void);
+void mail_autoreceive_setup_account(MailConfigService *source);
#ifdef __cplusplus
}