Index: servers/groupwise/e-gw-sendoptions.c
===================================================================
--- servers/groupwise/e-gw-sendoptions.c	(revision 8465)
+++ servers/groupwise/e-gw-sendoptions.c	(working copy)
@@ -391,6 +391,9 @@
 			} else
 				gopts->delay_enabled = FALSE;
 		}
+
+		g_free (field);
+		g_free (val);
 	}
 }
 
Index: servers/groupwise/ChangeLog
===================================================================
--- servers/groupwise/ChangeLog	(revision 8465)
+++ servers/groupwise/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2008-02-07  Milan Crha  <mcrha@redhat.com>
+
+	** Fixes part of bug #510949
+
+	* e-gw-sendoptions.c:
+	* e-gw-proxy.c:
+	* e-gw-item.c:
+	* e-gw-connection.c: Memory leak fixes.
+
 2008-01-15  Dan Winship  <danw@gnome.org>
 
 	* e-gw-message.c: Update for libsoup 2.4
Index: servers/groupwise/e-gw-proxy.c
===================================================================
--- servers/groupwise/e-gw-proxy.c	(revision 8465)
+++ servers/groupwise/e-gw-proxy.c	(working copy)
@@ -50,20 +50,20 @@
 		value = NULL;
 		if (type_param)	{
 			value = soup_soap_parameter_get_string_value (type_param);
-			aclInstance->proxy_email = g_strdup_printf("%s", value);
+			aclInstance->proxy_email = value;
 		}
 
 		type_param = soup_soap_parameter_get_first_child_by_name (subparam, "displayName");
 		value = NULL;
 		if (type_param)	{
 			value = soup_soap_parameter_get_string_value (type_param);
-			aclInstance->proxy_name = g_strdup_printf ("%s", value);
+			aclInstance->proxy_name = value;
 		}
 		type_param = soup_soap_parameter_get_first_child_by_name (subparam, "id");
 		value = NULL;
 		if (type_param)	{
 			value = soup_soap_parameter_get_string_value (type_param);
-			aclInstance->uniqueid = g_strdup_printf ("%s", value);
+			aclInstance->uniqueid = value;
 		} else
 			aclInstance->uniqueid = NULL;
 
@@ -72,97 +72,69 @@
 		if (type_param)	{
 			individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"read");
 			if (individual_rights) {
-				value = soup_soap_parameter_get_string_value (individual_rights);
 				aclInstance->permissions |= E_GW_PROXY_MAIL_READ;
 			}
 			individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"write");
 			if (individual_rights) {
-				value = soup_soap_parameter_get_string_value (individual_rights);
 				aclInstance->permissions |= E_GW_PROXY_MAIL_WRITE;
 			}
 		}
 
-		if (value)
-			g_free (value);
-
-		value = NULL;
 		type_param = soup_soap_parameter_get_first_child_by_name (subparam, "appointment");
 		if (type_param) {
 			individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"read");
 			if (individual_rights) {
-				value = soup_soap_parameter_get_string_value (individual_rights);
 				aclInstance->permissions |= E_GW_PROXY_APPOINTMENT_READ;
 			}
 			individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"write");
 			if (individual_rights) {
-				value = soup_soap_parameter_get_string_value (individual_rights);
 				aclInstance->permissions |= E_GW_PROXY_APPOINTMENT_WRITE;
 			}
 		}
-		if (value)
-			g_free (value);
 
-		value = NULL;
 		type_param = soup_soap_parameter_get_first_child_by_name (subparam, "task");
 		if (type_param)	{
 			individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"read");
 			if (individual_rights) {
-				value = soup_soap_parameter_get_string_value (individual_rights);
 				aclInstance->permissions |= E_GW_PROXY_TASK_READ;
 			}
 			individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"write");
 			if (individual_rights) {
-				value = soup_soap_parameter_get_string_value (individual_rights);
 				aclInstance->permissions |= E_GW_PROXY_TASK_WRITE;
 			}
 		}
-		if (value)
-			g_free (value);
 
-		value = NULL;
 		type_param = soup_soap_parameter_get_first_child_by_name (subparam, "note");
 		if (type_param)	{
 			individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"read");
 			if (individual_rights) {
-				value = soup_soap_parameter_get_string_value (individual_rights);
 				aclInstance->permissions |= E_GW_PROXY_NOTES_READ;
 			}
 			individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"write");
 			if (individual_rights) {
-				value = soup_soap_parameter_get_string_value (individual_rights);
 				aclInstance->permissions |= E_GW_PROXY_NOTES_WRITE;
 			}
 		}
