evolution-data-server r9155 - in trunk/camel: . providers/groupwise providers/imap providers/local
- From: sragavan svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r9155 - in trunk/camel: . providers/groupwise providers/imap providers/local
- Date: Mon, 21 Jul 2008 08:59:55 +0000 (UTC)
Author: sragavan
Date: Mon Jul 21 08:59:54 2008
New Revision: 9155
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9155&view=rev
Log:
Add migration code and more cleanups.
Modified:
trunk/camel/camel-folder-summary.c
trunk/camel/camel-folder-summary.h
trunk/camel/providers/groupwise/camel-groupwise-summary.c
trunk/camel/providers/imap/camel-imap-summary.c
trunk/camel/providers/local/camel-mbox-store.c
Modified: trunk/camel/camel-folder-summary.c
==============================================================================
--- trunk/camel/camel-folder-summary.c (original)
+++ trunk/camel/camel-folder-summary.c Mon Jul 21 08:59:54 2008
@@ -499,7 +499,7 @@
ret = camel_db_read_message_info_record_with_uid (cdb, folder_name, uid, &data, camel_read_mir_callback, &ex);
if (ret != 0) {
// if (strcmp (folder_name, "UNMATCHED"))
- g_warning ("Unable to read uid %s from folder %s: %s", uid, folder_name, camel_exception_get_description(&ex));
+ //g_warning ("Unable to read uid %s from folder %s: %s", uid, folder_name, camel_exception_get_description(&ex));
return NULL;
}
@@ -1028,6 +1028,108 @@
}
+
+int
+camel_folder_summary_migrate_infos(CamelFolderSummary *s)
+{
+ FILE *in;
+ int i;
+ CamelMessageInfo *mi;
+ int ret = 0;
+ CamelDB *cdb = s->folder->cdb;
+ CamelFIRecord *record;
+ CamelException ex;
+
+ camel_exception_init (&ex);
+ d(g_print ("\ncamel_folder_summary_load from FLAT FILE called \n"));
+
+ if (s->summary_path == NULL) {
+ g_warning ("No summary path set. Unable to migrate\n");
+ return NULL;
+ }
+
+ in = g_fopen(s->summary_path, "rb");
+ if (in == NULL)
+ return -1;
+
+ if ( ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_load(s, in) == -1)
+ goto error;
+
+ /* now read in each message ... */
+ for (i=0;i<s->saved_count;i++) {
+ mi = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_load(s, in);
+
+ if (mi == NULL)
+ goto error;
+
+ /* FIXME: this should be done differently, how i don't know */
+ if (s->build_content) {
+ ((CamelMessageInfoBase *)mi)->content = perform_content_info_load(s, in);
+ if (((CamelMessageInfoBase *)mi)->content == NULL) {
+ camel_message_info_free(mi);
+ goto error;
+ }
+ }
+
+ CamelTag *tag;
+
+ tag = mi->user_tags;
+ while (tag) {
+ if (strcmp (tag->name, "label")) {
+ res = camel_flag_set(&mi->user_flags, tag->value, TRUE);
+ }
+ tag = tag->next;
+ }
+
+ mi->dirty = TRUE;
+ g_hash_table_insert (s->loaded_infos, mi->uid, mi);
+ }
+
+
+ if (fclose (in) != 0)
+ return -1;
+
+
+ camel_db_begin_transaction (cdb, &ex);
+
+ ret = save_message_infos_to_db (s, &ex);
+
+ if (ret != 0) {
+ camel_db_abort_transaction (cdb, &ex);
+ return -1;
+ }
+ camel_db_end_transaction (cdb, &ex);
+
+ record = (((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_to_db (s, &ex));
+ if (!record) {
+ return -1;
+ }
+
+ camel_db_begin_transaction (cdb, &ex);
+ ret = camel_db_write_folder_info_record (cdb, record, &ex);
+ g_free (record);
+
+ if (ret != 0) {
+ camel_db_abort_transaction (cdb, &ex);
+ return -1;
+ }
+
+ camel_db_end_transaction (cdb, &ex);
+
+
+ return ret;
+
+error:
+ if (errno != EINVAL)
+ g_warning ("Cannot load summary file: '%s': %s", s->summary_path, g_strerror (errno));
+
+ fclose (in);
+
+ return -1;
+
+}
+
+
/* saves the content descriptions, recursively */
static int
perform_content_info_save_to_db (CamelFolderSummary *s, CamelMessageContentInfo *ci, CamelMIRecord *record)
@@ -1144,14 +1246,14 @@
camel_db_abort_transaction (cdb, ex);
return -1;
}
-
+ camel_db_end_transaction (cdb, ex);
record = (((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->summary_header_to_db (s, ex));
if (!record) {
- camel_db_abort_transaction (cdb, ex);
return -1;
}
-
+
+ camel_db_begin_transaction (cdb, ex);
ret = camel_db_write_folder_info_record (cdb, record, ex);
g_free (record);
Modified: trunk/camel/camel-folder-summary.h
==============================================================================
--- trunk/camel/camel-folder-summary.h (original)
+++ trunk/camel/camel-folder-summary.h Mon Jul 21 08:59:54 2008
@@ -459,6 +459,9 @@
void camel_message_info_dump (CamelMessageInfo *mi);
+/* Migration code */
+int camel_folder_summary_migrate_infos(CamelFolderSummary *s);
+
G_END_DECLS
#endif /* ! _CAMEL_FOLDER_SUMMARY_H */
Modified: trunk/camel/providers/groupwise/camel-groupwise-summary.c
==============================================================================
--- trunk/camel/providers/groupwise/camel-groupwise-summary.c (original)
+++ trunk/camel/providers/groupwise/camel-groupwise-summary.c Mon Jul 21 08:59:54 2008
@@ -165,6 +165,7 @@
summary->folder = folder ;
camel_folder_summary_set_build_content (summary, TRUE);
+ camel_folder_summary_set_filename (summary, filename);
camel_exception_init (&ex);
if (camel_folder_summary_load_from_db (summary, &ex) == -1) {
Modified: trunk/camel/providers/imap/camel-imap-summary.c
==============================================================================
--- trunk/camel/providers/imap/camel-imap-summary.c (original)
+++ trunk/camel/providers/imap/camel-imap-summary.c Mon Jul 21 08:59:54 2008
@@ -158,6 +158,7 @@
summary->folder = folder;
camel_folder_summary_set_build_content (summary, TRUE);
+ camel_folder_summary_set_filename (summary, filename);
if (camel_folder_summary_load_from_db (summary, &ex) == -1) {
/* FIXME: Isn't this dangerous ? We clear the summary
Modified: trunk/camel/providers/local/camel-mbox-store.c
==============================================================================
--- trunk/camel/providers/local/camel-mbox-store.c (original)
+++ trunk/camel/providers/local/camel-mbox-store.c Mon Jul 21 08:59:54 2008
@@ -101,7 +101,7 @@
}
static char *extensions[] = {
- ".msf", ".ev-summary", ".ev-summary-meta", ".ibex.index", ".ibex.index.data", ".cmeta", ".lock", ".db"
+ ".msf", ".ev-summary", ".ev-summary-meta", ".ibex.index", ".ibex.index.data", ".cmeta", ".lock", ".db", ".journal"
};
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]