[evolution-patches] Patch for implementation of update of Cache in GW backend



The following patch comprises the implementation of the cache_update
feature in the GW backend including changes to use GList instead of
GSList, so the interfaces remain consistent with the other backends and
the ECalBackend type.

harish

? backends/groupwise/1.diff
? backends/groupwise/groupwise-config-listener.loT
? backends/groupwise/methods.xsd
? backends/groupwise/ref-docs
? backends/groupwise/types.xsd
? libedata-cal/getComponents.diff
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.141
diff -u -p -r1.141 ChangeLog
--- ChangeLog	21 Jan 2004 23:37:42 -0000	1.141
+++ ChangeLog	22 Jan 2004 06:17:02 -0000
@@ -1,3 +1,23 @@
+2004-01-22 Harish K <kharish novell com>
+        * calendar/backends/groupwise/e-cal-backend-groupwise.c
+          (populate_cache, e_cal_backend_groupwise_get_object_list,
+          e_cal_backend_groupwise_get_free_busy ) :changed
implementation
+          to use GList instead of GSList, aligning to the rest of the
+          backends.
+          (e_cal_backend_groupwise_get_changes, update_cache):
implemented.
+        * calendar/backends/groupwise/e-gw-connection.c
+          (get_attendee_list_from_soap_parameter) : modified 
+          get_attendee_list_from_string to handle recipients element.
+          (get_e_cal_component_from_soap_parameter) -fixed memory
leaks.
+          (update_cache_item) : implemented.
+          (e_gw_connection_get_freebusy_info, start_freebusy_session)
+          GSList to GList changes.
+        * calendar/backends/groupwise/e-gw-connection.h : updated 
+          declarations for the above changes.
+        * calendar/libedata-cal/e-cal-backend-cache.[ch] :
+          (e_cal_backend_cache_get_components) : return GList instead
of
+          GSList.
+          
 2004-01-21  Rodrigo Moya <rodrigo ximian com>
 
 	* backends/groupwise/e-cal-backend-groupwise.c
