[evolution-patches] Proxy Feature - GroupWise APIs



Hi all,

Shreyas and myself are currently implementing the proxy feature for
GroupWise accounts in Evolution. The attached patch contains the
code-changes made to eds/servers/groupwise/e-gw-connection.c, where the
APIs to interact with the server are defined and a new file e-proxy.h
which defines the structures and constants. Please review them.

Thanks,
Sankar

P.S.: Since the feature implementation has a higher LOC, we are
splitting the patches and will send them in pieces. 

Index: e-gw-connection.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-connection.c,v
retrieving revision 1.118
diff -u -p -r1.118 e-gw-connection.c
--- e-gw-connection.c	8 Jun 2005 05:42:43 -0000	1.118
+++ e-gw-connection.c	23 Jun 2005 14:36:26 -0000
@@ -2901,3 +2901,766 @@ e_gw_connection_reply_item (EGwConnectio
 
         return E_GW_CONNECTION_STATUS_OK;
 }
+
+EGwConnectionStatus
+e_gw_connection_get_proxy_access_list (EGwConnection *cnc, GList **proxy_list)
+{
+	SoupSoapMessage *msg = NULL;
+	SoupSoapResponse *response = NULL;
+	EGwConnectionStatus status;
+	SoupSoapParameter *param;
+	SoupSoapParameter *type_param;
+	SoupSoapParameter *individualRights;
+	char *value;
+
+	g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_CONNECTION);
+
+	/* build the SOAP message */
+	msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getProxyAccessListRequest");
+
+	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_INVALID_CONNECTION)
+		reauthenticate (cnc);
+
+	/* parse the response and create the individual proxy accounts */
+	*proxy_list = NULL;
+	param = soup_soap_response_get_first_parameter_by_name (response, "accessRights");	
+	if (!param) {
+		g_object_unref (response);
+		return status;
+	} else 	{
+		SoupSoapParameter *subparam;
+		for (subparam = soup_soap_parameter_get_first_child_by_name (param, "entry");
+				subparam != NULL;
+				subparam = soup_soap_parameter_get_next_child_by_name (subparam, "entry")) {
+		
+			proxyHandler *aclInstance;
+			aclInstance = (proxyHandler *) malloc(sizeof(proxyHandler));
+			aclInstance->permissions = 0;
+			aclInstance->flags = 0;
+			type_param = soup_soap_parameter_get_first_child_by_name (subparam, "email");
+			value = NULL;
+			if (type_param)	{
+				value = soup_soap_parameter_get_string_value (type_param);
+				aclInstance->proxy_email = g_strdup_printf("%s", 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);
+			}
+			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);
+			} else 
+				aclInstance->uniqueid = NULL;
+
+			type_param = soup_soap_parameter_get_first_child_by_name (subparam, "mail");
+			value = NULL;
+			if (type_param)	{
+				individualRights= soup_soap_parameter_get_first_child_by_name (type_param,"read");				 
+				if (individualRights) {
+					value = soup_soap_parameter_get_string_value (individualRights);
+					aclInstance->permissions |= PROXY_MAIL_READ;
+				}
+				individualRights= soup_soap_parameter_get_first_child_by_name (type_param,"write");				 
+				if (individualRights) {
+					value = soup_soap_parameter_get_string_value (individualRights);
+					aclInstance->permissions |= 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) {
+				individualRights= soup_soap_parameter_get_first_child_by_name (type_param,"read");				 
+				if (individualRights) {
+					value = soup_soap_parameter_get_string_value (individualRights);
+					aclInstance->permissions |= PROXY_APPOINTMENT_READ;
+				}
+				individualRights= soup_soap_parameter_get_first_child_by_name (type_param,"write");				 
+				if (individualRights) {
+					value = soup_soap_parameter_get_string_value (individualRights);
+					aclInstance->permissions |= 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)	{
+				individualRights= soup_soap_parameter_get_first_child_by_name (type_param,"read");				 
+				if (individualRights) {
+					value = soup_soap_parameter_get_string_value (individualRights);
+					aclInstance->permissions |= PROXY_TASK_READ;
+				}
+				individualRights= soup_soap_parameter_get_first_child_by_name (type_param,"write");				 
+				if (individualRights) {
+					value = soup_soap_parameter_get_string_value (individualRights);
+					aclInstance->permissions |= 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)	{
+				individualRights= soup_soap_parameter_get_first_child_by_name (type_param,"read");				 
+				if (individualRights) {
+					value = soup_soap_parameter_get_string_value (individualRights);
+					aclInstance->permissions |= PROXY_NOTES_READ;
+				}
+				individualRights= soup_soap_parameter_get_first_child_by_name (type_param,"write");				 
+				if (individualRights) {
+					value = soup_soap_parameter_get_string_value (individualRights);
+					aclInstance->permissions |= 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)	{
+				individualRights= soup_soap_parameter_get_first_child_by_name (type_param,"alarms");
+				if (individualRights) {
+					value = soup_soap_parameter_get_string_value (individualRights);
+					aclInstance->permissions |= PROXY_GET_ALARMS;
+				}
+				individualRights= soup_soap_parameter_get_first_child_by_name (type_param,"notify");
+				if (individualRights) {
+					value = soup_soap_parameter_get_string_value (individualRights);
+					aclInstance->permissions |= PROXY_GET_NOTIFICATIONS;
+				}
+				individualRights= soup_soap_parameter_get_first_child_by_name (type_param,"setup"); 
+				if (individualRights) {
+					value = soup_soap_parameter_get_string_value (individualRights);
+					aclInstance->permissions |= PROXY_MODIFY_FOLDERS;
+				}
+				individualRights= soup_soap_parameter_get_first_child_by_name (type_param,"readHidden"); 
+				if (individualRights) {
+					value = soup_soap_parameter_get_string_value (individualRights);
+					aclInstance->permissions |= PROXY_READ_PRIVATE;
+				}
+			}
+			if (value)
+				g_free(value);
+
+			*proxy_list = g_list_append(*proxy_list, aclInstance);
+		}
+	}
+	/* free memory */
+	if (response)
+		g_object_unref (response);
+	if (msg)
+		g_object_unref (msg);
+	return status;
+}
+
+EGwConnectionStatus 
+e_gw_proxy_add (EGwConnection *cnc, proxyHandler *new_proxy)
+{
+	SoupSoapMessage *msg = NULL;
+	SoupSoapResponse *response = NULL;
+	EGwConnectionStatus status;
+	gboolean added = FALSE;
+	
+	g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_UNKNOWN);
+	msg = e_gw_message_new_with_header (e_gw_connection_get_uri (cnc), e_gw_connection_get_session_id (cnc), "createProxyAccessRequest");
+	soup_soap_message_start_element (msg, "entry", NULL, NULL);
+	e_gw_message_write_string_parameter (msg, "email", NULL, new_proxy->proxy_email);
+	e_gw_message_write_string_parameter (msg, "displayName", NULL, new_proxy->proxy_name);	
+
+	if (new_proxy->permissions & PROXY_MAIL_READ){
+		added = TRUE;
+		soup_soap_message_start_element (msg, "mail", NULL, NULL);
+		e_gw_message_write_int_parameter (msg, "read", NULL, 1);
+	}
+	if (new_proxy->permissions & PROXY_MAIL_WRITE){
+		if (added == FALSE){
+			added=TRUE;
+			soup_soap_message_start_element (msg, "mail", NULL, NULL);
+		}
+		e_gw_message_write_int_parameter (msg, "write", NULL, 1);
+	}
+	if (added == TRUE)
+		soup_soap_message_end_element(msg);
+
+	added = FALSE;
+	if (new_proxy->permissions & PROXY_APPOINTMENT_READ){
+		added=TRUE;
+		soup_soap_message_start_element (msg, "appointment", NULL, NULL);
+		e_gw_message_write_int_parameter (msg, "read", NULL, 1);
+	}
+	if (new_proxy->permissions & PROXY_APPOINTMENT_WRITE){
+		if(added == FALSE)
+		{
+			added=TRUE;
+			soup_soap_message_start_element (msg, "appointment", NULL, NULL);
+		}
+		e_gw_message_write_int_parameter (msg, "write", NULL, 1);
+	}
+	if (added == TRUE)
+		soup_soap_message_end_element  (msg);
+
+	added = FALSE;
+	if (new_proxy->permissions & PROXY_TASK_READ){
+		added=TRUE;
+		soup_soap_message_start_element (msg, "task", NULL, NULL);
+		e_gw_message_write_int_parameter (msg, "read", NULL, 1);
+	}
+	if (new_proxy->permissions & PROXY_TASK_WRITE){
+		if (added == FALSE)
+		{
+			added=TRUE;
+			soup_soap_message_start_element (msg, "task", NULL, NULL);
+		}
+		e_gw_message_write_int_parameter (msg, "write", NULL, 1);
+	}
+	if (added == TRUE)
+		soup_soap_message_end_element(msg);
+
+	added = FALSE;
+	if (new_proxy->permissions & PROXY_NOTES_READ){
+		added=TRUE;
+		soup_soap_message_start_element (msg, "note", NULL, NULL);
+		e_gw_message_write_int_parameter (msg, "read", NULL, 1);
+	}
+	if (new_proxy->permissions & PROXY_NOTES_WRITE){
+			if(added==FALSE)
+		{
+			added=TRUE;
+			soup_soap_message_start_element (msg, "note", NULL, NULL);
+		}
+		e_gw_message_write_int_parameter (msg, "write", NULL, 1);
+	}
+	if (added == TRUE)
+		soup_soap_message_end_element(msg);
+	
+	added = FALSE;
+	if (new_proxy->permissions & PROXY_GET_ALARMS){
+		added=TRUE;
+		soup_soap_message_start_element(msg,"misc",NULL,NULL);
+		e_gw_message_write_int_parameter (msg, "alarms", NULL, 1);
+	}
+	if (new_proxy->permissions & PROXY_GET_NOTIFICATIONS){
+		if (added!=TRUE)
+		{
+			added=TRUE;
+			soup_soap_message_start_element(msg,"misc",NULL,NULL);
+		}
+		e_gw_message_write_int_parameter (msg, "notify", NULL, 1);
+	}
+	
+	if (new_proxy->permissions & PROXY_MODIFY_FOLDERS){
+		if (added!=TRUE)
+		{
+			added=TRUE;
+			soup_soap_message_start_element(msg,"misc",NULL,NULL);
+		}
+		e_gw_message_write_int_parameter (msg, "setup", NULL, 1);
+	}
+	if (new_proxy->permissions & PROXY_READ_PRIVATE){
+		if (added!=TRUE)
+		{
+			added=TRUE;
+			soup_soap_message_start_element(msg,"misc",NULL,NULL);
+		}
+		e_gw_message_write_int_parameter (msg, "readHidden", NULL, 1);
+	}
+	if (added==TRUE)
+		soup_soap_message_end_element(msg);			
+	e_gw_message_write_footer (msg);
+	response = e_gw_connection_send_message (cnc, msg);
+	if (!response) {
+		g_object_unref (msg);
+		return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
+	}
+	status = e_gw_connection_parse_response_status (response);
+
+	if (response)
+	g_object_unref (response);
+
+	if (msg)
+	g_object_unref (msg);
+	return status;
+}
+
+EGwConnectionStatus
+e_gw_proxy_remove (EGwConnection *cnc, proxyHandler *newProxy)
+{
+	SoupSoapMessage *msg;
+	SoupSoapResponse *response;
+	EGwConnectionStatus status;
+
+	g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_UNKNOWN);
+
+	msg = e_gw_message_new_with_header (e_gw_connection_get_uri(cnc), e_gw_connection_get_session_id(cnc), "removeProxyAccessRequest");
+
+	e_gw_message_write_string_parameter (msg, "id", NULL, newProxy->uniqueid);
+
+	e_gw_message_write_footer (msg);
+
+	response = e_gw_connection_send_message (cnc, msg);
+	if (!response) {
+		g_object_unref (msg);
+		return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
+	}
+	status = e_gw_connection_parse_response_status (response);
+	g_object_unref (response);
+	g_object_unref (msg);
+	return E_GW_CONNECTION_STATUS_OK;
+
+}
+
+EGwConnectionStatus 
+e_gw_proxy_changed (EGwConnection *cnc, proxyHandler *new_proxy)
+{
+	SoupSoapMessage *msg = NULL;
+	SoupSoapResponse *response = NULL;
+	EGwConnectionStatus status;
+	gboolean added = FALSE;
+	
+	g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_UNKNOWN);
+	msg = e_gw_message_new_with_header (e_gw_connection_get_uri (cnc), e_gw_connection_get_session_id (cnc), "modifyProxyAccessRequest");
+	e_gw_message_write_string_parameter (msg, "id", NULL, new_proxy->uniqueid);
+	soup_soap_message_start_element (msg, "updates", NULL, NULL);
+	e_gw_message_write_string_parameter (msg, "email", NULL, new_proxy->proxy_email);
+	e_gw_message_write_string_parameter (msg, "displayName", NULL, new_proxy->proxy_name);	
+	
+	if (new_proxy->permissions & PROXY_MAIL_READ){
+		added = TRUE;
+		soup_soap_message_start_element (msg, "mail", NULL, NULL);
+		e_gw_message_write_int_parameter (msg, "read", NULL, 1);
+	}
+	if (new_proxy->permissions & PROXY_MAIL_WRITE){
+		if (added == FALSE){
+			added=TRUE;
+			soup_soap_message_start_element (msg, "mail", NULL, NULL);
+		}
+		e_gw_message_write_int_parameter (msg, "write", NULL, 1);
+	}
+	if (added == TRUE)
+		soup_soap_message_end_element(msg);
+
+	added = FALSE;
+	if (new_proxy->permissions & PROXY_APPOINTMENT_READ){
+		added=TRUE;
+		soup_soap_message_start_element (msg, "appointment", NULL, NULL);
+		e_gw_message_write_int_parameter (msg, "read", NULL, 1);
+	}
+	if (new_proxy->permissions & PROXY_APPOINTMENT_WRITE){
+		if(added == FALSE)
+		{
+			added=TRUE;
+			soup_soap_message_start_element (msg, "appointment", NULL, NULL);
+		}
+		e_gw_message_write_int_parameter (msg, "write", NULL, 1);
+	}
+	if (added == TRUE)
+		soup_soap_message_end_element(msg);
+
+	added = FALSE;
+	if (new_proxy->permissions & PROXY_TASK_READ){
+		added=TRUE;
+		soup_soap_message_start_element (msg, "task", NULL, NULL);
+		e_gw_message_write_int_parameter (msg, "read", NULL, 1);
+	}
+	if (new_proxy->permissions & PROXY_TASK_WRITE){
+		if (added == FALSE)
+		{
+			added=TRUE;
+			soup_soap_message_start_element (msg, "task", NULL, NULL);
+		}
+		e_gw_message_write_int_parameter (msg, "write", NULL, 1);
+	}
+	if (added == TRUE)
+		soup_soap_message_end_element(msg);
+
+	added = FALSE;
+	if (new_proxy->permissions & PROXY_NOTES_READ){
+		added=TRUE;
+		soup_soap_message_start_element (msg, "note", NULL, NULL);
+		e_gw_message_write_int_parameter (msg, "read", NULL, 1);
+	}
+	if (new_proxy->permissions & PROXY_NOTES_WRITE){
+			if(added==FALSE)
+		{
+			added=TRUE;
+			soup_soap_message_start_element (msg, "note", NULL, NULL);
+		}
+		e_gw_message_write_int_parameter (msg, "write", NULL, 1);
+	}
+	if (added == TRUE)
+		soup_soap_message_end_element(msg);
+	
+	added = FALSE;
+	if (new_proxy->permissions & PROXY_GET_ALARMS){
+		added=TRUE;
+		soup_soap_message_start_element(msg,"misc",NULL,NULL);
+		e_gw_message_write_int_parameter (msg, "alarms", NULL, 1);
+	}
+	if (new_proxy->permissions & PROXY_GET_NOTIFICATIONS){
+		if (added!=TRUE)
+		{
+			added=TRUE;
+			soup_soap_message_start_element(msg,"misc",NULL,NULL);
+		}
+		e_gw_message_write_int_parameter (msg, "notify", NULL, 1);
+	}
+	
+	if (new_proxy->permissions & PROXY_MODIFY_FOLDERS){
+		if (added!=TRUE)
+		{
+			added=TRUE;
+			soup_soap_message_start_element(msg,"misc",NULL,NULL);
+		}
+		e_gw_message_write_int_parameter (msg, "setup", NULL, 1);
+	}
+	if (new_proxy->permissions & PROXY_READ_PRIVATE){
+		if (added!=TRUE)
+		{
+			added=TRUE;
+			soup_soap_message_start_element(msg,"misc",NULL,NULL);
+		}
+		e_gw_message_write_int_parameter (msg, "readHidden", NULL, 1);
+	}
+	if (added==TRUE)
+		soup_soap_message_end_element(msg);			
+	e_gw_message_write_footer (msg);
+	response = e_gw_connection_send_message (cnc, msg);
+	
+	if (!response) {
+		g_object_unref (msg);
+		return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
+	}
+	status = e_gw_connection_parse_response_status (response);
+
+	if (response)
+	g_object_unref (response);
+
+	if (msg)
+	g_object_unref (msg);
+	return status;
+}
+
+EGwConnectionStatus
+e_gw_connection_get_proxy_list (EGwConnection *cnc, GList **proxy_info)
+{
+	SoupSoapMessage *msg;
+        SoupSoapResponse *response;
+        EGwConnectionStatus status;
+        SoupSoapParameter *param;
+	SoupSoapParameter *type_param;
+	char *value;
+	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, "getProxyListRequest");
+        if (!msg) {
+                g_warning (G_STRLOC ": Could not build SOAP message");
+                return E_GW_CONNECTION_STATUS_UNKNOWN;
+        }
+	
+	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;
+	}
+	/* if status is OK - parse result. return the list */	
+	param = soup_soap_response_get_first_parameter_by_name (response, "proxies");
+			SoupSoapParameter *subparam;
+		for (subparam = soup_soap_parameter_get_first_child_by_name (param, "proxy");
+				subparam != NULL;
+				subparam = soup_soap_parameter_get_next_child_by_name (subparam, "proxy")) 
+		{
+
+			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);
+				*proxy_info = g_list_append(*proxy_info, value);
+			}
+			type_param = soup_soap_parameter_get_first_child_by_name (subparam, "email");
+			value = NULL;
+			if (type_param)	{
+				value = soup_soap_parameter_get_string_value (type_param);
+				*proxy_info = g_list_append(*proxy_info, value);
+			}
+		}	
+        if (!param) {
+                g_object_unref (response);
+                g_object_unref (msg);
+                return E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
+        }
+       	
+        g_object_unref (response);
+	g_object_unref (msg);
+
+        return E_GW_CONNECTION_STATUS_OK;
+}
+
+static SoupSoapMessage*
+form_proxy_login_request (EGwConnection *cnc, const char* username, const char* password, const char *proxy)
+{
+	SoupSoapMessage *msg;
+	/* build the SOAP message */
+	msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "loginRequest");
+	soup_soap_message_start_element (msg, "auth", "types", NULL);
+	soup_soap_message_add_attribute (msg, "type", "types:Proxy", "xsi",
+					 "http://www.w3.org/2001/XMLSchema-instance";);
+	e_gw_message_write_string_parameter (msg, "username", "types", username);
+	e_gw_message_write_string_parameter (msg, "password", "types", password);
+	e_gw_message_write_string_parameter (msg, "proxy", "types", proxy);
+	soup_soap_message_end_element (msg);
+	e_gw_message_write_footer (msg);
+	return msg;
+}
+
+EGwConnection *
+e_gw_proxy_connection_new (EGwConnection *parent_cnc, char *username, const char *password, const char *proxy, int  *permissions)
+{
+	EGwConnection *cnc;
+	SoupSoapMessage *msg;
+	SoupSoapResponse *response;
+	EGwConnectionStatus status;
+	SoupSoapParameter *param;
+	SoupSoapParameter *subparam;
+	SoupSoapParameter *individualRights;
+	char *value;
+	char *hash_key;
+	char *name = NULL;
+	int i;
+	
+	static GStaticMutex connecting = G_STATIC_MUTEX_INIT;	
+
+	g_static_mutex_lock (&connecting);
+
+	for (i=0; proxy[i]!='\0' && proxy[i]!='@'; i++);
+	if (proxy[i]=='@')
+		name = g_strndup(proxy, i);
+	/* search the connection in our hash table */
+	if (loaded_connections != NULL) {
+		hash_key = g_strdup_printf ( "%s:%s %s",
+				name ,
+				"",
+				parent_cnc->priv->uri);
+		cnc = g_hash_table_lookup (loaded_connections, hash_key);
+		g_free (hash_key);
+
+		if (E_IS_GW_CONNECTION (cnc)) {
+			g_object_ref (cnc);
+			g_static_mutex_unlock (&connecting);
+			return cnc;
+		}
+	}
+	
+	/* not found, so create a new connection */
+	cnc = g_object_new (E_TYPE_GW_CONNECTION, NULL);
+
+	msg = form_proxy_login_request (parent_cnc, username, password, proxy);
+
+	/* send message to server */
+	response = e_gw_connection_send_message (parent_cnc, msg);
+
+	if (!response) {
+		g_object_unref (cnc);
+		g_static_mutex_unlock (&connecting);
+		g_object_unref (msg);
+		return NULL;
+	}
+
+	status = e_gw_connection_parse_response_status (response);
+
+	param = soup_soap_response_get_first_parameter_by_name (response, "session");
+	if (!param) {
+		g_object_unref (response);
+		g_object_unref (msg);
+		g_object_unref (cnc);
+		g_static_mutex_unlock (&connecting);
+		return NULL;
+	}
+
+	cnc->priv->uri = g_strdup (parent_cnc->priv->uri);
+	cnc->priv->username = g_strdup (proxy);
+	cnc->priv->password = NULL;
+	cnc->priv->session_id = soup_soap_parameter_get_string_value (param);
+
+	/* retrieve user information */
+	param = soup_soap_response_get_first_parameter_by_name (response, "entry");
+
+	if (param) {
+		char *param_value;
+
+		subparam = soup_soap_parameter_get_first_child_by_name (param, "email");
+		if (subparam) {
+			param_value = soup_soap_parameter_get_string_value (subparam);
+			cnc->priv->user_email  = param_value;
+		}
+
+		subparam = soup_soap_parameter_get_first_child_by_name (param, "name");
+		if (subparam) {
+			param_value = soup_soap_parameter_get_string_value (subparam);
+			cnc->priv->user_name = param_value;
+		}
+
+		subparam = soup_soap_parameter_get_first_child_by_name (param, "uuid");
+		if (subparam) {
+			param_value = soup_soap_parameter_get_string_value (subparam);
+			cnc->priv->user_uuid = param_value;
+		}
+
+		subparam = soup_soap_parameter_get_first_child_by_name (param, "mail");
+		value = NULL;
+		if (subparam)	{
+			individualRights= soup_soap_parameter_get_first_child_by_name (subparam,"read");				 
+			if (individualRights) {
+				value = soup_soap_parameter_get_string_value (individualRights);
+				*permissions |= PROXY_MAIL_READ;
+			}
+			individualRights= soup_soap_parameter_get_first_child_by_name (subparam,"write");				 
+			if (individualRights) {
+				value = soup_soap_parameter_get_string_value (individualRights);
+				*permissions |= PROXY_MAIL_WRITE;
+			}
+		}
+
+		if (value)
+			g_free (value);
+
+		value = NULL;
+		subparam = soup_soap_parameter_get_first_child_by_name (param, "appointment");
+		if (subparam) {
+			individualRights= soup_soap_parameter_get_first_child_by_name (subparam,"read");				 
+			if (individualRights) {
+				value = soup_soap_parameter_get_string_value (individualRights);
+				*permissions |= PROXY_APPOINTMENT_READ;
+			}
+			individualRights= soup_soap_parameter_get_first_child_by_name (subparam,"write");				 
+			if (individualRights) {
+				value = soup_soap_parameter_get_string_value (individualRights);
+				*permissions |= PROXY_APPOINTMENT_WRITE;
+			}
+		}
+		if (value)
+			g_free (value);
+
+		value = NULL;
+		subparam = soup_soap_parameter_get_first_child_by_name (param, "task");
+		if (subparam)	{
+			individualRights= soup_soap_parameter_get_first_child_by_name (subparam,"read");				 
+			if (individualRights) {
+				value = soup_soap_parameter_get_string_value (individualRights);
+				*permissions |= PROXY_TASK_READ;
+			}
+			individualRights= soup_soap_parameter_get_first_child_by_name (subparam,"write");				 
+			if (individualRights) {
+				value = soup_soap_parameter_get_string_value (individualRights);
+				*permissions |= PROXY_TASK_WRITE;
+			}
+		}
+		if (value)
+			g_free (value);
+
+		value = NULL;
+		subparam = soup_soap_parameter_get_first_child_by_name (param, "note");
+		if (subparam)	{
+			individualRights= soup_soap_parameter_get_first_child_by_name (subparam,"read");				 
+			if (individualRights) {
+				value = soup_soap_parameter_get_string_value (individualRights);
+				*permissions |= PROXY_NOTES_READ;
+			}
+			individualRights= soup_soap_parameter_get_first_child_by_name (subparam,"write");				 
+			if (individualRights) {
+				value = soup_soap_parameter_get_string_value (individualRights);
+				*permissions |= PROXY_NOTES_WRITE;
+			}
+		}
+		if (value)
+			g_free (value);
+
+
+		subparam = soup_soap_parameter_get_first_child_by_name (param, "misc");
+		value = NULL;
+		if (subparam)	{
+			individualRights= soup_soap_parameter_get_first_child_by_name (subparam,"alarms");
+			if (individualRights) {
+				value = soup_soap_parameter_get_string_value (individualRights);
+				*permissions |= PROXY_GET_ALARMS;
+			}
+			individualRights= soup_soap_parameter_get_first_child_by_name (subparam,"notify");
+			if (individualRights) {
+				value = soup_soap_parameter_get_string_value (individualRights);
+				*permissions |= PROXY_GET_NOTIFICATIONS;
+			}
+			individualRights= soup_soap_parameter_get_first_child_by_name (subparam,"setup"); 
+			if (individualRights) {
+				value = soup_soap_parameter_get_string_value (individualRights);
+				*permissions |= PROXY_MODIFY_FOLDERS;
+			}
+			individualRights= soup_soap_parameter_get_first_child_by_name (subparam,"readHidden"); 
+			if (individualRights) {
+				value = soup_soap_parameter_get_string_value (individualRights);
+				*permissions |= PROXY_READ_PRIVATE;
+			}
+		}
+		if (value)
+			g_free(value);
+	}
+
+	param = soup_soap_response_get_first_parameter_by_name (response, "gwVersion");
+	if (param) {
+		char *param_value;
+		param_value = soup_soap_parameter_get_string_value (param);
+		cnc->priv->version = param_value;
+	} else
+		cnc->priv->version = NULL;	
+
+	param = soup_soap_response_get_first_parameter_by_name (response, "serverUTCTime");
+	if (param) 
+		cnc->priv->server_time = soup_soap_parameter_get_string_value (param);
+
+	/* add the connection to the loaded_connections hash table */
+	hash_key = g_strdup_printf ("%s:%s %s",
+			name,
+			"",
+			cnc->priv->uri);
+	if (loaded_connections == NULL)
+		loaded_connections = g_hash_table_new (g_str_hash, g_str_equal);
+	g_hash_table_insert (loaded_connections, hash_key, cnc);
+
+	/* free memory */
+	g_object_unref (response);
+	g_object_unref (msg);
+	g_static_mutex_unlock (&connecting);
+	return cnc;
+}
Index: e-gw-connection.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-connection.h,v
retrieving revision 1.59
diff -u -p -r1.59 e-gw-connection.h
--- e-gw-connection.h	8 Jun 2005 05:42:43 -0000	1.59
+++ e-gw-connection.h	23 Jun 2005 14:36:26 -0000
@@ -26,6 +26,7 @@
 
 #include <glib-object.h>
 #include <libsoup/soup-soap-message.h>
