diff options
author | Not Zed <NotZed@Ximian.com> | 2004-05-04 15:48:14 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2004-05-04 15:48:14 +0800 |
commit | ce6bb045a6540369f3fe8159dad4d9b9600ba583 (patch) | |
tree | 2dff5763ff93949864168454598d4a8eec6c7ebd | |
parent | 3fc532ba3c45bfd87b82f095668549de57bee818 (diff) | |
download | gsoc2013-evolution-ce6bb045a6540369f3fe8159dad4d9b9600ba583.tar gsoc2013-evolution-ce6bb045a6540369f3fe8159dad4d9b9600ba583.tar.gz gsoc2013-evolution-ce6bb045a6540369f3fe8159dad4d9b9600ba583.tar.bz2 gsoc2013-evolution-ce6bb045a6540369f3fe8159dad4d9b9600ba583.tar.lz gsoc2013-evolution-ce6bb045a6540369f3fe8159dad4d9b9600ba583.tar.xz gsoc2013-evolution-ce6bb045a6540369f3fe8159dad4d9b9600ba583.tar.zst gsoc2013-evolution-ce6bb045a6540369f3fe8159dad4d9b9600ba583.zip |
** See #57979.
2004-05-04 Not Zed <NotZed@Ximian.com>
** See #57979.
* camel-vee-folder.c (subfolder_renamed_update): when the
subfolder gets renamed, remove all the old uid's and add the new
ones (since the uid is based on the subordinate folder name).
(subfolder_renamed): listen to renamed folder events.
* providers/local/camel-mbox-store.c (get_folder_info): if we're
getting a single folder with no children, make sure we fill the
counts out. Fixes some rename strangeness.
* camel-vee-folder.c (camel_vee_folder_add_folder): hook onto the
folder renamed signal.
(camel_vee_folder_finalise): unhook folder_renamed signal.
(camel_vee_folder_remove_folder): same.
svn path=/trunk/; revision=25776
-rw-r--r-- | camel/ChangeLog | 18 | ||||
-rw-r--r-- | camel/camel-folder-summary.h | 1 | ||||
-rw-r--r-- | camel/camel-vee-folder.c | 79 | ||||
-rw-r--r-- | camel/providers/local/camel-mbox-store.c | 3 |
4 files changed, 99 insertions, 2 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index d43c588e6d..25346d437e 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,21 @@ +2004-05-04 Not Zed <NotZed@Ximian.com> + + ** See #57979. + + * camel-vee-folder.c (subfolder_renamed_update): when the + subfolder gets renamed, remove all the old uid's and add the new + ones (since the uid is based on the subordinate folder name). + (subfolder_renamed): listen to renamed folder events. + + * providers/local/camel-mbox-store.c (get_folder_info): if we're + getting a single folder with no children, make sure we fill the + counts out. Fixes some rename strangeness. + + * camel-vee-folder.c (camel_vee_folder_add_folder): hook onto the + folder renamed signal. + (camel_vee_folder_finalise): unhook folder_renamed signal. + (camel_vee_folder_remove_folder): same. + 2004-05-03 Not Zed <NotZed@Ximian.com> ** See bug #57881. diff --git a/camel/camel-folder-summary.h b/camel/camel-folder-summary.h index 8f8c02e220..00506dec35 100644 --- a/camel/camel-folder-summary.h +++ b/camel/camel-folder-summary.h @@ -270,6 +270,7 @@ void camel_folder_summary_remove(CamelFolderSummary *s, CamelMessageInfo *info); void camel_folder_summary_remove_uid(CamelFolderSummary *s, const char *uid); void camel_folder_summary_remove_index(CamelFolderSummary *s, int); void camel_folder_summary_remove_range(CamelFolderSummary *s, int start, int end); + /* remove all items */ void camel_folder_summary_clear(CamelFolderSummary *s); diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c index 6ad9c949a9..cf4301df03 100644 --- a/camel/camel-vee-folder.c +++ b/camel/camel-vee-folder.c @@ -45,7 +45,7 @@ #include "e-util/e-memory.h" #endif -#define d(x) +#define d(x) #define dd(x) (camel_debug("vfolder")?(x):0) #define _PRIVATE(o) (((CamelVeeFolder *)(o))->priv) @@ -79,6 +79,7 @@ static void vee_folder_remove_folder(CamelVeeFolder *vf, CamelFolder *source, in static void folder_changed(CamelFolder *sub, CamelFolderChangeInfo *changes, CamelVeeFolder *vf); static void subfolder_deleted(CamelFolder *f, void *event_data, CamelVeeFolder *vf); +static void subfolder_renamed(CamelFolder *f, void *event_data, CamelVeeFolder *vf); static void folder_changed_remove_uid(CamelFolder *sub, const char *uid, const char hash[8], int keep, CamelVeeFolder *vf); @@ -181,6 +182,7 @@ camel_vee_folder_finalise (CamelObject *obj) if (vf != folder_unmatched) { camel_object_unhook_event((CamelObject *)f, "folder_changed", (CamelObjectEventHookFunc) folder_changed, vf); camel_object_unhook_event((CamelObject *)f, "deleted", (CamelObjectEventHookFunc) subfolder_deleted, vf); + camel_object_unhook_event((CamelObject *)f, "renamed", (CamelObjectEventHookFunc) subfolder_renamed, vf); /* this updates the vfolder */ if ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0) vee_folder_remove_folder(vf, f, FALSE); @@ -382,6 +384,7 @@ camel_vee_folder_add_folder(CamelVeeFolder *vf, CamelFolder *sub) camel_object_hook_event((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc)folder_changed, vf); camel_object_hook_event((CamelObject *)sub, "deleted", (CamelObjectEventHookFunc)subfolder_deleted, vf); + camel_object_hook_event((CamelObject *)sub, "renamed", (CamelObjectEventHookFunc)subfolder_renamed, vf); vee_folder_build_folder(vf, sub, NULL); } @@ -413,6 +416,7 @@ camel_vee_folder_remove_folder(CamelVeeFolder *vf, CamelFolder *sub) camel_object_unhook_event((CamelObject *)sub, "folder_changed", (CamelObjectEventHookFunc) folder_changed, vf); camel_object_unhook_event((CamelObject *)sub, "deleted", (CamelObjectEventHookFunc) subfolder_deleted, vf); + camel_object_unhook_event((CamelObject *)sub, "renamed", (CamelObjectEventHookFunc) subfolder_renamed, vf); p->folders = g_list_remove(p->folders, sub); @@ -1660,6 +1664,79 @@ subfolder_deleted(CamelFolder *f, void *event_data, CamelVeeFolder *vf) } static void +subfolder_renamed_update(CamelVeeFolder *vf, CamelFolder *sub, char hash[8]) +{ + int count, i; + CamelFolderChangeInfo *changes = NULL; + + CAMEL_VEE_FOLDER_LOCK(vf, summary_lock); + + count = camel_folder_summary_count(((CamelFolder *)vf)->summary); + for (i=0;i<count;i++) { + CamelVeeMessageInfo *mi = (CamelVeeMessageInfo *)camel_folder_summary_index(((CamelFolder *)vf)->summary, i); + CamelVeeMessageInfo *vinfo; + + if (mi == NULL) + continue; + + if (mi->folder == sub) { + char *uid = (char *)camel_message_info_uid(mi); + char *oldkey; + void *oldval; + + camel_folder_change_info_remove_uid(vf->changes, uid); + camel_folder_summary_remove(((CamelFolder *)vf)->summary, (CamelMessageInfo *)mi); + + /* works since we always append on the end */ + i--; + count--; + + vinfo = vee_folder_add_uid(vf, sub, uid+8, hash); + if (vinfo) + camel_folder_change_info_add_uid(vf->changes, camel_message_info_uid(vinfo)); + + /* check unmatched uid's table for any matches */ + if (vf == folder_unmatched + && g_hash_table_lookup_extended(unmatched_uids, uid, (void **)&oldkey, &oldval)) { + g_hash_table_remove(unmatched_uids, oldkey); + g_hash_table_insert(unmatched_uids, g_strdup(camel_message_info_uid(vinfo)), oldval); + g_free(oldkey); + } + } + + camel_folder_summary_info_free(((CamelFolder *)vf)->summary, (CamelMessageInfo *)mi); + } + + if (camel_folder_change_info_changed(vf->changes)) { + changes = vf->changes; + vf->changes = camel_folder_change_info_new(); + } + + CAMEL_VEE_FOLDER_UNLOCK(vf, summary_lock); + + if (changes) { + camel_object_trigger_event((CamelObject *)vf, "folder_changed", changes); + camel_folder_change_info_free(changes); + } +} + +static void +subfolder_renamed(CamelFolder *f, void *event_data, CamelVeeFolder *vf) +{ + char hash[8]; + + /* TODO: This could probably be done in another thread, tho it is pretty quick/memory bound */ + + /* Life just got that little bit harder, if the folder is renamed, it means it breaks all of our uid's. + We need to remove the old uid's, fix them up, then release the new uid's, for the uid's that match this folder */ + + camel_vee_folder_hash_folder(f, hash); + + subfolder_renamed_update(vf, f, hash); + subfolder_renamed_update(folder_unmatched, f, hash); +} + +static void vee_freeze (CamelFolder *folder) { CamelVeeFolder *vfolder = (CamelVeeFolder *)folder; diff --git a/camel/providers/local/camel-mbox-store.c b/camel/providers/local/camel-mbox-store.c index b9d3a976d1..4893853689 100644 --- a/camel/providers/local/camel-mbox-store.c +++ b/camel/providers/local/camel-mbox-store.c @@ -823,7 +823,8 @@ get_folder_info(CamelStore *store, const char *top, guint32 flags, CamelExceptio fi->child = scan_dir (store, url, visited, fi, subdir, top, flags, ex); else fill_fi(store, fi, flags); - } + } else + fill_fi(store, fi, flags); camel_url_free (url); |