Index: 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.31
diff -u -p -r1.31 e-cal-backend-groupwise.c
--- backends/groupwise/e-cal-backend-groupwise.c	21 Jan 2004 23:37:43
-0000	1.31
+++ backends/groupwise/e-cal-backend-groupwise.c	22 Jan 2004 06:17:02
-0000
@@ -68,16 +68,16 @@ populate_cache (ECalBackendGroupwisePriv
         ECalComponent *comp;
 	const char *uid;
 	char *rid;
-        GSList *list = NULL, *l;
+        GList *list = NULL, *l;
 
         /* get all the objects from the server */
         status = e_gw_connection_get_items (priv->cnc,
priv->container_id, NULL, &list);
         if (status != E_GW_CONNECTION_STATUS_OK) {
-                g_slist_free (list);
+                g_list_free (list);
                 return status;
         }
         
-        for (l = list; l != NULL; l = g_slist_next(l)) {
+        for (l = list; l != NULL; l = g_list_next(l)) {
                 comp = E_CAL_COMPONENT (l->data);
 		e_cal_component_get_uid (comp, &uid);
                 rid = g_strdup (e_cal_component_get_recurid_as_string
(comp));
@@ -87,7 +87,7 @@ populate_cache (ECalBackendGroupwisePriv
                 g_free (comp);
         }
         
-        g_slist_free (list);
+        g_list_free (list);
         return E_GW_CONNECTION_STATUS_OK;        
                                                                                                                     
 }
@@ -95,8 +95,13 @@ populate_cache (ECalBackendGroupwisePriv
 static EGwConnectionStatus 
 update_cache (gpointer *data)
 {
-        /* FIXME: to implemented using the getDeltas call */
-	return E_GW_CONNECTION_STATUS_OK;
+        ECalBackendGroupwise *cbgw;
+        EGwConnection *cnc;
+        EGwConnectionStatus status;
+	cbgw = E_CAL_BACKEND_GROUPWISE (data);
+        cnc = cbgw->priv->cnc;
+        status = e_gw_connection_get_deltas (cnc, cbgw->priv->cache);
+        return status;
 }
 
 static GnomeVFSURI *
@@ -307,6 +312,8 @@ e_cal_backend_groupwise_get_static_capab
 	return GNOME_Evolution_Calendar_Success;
 }
 
+
+
 /* Open handler for the file backend */
 static ECalBackendSyncStatus
 e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal,
gboolean only_if_exists,
@@ -577,12 +584,12 @@ match_object_sexp (gpointer key, gpointe
 
 /* Get_objects_in_range handler for the groupwise backend */
 static ECalBackendSyncStatus
-e_cal_backend_groupwise_get_object_list (ECalBackendSync *backend,
EDataCal *cal, const char *sexp, GSList **objects)
+e_cal_backend_groupwise_get_object_list (ECalBackendSync *backend,
EDataCal *cal, const char *sexp, GList **objects)
 {
 	ECalBackendGroupwise *cbgw;
 	ECalBackendGroupwisePrivate *priv;
 	MatchObjectData match_data;
-        GSList *l;
+        GList *l;
         
 	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
 	priv = cbgw->priv;
@@ -606,7 +613,7 @@ e_cal_backend_groupwise_get_object_list 
 		return GNOME_Evolution_Calendar_InvalidQuery;
 	}
 
-        for( l = e_cal_backend_cache_get_components (priv->cache); l !=
NULL; l = g_slist_next (l)) {
+        for( l = e_cal_backend_cache_get_components (priv->cache); l !=
NULL; l = g_list_next (l)) {
                 const char *uid;
                 ECalComponent *comp = E_CAL_COMPONENT (l);
                 e_cal_component_get_uid (comp, &uid);
@@ -627,7 +634,7 @@ e_cal_backend_groupwise_start_query (ECa
 	ECalBackendGroupwise *cbgw;
 	ECalBackendGroupwisePrivate *priv;
 	MatchObjectData match_data;
-        GSList *l;
+        GList *l;
 
 	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
 	priv = cbgw->priv;
@@ -669,8 +676,8 @@ e_cal_backend_groupwise_start_query (ECa
 
 /* Get_free_busy handler for the file backend */
 static ECalBackendSyncStatus
-e_cal_backend_groupwise_get_free_busy (ECalBackendSync *backend,
EDataCal *cal, GSList *users,
-				time_t start, time_t end, GSList **freebusy)
+e_cal_backend_groupwise_get_free_busy (ECalBackendSync *backend,
EDataCal *cal, GList *users,
+				time_t start, time_t end, GList **freebusy)
 {
        EGwConnectionStatus status;
        ECalBackendGroupwise *cbgw;
@@ -685,12 +692,115 @@ e_cal_backend_groupwise_get_free_busy (E
        return GNOME_Evolution_Calendar_Success; 
 }
 
-/* Get_changes handler for the file backend */
+typedef struct 
+{
+	ECalBackendGroupwise *backend;
+	icalcomponent_kind kind;
+	GList *deletes;
+	EXmlHash *ehash;
+} ECalBackendGroupwiseComputeChangesData;
+
+static void
+e_cal_backend_groupwise_compute_changes_foreach_key (const char *key,
gpointer data)
+{
+	ECalBackendGroupwiseComputeChangesData *be_data = data;
+                
+                if (!e_cal_backend_cache_get_component
(be_data->backend->priv->cache, key, NULL)) {
+		ECalComponent *comp;
+
+		comp = e_cal_component_new ();
+		if (be_data->kind == ICAL_VTODO_COMPONENT)
+			e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_TODO);
+		else
+			e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT);
+
+		e_cal_component_set_uid (comp, key);
+		be_data->deletes = g_list_prepend (be_data->deletes,
e_cal_component_get_as_string (comp));
+
+		e_xmlhash_remove (be_data->ehash, key);
+ 	}
+}
+
+static ECalBackendSyncStatus
+e_cal_backend_groupwise_compute_changes (ECalBackendGroupwise *cbgw,
const char *change_id,
+				  GList **adds, GList **modifies, GList **deletes)
+{
+        ECalBackendSyncStatus status;
+	ECalBackendCache *cache;
+	char    *filename;
+	EXmlHash *ehash;
+	ECalBackendGroupwiseComputeChangesData be_data;
+	GList *i, *list = NULL;
+	gchar *unescaped_uri;
+
+	cache = cbgw->priv->cache;
+
+	/* FIXME Will this always work? */
+	unescaped_uri = gnome_vfs_unescape_string (cbgw->priv->uri, "");
+	filename = g_strdup_printf ("%s-%s.db", unescaped_uri, change_id);
+	ehash = e_xmlhash_new (filename);
+	g_free (filename);
+	g_free (unescaped_uri);
+
+        status = e_cal_backend_groupwise_get_object_list
(E_CAL_BACKEND_SYNC (cbgw), NULL, NULL, &list);
+        if (status != GNOME_Evolution_Calendar_Success)
+                return status;
+        
+        /* Calculate adds and modifies */
+	for (i = list; i != NULL; i = g_list_next (i)) {
+		const char *uid;
+		char *calobj;
+
+		e_cal_component_get_uid (i->data, &uid);
+		calobj = e_cal_component_get_as_string (i->data);
+
+		g_assert (calobj != NULL);
+
+		/* check what type of change has occurred, if any */
+		switch (e_xmlhash_compare (ehash, uid, calobj)) {
+		case E_XMLHASH_STATUS_SAME:
+			break;
+		case E_XMLHASH_STATUS_NOT_FOUND:
+			*adds = g_list_prepend (*adds, g_strdup (calobj));
+			e_xmlhash_add (ehash, uid, calobj);
+			break;
+		case E_XMLHASH_STATUS_DIFFERENT:
+			*modifies = g_list_prepend (*modifies, g_strdup (calobj));
+			e_xmlhash_add (ehash, uid, calobj);
+			break;
+		}
+
+		g_free (calobj);
+	}
+
+	/* Calculate deletions */
+	be_data.backend = cbgw;
+	be_data.kind = e_cal_backend_get_kind (E_CAL_BACKEND (cbgw));
+	be_data.deletes = NULL;
+	be_data.ehash = ehash;
+   	e_xmlhash_foreach_key (ehash,
(EXmlHashFunc)e_cal_backend_groupwise_compute_changes_foreach_key,
&be_data);
+
+	*deletes = be_data.deletes;
+
+	e_xmlhash_write (ehash);
+  	e_xmlhash_destroy (ehash);
+	
+	return GNOME_Evolution_Calendar_Success;
+}
+
+/* Get_changes handler for the groupwise backend */
 static ECalBackendSyncStatus
 e_cal_backend_groupwise_get_changes (ECalBackendSync *backend, EDataCal
*cal, const char *change_id,
 				     GList **adds, GList **modifies, GList **deletes)
 {
-	return GNOME_Evolution_Calendar_OtherError;
+        ECalBackendGroupwise *cbgw;
+	cbgw = E_CAL_BACKEND_GROUPWISE (backend);
+
+	g_return_val_if_fail (E_IS_CAL_BACKEND_GROUPWISE (cbgw),
GNOME_Evolution_Calendar_InvalidObject);
+	g_return_val_if_fail (change_id != NULL,
GNOME_Evolution_Calendar_ObjectNotFound);
+
+	return e_cal_backend_groupwise_compute_changes (cbgw, change_id, adds,
modifies, deletes);
+
 }
 
 /* Discard_alarm handler for the file backend */
Index: backends/groupwise/e-gw-connection.c
===================================================================
RCS file:
/cvs/gnome/evolution-data-server/calendar/backends/groupwise/e-gw-connection.c,v
retrieving revision 1.37
diff -u -p -r1.37 e-gw-connection.c
--- backends/groupwise/e-gw-connection.c	21 Jan 2004 17:21:07 -0000	1.37
+++ backends/groupwise/e-gw-connection.c	22 Jan 2004 06:17:03 -0000
@@ -385,47 +385,50 @@ get_evo_date_from_string (const char * s
 }
 
 static GSList*
-get_attendee_list_from_string (const char *to_string)
+get_attendee_list_from_soap_parameter (SoupSoapParameter *param)
 {
-        /* String is of format <name>[;''<name>]*   */
+        SoupSoapParameter *param_recipient;
         GSList *list = NULL;
         ECalComponentAttendee *attendee;
-        char *user;
-        int i, j, len;
-        
-        len = strlen (to_string);
-        user = g_malloc0 (len);
-        for (i = 0, j = 0; i < len; i++) {
-                if (to_string[i] != ';') {
-                        user[j] = to_string[i];
-                        j++;
-                } else {
-                        ECalComponentAttendee *attendee;
-                        user[j] = '\0';
-                        attendee = g_malloc0( sizeof
(ECalComponentAttendee));
-                        /*FIXME to fill member, value etc we need more
data*/ 
-                        attendee->cn = g_strdup (user);
-                        list = g_slist_append (list, attendee);
-                        j = 0;
-                        i++; /* skips the space after ; */
+        const char *email, *cn;
+        for (param_recipient =
soup_soap_parameter_get_first_child_by_name (param, "recipient");
+                param_recipient != NULL;
+                param_recipient =
soup_soap_parameter_get_next_child_by_name (param, "recipient")) {
+
+                SoupSoapParameter *subparam;
+                attendee = g_malloc0 (sizeof (ECalComponentAttendee));
+                subparam = soup_soap_parameter_get_first_child_by_name
(param_recipient, "email");
+                if (subparam) {
+                        email = soup_soap_parameter_get_string_value
(subparam);
+                        attendee->value = g_strdup (email);
                 }        
-        }
+                subparam = soup_soap_parameter_get_first_child_by_name
(param_recipient, "displayName");
+                if (subparam) {
+                        cn = soup_soap_parameter_get_string_value
(subparam);
+                        attendee->cn = g_strdup (cn);
+                }
                 
-        user[j] = '\0';
-        attendee = g_malloc0( sizeof (ECalComponentAttendee));
-        attendee->cn = g_strdup (user);
-        list = g_slist_append (list, attendee);
-
-        g_free (user);
+                subparam = soup_soap_parameter_get_first_child_by_name
(param_recipient, "distType");
+                if (subparam) {
+                        const char *dist_type;
+                        dist_type =
soup_soap_parameter_get_string_value (subparam);
+                        if (!strcmp (dist_type, "TO")) 
+                                attendee->role =
ICAL_ROLE_REQPARTICIPANT;
+                        else if (!strcmp (dist_type, "CC"))
+                                attendee->role =
ICAL_ROLE_OPTPARTICIPANT;
+                        else
+                                attendee->role =
ICAL_ROLE_NONPARTICIPANT;
+                }        
+                list = g_slist_append (list, attendee);
+        }        
         return list;
-        
 }
 
 static ECalComponent* 
 get_e_cal_component_from_soap_parameter (SoupSoapParameter *param)
 {
         SoupSoapParameter *subparam;
-        const char *item_type, *classification, *accept_level,
*to_list;
+        const char *item_type, *classification, *accept_level;
         char *dtstring;
         ECalComponent *comp;
         ECalComponentDateTime *dt;
@@ -482,7 +485,6 @@ get_e_cal_component_from_soap_parameter 
         dtstring = get_evo_date_from_string
(soup_soap_parameter_get_string_value (subparam));
         t = icaltime_from_string (dtstring);
         g_free (dtstring);
-        dt = g_malloc0 (sizeof (ECalComponentDateTime));
         dt->value = &t;
         dt->tzid = "UTC"; 
         e_cal_component_set_dtstart (comp, dt); 
@@ -526,21 +528,25 @@ get_e_cal_component_from_soap_parameter 
 
         /* Property - attendee-list*/ 
         subparam = soup_soap_parameter_get_first_child_by_name (param,
"distribution");
-	if (subparam) {
-		/* FIXME  what to do with 'from' data*/
-
-		to_list = soup_soap_parameter_get_string_value (
soup_soap_parameter_get_first_child_by_name (subparam, "to"));
-		if (to_list)
-			attendee_list = get_attendee_list_from_string (to_list);
-
-		if (!attendee_list) {
-			g_object_unref (comp);
-			return NULL;
-		}
-		/*e_cal_component_set_attendee_list (comp, attendee_list);*/
-	}
-                
-        /* FIXME  Property - status*/
+        /* FIXME  what to do with 'from' data*/
+        
+        subparam = soup_soap_parameter_get_first_child_by_name
(subparam, "recipients");
+        if (subparam) 
+                attendee_list = get_attendee_list_from_soap_parameter
(subparam);
+               
+        if (attendee_list) {
+                GSList *l;
+                e_cal_component_set_attendee_list (comp,
attendee_list);
+                for (l = attendee_list; l != NULL; l = g_slist_next
(l)) {
+                        ECalComponentAttendee *attendee;
+                        attendee = (ECalComponentAttendee*) l->data;
+                        g_free (attendee->cn);
+                        g_free (attendee->value);
+                }        
+                g_slist_foreach (attendee_list, (GFunc) g_free, NULL);
+        }
+        
+       /* FIXME  Property - status*/
         /* FIXME  Property priority */  
         subparam = soup_soap_parameter_get_first_child_by_name (param,
"options");
         if (!subparam) {
@@ -580,7 +586,6 @@ get_e_cal_component_from_soap_parameter 
                 t = icaltime_from_string (dtstring);
                 g_free (dtstring);
                 
-                dt = g_malloc0 (sizeof (ECalComponentDateTime));
                 dt->value = &t;
                 dt->tzid = "UTC"; 
                 e_cal_component_set_dtend (comp, dt);
@@ -600,7 +605,6 @@ get_e_cal_component_from_soap_parameter 
                 t = icaltime_from_string (dtstring);
                 g_free (dtstring);
                 
-                dt = g_malloc0 (sizeof (ECalComponentDateTime));
                 dt->value = &t;
                 dt->tzid = "UTC"; 
                 e_cal_component_set_due (comp, dt);
@@ -697,7 +701,7 @@ e_gw_connection_get_container_id (EGwCon
 }
 
 EGwConnectionStatus
-e_gw_connection_get_items (EGwConnection *cnc, const char *container,
const char * filter, GSList **list)
+e_gw_connection_get_items (EGwConnection *cnc, const char *container,
const char * filter, GList **list)
 {
         SoupSoapMessage *msg;
         SoupSoapResponse *response;
@@ -714,6 +718,7 @@ e_gw_connection_get_items (EGwConnection
         }
 
         e_gw_message_write_string_parameter (msg, "container", NULL,
container);
+        e_gw_message_write_string_parameter (msg, "view", NULL,
"recipients");
 	if (filter)
 		e_gw_message_write_string_parameter (msg, "Filter", NULL, filter);
 	e_gw_message_write_footer (msg);
@@ -742,14 +747,14 @@ e_gw_connection_get_items (EGwConnection
 	
         /* parse these parameters into ecalcomponents*/
         for (subparam = soup_soap_parameter_get_first_child_by_name
(param, "item");
-	     subparam != NULL;
-	     subparam = soup_soap_parameter_get_next_child_by_name (subparam,
"item")) { 
-		ECalComponent *comp = NULL;
-		comp = get_e_cal_component_from_soap_parameter (subparam);
-		if (comp)
-			*list = g_slist_append (*list, comp);
-		else
-			continue; /*FIXME: skips element if error. need to generate proper
error*/
+                subparam != NULL;
+                subparam = soup_soap_parameter_get_next_child_by_name
(subparam, "item")) { 
+                        ECalComponent *comp = NULL;
+                        comp = get_e_cal_component_from_soap_parameter
(subparam);
+                        if (comp)
+                                *list = g_list_append (*list, comp);
+                        else
+                                continue; /*FIXME: skips element if
error. need to generate proper error*/
         }
                
 	/* free memory */
@@ -759,8 +764,199 @@ e_gw_connection_get_items (EGwConnection
         return E_GW_CONNECTION_STATUS_OK;        
 }
 
+static
+gboolean update_cache_item (ECalBackendCache *cache, SoupSoapParameter
*param)
+{
+        SoupSoapParameter *subparam;
+        const char *uid, *item_type, *classification, *accept_level;
+        char *dtstring;
+        ECalComponent *comp;
+        ECalComponentDateTime *dt;
+        ECalComponentText summary;
+        struct icaltimetype t;
+        int type = 0; /* type : stores enum value of ECalcomponentVType
for local access*/ 
+        GSList *attendee_list = NULL;
+        /* FIXME: need to add some validation code*/
+        
+        subparam = soup_soap_parameter_get_first_child_by_name (param,
"id");
+        if (!subparam) {
+                return FALSE;
+        }
+        uid = soup_soap_parameter_get_string_value (subparam);
+        if (!uid)
+                return FALSE;
+
+        comp = e_cal_backend_cache_get_component (cache, uid, NULL );
+        if (!comp)
+                return FALSE;
+
+        /* Ensure that the component type matches response data */
+        item_type = xmlGetProp (param, "type");
+        if ( !g_ascii_strcasecmp (item_type, "Appointment")) {
+                if (e_cal_component_get_vtype (comp) !=
E_CAL_COMPONENT_EVENT)
+                        return FALSE;
+                type = 1;
+        }
+        else if (!g_ascii_strcasecmp (item_type, "Task")) {
+                if (e_cal_component_get_vtype (comp) !=
E_CAL_COMPONENT_TODO)
+                        return FALSE;
+                type = 2;
+        }
+        else if (!g_ascii_strcasecmp (item_type, "Note")) {
+                if (e_cal_component_get_vtype (comp) !=
E_CAL_COMPONENT_JOURNAL)
+                        return FALSE;
+                type = 3;
+        }
+        else 
+                return FALSE;
+        
+        /* Property - created*/ 
+        subparam = soup_soap_parameter_get_first_child_by_name (param,
"created");
+        if (subparam) {
+                dtstring = get_evo_date_from_string
(soup_soap_parameter_get_string_value (subparam));
+                t = icaltime_from_string (dtstring);
+                g_free (dtstring);
+                e_cal_component_set_created (comp, &t);
+                e_cal_component_set_dtstamp (comp, &t);
+        }
+        
+                
+        /* Property - startDate*/ 
+        subparam = soup_soap_parameter_get_first_child_by_name (param,
"startDate");
+        
+        if (subparam) {
+                dtstring = get_evo_date_from_string
(soup_soap_parameter_get_string_value (subparam));
+                t = icaltime_from_string (dtstring);
+                g_free (dtstring);
+                dt->value = &t;
+                dt->tzid = "UTC"; 
+                e_cal_component_set_dtstart (comp, dt); 
+        }
+       
+        /* Category - missing server implementation */
+
+        /* Classification */
+        subparam = soup_soap_parameter_get_first_child_by_name (param,
"class"); 
+        if (subparam) {
+                classification = soup_soap_parameter_get_string_value
(subparam);
+                if ( !g_ascii_strcasecmp (classification, "Public"))
+                        e_cal_component_set_classification (comp,
E_CAL_COMPONENT_CLASS_PUBLIC);
+                else if (!g_ascii_strcasecmp (classification,
"Private"))
+                        e_cal_component_set_classification (comp,
E_CAL_COMPONENT_CLASS_PRIVATE);
+                else if (!g_ascii_strcasecmp (classification,
"Confidential"))
+                        e_cal_component_set_classification (comp,
E_CAL_COMPONENT_CLASS_CONFIDENTIAL);
+                else
+                        e_cal_component_set_classification (comp,
E_CAL_COMPONENT_CLASS_UNKNOWN);
+        }
+
+        /* Transparency - Busy, OutOfOffice, Free, Tentative*/
+        subparam = soup_soap_parameter_get_first_child_by_name (param,
"acceptLevel"); 
+        if (subparam) {
+                accept_level = soup_soap_parameter_get_string_value
(subparam);
+                if ( !g_ascii_strcasecmp (accept_level, "Busy") ||
!g_ascii_strcasecmp (accept_level, "OutOfOffice"))
+                        e_cal_component_set_transparency (comp,
E_CAL_COMPONENT_TRANSP_OPAQUE);
+                else
+                        e_cal_component_set_transparency (comp,
E_CAL_COMPONENT_TRANSP_TRANSPARENT);
+        }
+
+        /* Property - summary*/ 
+        subparam = soup_soap_parameter_get_first_child_by_name (param,
"subject"); 
+        if (subparam) {
+                summary.value = g_strdup
(soup_soap_parameter_get_string_value (subparam));
+                summary.altrep = NULL;
+                e_cal_component_set_summary (comp, &summary);
+        }
+
+        /* Property - attendee-list*/ 
+        subparam = soup_soap_parameter_get_first_child_by_name (param,
"distribution");
+        if (subparam) {
+                /* FIXME  what to do with 'from' data*/
+                
+                subparam = soup_soap_parameter_get_first_child_by_name
(subparam, "recipients");
+                if (subparam) {
+                        attendee_list =
get_attendee_list_from_soap_parameter (subparam);
+                        if (attendee_list)
+                                e_cal_component_set_attendee_list
(comp, attendee_list);
+                }        
+        
+                        
+        }        
+        /* FIXME  Property - status*/
+        /* FIXME  Property priority */  
+        subparam = soup_soap_parameter_get_first_child_by_name (param,
"options");
+        if (subparam) {
+                subparam = soup_soap_parameter_get_first_child_by_name
(param, "priority");
+                if (subparam) {
+                        const char *priority;
+                        int i;
+                        priority = soup_soap_parameter_get_string_value
(subparam);
+                        if (!g_ascii_strcasecmp ("High", priority )) 
+                                i = 3;
+                        else if (!g_ascii_strcasecmp ("Standard",
priority)) 
+                                i = 5;
+                        else if (!g_ascii_strcasecmp ("Low", priority))
+                                i = 7;
+                        else 
+                                i = -1;
+                        e_cal_component_set_priority (comp, &i);
+                }
+        }
+                        
+        
+        /* EVENT -specific properties */
+        if (type == 1) {
+                /* Property - endDate*/ 
+                subparam = soup_soap_parameter_get_first_child_by_name
(param, "endDate");
+
+                if (subparam) {
+                        dtstring = get_evo_date_from_string
(soup_soap_parameter_get_string_value (subparam));
+                        t = icaltime_from_string (dtstring);
+                        g_free (dtstring);
+                        
+                        dt->value = &t;
+                        dt->tzid = "UTC"; 
+                        e_cal_component_set_dtend (comp, dt);
+                }
+
+                subparam = soup_soap_parameter_get_first_child_by_name
(param, "place"); 
+                if (subparam) 
+                        e_cal_component_set_location (comp,
soup_soap_parameter_get_string_value (subparam));
+                        
+
+        } else if (type == 2) {
+                /* Property - dueDate*/ 
+                subparam = soup_soap_parameter_get_first_child_by_name
(param, "dueDate");
+                if (subparam) {
+                        dtstring = get_evo_date_from_string
(soup_soap_parameter_get_string_value (subparam));
+                        t = icaltime_from_string (dtstring);
+                        g_free (dtstring);
+                        
+                        dt->value = &t;
+                        dt->tzid = "UTC"; 
+                        e_cal_component_set_due (comp, dt);
+                }        
+
+                /*FIXME  Property - completed - missing server
implementation  */
+                /* Only 0 and 100 are legal values since server data is
boolean */
+                subparam = soup_soap_parameter_get_first_child_by_name
(param, "completed");
+                if (subparam) {
+                        const char *completed =
soup_soap_parameter_get_string_value (subparam);
+                        int i =0;
+                        if (!g_ascii_strcasecmp (completed, "true")) {
+                                i = 100;
+                                e_cal_component_set_percent (comp, &i);
+                        } else 
+                                e_cal_component_set_percent (comp, &i);
+                }        
+
+        } 
+        return TRUE;
+}
+
+
+
 EGwConnectionStatus
-e_gw_connection_get_deltas (EGwConnection *cnc, GSList **list)
+e_gw_connection_get_deltas (EGwConnection *cnc, ECalBackendCache
*cache)
 {
         SoupSoapMessage *msg;
         SoupSoapResponse *response;
@@ -821,6 +1017,18 @@ e_gw_connection_get_deltas (EGwConnectio
                         subparam != NULL;
                         subparam =
soup_soap_parameter_get_next_child_by_name (subparam, "item")) { 
                                 /*process each item */ 
+                                const char *uid;
+                                SoupSoapParameter *param_id;
+
+                                param_id =
soup_soap_parameter_get_first_child_by_name (subparam, "id");
+                                if (!param_id) {
+                                        g_object_unref (response);
+                                        g_object_unref (msg);
+                                        return
E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
+                                }
+                                uid =
soup_soap_parameter_get_string_value (param_id);
+                                if
(!e_cal_backend_cache_remove_component (cache, uid, NULL))
+                                        g_message ("Could not remove
%s", uid);
                 }
         }
         
@@ -831,6 +1039,15 @@ e_gw_connection_get_deltas (EGwConnectio
                         subparam != NULL;
                         subparam =
soup_soap_parameter_get_next_child_by_name (subparam, "item")) { 
                                 /*process each item */ 
+                                ECalComponent *comp;
+                                comp =
get_e_cal_component_from_soap_parameter (subparam);
+                                if (!comp) {
+                                        g_object_unref (response);
+                                        g_object_unref (msg);
+                                        return
E_GW_CONNECTION_STATUS_INVALID_RESPONSE;
+                                }
+                                if (!e_cal_backend_cache_put_component
(cache, comp))
+                                        g_message ("Could not add the
component");
                 }
         }
         
@@ -841,6 +1058,7 @@ e_gw_connection_get_deltas (EGwConnectio
                         subparam != NULL;
                         subparam = soup_soap_parameter_get_next_child
(subparam)) { 
                                 /*process each item */ 
+                                update_cache_item (cache, subparam);
                 }
         }
                
@@ -917,14 +1135,14 @@ e_gw_connection_remove_item (EGwConnecti
 }
 
 static EGwConnectionStatus
-start_freebusy_session (EGwConnection *cnc, GSList *users, 
+start_freebusy_session (EGwConnection *cnc, GList *users, 
                time_t start, time_t end, const char **session)
 {
         SoupSoapMessage *msg;
         SoupSoapResponse *response;
         EGwConnectionStatus status;
         SoupSoapParameter *param;
-        GSList *l;
+        GList *l;
         icaltimetype icaltime;
         const char *start_date, *end_date;
 
@@ -937,7 +1155,7 @@ start_freebusy_session (EGwConnection *c
          * email id apart from the name*/
         
         soup_soap_message_start_element (msg, "users", "types", NULL); 
-        for ( l = users; l != NULL; l = g_slist_next (l)) {
+        for ( l = users; l != NULL; l = g_list_next (l)) {
                 e_gw_message_write_string_parameter (msg, "user", NULL,
l->data);
         }
         soup_soap_message_end_element (msg);
@@ -1017,7 +1235,7 @@ close_freebusy_session (EGwConnection *c
 }
 
 EGwConnectionStatus
-e_gw_connection_get_freebusy_info (EGwConnection *cnc, GSList *users,
time_t start, time_t end, GSList **freebusy)
+e_gw_connection_get_freebusy_info (EGwConnection *cnc, GList *users,
time_t start, time_t end, GList **freebusy)
 {
         SoupSoapMessage *msg;
         SoupSoapResponse *response;
@@ -1101,7 +1319,6 @@ e_gw_connection_get_freebusy_info (EGwCo
                                 dtstring = get_evo_date_from_string
(start);
                                 t = icaltime_from_string (dtstring);
                                 g_free (dtstring);
-                                dt = g_malloc0 (sizeof
(ECalComponentDateTime));
                                 dt->value = &t;
                                 dt->tzid = "UTC"; 
                                 e_cal_component_set_dtstart (comp, dt);
@@ -1110,12 +1327,11 @@ e_gw_connection_get_freebusy_info (EGwCo
                                 dtstring = get_evo_date_from_string
(end);
                                 t = icaltime_from_string (dtstring);
                                 g_free (dtstring);
-                                dt = g_malloc0 (sizeof
(ECalComponentDateTime));
                                 dt->value = &t;
                                 dt->tzid = "UTC"; 
                                 e_cal_component_set_dtend (comp, dt);
 
-                                *freebusy = g_slist_append (*freebusy,
comp);
+                                *freebusy = g_list_append (*freebusy,
comp);
                         }
 
                 }
Index: backends/groupwise/e-gw-connection.h
===================================================================
RCS file:
/cvs/gnome/evolution-data-server/calendar/backends/groupwise/e-gw-connection.h,v
retrieving revision 1.14
diff -u -p -r1.14 e-gw-connection.h
--- backends/groupwise/e-gw-connection.h	18 Jan 2004 14:31:15 -0000	1.14
+++ backends/groupwise/e-gw-connection.h	22 Jan 2004 06:17:03 -0000
@@ -26,6 +26,7 @@
 
 #include <glib-object.h>
 #include <libsoup/soup-soap-message.h>
+#include <libedata-cal/e-cal-backend-cache.h>
 #include "e-gw-item.h"
 
 G_BEGIN_DECLS
@@ -68,13 +69,13 @@ EGwConnectionStatus e_gw_connection_logo
 EGwConnectionStatus e_gw_connection_get_container_list (EGwConnection
*cnc, SoupSoapResponse **response);
 char               *e_gw_connection_get_container_id (EGwConnection
*cnc, const char *name);
 EGwConnectionStatus e_gw_connection_get_items (EGwConnection *cnc,
const char *container,
-					       const char *filter, GSList **list);
-EGwConnectionStatus e_gw_connection_get_deltas (EGwConnection *cnc,
GSList **list);
+					       const char *filter, GList **list);
+EGwConnectionStatus e_gw_connection_get_deltas (EGwConnection *cnc,
ECalBackendCache *cache);
 EGwConnectionStatus e_gw_connection_send_item (EGwConnection *cnc,
EGwItem *item);
 EGwConnectionStatus e_gw_connection_send_appointment (EGwConnection
*cnc, const char *container, ECalComponent *comp);
 EGwConnectionStatus e_gw_connection_remove_item (EGwConnection *cnc,
const char *container, const char *id);
-EGwConnectionStatus e_gw_connection_get_freebusy_info (EGwConnection
*cnc, GSList *users,
-                                                                       
time_t start, time_t end, GSList **freebusy);
+EGwConnectionStatus e_gw_connection_get_freebusy_info (EGwConnection
*cnc, GList *users,
+                                                                       
time_t start, time_t end, GList **freebusy);
 
 const char         *e_gw_connection_get_user_name (EGwConnection *cnc);
 const char         *e_gw_connection_get_user_email (EGwConnection
*cnc);
Index: libedata-cal/e-cal-backend-cache.c
===================================================================
RCS file:
/cvs/gnome/evolution-data-server/calendar/libedata-cal/e-cal-backend-cache.c,v
retrieving revision 1.11
diff -u -p -r1.11 e-cal-backend-cache.c
--- libedata-cal/e-cal-backend-cache.c	16 Jan 2004 18:15:14 -0000	1.11
+++ libedata-cal/e-cal-backend-cache.c	22 Jan 2004 06:17:03 -0000
@@ -360,11 +360,11 @@ e_cal_backend_cache_remove_component (EC
 	return retval;
 }
 
-GSList *
+GList *
 e_cal_backend_cache_get_components (ECalBackendCache *cache)
 {
         char *comp_str;
-        GSList *l, *list = NULL;
+        GList *l, *list = NULL;
 	icalcomponent *icalcomp;
 	ECalComponent *comp = NULL;
         
@@ -373,14 +373,14 @@ e_cal_backend_cache_get_components (ECal
         l = e_file_cache_get_objects (E_FILE_CACHE (cache));
         if (!l)
                 return NULL;
-        for ( ; l != NULL; l = g_slist_next (l)) {
+        for ( ; l != NULL; l = g_list_next (l)) {
                 comp_str = l->data;
                 if (comp_str) {
                         icalcomp = icalparser_parse_string (comp_str);
                         if (icalcomp) {
                                 comp = e_cal_component_new ();
                                 e_cal_component_set_icalcomponent
(comp, icalcomp);
-                                list = g_slist_append (list, comp);
+                                list = g_list_append (list, comp);
                         }
                 }
                 
Index: libedata-cal/e-cal-backend-cache.h
===================================================================
RCS file:
/cvs/gnome/evolution-data-server/calendar/libedata-cal/e-cal-backend-cache.h,v
retrieving revision 1.7
diff -u -p -r1.7 e-cal-backend-cache.h
--- libedata-cal/e-cal-backend-cache.h	13 Jan 2004 13:14:59 -0000	1.7
+++ libedata-cal/e-cal-backend-cache.h	22 Jan 2004 06:17:03 -0000
@@ -54,7 +54,7 @@ gboolean          e_cal_backend_cache_pu
 gboolean          e_cal_backend_cache_remove_component
(ECalBackendCache *cache,
 							const char *uid,
 							const char *rid);
-GSList           *e_cal_backend_cache_get_components (ECalBackendCache
*cache);
+GList           *e_cal_backend_cache_get_components (ECalBackendCache
*cache);
 
 G_END_DECLS
 




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