added a 'container' argument. (e_gw_item_dispose): free new field in the
authorRodrigo Moya <rodrigo@ximian.com>
Tue, 13 Jan 2004 18:28:10 +0000 (18:28 +0000)
committerRodrigo Moya <rodrigo@src.gnome.org>
Tue, 13 Jan 2004 18:28:10 +0000 (18:28 +0000)
2004-01-13  Rodrigo Moya <rodrigo@ximian.com>

* backends/groupwise/e-gw-item.[ch] (e_gw_item_new_appointment):
added a 'container' argument.
(e_gw_item_dispose): free new field in the private structure.

* backends/groupwise/e-gw-connection.[ch]
(e_gw_connection_send_appointment): added a 'container' argument.

* backends/groupwise/e-cal-backend-groupwise.c
(e_cal_backend_groupwise_create_object,
e_cal_backend_groupwise_modify_object): adapted to changes in
e_gw_connection_send_appointment.
(e_cal_backend_groupwise_receive_objects): implemented.

calendar/ChangeLog
calendar/backends/groupwise/e-cal-backend-groupwise.c
calendar/backends/groupwise/e-gw-connection.c
calendar/backends/groupwise/e-gw-connection.h
calendar/backends/groupwise/e-gw-item.c
calendar/backends/groupwise/e-gw-item.h
servers/groupwise/e-gw-connection.c
servers/groupwise/e-gw-connection.h
servers/groupwise/e-gw-item.c
servers/groupwise/e-gw-item.h

index 5f59eb7..7d68d4c 100644 (file)
@@ -1,5 +1,20 @@
 2004-01-13  Rodrigo Moya <rodrigo@ximian.com>
 
+       * backends/groupwise/e-gw-item.[ch] (e_gw_item_new_appointment):
+       added a 'container' argument.
+       (e_gw_item_dispose): free new field in the private structure.
+
+       * backends/groupwise/e-gw-connection.[ch]
+       (e_gw_connection_send_appointment): added a 'container' argument.
+
+       * backends/groupwise/e-cal-backend-groupwise.c
+       (e_cal_backend_groupwise_create_object,
+       e_cal_backend_groupwise_modify_object): adapted to changes in
+       e_gw_connection_send_appointment.
+       (e_cal_backend_groupwise_receive_objects): implemented.
+
+2004-01-13  Rodrigo Moya <rodrigo@ximian.com>
+
        * backends/groupwise/e-gw-connection.[ch]
        (e_gw_connection_get_items): moved the folder retrieving code to...
        (e_gw_connection_get_container_id): ...here, new function.
