evolution-data-server r9934 - branches/gnome-2-24/camel/providers/groupwise



Author: psankar
Date: Thu Jan 15 12:13:37 2009
New Revision: 9934
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9934&view=rev

Log:
2009-01-15  Sankar P  <psankar novell com>

	* camel-groupwise-folder.c (groupwise_sync),
	(groupwise_refresh_folder), (groupwise_transfer_messages_to):
	* camel-groupwise-journal.h:
	* camel-groupwise-summary.c (gw_info_set_flags):
	* camel-groupwise-summary.h:
	Manage GroupWise counts better. fix bugs in read-cursor elimination.
	A brand new flags handling code for GroupWise provider.




Modified:
   branches/gnome-2-24/camel/providers/groupwise/ChangeLog
   branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-folder.c
   branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-journal.h
   branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-summary.c
   branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-summary.h

Modified: branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-folder.c
==============================================================================
--- branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-folder.c	(original)
+++ branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-folder.c	Thu Jan 15 12:13:37 2009
@@ -667,6 +667,11 @@
 			continue;
 		flags = camel_message_info_flags (info);	
 
+		if (!(flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) {
+				camel_message_info_free(info);
+				continue;
+		}
+
 		if ((flags & CAMEL_MESSAGE_JUNK) && strcmp(camel_folder_get_name(folder), JUNK_FOLDER)) { 
 			/*marked a message junk*/
 			move_to_junk (folder, info, ex);
@@ -1065,6 +1070,7 @@
 	char *time_string = NULL, *t_str = NULL;
 	struct _folder_update_msg *msg;
 	gboolean check_all = FALSE;
+	int new_items = 0;
 
 	/* Sync-up the (un)read changes before getting updates,
 	so that the getFolderList will reflect the most recent changes too */
@@ -1159,7 +1165,7 @@
 		   for ( sl = slist ; sl != NULL; sl = sl->next) 
 		   list = g_list_append (list, sl->data);*/
 
-		if (slist && g_slist_length(slist) != 0)
+		if (slist && (new_items = g_slist_length(slist)) != 0)
 			check_all = TRUE;
 
 		g_slist_free (slist);
@@ -1203,16 +1209,28 @@
 		
 		if (check_all && !is_proxy) {
 				EGwContainer *container;
-				container = e_gw_connection_get_container (cnc, container_id);
+				int i=0;
 
-				d(printf ("Evolution's folder summary length is : %u\tserver has %u items",
-										camel_folder_summary_count (folder->summary), e_gw_container_get_total_count (container)));
+				do {
+						/* HACK: Refer to Novell bugzilla bug #464379 */ 
+						container = e_gw_connection_get_container (cnc, container_id);
+						++i;
+						if (!strcmp (folder->full_name, e_gw_container_get_name (container))) 
+								i = 10;
+				} while (i < 2);
+
+				if (i == 10) {
+						/* HACK: Refer to Novell bugzilla bug #464379 */ 
+						d(printf ("Evolution's folder summary length is : %u\tserver has %u items",
+												camel_folder_summary_count (folder->summary), e_gw_container_get_total_count (container)));
 
-				if (camel_folder_summary_count (folder->summary) == e_gw_container_get_total_count (container))
-						check_all = FALSE;
+						if ((camel_folder_summary_count (folder->summary) + new_items) == e_gw_container_get_total_count (container))
+								check_all = FALSE;
 
-				folder->summary->unread_count = e_gw_container_get_unread_count (container);
-				folder->summary->visible_count = e_gw_container_get_total_count (container);
+						folder->summary->unread_count = e_gw_container_get_unread_count (container);
+						folder->summary->visible_count = e_gw_container_get_total_count (container);
+				} else
+					check_all = FALSE;
 				g_object_unref (container);
 		}
 
@@ -2303,6 +2321,7 @@
 			}
 		}
 
