added a function to share a folder (e_gw_connection_share_folder) Added
authorVivek Jain <jvivek@novell.com>
Mon, 3 Jan 2005 13:20:20 +0000 (13:20 +0000)
committerJain Vivek <jvivek@src.gnome.org>
Mon, 3 Jan 2005 13:20:20 +0000 (13:20 +0000)
2005-01-03  Vivek Jain <jvivek@novell.com>

       * e-gw-connection.[ch] : added a function to share a folder
         (e_gw_connection_share_folder)
       * e-gw-container.[ch] : Added One structure for reperenting a user
        corresponding to a folder (EShUsers),
        Added functions
       (e_gw_container_get_user_list) : gets list of users for a folder
       (e_gw_container_get_owner): gets owner of the folder
       (e_gw_container_get_modified) : gets when modified last
       (e_gw_container_get_sequence) : gets the sequence of the folder
       (e_gw_container_get_is_shared_by_me)
       (e_gw_container_get_is_shared_to_me)
       (e_gw_container_get_rights)
       (e_gw_container_form_message) : to form the request message
        and for setting these the following static methods in
       * e-gw-container.c
        (e_gw_container_set_owner)
        (e_gw_container_set_modified)
        (e_gw_container_set_sequence)
        (e_gw_container_set_is_shared_by_me)
        (e_gw_container_set_is_shared_to_me)

servers/groupwise/ChangeLog
servers/groupwise/e-gw-connection.c
servers/groupwise/e-gw-connection.h
servers/groupwise/e-gw-container.c
servers/groupwise/e-gw-container.h

index e49ccf0..3378f6a 100644 (file)
@@ -1,3 +1,28 @@
+2005-01-03  Vivek Jain <jvivek@novell.com>
+
+       * e-gw-connection.[ch] : added a function to share a folder
+       (e_gw_connection_share_folder)
+       
+       *e-gw-container.[ch] : Added One structure for reperenting a user
+       corresponding to a folder (EShUsers),
+       Added functions 
+       (e_gw_container_get_user_list) : gets list of users for a folder
+       (e_gw_container_get_owner): gets owner of the folder
+       (e_gw_container_get_modified) : gets when modified last
+       (e_gw_container_get_sequence) : gets the sequence of the folder
+       (e_gw_container_get_is_shared_by_me)
+       (e_gw_container_get_is_shared_to_me)
+       (e_gw_container_get_rights)
+       (e_gw_container_form_message) : to form the request message
+
+       and for setting these the following static methods in 
+       * e-gw-container.c 
+       (e_gw_container_set_owner)
+       (e_gw_container_set_modified)
+       (e_gw_container_set_sequence) 
+       (e_gw_container_set_is_shared_by_me)
+       (e_gw_container_set_is_shared_to_me) 
+       
 2004-12-15  Chenthill Palanisamy <pchenthill@novell.com>
 
        * e-gw-item.c:
index 0e32500..348799f 100644 (file)
@@ -2094,3 +2094,29 @@ e_gw_connection_add_item (EGwConnection *cnc, const char *container, const char
        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 82c7e50..c35fab9 100644 (file)
@@ -119,6 +119,7 @@ EGwConnectionStatus e_gw_connection_get_quick_messages (EGwConnection *cnc, cons
 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
index 7c4ab45..97ee79f 100644 (file)
 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,242 @@ e_gw_container_set_from_soap_parameter (EGwContainer *container, SoupSoapParamet
                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)
+                                               g_warning (G_STRLOC ": User without any Rights");
+                                       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");
+
+               if (subparam) { 
+                       int_value = soup_soap_parameter_get_int_value (subparam);
+                       e_gw_container_set_sequence (container, int_value);             
+               }
+
+               return TRUE;
+       }
 
-       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 *
@@ -298,5 +551,125 @@ gboolean
 e_gw_container_is_root (EGwContainer *container)
 {
        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 entry
+ * flag = 2 :update entry
+ * 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 == 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 == 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 == 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 47245cb..86848e5 100644 (file)
@@ -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_writable (EGwContainer *container, gboolean
 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