diff options
author | Dan Winship <danw@src.gnome.org> | 2001-10-02 03:45:39 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2001-10-02 03:45:39 +0800 |
commit | 8d3a2ebd284bbcde524a40054970c03ef7e07426 (patch) | |
tree | e4fd6a50b33358afe5cd7d77de97a4398b117e3d | |
parent | a9decdd87985fd66f202aa118d5e81d774734420 (diff) | |
download | gsoc2013-evolution-8d3a2ebd284bbcde524a40054970c03ef7e07426.tar gsoc2013-evolution-8d3a2ebd284bbcde524a40054970c03ef7e07426.tar.gz gsoc2013-evolution-8d3a2ebd284bbcde524a40054970c03ef7e07426.tar.bz2 gsoc2013-evolution-8d3a2ebd284bbcde524a40054970c03ef7e07426.tar.lz gsoc2013-evolution-8d3a2ebd284bbcde524a40054970c03ef7e07426.tar.xz gsoc2013-evolution-8d3a2ebd284bbcde524a40054970c03ef7e07426.tar.zst gsoc2013-evolution-8d3a2ebd284bbcde524a40054970c03ef7e07426.zip |
create storages for providers that are STORAGE and aren't EXTERNAL, rather
* component-factory.c (mail_load_storage_by_uri): create storages
for providers that are STORAGE and aren't EXTERNAL, rather than
"(STORAGE and REMOTE) or spool, maildir, or vfolder".
(mail_remove_storage_by_uri): Use the same rule here (which makes
it possible now to remove maildir and spool stores now, which
weren't properly special-cased before). Remove some CamelException
misuse.
* mail-config.c (new_source_created): Fix up the broken INBOX-
shortcut-generating assumption a little by only assuming that if
you call camel_store_get_inbox(), that its full_name is the same
as its path. (This happens to always be true for inboxes now, and
will be always true by definition at some point in the future.)
Now maildir stores get working Inbox shortcuts.
* mail-send-recv.c (get_receive_type): If PROVIDER_IS_STORAGE
then use SEND_UPDATE, if not, use SEND_RECEIVE.
* mail-local.c (local_provider): The local provider is EXTERNAL.
(The shell creates it.)
(mail_local_reconfigure_folder): Allow reconfiguring between
IS_LOCAL providers.
* mail-accounts.c (news_delete): Don't need to check the provider
flags here... we know nntp is a STORAGE.
svn path=/trunk/; revision=13277
-rw-r--r-- | mail/ChangeLog | 28 | ||||
-rw-r--r-- | mail/component-factory.c | 50 | ||||
-rw-r--r-- | mail/mail-config.c | 59 | ||||
-rw-r--r-- | mail/mail-local.c | 10 | ||||
-rw-r--r-- | mail/mail-offline-handler.c | 3 | ||||
-rw-r--r-- | mail/mail-send-recv.c | 9 |
6 files changed, 97 insertions, 62 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index c78a2251eb..8351b96703 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,33 @@ 2001-10-01 Dan Winship <danw@ximian.com> + * component-factory.c (mail_load_storage_by_uri): create storages + for providers that are STORAGE and aren't EXTERNAL, rather than + "(STORAGE and REMOTE) or spool, maildir, or vfolder". + (mail_remove_storage_by_uri): Use the same rule here (which makes + it possible now to remove maildir and spool stores now, which + weren't properly special-cased before). Remove some CamelException + misuse. + + * mail-config.c (new_source_created): Fix up the broken INBOX- + shortcut-generating assumption a little by only assuming that if + you call camel_store_get_inbox(), that its full_name is the same + as its path. (This happens to always be true for inboxes now, and + will be always true by definition at some point in the future.) + Now maildir stores get working Inbox shortcuts. + + * mail-send-recv.c (get_receive_type): If PROVIDER_IS_STORAGE + then use SEND_UPDATE, if not, use SEND_RECEIVE. + + * mail-local.c (local_provider): The local provider is EXTERNAL. + (The shell creates it.) + (mail_local_reconfigure_folder): Allow reconfiguring between + IS_LOCAL providers. + + * mail-accounts.c (news_delete): Don't need to check the provider + flags here... we know nntp is a STORAGE. + +2001-10-01 Dan Winship <danw@ximian.com> + * mail-local.c (mail_local_reconfigure_folder): Don't use mail_tool_get_folder_name here since that function only existed to be clever in a certain case that this is not. diff --git a/mail/component-factory.c b/mail/component-factory.c index 4bb72ff0ed..9cf5cf47e2 100644 --- a/mail/component-factory.c +++ b/mail/component-factory.c @@ -1056,20 +1056,9 @@ mail_load_storage_by_uri (GNOME_Evolution_Shell shell, const char *uri, const ch 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 ... - * And vfolder, and maildir ... - */ - if ((!(prov->flags & CAMEL_PROVIDER_IS_STORAGE) || - !(prov->flags & CAMEL_PROVIDER_IS_REMOTE)) - && !((strcmp (prov->protocol, "spool") == 0) - || (strcmp (prov->protocol, "maildir") == 0) - || (strcmp (prov->protocol, "vfolder") == 0))) + + if (!(prov->flags & CAMEL_PROVIDER_IS_STORAGE) || + (prov->flags & CAMEL_PROVIDER_IS_EXTERNAL)) return; store = camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, &ex); @@ -1189,27 +1178,20 @@ 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 { - /* why make the caller redundantly check this? */ - /*g_warning ("%s is not a remote storage.", uri);*/ - } + CamelService *store; - camel_exception_clear (&ex); + prov = camel_session_get_provider (session, uri, NULL); + if (!prov) + return; + if (!(prov->flags & CAMEL_PROVIDER_IS_STORAGE) || + (prov->flags & CAMEL_PROVIDER_IS_EXTERNAL)) + return; + + store = camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, NULL); + if (store != NULL) { + mail_remove_storage (CAMEL_STORE (store)); + camel_object_unref (CAMEL_OBJECT (store)); + } } int diff --git a/mail/mail-config.c b/mail/mail-config.c index 7372f664e3..e3240e8aac 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -46,12 +46,14 @@ #include <gal/util/e-util.h> #include <gal/unicode/gunicode.h> +#include <gal/widgets/e-gui-utils.h> #include <e-util/e-html-utils.h> #include <e-util/e-url.h> #include <e-util/e-unicode-i18n.h> #include "mail.h" #include "mail-config.h" #include "mail-mt.h" +#include "mail-tools.h" #include "Mail.h" @@ -1520,10 +1522,9 @@ 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; + int i; if (!global_shell_client) return; @@ -1590,6 +1591,8 @@ static void new_source_created (MailConfigAccount *account) { CamelProvider *prov; + CamelFolder *inbox; + CamelException ex; gchar *name; gchar *url; @@ -1597,28 +1600,52 @@ new_source_created (MailConfigAccount *account) if (!account->source || !account->source->url) return; - prov = camel_session_get_provider (session, account->source->url, NULL); + camel_exception_init (&ex); + prov = camel_session_get_provider (session, account->source->url, &ex); + if (camel_exception_is_set (&ex)) { + g_warning ("Configured provider that doesn't exist?"); + camel_exception_clear (&ex); + return; + } /* 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? - */ + inbox = mail_tool_get_inbox (account->source->url, &ex); + if (camel_exception_is_set (&ex)) { + e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, + _("Could not get inbox for new mail store:\n%s\n" + "No shortcut will be created."), + camel_exception_get_description (&ex)); + camel_exception_clear (&ex); + return; + } - name = g_strdup_printf (U_("%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); + if (inbox) { + /* Create the shortcut. FIXME: This only works if the + * full name matches the path. + */ + name = g_strdup_printf (U_("%s: Inbox"), account->name); + url = g_strdup_printf ("evolution:/%s/%s", account->name, + inbox->full_name); + add_shortcut_entry (name, url, "mail"); + g_free (name); + g_free (url); + + /* If we unref inbox here, it will disconnect from the + * store, but then add_new_storage will reconnect. So + * we'll keep holding the ref until after that. + */ + } - /* while we're here, add the storage to the folder tree */ + if (!(prov->flags & CAMEL_PROVIDER_IS_EXTERNAL)) { + /* add the storage to the folder tree */ + add_new_storage (account->source->url, account->name); + } - add_new_storage (account->source->url, account->name); + if (inbox) + camel_object_unref (CAMEL_OBJECT (inbox)); } void diff --git a/mail/mail-local.c b/mail/mail-local.c index 32a2ad6c60..759c464737 100644 --- a/mail/mail-local.c +++ b/mail/mail-local.c @@ -888,7 +888,8 @@ static void mail_local_store_remove_folder(MailLocalStore *mls, const char *path static CamelProvider local_provider = { "file", "Local mail", NULL, "mail", - CAMEL_PROVIDER_IS_STORAGE, CAMEL_URL_NEED_PATH, + CAMEL_PROVIDER_IS_STORAGE | CAMEL_PROVIDER_IS_EXTERNAL, + CAMEL_URL_NEED_PATH, /* ... */ }; @@ -1227,11 +1228,8 @@ mail_local_reconfigure_folder (FolderBrowser *fb) while (p) { CamelProvider *cp = p->data; - /* we only want local storages */ - /* hack it so we also dont see file or spool stores, which aren't really meant for this */ - if ((cp->flags & (CAMEL_PROVIDER_IS_REMOTE|CAMEL_PROVIDER_IS_STORAGE)) == CAMEL_PROVIDER_IS_STORAGE - && strcmp(cp->protocol, "file") - && strcmp(cp->protocol, "spool")) { + /* we only want local providers */ + if (cp->flags & CAMEL_PROVIDER_IS_LOCAL) { GtkWidget *item; char *label; diff --git a/mail/mail-offline-handler.c b/mail/mail-offline-handler.c index dfa3af7d53..e613bb394f 100644 --- a/mail/mail-offline-handler.c +++ b/mail/mail-offline-handler.c @@ -45,7 +45,8 @@ struct _MailOfflineHandlerPrivate { static gboolean service_is_relevant (CamelService *service, gboolean going_offline) { - if (!(service->provider->flags & CAMEL_PROVIDER_IS_REMOTE)) + if (!(service->provider->flags & CAMEL_PROVIDER_IS_REMOTE) || + (service->provider->flags & CAMEL_PROVIDER_IS_EXTERNAL)) return FALSE; if (CAMEL_IS_DISCO_STORE (service) && going_offline && diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c index db5e23483a..d1d619b0dd 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -253,9 +253,10 @@ format_url(const char *internal_url) static send_info_t get_receive_type(const char *url) { - if (!strncmp(url, "imap:", 5) - || !strncmp(url, "spool:", 6) - || !strncmp(url, "maildir:", 8)) + CamelProvider *provider; + + provider = camel_session_get_provider (session, url, NULL); + if (provider->flags & CAMEL_PROVIDER_IS_STORAGE) return SEND_UPDATE; else return SEND_RECEIVE; @@ -301,7 +302,6 @@ build_dialogue (GSList *sources, CamelFolder *outbox, const char *destination) info = g_hash_table_lookup (data->active, source->url); if (info == NULL) { info = g_malloc0 (sizeof (*info)); - /* imap and spool are handled differently */ info->type = get_receive_type(source->url); d(printf("adding source %s\n", source->url)); @@ -795,7 +795,6 @@ mail_receive_uri (const char *uri, int keep) d(printf("starting non-interactive download of '%s'\n", uri)); info = g_malloc0 (sizeof (*info)); - /* imap is handled differently */ info->type = get_receive_type(uri); info->bar = NULL; info->status = NULL; |