+
 		if (destination_is_trash) {
 				e_gw_connection_remove_item (cnc, source_container_id, (const char*) uids->pdata[index]);
 				camel_folder_summary_remove_uid (source->summary, uids->pdata[index]);
@@ -2329,6 +2348,10 @@
 								/*if ( !strcmp(source->full_name, SENT) ) {
 								  camel_folder_delete_message(source, uids->pdata[index]);
 								  } else {*/
+
+								if (!(gw_info->info.flags & CAMEL_MESSAGE_SEEN))
+										source->summary->unread_count --;
+
 								camel_folder_summary_remove_uid (source->summary, uids->pdata[index]);
 								camel_folder_change_info_remove_uid (changes, uids->pdata[index]);
 								//}

Modified: branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-journal.h
==============================================================================
--- branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-journal.h	(original)
+++ branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-journal.h	Thu Jan 15 12:13:37 2009
@@ -54,7 +54,7 @@
 struct _CamelGroupwiseJournalEntry {
 	CamelDListNode node;
 	
-	int type;
+	guint32 type;
 
 	char *uid;
 	char *original_uid;

Modified: branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-summary.c
==============================================================================
--- branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-summary.c	(original)
+++ branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-summary.c	Thu Jan 15 12:13:37 2009
@@ -47,6 +47,8 @@
 #define EXTRACT_FIRST_DIGIT(val) part ? val=strtoul (part, &part, 10) : 0;
 #define EXTRACT_DIGIT(val) part++; part ? val=strtoul (part, &part, 10) : 0;
 
+#define d(x) 
+
 /*Prototypes*/
 static int gw_summary_header_load (CamelFolderSummary *, FILE *);
 static int gw_summary_header_save (CamelFolderSummary *, FILE *);
@@ -362,70 +364,66 @@
 static gboolean
 gw_info_set_flags (CamelMessageInfo *info, guint32 flags, guint32 set)
 {
-	guint32 old;
-	CamelMessageInfoBase *mi = (CamelMessageInfoBase *)info;
+		guint32 old;
+		CamelMessageInfoBase *mi = (CamelMessageInfoBase *)info;
+		int read = 0 , deleted = 0;
 
-	/* TODO: locking? */
+		int junk_flag = 0, junk_learn_flag = 0;
 
-	old = mi->flags;
-	/* we don't set flags which aren't appropriate for the folder*/
-	if ((set == (CAMEL_MESSAGE_JUNK|CAMEL_MESSAGE_JUNK_LEARN|CAMEL_MESSAGE_SEEN)) && (old & CAMEL_GW_MESSAGE_JUNK))
-		return FALSE;
-	
-	mi->flags = (old & ~flags) | (set & flags);
-	if (old != mi->flags) {
-		mi->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED;
-
-		if (mi->summary) {
-
-				if ((set & CAMEL_MESSAGE_SEEN) && !(old & CAMEL_MESSAGE_SEEN)) {
-						mi->summary->unread_count -- ;
-				} else if ( (!(set & CAMEL_MESSAGE_SEEN)) && (old & CAMEL_MESSAGE_SEEN) ) {
-						mi->summary->unread_count ++ ;
-				}
+		/* TODO: locking? */
 
-				if ((flags & CAMEL_MESSAGE_DELETED) && !(old & CAMEL_MESSAGE_DELETED)) {
-						mi->summary->deleted_count ++ ;
+		if (flags & CAMEL_MESSAGE_SEEN && ((set & CAMEL_MESSAGE_SEEN) != (mi->flags & CAMEL_MESSAGE_SEEN)))
+		{ read = set & CAMEL_MESSAGE_SEEN ? 1 : -1; d(printf("Setting read as %d\n", set & CAMEL_MESSAGE_SEEN ? 1 : 0));}
 
-						#warning "What to do when the user has set to show-deleted-messages "
-						mi->summary->visible_count -- ;
+		if (flags & CAMEL_MESSAGE_DELETED && ((set & CAMEL_MESSAGE_DELETED) != (mi->flags & CAMEL_MESSAGE_DELETED)))
+		{ deleted = set & CAMEL_MESSAGE_DELETED ? 1 : -1; d(printf("Setting deleted as %d\n", set & CAMEL_MESSAGE_DELETED ? 1 : 0));}
 
-						if (!(flags & CAMEL_MESSAGE_SEEN))
-							mi->summary->unread_count -- ;
-				}
+		old = mi->flags;
+		mi->flags = (old & ~flags) | (set & flags);
 
+		if (old != mi->flags) {
+				mi->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED;
 				mi->dirty = TRUE;
-				camel_folder_summary_touch(mi->summary);
+
+				if (((old & ~CAMEL_MESSAGE_SYSTEM_MASK) == (mi->flags & ~CAMEL_MESSAGE_SYSTEM_MASK)) )
+						return FALSE;
+
+				if (mi->summary) {
+						mi->summary->deleted_count += deleted;
+						mi->summary->unread_count -= read;
+						camel_folder_summary_touch(mi->summary);
+				}
 		}
-	}
-	/* This is a hack, we are using CAMEL_MESSAGE_JUNK justo to hide the item
-	 * we make sure this doesn't have any side effects*/
-	
-	if ((set == CAMEL_MESSAGE_JUNK_LEARN) && (old & CAMEL_GW_MESSAGE_JUNK)) {
-		mi->flags |= CAMEL_GW_MESSAGE_NOJUNK | CAMEL_MESSAGE_JUNK;
 
-		/* This has ugly side-effects. Evo will never learn unjunk. 
+		junk_flag = ((flags & CAMEL_MESSAGE_JUNK) && (set & CAMEL_MESSAGE_JUNK));
+		junk_learn_flag = ((flags & CAMEL_MESSAGE_JUNK_LEARN) && (set & CAMEL_MESSAGE_JUNK_LEARN));
 
-		   We need to create one CAMEL_MESSAGE_HIDDEN flag which must be used for all hiding operations. We must also get rid of the seperate file that is maintained somewhere in evolution/mail/em-folder-browser.c for hidden messages
-		 */
+		/* This is a hack, we are using CAMEL_MESSAGE_JUNK justo to hide the item
+		 * we make sure this doesn't have any side effects*/
 
-		if (mi->summary) {
-			camel_folder_summary_touch(mi->summary);
+		if (junk_learn_flag && !junk_flag  && (old & CAMEL_GW_MESSAGE_JUNK)) {
+				/* 
+				   This has ugly side-effects. Evo will never learn unjunk. 
+				   We need to create one CAMEL_MESSAGE_HIDDEN flag which must be
+				   used for all hiding operations. We must also get rid of the seperate file 
+				   that is maintained somewhere in evolution/mail/em-folder-browser.c for hidden messages
+				 */
+				mi->flags |= CAMEL_GW_MESSAGE_NOJUNK | CAMEL_MESSAGE_JUNK | CAMEL_MESSAGE_JUNK_LEARN;
+		} else if (junk_learn_flag && junk_flag && !(old & CAMEL_GW_MESSAGE_JUNK)) {
+				mi->flags |= CAMEL_GW_MESSAGE_JUNK | CAMEL_MESSAGE_JUNK | CAMEL_MESSAGE_JUNK_LEARN;
 		}
 
-	} else	if ((old & ~CAMEL_MESSAGE_SYSTEM_MASK) == (mi->flags & ~CAMEL_MESSAGE_SYSTEM_MASK)) 
-		return FALSE;
 
-	if (mi->summary && mi->summary->folder && mi->uid) {
-		CamelFolderChangeInfo *changes = camel_folder_change_info_new();
+		if (mi->summary && mi->summary->folder && mi->uid) {
+				CamelFolderChangeInfo *changes = camel_folder_change_info_new();
 
-		camel_folder_change_info_change_uid(changes, camel_message_info_uid(info));
-		camel_object_trigger_event(mi->summary->folder, "folder_changed", changes);
-		camel_folder_change_info_free(changes);
-	}
-
-	return TRUE;
+				camel_folder_change_info_change_uid(changes, camel_message_info_uid(info));
+				camel_object_trigger_event(mi->summary->folder, "folder_changed", changes);
+				camel_folder_change_info_free(changes);
+				camel_folder_summary_touch(mi->summary);
+		}
 
+		return TRUE;
 }
 
 

Modified: branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-summary.h
==============================================================================
--- branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-summary.h	(original)
+++ branches/gnome-2-24/camel/providers/groupwise/camel-groupwise-summary.h	Thu Jan 15 12:13:37 2009
@@ -56,11 +56,11 @@
 
 
 struct _CamelGroupwiseSummary {
-	CamelFolderSummary parent ;
+	CamelFolderSummary parent;
 
 	char *time_string;
-	guint32 version ;
-	guint32 validity ;
+	gint32 version;
+	gint32 validity;
 } ;
 
 



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