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
This commit is contained in:
@ -1,3 +1,14 @@
|
||||
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.
|
||||
|
||||
2003-11-18 Jeffrey Stedfast <fejj@ximian.com>
|
||||
|
||||
* em-migrate.c (em_migrate_dir): Don't leak the message objects.
|
||||
|
@ -734,7 +734,7 @@ char *em_uri_to_camel(const char *euri)
|
||||
g_assert(eurl->host != 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);
|
||||
curi = g_strdup_printf("mbox:%s/.evolution/mail/local#%s", g_get_home_dir(), eurl->path[0]=='/'?eurl->path+1:eurl->path);
|
||||
camel_url_free(eurl);
|
||||
return curi;
|
||||
}
|
||||
@ -755,7 +755,7 @@ char *em_uri_to_camel(const char *euri)
|
||||
|
||||
curl = camel_url_new(service->url, NULL);
|
||||
if (provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH)
|
||||
camel_url_set_fragment(curl, eurl->path);
|
||||
camel_url_set_fragment(curl, eurl->path[0]=='/'?eurl->path+1:eurl->path);
|
||||
else
|
||||
camel_url_set_path(curl, eurl->path);
|
||||
|
||||
|
@ -539,10 +539,9 @@ alert_user(CamelSession *session, CamelSessionAlertType type, const char *prompt
|
||||
static CamelFolder *
|
||||
get_folder (CamelFilterDriver *d, const char *uri, void *data, CamelException *ex)
|
||||
{
|
||||
return mail_tool_uri_to_folder (uri, 0, ex);
|
||||
return mail_tool_uri_to_folder(uri, 0, ex);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
main_play_sound (CamelFilterDriver *driver, char *filename, gpointer user_data)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user