evolution-data-server r8841 - in branches/camel-db-summary/camel: . providers/local
- From: psankar svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r8841 - in branches/camel-db-summary/camel: . providers/local
- Date: Fri, 23 May 2008 20:12:58 +0000 (UTC)
Author: psankar
Date: Fri May 23 20:12:58 2008
New Revision: 8841
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8841&view=rev
Log:
camel_folder_summary_load_from_db implements folder-info loading.
Messageinfo-s are still pending.
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-folder-summary.h
branches/camel-db-summary/camel/camel-store.c
branches/camel-db-summary/camel/providers/local/camel-local-summary.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 Fri May 23 20:12:58 2008
@@ -54,7 +54,7 @@
cdb = g_new (CamelDB, 1);
cdb->db = db;
cdb->lock = g_mutex_new ();
- d(g_print ("\n\aDatabase succesfully opened \n\a"));
+ d(g_print ("\nDatabase succesfully opened \n"));
return cdb;
}
@@ -65,7 +65,7 @@
sqlite3_close (cdb->db);
g_mutex_free (cdb->lock);
g_free (cdb);
- d(g_print ("\n\aDatabase succesfully closed \n\a"));
+ d(g_print ("\nDatabase succesfully closed \n"));
}
}
@@ -91,7 +91,7 @@
for(i=0; i<argc; i++) {
if (strstr(azColName[i], "count")) {
- *(int **)data = atol(argv[i]);
+ (*(int **)data) = atoi(argv[i]);
}
}
@@ -120,7 +120,7 @@
int
-camel_db_select (CamelDB *cdb, const char* stmt, CamelDBSelectCB callback, gpointer data)
+camel_db_select (CamelDB *cdb, const char* stmt, CamelDBSelectCB callback, gpointer data, CamelException *ex)
{
char *errmsg;
//int nrecs = 0;
@@ -133,6 +133,7 @@
if(ret != SQLITE_OK) {
d(g_warning ("Error in select statement '%s' [%s].\n", stmt, errmsg));
+ camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, errmsg);
sqlite3_free (errmsg);
}
g_mutex_unlock (cdb->lock);
@@ -191,6 +192,70 @@
return 0;
}
+static int
+read_fir_callback (void * ref, int ncol, char ** cols, char ** name)
+{
+ CamelFIRecord *record = *(CamelFIRecord **) ref;
+
+ d(g_print ("\nread_fir_callback called \n"));
+#if 0
+ record->folder_name = cols [0];
+ record->version = cols [1];
+ /* Just a sequential mapping of struct members to columns is enough I guess.
+ Needs some checking */
+#else
+ int i;
+
+ for (i = 0; i < ncol; ++i) {
+ if (!strcmp (name [i], "folder_name"))
+ record->folder_name = g_strdup(cols [i]);
+
+ else if (!strcmp (name [i], "version"))
+ record->version = cols [i] ? strtoul (cols [i], NULL, 10) : 0;
+
+ else if (!strcmp (name [i], "flags"))
+ record->flags = cols [i] ? strtoul (cols [i], NULL, 10) : 0;
+
+ else if (!strcmp (name [i], "nextuid"))
+ record->nextuid = cols [i] ? strtoul (cols [i], NULL, 10) : 0;
+
+ else if (!strcmp (name [i], "time"))
+ record->time = cols [i] ? strtoul (cols [i], NULL, 10) : 0;
+
+ else if (!strcmp (name [i], "saved_count"))
+ record->saved_count = cols [i] ? strtoul (cols [i], NULL, 10) : 0;
+
+ else if (!strcmp (name [i], "unread_count"))
+ record->unread_count = cols [i] ? strtoul (cols [i], NULL, 10) : 0;
+
+ else if (!strcmp (name [i], "deleted_count"))
+ record->deleted_count = cols [i] ? strtoul (cols [i], NULL, 10) : 0;
+
+ else if (!strcmp (name [i], "junk_count"))
+ record->junk_count = cols [i] ? strtoul (cols [i], NULL, 10) : 0;
+
+ else if (!strcmp (name [i], "bdata"))
+ record->bdata = g_strdup (cols [i]);
+
+ }
+#endif
+ return 0;
+}
+
+int
+camel_db_read_folder_info_record (CamelDB *cdb, char *folder_name, CamelFIRecord **record, CamelException *ex)
+{
+ char *query;
+
+ d(g_print ("\ncamel_db_read_folder_info_record called \n"));
+
+ query = g_strdup_printf ("SELECT * FROM folders WHERE folder_name = \"%s\"", folder_name);
+
+ return (camel_db_select (cdb, query, read_fir_callback, record, ex));
+}
+
+
+
gboolean
camel_db_delete_uid (CamelDB *cdb, char *folder, char *uid, CamelException *ex)
{
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 Fri May 23 20:12:58 2008
@@ -98,8 +98,9 @@
gboolean camel_db_delete_folder (CamelDB *cdb, char *folder, CamelException *ex);
gboolean camel_db_delete_uid (CamelDB *cdb, char *folder, char *uid, CamelException *ex);
int camel_db_create_folders_table (CamelDB *cdb, CamelException *ex);
-int camel_db_select (CamelDB *cdb, const char* stmt, CamelDBSelectCB callback, gpointer data);
+int camel_db_select (CamelDB *cdb, const char* stmt, CamelDBSelectCB callback, gpointer data, CamelException *ex);
int camel_db_write_folder_info_record (CamelDB *cdb, CamelFIRecord *record, CamelException *ex);
+int camel_db_read_folder_info_record (CamelDB *cdb, char *folder_name, CamelFIRecord **record, CamelException *ex);
guint32 camel_db_count (CamelDB *cdb, const char *stmt);
#endif
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 Fri May 23 20:12:58 2008
@@ -549,6 +549,38 @@
}
+int
+camel_folder_summary_load_from_db (CamelFolderSummary *s)
+{
+ CamelDB *cdb;
+ CamelFIRecord *record;
+ CamelException ex;// May be this should come from the provider
+ char *folder_name;
+
+ d(printf ("\ncamel_folder_summary_load_from_db called \n"));
+
+ s->flags &= ~CAMEL_SUMMARY_DIRTY;
+
+ folder_name = s->folder->full_name;
+ cdb = s->folder->parent_store->cdb;
+
+ record = g_new0 (CamelFIRecord, 1);
+ camel_db_read_folder_info_record (cdb, folder_name, &record, &ex);
+
+ if (record) {
+ if ( ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_from_db (s, record) == -1)
+ return -1;
+ } else {
+ return -1;
+ }
+
+
+ /* FIXME: What about message-info ? Ye Need to load them. */
+
+ return 0;
+
+}
+
/**
* camel_folder_summary_load:
* @summary: a #CamelFolderSummary object
@@ -563,6 +595,8 @@
FILE *in;
int i;
CamelMessageInfo *mi;
+
+ d(g_print ("\ncamel_folder_summary_load from FLAT FILE called \n"));
if (s->summary_path == NULL ||
s->meta_summary->path == NULL)
@@ -645,7 +679,7 @@
CamelFIRecord *record;
int ret;
- d(printf ("\n\acamel_folder_summary_save_to_db called \n\a"));
+ d(printf ("\ncamel_folder_summary_save_to_db called \n"));
record = (((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_to_db (s));
if (!record) {
Modified: branches/camel-db-summary/camel/camel-folder-summary.h
==============================================================================
--- branches/camel-db-summary/camel/camel-folder-summary.h (original)
+++ branches/camel-db-summary/camel/camel-folder-summary.h Fri May 23 20:12:58 2008
@@ -314,6 +314,7 @@
/* load/save the full summary from/to the db */
int camel_folder_summary_save_to_db (CamelFolderSummary *s, CamelException *ex);
+int camel_folder_summary_load_from_db (CamelFolderSummary *s);
/* only load the header */
int camel_folder_summary_header_load(CamelFolderSummary *summary);
Modified: branches/camel-db-summary/camel/camel-store.c
==============================================================================
--- branches/camel-db-summary/camel/camel-store.c (original)
+++ branches/camel-db-summary/camel/camel-store.c Fri May 23 20:12:58 2008
@@ -153,7 +153,7 @@
{
CamelStore *store = CAMEL_STORE (object);
- d(printf ("\n\acamel_store_finalize called \n\a"));
+ d(printf ("\ncamel_store_finalize called \n"));
if (store->folders)
camel_object_bag_destroy(store->folders);
Modified: branches/camel-db-summary/camel/providers/local/camel-local-summary.c
==============================================================================
--- branches/camel-db-summary/camel/providers/local/camel-local-summary.c (original)
+++ branches/camel-db-summary/camel/providers/local/camel-local-summary.c Fri May 23 20:12:58 2008
@@ -42,7 +42,7 @@
#define w(x)
#define io(x)
-#define d(x) /*(printf("%s(%d): ", __FILE__, __LINE__),(x))*/
+#define d(x) x /*(printf("%s(%d): ", __FILE__, __LINE__),(x))*/
#define CAMEL_LOCAL_SUMMARY_VERSION (1)
@@ -140,7 +140,8 @@
static int
local_summary_load(CamelLocalSummary *cls, int forceindex, CamelException *ex)
{
- return camel_folder_summary_load((CamelFolderSummary *)cls);
+ d(g_print ("\nlocal_summary_load called \n"));
+ return camel_folder_summary_load_from_db ((CamelFolderSummary *)cls);
}
/* load/check the summary */
@@ -153,7 +154,6 @@
d(printf("Loading summary ...\n"));
if (forceindex
- || g_stat(s->summary_path, &st) == -1
|| ((CamelLocalSummaryClass *)(CAMEL_OBJECT_GET_CLASS(cls)))->load(cls, forceindex, ex) == -1) {
w(g_warning("Could not load summary: flags may be reset"));
camel_folder_summary_clear((CamelFolderSummary *)cls);
@@ -424,7 +424,7 @@
mi = (CamelLocalMessageInfo *)camel_folder_summary_add_from_message((CamelFolderSummary *)cls, msg);
if (mi) {
- d(printf("Added, uid = %s\n", mi->uid));
+ //d(printf("Added, uid = %s\n", mi->uid));
if (info) {
const CamelTag *tag = camel_message_info_user_tags(info);
const CamelFlag *flag = camel_message_info_user_flags(info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]