[evolution-patches] patch for attachment support in soap provider



Hi,
Attached patch provides support for attachments in soap mailer. 
This patch also has functions which parse the soap response for the
total count and unread count (of mails) for each mail folder.

cheers,
partha
Index: e-gw-item.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-item.c,v
retrieving revision 1.50
diff -u -r1.50 e-gw-item.c
--- e-gw-item.c	15 Dec 2004 08:55:15 -0000	1.50
+++ e-gw-item.c	3 Jan 2005 05:53:46 -0000
@@ -171,6 +171,8 @@
 			g_free (attach->contentType), attach->contentType = NULL ;
 		if (attach->date)
 			g_free (attach->date), attach->date = NULL ;
+		if (attach->data)
+			g_free (attach->data), attach->data = NULL ;
 	
 		g_free(attach) ;
 	}
@@ -2010,6 +2012,15 @@
 	return item->priv->organizer;
 }
 
+void
+e_gw_item_set_attach_id_list (EGwItem *item, GSList *attach_list)
+{
+	if (attach_list) {
+		g_slist_foreach (item->priv->attach_list, (GFunc)free_attach, NULL) ;
+		g_slist_free (item->priv->attach_list) ;
+	}
+	item->priv->attach_list = attach_list ;
+}
 GSList *
 e_gw_item_get_attach_id_list (EGwItem *item)
 {
@@ -2401,6 +2412,36 @@
 	soup_soap_message_end_element (msg);
 }
 
+static void
+add_attachment_to_soap_message(EGwItemAttachment *attachment, SoupSoapMessage *msg)
+{
+	char *size ;
+	soup_soap_message_start_element (msg, "attachment", NULL, NULL) ;
+
+	/*id*/
+	if (attachment->id)
+		e_gw_message_write_string_parameter (msg, "id", NULL, attachment->id) ;
+	else
+		e_gw_message_write_string_parameter (msg, "id", NULL, "") ;
+	/*name*/
+	e_gw_message_write_string_parameter (msg, "name", NULL, attachment->name) ;
+	/*content type*/
+	e_gw_message_write_string_parameter (msg, "contentType", NULL, attachment->contentType) ;
+	/*size*/
+	size = g_strdup_printf ("%d", attachment->size) ;
+	e_gw_message_write_string_parameter (msg, "size", NULL, size) ;
+	g_free (size) ;
+	/*date*/
+	if (attachment->date) 
+		e_gw_message_write_string_parameter (msg, "date", NULL, attachment->date) ;	
+	else
+		e_gw_message_write_string_parameter (msg, "date", NULL, "") ;	
+
+	/*data*/
+	e_gw_message_write_string_parameter (msg, "data", NULL, attachment->data) ;
+	
+	soup_soap_message_end_element (msg) ;
+}
 static void 
 e_gw_item_set_calendar_item_elements (EGwItem *item, SoupSoapMessage *msg)
 {
@@ -2480,6 +2521,7 @@
 {
 	EGwItemPrivate *priv;
 	char *alarm;
+	GSList *attach_list = NULL;
 
 	g_return_val_if_fail (E_IS_GW_ITEM (item), FALSE);
 	g_return_val_if_fail (SOUP_IS_SOAP_MESSAGE (msg), FALSE);
@@ -2507,20 +2549,29 @@
 			char *str ;
 			char *str_len ;
 
-			printf ("||||| MESSAGE |||||\n%s\n",priv->message) ;
 			str = soup_base64_encode (priv->message, strlen (priv->message));
 			str_len = g_strdup_printf ("%d", strlen (str));
 			soup_soap_message_add_attribute (msg, "length", str_len, NULL, NULL);
 			g_free (str_len);
 			soup_soap_message_write_string (msg, str);
-			printf ("||||| ENCODED MESSAGE|||||\n%s\n",str) ;
 			g_free (str);
 		} else {
 			soup_soap_message_add_attribute (msg, "length", "0", NULL, NULL);
 			soup_soap_message_write_string (msg, "");
 		}
-
 		soup_soap_message_end_element (msg);
+
+		/*attachments*/
+		soup_soap_message_start_element (msg, "attachments", NULL, NULL) ;
+		attach_list = e_gw_item_get_attach_id_list (item) ;
+		if (attach_list) {
+			GSList *al ;
+			for (al = attach_list ; al != NULL ;  al = al->next) {
+				EGwItemAttachment *attachment = (EGwItemAttachment *)al->data ;
+				add_attachment_to_soap_message (attachment, msg) ;
+			}
+		}
+		soup_soap_message_end_element (msg) ;
 
 		break;
 
Index: e-gw-item.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-item.h,v
retrieving revision 1.23
diff -u -r1.23 e-gw-item.h
--- e-gw-item.h	15 Dec 2004 08:55:15 -0000	1.23
+++ e-gw-item.h	3 Jan 2005 05:53:46 -0000
@@ -123,6 +123,7 @@
 	char *contentType ;
 	int size ;
 	char *date ;
+	char *data ;
 } EGwItemAttachment ;
 
 typedef enum {
@@ -245,6 +246,7 @@
 void e_gw_item_set_organizer (EGwItem  *item, EGwItemOrganizer *organizer);
 
 GSList * e_gw_item_get_attach_id_list (EGwItem *item) ;
+void e_gw_item_set_attach_id_list (EGwItem *item, GSList *attach_list) ;
 
 
 GSList *e_gw_item_get_recurrence_dates (EGwItem *item);
Index: e-gw-container.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-container.c,v
retrieving revision 1.6
diff -u -r1.6 e-gw-container.c
--- e-gw-container.c	6 Dec 2004 01:31:31 -0000	1.6
+++ e-gw-container.c	3 Jan 2005 05:54:38 -0000
@@ -31,6 +31,8 @@
 	char *name;
 	char *id;
 	char *parent ;
+	guint32 unread ;
+	guint32 total ;
 	gboolean is_root ;
 	gboolean is_writable;
 	gboolean is_frequent_contacts; /*indicates  whether this folder is frequent contacts or not */
@@ -186,6 +188,32 @@
 		e_gw_container_set_parent_id (container, (const char *) value);
 		g_free (value) ;
 	}
