evolution-data-server r9109 - branches/camel-db-summary/camel
- From: sragavan svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9109 - branches/camel-db-summary/camel
- Date: Thu, 10 Jul 2008 14:23:33 +0000 (UTC)
Author: sragavan
Date: Thu Jul 10 14:23:33 2008
New Revision: 9109
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9109&view=rev
Log:
Make message list work back. But now trash/junk crash, so fix it next.
Modified:
branches/camel-db-summary/camel/camel-db.c
branches/camel-db-summary/camel/camel-db.h
branches/camel-db-summary/camel/camel-folder-summary.c
branches/camel-db-summary/camel/camel-vtrash-folder.c
Modified: branches/camel-db-summary/camel/camel-db.c
==============================================================================
--- branches/camel-db-summary/camel/camel-db.c (original)
+++ branches/camel-db-summary/camel/camel-db.c Thu Jul 10 14:23:33 2008
@@ -456,6 +456,80 @@
static int
read_uids_callback (void *ref, int ncol, char ** cols, char ** name)
{
+ GPtrArray *array = (GPtrArray *) ref;
+ int i;
+
+ #warning Sankar check if it is OK.
+ for (i = 0; i < ncol; ++i) {
+ if (!strcmp (name [i], "uid"))
+ g_ptr_array_add (array, (char *) (camel_pstring_strdup(cols [i])));
+ }
+
+ return 0;
+}
+
+int
+camel_db_get_folder_uids (CamelDB *db, char *folder_name, GPtrArray *array, CamelException *ex)
+{
+ char *sel_query;
+ int ret;
+
+ sel_query = sqlite3_mprintf("SELECT uid FROM %Q", folder_name);
+
+ g_print ("QUERY %s\n", sel_query);
+ #warning "handle return values"
+ ret = camel_db_select (db, sel_query, read_uids_callback, array, ex);
+ sqlite3_free (sel_query);
+
+ return ret;
+}
+
+GPtrArray *
+camel_db_get_folder_junk_uids (CamelDB *db, char *folder_name, CamelException *ex)
+{
+ char *sel_query;
+ int ret;
+ GPtrArray *array = g_ptr_array_new();
+
+ sel_query = sqlite3_mprintf("SELECT uid FROM %Q where junk=1", folder_name);
+
+ g_print ("QUERY %s\n", sel_query);
+ #warning "handle return values"
+ ret = camel_db_select (db, sel_query, read_uids_callback, array, ex);
+ sqlite3_free (sel_query);
+
+ if (!array->len) {
+ g_ptr_array_free (array, TRUE);
+ array = NULL;
+ }
+ return ret;
+}
+
+GPtrArray *
+camel_db_get_folder_deleted_uids (CamelDB *db, char *folder_name, CamelException *ex)
+{
+ char *sel_query;
+ int ret;
+ GPtrArray *array = g_ptr_array_new();
+
+ sel_query = sqlite3_mprintf("SELECT uid FROM %Q where deleted=1", folder_name);
+
+ g_print ("QUERY %s\n", sel_query);
+ #warning "handle return values"
+ ret = camel_db_select (db, sel_query, read_uids_callback, array, ex);
+ sqlite3_free (sel_query);
+
+ if (!array->len) {
+ g_ptr_array_free (array, TRUE);
+ array = NULL;
+ }
+
+ return ret;
+}
+
+static int
+read_vuids_callback (void *ref, int ncol, char ** cols, char ** name)
+{
GPtrArray *array = (GPtrArray *)ref;
int i;
@@ -485,7 +559,7 @@
g_print ("QUERY %s\n", sel_query);
#warning "handle return values"
array = g_ptr_array_new ();
- camel_db_select (db, sel_query, read_uids_callback, array, ex);
+ camel_db_select (db, sel_query, read_vuids_callback, array, ex);
sqlite3_free (sel_query);
/* We make sure to return NULL if we don't get anything. Be good to your caller */
if (!array->len) {
Modified: branches/camel-db-summary/camel/camel-db.h
==============================================================================
--- branches/camel-db-summary/camel/camel-db.h (original)
+++ branches/camel-db-summary/camel/camel-db.h Thu Jul 10 14:23:33 2008
@@ -139,6 +139,11 @@
int camel_db_add_to_vfolder (CamelDB *db, char *folder_name, char *vuid, CamelException *ex);
int camel_db_add_to_vfolder_transaction (CamelDB *db, char *folder_name, char *vuid, CamelException *ex);
+int camel_db_get_folder_uids (CamelDB *db, char *folder_name, GPtrArray *array, CamelException *ex);
+
+GPtrArray * camel_db_get_folder_junk_uids (CamelDB *db, char *folder_name, CamelException *ex);
+GPtrArray * camel_db_get_folder_deleted_uids (CamelDB *db, char *folder_name, CamelException *ex);
+
char * camel_db_sqlize_string (const char *string);
void camel_db_free_sqlized_string (char *string);
Modified: branches/camel-db-summary/camel/camel-folder-summary.c
==============================================================================
--- branches/camel-db-summary/camel/camel-folder-summary.c (original)
+++ branches/camel-db-summary/camel/camel-folder-summary.c Thu Jul 10 14:23:33 2008
@@ -785,6 +785,8 @@
folder_name = s->folder->full_name;
cdb = s->folder->cdb;
+
+ ret = camel_db_get_folder_uids (cdb, folder_name, s->uids, ex);
#if 0
/* FIXME FOR SANKAR: No need to pass the address of summary here. */
data.summary = s;
Modified: branches/camel-db-summary/camel/camel-vtrash-folder.c
==============================================================================
--- branches/camel-db-summary/camel/camel-vtrash-folder.c (original)
+++ branches/camel-db-summary/camel/camel-vtrash-folder.c Thu Jul 10 14:23:33 2008
@@ -428,11 +428,10 @@
}
static void
-vtrash_uid_added(CamelVTrashFolder *vf, const char *uid, CamelMessageInfo *info, char hash[8])
+vtrash_uid_added(CamelVTrashFolder *vf, const char *uid, CamelFolderSummary *ssummary, char hash[8])
{
char *vuid;
CamelVeeMessageInfo *vinfo;
- CamelMessageInfoBase *binfo = (CamelMessageInfoBase *) info;
vuid = g_alloca(strlen(uid)+9);
memcpy(vuid, hash, 8);
@@ -440,7 +439,7 @@
vinfo = (CamelVeeMessageInfo *)camel_folder_summary_uid(((CamelFolder *)vf)->summary, vuid);
if (vinfo == NULL) {
CamelMessageInfo *tinfo;
- tinfo = camel_vee_summary_add((CamelVeeSummary *)((CamelFolder *)vf)->summary, binfo->summary, uid, hash);
+ tinfo = camel_vee_summary_add((CamelVeeSummary *)((CamelFolder *)vf)->summary, ssummary, uid, hash);
if (tinfo) {
camel_folder_change_info_add_uid(((CamelVeeFolder *)vf)->changes, vuid);
camel_message_info_free (tinfo);
@@ -478,7 +477,7 @@
if ((camel_message_info_flags(info) & ((CamelVTrashFolder *)vf)->bit) == 0)
vtrash_uid_removed((CamelVTrashFolder *)vf, uid, hash);
else
- vtrash_uid_added((CamelVTrashFolder *)vf, uid, info, hash);
+ vtrash_uid_added((CamelVTrashFolder *)vf, uid, sub->summary, hash);
camel_message_info_free(info);
}
@@ -492,7 +491,7 @@
continue;
if ((camel_message_info_flags(info) & ((CamelVTrashFolder *)vf)->bit) != 0)
- vtrash_uid_added((CamelVTrashFolder *)vf, uid, info, hash);
+ vtrash_uid_added((CamelVTrashFolder *)vf, uid, sub->summary, hash);
camel_message_info_free(info);
}
@@ -513,7 +512,7 @@
static void
vtrash_add_folder(CamelVeeFolder *vf, CamelFolder *sub)
{
- GPtrArray *infos;
+ GPtrArray *infos=NULL;
int i;
char hash[8];
CamelFolderChangeInfo *vf_changes = NULL;
@@ -523,15 +522,22 @@
CAMEL_VEE_FOLDER_LOCK(vf, summary_lock);
#warning "Search for deleted /junk uids in the db and add them directly"
- infos = camel_folder_get_summary(sub);
+ if (((CamelVTrashFolder *)vf)->bit == CAMEL_MESSAGE_DELETED)
+ infos = camel_db_get_folder_deleted_uids (sub->cdb, sub->full_name, NULL);
+ else if (((CamelVTrashFolder *)vf)->bit == CAMEL_MESSAGE_JUNK)
+ infos = camel_db_get_folder_junk_uids (sub->cdb, sub->full_name, NULL);
+
+ if (!infos) {
+ CAMEL_VEE_FOLDER_UNLOCK(vf, summary_lock);
+ return;
+ }
+
for (i=0;i<infos->len;i++) {
CamelMessageInfo *info;
char *uid = infos->pdata[i];
- info = camel_folder_summary_uid (sub->summary, uid);
- if ((camel_message_info_flags(info) & ((CamelVTrashFolder *)vf)->bit))
- vtrash_uid_added((CamelVTrashFolder *)vf, uid, info, hash);
- camel_message_info_free (info);
+ vtrash_uid_added((CamelVTrashFolder *)vf, uid, sub->summary, hash);
}
+
g_ptr_array_foreach (infos, camel_pstring_free, NULL);
g_ptr_array_free (infos, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]