aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-tools.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2003-11-19 14:17:56 +0800
committerMichael Zucci <zucchi@src.gnome.org>2003-11-19 14:17:56 +0800
commitc05d3716731fc810a21b60f81c6da695747abe4d (patch)
tree1cf1d3f5ceee8e0912a3e82a4ed55d120aa5648c /mail/mail-tools.c
parent736f94d96e9a4c5eee7dcb551fce5d7bd4d6c3c4 (diff)
downloadgsoc2013-evolution-c05d3716731fc810a21b60f81c6da695747abe4d.tar
gsoc2013-evolution-c05d3716731fc810a21b60f81c6da695747abe4d.tar.gz
gsoc2013-evolution-c05d3716731fc810a21b60f81c6da695747abe4d.tar.bz2
gsoc2013-evolution-c05d3716731fc810a21b60f81c6da695747abe4d.tar.lz
gsoc2013-evolution-c05d3716731fc810a21b60f81c6da695747abe4d.tar.xz
gsoc2013-evolution-c05d3716731fc810a21b60f81c6da695747abe4d.tar.zst
gsoc2013-evolution-c05d3716731fc810a21b60f81c6da695747abe4d.zip
if we're setting the fragment, strip leading /'s.
2003-11-19 Not Zed <NotZed@Ximian.com> * mail-component.c (em_uri_to_camel): if we're setting the fragment, strip leading /'s. * mail-tools.c (mail_tool_get_meta_data) (mail_tool_delete_meta_data, meta_data_key): old stuff killed. (mail_tool_uri_to_folder): handle email: uri's specially. this is a bit of a hack, the filter callbacks should manage this itself since filters are the only bits which use those uri's. svn path=/trunk/; revision=23437
Diffstat (limited to 'mail/mail-tools.c')
-rw-r--r--mail/mail-tools.c91
1 files changed, 13 insertions, 78 deletions
diff --git a/mail/mail-tools.c b/mail/mail-tools.c
index 9a10b0eb5b..f77a86a7ac 100644
--- a/mail/mail-tools.c
+++ b/mail/mail-tools.c
@@ -298,7 +298,8 @@ mail_tool_uri_to_folder (const char *uri, guint32 flags, CamelException *ex)
CamelStore *store = NULL;
CamelFolder *folder = NULL;
int offset = 0;
-
+ char *curi = NULL;
+
g_return_val_if_fail (uri != NULL, NULL);
/* This hack is still needed for file:/ since it's its own EvolutionStorage type */
@@ -306,9 +307,19 @@ mail_tool_uri_to_folder (const char *uri, guint32 flags, CamelException *ex)
offset = 7;
else if (!strncmp (uri, "vjunk:", 6))
offset = 6;
+ else if (!strncmp(uri, "email:", 6)) {
+ /* FIXME?: the filter:get_folder callback should do this itself? */
+ curi = em_uri_to_camel(uri);
+ if (uri == NULL) {
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Invalid folder: `%s'"), uri);
+ return NULL;
+ }
+ uri = curi;
+ }
url = camel_url_new (uri + offset, ex);
if (!url) {
+ g_free(curi);
return NULL;
}
@@ -343,6 +354,7 @@ mail_tool_uri_to_folder (const char *uri, guint32 flags, CamelException *ex)
mail_note_folder (folder);
camel_url_free (url);
+ g_free(curi);
return folder;
}
@@ -411,80 +423,3 @@ mail_tools_folder_to_url (CamelFolder *folder)
return url;
}
-
-static char *meta_data_key(const char *uri, char **pathp)
-{
- const char *base_directory = mail_component_peek_base_directory (mail_component_peek ());
- CamelURL *url;
- GString *path;
- const char *key;
- char *p, c;
-
- url = camel_url_new(uri, NULL);
-
- if (url == NULL) {
- g_warning("Trying to retrieve meta-data for unparsable uri: %s", uri);
- *pathp = g_build_path(base_directory, "meta/unknown", NULL);
-
- return g_strdup("folder");
- }
-
- path = g_string_new(base_directory);
- g_string_append_printf(path, "/meta/%s/", url->protocol);
-
- if (url->host && url->host[0]) {
- if (url->user)
- g_string_append_printf(path, "%s@", url->user);
- g_string_append(path, url->host);
- if (url->port)
- g_string_append_printf(path, ":%d", url->port);
- key = url->path;
- } else if (url->path) {
- if (url->fragment) {
- p = url->path;
- while ((c = *p++)) {
- if (c == '/')
- c = '_';
- g_string_append_c(path, c);
- }
- key = url->fragment;
- } else {
- key = url->path;
- }
- }
-
- if (key == NULL)
- key = uri;
-
- p = g_strdup(key);
- camel_url_free(url);
- *pathp = path->str;
- g_string_free(path, FALSE);
-
- return p;
-}
-
-EMeta *
-mail_tool_get_meta_data(const char *uri)
-{
- char *path, *key;
- EMeta *meta;
-
- key = meta_data_key(uri, &path);
- meta = e_meta_data_find(path, key);
- g_free(key);
- g_free(path);
-
- return meta;
-}
-
-void
-mail_tool_delete_meta_data(const char *uri)
-{
- char *path, *key;
-
- key = meta_data_key(uri, &path);
- e_meta_data_delete(path, key);
- g_free(key);
- g_free(path);
-}