+	/* retrive the unread and total count */
+	subparam = soup_soap_parameter_get_first_child_by_name (param, "hasUnread") ;
+	if (!subparam) {
+		container->priv->unread = 0 ;
+	} else {
+		subparam = soup_soap_parameter_get_first_child_by_name (param, "unreadCount") ;
+		if (subparam) {
+			value = soup_soap_parameter_get_string_value (subparam) ;
+			if (value)
+				container->priv->unread = atoi(value) ;
+			else
+				container->priv->unread = 0 ; /*XXX:should it be 0?*/
+
+			g_free (value) ;
+		}
+	}
+
+	subparam = soup_soap_parameter_get_first_child_by_name (param, "count") ;
+	if (subparam) {
+		value = soup_soap_parameter_get_string_value (subparam) ;
+		if (value)
+			container->priv->total = atoi(value) ;
+		else
+			/*Some problem - should return FALSE??*/
+			g_free (value) ;
+	}
 
 	return TRUE;
 }
@@ -259,6 +287,23 @@
 
 	priv->parent = g_strdup (parent_id) ;
 }
+guint32
+e_gw_container_get_total_count (EGwContainer *container)
+{
+	g_return_val_if_fail (E_IS_GW_CONTAINER (container), -1) ;
+
+	return container->priv->total ;
+}
+		
+guint32
+e_gw_container_get_unread_count (EGwContainer *container)
+{
+	g_return_val_if_fail (E_IS_GW_CONTAINER (container), -1) ;
+
+	return container->priv->unread ;
+
+}
+
 
 gboolean 
 e_gw_container_get_is_writable (EGwContainer *container)
Index: e-gw-container.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-container.h,v
retrieving revision 1.5
diff -u -r1.5 e-gw-container.h
--- e-gw-container.h	6 Dec 2004 01:31:31 -0000	1.5
+++ e-gw-container.h	3 Jan 2005 05:54:38 -0000
@@ -57,6 +57,8 @@
 void          e_gw_container_set_id (EGwContainer *container, const char *new_id);
 const char   *e_gw_container_get_parent_id (EGwContainer *container) ;
 void 	      e_gw_container_set_parent_id (EGwContainer *container, const char *parent_id) ;
+guint32       e_gw_container_get_total_count (EGwContainer *container) ;
+guint32       e_gw_container_get_unread_count (EGwContainer *container) ;
 gboolean      e_gw_container_get_is_writable (EGwContainer *container);
 void          e_gw_container_set_is_writable (EGwContainer *container, gboolean writable);
 gboolean     e_gw_container_get_is_frequent_contacts (EGwContainer *container);
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/ChangeLog,v
retrieving revision 1.80
diff -u -r1.80 ChangeLog
--- ChangeLog	15 Dec 2004 08:55:14 -0000	1.80
+++ ChangeLog	3 Jan 2005 06:04:13 -0000
@@ -1,3 +1,16 @@
+2005-01-03  Parthasarathi Susarla <sparthasarathi novell com>
+	
+	* e-gw-item.[ch]: support for attachments for soap mailer
+	  (free_attach), 
+	  (e_gw_item_set_attach_id_list),
+	  (add_attachment_to_soap_message),
+	  (e_gw_item_set_calendar_item_elemets)
+	* e-gw-container.[ch]: retrive the unread and total count from
+	  the soap response.
+	  (e_gw_container_set_from_soap_parameter),
+	  (e_gw_container_get_total_count),
+	  (e_gw_container_get_unread_count)
+
 2004-12-15  Chenthill Palanisamy <pchenthill novell com>
 
 	* e-gw-item.c:


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