evolution-data-server r9048 - in branches/camel-db-summary/camel: . providers/imap providers/local



Author: sragavan
Date: Thu Jun 26 05:24:02 2008
New Revision: 9048
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9048&view=rev

Log:
Make IMAP work well on production. Make mbox too rock.


Modified:
   branches/camel-db-summary/camel/camel-db.c
   branches/camel-db-summary/camel/camel-folder-search.c
   branches/camel-db-summary/camel/camel-folder-summary.c
   branches/camel-db-summary/camel/providers/imap/camel-imap-folder.c
   branches/camel-db-summary/camel/providers/local/camel-mbox-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	Thu Jun 26 05:24:02 2008
@@ -60,7 +60,8 @@
 	d(g_print ("\nDatabase succesfully opened  \n"));
 
 	#warning "make these under g_getenv"
-	camel_db_command (cdb, "PRAGMA cache_size=100", NULL);
+	
+	//camel_db_command (cdb, "PRAGMA cache_size=100", NULL);
 	
 	return cdb;
 }
@@ -706,11 +707,11 @@
 		camel_pstring_free (record->followup_flag);
 		camel_pstring_free (record->followup_completed_on);
 		camel_pstring_free (record->followup_due_by);
-		camel_pstring_free (record->part);
-		camel_pstring_free (record->labels);
-		camel_pstring_free (record->usertags);
-		camel_pstring_free (record->cinfo);
-		camel_pstring_free (record->bdata);
+		g_free (record->part);
+		g_free (record->labels);
+		g_free (record->usertags);
+		g_free (record->cinfo);
+		g_free (record->bdata);
 
 		g_free (record);
 	}

Modified: branches/camel-db-summary/camel/camel-folder-search.c
==============================================================================
--- branches/camel-db-summary/camel/camel-folder-search.c	(original)
+++ branches/camel-db-summary/camel/camel-folder-search.c	Thu Jun 26 05:24:02 2008
@@ -50,6 +50,7 @@
 #include "camel-stream-mem.h"
 #include "camel-db.h"
 #include "camel-store.h"
+#include "camel-vee-folder.h"
 
 #define d(x) 
 #define r(x) 
@@ -665,8 +666,42 @@
 		g_assert(0);
 		return r;
 	}
+#if 0
+	v = search->summary_set?search->summary_set:search->summary;
+	
+	if (v->len - g_hash_table_size (search->folder->summary->loaded_infos) > 100 && !CAMEL_IS_VEE_FOLDER (search->folder)) {
+		/* Load the DB contents. FIXME this 100 needs to be a better threshold to reload from DB. */
+		#warning "handle exception"
+		camel_folder_summary_reload_from_db (search->folder->summary, NULL);
+	} 
 
+#endif	
 	e_sexp_term_eval (f, argv [0]);