-		if (value)
-			g_free (value);
 
-
 		type_param = soup_soap_parameter_get_first_child_by_name (subparam, "misc");
-		value = NULL;
 		if (type_param)	{
 			individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"alarms");
 			if (individual_rights) {
-				value = soup_soap_parameter_get_string_value (individual_rights);
 				aclInstance->permissions |= E_GW_PROXY_GET_ALARMS;
 			}
 			individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"notify");
 			if (individual_rights) {
-				value = soup_soap_parameter_get_string_value (individual_rights);
 				aclInstance->permissions |= E_GW_PROXY_GET_NOTIFICATIONS;
 			}
 			individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"setup");
 			if (individual_rights) {
-				value = soup_soap_parameter_get_string_value (individual_rights);
 				aclInstance->permissions |= E_GW_PROXY_MODIFY_FOLDERS;
 			}
 			individual_rights= soup_soap_parameter_get_first_child_by_name (type_param,"readHidden");
 			if (individual_rights) {
-				value = soup_soap_parameter_get_string_value (individual_rights);
 				aclInstance->permissions |= E_GW_PROXY_READ_PRIVATE;
 			}
 		}
-		if (value)
-			g_free(value);
 
 		*proxy_list = g_list_append(*proxy_list, aclInstance);
 	}
@@ -337,104 +309,74 @@
 e_gw_proxy_parse_proxy_login_response (SoupSoapParameter *param, int *permissions)
 {
 	SoupSoapParameter *subparam;
-	char *value;
 	SoupSoapParameter *individual_rights;
 
 	*permissions = 0;
 	subparam = soup_soap_parameter_get_first_child_by_name (param, "mail");
-	value = NULL;
 	if (subparam) {
 		individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"read");
 		if (individual_rights) {
-			value = soup_soap_parameter_get_string_value (individual_rights);
 			*permissions |= E_GW_PROXY_MAIL_READ;
 		}
 		individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"write");
 		if (individual_rights) {
-			value = soup_soap_parameter_get_string_value (individual_rights);
 			*permissions |= E_GW_PROXY_MAIL_WRITE;
 		}
 	}
 
-	if (value)
-		g_free (value);
-
-	value = NULL;
 	subparam = soup_soap_parameter_get_first_child_by_name (param, "appointment");
 	if (subparam) {
 		individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"read");
 		if (individual_rights) {
-			value = soup_soap_parameter_get_string_value (individual_rights);
 			*permissions |= E_GW_PROXY_APPOINTMENT_READ;
 		}
 		individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"write");
 		if (individual_rights) {
-			value = soup_soap_parameter_get_string_value (individual_rights);
 			*permissions |= E_GW_PROXY_APPOINTMENT_WRITE;
 		}
 	}
-	if (value)
-		g_free (value);
 
-	value = NULL;
 	subparam = soup_soap_parameter_get_first_child_by_name (param, "task");
 	if (subparam)	{
 		individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"read");
 		if (individual_rights) {
-			value = soup_soap_parameter_get_string_value (individual_rights);
 			*permissions |= E_GW_PROXY_TASK_READ;
 		}
 		individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"write");
 		if (individual_rights) {
-			value = soup_soap_parameter_get_string_value (individual_rights);
 			*permissions |= E_GW_PROXY_TASK_WRITE;
 		}
 	}
-	if (value)
-		g_free (value);
 
-	value = NULL;
 	subparam = soup_soap_parameter_get_first_child_by_name (param, "note");
 	if (subparam)	{
 		individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"read");
 		if (individual_rights) {
-			value = soup_soap_parameter_get_string_value (individual_rights);
 			*permissions |= E_GW_PROXY_NOTES_READ;
 		}
 		individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"write");
 		if (individual_rights) {
-			value = soup_soap_parameter_get_string_value (individual_rights);
 			*permissions |= E_GW_PROXY_NOTES_WRITE;
 		}
 	}
-	if (value)
-		g_free (value);
 
-
 	subparam = soup_soap_parameter_get_first_child_by_name (param, "misc");
-	value = NULL;
 	if (subparam)	{
 		individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"alarms");
 		if (individual_rights) {
-			value = soup_soap_parameter_get_string_value (individual_rights);
 			*permissions |= E_GW_PROXY_GET_ALARMS;
 		}
 		individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"notify");
 		if (individual_rights) {
-			value = soup_soap_parameter_get_string_value (individual_rights);
 			*permissions |= E_GW_PROXY_GET_NOTIFICATIONS;
 		}
 		individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"setup");
 		if (individual_rights) {
-			value = soup_soap_parameter_get_string_value (individual_rights);
 			*permissions |= E_GW_PROXY_MODIFY_FOLDERS;
 		}
 		individual_rights= soup_soap_parameter_get_first_child_by_name (subparam,"readHidden");
 		if (individual_rights) {
-			value = soup_soap_parameter_get_string_value (individual_rights);
 			*permissions |= E_GW_PROXY_READ_PRIVATE;
 		}
 	}
