diff options
author | 4 <NotZed@Ximian.com> | 2001-09-15 16:12:58 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2001-09-15 16:12:58 +0800 |
commit | 466e05c024510d8019989f8bf8f04541c3ca792d (patch) | |
tree | a744a404a3861eb09836240628b5f8480ced01c2 /camel/camel-vee-folder.c | |
parent | 576a04e67d0f059992afbb1afdca67fb668288f4 (diff) | |
download | gsoc2013-evolution-466e05c024510d8019989f8bf8f04541c3ca792d.tar.gz gsoc2013-evolution-466e05c024510d8019989f8bf8f04541c3ca792d.tar.zst gsoc2013-evolution-466e05c024510d8019989f8bf8f04541c3ca792d.zip |
New function, set the complete list of folders on a vfolder, all at once.
2001-09-14 <NotZed@Ximian.com>
* camel-vee-folder.c (camel_vee_folder_set_folders): New function,
set the complete list of folders on a vfolder, all at once.
(camel_vee_folder_set_expression): If we set the query to be the
same thing, dont do anything.
* camel-vee-store.c (camel_vee_store_init): Turn off vtrash for
this store.
* camel-store.c (camel_store_init): Enable vtrash by default via
flags.
(camel_store_get_trash): REturn NULL if the store doesn't support
vtrash.
(init_trash): Dont init if store doesn't support vtrash.
* camel-store.h: Add a new flags CAMEL_STORE_VTRASH -> store
supports vtrash.
2001-09-13 <NotZed@Ximian.com>
* camel-vee-store.c (vee_get_folder_info): Implement.
(build_info): Used to build a folder record from the folders
hashtable.
(vee_delete_folder): Implemented, remove folder from hashtable.
(vee_rename_folder): Implemented, remove old folder from
hashtable, add new one and rename its guts too.
* camel-store.c (camel_store_rename_folder): Do nothing if we're
not asked to actually change names. Also dont do the renamed
cache check till after we've called the subclass.
(camel_store_delete_folder): Call the subclass delete firs,t then
make sure the cache is right.
* camel-vee-folder.c (vee_folder_construct): Remove support for
name?query syntax to setup vfolder. Abort if such syntax is used.
(camel_vee_folder_new): Removed code that handles ? syntax, etc.
(vee_folder_build_folder): Handle unset expression, treat it as an
empty search.
(camel_vee_folder_set_expression): Oops, actually set the
expression.
* camel-vtrash-folder.c (camel_vtrash_folder_new): Dont use
name?query syntax to setup vfolder, but set the expression
directly. Also fixes a small memleak.
2001-09-12 <NotZed@Ximian.com>
* camel-store.c (camel_store_delete_folder): Fixed warnings with a cast.
(camel_store_rename_folder): "
svn path=/trunk/; revision=12854
Diffstat (limited to 'camel/camel-vee-folder.c')
-rw-r--r-- | camel/camel-vee-folder.c | 95 |
1 files changed, 76 insertions, 19 deletions
diff --git a/camel/camel-vee-folder.c b/camel/camel-vee-folder.c index fde38fa1d5..e2e224da92 100644 --- a/camel/camel-vee-folder.c +++ b/camel/camel-vee-folder.c @@ -194,14 +194,10 @@ vee_folder_construct (CamelVeeFolder *vf, CamelStore *parent_store, const char * vf->flags = flags; - tmp = strchr(name, '?'); - if (tmp) { - vf->vname = g_strndup(name, tmp-name); - vf->expression = g_strdup(tmp+1); - } else { - vf->vname = g_strdup(name); - } + /* We dont support ? syntax anymore */ + g_assert(strchr(name, '?') == NULL); + vf->vname = g_strdup(name); tmp = strrchr(vf->vname, '/'); if (tmp) tmp++; @@ -247,7 +243,6 @@ CamelFolder * camel_vee_folder_new(CamelStore *parent_store, const char *name, guint32 flags) { CamelVeeFolder *vf; - char *path, *query; UNMATCHED_LOCK(); @@ -261,13 +256,7 @@ camel_vee_folder_new(CamelStore *parent_store, const char *name, guint32 flags) UNMATCHED_UNLOCK(); - path = alloca(strlen(name)+1); - strcpy(path, name); - query = strchr(path, '?'); - if (query) - *query++ = 0; - - if (strcmp(path, "UNMATCHED") == 0) { + if (strcmp(name, "UNMATCHED") == 0) { camel_object_ref((CamelObject *)folder_unmatched); printf("returning unmatched %p, count = %d\n", folder_unmatched, camel_folder_get_message_count((CamelFolder *)folder_unmatched)); return (CamelFolder *)folder_unmatched; @@ -289,6 +278,17 @@ camel_vee_folder_set_expression(CamelVeeFolder *vf, const char *query) CAMEL_VEE_FOLDER_LOCK(vf, subfolder_lock); + /* no change, do nothing */ + if ((vf->expression && query && strcmp(vf->expression, query) == 0) + || (vf->expression == NULL && query == NULL)) { + CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock); + return; + } + + g_free(vf->expression); + if (query) + vf->expression = g_strdup(query); + node = p->folders; while (node) { CamelFolder *f = node->data; @@ -372,6 +372,54 @@ camel_vee_folder_remove_folder(CamelVeeFolder *vf, CamelFolder *sub) camel_object_unref((CamelObject *)sub); } +static void +remove_folders(CamelFolder *folder, CamelFolder *foldercopy, CamelVeeFolder *vf) +{ + camel_vee_folder_remove_folder(vf, folder); + camel_object_unref((CamelObject *)folder); +} + +/** + * camel_vee_folder_set_folders: + * @vf: + * @folders: + * + * Set the whole list of folder sources on a vee folder. + **/ +void +camel_vee_folder_set_folders(CamelVeeFolder *vf, GList *folders) +{ + GHashTable *remove = g_hash_table_new(NULL, NULL); + GList *l; + CamelFolder *folder; + + /* setup a table of all folders we have currently */ + CAMEL_VEE_FOLDER_LOCK(vf, subfolder_lock); + l = vf->priv->folders; + while (l) { + g_hash_table_insert(remove, l->data, l->data); + camel_object_ref((CamelObject *)l->data); + l = l->next; + } + CAMEL_VEE_FOLDER_UNLOCK(vf, subfolder_lock); + + /* if we already have the folder, ignore it, otherwise add it */ + l = folders; + while (l) { + if ((folder = g_hash_table_lookup(remove, l->data))) { + g_hash_table_remove(remove, folder); + camel_object_unref((CamelObject *)folder); + } else { + camel_vee_folder_add_folder(vf, l->data); + } + l = l->next; + } + + /* then remove any we still have */ + g_hash_table_foreach(remove, (GHFunc)remove_folders, vf); + g_hash_table_destroy(remove); +} + /** * camel_vee_folder_hash_folder: * @folder: @@ -750,9 +798,14 @@ vee_folder_build_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException if (vf == folder_unmatched) return 0; - match = camel_folder_search_by_expression(f, vf->expression, ex); - if (match == NULL) - return -1; + /* if we have no expression, or its been cleared, then act as if no matches */ + if (vf->expression == NULL) { + match = g_ptr_array_new(); + } else { + match = camel_folder_search_by_expression(f, vf->expression, ex); + if (match == NULL) + return -1; + } u.source = source; u.vf = vf; @@ -847,7 +900,11 @@ vee_folder_build_folder(CamelVeeFolder *vf, CamelFolder *source, CamelException g_hash_table_destroy(matchhash); g_hash_table_destroy(allhash); - camel_folder_search_free(f, match); + /* if expression not set, we only had a null list */ + if (vf->expression == NULL) + g_ptr_array_free(match, TRUE); + else + camel_folder_search_free(f, match); camel_folder_free_uids(f, all); if (unmatched_changes) { |