+#if 0
+	for (i=0;i<v->len;i++) {
+		const char *uid;
+
+		search->current = camel_folder_summary_uid (search->folder->summary, v->pdata[i]);
+		uid = camel_message_info_uid(search->current);
+
+		if (argc>0) {
+			r1 = e_sexp_term_eval(f, argv[0]);
+			if (r1->type == ESEXP_RES_BOOL) {
+				if (r1->value.bool)
+					g_ptr_array_add(r->value.ptrarray, (char *)uid);
+			} else {
+				g_warning("invalid syntax, matches require a single bool result");
+				error_msg = g_strdup_printf(_("(%s) requires a single bool result"), "match-all");
+				e_sexp_fatal_error(f, error_msg);
+				g_free(error_msg);
+			}
+			e_sexp_result_free(f, r1);
+		} else {
+			g_ptr_array_add(r->value.ptrarray, (char *)uid);
+		}
+		camel_message_info_free (search->current);
+	}
+#endif	
 	search->current = NULL;
 	return r;
 }

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 Jun 26 05:24:02 2008
@@ -679,7 +679,7 @@
 static gboolean
 remove_item (char *key, CamelMessageInfo *info, CamelFolderSummary *s)
 {
-	d(printf("%d\t", info->refcount)); //camel_message_info_dump (info);
+	d(printf("%d(%d)\t", info->refcount, info->dirty)); //camel_message_info_dump (info);
 	CAMEL_SUMMARY_LOCK(info->summary, ref_lock);
 	if (info->refcount == 1 && !info->dirty) {
 		CAMEL_SUMMARY_UNLOCK(info->summary, ref_lock);
@@ -697,16 +697,36 @@
 remove_cache (CamelFolderSummary *s)
 {
 	struct _CamelFolderSummaryPrivate *p = _PRIVATE(s);
-	d(printf("removing cache for  %s %d\n", s->folder->full_name, g_hash_table_size (s->loaded_infos)));
+
+	printf("removing cache for  %s %d\n", s->folder->full_name, g_hash_table_size (s->loaded_infos));
 	#warning "hack. fix it"
 	CAMEL_SUMMARY_LOCK (s, summary_lock);
 	g_hash_table_foreach_remove  (s->loaded_infos, remove_item, s);
 	CAMEL_SUMMARY_UNLOCK (s, summary_lock);
-	d(printf("done .. now %d\n",g_hash_table_size (s->loaded_infos)));
+	printf("done .. now %d\n",g_hash_table_size (s->loaded_infos));
 	return TRUE;
 }
 
 int
+camel_folder_summary_reload_from_db (CamelFolderSummary *s, CamelException *ex)
+{
+	CamelDB *cdb;
+	char *folder_name;
+	int ret = 0;
+
+	d(printf ("\ncamel_folder_summary_reload_from_db called \n"));
+
+	folder_name = s->folder->full_name;
+	cdb = s->folder->parent_store->cdb;
+
+	/* FIXME FOR SANKAR: No need to pass the address of summary here. */
+	ret = camel_db_read_message_info_records (cdb, folder_name, (gpointer**) &s, camel_read_mir_callback, ex);
+
+	return ret;
+}
+
+
+int
 camel_folder_summary_load_from_db (CamelFolderSummary *s, CamelException *ex)
 {
 	CamelDB *cdb;
@@ -728,7 +748,7 @@
 	ret = camel_db_read_message_info_records (cdb, folder_name, (gpointer**) &s, camel_read_mir_callback, ex);
 
 	#warning "LRU please and not timeouts"
-	g_timeout_add_seconds (40, remove_cache, s);
+	g_timeout_add_seconds (5, remove_cache, s);
 	return ret;
 }
 
@@ -778,15 +798,15 @@
 		else if ( !strcmp (name [i], "followup_due_by") ) 
 			mir->followup_due_by = camel_pstring_strdup(cols [i]);
 		else if ( !strcmp (name [i], "part") ) 
-			mir->part = camel_pstring_strdup (cols [i]);
+			mir->part = g_strdup (cols [i]);
 		else if ( !strcmp (name [i], "labels") ) 
-			mir->labels = camel_pstring_strdup (cols [i]);
+			mir->labels = g_strdup (cols [i]);
 		else if ( !strcmp (name [i], "usertags") ) 
-			mir->usertags = camel_pstring_strdup (cols [i]);
+			mir->usertags = g_strdup (cols [i]);
 		else if ( !strcmp (name [i], "cinfo") ) 
-			mir->cinfo = camel_pstring_strdup(cols [i]);
+			mir->cinfo = g_strdup(cols [i]);
 		else if ( !strcmp (name [i], "bdata") ) 
-			mir->bdata = camel_pstring_strdup(cols [i]);
+			mir->bdata = g_strdup(cols [i]);
 
 	}	
 }
@@ -800,8 +820,17 @@
 	int i;
 
 	mir = g_new0 (CamelMIRecord , 1);
-
 	mir_from_cols (mir, s, ncol, cols, name);
+	
+	CAMEL_SUMMARY_LOCK (s, summary_lock);
+	if (g_hash_table_lookup (s->loaded_infos, mir->uid)) {
+		/* Unlock and better return*/
+		CAMEL_SUMMARY_UNLOCK (s, summary_lock);
+		camel_db_camel_mir_free (mir);
+		return;
+	}
+	CAMEL_SUMMARY_UNLOCK (s, summary_lock);
+
 
 	info = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_from_db (s, mir);
 
