evolution-data-server r9219 - in trunk/camel: . providers/local



Author: sragavan
Date: Tue Jul 29 06:42:37 2008
New Revision: 9219
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=9219&view=rev

Log:
2008-07-29  Srinivasa Ragavan  <sragavan novell com>

	** Fix for bug #545099

	* camel/camel-folder-summary.c: When new mails added, update the
	summary.
2008-07-29  Srinivasa Ragavan  <sragavan novell com>

	** Fix for bug #545099

	* camel/providers/local/camel-local-summary.c: Improve flag sync. Make
	it work for append mails


Modified:
   trunk/camel/ChangeLog
   trunk/camel/camel-folder-summary.c
   trunk/camel/providers/local/ChangeLog
   trunk/camel/providers/local/camel-local-summary.c

Modified: trunk/camel/camel-folder-summary.c
==============================================================================
--- trunk/camel/camel-folder-summary.c	(original)
+++ trunk/camel/camel-folder-summary.c	Tue Jul 29 06:42:37 2008
@@ -1602,6 +1602,43 @@
 }
 
 
+static void
+update_summary (CamelFolderSummary *summary, CamelMessageInfoBase *info)
+{
+	int unread=0, deleted=0, junk=0;
+	guint32 flags = info->flags;
+
+	if (!(flags & CAMEL_MESSAGE_SEEN))
+		unread = 1;
+	
+	if (flags & CAMEL_MESSAGE_DELETED)
+		deleted = 1;
+
+	if (flags & CAMEL_MESSAGE_JUNK)
+		junk = 1;
+	
+	info->flags |= CAMEL_MESSAGE_FOLDER_FLAGGED;
+	info->dirty = TRUE;
+
+	if (summary) {
+
+		if (unread)
+			summary->unread_count += unread;
+		if (deleted)
+			summary->deleted_count += deleted;
+		if (junk)
+			summary->junk_count += junk;
+		if (junk && !deleted)
+			summary->junk_not_deleted_count += junk;
+		summary->visible_count++;
+		if (junk ||  deleted) 
+			summary->visible_count -= junk ? junk : deleted;
+
+		summary->saved_count++;
+		camel_folder_summary_touch(summary);
+	}
+}
+
 /**
  * camel_folder_summary_add_from_header:
  * @summary: a #CamelFolderSummary object
@@ -1621,7 +1658,7 @@
 	CamelMessageInfo *info = camel_folder_summary_info_new_from_header(s, h);
 
 	camel_folder_summary_add (s, info);
-
+	update_summary (s, (CamelMessageInfoBase *) info);
 	return info;
 }
 
@@ -1650,7 +1687,7 @@
 	info = camel_folder_summary_info_new_from_parser(s, mp);
 
 	camel_folder_summary_add (s, info);
-
+	update_summary (s, (CamelMessageInfoBase *) info);
 	return info;
 }
 
@@ -1670,7 +1707,7 @@
 	CamelMessageInfo *info = camel_folder_summary_info_new_from_message(s, msg);
 
 	camel_folder_summary_add (s, info);
-
+	update_summary (s, (CamelMessageInfoBase *) info);
 	return info;
 }
 

Modified: trunk/camel/providers/local/camel-local-summary.c
==============================================================================
--- trunk/camel/providers/local/camel-local-summary.c	(original)
+++ trunk/camel/providers/local/camel-local-summary.c	Tue Jul 29 06:42:37 2008
@@ -421,10 +421,45 @@
 	return ret;
 }
 
+static void
+update_summary (CamelFolderSummary *summary, CamelMessageInfoBase *info, CamelMessageInfoBase *old)
+{
+	int unread=0, deleted=0, junk=0;
+	guint32 flags = info->flags;
+	guint32 oldflags = old->flags;
+
+	if ((flags & CAMEL_MESSAGE_SEEN) != (oldflags & CAMEL_MESSAGE_SEEN))
+		unread = (oldflags & CAMEL_MESSAGE_SEEN) ? 1 : -1;
+	
+	if ((flags & CAMEL_MESSAGE_DELETED) != (oldflags & CAMEL_MESSAGE_DELETED))
+		deleted = (oldflags & CAMEL_MESSAGE_DELETED) ? 1 : -1;
+
+	if ((flags & CAMEL_MESSAGE_JUNK) != (oldflags & CAMEL_MESSAGE_JUNK))
+		junk = (oldflags & CAMEL_MESSAGE_JUNK) ? 1 : -1;
+	
+	/* Things would already be flagged */
+	
+	if (summary) {
+		
+		if (unread)
+			summary->unread_count -= unread;
+		if (deleted)
+			summary->deleted_count += deleted;
+		if (junk)
+			summary->junk_count += junk;
+		if (junk && !deleted)
+			summary->junk_not_deleted_count += junk;
+		if (junk ||  deleted) 
+			summary->visible_count -= junk ? junk : deleted;
+	}
+
+}
+
 static CamelMessageInfo *
 local_summary_add(CamelLocalSummary *cls, CamelMimeMessage *msg, const CamelMessageInfo *info, CamelFolderChangeInfo *ci, CamelException *ex)
 {
 	CamelLocalMessageInfo *mi;
+	CamelFolderSummary *s = (CamelFolderSummary *)cls;
 	char *xev;
 
 	d(printf("Adding message to summary\n"));
@@ -445,7 +480,8 @@
 				camel_message_info_set_user_tag((CamelMessageInfo *)mi, tag->name, tag->value);
 				tag = tag->next;
 			}
-
+			
+			update_summary (s, (CamelMessageInfoBase *) mi, (CamelMessageInfoBase *) info);
 			mi->info.flags |= (camel_message_info_flags(info) & 0xffff);
 			mi->info.size = camel_message_info_size(info);
 		}



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