index 27534f7..7f07bb2 100644 (file)
@@ -687,7 +687,7 @@ e_cal_backend_groupwise_create_object (ECalBackendSync *backend, EDataCal *cal,
        case CAL_MODE_ANY :
        case CAL_MODE_REMOTE :
                /* when online, send the item to the server */
-               status = e_gw_connection_send_appointment (priv->cnc, comp);
+               status = e_gw_connection_send_appointment (priv->cnc, priv->container_id, comp);
                if (status != E_GW_CONNECTION_STATUS_OK)
                        break;
                /* if successful, update the cache */
@@ -733,7 +733,7 @@ e_cal_backend_groupwise_modify_object (ECalBackendSync *backend, EDataCal *cal,
        case CAL_MODE_ANY :
        case CAL_MODE_REMOTE :
                /* when online, send the item to the server */
-               status = e_gw_connection_send_appointment (priv->cnc, comp);
+               status = e_gw_connection_send_appointment (priv->cnc, priv->container_id, comp);
                if (status != E_GW_CONNECTION_STATUS_OK)
                        break;
                /* if successful, update the cache */
@@ -779,10 +779,74 @@ e_cal_backend_groupwise_remove_object (ECalBackendSync *backend, EDataCal *cal,
        return GNOME_Evolution_Calendar_Success;
 }
 
+static ECalBackendSyncStatus
+receive_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalcomp)
+{
+       ECalComponent *comp, *found_comp;
+       ECalBackendGroupwisePrivate *priv;
+       const char *uid, *rid;
+       char *comp_str;
+       ECalBackendSyncStatus status = GNOME_Evolution_Calendar_Success;
+
+       priv = cbgw->priv;
+
+       /* search the object in the cache */
+       comp = e_cal_component_new ();
+       e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp));
+       e_cal_component_get_uid (comp, &uid);
+       rid = e_cal_component_get_recurid_as_string (comp);
+
+       comp_str = e_cal_component_get_as_string (comp);
+
+       found_comp = e_cal_backend_cache_get_component (priv->cache, uid, rid);
+       if (found_comp) {
+               status = e_cal_backend_groupwise_modify_object (E_CAL_BACKEND_SYNC (cbgw), cal, comp_str,
+                                                               CALOBJ_MOD_THIS, NULL);
+       } else
+               status = e_cal_backend_groupwise_create_object (E_CAL_BACKEND_SYNC (cbgw), cal, comp_str, NULL);
+
+       g_free (comp_str);
+       g_object_unref (comp);
+
+       return status;
+}
+
 /* Update_objects handler for the file backend. */
 static ECalBackendSyncStatus
 e_cal_backend_groupwise_receive_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj)
 {
+       ECalBackendGroupwise *cbgw;
+        ECalBackendGroupwisePrivate *priv;
+       icalcomponent *icalcomp, *subcomp;
+       icalcomponent_kind kind;
+       ECalBackendSyncStatus status = GNOME_Evolution_Calendar_Success;
+
+       cbgw = E_CAL_BACKEND_GROUPWISE (backend);
+       priv = cbgw->priv;
+
+       icalcomp = icalparser_parse_string (calobj);
+       if (!icalcomp)
+               return GNOME_Evolution_Calendar_InvalidObject;
+
+       kind = icalcomponent_isa (icalcomp);
+       if (kind == ICAL_VCALENDAR_COMPONENT) {
+               subcomp = icalcomponent_get_first_component (icalcomp,
+                                                            e_cal_backend_get_kind (E_CAL_BACKEND (backend)));
+               while (subcomp) {
+                       status = receive_object (cbgw, cal, subcomp);
+                       if (status != GNOME_Evolution_Calendar_Success)
+                               break;
+                       subcomp = icalcomponent_get_next_component (icalcomp,
+                                                                   e_cal_backend_get_kind (E_CAL_BACKEND (backend)));
+               }
+       } else if (kind == e_cal_backend_get_kind (E_CAL_BACKEND (backend))) {
+               status = receive_object (cbgw, cal, icalcomp);
+       } else
+               status = GNOME_Evolution_Calendar_InvalidObject;
+
+       icalcomponent_free (icalcomp);
+
+       return status;
 }
 
 static ECalBackendSyncStatus
index 8d1e730..c02d7a9 100644 (file)
@@ -636,7 +636,7 @@ e_gw_connection_send_item (EGwConnection *cnc, EGwItem *item)
 }
 
 EGwConnectionStatus
-e_gw_connection_send_appointment (EGwConnection *cnc, ECalComponent *comp)
+e_gw_connection_send_appointment (EGwConnection *cnc, const char *container, ECalComponent *comp)
 {
        EGwItem *item;
        EGwConnectionStatus status;
@@ -644,7 +644,7 @@ e_gw_connection_send_appointment (EGwConnection *cnc, ECalComponent *comp)
        g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_CONNECTION);
        g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
 
-       item = e_gw_item_new_appointment (comp);
+       item = e_gw_item_new_appointment (container, comp);
        status = e_gw_connection_send_item (cnc, item);
        g_object_unref (item);
 
index 9901799..eea69b8 100644 (file)
@@ -71,7 +71,7 @@ EGwConnectionStatus e_gw_connection_get_items (EGwConnection *cnc, const char *c
                                               const char *filter, GSList **list);
 EGwConnectionStatus e_gw_connection_get_deltas (EGwConnection *cnc, char * sequence_number, GSList **list);
 EGwConnectionStatus e_gw_connection_send_item (EGwConnection *cnc, EGwItem *item);
-EGwConnectionStatus e_gw_connection_send_appointment (EGwConnection *cnc, ECalComponent *comp);
+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);
 
 const char         *e_gw_connection_get_user_name (EGwConnection *cnc);
index 4c652b3..06ed196 100644 (file)
@@ -28,6 +28,7 @@
 
 struct _EGwItemPrivate {
        EGwItemType item_type;
+       char *container;
        gpointer item_data;
 };
 