@@ -847,24 +876,25 @@
 	info = ((CamelFolderSummaryClass *)(CAMEL_OBJECT_GET_CLASS(s)))->message_info_from_db (s, mir);
 
 	if (info) {
-
 		if (s->build_content) {
+			char *tmp;
+			tmp = mir->cinfo;			
 			/* 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;
-			} 
+			}
+			mir->cinfo = tmp;			
 		}
 
 		/* Just now we are reading from the DB, it can't be dirty. */
 		((CamelMessageInfoBase *)info)->dirty = FALSE;
 		//((CamelMessageInfoBase *)info)->flags &= ~CAMEL_MESSAGE_DB_DIRTY;
-		/* double reffing, because, at times frees before, I could read it. */
+		/* double reffing, because, at times frees before, I could read it. */		
 		camel_message_info_ref(info);
-		camel_folder_summary_insert (s, info, TRUE);
-		
 		d(g_print ("\nAdding messageinfo to db from db \n"));
+		camel_folder_summary_insert (s, info, TRUE);
 	} else
 		g_warning ("Loading messageinfo from db failed");
 
@@ -1353,9 +1383,10 @@
 	if (info == NULL)
 		return;
 
+	
 	if (summary_assign_uid(s, info) == 0)
 		return;
-
+	
 	CAMEL_SUMMARY_LOCK(s, summary_lock);
 
 /* unnecessary for pooled vectors */

Modified: branches/camel-db-summary/camel/providers/imap/camel-imap-folder.c
==============================================================================
--- branches/camel-db-summary/camel/providers/imap/camel-imap-folder.c	(original)
+++ branches/camel-db-summary/camel/providers/imap/camel-imap-folder.c	Thu Jun 26 05:24:02 2008
@@ -739,7 +739,7 @@
 	array_str = g_strsplit (custom_flags, " ", -1);
 
 	while (array_str[index] != NULL) {
-		camel_message_info_set_user_flag (mi, array_str[index], TRUE);
+		camel_flag_set(&((CamelMessageInfoBase *)mi)->user_flags, array_str[index], TRUE);
 		++ index;
 	}
 
@@ -2911,10 +2911,13 @@
 	 */
 	fetch_data = g_ptr_array_new ();
 	messages = g_ptr_array_new ();
+	int k = 0, ct;
+	ct = exists - seq;
 	while ((type = camel_imap_command_response (store, &resp, ex)) ==
 	       CAMEL_IMAP_RESPONSE_UNTAGGED && !camel_application_is_exiting) {
 		data = parse_fetch_response (imap_folder, resp);
 		g_free (resp);
+		k++;
 		if (!data)
 			continue;
 		
@@ -2939,7 +2942,7 @@
 			g_datalist_set_data (&data, "BODY_PART_STREAM", NULL);
 		}
 
-		camel_operation_progress (NULL, got * 100 / size);
+		camel_operation_progress (NULL, k * 100 / ct);
 		g_ptr_array_add (fetch_data, data);
 	}
 	camel_operation_end (NULL);
@@ -3067,7 +3070,7 @@
 		
 		uid = g_datalist_get_data (&data, "UID");
 		if (uid)
-			mi->info.uid = g_strdup (uid);
+			mi->info.uid = camel_pstring_strdup (uid);
 		flags = GPOINTER_TO_INT (g_datalist_get_data (&data, "FLAGS"));
 		if (flags) {
 			char *custom_flags = NULL;
@@ -3137,6 +3140,7 @@
 /* 			break; */
 /* 		}  */
 
+		((CamelMessageInfoBase *)mi)->dirty = TRUE;
 		camel_folder_summary_add (folder->summary, (CamelMessageInfo *)mi);
 		camel_folder_change_info_add_uid (changes, camel_message_info_uid (mi));
 
@@ -3146,10 +3150,10 @@
 			camel_folder_change_info_recent_uid (changes, camel_message_info_uid (mi));
 	}
 
-	for ( ; i < messages->len; i++) {
-		if ((mi = messages->pdata[i]))
-			camel_message_info_free(&mi->info);
-	}
+/* 	for ( ; i < messages->len; i++) { */
+/* 		if ((mi = messages->pdata[i])) */
+/* 			camel_message_info_free(&mi->info); */
+/* 	} */
 	
 	g_ptr_array_free (messages, TRUE);
 	

Modified: branches/camel-db-summary/camel/providers/local/camel-mbox-summary.c
==============================================================================
--- branches/camel-db-summary/camel/providers/local/camel-mbox-summary.c	(original)
+++ branches/camel-db-summary/camel/providers/local/camel-mbox-summary.c	Thu Jun 26 05:24:02 2008
@@ -42,6 +42,9 @@
 #include "camel-private.h"
 
 #include "camel-mbox-summary.h"
+#include "camel-string-utils.h"
+#include "camel-store.h"
+#include "camel-folder.h"
 
 #define io(x)
 #define d(x) /*(printf("%s(%d): ", __FILE__, __LINE__),(x))*/
@@ -815,7 +818,7 @@
 	summary = camel_folder_summary_get_changed ((CamelFolderSummary *)mbs);
 	for (i = 0; i < summary->len; i++) {
 		int xevoffset;
-		int pc = (i+1)*100/count;
+		int pc = (i+1)*100/summary->len;
 
 		camel_operation_progress(NULL, pc);
 
@@ -984,7 +987,7 @@
 
 	summary = camel_folder_summary_get_changed ((CamelFolderSummary *)mbs);
 	for (i=0; i<summary->len; i++) {
-		CamelMboxMessageInfo *info = (CamelMboxMessageInfo *)camel_folder_summary_uids(s, summary->pdata[i]);
+		CamelMboxMessageInfo *info = (CamelMboxMessageInfo *)camel_folder_summary_uid(s, summary->pdata[i]);
 		
 		if ((expunge && (info->info.info.flags & CAMEL_MESSAGE_DELETED)) ||
 		    (info->info.info.flags & (CAMEL_MESSAGE_FOLDER_NOXEV|CAMEL_MESSAGE_FOLDER_XEVCHANGE)))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]