aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-folder.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@HelixCode.com>2000-11-21 21:38:53 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-11-21 21:38:53 +0800
commita34a4b15b8e5ab5f0a145c17ef0969da9666d8d0 (patch)
tree9115b83535becfc19b984178b8cf40d0fca64e70 /camel/camel-folder.c
parentc657e20b4c142f72de93fd133e0afeabca872a66 (diff)
downloadgsoc2013-evolution-a34a4b15b8e5ab5f0a145c17ef0969da9666d8d0.tar
gsoc2013-evolution-a34a4b15b8e5ab5f0a145c17ef0969da9666d8d0.tar.gz
gsoc2013-evolution-a34a4b15b8e5ab5f0a145c17ef0969da9666d8d0.tar.bz2
gsoc2013-evolution-a34a4b15b8e5ab5f0a145c17ef0969da9666d8d0.tar.lz
gsoc2013-evolution-a34a4b15b8e5ab5f0a145c17ef0969da9666d8d0.tar.xz
gsoc2013-evolution-a34a4b15b8e5ab5f0a145c17ef0969da9666d8d0.tar.zst
gsoc2013-evolution-a34a4b15b8e5ab5f0a145c17ef0969da9666d8d0.zip
Shite, -1 on error, >=0 on success. So i've just been truncating all the
2000-11-21 Not Zed <NotZed@HelixCode.com> * providers/local/camel-mh-summary.c (mh_summary_sync_message): Shite, -1 on error, >=0 on success. So i've just been truncating all the messages I touched, good one zed. (mh_summary_sync_message): Sigh, and write to the right damn fd as well. (mh_summary_sync_message): Argh, and we need to compare the length of the old xev -1 to the new xev, to check if we can optimise it. * camel-folder.c (camel_folder_change_info_new): Init the pool. (camel_folder_change_info_add_source): Allocate string in the pool. (camel_folder_change_info_add_source_list): (camel_folder_change_info_add_update): No longer free the key, as it cannot be yet. (change_info_add_uid): Add a new arg, copy, telling it whether to copy the uid argument or not, and copy using mempool_strdup. (change_info_cat): Tell add_uid to copy the string. (camel_folder_change_info_add_update): Call add_uid directly. (change_info_remove): Call add_uid directly, with no copy, and dont free the key. (change_info_free_update): No longer required since we dont malloc the keys. (camel_folder_change_info_add_uid): Fix for add_uid change. (camel_folder_change_info_remove_uid): (camel_folder_change_info_change_uid): (change_info_clear): No longer needed, just set the size to 0 on the array directly. (camel_folder_change_info_clear): Empty the arrays directly, and flush the mempool too, and also clear uid_source, incase anyone was silly enough to call us in the wrong order. (camel_folder_change_info_free): Dont bother clearing the array's contents, just free the pool and throw away all the indexes. * camel-folder.h: Added a mempool to CamelFolderChangeInfo to store the uid's we get. * camel-folder-search.c (search_match_all): If we are only matching a single info, just use that/do the search. (camel_folder_search_match_expression): New function. Matches a single message info against an expression. (camel_folder_search_init): Init a hash table used to map the returned gptrarrays' to mempools. (camel_folder_search_execute_expression): Store all of the string data in a mempool, slightly faster, less wasted space (usually),. (camel_folder_search_free_result): Check for the mempool that stores the data for the list, and free that if we have it, otherwise assume we need to use g_free() (which should only happen if the list is empty at the moment). : commented out the debugging prints. Got sick of 'executing header search' crap. * providers/vee/camel-vee-folder.c (camel_vee_folder_init): Init changes. (camel_vee_folder_finalise): Free changes. (vfolder_add_match): Simple helper to add a new matching info record. (camel_vee_folder_add_folder): Only trigger a changed event if we have changes. (vfolder_change_match): New function, changes our local vfolder info to match the source. (vfolder_add_match): Add a new info to the vfolder list. (vfolder_remove_match): Remove a no-longer matching info from the vfolder summary. (message_changed): check if the message still matches, and remove/etc as required. (camel_vee_folder_finalise, init): init/free search object. (vee_folder_build_folder): Build the changes to the folder into the changes data, as we go. (folder_changed): If the folder gave us an explicit list of changes, then process each one separately (unless there's a lot added/changed). * providers/vee/camel-vee-folder.h: Added a changes field to the folder. svn path=/trunk/; revision=6628
Diffstat (limited to 'camel/camel-folder.c')
-rw-r--r--camel/camel-folder.c104
1 files changed, 47 insertions, 57 deletions
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index f2fd6a4cec..1453f91f3f 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -30,6 +30,7 @@
#include "camel-store.h"
#include "camel-mime-message.h"
#include "string-utils.h"
+#include "e-util/e-memory.h"
static CamelObjectClass *parent_class = NULL;
@@ -1114,10 +1115,37 @@ camel_folder_change_info_new(void)
info->uid_removed = g_ptr_array_new();
info->uid_changed = g_ptr_array_new();
info->uid_source = NULL;
+ info->uid_pool = e_mempool_new(512, 256, E_MEMPOOL_ALIGN_BYTE);
return info;
}
+static void
+change_info_add_uid(CamelFolderChangeInfo *info, GPtrArray *uids, const char *uid, int copy)
+{
+ int i;
+
+ /* TODO: Check that it is in the other arrays and remove it from them/etc? */
+ for (i=0;i<uids->len;i++) {
+ if (!strcmp(uids->pdata[i], uid))
+ return;
+ }
+ if (copy)
+ g_ptr_array_add(uids, e_mempool_strdup(info->uid_pool, uid));
+ else
+ g_ptr_array_add(uids, uid);
+}
+
+static void
+change_info_cat(CamelFolderChangeInfo *info, GPtrArray *uids, GPtrArray *source)
+{
+ int i;
+
+ for (i=0;i<source->len;i++) {
+ change_info_add_uid(info, uids, source->pdata[i], TRUE);
+ }
+}
+
/**
* camel_folder_change_info_add_source:
* @info:
@@ -1132,7 +1160,7 @@ camel_folder_change_info_add_source(CamelFolderChangeInfo *info, const char *uid
info->uid_source = g_hash_table_new(g_str_hash, g_str_equal);
if (g_hash_table_lookup(info->uid_source, uid) == NULL)
- g_hash_table_insert(info->uid_source, g_strdup(uid), (void *)1);
+ g_hash_table_insert(info->uid_source, e_mempool_strdup(info->uid_pool, uid), (void *)1);
}
/**
@@ -1154,7 +1182,7 @@ camel_folder_change_info_add_source_list(CamelFolderChangeInfo *info, const GPtr
char *uid = list->pdata[i];
if (g_hash_table_lookup(info->uid_source, uid) == NULL)
- g_hash_table_insert(info->uid_source, g_strdup(uid), (void *)1);
+ g_hash_table_insert(info->uid_source, e_mempool_strdup(info->uid_pool, uid), (void *)1);
}
}
@@ -1172,15 +1200,14 @@ camel_folder_change_info_add_update(CamelFolderChangeInfo *info, const char *uid
int value;
if (info->uid_source == NULL) {
- camel_folder_change_info_add_uid(info, uid);
+ change_info_add_uid(info, info->uid_added, uid, TRUE);
return;
}
if (g_hash_table_lookup_extended(info->uid_source, uid, (void **)&key, (void **)&value)) {
g_hash_table_remove(info->uid_source, key);
- g_free(key);
} else {
- camel_folder_change_info_add_uid(info, uid);
+ change_info_add_uid(info, info->uid_added, uid, TRUE);
}
}
@@ -1204,14 +1231,8 @@ camel_folder_change_info_add_update_list(CamelFolderChangeInfo *info, const GPtr
static void
change_info_remove(char *key, void *value, CamelFolderChangeInfo *info)
{
- camel_folder_change_info_remove_uid(info, key);
- g_free(key);
-}
-
-static void
-change_info_free_update(char *key, void *value, CamelFolderChangeInfo *info)
-{
- g_free(key);
+ /* we dont need to copy this, as they've already been copied into our pool */
+ change_info_add_uid(info, info->uid_removed, key, FALSE);
}
/**
@@ -1231,29 +1252,6 @@ camel_folder_change_info_build_diff(CamelFolderChangeInfo *info)
}
}
-static void
-change_info_add_uid(CamelFolderChangeInfo *info, GPtrArray *uids, const char *uid)
-{
- int i;
-
- /* TODO: Check that it is in the other arrays and remove it from them/etc? */
- for (i=0;i<uids->len;i++) {
- if (!strcmp(uids->pdata[i], uid))
- return;
- }
- g_ptr_array_add(uids, g_strdup(uid));
-}
-
-static void
-change_info_cat(CamelFolderChangeInfo *info, GPtrArray *uids, GPtrArray *source)
-{
- int i;
-
- for (i=0;i<source->len;i++) {
- change_info_add_uid(info, uids, source->pdata[i]);
- }
-}
-
/**
* camel_folder_change_info_cat:
* @info:
@@ -1280,7 +1278,7 @@ camel_folder_change_info_cat(CamelFolderChangeInfo *info, CamelFolderChangeInfo
void
camel_folder_change_info_add_uid(CamelFolderChangeInfo *info, const char *uid)
{
- change_info_add_uid(info, info->uid_added, uid);
+ change_info_add_uid(info, info->uid_added, uid, TRUE);
}
/**
@@ -1293,7 +1291,7 @@ camel_folder_change_info_add_uid(CamelFolderChangeInfo *info, const char *uid)
void
camel_folder_change_info_remove_uid(CamelFolderChangeInfo *info, const char *uid)
{
- change_info_add_uid(info, info->uid_removed, uid);
+ change_info_add_uid(info, info->uid_removed, uid, TRUE);
}
/**
@@ -1306,18 +1304,7 @@ camel_folder_change_info_remove_uid(CamelFolderChangeInfo *info, const char *uid
void
camel_folder_change_info_change_uid(CamelFolderChangeInfo *info, const char *uid)
{
- change_info_add_uid(info, info->uid_changed, uid);
-}
-
-static void
-change_info_clear(GPtrArray *uids)
-{
- int i;
-
- for (i=0;i<uids->len;i++) {
- g_free(uids->pdata[i]);
- }
- g_ptr_array_set_size(uids, 0);
+ change_info_add_uid(info, info->uid_changed, uid, TRUE);
}
/**
@@ -1343,9 +1330,14 @@ camel_folder_change_info_changed(CamelFolderChangeInfo *info)
void
camel_folder_change_info_clear(CamelFolderChangeInfo *info)
{
- change_info_clear(info->uid_added);
- change_info_clear(info->uid_removed);
- change_info_clear(info->uid_changed);
+ g_ptr_array_set_size(info->uid_added, 0);
+ g_ptr_array_set_size(info->uid_removed, 0);
+ g_ptr_array_set_size(info->uid_changed, 0);
+ if (info->uid_source) {
+ g_hash_table_destroy(info->uid_source);
+ info->uid_source = NULL;
+ }
+ e_mempool_flush(info->uid_pool, TRUE);
}
/**
@@ -1357,12 +1349,10 @@ camel_folder_change_info_clear(CamelFolderChangeInfo *info)
void
camel_folder_change_info_free(CamelFolderChangeInfo *info)
{
- if (info->uid_source) {
- g_hash_table_foreach(info->uid_source, (GHFunc)change_info_free_update, info);
+ if (info->uid_source)
g_hash_table_destroy(info->uid_source);
- }
- camel_folder_change_info_clear(info);
+ e_mempool_destroy(info->uid_pool);
g_ptr_array_free(info->uid_added, TRUE);
g_ptr_array_free(info->uid_removed, TRUE);