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.
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 */
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 */
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
}
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;
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);
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);
struct _EGwItemPrivate {
EGwItemType item_type;
+ char *container;
gpointer item_data;
};
priv = item->priv;
if (priv) {
+ if (priv->container) {
+ g_free (priv->container);
+ priv->container = NULL;
+ }
}
if (parent_class->dispose)
}
EGwItem *
-e_gw_item_new_appointment (ECalComponent *comp)
+e_gw_item_new_appointment (const char *container, ECalComponent *comp)
{
EGwItem *item;
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;
};
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
}
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;
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);
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);
struct _EGwItemPrivate {
EGwItemType item_type;
+ char *container;
gpointer item_data;
};
priv = item->priv;
if (priv) {
+ if (priv->container) {
+ g_free (priv->container);
+ priv->container = NULL;
+ }
}
if (parent_class->dispose)
}
EGwItem *
-e_gw_item_new_appointment (ECalComponent *comp)
+e_gw_item_new_appointment (const char *container, ECalComponent *comp)
{
EGwItem *item;
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;
};
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