+#include <libedataserver/e-proxy.h>
 #include "e-gw-container.h"
 #include "e-gw-item.h"
 #include "e-gw-filter.h"
@@ -147,6 +148,12 @@ EGwConnectionStatus e_gw_connection_purg
 EGwConnectionStatus e_gw_connection_mark_read(EGwConnection *cnc, GList *item_ids) ;
 EGwConnectionStatus e_gw_connection_mark_unread(EGwConnection *cnc, GList *item_ids) ;
 EGwConnectionStatus e_gw_connection_reply_item (EGwConnection *cnc, const char *id, const char *view, EGwItem **item) ;
+EGwConnectionStatus e_gw_connection_get_proxy_access_list (EGwConnection *cnc, GList **proxy_list);
+EGwConnectionStatus e_gw_proxy_add (EGwConnection *cnc, proxyHandler *new_proxy);
+EGwConnectionStatus e_gw_proxy_remove (EGwConnection *cnc, proxyHandler *newProxy);
+EGwConnectionStatus e_gw_proxy_changed (EGwConnection *cnc, proxyHandler *newProxy);
+EGwConnectionStatus e_gw_connection_get_proxy_list (EGwConnection *cnc, GList **proxy_info);
+EGwConnection *e_gw_proxy_connection_new (EGwConnection *cnc1, char *username, const char *password, const char *proxy, int* permissions);
 G_END_DECLS
 
 #endif
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/ChangeLog,v
retrieving revision 1.141
diff -u -p -r1.141 ChangeLog
--- ChangeLog	8 Jun 2005 05:42:43 -0000	1.141
+++ ChangeLog	23 Jun 2005 14:36:28 -0000
@@ -1,3 +1,16 @@
+2005-06-23  Shreyas Srinivasan <sshreyas novell com>
+	* e-gw-connection.[ch] : Added the following functions for the proxy feature.
+	(e_gw_proxy_add)
+	(e_gw_proxy_remove)
+	(e_gw_proxy_changed)
+	(e_gw_connection_get_proxy_list)
+	
+2005-06-23  Sankar P <psankar novell com>
+	* e-gw-connection.[ch] : Added the following functions for the proxy feature.
+	(e_gw_proxy_connection_new)
+	(e_gw_connection_get_proxy_access_list)
+	* e-gw-connection.c : (form_proxy_login_request)
+	
 2005-06-08  Srinivasa Ragavan <sragavan novell com>
 
 	* e-gw-connection.[ch] :Added function to retrive deltainfo and delta
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* 
 * Authors : 
 *  Shreyas Srinivasan <sshreyas novell com>
 *  Sankar P <psankar novell com>
 *
 * Copyright 2003, Novell, Inc.
 *
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of version 2 of the GNU General Public 
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

/*State of each proxy grant*/

#define  PROXY_NEW           (1 << 0)           
#define  PROXY_DELETED       (1 << 1)
#define  PROXY_EDITED	  (1 << 2)

/*Permissions associated with a proxy grant*/
#define PROXY_MAIL_READ                (1 << 0)           
#define PROXY_MAIL_WRITE               (1 << 1)
#define PROXY_APPOINTMENT_READ         (1 << 2)           
#define PROXY_APPOINTMENT_WRITE        (1 << 3)
#define PROXY_NOTES_READ               (1 << 4)
#define PROXY_NOTES_WRITE              (1 << 5)
#define PROXY_TASK_READ                (1 << 6)
#define PROXY_TASK_WRITE               (1 << 7)
#define PROXY_GET_ALARMS               (1 << 8)
#define PROXY_GET_NOTIFICATIONS        (1 << 9)
#define PROXY_MODIFY_FOLDERS           (1 << 10)
#define PROXY_READ_PRIVATE             (1 << 11)


struct _proxyHandler {
    char *uniqueid;
    char *proxy_name;
    char *proxy_email;   
    guint32 flags;
    guint32 permissions;
};

typedef struct _proxyHandler proxyHandler;


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