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



Author: sragavan
Date: Fri Jun  6 04:58:29 2008
New Revision: 8938
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8938&view=rev

Log:
More refactoring.


Modified:
   branches/camel-db-summary/camel/camel-folder-summary.c
   branches/camel-db-summary/camel/providers/groupwise/camel-groupwise-folder.c
   branches/camel-db-summary/camel/providers/imap/camel-imap-folder.c
   branches/camel-db-summary/camel/providers/imap/camel-imap-utils.c
   branches/camel-db-summary/camel/providers/local/camel-maildir-summary.c
   branches/camel-db-summary/camel/providers/local/camel-mbox-summary.c
   branches/camel-db-summary/camel/providers/local/camel-mh-summary.c

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 Jun  6 04:58:29 2008
@@ -375,8 +375,11 @@
 
 		/* FIXME: Get exception from caller
 		and pass it on below */
+		
+		CAMEL_SUMMARY_UNLOCK(s, ref_lock);
+		CAMEL_SUMMARY_UNLOCK(s, summary_lock);
 
-		info = camel_folder_summary_uid (s, uid);
+		return camel_folder_summary_uid (s, uid);
 	}
 
 	CAMEL_SUMMARY_UNLOCK(s, ref_lock);
@@ -385,6 +388,7 @@
 	return info;
 }
 
+#warning "Implement - camel_folder_summary_uid_exist - directly through db than manual strcmp"
 
 /**
  * camel_folder_summary__uid_from_index:
@@ -480,8 +484,11 @@
 		cdb = s->folder->parent_store->cdb;
 
 		ret = camel_db_read_message_info_record_with_uid (cdb, folder_name, uid, (gpointer**) &s, camel_read_mir_callback, &ex);
-		if (ret != 0)
+		if (ret != 0) {
+			CAMEL_SUMMARY_UNLOCK(s, ref_lock);
+			CAMEL_SUMMARY_UNLOCK(s, summary_lock);
 			return NULL;
+		}
 		
 		info = g_hash_table_lookup (s->loaded_infos, uid);
 
@@ -491,6 +498,10 @@
 		}
 	}
 
+	#warning "this will help to find crash, so leave it just like this atm"
+	if (info)
+		info->refcount++;
+	
 	CAMEL_SUMMARY_UNLOCK(s, ref_lock);
 	CAMEL_SUMMARY_UNLOCK(s, summary_lock);
 
@@ -902,7 +913,7 @@
 	}
 
 	/* Push MessageInfo-es */
-	g_hash_table_foreach (s->loaded_infos, save_to_db_cb, s);
+	g_hash_table_foreach (s->loaded_infos, save_to_db_cb, ex);
 
 #warning "make sure we free the message infos that are loaded are freed if not used anymore or should we leave that to the timer? "
 	
@@ -1248,12 +1259,12 @@
 #endif
 
 	/* Summary always holds a ref for the loaded infos */
-	//camel_message_info_ref(info); //FIXME: Check how things are loaded.
+	camel_message_info_ref(info); //FIXME: Check how things are loaded.
 	#warning "FIXME: SHould we ref it or redesign it later on"
 	/* The uid array should have its own memory. We will unload the infos when not reqd.*/
-	g_ptr_array_add (s->uids, (char *) g_strdup(camel_message_info_uid(info)));
+	g_ptr_array_add (s->uids, g_strdup(camel_message_info_uid(info)));
 	
-	g_hash_table_insert (s->loaded_infos, (char *) camel_message_info_uid(info), info);
+	g_hash_table_insert (s->loaded_infos, camel_message_info_uid (info), info);
 	s->flags |= CAMEL_SUMMARY_DIRTY;
 
 	CAMEL_SUMMARY_UNLOCK(s, summary_lock);
