aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/ChangeLog24
-rw-r--r--mail/em-migrate.c5
-rw-r--r--mail/mail-component.c166
-rw-r--r--mail/mail-vfolder.c24
4 files changed, 100 insertions, 119 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 7fcaa927c6..686b655d49 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,29 @@
2004-01-19 Not Zed <NotZed@Ximian.com>
+ * em-migrate.c (em_upgrade_pop_uid_caches_1_4): if we can't open
+ the pop3 cache dir, because it doesn't exist, it is not an error.
+
+ ** See bug #52983.
+
+ * mail-component.c (em_uri_from_camel, em_uri_to_camel): Handle
+ vfolder: uri's properly. And make sure local uri's are properly
+ encoded.
+ (mail_component_get_folder_from_evomail_uri)
+ (mail_component_evomail_uri_from_folder): removed, no longer used.
+ (em_uri_from_camel): don't leak the camelurl.
+ (d): disable debug
+
+ * mail-vfolder.c (vfolder_load_storage): move the vfolder storage
+ location to ~/.evolution/mail/vfolder rather than
+ ~/.evolution/mail (this is currently unused anyway).
+ (uri_is_ignore): short-circuit exit if we find a match.
+ (mail_vfolder_add_uri): dont exit immediately if we have a vfolder
+ uri, but don't add it to local/remove either.
+ (mail_vfolder_delete_uri): remove any uri from the local/remote
+ source list while we're at it.
+
+2004-01-19 Not Zed <NotZed@Ximian.com>
+
* em-folder-view.c (emfv_on_url_cb): properly decode the mailto
url rather than treating it as a simple string.
diff --git a/mail/em-migrate.c b/mail/em-migrate.c
index 26c3c9c566..44286f8739 100644
--- a/mail/em-migrate.c
+++ b/mail/em-migrate.c
@@ -1685,6 +1685,11 @@ em_upgrade_pop_uid_caches_1_4 (const char *evolution_dir, CamelException *ex)
/* open the old cache dir */
cache_dir = g_build_filename (g_get_home_dir (), "evolution", "mail", "pop3", NULL);
if (!(dir = opendir (cache_dir))) {
+ if (errno == ENOENT) {
+ g_free(cache_dir);
+ return 0;
+ }
+
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Failed to migrate pop3 uid caches: %s"),
g_strerror (errno));
diff --git a/mail/mail-component.c b/mail/mail-component.c
index 1f01ef691b..a437de6318 100644
--- a/mail/mail-component.c
+++ b/mail/mail-component.c
@@ -68,9 +68,7 @@
#include <bonobo/bonobo-control.h>
#include <bonobo/bonobo-widget.h>
-
-#define d(x) x
-
+#define d(x)
#define PARENT_TYPE bonobo_object_get_type ()
static BonoboObjectClass *parent_class = NULL;
@@ -801,31 +799,50 @@ mail_component_get_local_inbox(MailComponent *mc, struct _CamelException *ex)
extern struct _CamelSession *session;
+/* email: uri's are based on the account, with special cases for local
+ * stores, vfolder and local mail.
+ * e.g.
+ * imap account imap://user@host/ -> email://accountid@accountid.host/
+ * vfolder vfolder:/storage/path#folder -> email://vfolder@local/folder
+ * local local:/storage/path#folder -> email://local@local/folder
+ */
+
char *em_uri_from_camel(const char *curi)
{
CamelURL *curl;
EAccount *account;
const char *uid, *path;
- char *euri;
+ char *euri, *tmp;
CamelProvider *provider;
provider = camel_session_get_provider(session, curi, NULL);
- if (provider == NULL)
+ if (provider == NULL) {
+ d(printf("em uri from camel failed '%s'\n", curi));
return g_strdup(curi);
+ }
curl = camel_url_new(curi, NULL);
if (curl == NULL)
return g_strdup(curi);
- account = mail_config_get_account_by_source_url(curi);
- uid = (account == NULL)?"local@local":account->uid;
+ if (strcmp(curl->protocol, "vfolder") == 0)
+ uid = "vfolder@local";
+ else if ((account = mail_config_get_account_by_source_url(curi)) == NULL)
+ uid = "local@local";
+ else
+ uid = account->uid;
path = (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH)?curl->fragment:curl->path;
if (path[0] == '/')
path++;
- euri = g_strdup_printf("email://%s/%s", uid, path);
+
+ tmp = camel_url_encode(path, ";?");
+ euri = g_strdup_printf("email://%s/%s", uid, tmp);
+ g_free(tmp);
d(printf("em uri from camel '%s' -> '%s'\n", curi, euri));
-
+
+ camel_url_free(curl);
+
return euri;
}
@@ -838,21 +855,37 @@ char *em_uri_to_camel(const char *euri)
CamelURL *eurl, *curl;
char *uid, *curi;
- eurl = camel_url_new(euri, NULL);
- if (eurl == NULL)
+ if (strncmp(euri, "email:", 6) != 0) {
+ d(printf("em uri to camel not euri '%s'\n", euri));
return g_strdup(euri);
+ }
- if (strcmp(eurl->protocol, "email") != 0) {
- camel_url_free(eurl);
+ eurl = camel_url_new(euri, NULL);
+ if (eurl == NULL)
return g_strdup(euri);
- }
g_assert(eurl->host != NULL);
if (eurl->user != NULL) {
- if (strcmp(eurl->user, "local") == 0 && strcmp(eurl->host, "local") == 0) {
- curi = g_strdup_printf("mbox:%s/.evolution/mail/local#%s", g_get_home_dir(), eurl->path[0]=='/'?eurl->path+1:eurl->path);
+ /* Sigh, shoul'dve used mbox@local for mailboxes, not local@local */
+ if (strcmp(eurl->host, "local") == 0
+ && (strcmp(eurl->user, "local") == 0 || strcmp(eurl->user, "vfolder") == 0)) {
+ char *base;
+
+ if (strcmp(eurl->user, "vfolder") == 0)
+ curl = camel_url_new("vfolder:", NULL);
+ else
+ curl = camel_url_new("mbox:", NULL);
+
+ base = g_strdup_printf("%s/.evolution/mail/%s", g_get_home_dir(), eurl->user);
+ camel_url_set_path(curl, base);
+ g_free(base);
+ camel_url_set_fragment(curl, eurl->path[0]=='/'?eurl->path+1:eurl->path);
+ curi = camel_url_to_string(curl, 0);
+ camel_url_free(curl);
camel_url_free(eurl);
+
+ d(printf("em uri to camel local '%s' -> '%s'\n", euri, curi));
return curi;
}
@@ -867,6 +900,7 @@ char *em_uri_to_camel(const char *euri)
if (account == NULL) {
camel_url_free(eurl);
+ d(printf("em uri to camel no account '%s' -> '%s'\n", euri, euri));
return g_strdup(euri);
}
@@ -889,104 +923,4 @@ char *em_uri_to_camel(const char *euri)
return curi;
}
-
-CamelFolder *
-mail_component_get_folder_from_evomail_uri (MailComponent *component,
- guint32 flags,
- const char *evomail_uri,
- CamelException *ex)
-{
- CamelException local_ex;
- EAccountList *accounts;
- EIterator *iter;
- const char *p;
- const char *q;
- const char *folder_name;
- char *uid;
-
- camel_exception_init (&local_ex);
-
- if (strncmp (evomail_uri, "evomail:", 8) != 0)
- return NULL;
-
- p = evomail_uri + 8;
- while (*p == '/')
- p ++;
-
- q = strchr (p, '/');
- if (q == NULL)
- return NULL;
-
- uid = g_strndup (p, q - p);
- folder_name = q + 1;
-
- /* since we have no explicit account for 'local' folders, make one up */
- if (strcmp(uid, "local") == 0) {
- g_free(uid);
- return camel_store_get_folder(component->priv->local_store, folder_name, flags, ex);
- }
-
- accounts = mail_config_get_accounts ();
- iter = e_list_get_iterator ((EList *) accounts);
- while (e_iterator_is_valid (iter)) {
- EAccount *account = (EAccount *) e_iterator_get (iter);
- EAccountService *service = account->source;
- CamelProvider *provider;
- CamelStore *store;
-
- if (strcmp (account->uid, uid) != 0)
- continue;
-
- provider = camel_session_get_provider (session, service->url, &local_ex);
- if (provider == NULL)
- goto fail;
-
- store = (CamelStore *) camel_session_get_service (session, service->url, CAMEL_PROVIDER_STORE, &local_ex);
- if (store == NULL)
- goto fail;
-
- g_free (uid);
- return camel_store_get_folder (store, folder_name, flags, ex);
- }
-
- fail:
- camel_exception_clear (&local_ex);
- g_free (uid);
- return NULL;
-}
-
-
-char *
-mail_component_evomail_uri_from_folder (MailComponent *component,
- CamelFolder *folder)
-{
- CamelStore *store = camel_folder_get_parent_store (folder);
- EAccount *account;
- char *service_url;
- char *evomail_uri;
- const char *uid;
-
- if (store == NULL)
- return NULL;
-
- service_url = camel_service_get_url (CAMEL_SERVICE (store));
- account = mail_config_get_account_by_source_url (service_url);
-
- if (account == NULL) {
- /* since we have no explicit account for 'local' folders, make one up */
- /* TODO: check the folder is really a local one, folder->parent_store == local_store? */
- uid = "local";
- /*g_free (service_url);
- return NULL;*/
- } else {
- uid = account->uid;
- }
-
- evomail_uri = g_strconcat ("evomail:///", uid, "/", camel_folder_get_full_name (folder), NULL);
- g_free (service_url);
-
- return evomail_uri;
-}
-
-
BONOBO_TYPE_FUNC_FULL (MailComponent, GNOME_Evolution_Component, PARENT_TYPE, mail_component)
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 80501b32b0..b1474b7afe 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -311,6 +311,9 @@ uri_is_ignore(const char *uri, GCompareFunc uri_cmp)
|| (default_sent_folder_uri && uri_cmp(default_sent_folder_uri, uri))
|| (default_drafts_folder_uri && uri_cmp(default_drafts_folder_uri, uri));
+ if (found)
+ return found;
+
accounts = mail_config_get_accounts ();
iter = e_list_get_iterator ((EList *) accounts);
while (e_iterator_is_valid (iter)) {
@@ -347,7 +350,7 @@ mail_vfolder_add_uri(CamelStore *store, const char *curi, int remove)
char *uri;
uri = em_uri_from_camel(curi);
- if (CAMEL_IS_VEE_STORE(store) || !strncmp(curi, "vtrash:", 7) || !strncmp(curi, "vjunk:", 6) || context == NULL) {
+ if (!strncmp(curi, "vtrash:", 7) || !strncmp(curi, "vjunk:", 6) || context == NULL) {
g_free(uri);
return;
}
@@ -361,7 +364,9 @@ mail_vfolder_add_uri(CamelStore *store, const char *curi, int remove)
d(printf("%s uri to check: %s\n", remove?"Removing":"Adding", uri));
/* maintain the source folders lists for changed rules later on */
- if (remove) {
+ if (CAMEL_IS_VEE_STORE(store)) {
+ is_ignore = TRUE;
+ } else if (remove) {
if (remote) {
if ((link = my_list_find(source_folders_remote, (void *)uri, uri_cmp)) != NULL) {
g_free(link->data);
@@ -438,6 +443,7 @@ mail_vfolder_delete_uri(CamelStore *store, const char *curi)
CamelVeeFolder *vf;
GString *changed;
char *uri;
+ GList *link;
if (context == NULL || !strncmp(curi, "vtrash:", 7) || !strncmp(curi, "vjunk:", 6))
return;
@@ -471,6 +477,16 @@ mail_vfolder_delete_uri(CamelStore *store, const char *curi)
}
}
}
+
+ if ((link = my_list_find(source_folders_remote, (void *)uri, uri_cmp)) != NULL) {
+ g_free(link->data);
+ source_folders_remote = g_list_remove_link(source_folders_remote, link);
+ }
+
+ if ((link = my_list_find(source_folders_local, (void *)uri, uri_cmp)) != NULL) {
+ g_free(link->data);
+ source_folders_local = g_list_remove_link(source_folders_local, link);
+ }
UNLOCK();
@@ -607,6 +623,8 @@ rule_changed(FilterRule *rule, CamelFolder *folder)
sources_folder = g_list_append(sources_folder, newfolder);
else
sources_uri = g_list_append(sources_uri, g_strdup(sourceuri));
+ } else {
+ d(printf(" no i'm not - this folder doesn't exist anywhere\n"));
}
g_free(curi);
@@ -791,7 +809,7 @@ vfolder_load_storage(void)
vfolder_hash = g_hash_table_new(g_str_hash, g_str_equal);
/* first, create the vfolder store, and set it up */
- storeuri = g_strdup_printf("vfolder:%s/vfolder", mail_component_peek_base_directory (mail_component_peek ()));
+ storeuri = g_strdup_printf("vfolder:%s/mail/vfolder", mail_component_peek_base_directory (mail_component_peek ()));
vfolder_store = camel_session_get_store(session, storeuri, NULL);
if (vfolder_store == NULL) {
g_warning("Cannot open vfolder store - no vfolders available");