File camel-partha-gw-fixes.patch of Package evolution-data-server

diff -Nrup camel/providers/groupwise/camel-groupwise-folder.c /root/varadhan/2.5/mar-23/head/evolution-data-server-1.5.92/camel/providers/groupwise/camel-groupwise-folder.c
--- camel/providers/groupwise/camel-groupwise-folder.c	2006-03-23 14:08:09.734955209 +0100
+++ /root/varadhan/2.5/mar-23/head/evolution-data-server-1.5.92/camel/providers/groupwise/camel-groupwise-folder.c	2006-03-23 12:07:49.000000000 +0100
@@ -92,7 +92,7 @@ static void gw_update_cache ( CamelFolde
 static CamelMimeMessage *groupwise_folder_item_to_msg ( CamelFolder *folder, EGwItem *item, CamelException *ex );
 
 
-#define d(x) x
+#define d(x) 
 
 static CamelMimeMessage *
 groupwise_folder_get_message( CamelFolder *folder,
@@ -635,9 +635,10 @@ groupwise_sync (CamelFolder *folder, gbo
 			diff.changed &= folder->permanent_flags;
 
 			/* weed out flag changes that we can't sync to the server */
-			if (!diff.changed)
+			if (!diff.changed) {
 				camel_message_info_free(info);
-			else {
+				continue;
+			} else {
 				const char *uid = camel_message_info_uid (info);
 				if (diff.changed & CAMEL_MESSAGE_SEEN)
 					read_items = g_list_append (read_items, (char *)uid);
@@ -656,7 +657,6 @@ groupwise_sync (CamelFolder *folder, gbo
 			}
 		}
 		camel_message_info_free (info);
-		info = NULL;
 	}
 	CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
 
@@ -989,7 +989,6 @@ groupwise_refresh_folder(CamelFolder *fo
 	
 	/* The storing of time-stamp to summary code below should be commented if the 
 	   above commented code is uncommented */
-
 	if (summary->time_string)
 		g_free (summary->time_string);
 
@@ -1047,7 +1046,7 @@ end1:
 	return;
 }
 
-void
+static void
 gw_update_cache (CamelFolder *folder, GList *list, CamelException *ex, gboolean uid_flag) 
 {
 	CamelGroupwiseMessageInfo *mi = NULL;
@@ -1069,6 +1068,7 @@ gw_update_cache (CamelFolder *folder, GL
 	int total_items = g_list_length (item_list), i=0;
 	
 	/*Assert lock*/
+	CAMEL_SERVICE_ASSERT_LOCKED (gw_store, connect_lock);
 	changes = camel_folder_change_info_new ();
 	container_id = g_strdup (camel_groupwise_store_container_id_lookup (gw_store, folder->full_name));
 	if (!container_id) {
@@ -1092,8 +1092,9 @@ gw_update_cache (CamelFolder *folder, GL
 		const char *id;
 		GSList *recp_list = NULL;
 		status_flags = 0;
-		CamelStream *cache_stream;
+		CamelStream *cache_stream, *t_cache_stream;
 		CamelMimeMessage *mail_msg = NULL;
+		gboolean is_sent_folder = FALSE;
 
 		exists = FALSE;
 		
@@ -1118,11 +1119,7 @@ gw_update_cache (CamelFolder *folder, GL
 		if (pmi) {
 			exists = TRUE;
 			camel_message_info_ref (pmi);
-			mi = (CamelGroupwiseMessageInfo *)camel_message_info_clone(pmi);
-			/*
-			pmi->summary = folder->summary;
-			mi->info.summary = folder->summary;
-			*/
+			mi = (CamelGroupwiseMessageInfo *)pmi;
 		}
 
 		if (!exists) {
@@ -1146,9 +1143,15 @@ gw_update_cache (CamelFolder *folder, GL
 		item_status = e_gw_item_get_item_status (item);
 		if (item_status & E_GW_ITEM_STAT_READ)
 			status_flags |= CAMEL_MESSAGE_SEEN;
+		else 
+			mi->info.flags &= ~CAMEL_MESSAGE_SEEN;
+
 		if (item_status & E_GW_ITEM_STAT_REPLIED)
 			status_flags |= CAMEL_MESSAGE_ANSWERED;
-		mi->info.flags |= status_flags;
+		if (exists) 
+			mi->info.flags |= status_flags;
+		else 
+			mi->info.flags = status_flags;
 
 		priority = e_gw_item_get_priority (item);
 		if (priority && !(g_ascii_strcasecmp (priority,"High"))) {
@@ -1222,12 +1225,7 @@ gw_update_cache (CamelFolder *folder, GL
 				mi->info.date_sent = mi->info.date_received = actual_time;
 			}
 		}
-#if 0
-
-		if (exists)
-			g_free(mi->info.uid);
-		mi->info.uid = g_strdup(e_gw_item_get_id(item));
-#endif
+		
 		if (!exists) {
 			mi->info.uid = g_strdup (e_gw_item_get_id(item));
 			mi->info.size = e_gw_item_get_mail_size (item);	
@@ -1235,12 +1233,7 @@ gw_update_cache (CamelFolder *folder, GL
 		}
 		
 		if (exists) {
-			/*
 			camel_folder_change_info_change_uid (changes, mi->info.uid);
-			camel_message_info_free (&mi->info);*/
-			camel_folder_summary_remove(folder->summary, pmi);
-			camel_folder_summary_add (folder->summary,(CamelMessageInfo *)mi);
-			camel_folder_change_info_add_uid (changes, mi->info.uid);
 			camel_message_info_free (pmi);
 		} else {
 			camel_folder_summary_add (folder->summary,(CamelMessageInfo *)mi);
@@ -1253,13 +1246,17 @@ gw_update_cache (CamelFolder *folder, GL
 			continue;
 
 		if (!strcmp (folder->full_name, "Sent Items"))
-			exists = FALSE;
+			is_sent_folder = TRUE;
 		/******************** Begine Caching ************************/
 		/* add to cache if its a new message*/
-		if (!exists) {
+		t_cache_stream  = camel_data_cache_get (gw_folder->cache, "cache", id, ex);
+		if (t_cache_stream && !is_sent_folder) {
+			camel_object_unref (t_cache_stream);
+			
 			mail_msg = groupwise_folder_item_to_msg (folder, item, ex);
 			if (mail_msg)
 				camel_medium_set_header (CAMEL_MEDIUM (mail_msg), "X-Evolution-Source", groupwise_base_url_lookup (priv));
+
 			CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
 			if ((cache_stream = camel_data_cache_add (gw_folder->cache, "cache", id, NULL))) {
 				if (camel_data_wrapper_write_to_stream ((CamelDataWrapper *) mail_msg, 	cache_stream) == -1 || camel_stream_flush (cache_stream) == -1)
@@ -1579,7 +1576,6 @@ groupwise_folder_item_to_msg( CamelFolde
 				}
 				g_object_unref (temp_item);
 			} else {
-				g_print ("%d:%d\n", attach->size, MAX_ATTACHMENT_SIZE);
 				if (attach->size > MAX_ATTACHMENT_SIZE) {
 					long count = 0;
 					int i, t_len=0, offset=0, t_offset=0;
@@ -1743,7 +1739,7 @@ groupwise_append_message (CamelFolder *f
 	CamelGroupwiseStorePrivate  *priv = gw_store->priv;
 	CamelOfflineStore *offline = (CamelOfflineStore *) folder->parent_store;
 	CamelAddress *recipients;
-	EGwConnectionStatus status = E_GW_CONNECTION_STATUS_OK;
+	EGwConnectionStatus status;
 	EGwConnection *cnc;
 	EGwItem *item;
 	char *id;
diff -Nrup camel/providers/groupwise/camel-groupwise-store.c /root/varadhan/2.5/mar-23/head/evolution-data-server-1.5.92/camel/providers/groupwise/camel-groupwise-store.c
--- camel/providers/groupwise/camel-groupwise-store.c	2006-03-23 14:08:09.722954807 +0100
+++ /root/varadhan/2.5/mar-23/head/evolution-data-server-1.5.92/camel/providers/groupwise/camel-groupwise-store.c	2006-03-23 10:26:40.000000000 +0100
@@ -461,16 +461,15 @@ groupwise_build_folder_info(CamelGroupwi
 		name = fi->full_name;
 	else
 		name++;
-	
-       if (!strcmp (folder_name, "Sent Items"))
-               fi->flags |= CAMEL_FOLDER_TYPE_SENT;
-       else if (!strcmp (folder_name, "Mailbox"))
-               fi->flags |= CAMEL_FOLDER_TYPE_INBOX;
-       else if (!strcmp (folder_name, "Trash"))
-               fi->flags |= CAMEL_FOLDER_TYPE_TRASH;
-       else if (!strcmp (folder_name, "Junk Mail"))
-               fi->flags |= CAMEL_FOLDER_TYPE_JUNK;
-
+	if (!strcmp (folder_name, "Sent Items"))
+		fi->flags |= CAMEL_FOLDER_TYPE_SENT;
+	else if (!strcmp (folder_name, "Mailbox"))
+		fi->flags |= CAMEL_FOLDER_TYPE_INBOX;
+	else if (!strcmp (folder_name, "Trash"))
+		fi->flags |= CAMEL_FOLDER_TYPE_TRASH;
+	else if (!strcmp (folder_name, "Junk Mail"))
+		fi->flags |= CAMEL_FOLDER_TYPE_JUNK;
+		
 	fi->name = g_strdup(name);
 	return fi;
 }
@@ -690,7 +689,7 @@ gw_store_reload_folder (CamelGroupwiseSt
 {
 	CamelGroupwiseStorePrivate *priv = gw_store->priv;
 	CamelGroupwiseSummary *summary;
-	char *container_id, *folder_dir, *storage_path;
+	char *container_id;
 	EGwConnectionStatus status;
 	GList *list = NULL;
 	gboolean done = FALSE;
@@ -751,11 +750,9 @@ gw_store_reload_folder (CamelGroupwiseSt
 			if (status != E_GW_CONNECTION_STATUS_OK) {
 				CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
 				e_gw_connection_destroy_cursor (priv->cnc, container_id, cursor);
-				camel_folder_summary_clear (folder->summary);
 				camel_folder_summary_save (folder->summary);
 				camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_INVALID, _("Authentication failed"));
 				camel_operation_end (NULL);
-				camel_object_unref (folder);
 				g_free (container_id);
 				return;
 			}
@@ -981,6 +978,10 @@ groupwise_folders_sync (CamelGroupwiseSt
 				info = NULL;
 			}
 		}
+		if (store->current_folder && strcmp (store->current_folder->full_name, info->full_name) == 0) {
+			g_print ("Syncing up %s\n", info->full_name);
+			CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS (store->current_folder))->sync(store->current_folder, FALSE, ex);
+		}
 	}
 	
 	g_free ((char *)url);
@@ -1153,7 +1154,8 @@ groupwise_get_folder_info (CamelStore *s
 	}
 
 	CAMEL_SERVICE_LOCK (store, connect_lock);
-	if ((groupwise_store->list_loaded == FALSE) && check_for_connection((CamelService *)store, ex)) {
+/*	if ((groupwise_store->list_loaded == FALSE) && check_for_connection((CamelService *)store, ex)) {*/
+	if (check_for_connection((CamelService *)store, ex)) {
 		if (!priv->cnc) {
 			if (groupwise_connect ((CamelService *)store, ex)) {
 				g_warning ("Could connect!!!\n");
@@ -1161,7 +1163,7 @@ groupwise_get_folder_info (CamelStore *s
 				g_warning ("Could not connect..failure connecting\n");
 		}
 		if (camel_groupwise_store_connected ((CamelGroupwiseStore *)store, ex)) {
-			groupwise_store->list_loaded = TRUE;
+			/*groupwise_store->list_loaded = TRUE;*/
 			groupwise_folders_sync (groupwise_store, ex);
 			if (camel_exception_is_set (ex)) {
 				CAMEL_SERVICE_UNLOCK (store, connect_lock);
@@ -1173,7 +1175,7 @@ groupwise_get_folder_info (CamelStore *s
 	}
 	CAMEL_SERVICE_UNLOCK (store, connect_lock);
 
-	//camel_exception_clear (ex);
+	/*camel_exception_clear (ex);*/
 	info = groupwise_get_folder_info_offline (store, top, flags, ex);
 	return info;
 }
diff -Nrup camel/providers/groupwise/camel-groupwise-utils.c /root/varadhan/2.5/mar-23/head/evolution-data-server-1.5.92/camel/providers/groupwise/camel-groupwise-utils.c
--- camel/providers/groupwise/camel-groupwise-utils.c	2006-03-23 14:08:09.702954138 +0100
+++ /root/varadhan/2.5/mar-23/head/evolution-data-server-1.5.92/camel/providers/groupwise/camel-groupwise-utils.c	2006-03-21 07:12:04.000000000 +0100
@@ -432,7 +432,7 @@ camel_groupwise_util_item_from_message (
 	} else {
 		/*only message*/
 		CamelStreamMem *content = (CamelStreamMem *)camel_stream_mem_new ();
-		CamelDataWrapper *dw = camel_data_wrapper_new ();
+		CamelDataWrapper *dw = NULL;
 		CamelContentType *type;
 		char *buffer = NULL;
 		char *content_type = NULL;
@@ -587,7 +587,7 @@ do_multipart (EGwConnection *cnc, EGwIte
 		CamelContentType *type;
 		CamelMimePart *part;
 		CamelStreamMem *content = (CamelStreamMem *)camel_stream_mem_new ();
-		CamelDataWrapper *dw = camel_data_wrapper_new ();
+		CamelDataWrapper *dw = NULL;
 		const char *disposition, *filename;
 		char *buffer = NULL;
 		char *mime_type = NULL;
@@ -611,7 +611,7 @@ do_multipart (EGwConnection *cnc, EGwIte
 			const char *cid = NULL;
 			CamelStreamMem *temp_content = (CamelStreamMem *)camel_stream_mem_new ();
 			temp_part = camel_multipart_get_part ((CamelMultipart *)dw, 1);
-			CamelDataWrapper *temp_dw = camel_data_wrapper_new ();
+			CamelDataWrapper *temp_dw = NULL;
 			if (temp_part) {
 				is_alternative = TRUE;
 				temp_dw = camel_medium_get_content_object (CAMEL_MEDIUM (temp_part));
@@ -628,8 +628,6 @@ do_multipart (EGwConnection *cnc, EGwIte
 				g_free (mime_type);
 			}
 			camel_object_unref (temp_content);
-			camel_object_unref (temp_dw);
-			camel_object_unref (dw);
 			continue;
 		} 
 		
@@ -653,6 +651,5 @@ do_multipart (EGwConnection *cnc, EGwIte
 		g_free (buffer);
 		g_free (mime_type);
 		camel_object_unref (content);
-		camel_object_unref (dw);
 	} /*end of for*/
 }
openSUSE Build Service is sponsored by