[evolution-patches] Proxy Patch - Calendar & servers/GroupWise
- From: "Pasupathilingam Sankarasivasubramanian" <psankar novell com>
- To: <evolution-patches lists ximian com>
- Subject: [evolution-patches] Proxy Patch - Calendar & servers/GroupWise
- Date: Fri, 08 Jul 2005 06:45:37 -0600
Hi,
Attached with this mail is the patch for proxy coding for Calendar and the directory eds/servers/groupwise where the APIs for GroupWise server interaction are defined. As always, expecting your valuable review comments.
Thanks,
Sankar P
Index: servers/groupwise/e-gw-connection.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-connection.c,v
retrieving revision 1.124
diff -u -p -r1.124 e-gw-connection.c
--- servers/groupwise/e-gw-connection.c 8 Jul 2005 08:07:01 -0000 1.124
+++ servers/groupwise/e-gw-connection.c 8 Jul 2005 12:37:52 -0000
@@ -36,7 +36,7 @@
static GObjectClass *parent_class = NULL;
-static GHashTable *loaded_connections = NULL;
+static GHashTable *loaded_connections_permissions = NULL;
struct _EGwConnectionPrivate {
SoupSession *soup_session;
@@ -221,16 +221,16 @@ e_gw_connection_dispose (GObject *object
printf ("gw connection dispose \n");
/* removed the connection from the hash table */
- if (loaded_connections != NULL) {
+ if (loaded_connections_permissions != NULL) {
hash_key = g_strdup_printf ("%s:%s %s",
priv->username ? priv->username : "",
priv->password ? priv->password : "",
priv->uri);
- if (g_hash_table_lookup_extended (loaded_connections, hash_key, &orig_key, &orig_value)) {
- g_hash_table_remove (loaded_connections, hash_key);
- if (g_hash_table_size (loaded_connections) == 0) {
- g_hash_table_destroy (loaded_connections);
- loaded_connections = NULL;
+ if (g_hash_table_lookup_extended (loaded_connections_permissions, hash_key, &orig_key, &orig_value)) {
+ g_hash_table_remove (loaded_connections_permissions, hash_key);
+ if (g_hash_table_size (loaded_connections_permissions) == 0) {
+ g_hash_table_destroy (loaded_connections_permissions);
+ loaded_connections_permissions = NULL;
}
g_free (orig_key);
@@ -418,12 +418,12 @@ e_gw_connection_new (const char *uri, co
g_static_mutex_lock (&connecting);
/* search the connection in our hash table */
- if (loaded_connections != NULL) {
+ if (loaded_connections_permissions != NULL) {
hash_key = g_strdup_printf ("%s:%s %s",
username ? username : "",
password ? password : "",
uri);
- cnc = g_hash_table_lookup (loaded_connections, hash_key);
+ cnc = g_hash_table_lookup (loaded_connections_permissions, hash_key);
g_free (hash_key);
if (E_IS_GW_CONNECTION (cnc)) {
@@ -527,14 +527,14 @@ e_gw_connection_new (const char *uri, co
if (param)
cnc->priv->server_time = soup_soap_parameter_get_string_value (param);
- /* add the connection to the loaded_connections hash table */
+ /* add the connection to the loaded_connections_permissions hash table */
hash_key = g_strdup_printf ("%s:%s %s",
cnc->priv->username ? cnc->priv->username : "",
cnc->priv->password ? cnc->priv->password : "",
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);
+ if (loaded_connections_permissions == NULL)
+ loaded_connections_permissions = g_hash_table_new (g_str_hash, g_str_equal);
+ g_hash_table_insert (loaded_connections_permissions, hash_key, cnc);
/* free memory */
g_object_unref (response);
@@ -3477,5 +3477,424 @@ e_gw_connection_read_ical_ids (EGwConnec
g_object_unref (msg);
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;
+
+ 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);
+
+ param = soup_soap_response_get_first_parameter_by_name (response, "accessRights");
+ if (!param) {
+ g_object_unref (response);
+ return status;
+ } else {
+ e_gw_proxy_construct_proxy_access_list (param, proxy_list);
+ }
+ /* free memory */
+ if (response)
+ g_object_unref (response);
+ if (msg)
+ g_object_unref (msg);
+ return status;
+}
+
+EGwConnectionStatus
+e_gw_connection_add_proxy (EGwConnection *cnc, proxyHandler *new_proxy)
+{
+ SoupSoapMessage *msg = NULL;
+ SoupSoapResponse *response = NULL;
+ 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), "createProxyAccessRequest");
+
+ e_gw_proxy_form_proxy_add_msg (msg, new_proxy);
+
+ 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_remove_proxy (EGwConnection *cnc, proxyHandler *removeProxy)
+{
+ 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_proxy_form_proxy_remove_msg (msg, removeProxy);
+
+ 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_connection_modify_proxy (EGwConnection *cnc, proxyHandler *new_proxy)
+{
+ SoupSoapMessage *msg = NULL;
+ SoupSoapResponse *response = NULL;
+ 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), "modifyProxyAccessRequest");
+ e_gw_message_write_string_parameter (msg, "id", NULL, new_proxy->uniqueid);
+
+ e_gw_proxy_form_modify_proxy_msg (msg, new_proxy);
+
+ 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;
+
+ 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");
+ e_gw_proxy_construct_proxy_list (param, proxy_info);
+ 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;
+ char *permissions_key = NULL;
+
+ 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);
+ else
+ name = g_strdup (proxy);
+ /* search the connection in our hash table */
+ if (loaded_connections_permissions != NULL) {
+ hash_key = g_strdup_printf ( "%s:%s %s",
+ name,
+ "",
+ parent_cnc->priv->uri);
+ cnc = g_hash_table_lookup (loaded_connections_permissions, hash_key);
+ permissions_key = g_strdup_printf ("%s:permissions", hash_key);
+ g_free (hash_key);
+
+ if (E_IS_GW_CONNECTION (cnc)) {
+ *permissions = GPOINTER_TO_INT (g_hash_table_lookup (loaded_connections_permissions, permissions_key));
+ g_free (permissions_key);
+ g_object_ref (cnc);
+ g_static_mutex_unlock (&connecting);
+ return cnc;
+ }
+ g_free (permissions_key);
+ }
+
+ /* 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;
+ }
+ *permissions = 0;
+ 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_permissions hash table */
+ hash_key = g_strdup_printf ("%s:%s %s",
+ name,
+ "",
+ cnc->priv->uri);
+
+ g_hash_table_insert (loaded_connections_permissions, hash_key, cnc);
+
+ permissions_key = g_strdup_printf ("%s:permissions", hash_key);
+ g_hash_table_insert (loaded_connections_permissions, permissions_key, GINT_TO_POINTER(*permissions));
+
+ /* free memory */
+ g_object_unref (response);
+ g_object_unref (msg);
+ g_static_mutex_unlock (&connecting);
+ return cnc;
+}
+
Index: servers/groupwise/e-gw-connection.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-connection.h,v
retrieving revision 1.63
diff -u -p -r1.63 e-gw-connection.h
--- servers/groupwise/e-gw-connection.h 8 Jul 2005 08:07:02 -0000 1.63
+++ servers/groupwise/e-gw-connection.h 8 Jul 2005 12:37:52 -0000
@@ -26,6 +26,7 @@
#include <glib-object.h>
#include <libsoup/soup-soap-message.h>
+#include "e-gw-proxy.h"
#include "e-gw-container.h"
#include "e-gw-item.h"
#include "e-gw-filter.h"
@@ -166,6 +167,13 @@ EGwConnectionStatus e_gw_connection_modi
EGwConnectionStatus e_gw_connection_get_junk_entries (EGwConnection *cnc, GList **entries);
EGwConnectionStatus e_gw_connection_remove_junk_entry (EGwConnection *cnc, const char *id);
EGwConnectionStatus e_gw_connection_read_ical_ids (EGwConnection *cnc, const char *container, int cursor, gboolean forward, int count, const char *cursor_seek, GList **list);
+EGwConnectionStatus e_gw_connection_get_proxy_access_list (EGwConnection *cnc, GList **proxy_list);
+EGwConnectionStatus e_gw_connection_add_proxy (EGwConnection *cnc, proxyHandler *new_proxy);
+EGwConnectionStatus e_gw_connection_remove_proxy (EGwConnection *cnc, proxyHandler *newProxy);
+EGwConnectionStatus e_gw_connection_modify_proxy (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: servers/groupwise/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/ChangeLog,v
retrieving revision 1.149
diff -u -p -r1.149 ChangeLog
--- servers/groupwise/ChangeLog 8 Jul 2005 08:07:01 -0000 1.149
+++ servers/groupwise/ChangeLog 8 Jul 2005 12:37:53 -0000
@@ -1,3 +1,23 @@
+2005-07-08 Sankar P <psankar novell com>
+
+ * e-gw-connection.c :
+ Changed loaded_connections hashtable to loaded_connections_permissions,
+ since the hash-table is used to hold not only connections but also permissions
+ associated witha proxy login.
+ (form_proxy_login_request) : Added function to form a proxy login SOAP request.
+
+ * e-gw-connection.[ch] :
+ (e_gw_connection_get_proxy_connection)
+ (e_gw_connection_get_proxy_access_list)
+ (e_gw_connection_get_proxy_list) : Added functions to implement the proxy feature.
+
+2005-07-08 Shreyas Srinivasan <sshreyas novell com>
+
+ * e-gw-connection.[ch] :
+ (e_gw_connection_add_proxy)
+ (e_gw_connection_remove_proxy)
+ (e_gw_connection_modify_proxy) : Added functions to implement the proxy feature.
+
2005-07-08 Harish Krishnaswamy <kharish novell com>
* Makefile.am: Added the new files e-gw-recur-utils.[ch] for
Index: calendar/backends/groupwise/e-cal-backend-groupwise.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/groupwise/e-cal-backend-groupwise.c,v
retrieving revision 1.149
diff -u -p -r1.149 e-cal-backend-groupwise.c
--- calendar/backends/groupwise/e-cal-backend-groupwise.c 8 Jul 2005 06:28:03 -0000 1.149
+++ calendar/backends/groupwise/e-cal-backend-groupwise.c 8 Jul 2005 12:37:54 -0000
@@ -714,8 +714,12 @@ connect_to_server (ECalBackendGroupwise
ESource *source;
const char *use_ssl;
char *http_uri;
+ int permissions, flag;
GThread *thread;
GError *error = NULL;
+ char *user = NULL;
+ icalcomponent_kind kind;
+
priv = cbgw->priv;
source = e_cal_backend_get_source (E_CAL_BACKEND (cbgw));
@@ -723,28 +727,62 @@ connect_to_server (ECalBackendGroupwise
if (source)
real_uri = form_uri (source);
use_ssl = e_source_get_property (source, "use_ssl");
-
+
if (!real_uri) {
e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Invalid server URI"));
return GNOME_Evolution_Calendar_NoSuchCal;
} else {
+ user = (char *) e_source_get_property (source, "parent_id_name");
/* create connection to server */
- priv->cnc = e_gw_connection_new (
- real_uri,
- priv->username,
- priv->password);
-
- if (!E_IS_GW_CONNECTION(priv->cnc) && use_ssl && g_str_equal (use_ssl, "when-possible")) {
- http_uri = g_strconcat ("http://", real_uri + 8, NULL);
- priv->cnc = e_gw_connection_new (http_uri, priv->username, priv->password);
- g_free (http_uri);
+ if (user) {
+ EGwConnection *cnc;
+ /* create connection to server */
+ cnc = e_gw_connection_new (real_uri, user, priv->password);
+ if (!E_IS_GW_CONNECTION(cnc) && use_ssl && g_str_equal (use_ssl, "when-possible")) {
+ http_uri = g_strconcat ("http://", real_uri + 8, NULL);
+ cnc = e_gw_connection_new (http_uri, user, priv->password);
+ g_free (http_uri);
+ }
+
+ if (!cnc) {
+ e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Authentication failed"));
+ return GNOME_Evolution_Calendar_AuthenticationFailed;
+ }
+
+ priv->cnc = e_gw_proxy_connection_new (cnc, user, priv->password, priv->username, &permissions);
+
+ g_object_unref(cnc);
+
+ if (!priv->cnc) {
+ e_cal_backend_notify_error (E_CAL_BACKEND (cbgw), _("Authentication failed"));
+ return GNOME_Evolution_Calendar_AuthenticationFailed;
+ }
+
+ kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
+
+ cbgw->priv->read_only = TRUE;
+
+ if (kind == ICAL_VEVENT_COMPONENT && (permissions & PROXY_APPOINTMENT_WRITE) )
+ cbgw->priv->read_only = FALSE;
+ else if (kind == ICAL_VTODO_COMPONENT && (permissions & PROXY_TASK_WRITE))
+ cbgw->priv->read_only = FALSE;
+
+ } else {
+
+ priv->cnc = e_gw_connection_new (
+ real_uri,
+ priv->username,
+ priv->password);
+
+ if (!E_IS_GW_CONNECTION(priv->cnc) && use_ssl && g_str_equal (use_ssl, "when-possible")) {
+ http_uri = g_strconcat ("http://", real_uri + 8, NULL);
+ priv->cnc = e_gw_connection_new (http_uri, priv->username, priv->password);
+ g_free (http_uri);
+ }
+ cbgw->priv->read_only = FALSE;
}
g_free (real_uri);
- /* As of now we are assuming that logged in user has write rights to calender */
- /* we need to read actual rights from server when we implement proxy user access */
- cbgw->priv->read_only = FALSE;
-
if (priv->cnc && priv->cache && priv->container_id) {
char *utc_str;
priv->mode = CAL_MODE_REMOTE;
Index: calendar/libecal/e-cal.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libecal/e-cal.c,v
retrieving revision 1.103
diff -u -p -r1.103 e-cal.c
--- calendar/libecal/e-cal.c 2 Jul 2005 07:08:11 -0000 1.103
+++ calendar/libecal/e-cal.c 8 Jul 2005 12:37:56 -0000
@@ -1563,7 +1563,7 @@ open_calendar (ECal *ecal, gboolean only
/* see if the backend needs authentication */
if ( (priv->mode != CAL_MODE_LOCAL) && e_source_get_property (priv->source, "auth")) {
- char *prompt, *key;
+ char *prompt, *key, *parent_source_url, *user;
priv->load_state = E_CAL_LOAD_AUTHENTICATING;
@@ -1587,8 +1587,14 @@ open_calendar (ECal *ecal, gboolean only
}
/* actually ask the client for authentication */
- prompt = g_strdup_printf (_("Enter password for %s (user %s)"),
- e_source_peek_name (priv->source), username);
+ user = e_source_get_property (priv->source, "parent_id_name");
+ if (user) {
+ prompt = g_strdup_printf (_("Enter password for %s to enable proxy for user %s"), e_source_peek_name (priv->source), user);
+
+ } else {
+ prompt = g_strdup_printf (_("Enter password for %s (user %s)"),
+ e_source_peek_name (priv->source), username);
+ }
key = e_source_get_uri (priv->source);
if (!key) {
e_calendar_remove_op (ecal, our_op);
@@ -4023,10 +4029,6 @@ e_cal_create_object (ECal *ecal, icalcom
status = our_op->status;
if (uid)
*uid = our_op->uid;
- else {
- g_free (our_op->uid);
- our_op->uid = NULL;
- }
e_calendar_remove_op (ecal, our_op);
g_mutex_unlock (our_op->mutex);
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.474
diff -u -p -r1.474 ChangeLog
--- calendar/ChangeLog 8 Jul 2005 06:28:02 -0000 1.474
+++ calendar/ChangeLog 8 Jul 2005 12:37:57 -0000
@@ -1,4 +1,12 @@
2005-07-08 Sankar P <psankar novell com>
+
+ * libecal/e-cal.c: (open_calendar)
+ Added a string which will be used for password prompt in case of a proxy account.
+
+ * backends/groupwise/e-cal-backend-groupwise.c: (connect_to_server)
+ Added code to set the backend permission based on the proxy rights with which a proxy can act.
+
+2005-07-08 Sankar P <psankar novell com>
* backends/groupwise/e-cal-backend-groupwise.c: (get_deltas)
Moved from getQuickMessages to combination of getItems and readCursor,
--- /dev/null 2005-03-20 01:06:14.000000000 +0530
+++ servers/groupwise/e-gw-proxy.c 2005-07-07 14:27:49.000000000 +0530
@@ -0,0 +1,327 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Authors :
+ * Sankar P <psankar novell com>
+ * Shreyas Srinivasan <sshreyas 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
+#include <string.h>
+#include "e-gw-proxy.h"
+#include "e-gw-message.h"
+
+void
+e_gw_proxy_construct_proxy_access_list (SoupSoapParameter *param, GList **proxy_list)
+{
+ /* parse the response and create the individual proxy accounts */
+ SoupSoapParameter *subparam;
+ SoupSoapParameter *type_param;
+ SoupSoapParameter *individualRights;
+ char *value;
+
+ *proxy_list = NULL;
+ 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);
+ }
+}
+
+void
+e_gw_proxy_construct_proxy_list (SoupSoapParameter *param, GList **proxy_info)
+{
+ SoupSoapParameter *subparam;
+ SoupSoapParameter *type_param;
+ char *value;
+
+ 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);
+ }
+ }
+}
+
+static void
+e_gw_proxy_form_soap_request_from_proxyHandler (SoupSoapMessage *msg, proxyHandler *new_proxy)
+{
+ gboolean added = FALSE;
+ 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);
+
+}
+
+void
+e_gw_proxy_form_proxy_add_msg (SoupSoapMessage *msg, proxyHandler *new_proxy)
+{
+ soup_soap_message_start_element (msg, "entry", NULL, NULL);
+
+ e_gw_proxy_form_soap_request_from_proxyHandler (msg, new_proxy);
+}
+
+void
+e_gw_proxy_form_proxy_remove_msg (SoupSoapMessage *msg, proxyHandler *removeProxy)
+{
+ e_gw_message_write_string_parameter (msg, "id", NULL, removeProxy->uniqueid);
+}
+
+void
+e_gw_proxy_form_modify_proxy_msg (SoupSoapMessage *msg, proxyHandler *new_proxy)
+{
+ soup_soap_message_start_element (msg, "updates", NULL, NULL);
+
+ e_gw_proxy_form_soap_request_from_proxyHandler (msg, new_proxy);
+}
Index: servers/groupwise/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/Makefile.am,v
retrieving revision 1.13
diff -u -p -r1.13 Makefile.am
--- servers/groupwise/Makefile.am 8 Jul 2005 08:07:02 -0000 1.13
+++ servers/groupwise/Makefile.am 8 Jul 2005 12:42:51 -0000
@@ -36,7 +36,9 @@ libegroupwise_1_2_la_SOURCES = \
e-gw-filter.c \
e-gw-filter.h \
e-gw-recur-utils.c \
- e-gw-recur-utils.h
+ e-gw-recur-utils.h \
+ e-gw-proxy.h \
+ e-gw-proxy.c
libegroupwise_1_2_la_LIBADD = \
$(E_DATA_SERVER_LIBS) \
@@ -54,7 +56,8 @@ libegroupwiseinclude_HEADERS =
e-gw-item.h \
e-gw-sendoptions.h \
e-gw-filter.h \
- e-gw-recur-utils.h
+ e-gw-recur-utils.h \
+ e-gw-proxy.h
%-$(API_VERSION).pc: %.pc
cp $< $@
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]