evolution-data-server r9681 - in branches/gnome-2-24/camel: . providers/imap
- From: sragavan svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9681 - in branches/gnome-2-24/camel: . providers/imap
- Date: Thu, 16 Oct 2008 04:45:14 +0000 (UTC)
Author: sragavan
Date: Thu Oct 16 04:45:14 2008
New Revision: 9681
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9681&view=rev
Log:
2008-10-16 Srinivasa Ragavan <sragavan novell com>
** Fix for bug #556495
* camel/camel-db.c:
* camel/camel-db.h:
* camel/camel-vee-folder.c: When things don't match, remove them from
db and force a count.
2008-10-16 Srinivasa Ragavan <sragavan novell com>
* camel-imap-message-cache.c (camel_imap_message_cache_new):
Optimize/speed up loading.
Modified:
branches/gnome-2-24/camel/ChangeLog
branches/gnome-2-24/camel/camel-folder-summary.c
branches/gnome-2-24/camel/camel-folder-summary.h
branches/gnome-2-24/camel/camel-folder.c
branches/gnome-2-24/camel/camel-vee-summary.c
branches/gnome-2-24/camel/camel-vtrash-folder.c
branches/gnome-2-24/camel/providers/imap/ChangeLog
branches/gnome-2-24/camel/providers/imap/camel-imap-message-cache.c
Modified: branches/gnome-2-24/camel/camel-folder-summary.c
==============================================================================
--- branches/gnome-2-24/camel/camel-folder-summary.c (original)
+++ branches/gnome-2-24/camel/camel-folder-summary.c Thu Oct 16 04:45:14 2008
@@ -492,6 +492,40 @@
return res;
}
+/**
+ * camel_folder_summary_get_hashtable:
+ * @summary: a #CamelFolderSummary object
+ *
+ * Obtain a copy of the summary array in the hashtable. This is done atomically,
+ * so cannot contain empty entries.
+ *
+ * It must be freed using camel_folder_summary_free_hashtable
+ *
+ * Returns: a #GHashTable of uids
+ **/
+GHashTable *
+camel_folder_summary_get_hashtable(CamelFolderSummary *s)
+{
+ GHashTable *hash = g_hash_table_new (g_str_hash, g_str_equal);
+ int i;
+
+ CAMEL_SUMMARY_LOCK(s, summary_lock);
+
+ for (i=0;i<s->uids->len;i++)
+ g_hash_table_insert (hash, (gpointer)camel_pstring_strdup ((char *)g_ptr_array_index(s->uids, i)), GINT_TO_POINTER(1));
+
+ CAMEL_SUMMARY_UNLOCK(s, summary_lock);
+
+ return hash;
+}
+
+void
+camel_folder_summary_free_hashtable (GHashTable *ht)
+{
+ g_hash_table_foreach (ht, (GHFunc)camel_pstring_free, NULL);
+ g_hash_table_destroy (ht);
+}
+
CamelMessageInfo *
camel_folder_summary_peek_info (CamelFolderSummary *s, const char *uid)
{
Modified: branches/gnome-2-24/camel/camel-folder-summary.h
==============================================================================
--- branches/gnome-2-24/camel/camel-folder-summary.h (original)
+++ branches/gnome-2-24/camel/camel-folder-summary.h Thu Oct 16 04:45:14 2008
@@ -405,6 +405,8 @@
gboolean camel_folder_summary_check_uid (CamelFolderSummary *s, const char *uid);
GPtrArray *camel_folder_summary_array(CamelFolderSummary *summary);
+GHashTable *camel_folder_summary_get_hashtable(CamelFolderSummary *s);
+void camel_folder_summary_free_hashtable (GHashTable *ht);
/* basically like strings, but certain keywords can be compressed and de-cased */
int camel_folder_summary_encode_token(FILE *out, const char *str);
Modified: branches/gnome-2-24/camel/camel-folder.c
==============================================================================
--- branches/gnome-2-24/camel/camel-folder.c (original)
+++ branches/gnome-2-24/camel/camel-folder.c Thu Oct 16 04:45:14 2008
@@ -417,19 +417,19 @@
switch (tag & CAMEL_ARG_TAG) {
case CAMEL_FOLDER_ARG_UNREAD:
- count = unread;
+ count = unread == -1 ? 0 : unread;
break;
case CAMEL_FOLDER_ARG_DELETED:
- count = deleted;
+ count = deleted == -1 ? 0 : deleted;
break;
case CAMEL_FOLDER_ARG_JUNKED:
- count = junked;
+ count = junked == -1 ? 0 : junked;
break;
case CAMEL_FOLDER_ARG_JUNKED_NOT_DELETED:
- count = junked_not_deleted;
+ count = junked_not_deleted == -1 ? 0 : junked_not_deleted;
break;
case CAMEL_FOLDER_ARG_VISIBLE:
- count = visible;
+ count = visible == -1 ? 0 : visible;
break;
}
Modified: branches/gnome-2-24/camel/camel-vee-summary.c
==============================================================================
--- branches/gnome-2-24/camel/camel-vee-summary.c (original)
+++ branches/gnome-2-24/camel/camel-vee-summary.c Thu Oct 16 04:45:14 2008
@@ -30,6 +30,7 @@
#include <sys/stat.h>
#include "camel-db.h"
+#include "camel-debug.h"
#include "camel-folder.h"
#include "camel-store.h"
#include "camel-vee-summary.h"
Modified: branches/gnome-2-24/camel/camel-vtrash-folder.c
==============================================================================
--- branches/gnome-2-24/camel/camel-vtrash-folder.c (original)
+++ branches/gnome-2-24/camel/camel-vtrash-folder.c Thu Oct 16 04:45:14 2008
@@ -122,7 +122,7 @@
CamelFolder *folder = (CamelFolder *)object;
int i;
guint32 tag;
- int unread = -1, deleted = 0, junked = 0, visible = 0, count = -1;
+ int unread = -1, deleted = 0, junked = 0, visible = 0, count = -1, junked_not_deleted = -1;
for (i=0;i<args->argc;i++) {
CamelArgGet *arg = &args->argv[i];
@@ -135,14 +135,16 @@
case CAMEL_FOLDER_ARG_UNREAD:
case CAMEL_FOLDER_ARG_DELETED:
case CAMEL_FOLDER_ARG_JUNKED:
+ case CAMEL_FOLDER_ARG_JUNKED_NOT_DELETED:
case CAMEL_FOLDER_ARG_VISIBLE:
+
/* This is so we can get the values atomically, and also so we can calculate them only once */
if (unread == -1) {
int j;
CamelMessageInfoBase *info;
CamelVeeMessageInfo *vinfo;
- unread = 0;
+ unread = deleted = visible = junked = junked_not_deleted = 0;
count = camel_folder_summary_count(folder->summary);
for (j=0; j<count; j++) {
if ((info = (CamelMessageInfoBase *) camel_folder_summary_index(folder->summary, j))) {
@@ -155,8 +157,11 @@
unread++;
if (flags & CAMEL_MESSAGE_DELETED)
deleted++;
- if (flags & CAMEL_MESSAGE_JUNK)
+ if (flags & CAMEL_MESSAGE_JUNK) {
junked++;
+ if (! (flags & CAMEL_MESSAGE_DELETED))
+ junked_not_deleted++;
+ }
if ((flags & (CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_JUNK)) == 0)
visible++;
camel_message_info_free(info);
@@ -166,19 +171,26 @@
switch (tag & CAMEL_ARG_TAG) {
case CAMEL_FOLDER_ARG_UNREAD:
- count = unread;
+ count = unread == -1 ? 0 : unread;
break;
case CAMEL_FOLDER_ARG_DELETED:
- count = deleted;
+ count = deleted == -1 ? 0 : deleted;
break;
case CAMEL_FOLDER_ARG_JUNKED:
- count = junked;
+ count = junked == -1 ? 0 : junked;
break;
+ case CAMEL_FOLDER_ARG_JUNKED_NOT_DELETED:
+ count = junked_not_deleted == -1 ? 0 : junked_not_deleted;
+ break;
case CAMEL_FOLDER_ARG_VISIBLE:
- count = visible;
+ count = visible == -1 ? 0 : visible;
break;
}
-
+ folder->summary->unread_count = unread == -1 ? 0 : unread;
+ folder->summary->deleted_count = deleted == -1 ? 0 : deleted;
+ junked = folder->summary->junk_count = junked == -1 ? 0 : junked;
+ folder->summary->junk_not_deleted_count = junked_not_deleted == -1 ? 0 : junked_not_deleted;
+ folder->summary->visible_count = visible == -1 ? 0 : visible;
*arg->ca_int = count;
break;
default:
Modified: branches/gnome-2-24/camel/providers/imap/camel-imap-message-cache.c
==============================================================================
--- branches/gnome-2-24/camel/providers/imap/camel-imap-message-cache.c (original)
+++ branches/gnome-2-24/camel/providers/imap/camel-imap-message-cache.c Thu Oct 16 04:45:14 2008
@@ -153,6 +153,7 @@
char *uid, *p;
GPtrArray *deletes;
GError *error = NULL;
+ GHashTable *shash;
dir = g_dir_open (path, 0, &error);
if (!dir) {
@@ -169,6 +170,8 @@
cache->parts = g_hash_table_new (g_str_hash, g_str_equal);
cache->cached = g_hash_table_new (NULL, NULL);
deletes = g_ptr_array_new ();
+ shash = camel_folder_summary_get_hashtable (summary);
+
while ((dname = g_dir_read_name (dir))) {
if (!isdigit (dname[0]))
continue;
@@ -178,7 +181,7 @@
else
uid = g_strdup (dname);
- if (camel_folder_summary_check_uid(summary, uid))
+ if (g_hash_table_lookup(shash, uid))
cache_put (cache, uid, dname, NULL);
else
g_ptr_array_add (deletes, g_strdup_printf ("%s/%s", cache->path, dname));
@@ -194,6 +197,8 @@
}
g_ptr_array_free (deletes, TRUE);
+ camel_folder_summary_free_hashtable (shash);
+
return cache;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]