File bnc-152062-evolution-wont-show-attachment.patch of Package evolution-data-server

Index: camel/providers/groupwise/camel-groupwise-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/camel-groupwise-folder.c,v
retrieving revision 1.119
diff -u -p -r1.119 camel-groupwise-folder.c
--- camel/providers/groupwise/camel-groupwise-folder.c	15 Mar 2006 08:45:26 -0000	1.119
+++ camel/providers/groupwise/camel-groupwise-folder.c	16 Mar 2006 11:29:35 -0000
@@ -49,6 +49,8 @@
 #include <e-gw-connection.h>
 #include <e-gw-item.h>
 
+#include <libsoup/soup-misc.h>
+
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -58,6 +60,7 @@
 #define REMOVE_JUNK_ENTRY -1
 #define JUNK_FOLDER "Junk Mail"
 #define READ_CURSOR_MAX_IDS 500
+#define MAX_ATTACHMENT_SIZE 1*1024*1024   /*In bytes*/
 
 static CamelOfflineFolderClass *parent_class = NULL;
 
@@ -1455,7 +1458,7 @@ groupwise_folder_item_to_msg( CamelFolde
 	const char *uid = NULL;
 	gboolean is_text_html = FALSE;
 	gboolean is_text_html_embed = FALSE;
-	
+	gboolean is_base64_encoded = FALSE;
 
 	uid = e_gw_item_get_id(item);
 	cnc = cnc_lookup (priv);
@@ -1541,6 +1544,7 @@ groupwise_folder_item_to_msg( CamelFolde
 			int len = 0;
 			CamelMimePart *part;
 			EGwItem *temp_item;
+			is_base64_encoded = FALSE;
 
 			if (attach->contentid && (is_text_html_embed != TRUE))
 				is_text_html_embed = TRUE;
@@ -1568,9 +1572,36 @@ groupwise_folder_item_to_msg( CamelFolde
 				}
 				g_object_unref (temp_item);
 			} else {
-				status = e_gw_connection_get_attachment (cnc, 
-						attach->id, 0, -1, 
-						(const char **)&attachment, &len);
+				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;
+					char *t_attach = NULL;
+					GString *gstr = g_string_new (NULL);
+					
+					count = (attach->size)/(1024*1024);
+					count++;
+					len = 0;
+					for (i = 0; i<count; i++) {
+						status = e_gw_connection_get_attachment_base64 (cnc, 
+								attach->id, t_offset, MAX_ATTACHMENT_SIZE, 
+								(const char **)&t_attach, &t_len, &offset);
+						if (status == E_GW_CONNECTION_STATUS_OK) {
+							gstr = g_string_append (gstr, t_attach);
+							t_offset = offset;
+							g_free (t_attach);
+							t_attach = NULL;
+							t_len = 0;
+						}
+					}
+					attachment = soup_base64_decode (gstr->str, &len);
+					g_string_free (gstr, TRUE);
+					is_base64_encoded = FALSE;
+				} else {
+					status = e_gw_connection_get_attachment (cnc, 
+							attach->id, 0, -1, 
+							(const char **)&attachment, &len);
+				}
 				if (status != E_GW_CONNECTION_STATUS_OK) {
 					g_warning ("Could not get attachment\n");
 					continue;
@@ -1613,6 +1644,8 @@ groupwise_folder_item_to_msg( CamelFolde
 
 					//camel_mime_part_set_filename(part, g_strdup(attach->name));
 					if (attach->contentType) {
+						if (is_base64_encoded)
+							camel_mime_part_set_encoding (part, CAMEL_TRANSFER_ENCODING_BASE64);
 						camel_mime_part_set_content(part, attachment, len, attach->contentType);
 						camel_content_type_set_param (((CamelDataWrapper *) part)->mime_type, "name", attach->name);
 					} else 
@@ -1872,15 +1905,16 @@ groupwise_transfer_messages_to (CamelFol
 		if (status == E_GW_CONNECTION_STATUS_OK) {
 			if (delete_originals) 
 				camel_folder_delete_message(source, uids->pdata[index]);
-			/* Refresh the destination folder, if its not refreshed already */
-			if (gw_store->current_folder != destination || 
-				camel_folder_summary_count (destination->summary) == count)
-				camel_folder_refresh_info (destination, ex);
 		} else {
 			g_warning ("Warning!! Could not move item : %s\n", (char *)uids->pdata[index]);
 		}
 		index ++;
 	}
+	/* Refresh the destination folder, if its not refreshed already */
+	if (gw_store->current_folder != destination || 
+			camel_folder_summary_count (destination->summary) == count)
+		camel_folder_refresh_info (destination, ex);
+
 	camel_folder_summary_touch (source->summary);
 	camel_folder_summary_touch (destination->summary);
 
Index: servers/groupwise/e-gw-connection.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-connection.c,v
retrieving revision 1.139
diff -u -p -r1.139 e-gw-connection.c
--- servers/groupwise/e-gw-connection.c	15 Mar 2006 06:08:24 -0000	1.139
+++ servers/groupwise/e-gw-connection.c	17 Mar 2006 05:22:38 -0000
@@ -148,6 +148,7 @@ e_gw_connection_parse_response_status (S
 	case 53530: return E_GW_CONNECTION_STATUS_OTHER;
 	/* FIXME: 58652 should be changed with an enum.*/
 	case 58652: return 58652;
+	case 59922: return 59922; /*Very big attachment, get in chunks*/
 		/* FIXME: map all error codes */
 	}
 
@@ -2571,6 +2572,75 @@ e_gw_connection_get_attachment (EGwConne
         return E_GW_CONNECTION_STATUS_OK;
 }
 
+/*
+ * 
+ */
+EGwConnectionStatus
+e_gw_connection_get_attachment_base64 (EGwConnection *cnc, const char *id, int offset, int length, const char **attachment, int *attach_length, int *offset_r)
+{
+
+	SoupSoapMessage *msg;
+        SoupSoapResponse *response;
+        EGwConnectionStatus status;
+	SoupSoapParameter *param ;
+	char *buffer = NULL, *buf_length = NULL, *o_return = NULL;
+
+        g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
+
+	/* build the SOAP message */
+        msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getAttachmentRequest");
+        if (!msg) {
+                g_warning (G_STRLOC ": Could not build SOAP message");
+                return E_GW_CONNECTION_STATUS_UNKNOWN;
+        }
+      
+
+	e_gw_message_write_string_parameter (msg, "id", NULL, id);
+	e_gw_message_write_int_parameter (msg, "offset", NULL, offset);
+	e_gw_message_write_int_parameter (msg, "length", NULL, length);
+
+	e_gw_message_write_footer (msg);
+
+        /* send message to server */
+        response = e_gw_connection_send_message (cnc, msg);
+        if (!response) {
+                g_object_unref (msg);
+                return E_GW_CONNECTION_STATUS_NO_RESPONSE;
+        }
+
+        status = e_gw_connection_parse_response_status (response);
+        if (status != E_GW_CONNECTION_STATUS_OK) {
+		if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+			reauthenticate (cnc);
+		g_object_unref (response);
+                g_object_unref (msg);
+		return status;
+	}
+
+	
+	param = soup_soap_response_get_first_parameter_by_name (response, "part") ;
+	if (param) {
+		buf_length =  soup_soap_parameter_get_property (param, "length") ;
+		o_return =  soup_soap_parameter_get_property (param, "offset") ;
+		buffer = soup_soap_parameter_get_string_value (param) ;
+	}
+        
+	if (buffer && buf_length) {
+		int len = atoi (buf_length) ;
+		*attachment = g_strdup (buffer);
+		*attach_length = len;
+		*offset_r = atoi (o_return);
+	}
+
+	/* free memory */
+	g_free (buffer) ;
+	g_free (buf_length) ;
+	g_free (o_return);
+        g_object_unref (response);
+	g_object_unref (msg);
+
+        return E_GW_CONNECTION_STATUS_OK;
+}
 
 EGwConnectionStatus
 e_gw_connection_add_item (EGwConnection *cnc, const char *container, const char *id)
Index: servers/groupwise/e-gw-connection.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-connection.h,v
retrieving revision 1.68
diff -u -p -r1.68 e-gw-connection.h
--- servers/groupwise/e-gw-connection.h	31 Aug 2005 04:26:07 -0000	1.68
+++ servers/groupwise/e-gw-connection.h	17 Mar 2006 05:22:38 -0000
@@ -144,6 +144,7 @@ EGwConnectionStatus e_gw_connection_get_
 EGwConnectionStatus e_gw_connection_create_folder(EGwConnection *cnc, const char *parent_name,const char *folder_name, char **container_id) ;
 EGwConnectionStatus
 e_gw_connection_get_attachment (EGwConnection *cnc, const char *id, int offset, int length, const char **attachment, int *attach_length) ;
+EGwConnectionStatus e_gw_connection_get_attachment_base64 (EGwConnection *cnc, const char *id, int offset, int length, const char **attachment, int *attach_length, int *offset_r);
 EGwConnectionStatus e_gw_connection_add_item (EGwConnection *cnc, const char *container, const char *id) ;
 EGwConnectionStatus e_gw_connection_add_items (EGwConnection *cnc, const char *container, GList *item_ids) ;
 EGwConnectionStatus e_gw_connection_move_item (EGwConnection *cnc, const char *id, const char *dest_container_id, const char *from_container_id);
openSUSE Build Service is sponsored by