evolution-data-server r8828 - branches/camel-db-summary/camel
- From: sragavan svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r8828 - branches/camel-db-summary/camel
- Date: Thu, 22 May 2008 18:49:37 +0000 (UTC)
Author: sragavan
Date: Thu May 22 18:49:37 2008
New Revision: 8828
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8828&view=rev
Log:
Implemented loading/saving folder basic summary info to db.
Modified:
branches/camel-db-summary/camel/camel-folder-summary.c
branches/camel-db-summary/camel/camel-folder-summary.h
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 May 22 18:49:37 2008
@@ -1498,6 +1498,40 @@
return 0;
}
+static int
+summary_header_from_db (CamelFolderSummary *s, CamelFIRecord *record)
+{
+ io(printf("Loading header from db \n"));
+
+ s->version = record->version;
+
+ /* We may not worry, as we are setting a new standard here */
+#if 0
+ /* Legacy version check, before version 12 we have no upgrade knowledge */
+ if ((s->version > 0xff) && (s->version & 0xff) < 12) {
+ io(printf ("Summary header version mismatch"));
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (!(s->version < 0x100 && s->version >= 13))
+ io(printf("Loading legacy summary\n"));
+ else
+ io(printf("loading new-format summary\n"));
+#endif
+
+ s->flags = record->flags;
+ s->nextuid = record->nextuid;
+ s->time = record->time;
+ s->saved_count = record->savedcount;
+
+ s->unread_count = record->unread;
+ s->deleted_count = record->deleted;
+ s->junk_count = record->junk;
+
+ return 0;
+}
+
static int
summary_header_load(CamelFolderSummary *s, FILE *in)
{
@@ -1542,6 +1576,37 @@
return 0;
}
+#define DB_COUNT(lhs,var,cond) str = g_strdup_printf ("select counts(%s) from %s%s", var, table_name, cond); \
+ ldh = camel_db_count (s->folder->parent_store->cdb, str); \
+ g_free (str);
+
+
+static CamelFIRecord *
+summary_header_to_db (CamelFolderSummary *s)
+{
+ int unread = 0, deleted = 0, junk = 0, count, i;
+ struct _CamelFIRecord * record = g_new0 (struct _CamelFIRecord, 1);
+ char *table_name = safe_table (camel_file_util_safe_filename (s->folder->full_name));
+ char *str;
+
+ io(printf("Savining header to db\n"));
+
+ record->folder = table_name;
+
+ /* we always write out the current version */
+ record->version = CAMEL_FOLDER_SUMMARY_VERSION;
+ record->flags = s->flags;
+ record->nextuid = s->nextuid;
+ record->time = s->time;
+
+ DB_COUNT(record->savedcount, "uid", "");
+ DB_COUNT(record->unread, "read", " where read=0");
+ DB_COUNT(record->deleted, "deleted", " where deleted=1");
+ DB_COUNT(record->junk, "junk", "where junk=1");
+
+ return record;
+}
+
static int
summary_header_save(CamelFolderSummary *s, FILE *out)
{
@@ -3279,6 +3344,9 @@
klass->summary_header_load = summary_header_load;
klass->summary_header_save = summary_header_save;
+ klass->summary_header_from_db = summary_header_from_db;
+ klass->summary_header_to_db = summary_header_to_db;
+
klass->message_info_new_from_header = message_info_new_from_header;
klass->message_info_new_from_parser = message_info_new_from_parser;
klass->message_info_new_from_message = message_info_new_from_message;
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 Thu May 22 18:49:37 2008
@@ -307,6 +307,8 @@
/* load/save the global info */
int (*summary_header_load)(CamelFolderSummary *, FILE *);
int (*summary_header_save)(CamelFolderSummary *, FILE *);
+
+ /* Load/Save folder summary from DB*/
int (*summary_header_from_db)(CamelFolderSummary *, CamelFIRecord *);
CamelFIRecord * (*summary_header_to_db)(CamelFolderSummary *);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]