-	if (value)
-		g_free(value);
 }
Index: servers/groupwise/e-gw-item.c
===================================================================
--- servers/groupwise/e-gw-item.c	(revision 8465)
+++ servers/groupwise/e-gw-item.c	(working copy)
@@ -745,6 +745,7 @@
 			value = soup_soap_parameter_get_string_value (child);
 			if (value && !g_ascii_strcasecmp (value, "1"))
 				priv->reply_request_set = TRUE;
+			g_free (value), value = NULL;
 		}
 
 		if (!priv->reply_request_set) {
@@ -1168,7 +1169,6 @@
 				const char *key = NULL;
 
 				type =  soup_soap_parameter_get_property (temp, "type");
-				value = soup_soap_parameter_get_string_value (temp);
 				switch (*type) {
 					case 'O' :
 						key = "phone_Office";
@@ -1192,6 +1192,7 @@
 				};
 
 				if (type) {
+					value = soup_soap_parameter_get_string_value (temp);
 					g_hash_table_insert (item->priv->simple_fields, (char*)key, value);
 					g_free (type);
 				}
@@ -1305,9 +1306,10 @@
 				second_level_child = soup_soap_parameter_get_first_child_by_name (temp, "name");
 				member->name =  soup_soap_parameter_get_string_value (second_level_child);
 				item->priv->member_list = g_list_append (item->priv->member_list, member);
+			} else {
+				g_free (id);
+				g_free (email);
 			}
-
-
 		}
 	}
 
@@ -2026,8 +2028,8 @@
 				/* convert it into integer */
 				item->priv->trigger = atoi (value);
 				g_free (value);
-				g_free (enabled);
 			}
+			g_free (enabled);
 		}
 
 	}
Index: servers/groupwise/e-gw-connection.c
===================================================================
--- servers/groupwise/e-gw-connection.c	(revision 8465)
+++ servers/groupwise/e-gw-connection.c	(working copy)
@@ -524,10 +524,10 @@
 			response = e_gw_connection_send_message (cnc, msg);
 			status = e_gw_connection_parse_response_status (response);
 			g_strfreev (tokens);
-			g_free (host);
-			g_free (port);
 		}
 
+		g_free (host);
+		g_free (port);
 	}
 	param = soup_soap_response_get_first_parameter_by_name (response, "session");
 	if (!param) {
@@ -1053,6 +1053,7 @@
         SoupSoapResponse *response;
         EGwConnectionStatus status;
         SoupSoapParameter *param, *subparam;
+	char *tmp;
 
  	g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
 
@@ -1094,12 +1095,16 @@
                  return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
          }
 
-         if (!g_ascii_strcasecmp ( soup_soap_parameter_get_string_value (param), "0")) {
+	tmp = soup_soap_parameter_get_string_value (param);
+	if (!g_ascii_strcasecmp (tmp, "0")) {
+		g_free (tmp);
                  g_message ("No deltas");
 		 // g_object_unref (cnc);
                  return E_GW_CONNECTION_STATUS_OK;
-         }
+        }
 
+	g_free (tmp);
+
          param = soup_soap_response_get_first_parameter_by_name (response, "deltas");
          if (!param) {
                  g_object_unref (response);
@@ -1270,7 +1275,7 @@
 	if (status == E_GW_CONNECTION_STATUS_OK) {
 		param = soup_soap_response_get_first_parameter_by_name (response, "id");
 		if (param != NULL)
-			*id = g_strdup (soup_soap_parameter_get_string_value (param));
+			*id = soup_soap_parameter_get_string_value (param);
 	} else if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
 		reauthenticate (cnc);
 
@@ -2132,9 +2137,10 @@
 			if (categories_by_name)
 				g_hash_table_insert (priv->categories_by_name, g_strdup (name), g_strdup (id));
 			g_strfreev (components);
-			g_free (name);
+			id = NULL;
 		}
-
+		g_free (id);
+		g_free (name);
         }
 
 	/* free memory */
@@ -3259,23 +3265,20 @@
 				if (val_param)
 					val = soup_soap_parameter_get_int_value (val_param);
 				*use_junk = val;
