evolution-data-server r8876 - branches/camel-db-summary/camel
- From: psankar svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r8876 - branches/camel-db-summary/camel
- Date: Fri, 30 May 2008 07:31:01 +0000 (UTC)
Author: psankar
Date: Fri May 30 07:31:01 2008
New Revision: 8876
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8876&view=rev
Log:
content_info_load/save
miscellaneous compiler warnings
changed time format from string to numeric in the db
Modified:
branches/camel-db-summary/camel/camel-db.c
branches/camel-db-summary/camel/camel-folder-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 30 07:31:01 2008
@@ -177,7 +177,7 @@
for(i=0; i<argc; i++) {
if (strstr(azColName[i], "count")) {
- *(int **)data = atoi(argv[i]);
+ *(int *)data = atoi(argv[i]);
}
}
@@ -260,24 +260,12 @@
char *table_creation_query;
- table_creation_query = g_strdup_printf ("CREATE TABLE IF NOT EXISTS %s ( uid TEXT PRIMARY KEY , flags INTEGER , read INTEGER , deleted INTEGER , replied INTEGER , important INTEGER , junk INTEGER , attachment INTEGER , size INTEGER , dsent NUMERIC , dreceived NUMERIC , subject TEXT , mail_from TEXT , mail_to TEXT , cc TEXT , mlist TEXT , followup_flag TEXT , followup_completed_on TEXT , followup_due_by TEXT , part TEXT , labels TEXT , usertags TEXT , cinfo TEXT , bdata TEXT )", folder_name);
+ table_creation_query = g_strdup_printf ("CREATE TABLE IF NOT EXISTS %s ( uid TEXT PRIMARY KEY , flags INTEGER , read INTEGER , deleted INTEGER , replied INTEGER , important INTEGER , junk INTEGER , attachment INTEGER , size INTEGER , dsent NUMERIC , dreceived NUMERIC , subject TEXT , mail_from TEXT , mail_to TEXT , mail_cc TEXT , mlist TEXT , followup_flag TEXT , followup_completed_on TEXT , followup_due_by TEXT , part TEXT , labels TEXT , usertags TEXT , cinfo TEXT , bdata TEXT )", folder_name);
char *del_query;
char *ins_query;
- char date_sent [255];
- char date_received [255];
-
- struct tm sent;
- struct tm received;
-
- gmtime_r (&(record->dsent), &sent);
- gmtime_r (&(record->dreceived), &received);
-
- strftime (date_sent, sizeof (date_sent), "%F", &sent);
- strftime (date_received, sizeof (date_received), "%F", &received);
-
- ins_query = g_strdup_printf ("INSERT INTO \"%s\" VALUES (\"%s\", %d, %d, %d, %d, %d, %d, %d, %d, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\" )", folder_name, record->uid, record->flags, record->read, record->deleted, record->replied, record->important, record->junk, record->attachment, record->size, date_sent, date_received, record->subject, record->from, record->to, record->cc, record->mlist, record->followup_flag, record->followup_completed_on, record->followup_due_by, record->part, record->labels, record->usertags, record->cinfo, record->bdata);
+ ins_query = g_strdup_printf ("INSERT INTO \"%s\" VALUES (\"%s\", %d, %d, %d, %d, %d, %d, %d, %d, %ld, %ld, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\" )", folder_name, record->uid, record->flags, record->read, record->deleted, record->replied, record->important, record->junk, record->attachment, record->size, record->dsent, record->dreceived, record->subject, record->from, record->to, record->cc, record->mlist, record->followup_flag, record->followup_completed_on, record->followup_due_by, record->part, record->labels, record->usertags, record->cinfo, record->bdata);
del_query = g_strdup_printf ("DELETE FROM %s WHERE uid = \"%s\"", folder_name, record->uid);
@@ -309,7 +297,7 @@
char *del_query;
char *ins_query;
- ins_query = g_strdup_printf ("INSERT INTO folders VALUES ( \"%s\", %d, %d, %d, 143, %d, %d, %d, %d, \"%s\" ) ", record->folder_name, record->version, record->flags , record->nextuid , record->saved_count , record->unread_count , record->deleted_count , record->junk_count , "PROVIDER SPECIFIC DATA");
+ ins_query = g_strdup_printf ("INSERT INTO folders VALUES ( \"%s\", %d, %d, %d, 143, %d, %d, %d, %d, \"%s\" ) ", record->folder_name, record->version, record->flags , record->nextuid , record->saved_count , record->unread_count , record->deleted_count , record->junk_count , record->bdata);
del_query = g_strdup_printf ("DELETE FROM folders WHERE folder_name = \"%s\"", record->folder_name);
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 30 07:31:01 2008
@@ -529,6 +529,38 @@
return ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->next_uid_string(s);
}
+static CamelMessageContentInfo *
+perform_content_info_load_from_db (CamelFolderSummary *s, CamelMIRecord *mir)
+{
+ int i;
+ guint32 count;
+ CamelMessageContentInfo *ci, *pci;
+ char *part;
+ ci = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->content_info_from_db (s, mir);
+ if (ci == NULL)
+ return NULL;
+ part = mir->cinfo;
+ if (!part)
+ return ci;
+ if (*part == ' ') part++;
+ EXTRACT_DIGIT (count);
+
+ mir->cinfo = part;
+ for (i=0;i<count;i++) {
+ pci = perform_content_info_load_from_db (s, mir);
+ if (pci ) {
+ my_list_append((struct _node **)&ci->childs, (struct _node *)pci);
+ pci->parent = ci;
+ } else {
+ d(fprintf (stderr, "Summary file format messed up?"));
+ camel_folder_summary_content_info_free (s, ci);
+ return NULL;
+ }
+ }
+ return ci;
+}
+
+
/* loads the content descriptions, recursively */
static CamelMessageContentInfo *
perform_content_info_load(CamelFolderSummary *s, FILE *in)
@@ -625,21 +657,17 @@
mir->attachment = (cols [i]) ? ( ((strtoul (cols [i], NULL, 10)) ? TRUE : FALSE)) : FALSE;
else if ( !strcmp (name [i], "size") )
mir->size = cols [i] ? strtoul (cols [i], NULL, 10) : 0;
- else if ( !strcmp (name [i], "dsent") ) {
- struct tm tmm;
- strptime (cols [i], "%F", &(tmm));
- mir->dsent = mktime (&tmm);
- } else if ( !strcmp (name [i], "dreceived") ) {
- struct tm tmm;
- strptime (cols [i], "%F", &(tmm));
- mir->dreceived = mktime (&tmm);
- } else if ( !strcmp (name [i], "subject") )
+ else if ( !strcmp (name [i], "dsent") )
+ mir->dsent = cols [i] ? strtol (cols [i], NULL, 10) : 0;
+ else if ( !strcmp (name [i], "dreceived") )
+ mir->dreceived = cols [i] ? strtol (cols [i], NULL, 10) : 0;
+ else if ( !strcmp (name [i], "subject") )
mir->subject = g_strdup (cols [i]);
- else if ( !strcmp (name [i], "from") )
+ else if ( !strcmp (name [i], "mail_from") )
mir->from = g_strdup (cols [i]);
- else if ( !strcmp (name [i], "to") )
+ else if ( !strcmp (name [i], "mail_to") )
mir->to = g_strdup (cols [i]);
- else if ( !strcmp (name [i], "cc") )
+ else if ( !strcmp (name [i], "mail_cc") )
mir->cc = g_strdup (cols [i]);
else if ( !strcmp (name [i], "mlist") )
mir->mlist = g_strdup (cols [i]);
@@ -665,7 +693,18 @@
info = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_from_db (s, mir);
if (info) {
+
+ if (s->build_content) {
+ /* FIXME: this should be done differently, how i don't know */
+ ((CamelMessageInfoBase *)info)->content = perform_content_info_load_from_db (s, mir);
+ if (((CamelMessageInfoBase *)info)->content == NULL) {
+ camel_message_info_free(info);
+ info = NULL;
+ }
+ }
+
camel_folder_summary_add (s, info);
+
d(g_print ("\nAdding messageinfo to db from db \n"));
} else
g_warning ("Loading messageinfo from db failed");
@@ -745,6 +784,30 @@
/* saves the content descriptions, recursively */
static int
+perform_content_info_save_to_db (CamelFolderSummary *s, CamelMessageContentInfo *ci, CamelMIRecord *record)
+{
+ CamelMessageContentInfo *part;
+ char *oldr, *cnt;
+ if (((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS (s)))->content_info_to_db (s, ci, record) == -1)
+ return -1;
+
+ oldr = record->cinfo;
+ cnt = g_strdup_printf (" %d", my_list_size ((struct _node **)&ci->childs));
+ record->cinfo = g_strconcat (oldr, cnt, NULL);
+ g_free (oldr); g_free (cnt);
+
+ part = ci->childs;
+ while (part) {
+ if (perform_content_info_save_to_db (s, part, record) == -1)
+ return -1;
+ part = part->next;
+ }
+
+ return 0;
+}
+
+/* saves the content descriptions, recursively */
+static int
perform_content_info_save(CamelFolderSummary *s, FILE *out, CamelMessageContentInfo *ci)
{
CamelMessageContentInfo *part;
@@ -782,6 +845,15 @@
for (i = 0; i < count; ++i) {
mi = s->messages->pdata [i];
mir = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_to_db (s, mi);
+
+ if (mir && s->build_content) {
+ if (perform_content_info_save_to_db (s, ((CamelMessageInfoBase *)mi)->content, mir) == -1) {
+ g_warning ("unable to save mir+cinfo for uid: %s\n", mir->uid);
+ /* FIXME: Add exception here */
+ return -1;
+ }
+ }
+
if (camel_db_write_message_info_record (cdb, folder_name, mir, ex) != 0)
return -1;
}
@@ -2092,11 +2164,11 @@
}
static CamelMessageInfo *
-message_info_from_db (CamelFolderSummary *s, struct _CamelMIRecord *record)
+message_info_from_db (CamelFolderSummary *s, CamelMIRecord *record)
{
CamelMessageInfoBase *mi;
int i;
- int len, val, count;
+ int count;
char *part, *label;
mi = (CamelMessageInfoBase *)camel_message_info_new(s);
@@ -2143,7 +2215,7 @@
if (part[i] == ' ') {
part[i] = 0;
camel_flag_set(&mi->user_flags, label, TRUE);
- label = part[i+1];
+ label = &(part[i+1]);
}
}
camel_flag_set(&mi->user_flags, label, TRUE);
@@ -2161,7 +2233,7 @@
g_free(value);
}
- return mi;
+ return (CamelMessageInfo *) mi;
}
static CamelMessageInfo *
@@ -2550,45 +2622,45 @@
ct = ci->type;
if (ct) {
if (ct->type)
- g_string_append_printf (str, " %lu-%s", strlen (ct->type), ct->type);
+ g_string_append_printf (str, " %d-%s", strlen (ct->type), ct->type);
else
g_string_append_printf (str, " 0-");
if (ct->subtype)
- g_string_append_printf (str, " %lu-%s", strlen (ct->subtype), ct->subtype);
+ g_string_append_printf (str, " %d-%s", strlen (ct->subtype), ct->subtype);
else
g_string_append_printf (str, " 0-");
- g_string_append_printf (str, " %lu", my_list_size((struct _node **)&ct->params));
+ g_string_append_printf (str, " %d", my_list_size((struct _node **)&ct->params));
hp = ct->params;
while (hp) {
if (hp->name)
- g_string_append_printf (str, " %lu-%s", strlen(hp->name), hp->name);
+ g_string_append_printf (str, " %d-%s", strlen(hp->name), hp->name);
else
g_string_append_printf (str, " 0-");
if (hp->value)
- g_string_append_printf (str, " %lu-%s", strlen (hp->value), hp->value);
+ g_string_append_printf (str, " %d-%s", strlen (hp->value), hp->value);
else
g_string_append_printf (str, " 0-");
hp = hp->next;
}
} else {
- g_string_append_printf (str, " %lu-", 0);
- g_string_append_printf (str, " %lu-", 0);
- g_string_append_printf (str, " %lu", 0);
+ g_string_append_printf (str, " %d-", 0);
+ g_string_append_printf (str, " %d-", 0);
+ g_string_append_printf (str, " %d", 0);
}
if (ci->id)
- g_string_append_printf (str, " %lu-%s", strlen (ci->id), ci->id);
+ g_string_append_printf (str, " %d-%s", strlen (ci->id), ci->id);
else
g_string_append_printf (str, " 0-");
if (ci->description)
- g_string_append_printf (str, " %lu-%s", strlen (ci->description), ci->description);
+ g_string_append_printf (str, " %d-%s", strlen (ci->description), ci->description);
else
g_string_append_printf (str, " 0-");
if (ci->encoding)
- g_string_append_printf (str, " %lu-%s", strlen (ci->encoding), ci->encoding);
+ g_string_append_printf (str, " %d-%s", strlen (ci->encoding), ci->encoding);
else
g_string_append_printf (str, " 0-");
- g_string_append_printf (str, " %lu", ci->size);
+ g_string_append_printf (str, " %u", ci->size);
if (record->cinfo) {
oldr = record->cinfo;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]