diff options
author | Peter Williams <peterw@ximian.com> | 2001-08-14 05:23:04 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2001-08-14 05:23:04 +0800 |
commit | e86531cbd14a2ac303a5744ab5eb99c0c214dc50 (patch) | |
tree | de52fac44bfed276ed932178cf09e78996bc14e1 /mail/mail-config.c | |
parent | a5facd0e78bda439cd4e72f50817fe5f5dbb910c (diff) | |
download | gsoc2013-evolution-e86531cbd14a2ac303a5744ab5eb99c0c214dc50.tar gsoc2013-evolution-e86531cbd14a2ac303a5744ab5eb99c0c214dc50.tar.gz gsoc2013-evolution-e86531cbd14a2ac303a5744ab5eb99c0c214dc50.tar.bz2 gsoc2013-evolution-e86531cbd14a2ac303a5744ab5eb99c0c214dc50.tar.lz gsoc2013-evolution-e86531cbd14a2ac303a5744ab5eb99c0c214dc50.tar.xz gsoc2013-evolution-e86531cbd14a2ac303a5744ab5eb99c0c214dc50.tar.zst gsoc2013-evolution-e86531cbd14a2ac303a5744ab5eb99c0c214dc50.zip |
Break most of the functionality into a separate function.
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.
svn path=/trunk/; revision=11961
Diffstat (limited to 'mail/mail-config.c')
-rw-r--r-- | mail/mail-config.c | 140 |
1 files changed, 139 insertions, 1 deletions
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 |