evolution-exchange r1695 - in trunk: . camel



Author: psankar
Date: Wed Jul 16 11:55:38 2008
New Revision: 1695
URL: http://svn.gnome.org/viewvc/evolution-exchange?rev=1695&view=rev

Log:
2008-07-16  Sankar P  <psankar novell com>

	Pushing changes that are necessary for disk-summary to work. 

	* camel/camel-exchange-folder.c (class_init),
	(camel_exchange_folder_construct), (exchange_sync):
	* camel/camel-exchange-summary.c (exchange_summary_class_init),
	(camel_exchange_summary_new), (summary_header_from_db),
	(summary_header_to_db), (message_info_from_db),
	(message_info_load), (message_info_to_db):




Modified:
   trunk/ChangeLog
   trunk/camel/camel-exchange-folder.c
   trunk/camel/camel-exchange-summary.c

Modified: trunk/camel/camel-exchange-folder.c
==============================================================================
--- trunk/camel/camel-exchange-folder.c	(original)
+++ trunk/camel/camel-exchange-folder.c	Wed Jul 16 11:55:38 2008
@@ -55,8 +55,6 @@
 /* Returns the class for a CamelFolder */
 #define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so))
 
-static void folder_sync (CamelFolder *folder, gboolean expunge,
-			 CamelException *ex);
 static void exchange_expunge (CamelFolder *folder, CamelException *ex);
 static void append_message (CamelFolder *folder, CamelMimeMessage *message,
 			    const CamelMessageInfo *info, char **appended_uid,
@@ -97,7 +95,6 @@
 	parent_class = CAMEL_OFFLINE_FOLDER_CLASS (camel_type_get_global_classfuncs (camel_offline_folder_get_type ())) ;
 
 	/* virtual method definition */
-	camel_folder_class->sync = folder_sync;
 	camel_folder_class->expunge = exchange_expunge;
 	camel_folder_class->append_message = append_message;
 	camel_folder_class->get_message = get_message;
@@ -171,45 +168,6 @@
 	return camel_exchange_folder_type;
 }
 
-
-static void
-folder_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
-{
-	CamelExchangeFolder *exch = CAMEL_EXCHANGE_FOLDER (folder);
-	GPtrArray *summary, *uids;
-	CamelMessageInfo *info;
-	CamelFolder *trash;
-	int i;
-
-	/* Give the backend a chance to process queued changes. */
-	camel_stub_send (exch->stub, NULL, CAMEL_STUB_CMD_SYNC_FOLDER,
-			 CAMEL_STUB_ARG_FOLDER, folder->full_name,
-			 CAMEL_STUB_ARG_END);
-
-	/* If there are still deleted messages left, we need to delete
-	 * them the hard way.
-	 */
-	summary = camel_folder_get_summary (folder);
-	uids = g_ptr_array_new ();
-	for (i = 0; i < summary->len; i++) {
-		info = summary->pdata[i];
-		if (!(camel_message_info_flags(info) & CAMEL_MESSAGE_DELETED))
-			continue;
-		g_ptr_array_add (uids, (char *)camel_message_info_uid (info));
-	}
-	if (uids->len) {
-		trash = camel_store_get_trash (folder->parent_store, ex);
-		if (trash) {
-			transfer_messages_the_hard_way (folder, uids, trash,
-							NULL, TRUE, ex);
-		}
-	}
-	g_ptr_array_free (uids, TRUE);
-	camel_folder_free_summary (folder, summary);
-
-	camel_folder_summary_save (folder->summary);
-}
-
 static void
 refresh_info (CamelFolder *folder, CamelException *ex)
 {
@@ -1120,6 +1078,9 @@
 		hrefs = g_ptr_array_new ();
 		g_ptr_array_set_size (hrefs, summary->len);
 
+		if (summary->len - camel_folder_summary_cache_size (folder->summary) > 50)
+			camel_folder_summary_reload_from_db (folder->summary, ex);
+		
 		for (i = 0; i < summary->len; i++) {
 			info = summary->pdata[i];
 			uids->pdata[i] = (char *)camel_message_info_uid (info);
@@ -1168,7 +1129,8 @@
 		camel_operation_end (NULL);
 		if (!ok)
 			return FALSE;
-		camel_folder_summary_save (folder->summary);
+		
+		camel_folder_summary_save_to_db (folder->summary, ex);
 	}
 
 	if (camel_exchange_summary_get_readonly (folder->summary))
@@ -1183,7 +1145,7 @@
 	if (expunge)
 		exchange_expunge (folder, ex);
 
-	camel_folder_summary_save (folder->summary);
+	camel_folder_summary_save_to_db (folder->summary, ex);
 }
 
 static int

Modified: trunk/camel/camel-exchange-summary.c
==============================================================================
--- trunk/camel/camel-exchange-summary.c	(original)
+++ trunk/camel/camel-exchange-summary.c	Wed Jul 16 11:55:38 2008
@@ -37,6 +37,11 @@
 
 #define CAMEL_EXCHANGE_SUMMARY_VERSION (2)
 
+#define EXTRACT_FIRST_DIGIT(val) val=strtoul (part, &part, 10);
+#define EXTRACT_DIGIT(val) part++; val=strtoul (part, &part, 10);
+#define EXTRACT_FIRST_STRING(val) len=strtoul (part, &part, 10); part++; val=g_strndup (part, len);
+#define EXTRACT_STRING(val) part++; len=strtoul (part, &part, 10); part++; val=g_strndup (part, len);
+
 #define d(x)
 
 static int header_load (CamelFolderSummary *summary, FILE *in);
