aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-vfolder.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2005-01-17 17:00:28 +0800
committerMichael Zucci <zucchi@src.gnome.org>2005-01-17 17:00:28 +0800
commit5c440f07f1ef24cfa6013c57a8859f5636689ba8 (patch)
tree1b2f42cb09d1674c1778e44275b9b0422204aa91 /mail/mail-vfolder.c
parentf143158ccc1d6c5b98002f3020bc3b5695137f29 (diff)
downloadgsoc2013-evolution-5c440f07f1ef24cfa6013c57a8859f5636689ba8.tar.gz
gsoc2013-evolution-5c440f07f1ef24cfa6013c57a8859f5636689ba8.tar.zst
gsoc2013-evolution-5c440f07f1ef24cfa6013c57a8859f5636689ba8.zip
** Related to changes for #65178.
2005-01-14 Not Zed <NotZed@Ximian.com> ** Related to changes for #65178. * mail-vfolder.c (mv_find_folder): changed from my_list_find, take store arg and use camel_Store_Folder_uri_equal() instead of wrong uri_cmp function. (mail_vfolder_delete_uri): same. (mail_vfolder_rename_uri): same. (uri_is_ignore): take store arg, and same as above. use the right uri for checking sent folder. (mail_vfolder_*): convert to storing uri's in camel form. svn path=/trunk/; revision=28417
Diffstat (limited to 'mail/mail-vfolder.c')
-rw-r--r--mail/mail-vfolder.c75
1 files changed, 43 insertions, 32 deletions
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index e600a34635..bbb839eb9a 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -321,12 +321,11 @@ vfolder_adduri(const char *uri, GList *folders, int remove)
/* ********************************************************************** */
-/* So, uh, apparently g_list_find_custom expect the compare func to return 0 to mean true? */
static GList *
-my_list_find(GList *l, const char *uri, GCompareFunc cmp)
+mv_find_folder(GList *l, CamelStore *store, const char *uri)
{
while (l) {
- if (cmp(l->data, uri))
+ if (camel_store_folder_uri_equal(store, l->data, uri))
break;
l = l->next;
}
@@ -335,7 +334,7 @@ my_list_find(GList *l, const char *uri, GCompareFunc cmp)
/* uri is a camel uri */
static int
-uri_is_ignore(const char *uri, GCompareFunc uri_cmp)
+uri_is_ignore(CamelStore *store, const char *uri)
{
EAccountList *accounts;
EAccount *account;
@@ -347,9 +346,9 @@ uri_is_ignore(const char *uri, GCompareFunc uri_cmp)
mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_SENT),
mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_DRAFTS)));
- found = uri_cmp(mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_OUTBOX), uri)
- || uri_cmp(mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_SENT), uri)
- || uri_cmp(mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_DRAFTS), uri);
+ found = camel_store_folder_uri_equal(store, mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_OUTBOX), uri)
+ || camel_store_folder_uri_equal(store, mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_SENT), uri)
+ || camel_store_folder_uri_equal(store, mail_component_get_folder_uri(NULL, MAIL_COMPONENT_FOLDER_DRAFTS), uri);
if (found)
return found;
@@ -357,14 +356,24 @@ uri_is_ignore(const char *uri, GCompareFunc uri_cmp)
accounts = mail_config_get_accounts ();
iter = e_list_get_iterator ((EList *) accounts);
while (e_iterator_is_valid (iter)) {
+ char *curi;
+
account = (EAccount *) e_iterator_get (iter);
-
+
d(printf("checking sent_folder_uri '%s' == '%s'\n",
account->sent_folder_uri ? account->sent_folder_uri : "empty", uri));
-
- found = (account->sent_folder_uri && uri_cmp (account->sent_folder_uri, uri))
- || (account->drafts_folder_uri && uri_cmp (account->drafts_folder_uri, uri));
-
+
+ if (account->sent_folder_uri) {
+ curi = em_uri_to_camel(account->sent_folder_uri);
+ found = camel_store_folder_uri_equal(store, uri, curi);
+ g_free(curi);
+ }
+ if (!found && account->drafts_folder_uri) {
+ curi = em_uri_to_camel(account->drafts_folder_uri);
+ found = camel_store_folder_uri_equal(store, uri, curi);
+ g_free(curi);
+ }
+
if (found)
break;
@@ -420,7 +429,6 @@ mail_vfolder_add_uri(CamelStore *store, const char *curi, int remove)
CamelVeeFolder *vf;
GList *folders = NULL, *link;
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;
@@ -432,7 +440,7 @@ mail_vfolder_add_uri(CamelStore *store, const char *curi, int remove)
g_assert(pthread_self() == mail_gui_thread);
- is_ignore = uri_is_ignore(curi, uri_cmp);
+ is_ignore = uri_is_ignore(store, curi);
LOCK();
@@ -443,12 +451,12 @@ mail_vfolder_add_uri(CamelStore *store, const char *curi, int remove)
is_ignore = TRUE;
} else if (remove) {
if (remote) {
- if ((link = my_list_find(source_folders_remote, (void *)uri, uri_cmp)) != NULL) {
+ if ((link = mv_find_folder(source_folders_remote, store, curi)) != NULL) {
g_free(link->data);
source_folders_remote = g_list_remove_link(source_folders_remote, link);
}
} else {
- if ((link = my_list_find(source_folders_local, (void *)uri, uri_cmp)) != NULL) {
+ if ((link = mv_find_folder(source_folders_local, store, curi)) != NULL) {
g_free(link->data);
source_folders_local = g_list_remove_link(source_folders_local, link);
}
@@ -456,11 +464,11 @@ mail_vfolder_add_uri(CamelStore *store, const char *curi, int remove)
} else if (!is_ignore) {
/* we ignore drafts/sent/outbox here */
if (remote) {
- if (my_list_find(source_folders_remote, (void *)uri, uri_cmp) == NULL)
- source_folders_remote = g_list_prepend(source_folders_remote, g_strdup(uri));
+ if (mv_find_folder(source_folders_remote, store, curi) == NULL)
+ source_folders_remote = g_list_prepend(source_folders_remote, g_strdup(curi));
} else {
- if (my_list_find(source_folders_local, (void *)uri, uri_cmp) == NULL)
- source_folders_local = g_list_prepend(source_folders_local, g_strdup(uri));
+ if (mv_find_folder(source_folders_local, store, curi) == NULL)
+ source_folders_local = g_list_prepend(source_folders_local, g_strdup(curi));
}
}
@@ -481,15 +489,14 @@ mail_vfolder_add_uri(CamelStore *store, const char *curi, int remove)
|| (((EMVFolderRule *)rule)->with == EM_VFOLDER_RULE_WITH_LOCAL_REMOTE_ACTIVE)))
found = TRUE;
- /* we check using the store uri_cmp since its more accurate */
source = NULL;
while (!found && (source = em_vfolder_rule_next_source((EMVFolderRule *)rule, source))) {
- char *esource;
+ char *csource;
- 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);
+ csource = em_uri_to_camel(source);
+ found = camel_store_folder_uri_equal(store, curi, csource);
+ d(printf(found?" '%s' == '%s'?\n":" '%s' != '%s'\n", curi, csource));
+ g_free(csource);
}
if (found) {
@@ -512,7 +519,6 @@ mail_vfolder_add_uri(CamelStore *store, const char *curi, int remove)
void
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;
@@ -538,9 +544,11 @@ mail_vfolder_delete_uri(CamelStore *store, const char *curi)
while ((rule = rule_context_next_rule ((RuleContext *) context, rule, NULL))) {
source = NULL;
while ((source = em_vfolder_rule_next_source ((EMVFolderRule *) rule, source))) {
+ char *csource = em_uri_to_camel(source);
+
/* Remove all sources that match, ignore changed events though
because the adduri call above does the work async */
- if (uri_cmp (uri, source)) {
+ if (camel_store_folder_uri_equal(store, curi, csource)) {
vf = g_hash_table_lookup (vfolder_hash, rule->name);
g_assert (vf != NULL);
g_signal_handlers_disconnect_matched (rule, G_SIGNAL_MATCH_FUNC|G_SIGNAL_MATCH_DATA, 0,
@@ -550,15 +558,16 @@ mail_vfolder_delete_uri(CamelStore *store, const char *curi)
g_string_append_printf (changed, " %s\n", rule->name);
source = NULL;
}
+ g_free(csource);
}
}
- if ((link = my_list_find(source_folders_remote, (void *)uri, uri_cmp)) != NULL) {
+ if ((link = mv_find_folder(source_folders_remote, store, curi)) != 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) {
+ if ((link = mv_find_folder(source_folders_local, store, curi)) != NULL) {
g_free(link->data);
source_folders_local = g_list_remove_link(source_folders_local, link);
}
@@ -588,7 +597,6 @@ mail_vfolder_delete_uri(CamelStore *store, const char *curi)
void
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;
@@ -612,9 +620,11 @@ mail_vfolder_rename_uri(CamelStore *store, const char *cfrom, const char *cto)
while ( (rule = rule_context_next_rule((RuleContext *)context, rule, NULL)) ) {
source = NULL;
while ( (source = em_vfolder_rule_next_source((EMVFolderRule *)rule, source)) ) {
+ char *csource = em_uri_to_camel(source);
+
/* Remove all sources that match, ignore changed events though
because the adduri call above does the work async */
- if (uri_cmp(from, source)) {
+ if (camel_store_folder_uri_equal(store, cfrom, csource)) {
d(printf("Vfolder '%s' used '%s' ('%s') now uses '%s'\n", rule->name, source, from, to));
vf = g_hash_table_lookup(vfolder_hash, rule->name);
g_assert(vf);
@@ -626,6 +636,7 @@ mail_vfolder_rename_uri(CamelStore *store, const char *cfrom, const char *cto)
changed++;
source = NULL;
}
+ g_free(csource);
}
}