[evolution-data-server/gnome-2-28] Bug 549221 (bnc) - delete, sync flags immediately.



commit 9d9727001e3b59075ef578f470ccaa746e42a798
Author: Chenthill Palanisamy <pchenthill novell com>
Date:   Tue Nov 24 20:34:36 2009 +0530

    Bug 549221 (bnc) - delete, sync flags immediately.

 camel/providers/groupwise/camel-groupwise-folder.c |   54 ++++++++++++++++++--
 1 files changed, 50 insertions(+), 4 deletions(-)
---
diff --git a/camel/providers/groupwise/camel-groupwise-folder.c b/camel/providers/groupwise/camel-groupwise-folder.c
index 2e60f71..5ed62e4 100644
--- a/camel/providers/groupwise/camel-groupwise-folder.c
+++ b/camel/providers/groupwise/camel-groupwise-folder.c
@@ -99,6 +99,7 @@ static CamelMimeMessage *groupwise_folder_item_to_msg ( CamelFolder *folder, EGw
 static gchar * groupwise_get_filename (CamelFolder *folder, const gchar *uid, CamelException *ex);
 static const gchar *get_from_from_org (EGwItemOrganizer *org);
 static void groupwise_refresh_folder(CamelFolder *folder, CamelException *ex);
+static void groupwise_sync (CamelFolder *folder, gboolean expunge, CamelMessageInfo *update_single, CamelException *ex);
 
 #define d(x)
 
@@ -688,9 +689,45 @@ sync_flags (CamelFolder *folder, GList *uids)
 	}
 }
 
+
+static gboolean
+groupwise_set_message_flags (CamelFolder *folder, const gchar *uid, guint32 flags, guint32 set)
+{
+	CamelMessageInfo *info;
+	gint res;
+	const gchar *sync_immediately;
+	
+	g_return_val_if_fail (folder->summary != NULL, FALSE);
+	
+	info = camel_folder_summary_uid (folder->summary, uid);
+	if (info == NULL)
+		return FALSE;
+
+	res = camel_message_info_set_flags (info, flags, set);
+
+	sync_immediately = g_getenv ("GW_SYNC_IMMEDIATE");
+	
+	if (sync_immediately) {
+		CamelException ex;
+		
+		camel_exception_init (&ex);
+		groupwise_sync (folder, FALSE, info, &ex); 
+		camel_exception_clear (&ex);
+	}
+
+	camel_message_info_free (info);
+	return res;
+}
+
+static void
+groupwise_sync_all (CamelFolder *folder, gboolean expunge, CamelException *ex)
+{
+	groupwise_sync (folder, expunge, NULL, ex);	
+}
+
 /* This may need to be reorganized. */
 static void
-groupwise_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
+groupwise_sync (CamelFolder *folder, gboolean expunge, CamelMessageInfo *update_single, CamelException *ex)
 {
 	CamelGroupwiseStore *gw_store = CAMEL_GROUPWISE_STORE (folder->parent_store);
 	CamelGroupwiseFolder *gw_folder = CAMEL_GROUPWISE_FOLDER (folder);
@@ -732,7 +769,14 @@ groupwise_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
 	CAMEL_GROUPWISE_FOLDER_REC_LOCK (folder, cache_lock);
 	for (i=0; i < count; i++) {
 		guint32 flags = 0;
-		info = camel_folder_summary_index (folder->summary, i);
+		
+		if (update_single != NULL) {
+			info = update_single;
+			camel_message_info_ref (info);
+			count = 1;
+		} else
+			info = camel_folder_summary_index (folder->summary, i);
+
 		gw_info = (CamelGroupwiseMessageInfo *) info;
 
 		/**Junk Mail handling**/
@@ -837,6 +881,7 @@ groupwise_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
 				}
 			}
 		}
+		
 		camel_message_info_free (info);
 	}
 
@@ -1252,7 +1297,7 @@ groupwise_refresh_folder(CamelFolder *folder, CamelException *ex)
 
 	/* Sync-up the (un)read changes before getting updates,
 	so that the getFolderList will reflect the most recent changes too */
-	/*groupwise_sync (folder, FALSE, ex);*/
+	groupwise_sync_all (folder, FALSE, ex);
 
 	if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
 		g_warning ("In offline mode. Cannot refresh!!!\n");
@@ -2724,7 +2769,8 @@ camel_groupwise_folder_class_init (CamelGroupwiseFolderClass *camel_groupwise_fo
 	camel_folder_class->search_free = groupwise_folder_search_free;
 	camel_folder_class->append_message = groupwise_append_message;
 	camel_folder_class->refresh_info = groupwise_refresh_info;
-	camel_folder_class->sync = groupwise_sync;
+	camel_folder_class->sync = groupwise_sync_all;
+	camel_folder_class->set_message_flags = groupwise_set_message_flags;
 	camel_folder_class->expunge = groupwise_expunge;
 	camel_folder_class->transfer_messages_to = groupwise_transfer_messages_to;
 	camel_folder_class->get_filename = groupwise_get_filename;



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