@@ -47,6 +52,10 @@
 static int               message_info_save (CamelFolderSummary *summary,
 					    FILE *out,
 					    CamelMessageInfo *info);
+static int summary_header_from_db (CamelFolderSummary *s, CamelFIRecord *mir);
+static CamelFIRecord * summary_header_to_db (CamelFolderSummary *s, CamelException *ex);
+static CamelMIRecord * message_info_to_db (CamelFolderSummary *s, CamelMessageInfo *info);
+static CamelMessageInfo * message_info_from_db (CamelFolderSummary *s, CamelMIRecord *mir);
 static CamelMessageInfo *message_info_new_from_header  (CamelFolderSummary *summary,
 							struct _camel_header_raw *h);
 
@@ -75,6 +84,11 @@
 	camel_folder_summary_class->message_info_new_from_header = message_info_new_from_header;
 	camel_folder_summary_class->message_info_free = message_info_free;
 	
+	camel_folder_summary_class->summary_header_to_db = summary_header_to_db;
+	camel_folder_summary_class->summary_header_from_db = summary_header_from_db;
+	camel_folder_summary_class->message_info_to_db = message_info_to_db;
+	camel_folder_summary_class->message_info_from_db = message_info_from_db;
+	
 	camel_folder_summary_class->info_set_flags = info_set_flags;
 	camel_folder_summary_class->info_set_user_tag = info_set_user_tag;
 }
@@ -120,18 +134,47 @@
 camel_exchange_summary_new (struct _CamelFolder *folder, const char *filename)
 {
 	CamelFolderSummary *summary;
+	CamelException lex;
 
+	camel_exception_init (&lex);
 	summary = (CamelFolderSummary *)camel_object_new (CAMEL_EXCHANGE_SUMMARY_TYPE);
 	summary->folder = folder;
 	camel_folder_summary_set_filename (summary, filename);
-	if (camel_folder_summary_load (summary) == -1) {
-		camel_folder_summary_clear (summary);
+	if (camel_folder_summary_load_from_db (summary, &lex) == -1) {
+		g_warning ("Unable to load Exchage summary for folder %s: %s\n", folder->full_name, camel_exception_get_description(&lex));
+		camel_folder_summary_clear_db (summary);
 		camel_folder_summary_touch (summary);
 	}
 
+	camel_exception_clear (&lex);
 	return summary;
 }
 
+static int
+summary_header_from_db (CamelFolderSummary *s, CamelFIRecord *mir)
+{
+	CamelExchangeSummary *exchange = (CamelExchangeSummary *) s;
+	char *part;
+
+	if (CAMEL_FOLDER_SUMMARY_CLASS (parent_class)->summary_header_from_db (s, mir) == -1)
+		return -1;
+
+	part = mir->bdata;
+
+	if (part) {
+		EXTRACT_FIRST_DIGIT (exchange->version)
+	}
+	
+	if (part) {
+		EXTRACT_DIGIT (exchange->readonly)
+	}
+
+	if (part) {
+		EXTRACT_DIGIT (exchange->high_article_num)
+	}
+	
+	return 0;
+}
 
 static int
 header_load (CamelFolderSummary *summary, FILE *in)
@@ -169,6 +212,20 @@
 	return 0;
 }
 
+static CamelFIRecord *
+summary_header_to_db (CamelFolderSummary *s, CamelException *ex)
+{
+	CamelExchangeSummary *exchange = (CamelExchangeSummary *) s;
+	struct _CamelFIRecord *fir;
+	
+	fir = CAMEL_FOLDER_SUMMARY_CLASS(parent_class)->summary_header_to_db (s, ex);
+	if (!fir)
+		return NULL;
+	fir->bdata = g_strdup_printf ("%u %u %u", exchange->version, exchange->readonly, exchange->high_article_num);
+
+	return fir;
+}
+
 static int
 header_save (CamelFolderSummary *summary, FILE *out)
 {
@@ -190,6 +247,23 @@
 
 	return 0;
 }
+static CamelMessageInfo *
+message_info_from_db (CamelFolderSummary *s, CamelMIRecord *mir)
+{
+	CamelMessageInfo *info;
+	CamelExchangeMessageInfo *einfo;
+
+	info = CAMEL_FOLDER_SUMMARY_CLASS(parent_class)->message_info_from_db (s, mir);
+	if (info) {
+		char *part = g_strdup (mir->bdata);
+		int len;
+		einfo = (CamelExchangeMessageInfo *)info;
+		EXTRACT_FIRST_STRING (einfo->thread_index)
+		EXTRACT_FIRST_STRING (einfo->href)	
+	}
+
+	return info;
+}
 
 static CamelMessageInfo *
 message_info_load (CamelFolderSummary *summary, FILE *in)
@@ -228,6 +302,19 @@
 	return NULL;
 }
 
+static CamelMIRecord *
+message_info_to_db (CamelFolderSummary *s, CamelMessageInfo *info)
+{
+	CamelExchangeMessageInfo *einfo = (CamelExchangeMessageInfo *)info;
+	struct _CamelMIRecord *mir;
+
+	mir = CAMEL_FOLDER_SUMMARY_CLASS(parent_class)->message_info_to_db (s, info);
+	if (mir) 
+		mir->bdata = g_strdup_printf ("%d-%s %d-%s", einfo->thread_index ? strlen(einfo->thread_index):0 , einfo->thread_index ? einfo->thread_index : "", einfo->href ? strlen(einfo->href):0, einfo->href ? einfo->href:"");
+
+	return mir;
+}
+
 static int
 message_info_save (CamelFolderSummary *summary, FILE *out, CamelMessageInfo *info)
 {



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