[evolution-patches] Re: Revised patch for the e-d-s changes to support shared folders
- From: Vivek Jain <jvivek novell com>
- To: evolution-patches lists ximian com
- Subject: [evolution-patches] Re: Revised patch for the e-d-s changes to support shared folders
- Date: Mon, 03 Jan 2005 14:05:18 +0530
Sorry, I had attached the wrong file.
Attached herewith is the proper file.
Thanks,
Vivek
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 -p -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 08:00:04 -0000
@@ -30,14 +30,27 @@
struct _EGwContainerPrivate {
char *name;
char *id;
- char *parent ;
+ char *parent;
+ int sequence;
+ char *owner;
+ GList *user_list;
+ const char *modified;
gboolean is_root ;
gboolean is_writable;
gboolean is_frequent_contacts; /*indicates whether this folder is frequent contacts or not */
+ gboolean is_shared_by_me;
+ gboolean is_shared_to_me;
+
};
static GObjectClass *parent_class = NULL;
+static void e_gw_container_set_sequence (EGwContainer *container, int sequence);
+static void e_gw_container_set_modified (EGwContainer *container, const char *modified);
+static void e_gw_container_set_owner(EGwContainer *container, const char *owner);
+static void e_gw_container_set_is_shared_by_me (EGwContainer *container, gboolean is_shared_by_me);
+static void e_gw_container_set_is_shared_to_me (EGwContainer *container, gboolean is_shared_to_me);
+
static void
e_gw_container_dispose (GObject *object)
{
@@ -146,12 +159,18 @@ gboolean
e_gw_container_set_from_soap_parameter (EGwContainer *container, SoupSoapParameter *param)
{
char *value;
+ int int_value;
+ int rights = 0;
+ gboolean byme = FALSE;
+ gboolean tome = FALSE;
SoupSoapParameter *subparam;
+ SoupSoapParameter *entry_subparam;
+ SoupSoapParameter *email_rt_subparam;
+ SoupSoapParameter *rights_subparam;
g_return_val_if_fail (E_IS_GW_CONTAINER (container), FALSE);
g_return_val_if_fail (param != NULL, FALSE);
-
/* retrieve the name */
subparam = soup_soap_parameter_get_first_child_by_name (param, "name");
if (!subparam) {
@@ -186,8 +205,235 @@ e_gw_container_set_from_soap_parameter (
e_gw_container_set_parent_id (container, (const char *) value);
g_free (value) ;
}
+/* Is shared by me*/
+ subparam = soup_soap_parameter_get_first_child_by_name (param, "isSharedByMe");
+ if (!subparam) {
+ e_gw_container_set_is_shared_by_me(container, FALSE);
+
+ } else {
+ value = soup_soap_parameter_get_string_value (subparam);
+ if (value) {
+ e_gw_container_set_is_shared_by_me (container, TRUE);
+ byme = TRUE;
+ } else {
+ e_gw_container_set_is_shared_by_me (container, FALSE);
+ byme = FALSE;
+ }
+
+ g_free (value);
+ }
+ /* is shared to me*/
+ subparam = soup_soap_parameter_get_first_child_by_name (param, "isSharedToMe");
+
+ if (!subparam) {
+ e_gw_container_set_is_shared_to_me (container, FALSE);
+
+ } else {
+ value = soup_soap_parameter_get_string_value (subparam);
+ if (value) {
+ e_gw_container_set_is_shared_to_me (container, TRUE);
+ tome = TRUE;
+ } else {
+ e_gw_container_set_is_shared_to_me (container, FALSE);
+ tome = FALSE;
+ }
+
+ g_free (value);
+ }
+ /*Retrieve email add of the sharing person*/
+ if (tome || byme) {
+ subparam = soup_soap_parameter_get_first_child_by_name (param, "acl");
+ if (!subparam)
+ g_warning (G_STRLOC ": No ACL");
+
+ else {
+ for (entry_subparam = soup_soap_parameter_get_first_child_by_name (subparam, "entry");
+ entry_subparam != NULL;
+ entry_subparam = soup_soap_parameter_get_next_child_by_name (entry_subparam, "entry")) {
+
+ EShUsers *user = g_new0(EShUsers , 1);
+ email_rt_subparam = soup_soap_parameter_get_first_child_by_name (entry_subparam, "email");
+
+ if (!email_rt_subparam) {
+ g_warning (G_STRLOC ":Email Tag Not Available");
+ } else {
+ value = soup_soap_parameter_get_string_value (email_rt_subparam);
+ if (value) {
+ user->email = g_strdup (value);
+ g_free (value);
+ }
+ /* Retrieve Rights*/
+ email_rt_subparam = soup_soap_parameter_get_first_child_by_name (entry_subparam, "rights");
+
+ if (!email_rt_subparam)
+ break;
+ else {
+ rights = 0;
+ rights_subparam = soup_soap_parameter_get_first_child_by_name (email_rt_subparam, "add");
+ if (rights_subparam)
+ rights = rights | 0x1;
+
+ rights_subparam = soup_soap_parameter_get_first_child_by_name (email_rt_subparam, "edit");
+ if (rights_subparam)
+ rights = rights | 0x2;
+
+ rights_subparam = soup_soap_parameter_get_first_child_by_name (email_rt_subparam, "delete");
+ if (rights_subparam)
+ rights = rights | 0x4;
+
+ user->rights = rights;
+ }
+
+ container->priv->user_list = g_list_append (container->priv->user_list, user);
+
+ }
+
+ }
+
+ }
+
+ /*Retrieve owner*/
+ subparam = soup_soap_parameter_get_first_child_by_name (param, "owner");
+ if (subparam) {
+ value = soup_soap_parameter_get_string_value (subparam);
+ e_gw_container_set_owner (container, value);
+ g_free (value);
+ }
+ }
+
+ /* shared folder*/
+ /*Retrieve When Modified last*/
+ subparam = soup_soap_parameter_get_first_child_by_name (param, "modified");
+
+ if (subparam) {
+ value = soup_soap_parameter_get_string_value (subparam);
+ e_gw_container_set_modified (container, (const char *) value);
+ g_free (value);
+ }
+
+ /*retrieve sequence*/
+ subparam = soup_soap_parameter_get_first_child_by_name (param, "sequence");
- return TRUE;
+ if (subparam) {
+ int_value = soup_soap_parameter_get_int_value (subparam);
+ e_gw_container_set_sequence (container, int_value);
+ }
+
+ return TRUE;
+ }
+
+void
+e_gw_container_get_user_list (EGwContainer *container, GList **user_list)
+{
+ g_return_if_fail (E_GW_CONTAINER (container));
+ *user_list = container->priv->user_list;
+
+}
+
+int
+e_gw_container_get_sequence (EGwContainer *container)
+{
+ g_return_val_if_fail (E_IS_GW_CONTAINER (container), 0);
+ return (int)container->priv->sequence;
+}
+
+static void
+e_gw_container_set_sequence (EGwContainer *container, int sequence)
+{
+ g_return_if_fail (E_IS_GW_CONTAINER (container));
+ container->priv->sequence = sequence;
+}
+
+const char *
+e_gw_container_get_modified (EGwContainer *container)
+{
+ g_return_val_if_fail (E_IS_GW_CONTAINER (container), NULL);
+
+ return (const char *) container->priv->modified;
+}
+
+static void
+e_gw_container_set_modified (EGwContainer *container, const char *modified)
+{
+ EGwContainerPrivate *priv;
+
+ g_return_if_fail (E_IS_GW_CONTAINER (container));
+ g_return_if_fail (modified != NULL);
+
+ priv = container->priv;
+
+ if (priv->modified)
+ g_free (priv->modified);
+ priv->modified = g_strdup (modified);
+}
+
+static void
+e_gw_container_set_owner(EGwContainer *container, const char *owner)
+{
+ EGwContainerPrivate *priv;
+ g_return_if_fail (E_IS_GW_CONTAINER(container));
+ g_return_if_fail (owner!=NULL);
+ priv = container->priv;
+ if (priv->owner)
+ g_free (container->priv->owner);
+ container->priv->owner = g_strdup (owner);
+}
+
+const char *
+e_gw_container_get_owner (EGwContainer *container)
+{
+ g_return_val_if_fail (E_GW_CONTAINER (container), NULL);
+ return (const char *) container->priv->owner;
+}
+
+int
+e_gw_container_get_rights (EGwContainer *container, gchar *email)
+{
+ GList *user_list = NULL;
+ GList *node = NULL;
+ EShUsers *user = NULL;
+
+ g_return_val_if_fail (E_IS_GW_CONTAINER (container), 0);
+
+ user_list = container->priv->user_list;
+
+ for (node = user_list; node != NULL; node = node->next) {
+ user = node->data;
+ if( !strcmp (user->email, email))
+ return user->rights;
+ }
+
+ return 0;
+}
+
+gboolean
+e_gw_container_get_is_shared_by_me (EGwContainer *container)
+{
+ g_return_val_if_fail (E_IS_GW_CONTAINER (container), FALSE);
+
+ return (gboolean) container->priv->is_shared_by_me;
+}
+
+static void
+e_gw_container_set_is_shared_by_me (EGwContainer *container, gboolean is_shared_by_me)
+{
+ g_return_if_fail (E_IS_GW_CONTAINER (container));
+ container->priv->is_shared_by_me = is_shared_by_me;
+}
+
+gboolean
+e_gw_container_get_is_shared_to_me (EGwContainer *container)
+{
+ g_return_val_if_fail (E_IS_GW_CONTAINER (container), FALSE);
+
+ return (gboolean) container->priv->is_shared_to_me;
+}
+
+static void
+e_gw_container_set_is_shared_to_me (EGwContainer *container, gboolean is_shared_to_me)
+{
+ g_return_if_fail (E_IS_GW_CONTAINER (container));
+ container->priv->is_shared_to_me = is_shared_to_me;
}
const char *
@@ -299,4 +545,123 @@ e_gw_container_is_root (EGwContainer *co
{
g_return_val_if_fail (E_IS_GW_CONTAINER (container), FALSE) ;
return container->priv->is_root ;
+}
+
+/* flag specifies whether we are adding to acl or deleting one or more entries*/
+/* flag = 1 :delete single entry
+ * flag = 2 :delete all entries
+ * flag = 0 :add to acl
+ */
+void
+e_gw_container_form_message (SoupSoapMessage *msg, gchar *id, GList *new_list, const char *sub, const char *mesg, int flag)
+{
+ gboolean add, edit, del;
+ gchar *email = NULL;
+ GList *node = NULL;
+ EShUsers *user = NULL;
+
+ e_gw_message_write_string_parameter (msg, "id", NULL, id);
+ soup_soap_message_start_element (msg, "notification", NULL, NULL);
+ e_gw_message_write_string_parameter (msg, "subject", NULL, sub);
+ e_gw_message_write_string_parameter (msg, "message", NULL, mesg);
+ soup_soap_message_end_element (msg);
+ soup_soap_message_start_element (msg, "updates", NULL, NULL);
+
+ if (flag == 1) {
+ soup_soap_message_start_element (msg, "delete", NULL, NULL);
+ soup_soap_message_start_element (msg, "acl", NULL, NULL);
+
+ for (node = new_list; node != NULL; node = node->next) {
+ user = node->data;
+ add = edit = del = FALSE;
+ soup_soap_message_start_element (msg, "entry", NULL, NULL);
+ e_gw_message_write_string_parameter (msg, "displayName", NULL, "name");
+ email = g_strdup (user->email);
+
+ if(user->rights & 0x1)
+ add = TRUE;
+ if(user->rights & 0x2)
+ edit = TRUE;
+ if(user->rights & 0x4)
+ del = TRUE;
+
+ e_gw_message_write_string_parameter (msg, "email", NULL, email);
+ soup_soap_message_start_element(msg, "rights", NULL, NULL);
+ e_gw_message_write_int_parameter (msg, "read", NULL, 1);
+ e_gw_message_write_int_parameter (msg, "add", NULL, add);
+ e_gw_message_write_int_parameter (msg, "edit", NULL, edit);
+ e_gw_message_write_int_parameter (msg, "delete", NULL, del);
+
+ soup_soap_message_end_element (msg);
+ soup_soap_message_end_element (msg);
+
+ }
+ soup_soap_message_end_element (msg);
+ soup_soap_message_end_element (msg);
+
+ } else if (flag == 0) {
+ soup_soap_message_start_element (msg, "add", NULL, NULL);
+ soup_soap_message_start_element (msg, "acl", NULL, NULL);
+
+ for (node = new_list; node != NULL; node = node->next) {
+ user = node->data;
+ add=edit=del=FALSE;
+ soup_soap_message_start_element (msg, "entry", NULL, NULL);
+ e_gw_message_write_string_parameter (msg, "displayName", NULL,"");
+ email = g_strdup (user->email);
+ if (user->rights & 0x1)
+ add = TRUE;
+ if (user->rights & 0x2)
+ edit = TRUE;
+ if (user->rights & 0x4)
+ del = TRUE;
+
+ e_gw_message_write_string_parameter (msg, "email", NULL, email);
+ soup_soap_message_start_element (msg, "rights", NULL, NULL);
+ e_gw_message_write_int_parameter (msg, "read", NULL, 1);
+ e_gw_message_write_int_parameter (msg, "add", NULL, add);
+ e_gw_message_write_int_parameter (msg, "edit", NULL, edit);
+ e_gw_message_write_int_parameter (msg, "delete", NULL, del);
+
+ soup_soap_message_end_element (msg);
+ soup_soap_message_end_element (msg);
+ }
+
+ soup_soap_message_end_element (msg);
+ soup_soap_message_end_element (msg);
+
+ } else if (flag == 2) {
+ soup_soap_message_start_element (msg, "update", NULL, NULL);
+ soup_soap_message_start_element (msg, "acl", NULL, NULL);
+
+ for (node = new_list; node != NULL; node = node->next) {
+ user = node->data;
+ add = edit = del = FALSE;
+ soup_soap_message_start_element (msg, "entry", NULL, NULL);
+ e_gw_message_write_string_parameter (msg, "displayName",NULL,"");
+ email = g_strdup (user->email);
+ if (user->rights & 0x1)
+ add = TRUE;
+ if (user->rights & 0x2)
+ edit = TRUE;
+ if (user->rights & 0x4)
+ del =TRUE;
+
+ e_gw_message_write_string_parameter (msg, "email", NULL, email);
+ soup_soap_message_start_element (msg, "rights", NULL, NULL);
+ e_gw_message_write_int_parameter (msg, "read", NULL, 1);
+ e_gw_message_write_int_parameter (msg, "add", NULL, add);
+ e_gw_message_write_int_parameter (msg, "edit", NULL, edit);
+ e_gw_message_write_int_parameter (msg, "delete", NULL, del);
+
+ soup_soap_message_end_element (msg);
+ soup_soap_message_end_element (msg);
+ }
+
+ soup_soap_message_end_element (msg);
+ soup_soap_message_end_element (msg);
+
+ }
+
+ soup_soap_message_end_element (msg);
}
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 -p -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 08:00:04 -0000
@@ -25,6 +25,7 @@
#define E_GW_CONTAINER_H
#include <libsoup/soup-soap-response.h>
+#include <libsoup/soup-soap-message.h>
G_BEGIN_DECLS
@@ -34,6 +35,7 @@ G_BEGIN_DECLS
#define E_IS_GW_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_GW_CONTAINER))
#define E_IS_GW_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_GW_CONTAINER))
+typedef struct _EShUsers EShUsers;
typedef struct _EGwContainer EGwContainer;
typedef struct _EGwContainerClass EGwContainerClass;
typedef struct _EGwContainerPrivate EGwContainerPrivate;
@@ -47,6 +49,11 @@ struct _EGwContainerClass {
GObjectClass parent_class;
};
+struct _EShUsers {
+ char *email;
+ int rights;
+};
+
GType e_gw_container_get_type (void);
EGwContainer *e_gw_container_new_from_soap_parameter (SoupSoapParameter *param);
gboolean e_gw_container_set_from_soap_parameter (EGwContainer *container,
@@ -62,6 +69,14 @@ void e_gw_container_set_is_writ
gboolean e_gw_container_get_is_frequent_contacts (EGwContainer *container);
void e_gw_container_set_is_frequent_contacts (EGwContainer *container, gboolean is_frequent_contacts);
gboolean e_gw_container_is_root (EGwContainer *container) ;
+const char * e_gw_container_get_owner(EGwContainer *container);
+const char * e_gw_container_get_modified(EGwContainer *container);
+int e_gw_container_get_sequence(EGwContainer *container);
+gboolean e_gw_container_get_is_shared_by_me(EGwContainer *container);
+gboolean e_gw_container_get_is_shared_to_me(EGwContainer *container);
+int e_gw_container_get_rights(EGwContainer *container, gchar *email);
+void e_gw_container_get_user_list(EGwContainer *container, GList **user_list);
+void e_gw_container_form_message (SoupSoapMessage *msg, gchar *id, GList *new_list, const char *sub, const char *mesg, int flag);
G_END_DECLS
Index: e-gw-connection.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-connection.c,v
retrieving revision 1.89
diff -u -p -r1.89 e-gw-connection.c
--- e-gw-connection.c 6 Dec 2004 01:31:31 -0000 1.89
+++ e-gw-connection.c 3 Jan 2005 08:00:05 -0000
@@ -2094,3 +2094,29 @@ e_gw_connection_add_item (EGwConnection
return status;
}
+EGwConnectionStatus
+e_gw_connection_share_folder(EGwConnection *cnc, gchar *id, GList *new_list, const char *sub, const char *mesg ,int flag)
+{
+ SoupSoapMessage *msg;
+ SoupSoapResponse *response;
+ EGwConnectionStatus status = 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), "modifyItemRequest");
+ e_gw_container_form_message (msg, id, new_list, sub, mesg, flag);
+ 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 (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
+ reauthenticate (cnc);
+ /* free memory */
+ g_object_unref (response);
+ g_object_unref (msg);
+
+ return status;
+}
Index: e-gw-connection.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/e-gw-connection.h,v
retrieving revision 1.39
diff -u -p -r1.39 e-gw-connection.h
--- e-gw-connection.h 6 Dec 2004 01:31:31 -0000 1.39
+++ e-gw-connection.h 3 Jan 2005 08:00:05 -0000
@@ -119,6 +119,7 @@ EGwConnectionStatus e_gw_connection_get_
EGwConnectionStatus e_gw_connection_create_folder(EGwConnection *cnc, const char *parent_name,const char *folder_name, char **container_id) ;
EGwConnectionStatus e_gw_connection_get_attachment (EGwConnection *cnc, const char *id, int offset, int length, const char **attachment, int *attach_lenght) ;
EGwConnectionStatus e_gw_connection_add_item (EGwConnection *cnc, const char *container, const char *id) ;
+EGwConnectionStatus e_gw_connection_share_folder (EGwConnection *cnc, gchar *id, GList *new_list, const char *sub, const char *mesg ,int flag);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]