@@ -43,6 +44,10 @@ e_gw_item_dispose (GObject *object)
 
        priv = item->priv;
        if (priv) {
+               if (priv->container) {
+                       g_free (priv->container);
+                       priv->container = NULL;
+               }
        }
 
        if (parent_class->dispose)
@@ -112,7 +117,7 @@ e_gw_item_get_type (void)
 }
 
 EGwItem *
-e_gw_item_new_appointment (ECalComponent *comp)
+e_gw_item_new_appointment (const char *container, ECalComponent *comp)
 {
        EGwItem *item;
 
@@ -120,6 +125,7 @@ e_gw_item_new_appointment (ECalComponent *comp)
 
        item = g_object_new (E_TYPE_GW_ITEM, NULL);
        item->priv->item_type = E_GW_ITEM_TYPE_APPOINTMENT;
+       item->priv->container = g_strdup (container);
        item->priv->item_data = comp;
 
        return item;
index 2d3679c..37aa809 100644 (file)
@@ -53,7 +53,7 @@ struct _EGwItemClass {
 };
 
 GType    e_gw_item_get_type (void);
-EGwItem *e_gw_item_new_appointment (ECalComponent *comp);
+EGwItem *e_gw_item_new_appointment (const char *container, ECalComponent *comp);
 
 G_END_DECLS
 
index 8d1e730..c02d7a9 100644 (file)
@@ -636,7 +636,7 @@ e_gw_connection_send_item (EGwConnection *cnc, EGwItem *item)
 }
 
 EGwConnectionStatus
-e_gw_connection_send_appointment (EGwConnection *cnc, ECalComponent *comp)
+e_gw_connection_send_appointment (EGwConnection *cnc, const char *container, ECalComponent *comp)
 {
        EGwItem *item;
        EGwConnectionStatus status;
@@ -644,7 +644,7 @@ e_gw_connection_send_appointment (EGwConnection *cnc, ECalComponent *comp)
        g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_CONNECTION);
        g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), E_GW_CONNECTION_STATUS_INVALID_OBJECT);
 
-       item = e_gw_item_new_appointment (comp);
+       item = e_gw_item_new_appointment (container, comp);
        status = e_gw_connection_send_item (cnc, item);
        g_object_unref (item);
 
index 9901799..eea69b8 100644 (file)
@@ -71,7 +71,7 @@ EGwConnectionStatus e_gw_connection_get_items (EGwConnection *cnc, const char *c
                                               const char *filter, GSList **list);
 EGwConnectionStatus e_gw_connection_get_deltas (EGwConnection *cnc, char * sequence_number, GSList **list);
 EGwConnectionStatus e_gw_connection_send_item (EGwConnection *cnc, EGwItem *item);
-EGwConnectionStatus e_gw_connection_send_appointment (EGwConnection *cnc, ECalComponent *comp);
+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);
 
 const char         *e_gw_connection_get_user_name (EGwConnection *cnc);
index 4c652b3..06ed196 100644 (file)
@@ -28,6 +28,7 @@
 
 struct _EGwItemPrivate {
        EGwItemType item_type;
+       char *container;
        gpointer item_data;
 };
 
@@ -43,6 +44,10 @@ e_gw_item_dispose (GObject *object)
 
        priv = item->priv;
        if (priv) {
+               if (priv->container) {
+                       g_free (priv->container);
+                       priv->container = NULL;
+               }
        }
 
        if (parent_class->dispose)
@@ -112,7 +117,7 @@ e_gw_item_get_type (void)
 }
 
 EGwItem *
-e_gw_item_new_appointment (ECalComponent *comp)
+e_gw_item_new_appointment (const char *container, ECalComponent *comp)
 {
        EGwItem *item;
 
@@ -120,6 +125,7 @@ e_gw_item_new_appointment (ECalComponent *comp)
 
        item = g_object_new (E_TYPE_GW_ITEM, NULL);
        item->priv->item_type = E_GW_ITEM_TYPE_APPOINTMENT;
+       item->priv->container = g_strdup (container);
        item->priv->item_data = comp;
 
        return item;
index 2d3679c..37aa809 100644 (file)
@@ -53,7 +53,7 @@ struct _EGwItemClass {
 };
 
 GType    e_gw_item_get_type (void);
-EGwItem *e_gw_item_new_appointment (ECalComponent *comp);
+EGwItem *e_gw_item_new_appointment (const char *container, ECalComponent *comp);
 
 G_END_DECLS