@@ -1621,8 +1632,9 @@
 {
 	CAMEL_SUMMARY_LOCK(s, summary_lock);
 
+	g_hash_table_remove (s->loaded_infos, camel_message_info_uid(info));	
 	summary_remove_uid (s, camel_message_info_uid(info));
-	g_hash_table_remove (s->loaded_infos, info);
+
 	
 	s->flags |= CAMEL_SUMMARY_DIRTY;
 	s->meta_summary->msg_expunged = TRUE;
@@ -1726,10 +1738,8 @@
 		g_slist_foreach (uids, (GFunc) g_free, NULL);
 		g_slist_free (uids);
 
-		/* FIXME: GOK What it means. I'll fix this later 
-		memmove(s->messages->pdata+start, s->messages->pdata+end, (s->messages->len-end)*sizeof(s->messages->pdata[0]));
-		g_ptr_array_set_size(s->messages, s->messages->len - (end - start));
-		*/
+		memmove(s->uids->pdata+start, s->uids->pdata+end, (s->uids->len-end)*sizeof(s->uids->pdata[0]));
+		g_ptr_array_set_size(s->uids, s->uids->len - (end - start));
 
 		s->flags |= CAMEL_SUMMARY_DIRTY;
 
@@ -2657,6 +2667,7 @@
 {
 	CamelMessageInfoBase *mi = (CamelMessageInfoBase *)info;
 
+	g_hash_table_remove (s->loaded_infos, mi->uid);
 	g_free(mi->uid);
 	camel_pstring_free(mi->subject);
 	camel_pstring_free(mi->from);

Modified: branches/camel-db-summary/camel/providers/groupwise/camel-groupwise-folder.c
==============================================================================
--- branches/camel-db-summary/camel/providers/groupwise/camel-groupwise-folder.c	(original)
+++ branches/camel-db-summary/camel/providers/groupwise/camel-groupwise-folder.c	Fri Jun  6 04:58:29 2008
@@ -1969,7 +1969,7 @@
 	int index = 0;
 	GList *temp;
 	CamelFolderChangeInfo *changes = NULL;
-	CamelMessageInfo *info; 
+	char *uid;
 	changes = camel_folder_change_info_new ();
 
 	item_list = g_list_reverse (item_list);
@@ -1977,18 +1977,18 @@
 	summary = camel_folder_get_summary (folder);
 	/*item_ids : List of ids from the summary*/
 	while (index < summary->len) {
-		info = g_ptr_array_index (summary, index);
+		uid = g_ptr_array_index (summary, index);
 		temp = NULL; 
 
 		if (item_list) {
-			temp = g_list_find_custom (item_list, (const char *)info->uid, (GCompareFunc) strcmp);
+			temp = g_list_find_custom (item_list, (const char *)uid, (GCompareFunc) strcmp);
 		}
 
 		if (!temp) {
 			CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
-			camel_folder_summary_remove_uid (folder->summary, info->uid);
-			camel_data_cache_remove (gw_folder->cache, "cache", info->uid, NULL);
-			camel_folder_change_info_remove_uid (changes, info->uid);
+			camel_folder_summary_remove_uid (folder->summary, uid);
+			camel_data_cache_remove (gw_folder->cache, "cache", uid, NULL);
+			camel_folder_change_info_remove_uid (changes, uid);
 			CAMEL_GROUPWISE_FOLDER_REC_UNLOCK (folder, cache_lock);
 		} else { 
 			item_list = g_list_delete_link (item_list, temp);

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	Fri Jun  6 04:58:29 2008
@@ -3070,21 +3070,24 @@
 					      i + first);
 			break;
 		}
-		info = (CamelImapMessageInfo *)camel_folder_summary_uid(folder->summary, uid);
-		if (info) {
-			for (seq = 0; seq < camel_folder_summary_count (folder->summary); seq++) {
-				if (folder->summary->messages->pdata[seq] == info)
-					break;
-			}
 
-			g_warning("Message already present? %s", camel_message_info_uid(mi));
-			camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
-					      _("Unexpected server response: Identical UIDs provided for messages %d and %d"),
-					      seq + 1, i + first);
-
-			camel_message_info_free(&info->info);
-			break;
-		} 
+		/* FIXME: If it enters if(info) it will always match the exception. So stupid */
+		#warning "Use a db query to see if the DB exists"
+/* 		info = (CamelImapMessageInfo *)camel_folder_summary_uid(folder->summary, uid); */
+/* 		if (info) { */
+/* 			for (seq = 0; seq < camel_folder_summary_count (folder->summary); seq++) { */
+/* 				if (folder->summary->messages->pdata[seq] == info) */
+/* 					break; */
+/* 			} */
+
+/* 			g_warning("Message already present? %s", camel_message_info_uid(mi)); */
+/* 			camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, */
+/* 					      _("Unexpected server response: Identical UIDs provided for messages %d and %d"), */
+/* 					      seq + 1, i + first); */
+
+/* 			camel_message_info_free(&info->info); */
+/* 			break; */
+/* 		}  */
 
 		camel_folder_summary_add (folder->summary, (CamelMessageInfo *)mi);
 		camel_folder_change_info_add_uid (changes, camel_message_info_uid (mi));

Modified: branches/camel-db-summary/camel/providers/imap/camel-imap-utils.c
==============================================================================
--- branches/camel-db-summary/camel/providers/imap/camel-imap-utils.c	(original)
+++ branches/camel-db-summary/camel/providers/imap/camel-imap-utils.c	Fri Jun  6 04:58:29 2008
@@ -1179,10 +1179,11 @@
 {
 	CamelMessageInfo *info;
 	unsigned long uid;
-	
-	info = camel_folder_summary_index (summary, index);
-	uid = strtoul (camel_message_info_uid (info), NULL, 10);
-	camel_message_info_free(info);
+	char *suid;
+
+	suid = camel_folder_summary_uid_from_index (summary, index);
+	uid = strtoul (suid, NULL, 10);
+	g_free (suid);
 	return uid;
 }
 

Modified: branches/camel-db-summary/camel/providers/local/camel-maildir-summary.c
==============================================================================
--- branches/camel-db-summary/camel/providers/local/camel-maildir-summary.c	(original)
+++ branches/camel-db-summary/camel/providers/local/camel-maildir-summary.c	Fri Jun  6 04:58:29 2008
@@ -726,7 +726,8 @@
 
 	/* sort the summary based on receive time, since the directory order is not useful */
 	CAMEL_SUMMARY_LOCK(s, summary_lock);
-	qsort(s->messages->pdata, s->messages->len, sizeof(CamelMessageInfo *), sort_receive_cmp);
+	#warning Add support for sorting via the DB.
+/* 	qsort(s->messages->pdata, s->messages->len, sizeof(CamelMessageInfo *), sort_receive_cmp); */
 	CAMEL_SUMMARY_UNLOCK(s, summary_lock);
 
 	g_mutex_unlock (((CamelMaildirSummary *) cls)->priv->summary_lock);

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	Fri Jun  6 04:58:29 2008
@@ -984,6 +984,8 @@
 		CamelMboxMessageInfo *info = (CamelMboxMessageInfo *)camel_folder_summary_index(s, i);
 
 		g_assert(info);
+//		if (!info)
+//			continue;
 		if ((expunge && (info->info.info.flags & CAMEL_MESSAGE_DELETED)) ||
 		    (info->info.info.flags & (CAMEL_MESSAGE_FOLDER_NOXEV|CAMEL_MESSAGE_FOLDER_XEVCHANGE)))
 			quick = FALSE;

Modified: branches/camel-db-summary/camel/providers/local/camel-mh-summary.c
==============================================================================
--- branches/camel-db-summary/camel/providers/local/camel-mh-summary.c	(original)
+++ branches/camel-db-summary/camel/providers/local/camel-mh-summary.c	Fri Jun  6 04:58:29 2008
@@ -294,7 +294,10 @@
 
 	/* sort the summary based on message number (uid), since the directory order is not useful */
 	CAMEL_SUMMARY_LOCK(s, summary_lock);
-	qsort(s->messages->pdata, s->messages->len, sizeof(CamelMessageInfo *), sort_uid_cmp);
+/* 	qsort(s->uids->pdata, s->uids->len, sizeof(CamelMessageInfo *), sort_uid_cmp); */
+	#warning "verify if strcmp works the same as the other one. Too busy to check this."
+    #warning "lets build a sort support for uid fetching from the db"
+	qsort(s->uids->pdata, s->uids->len, sizeof(CamelMessageInfo *), strcmp);	
 	CAMEL_SUMMARY_UNLOCK(s, summary_lock);
 
 	return 0;



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