aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author9 <NotZed@Ximian.com>2001-10-19 13:40:42 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-10-19 13:40:42 +0800
commit3e6cd9a7e55a6c19d73a86195ff320b6dff76d54 (patch)
treeb0a58e239142420e6fbf3220ea18a55b617cc406
parent0515ef5e4d5d138f1f7e9956b7a643cc01d7cf19 (diff)
downloadgsoc2013-evolution-3e6cd9a7e55a6c19d73a86195ff320b6dff76d54.tar
gsoc2013-evolution-3e6cd9a7e55a6c19d73a86195ff320b6dff76d54.tar.gz
gsoc2013-evolution-3e6cd9a7e55a6c19d73a86195ff320b6dff76d54.tar.bz2
gsoc2013-evolution-3e6cd9a7e55a6c19d73a86195ff320b6dff76d54.tar.lz
gsoc2013-evolution-3e6cd9a7e55a6c19d73a86195ff320b6dff76d54.tar.xz
gsoc2013-evolution-3e6cd9a7e55a6c19d73a86195ff320b6dff76d54.tar.zst
gsoc2013-evolution-3e6cd9a7e55a6c19d73a86195ff320b6dff76d54.zip
Free folders_uri. (real_folder_deleted): If folder is deleted, remove it
2001-10-19 <NotZed@Ximian.com> * mail-folder-cache.c (store_finalised): Free folders_uri. (real_folder_deleted): If folder is deleted, remove it from the hashtables. * subscribe-dialog.c (get_short_folderinfo_get): Remove the register/unregister, they're already done above us. * mail-vfolder.c (mail_vfolder_delete_uri): Dont do any work to remove the actual folder from the vfolder (we'd have to look it up first), let the vfolder remove it itself. Just update the rules. svn path=/trunk/; revision=13787
-rw-r--r--mail/ChangeLog12
-rw-r--r--mail/mail-folder-cache.c41
-rw-r--r--mail/mail-vfolder.c47
-rw-r--r--mail/subscribe-dialog.c2
4 files changed, 59 insertions, 43 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 0271cb3e87..f896a869ba 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,14 @@
+2001-10-19 <NotZed@Ximian.com>
+
+ * mail-folder-cache.c (store_finalised): Free folders_uri.
+ (real_folder_deleted): If folder is deleted, remove it from the
+ hashtables.
+
2001-10-18 <NotZed@Ximian.com>
+ * subscribe-dialog.c (get_short_folderinfo_get): Remove the
+ register/unregister, they're already done above us.
+
* mail-vfolder.c (vfolder_adduri): Added remove flag - its not
adduri, its removeuri, its less typing than creating a removeuri.
(vfolder_adduri_do): Implement the remove flag.
@@ -8,6 +17,9 @@
(mail_vfolder_add_uri): Added remove flag.
(rule_changed): When adding existing folders to a new rule, strdup
the list data.
+ (mail_vfolder_delete_uri): Dont do any work to remove the actual
+ folder from the vfolder (we'd have to look it up first), let the
+ vfolder remove it itself. Just update the rules.
* mail-folder-cache.c (store_finalised): Unhook from all events
when done.
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index 710147a8a1..d91fc1c8e1 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -75,6 +75,10 @@ struct _store_info {
static GHashTable *stores;
+static void free_folder_info(char *path, struct _folder_info *mfi, void *data);
+static void unset_folder_info(struct _folder_info *mfi, int delete);
+
+
/* This is how unread counts work (and don't work):
*
* camel_folder_unread_message_count() only gives a correct answer if
@@ -308,13 +312,22 @@ store_folder_created(CamelObject *o, void *event_data, void *data)
static void
-real_folder_deleted(CamelStore *store, void *event_data, CamelFolderInfo *fi)
+real_folder_deleted(CamelStore *store, struct _store_info *si, CamelFolderInfo *fi)
{
+ struct _folder_info *mfi;
+
d(printf("real_folder_deleted: %s (%s)\n", fi->full_name, fi->url));
-
- if (strstr(fi->url, ";noselect") == NULL)
- mail_vfolder_delete_uri(store, fi->url);
+ LOCK(info_lock);
+ mfi = g_hash_table_lookup(si->folders, fi->full_name);
+ if (mfi) {
+ g_hash_table_remove(si->folders, mfi->full_name);
+ g_hash_table_remove(si->folders_uri, mfi->uri);
+ unset_folder_info(mfi, TRUE);
+ free_folder_info(NULL, mfi, NULL);
+ }
+ UNLOCK(info_lock);
+
camel_object_unref((CamelObject *)store);
camel_folder_info_free(fi);
}
@@ -345,7 +358,7 @@ store_folder_deleted(CamelObject *o, void *event_data, void *data)
}
static void
-unset_folder_info(char *path, struct _folder_info *mfi, void *data)
+unset_folder_info(struct _folder_info *mfi, int delete)
{
if (mfi->folder) {
CamelFolder *folder = mfi->folder;
@@ -356,10 +369,21 @@ unset_folder_info(char *path, struct _folder_info *mfi, void *data)
camel_object_unhook_event((CamelObject *)folder, "finalize", folder_finalised, mfi);
}
- if (strstr(mfi->uri, ";noselect") == NULL)
- mail_vfolder_add_uri(mfi->store_info->store, mfi->uri, TRUE);
+ if (strstr(mfi->uri, ";noselect") == NULL) {
+ if (delete)
+ mail_vfolder_delete_uri(mfi->store_info->store, mfi->uri);
+ else
+ mail_vfolder_add_uri(mfi->store_info->store, mfi->uri, TRUE);
+ }
+}
+
+static void
+unset_folder_info_hash(char *path, struct _folder_info *mfi, void *data)
+{
+ unset_folder_info(mfi, FALSE);
}
+
static void
free_folder_info(char *path, struct _folder_info *mfi, void *data)
{
@@ -386,12 +410,13 @@ store_finalised(CamelObject *o, void *event_data, void *data)
camel_object_unhook_event((CamelObject *)store, "folder_unsubscribed", store_folder_unsubscribed, NULL);
camel_object_unhook_event((CamelObject *)store, "finalize", store_finalised, NULL);
- g_hash_table_foreach(si->folders, (GHFunc)unset_folder_info, NULL);
+ g_hash_table_foreach(si->folders, (GHFunc)unset_folder_info_hash, NULL);
UNLOCK(info_lock);
mail_async_event_destroy(si->async_event);
LOCK(info_lock);
g_hash_table_foreach(si->folders, (GHFunc)free_folder_info, NULL);
g_hash_table_destroy(si->folders);
+ g_hash_table_destroy(si->folders_uri);
g_free(si);
}
UNLOCK(info_lock);
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 477ae0d028..12c70d0e0c 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -308,9 +308,11 @@ mail_vfolder_add_uri(CamelStore *store, const char *uri, int remove)
if (CAMEL_IS_VEE_STORE(store) || !strncmp(uri, "vtrash:", 7))
return;
+ g_assert(pthread_self() == mail_gui_thread);
+
LOCK();
- d(printf("Removing uri to check: %s\n", remove?"Removing":"Adding", uri));
+ d(printf("%s uri to check: %s\n", remove?"Removing":"Adding", uri));
/* maintain the source folders lists for changed rules later on */
if (remove) {
@@ -368,9 +370,7 @@ mail_vfolder_add_uri(CamelStore *store, const char *uri, int remove)
void
mail_vfolder_delete_uri(CamelStore *store, const char *uri)
{
- 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;
- GList *link;
FilterRule *rule;
const char *source;
CamelVeeFolder *vf;
@@ -387,41 +387,22 @@ mail_vfolder_delete_uri(CamelStore *store, const char *uri)
LOCK();
- /* maintain remote/local lists */
- if (remote) {
- 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);
- }
- } else {
- 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);
- }
- }
-
- /* check to see if a rule needs updating, if it does, make out it changed which will re-build it */
+ /* see if any rules directly reference this removed uri */
rule = NULL;
while ( (rule = rule_context_next_rule((RuleContext *)context, rule, NULL)) ) {
- int found = FALSE;
-
source = NULL;
- while ( !found && (source = vfolder_rule_next_source((VfolderRule *)rule, source)) )
- found = uri_cmp(uri, source);
-
- if (found
- || (rule->source
- && ((!strcmp(rule->source, "local") && !remote)
- || (!strcmp(rule->source, "remote_active") && remote)
- || (!strcmp(rule->source, "local_remote_active"))))) {
-
- vf = g_hash_table_lookup(vfolder_hash, rule->name);
- g_assert(vf);
- if (source) {
+ while ( (source = vfolder_rule_next_source((VfolderRule *)rule, source)) ) {
+ /* Remove all sources that match, ignore changed events though
+ because the adduri call above does the work async */
+ if (uri_cmp(uri, source)) {
+ vf = g_hash_table_lookup(vfolder_hash, rule->name);
+ g_assert(vf);
+ gtk_signal_disconnect_by_func((GtkObject *)rule, rule_changed, vf);
vfolder_rule_remove_source((VfolderRule *)rule, source);
+ gtk_signal_connect((GtkObject *)rule, "changed", rule_changed, vf);
g_string_sprintfa(changed, " %s\n", rule->name);
- } else
- rule_changed(rule, (CamelFolder *)vf);
+ source = NULL;
+ }
}
}
diff --git a/mail/subscribe-dialog.c b/mail/subscribe-dialog.c
index ead4d0a209..9a2427b39e 100644
--- a/mail/subscribe-dialog.c
+++ b/mail/subscribe-dialog.c
@@ -229,9 +229,7 @@ get_short_folderinfo_get (struct _mail_msg *mm)
{
struct _get_short_folderinfo_msg *m = (struct _get_short_folderinfo_msg *) mm;
- camel_operation_register (mm->cancel);
m->info = camel_store_get_folder_info (m->ftree->store, m->prefix, CAMEL_STORE_FOLDER_INFO_FAST, &mm->ex);
- camel_operation_unregister (mm->cancel);
}
static void