aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/ChangeLog22
-rw-r--r--mail/component-factory.c11
-rw-r--r--mail/mail-folder-cache.c55
-rw-r--r--mail/mail-folder-cache.h3
-rw-r--r--mail/mail-vfolder.c75
-rw-r--r--mail/mail-vfolder.h11
6 files changed, 124 insertions, 53 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 479fe8048f..0271cb3e87 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,25 @@
+2001-10-18 <NotZed@Ximian.com>
+
+ * 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.
+ (mail_vfolder_remove_uri): Changed to mail_vfolder_delte_uri, to
+ indicate its actually been deleted.
+ (mail_vfolder_add_uri): Added remove flag.
+ (rule_changed): When adding existing folders to a new rule, strdup
+ the list data.
+
+ * mail-folder-cache.c (store_finalised): Unhook from all events
+ when done.
+ (mail_note_store_remove): Remove a store from being noted.
+ (free_folder_info): Also if we have a folder, unhook all events.
+ Also remove the uri from vfolders.
+ (mail_note_folder): Remove warning about adding folders to stores
+ that aren't added yet - we might actually be removing the store.
+
+ * component-factory.c (mail_remove_storage): Call
+ mail_note_store_remove when we remove the storage.
+
2001-10-18 Jeffrey Stedfast <fejj@ximian.com>
* mail-callbacks.c (providers_config): Don't make the mail
diff --git a/mail/component-factory.c b/mail/component-factory.c
index 52f249b840..64e92101a9 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -130,11 +130,8 @@ storage_activate (BonoboControl *control, gboolean activate,
camel_exception_clear (&ex);
storage = g_hash_table_lookup (storages_hash, store);
- if (storage &&
- !gtk_object_get_data (GTK_OBJECT (storage), "connected")) {
- mail_note_store (CAMEL_STORE(store), storage,
- CORBA_OBJECT_NIL, NULL, NULL);
- }
+ if (storage && !gtk_object_get_data (GTK_OBJECT (storage), "connected"))
+ mail_note_store (CAMEL_STORE(store), storage, CORBA_OBJECT_NIL, NULL, NULL);
camel_object_unref (CAMEL_OBJECT (store));
}
@@ -1207,6 +1204,10 @@ mail_remove_storage (CamelStore *store)
storage = g_hash_table_lookup (storages_hash, store);
g_hash_table_remove (storages_hash, store);
+
+ /* so i guess potentially we could have a race, add a store while one
+ being removed. ?? */
+ mail_note_store_remove(store);
shell_client = evolution_shell_component_get_owner (shell_component);
corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client));
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index d60dcbddc3..710147a8a1 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -172,7 +172,7 @@ setup_folder(CamelFolderInfo *fi, struct _store_info *si)
}
if (strstr(fi->url, ";noselect") == NULL)
- mail_vfolder_add_uri(store, fi->url);
+ mail_vfolder_add_uri(store, fi->url, FALSE);
camel_object_unref((CamelObject *)store);
}
@@ -205,7 +205,7 @@ folder_finalised(CamelObject *o, gpointer event_data, gpointer user_data)
{
struct _folder_info *mfi = user_data;
- (printf("Folder finalised '%s'!\n", ((CamelFolder *)o)->full_name));
+ d(printf("Folder finalised '%s'!\n", ((CamelFolder *)o)->full_name));
mfi->folder = NULL;
}
@@ -214,7 +214,7 @@ folder_deleted(CamelObject *o, gpointer event_data, gpointer user_data)
{
struct _folder_info *mfi = user_data;
- (printf("Folder deleted '%s'!\n", ((CamelFolder *)o)->full_name));
+ d(printf("Folder deleted '%s'!\n", ((CamelFolder *)o)->full_name));
mfi->folder = NULL;
}
@@ -241,7 +241,7 @@ void mail_note_folder(CamelFolder *folder)
LOCK(info_lock);
si = g_hash_table_lookup(stores, store);
if (si == NULL) {
- g_warning("Adding a folder `%s' to a store %p which hasn't been added yet?\n", folder->full_name, store);
+ /*g_warning("Adding a folder `%s' to a store %p which hasn't been added yet?", folder->full_name, store);*/
UNLOCK(info_lock);
return;
}
@@ -313,7 +313,7 @@ real_folder_deleted(CamelStore *store, void *event_data, CamelFolderInfo *fi)
d(printf("real_folder_deleted: %s (%s)\n", fi->full_name, fi->url));
if (strstr(fi->url, ";noselect") == NULL)
- mail_vfolder_remove_uri(store, fi->url);
+ mail_vfolder_delete_uri(store, fi->url);
camel_object_unref((CamelObject *)store);
camel_folder_info_free(fi);
@@ -344,13 +344,28 @@ store_folder_deleted(CamelObject *o, void *event_data, void *data)
store_folder_unsubscribed(o, event_data, data);
}
+static void
+unset_folder_info(char *path, struct _folder_info *mfi, void *data)
+{
+ if (mfi->folder) {
+ CamelFolder *folder = mfi->folder;
+
+ camel_object_unhook_event((CamelObject *)folder, "folder_changed", folder_changed, mfi);
+ camel_object_unhook_event((CamelObject *)folder, "message_changed", folder_changed, mfi);
+ camel_object_unhook_event((CamelObject *)folder, "deleted", folder_deleted, mfi);
+ 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);
+}
static void
-free_folder_info(char *path, struct _folder_info *info, void *data)
+free_folder_info(char *path, struct _folder_info *mfi, void *data)
{
- g_free(info->path);
- g_free(info->full_name);
- g_free(info->uri);
+ g_free(mfi->path);
+ g_free(mfi->full_name);
+ g_free(mfi->uri);
}
static void
@@ -364,6 +379,14 @@ store_finalised(CamelObject *o, void *event_data, void *data)
si = g_hash_table_lookup(stores, store);
if (si) {
g_hash_table_remove(stores, store);
+
+ camel_object_unhook_event((CamelObject *)store, "folder_created", store_folder_created, NULL);
+ camel_object_unhook_event((CamelObject *)store, "folder_deleted", store_folder_deleted, NULL);
+ camel_object_unhook_event((CamelObject *)store, "folder_subscribed", store_folder_subscribed, NULL);
+ 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);
UNLOCK(info_lock);
mail_async_event_destroy(si->async_event);
LOCK(info_lock);
@@ -377,7 +400,7 @@ store_finalised(CamelObject *o, void *event_data, void *data)
static void
create_folders(CamelFolderInfo *fi, struct _store_info *si)
{
- printf("Setup new folder: %s\n", fi->url);
+ d(printf("Setup new folder: %s\n", fi->url));
setup_folder(fi, si);
@@ -409,6 +432,18 @@ update_folders(CamelStore *store, CamelFolderInfo *info, void *data)
}
void
+mail_note_store_remove(CamelStore *store)
+{
+ g_assert(CAMEL_IS_STORE(store));
+
+ if (stores == NULL)
+ return;
+
+ /* same action */
+ store_finalised((CamelObject *)store, NULL, NULL);
+}
+
+void
mail_note_store(CamelStore *store, EvolutionStorage *storage, GNOME_Evolution_Storage corba_storage,
void (*done)(CamelStore *store, CamelFolderInfo *info, void *data), void *data)
{
diff --git a/mail/mail-folder-cache.h b/mail/mail-folder-cache.h
index 92cbfa6739..b8074d0fb3 100644
--- a/mail/mail-folder-cache.h
+++ b/mail/mail-folder-cache.h
@@ -35,6 +35,9 @@ void
mail_note_store(CamelStore *store, EvolutionStorage *storage, GNOME_Evolution_Storage corba_storage,
void (*done)(CamelStore *store, CamelFolderInfo *info, void *data), void *data);
+/* de-note a store */
+void mail_note_store_remove(CamelStore *store);
+
/* When a folder has been opened, notify it for watching.
The folder must have already been created on the store (which has already been noted)
before the folder can be opened
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 771190e31e..477ae0d028 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -44,7 +44,7 @@
#include "e-util/e-unicode-i18n.h"
-#define d(x) x
+#define d(x)
static VfolderContext *context; /* context remains open all time */
static CamelStore *vfolder_store; /* the 1 static vfolder store */
@@ -99,7 +99,7 @@ vfolder_setup_do(struct _mail_msg *mm)
l = m->sources_uri;
while (l) {
- (printf(" Adding uri: %s\n", (char *)l->data));
+ d(printf(" Adding uri: %s\n", (char *)l->data));
folder = mail_tool_uri_to_folder (l->data, 0, &mm->ex);
if (folder) {
list = g_list_append(list, folder);
@@ -193,6 +193,7 @@ struct _adduri_msg {
char *uri;
GList *folders;
+ int remove;
};
static char *
@@ -208,13 +209,14 @@ vfolder_adduri_do(struct _mail_msg *mm)
{
struct _adduri_msg *m = (struct _adduri_msg *)mm;
GList *l;
- CamelFolder *folder;
+ CamelFolder *folder = NULL;
extern CamelFolder *drafts_folder, *outbox_folder, *sent_folder;
- d(printf("Adding uri to vfolder: %s\n", m->uri));
+ d(printf("%s uri to vfolder: %s\n", m->remove?"Removing":"Adding", m->uri));
- if (!mail_note_get_folder_from_uri(m->uri, &folder)) {
- g_warning("Folder '%s' disappeared while I was adding it to my vfolder", m->uri);
+ /* we dont try lookup the cache if we are removing it, its no longer there */
+ if (!m->remove && !mail_note_get_folder_from_uri(m->uri, &folder)) {
+ g_warning("Folder '%s' disappeared while I was adding/remove it to/from my vfolder", m->uri);
return;
}
@@ -225,7 +227,10 @@ vfolder_adduri_do(struct _mail_msg *mm)
if (folder != drafts_folder && folder != outbox_folder && folder != sent_folder) {
l = m->folders;
while (l) {
- camel_vee_folder_add_folder((CamelVeeFolder *)l->data, folder);
+ if (m->remove)
+ camel_vee_folder_remove_folder((CamelVeeFolder *)l->data, folder);
+ else
+ camel_vee_folder_add_folder((CamelVeeFolder *)l->data, folder);
l = l->next;
}
}
@@ -259,7 +264,7 @@ static struct _mail_msg_op vfolder_adduri_op = {
};
static int
-vfolder_adduri(const char *uri, GList *folders)
+vfolder_adduri(const char *uri, GList *folders, int remove)
{
struct _adduri_msg *m;
int id;
@@ -267,6 +272,7 @@ vfolder_adduri(const char *uri, GList *folders)
m = mail_msg_new(&vfolder_adduri_op, NULL, sizeof (*m));
m->folders = folders;
m->uri = g_strdup(uri);
+ m->remove = remove;
id = m->msg.seq;
e_thread_put(mail_thread_queued_slow, (EMsg *)m);
@@ -288,14 +294,14 @@ my_list_find(GList *l, const char *uri, GCompareFunc cmp)
return l;
}
-/* called when a new uri becomes available */
+/* called when a new uri becomes (un)available */
void
-mail_vfolder_add_uri(CamelStore *store, const char *uri)
+mail_vfolder_add_uri(CamelStore *store, const char *uri, int remove)
{
FilterRule *rule;
const char *source;
CamelVeeFolder *vf;
- GList *folders = NULL;
+ 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;
@@ -304,15 +310,29 @@ mail_vfolder_add_uri(CamelStore *store, const char *uri)
LOCK();
- printf("Adding uri to check: %s\n", uri);
+ d(printf("Removing uri to check: %s\n", remove?"Removing":"Adding", uri));
/* maintain the source folders lists for changed rules later on */
- 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 (remove) {
+ 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);
+ }
+ }
} 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 (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));
+ } 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));
+ }
}
rule = NULL;
@@ -329,7 +349,7 @@ mail_vfolder_add_uri(CamelStore *store, const char *uri)
source = NULL;
while ( !found && (source = vfolder_rule_next_source((VfolderRule *)rule, source)) )
found = uri_cmp(uri, source);
-
+
if (found) {
vf = g_hash_table_lookup(vfolder_hash, rule->name);
g_assert(vf);
@@ -341,12 +361,12 @@ mail_vfolder_add_uri(CamelStore *store, const char *uri)
UNLOCK();
if (folders != NULL)
- vfolder_adduri(uri, folders);
+ vfolder_adduri(uri, folders, remove);
}
-/* called when a uri is removed from a store */
+/* called when a uri is deleted from a store */
void
-mail_vfolder_remove_uri(CamelStore *store, const char *uri)
+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;
@@ -359,7 +379,7 @@ mail_vfolder_remove_uri(CamelStore *store, const char *uri)
if (CAMEL_IS_VEE_STORE(store) || !strncmp(uri, "vtrash:", 7))
return;
- printf("Removing uri to check: %s\n", uri);
+ d(printf("Deleting uri to check: %s\n", uri));
g_assert(pthread_self() == mail_gui_thread);
@@ -380,8 +400,6 @@ mail_vfolder_remove_uri(CamelStore *store, const char *uri)
}
}
- printf("vfolder remove uri: %s\n", uri);
-
/* check to see if a rule needs updating, if it does, make out it changed which will re-build it */
rule = NULL;
while ( (rule = rule_context_next_rule((RuleContext *)context, rule, NULL)) ) {
@@ -512,7 +530,7 @@ rule_changed(FilterRule *rule, CamelFolder *folder)
if (newfolder)
sources_folder = g_list_append(sources_folder, newfolder);
else
- sources_uri = g_list_append(sources_uri, g_strdup(sourceuri));
+ sources_uri = g_list_append(sources_uri, g_strdup(l->data));
} else {
printf(" -> No such folder?\n");
}
@@ -839,13 +857,6 @@ vfolder_gui_add_from_mlist(CamelMimeMessage *msg, const char *mlist, const char
vfolder_gui_add_rule(rule);
}
-EvolutionStorage *
-mail_vfolder_get_vfolder_storage (void)
-{
- return mail_lookup_storage(vfolder_store);
-}
-
-
static void
vfolder_foreach_cb (gpointer key, gpointer data, gpointer user_data)
{
diff --git a/mail/mail-vfolder.h b/mail/mail-vfolder.h
index f72adc35b4..4dde188a69 100644
--- a/mail/mail-vfolder.h
+++ b/mail/mail-vfolder.h
@@ -21,14 +21,13 @@ void vfolder_gui_add_rule (VfolderRule *rule);
void vfolder_gui_add_from_message (CamelMimeMessage *msg, int flags, const char *source);
void vfolder_gui_add_from_mlist (CamelMimeMessage *msg, const char *mlist, const char *source);
-/* add a uri that is now available to vfolders */
-void mail_vfolder_add_uri(CamelStore *store, const char *uri);
+/* add a uri that is now (un)available to vfolders in a transient manner */
+void mail_vfolder_add_uri(CamelStore *store, const char *uri, int remove);
-/* remove a uri that should be removed from vfolders */
-void mail_vfolder_remove_uri(CamelStore *store, const char *uri);
-
-EvolutionStorage *mail_vfolder_get_vfolder_storage (void);
+/* remove a uri that should be removed from vfolders permanently */
+void mail_vfolder_delete_uri(CamelStore *store, const char *uri);
+/* close up, clean up */
void mail_vfolder_shutdown (void);
#endif