-				g_free (field);
 			} else	if (!g_ascii_strcasecmp (field, "useBlockList")) {
 				if (val_param)
 					val = soup_soap_parameter_get_int_value (val_param);
 				*use_block = val;
-				g_free (field);
 			} else if (!g_ascii_strcasecmp (field, "usePAB")) {
 				if (val_param)
 					val = soup_soap_parameter_get_int_value (val_param);
 				*use_pab = val;
-				g_free (field);
 			} else if (!g_ascii_strcasecmp (field, "persistence")) {
 				if (val_param)
 					val = soup_soap_parameter_get_int_value (val_param);
 				*persistence = val;
-				g_free (field);
 			}
+			g_free (field);
 		}
 	}
 }
Index: calendar/ChangeLog
===================================================================
--- calendar/ChangeLog	(revision 8465)
+++ calendar/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2008-02-07  Milan Crha  <mcrha@redhat.com>
+
+	** Fixes part of bug #510949
+
+	* backends/groupwise/e-cal-backend-groupwise-utils.c:
+	Memory leak fixes.
+
 2008-02-07  Chenthill Palanisamy  <pchenthill@novell.com>
 
 	Fixes part of #510949
Index: calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
===================================================================
--- calendar/backends/groupwise/e-cal-backend-groupwise-utils.c	(revision 8465)
+++ calendar/backends/groupwise/e-cal-backend-groupwise-utils.c	(working copy)
@@ -1655,7 +1655,8 @@
         SoupSoapResponse *response;
         EGwConnectionStatus status;
         SoupSoapParameter *param, *subparam, *param_outstanding;
-        const char *session, *outstanding = NULL;
+        const char *session;
+	char *outstanding = NULL;
 	gboolean resend_request = TRUE;
 	int request_iteration = 0;
 
@@ -1709,8 +1710,10 @@
 		g_object_unref (msg);
 		g_object_unref (response);
 		g_usleep (10000000);
+		g_free (outstanding); outstanding = NULL;
 		goto resend;
 	}
+	g_free (outstanding); outstanding = NULL;
 
         /* FIXME  the FreeBusyStats are not used currently.  */
         param = soup_soap_response_get_first_parameter_by_name (response, "freeBusyInfo");
@@ -1726,7 +1729,7 @@
 	     subparam != NULL;
 	     subparam = soup_soap_parameter_get_next_child_by_name (subparam, "user")) {
 		SoupSoapParameter *param_blocks, *subparam_block, *tmp;
-		const char *uuid = NULL, *email = NULL, *name = NULL;
+		char *uuid = NULL, *email = NULL, *name = NULL;
 		ECalComponent *comp;
 		ECalComponentAttendee attendee;
 		GSList *attendee_list = NULL;
@@ -1759,6 +1762,7 @@
 
 		/* XXX the uuid is not currently used. hence it is
 		 * discarded */
+		g_free (uuid); uuid = NULL;
 
 		attendee_list = g_slist_append (attendee_list, &attendee);
 
@@ -1782,7 +1786,7 @@
 			icalproperty *icalprop;
 			icaltimetype itt;
 			time_t t;
-			const char *start, *end, *accept_level;
+			char *start, *end, *accept_level;
 
 			memset (&ipt, 0, sizeof (struct icalperiodtype));
 			tmp = soup_soap_parameter_get_first_child_by_name (subparam_block, "startDate");
@@ -1791,6 +1795,7 @@
 				t = e_gw_connection_get_date_from_string (start);
 				itt = icaltime_from_timet_with_zone (t, 0, default_zone ? default_zone : NULL);
 				ipt.start = itt;
+				g_free (start);
 			}
 
 			tmp = soup_soap_parameter_get_first_child_by_name (subparam_block, "endDate");
@@ -1799,6 +1804,7 @@
 				t = e_gw_connection_get_date_from_string (end);
 				itt = icaltime_from_timet_with_zone (t, 0, default_zone ? default_zone : NULL);
 				ipt.end = itt;
+				g_free (end);
 			}
 			icalprop = icalproperty_new_freebusy (ipt);
 
@@ -1813,9 +1819,9 @@
 					icalproperty_set_parameter_from_string (icalprop, "FBTYPE", "BUSYUNAVAILABLE");
 				else if (!strcmp (accept_level, "Free"))
 					icalproperty_set_parameter_from_string (icalprop, "FBTYPE", "FREE");
-							}
+				g_free (accept_level);
+			}
 			icalcomponent_add_property(icalcomp, icalprop);
-
 		}
 
 		e_cal_component_commit_sequence (comp);
