aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-01-16 15:14:15 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-01-16 15:14:15 +0800
commit7ab4ccfe7670d38a00fa2a9c06dcc7a60a4c2726 (patch)
tree54f571c328e4070bdcd96799d048a88596e6b9c8 /mail
parent21d0e891e218511c00b8f71769eaee998f61edfd (diff)
downloadgsoc2013-evolution-7ab4ccfe7670d38a00fa2a9c06dcc7a60a4c2726.tar.gz
gsoc2013-evolution-7ab4ccfe7670d38a00fa2a9c06dcc7a60a4c2726.tar.zst
gsoc2013-evolution-7ab4ccfe7670d38a00fa2a9c06dcc7a60a4c2726.zip
change this to check the store using the provider url_cmp and just lookup
2004-01-16 Not Zed <NotZed@Ximian.com> * mail-folder-cache.c (storeinfo_find_folder_info): change this to check the store using the provider url_cmp and just lookup the folder name directly. folder_compare can't be used for uri's, this stuff was so broken, my fault :( ** See bug #52467. * em-folder-tree-model.c (sort_cb): handle null path (root?). * mail-vfolder.c (mail_vfolder_add_uri): map uri to euri before processing. (rule_changed): map uri to camel uri before looking up. (mail_vfolder_delete_uri): handle as euri internally. (mail_vfolder_rename_uri): " * mail-autofilter.c (vfolder_rule_from_message): map camel uri to euri before setting as vfolder source. svn path=/trunk/; revision=24266
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog20
-rw-r--r--mail/em-folder-tree-model.c16
-rw-r--r--mail/mail-autofilter.c8
-rw-r--r--mail/mail-folder-cache.c18
-rw-r--r--mail/mail-vfolder.c66
5 files changed, 103 insertions, 25 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 4280d4aa02..a73e8cc722 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,25 @@
2004-01-16 Not Zed <NotZed@Ximian.com>
+ * mail-folder-cache.c (storeinfo_find_folder_info): change this to
+ check the store using the provider url_cmp and just lookup the
+ folder name directly. folder_compare can't be used for uri's,
+ this stuff was so broken, my fault :(
+
+ ** See bug #52467.
+
+ * em-folder-tree-model.c (sort_cb): handle null path (root?).
+
+ * mail-vfolder.c (mail_vfolder_add_uri): map uri to euri before
+ processing.
+ (rule_changed): map uri to camel uri before looking up.
+ (mail_vfolder_delete_uri): handle as euri internally.
+ (mail_vfolder_rename_uri): "
+
+ * mail-autofilter.c (vfolder_rule_from_message): map camel uri to
+ euri before setting as vfolder source.
+
+2004-01-16 Not Zed <NotZed@Ximian.com>
+
* default/C/Inbox:
* default/C/Makefile.am:
* default/Makefile.am: Startup files/folders.
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index 6f409cfb05..fc29c5e761 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -214,12 +214,20 @@ sort_cb (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data
return -1;
path = gtk_tree_model_get_path (model, a);
- aname = gtk_tree_path_to_string (path);
- gtk_tree_path_free (path);
+ if (path) {
+ aname = gtk_tree_path_to_string (path);
+ gtk_tree_path_free (path);
+ } else {
+ aname = g_strdup("");
+ }
path = gtk_tree_model_get_path (model, b);
- bname = gtk_tree_path_to_string (path);
- gtk_tree_path_free (path);
+ if (path) {
+ bname = gtk_tree_path_to_string (path);
+ gtk_tree_path_free (path);
+ } else {
+ bname = g_strdup("");
+ }
ret = strcmp (aname, bname);
g_free (aname);
diff --git a/mail/mail-autofilter.c b/mail/mail-autofilter.c
index 79ab30f5dd..5d8de5fcad 100644
--- a/mail/mail-autofilter.c
+++ b/mail/mail-autofilter.c
@@ -326,11 +326,13 @@ FilterRule *
vfolder_rule_from_message (VfolderContext *context, CamelMimeMessage *msg, int flags, const char *source)
{
VfolderRule *rule;
-
+ char *euri = em_uri_from_camel(source);
+
rule = vfolder_rule_new ();
- vfolder_rule_add_source (rule, source);
+ vfolder_rule_add_source (rule, euri);
rule_from_message ((FilterRule *)rule, (RuleContext *)context, msg, flags);
-
+ g_free(euri);
+
return (FilterRule *)rule;
}
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index 750f9ab30d..285f1d1230 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -932,24 +932,34 @@ mail_note_store(CamelStore *store, CamelOperation *op,
struct _find_info {
const char *uri;
struct _folder_info *fi;
+ CamelURL *url;
};
/* look up on each storeinfo using proper hash function for that stores uri's */
static void storeinfo_find_folder_info(CamelStore *store, struct _store_info *si, struct _find_info *fi)
{
- if (fi->fi == NULL)
- fi->fi = g_hash_table_lookup(si->folders_uri, fi->uri);
+ if (fi->fi == NULL) {
+ if (((CamelService *)store)->provider->url_equal(fi->url, ((CamelService *)store)->url)) {
+ char *path = fi->url->fragment?fi->url->fragment:fi->url->path;
+
+ if (path[0] == '/')
+ path++;
+ fi->fi = g_hash_table_lookup(si->folders, path);
+ }
+ }
}
/* returns TRUE if the uri is available, folderp is set to a
reffed folder if the folder has also already been opened */
int mail_note_get_folder_from_uri(const char *uri, CamelFolder **folderp)
{
- struct _find_info fi = { uri, NULL };
+ struct _find_info fi = { uri, NULL, NULL };
if (stores == NULL)
return FALSE;
+ fi.url = camel_url_new(uri, NULL);
+
LOCK(info_lock);
g_hash_table_foreach(stores, (GHFunc)storeinfo_find_folder_info, &fi);
if (folderp) {
@@ -962,5 +972,7 @@ int mail_note_get_folder_from_uri(const char *uri, CamelFolder **folderp)
}
UNLOCK(info_lock);
+ camel_url_free(fi.url);
+
return fi.fi != NULL;
}
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index f014e42d08..963006c915 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -168,6 +168,7 @@ static struct _mail_msg_op vfolder_setup_op = {
vfolder_setup_free,
};
+/* sources_uri should be camel uri's */
static int
vfolder_setup(CamelFolder *folder, const char *query, GList *sources_uri, GList *sources_folder)
{
@@ -261,6 +262,8 @@ static struct _mail_msg_op vfolder_adduri_op = {
vfolder_adduri_free,
};
+
+/* uri should be a camel uri */
static int
vfolder_adduri(const char *uri, GList *folders, int remove)
{
@@ -292,6 +295,7 @@ my_list_find(GList *l, const char *uri, GCompareFunc cmp)
return l;
}
+/* uri is a camel uri */
static int
uri_is_ignore(const char *uri, GCompareFunc uri_cmp)
{
@@ -331,7 +335,7 @@ uri_is_ignore(const char *uri, GCompareFunc uri_cmp)
/* called when a new uri becomes (un)available */
void
-mail_vfolder_add_uri(CamelStore *store, const char *uri, int remove)
+mail_vfolder_add_uri(CamelStore *store, const char *curi, int remove)
{
FilterRule *rule;
const char *source;
@@ -340,13 +344,17 @@ mail_vfolder_add_uri(CamelStore *store, const char *uri, int remove)
int remote = (((CamelService *)store)->provider->flags & CAMEL_PROVIDER_IS_REMOTE) != 0;
GCompareFunc uri_cmp = CAMEL_STORE_CLASS(CAMEL_OBJECT_GET_CLASS(store))->compare_folder_name;
int is_ignore;
+ char *uri;
- if (CAMEL_IS_VEE_STORE(store) || !strncmp(uri, "vtrash:", 7) || !strncmp(uri, "vjunk:", 6) || context == NULL)
+ uri = em_uri_from_camel(curi);
+ if (CAMEL_IS_VEE_STORE(store) || !strncmp(curi, "vtrash:", 7) || !strncmp(curi, "vjunk:", 6) || context == NULL) {
+ g_free(uri);
return;
+ }
g_assert(pthread_self() == mail_gui_thread);
- is_ignore = uri_is_ignore(uri, uri_cmp);
+ is_ignore = uri_is_ignore(curi, uri_cmp);
LOCK();
@@ -395,9 +403,15 @@ mail_vfolder_add_uri(CamelStore *store, const char *uri, int remove)
/* we check using the store uri_cmp since its more accurate */
source = NULL;
- while (!found && (source = vfolder_rule_next_source((VfolderRule *)rule, source)))
- found = uri_cmp(uri, source);
-
+ while (!found && (source = vfolder_rule_next_source((VfolderRule *)rule, source))) {
+ char *esource;
+
+ esource = em_uri_from_camel(source);
+ found = uri_cmp(uri, esource);
+ d(printf(found?" '%s' == '%s'?\n":" '%s' != '%s'\n", uri, esource));
+ g_free(esource);
+ }
+
if (found) {
vf = g_hash_table_lookup(vfolder_hash, rule->name);
g_assert(vf);
@@ -409,22 +423,27 @@ mail_vfolder_add_uri(CamelStore *store, const char *uri, int remove)
UNLOCK();
if (folders != NULL)
- vfolder_adduri(uri, folders, remove);
+ vfolder_adduri(curi, folders, remove);
+
+ g_free(uri);
}
/* called when a uri is deleted from a store */
void
-mail_vfolder_delete_uri(CamelStore *store, const char *uri)
+mail_vfolder_delete_uri(CamelStore *store, const char *curi)
{
GCompareFunc uri_cmp = CAMEL_STORE_CLASS(CAMEL_OBJECT_GET_CLASS(store))->compare_folder_name;
FilterRule *rule;
const char *source;
CamelVeeFolder *vf;
GString *changed;
+ char *uri;
- if (context == NULL || !strncmp(uri, "vtrash:", 7) || !strncmp(uri, "vjunk:", 6))
+ if (context == NULL || !strncmp(curi, "vtrash:", 7) || !strncmp(curi, "vjunk:", 6))
return;
-
+
+ uri = em_uri_from_camel(curi);
+
d(printf ("Deleting uri to check: %s\n", uri));
g_assert (pthread_self() == mail_gui_thread);
@@ -474,25 +493,31 @@ mail_vfolder_delete_uri(CamelStore *store, const char *uri)
}
g_string_free (changed, TRUE);
+
+ g_free(uri);
}
/* called when a uri is renamed in a store */
void
-mail_vfolder_rename_uri(CamelStore *store, const char *from, const char *to)
+mail_vfolder_rename_uri(CamelStore *store, const char *cfrom, const char *cto)
{
GCompareFunc uri_cmp = CAMEL_STORE_CLASS(CAMEL_OBJECT_GET_CLASS(store))->compare_folder_name;
FilterRule *rule;
const char *source;
CamelVeeFolder *vf;
int changed = 0;
+ char *from, *to;
d(printf("vfolder rename uri: %s to %s\n", from, to));
- if (context == NULL || !strncmp(from, "vtrash:", 7) || !strncmp(to, "vtrash:", 7) || !strncmp(from, "vjunk:", 6) || !strncmp(to, "vjunk:", 6))
+ if (context == NULL || !strncmp(cfrom, "vtrash:", 7) || !strncmp(cto, "vtrash:", 7) || !strncmp(cfrom, "vjunk:", 6) || !strncmp(cto, "vjunk:", 6))
return;
g_assert(pthread_self() == mail_gui_thread);
+ from = em_uri_from_camel(cfrom);
+ to = em_uri_from_camel(cto);
+
LOCK();
/* see if any rules directly reference this removed uri */
@@ -527,6 +552,9 @@ mail_vfolder_rename_uri(CamelStore *store, const char *from, const char *to)
rule_context_save((RuleContext *)context, user);
g_free(user);
}
+
+ g_free(from);
+ g_fre(to);
}
/* ********************************************************************** */
@@ -571,12 +599,17 @@ rule_changed(FilterRule *rule, CamelFolder *folder)
/* find any (currently available) folders, and add them to the ones to open */
sourceuri = NULL;
while ( (sourceuri = vfolder_rule_next_source((VfolderRule *)rule, sourceuri)) ) {
- if (mail_note_get_folder_from_uri(sourceuri, &newfolder)) {
+ char *curi = em_uri_to_camel(sourceuri);
+
+ d(printf(" adding source '%s' '%s'\n", sourceuri, curi));
+ if (mail_note_get_folder_from_uri(curi, &newfolder)) {
if (newfolder)
sources_folder = g_list_append(sources_folder, newfolder);
else
sources_uri = g_list_append(sources_uri, g_strdup(sourceuri));
}
+
+ g_free(curi);
}
/* check the remote/local uri lists for any other uri's that should be looked at */
@@ -591,14 +624,17 @@ rule_changed(FilterRule *rule, CamelFolder *folder)
l = NULL;
while (l) {
- if (mail_note_get_folder_from_uri(l->data, &newfolder)) {
+ char *curi = em_uri_to_camel(l->data);
+
+ if (mail_note_get_folder_from_uri(curi, &newfolder)) {
if (newfolder)
sources_folder = g_list_append(sources_folder, newfolder);
else
- sources_uri = g_list_append(sources_uri, g_strdup(l->data));
+ sources_uri = g_list_append(sources_uri, g_strdup(curi));
} else {
d(printf(" -> No such folder?\n"));
}
+ g_free(curi);
l = l->next;
}
}