-2005-10-10 Chenthill Palanisamy <pchenthill@novell.com>
-
- Fixes #266144
- * backends/contacts/e-cal-backend-contacts.c:
- (contact_record_free):
- * backends/http/e-cal-backend-http.c:
- (notify_and_remove_from_cache):
- * backends/weather/e-cal-backend-weather.c:
- (finished_retrieval_cb):
- * backends/file/e-cal-backend-file.c: (notify_removals_cb),
- (e_cal_backend_file_receive_objects): Use ECalComponentId.
- * backends/groupwise/e-cal-backend-groupwise-utils.[ch]:
- (e_gw_item_to_cal_component): Store the recurrence id in
- utc.
- (e_gw_connection_send_appointment): Get the component while
- accepting/declining from mail component and pass all_instances
- and get the partstat.
- the
- * backends/groupwise/e-cal-backend-groupwise.c:
- (e_cal_backend_groupwise_remove_object), (change_status),
- (receive_object): Change the status of all recurring appointments
- if all_instances is set true.
- * idl/Evolution-DataServer-Calendar.idl: Added a structure
- to hold the recurrence id and uid to notify the component
- removed.
- * libecal/e-cal-component.c: (e_cal_component_get_id),
- (e_cal_component_free_id): Added new API's for getting
- the recurrence id and uid of a component.
- * libecal/e-cal-component.h: Added a structure of holding
- both the recurrence id and the uid.
- * libecal/e-cal-view-listener.c: (build_id_list),
- (impl_notifyObjectsRemoved):
- * libecal/e-cal-view.c: (objects_removed_cb):
- * libedata-cal/e-cal-backend-sync.c:
- (_e_cal_backend_remove_object):
- * libedata-cal/e-cal-backend.c: (match_query_and_notify),
- (e_cal_backend_notify_object_removed):
- * libedata-cal/e-cal-backend.h:
- * libedata-cal/e-data-cal-view.c: (uncache_with_id_cb),
- (remove_object_from_cache):
- (e_data_cal_view_notify_objects_removed),
- (e_data_cal_view_notify_objects_removed_1):
- * libedata-cal/e-data-cal-view.h:
- * libedata-cal/e-data-cal.c: (e_data_cal_notify_object_removed):
- * libedata-cal/e-data-cal.h: Changed the API's to use the
- ECalComponentId structure instead of uid.
-
2005-10-07 Arunprakash <arunp@novell.com>
* libedata-cal/e-data-cal-factory.c (backend_last_client_gone_cb) :
contact_record_free (ContactRecord *cr)
{
char *comp_str;
- ECalComponentId *id;
+ const char *uid;
g_object_unref (G_OBJECT (cr->contact));
/* Remove the birthday event */
if (cr->comp_birthday) {
comp_str = e_cal_component_get_as_string (cr->comp_birthday);
- id = e_cal_component_get_id (cr->comp_birthday);
- e_cal_backend_notify_object_removed (E_CAL_BACKEND (cr->cbc), id, comp_str, NULL);
-
- e_cal_component_free_id (id);
+ e_cal_component_get_uid (cr->comp_birthday, &uid);
+ e_cal_backend_notify_object_removed (E_CAL_BACKEND (cr->cbc), uid, comp_str, NULL);
g_free (comp_str);
g_object_unref (G_OBJECT (cr->comp_birthday));
}
/* Remove the anniversary event */
if (cr->comp_anniversary) {
comp_str = e_cal_component_get_as_string (cr->comp_anniversary);
- id = e_cal_component_get_id (cr->comp_birthday);
-
- e_cal_backend_notify_object_removed (E_CAL_BACKEND (cr->cbc), id, comp_str, NULL);
-
- e_cal_component_free_id (id);
+ e_cal_component_get_uid (cr->comp_anniversary, &uid);
+ e_cal_backend_notify_object_removed (E_CAL_BACKEND (cr->cbc), uid, comp_str, NULL);
g_free (comp_str);
g_object_unref (G_OBJECT (cr->comp_anniversary));
}
if (!g_hash_table_lookup (context->new_uid_hash, uid)) {
icalcomponent *old_icomp;
gchar *old_obj_str;
- ECalComponent *comp;
- ECalComponentId *id;
/* Object was removed */
old_obj_str = icalcomponent_as_ical_string (old_icomp);
if (!old_obj_str)
return;
-
- comp = e_cal_component_new_from_string (old_obj_str);
- id = e_cal_component_get_id (comp);
-
- e_cal_backend_notify_object_removed (context->backend, id, old_obj_str, NULL);
-
- e_cal_component_free_id (id);
- g_object_unref (comp);
+ e_cal_backend_notify_object_removed (context->backend, uid, old_obj_str, NULL);
}
}
break;
case ICAL_METHOD_CANCEL:
if (cancel_received_object (cbfile, subcomp)) {
- ECalComponentId *id;
object = (char *) icalcomponent_as_ical_string (subcomp);
obj_data = g_hash_table_lookup (priv->comp_uid_hash, uid);
if (obj_data)
else
old_object = NULL;
- id = e_cal_component_get_id (comp);
-
- e_cal_backend_notify_object_removed (E_CAL_BACKEND (backend), id, old_object, object);
+ e_cal_backend_notify_object_removed (E_CAL_BACKEND (backend), uid, old_object, object);
/* remove the component from the toplevel VCALENDAR */
icalcomponent_remove_component (toplevel_comp, subcomp);
icalcomponent_free (subcomp);
- e_cal_component_free_id (id);
g_free (old_object);
}
}
e_cal_component_set_dtstart (comp, &dt);
+ g_free (t);
}
else
return NULL;
recur_id->type = E_CAL_COMPONENT_RANGE_SINGLE;
recur_id->datetime = dt;
e_cal_component_set_recurid (comp, recur_id);
+
} else {
uid = e_gw_item_get_icalid (item);
return NULL;
}
}
-
- g_free (t);
/* classification */
description = e_gw_item_get_classification (item);
}
EGwConnectionStatus
-e_gw_connection_send_appointment (ECalBackendGroupwise *cbgw, const char *container, ECalComponent *comp, icalproperty_method method, gboolean all_instances, ECalComponent **created_comp, icalparameter_partstat *pstatus)
+e_gw_connection_send_appointment (ECalBackendGroupwise *cbgw, const char *container, ECalComponent *comp, icalproperty_method method, gboolean *remove, ECalComponent **created_comp)
{
EGwConnection *cnc;
EGwConnectionStatus status;
icalparameter_partstat partstat;
char *item_id = NULL;
const char *gw_id;
+ gboolean all_instances = FALSE;
+ icalproperty *icalprop;
+ icalcomponent *icalcomp;
const char *recurrence_key = NULL;
- gboolean need_to_get = FALSE;
cnc = e_cal_backend_groupwise_get_connection (cbgw);
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);
e_cal_component_commit_sequence (comp);
+ /* When the icalcomponent is obtained through the itip message rather
+ * than from the SOAP protocol, the container id has to be explicitly
+ * added to the xgwrecordid inorder to obtain the item id. */
+
+ /* handle recurrences - All */
+ icalcomp = e_cal_component_get_icalcomponent (comp);
+
+ icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
+ while (icalprop) {
+ const char *x_name;
+ x_name = icalproperty_get_x_name (icalprop);
+ if (!strcmp (x_name, "X-GW-RECUR-INSTANCES-MOD-TYPE")) {
+ if (!strcmp (icalproperty_get_x (icalprop), "All"))
+ all_instances = TRUE;
+ if (recurrence_key)
+ break;
+ }
+ if (!strcmp (x_name, "X-GW-RECURRENCE-KEY")) {
+ e_cal_component_get_uid (comp, &recurrence_key);
+ }
+ icalprop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY);
+ }
+
gw_id = e_cal_component_get_gw_id (comp);
switch (e_cal_component_get_vtype (comp)) {
case E_CAL_COMPONENT_EVENT:
- if (!g_str_has_suffix (gw_id, container)) {
+ if (!g_str_has_suffix (gw_id, container))
item_id = g_strconcat (e_cal_component_get_gw_id (comp), GW_EVENT_TYPE_ID, container, NULL);
- need_to_get = TRUE;
-
- }
else
item_id = g_strdup (gw_id);
break;
case E_CAL_COMPONENT_TODO:
- if (!g_str_has_suffix (gw_id, container)) {
+ if (!g_str_has_suffix (gw_id, container))
item_id = g_strconcat (e_cal_component_get_gw_id (comp), GW_TODO_TYPE_ID, container, NULL);
- need_to_get = TRUE;
-
- }
else
item_id = g_strdup (gw_id);
break;
return E_GW_CONNECTION_STATUS_INVALID_OBJECT;
}
- if (all_instances)
- e_cal_component_get_uid (comp, &recurrence_key);
-
- /*FIXME - remove this once the server returns us the same iCalid in both interfaces */
-
- if (need_to_get) {
- EGwItem *item = NULL;
-
- status = e_gw_connection_get_item (cnc, container, item_id, "recipients message recipientStatus attachments default", &item);
- if (status == E_GW_CONNECTION_STATUS_OK)
- *created_comp = e_gw_item_to_cal_component (item, cbgw);
-
- g_object_unref (item);
- }
-
switch (method) {
case ICAL_METHOD_REQUEST:
/* get attendee here and add the list along. */
status = E_GW_CONNECTION_STATUS_INVALID_OBJECT;
break;
}
- *pstatus = partstat;
switch (partstat) {
ECalComponentTransparency transp;
else
status = e_gw_connection_decline_request (cnc, item_id, NULL, NULL);
+ *remove = TRUE;
break;
case ICAL_PARTSTAT_TENTATIVE:
if (all_instances)
case ICAL_METHOD_CANCEL:
status = e_gw_connection_retract_request (cnc, item_id, NULL, FALSE, FALSE);
+ *remove = TRUE;
break;
default:
return E_GW_CONNECTION_STATUS_INVALID_OBJECT;
}
+ if (status == E_GW_CONNECTION_STATUS_ITEM_ALREADY_ACCEPTED)
+ return status;
+
+ /*FIXME - handling recurrence items */
+ if (!*remove && status == E_GW_CONNECTION_STATUS_OK) {
+ EGwItem *item = NULL;
+ EGwConnectionStatus stat;
+
+ stat = e_gw_connection_get_item (cnc, container, item_id, "recipients message recipientStatus attachments default", &item);
+ if (stat == E_GW_CONNECTION_STATUS_OK)
+ *created_comp = e_gw_item_to_cal_component (item, cbgw);
+ }
+
return status;
}
* Connection-related utility functions
*/
EGwConnectionStatus e_gw_connection_create_appointment (EGwConnection *cnc, const char *container, ECalBackendGroupwise *cbgw, ECalComponent *comp, GSList **id_list);
-EGwConnectionStatus e_gw_connection_send_appointment (ECalBackendGroupwise *cbgw, const char *container, ECalComponent *comp, icalproperty_method method, gboolean all_instances, ECalComponent **created_comp, icalparameter_partstat *pstatus);
+EGwConnectionStatus e_gw_connection_send_appointment (ECalBackendGroupwise *cbgw, const char *container, ECalComponent *comp, icalproperty_method method, gboolean *remove, ECalComponent **created_comp);
EGwConnectionStatus e_gw_connection_get_freebusy_info (EGwConnection *cnc, GList *users, time_t start, time_t end, GList **freebusy, icaltimezone *default_zone);
void e_cal_backend_groupwise_store_settings (EGwSendOptions *opts, ECalBackendGroupwise *cbgw);
EGwItem * e_gw_item_new_for_delegate_from_cal (ECalBackendGroupwise *cbgw, ECalComponent *comp);
ECalBackendSyncStatus status;
const char *id_to_remove = NULL;
icalcomponent *icalcomp;
-
- status = e_cal_backend_groupwise_get_object (backend, cal, uid, rid, &calobj);
- if (status != GNOME_Evolution_Calendar_Success)
- return status;
- g_message ("object found \n");
-
- icalcomp = icalparser_parse_string (calobj);
- if (!icalcomp) {
- g_free (calobj);
- return GNOME_Evolution_Calendar_InvalidObject;
- }
if (mod == CALOBJ_MOD_THIS) {
+
+ status = e_cal_backend_groupwise_get_object (backend, cal, uid, rid, &calobj);
+ if (status != GNOME_Evolution_Calendar_Success)
+ return status;
+
+ *old_object = strdup (calobj);
+
+ icalcomp = icalparser_parse_string (calobj);
+ if (!icalcomp) {
+ g_free (calobj);
+ return GNOME_Evolution_Calendar_InvalidObject;
+ }
+
id_to_remove = get_gw_item_id (icalcomp);
if (!id_to_remove) {
/* use the iCalId to remove the object */
return GNOME_Evolution_Calendar_ObjectNotFound;
}
*object = NULL;
- *old_object = strdup (calobj);
g_free (calobj);
return GNOME_Evolution_Calendar_Success;
} else {
status = e_gw_connection_decline_request (priv->cnc, id_to_remove, NULL, uid);
} else {
GList *item_ids = NULL;
-
for (l = comp_list; l; l = l->next) {
ECalComponent *comp = E_CAL_COMPONENT (l->data);
for (l = comp_list; l; l = l->next) {
ECalComponent *comp = E_CAL_COMPONENT (l->data);
- ECalComponentId *id = e_cal_component_get_id (comp);
-
- e_cal_backend_cache_remove_component (priv->cache, id->uid,
- id->rid);
- if (!g_str_equal (id->rid, rid))
- e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgw), id, e_cal_component_get_as_string (comp), NULL);
- e_cal_component_free_id (id);
-
+ e_cal_backend_cache_remove_component (priv->cache, uid,
+ e_cal_component_get_recurid_as_string (comp));
+ e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgw),
+ uid, e_cal_component_get_as_string (comp), NULL);
g_object_unref (comp);
}
/* Setting NULL would trigger another signal.
* We do not set the *object to NULL */
g_slist_free (comp_list);
- *old_object = strdup (calobj);
- *object = NULL;
- g_free (calobj);
return GNOME_Evolution_Calendar_Success;
} else {
- g_free (calobj);
return GNOME_Evolution_Calendar_OtherError;
}
} else
e_cal_component_set_attachment_list (comp, new_attach_list);
}
-static void
-change_status (ECalComponent *comp, icalparameter_partstat status, const char *email)
-{
- icalproperty *prop;
- icalparameter *param;
- gboolean found = FALSE;
- icalcomponent *icalcomp = e_cal_component_get_icalcomponent (comp);
-
-
- for (prop = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
- prop;
- prop = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY)) {
- const char *attendee = icalproperty_get_attendee (prop);
-
- if (!g_strncasecmp (attendee, "mailto:", 7))
- attendee += 7;
-
- if (!g_ascii_strcasecmp (attendee, email)) {
- found = TRUE;
- param = icalparameter_new_partstat (status);
- icalproperty_set_parameter (prop, param);
- break;
- }
- }
-
- /* We couldn find the attendee in the component, so add a new attendee */
- if (!found) {
- char *temp = g_strdup_printf ("MAILTO:%s", email);
-
- prop = icalproperty_new_attendee ((const char *) temp);
- icalcomponent_add_property (icalcomp, prop);
-
- param = icalparameter_new_partstat (ICAL_PARTSTAT_DELEGATED);
- icalproperty_add_parameter (prop, param);
-
- param = icalparameter_new_role (ICAL_ROLE_NONPARTICIPANT);
- icalproperty_add_parameter (prop, param);
-
- param = icalparameter_new_cutype (ICAL_CUTYPE_INDIVIDUAL);
- icalproperty_add_parameter (prop, param);
-
- param = icalparameter_new_rsvp (ICAL_RSVP_TRUE);
- icalproperty_add_parameter (prop, param);
-
- g_free (temp);
- }
-}
-
static ECalBackendSyncStatus
receive_object (ECalBackendGroupwise *cbgw, EDataCal *cal, icalcomponent *icalcomp)
{
ECalBackendGroupwisePrivate *priv;
icalproperty_method method;
EGwConnectionStatus status;
- gboolean all_instances = FALSE;
- icalparameter_partstat pstatus;
- icalproperty *icalprop;
+ gboolean remove = FALSE;
priv = cbgw->priv;
- /* When the icalcomponent is obtained through the itip message rather
- * than from the SOAP protocol, the container id has to be explicitly
- * added to the xgwrecordid inorder to obtain the item id. */
- icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY);
- while (icalprop) {
- const char *x_name;
-
- x_name = icalproperty_get_x_name (icalprop);
- if (!strcmp (x_name, "X-GW-RECUR-INSTANCES-MOD-TYPE")) {
- if (!strcmp (icalproperty_get_x (icalprop), "All")) {
- all_instances = TRUE;
- icalcomponent_remove_property (icalcomp, icalprop);
- break;
- }
- }
-
- icalprop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY);
- }
-
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (icalcomp));
method = icalcomponent_get_method (icalcomp);
if (e_cal_component_has_attachments (comp))
fetch_attachments (cbgw, comp);
- status = e_gw_connection_send_appointment (cbgw, priv->container_id, comp, method, all_instances, &modif_comp, &pstatus);
+ status = e_gw_connection_send_appointment (cbgw, priv->container_id, comp, method, &remove, &modif_comp);
if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
- status = e_gw_connection_send_appointment (cbgw, priv->container_id, comp, method, all_instances, &modif_comp, &pstatus);
+ status = e_gw_connection_send_appointment (cbgw, priv->container_id, comp, method, &remove, &modif_comp);
- if (!modif_comp)
- modif_comp = g_object_ref (comp);
+ if (status == E_GW_CONNECTION_STATUS_ITEM_ALREADY_ACCEPTED) {
+ g_object_unref (comp);
+ return GNOME_Evolution_Calendar_Success;
+ }
/* update the cache */
- if (status == E_GW_CONNECTION_STATUS_OK || status == E_GW_CONNECTION_STATUS_ITEM_ALREADY_ACCEPTED) {
- GSList *comps = NULL, *l;
- gboolean found = FALSE;
-
- if (all_instances) {
+ if (status == E_GW_CONNECTION_STATUS_OK) {
+ if (remove) {
const char *uid;
-
- e_cal_component_get_uid (modif_comp, (const char **) &uid);
- comps = e_cal_backend_cache_get_components_by_uid (priv->cache, uid);
-
- if (!comps)
- comps = g_slist_append (comps, g_object_ref (modif_comp));
- else
- found = TRUE;
- } else {
- ECalComponentId *id = e_cal_component_get_id (modif_comp);
- ECalComponent *comp = NULL;
-
- comp = e_cal_backend_cache_get_component (priv->cache, id->uid, id->rid);
-
- if (!comp)
- comps = g_slist_append (comps, g_object_ref (modif_comp));
- else {
- comps = g_slist_append (comps, comp);
- found = TRUE;
- }
-
- e_cal_component_free_id (id);
+
+ e_cal_component_get_uid (comp, (const char **) &uid);
+ if (e_cal_backend_cache_remove_component (priv->cache, uid, NULL))
+ e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgw), uid, e_cal_component_get_as_string (comp), NULL);
}
-
- for (l = comps; l != NULL; l = l->next) {
- ECalComponent *comp = E_CAL_COMPONENT (l->data);
-
- if (pstatus == ICAL_PARTSTAT_DECLINED) {
- ECalComponentId *id = e_cal_component_get_id (comp);
-
- if (e_cal_backend_cache_remove_component (priv->cache, id->uid, id->rid)) {
-
- e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbgw), id, e_cal_component_get_as_string (comp), NULL);
- e_cal_component_free_id (id);
+ else {
+ char *cache_comp = NULL, *uid, *new_comp = NULL;
+ ECalComponent *cache_component;
+
+ if (!modif_comp)
+ modif_comp = g_object_ref (comp);
+ else
+ e_cal_component_commit_sequence (modif_comp);
- }
+ e_cal_component_get_uid (modif_comp, (const char **) &uid);
+ cache_component = e_cal_backend_cache_get_component (priv->cache, uid, NULL);
+
+ if (cache_component) {
+ e_cal_component_commit_sequence (cache_component);
+ cache_comp = e_cal_component_get_as_string (cache_component);
+ }
- } else {
- char *comp_str = NULL;
+ e_cal_backend_cache_put_component (priv->cache, modif_comp);
+ new_comp = e_cal_component_get_as_string (modif_comp);
- change_status (comp, pstatus, e_gw_connection_get_user_email (priv->cnc));
- e_cal_backend_cache_put_component (priv->cache, comp);
- comp_str = e_cal_component_get_as_string (comp);
+ if (cache_comp)
+ e_cal_backend_notify_object_modified (E_CAL_BACKEND (cbgw), cache_comp, new_comp);
+ else
+ e_cal_backend_notify_object_created (E_CAL_BACKEND (cbgw), new_comp);
- if (found)
- e_cal_backend_notify_object_modified (E_CAL_BACKEND (cbgw), comp_str, comp_str);
- else
- e_cal_backend_notify_object_created (E_CAL_BACKEND (cbgw), comp_str);
-
- g_free (comp_str);
- }
- }
-
- g_slist_foreach (comps, (GFunc) g_object_unref, NULL);
- g_slist_free (comps);
+ g_free (cache_comp);
+ g_free (new_comp);
+ g_object_unref (modif_comp);
+ }
g_object_unref (comp);
- g_object_unref (modif_comp);
- return GNOME_Evolution_Calendar_Success;
-
+ return GNOME_Evolution_Calendar_Success;
}
if (status == E_GW_CONNECTION_STATUS_INVALID_OBJECT) {
const char *uid = key;
const char *calobj = value;
ECalBackendHttp *cbhttp = E_CAL_BACKEND_HTTP (user_data);
- ECalComponent *comp = e_cal_component_new_from_string (calobj);
- ECalComponentId *id = e_cal_component_get_id (comp);
- e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbhttp), id, calobj, NULL);
-
- e_cal_component_free_id (comp);
- g_object_unref (comp);
+ e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbhttp), uid, calobj, NULL);
return TRUE;
}
l = e_cal_backend_cache_get_components (priv->cache);
for (; l != NULL; l = g_list_next (l)) {
icomp = e_cal_component_get_icalcomponent (E_CAL_COMPONENT (l->data));
- ECalComponentId *id = e_cal_component_get_id (E_CAL_COMPONENT (l->data));
-
e_cal_backend_notify_object_removed (E_CAL_BACKEND (cbw),
- id,
+ icalcomponent_get_uid (icomp),
icalcomponent_as_ical_string (icomp),
NULL);
-
- e_cal_component_free_id (id);
g_object_unref (G_OBJECT (l->data));
}
g_list_free (l);
/* A unique identifier for a calendar component */
typedef string CalObjUID;
- /* A unique identifier for an event recurrence */
+ /* A unique identified for an event recurrence */
typedef string CalRecurID;
/* Simple sequence of strings */
/* Sequence of unique identifiers */
typedef sequence<CalObjUID> CalObjUIDSeq;
- /* A unique identifier and the recurrence id for calendar components */
- struct CalObjID {
- CalObjUID uid;
- CalRecurID rid;
- };
-
- /* sequence of ids of calendar components */
- typedef sequence<CalObjID> CalObjIDSeq;
-
/* A VTIMEZONE component, represented as an iCalendar string. */
typedef string CalTimezoneObj;
interface CalViewListener : Bonobo::Unknown {
oneway void notifyObjectsAdded (in stringlist objects);
oneway void notifyObjectsModified (in stringlist objects);
- oneway void notifyObjectsRemoved (in CalObjIDSeq ids);
+ oneway void notifyObjectsRemoved (in CalObjUIDSeq uids);
oneway void notifyQueryProgress (in string message, in short percent);
oneway void notifyQueryDone (in CallStatus status);
};
g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), NULL);
priv = comp->priv;
+ g_return_val_if_fail (priv->need_sequence_inc == FALSE, NULL);
return priv->icalcomp;
}
}
/**
- * e_cal_component_get_id:
- * @comp: A calendar component object.
- *
- * Return value: the id of the component
- * */
-ECalComponentId *
-e_cal_component_get_id (ECalComponent *comp)
-{
- ECalComponentPrivate *priv;
- ECalComponentId *id = NULL;
-
- g_return_if_fail (comp != NULL);
- g_return_if_fail (E_IS_CAL_COMPONENT (comp));
-
- priv = comp->priv;
- g_return_if_fail (priv->icalcomp != NULL);
-
- id = g_new0 (ECalComponentId, 1);
- id->uid = g_strdup (icalproperty_get_uid (priv->uid));
- id->rid = g_strdup (e_cal_component_get_recurid_as_string (comp));
-
- return id;
-}
-
-/**
* e_cal_component_get_uid:
* @comp: A calendar component object.
* @uid: Return value for the UID string.
}
/**
- * e_cal_component_free_id:
- * @id Component Id.
- *
- * Frees the id.
- **/
-void
-e_cal_component_free_id (ECalComponentId *id)
-{
- g_return_if_fail (id != NULL);
-
- if (id->uid) {
- g_free (id->uid);
- id->uid = NULL;
- }
-
- if (id->rid) {
- g_free (id->rid);
- id->rid = NULL;
- }
-
- g_free (id);
-}
-
-/**
* e_cal_component_free_text_list:
* @text_list: List of #ECalComponentText structures.
*
#define E_IS_CAL_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CAL_COMPONENT))
#define E_IS_CAL_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CAL_COMPONENT))
-typedef struct {
- char *uid;
- char *rid;
-} ECalComponentId;
-
/* Types of calendar components to be stored by a ECalComponent, as per RFC 2445.
* We don't put the alarm component type here since we store alarms as separate
* structures inside the other "real" components.
void e_cal_component_get_uid (ECalComponent *comp, const char **uid);
void e_cal_component_set_uid (ECalComponent *comp, const char *uid);
-ECalComponentId *e_cal_component_get_id (ECalComponent *comp);
-void e_cal_component_free_id (ECalComponentId *id);
-
void e_cal_component_get_categories (ECalComponent *comp, const char **categories);
void e_cal_component_set_categories (ECalComponent *comp, const char *categories);
void e_cal_component_get_categories_list (ECalComponent *comp, GSList **categ_list);
}
static GList *
-build_id_list (const GNOME_Evolution_Calendar_CalObjUIDSeq *seq)
+build_uid_list (const GNOME_Evolution_Calendar_CalObjUIDSeq *seq)
{
GList *list;
int i;
list = NULL;
- for (i = 0; i < seq->_length; i++) {
- GNOME_Evolution_Calendar_CalObjID *corba_id;
- ECalComponentId *id;
-
- corba_id = &seq->_buffer[i];
- id = g_new (ECalComponentId, 1);
-
- id->uid = g_strdup (corba_id->uid);
- id->rid = g_strdup (corba_id->rid);
-
- list = g_list_prepend (list, id);
- }
+ for (i = 0; i < seq->_length; i++)
+ list = g_list_prepend (list, g_strdup (seq->_buffer[i]));
return list;
}
static void
impl_notifyObjectsRemoved (PortableServer_Servant servant,
- const GNOME_Evolution_Calendar_CalObjIDSeq *ids,
+ const GNOME_Evolution_Calendar_CalObjUIDSeq *uids,
CORBA_Environment *ev)
{
ECalViewListener *ql;
ECalViewListenerPrivate *priv;
- GList *id_list, *l;
+ GList *uid_list, *l;
ql = E_CAL_VIEW_LISTENER (bonobo_object_from_servant (servant));
priv = ql->priv;
- id_list = build_id_list (ids);
+ uid_list = build_uid_list (uids);
- g_signal_emit (G_OBJECT (ql), signals[OBJECTS_REMOVED], 0, id_list);
+ g_signal_emit (G_OBJECT (ql), signals[OBJECTS_REMOVED], 0, uid_list);
- for (l = id_list; l; l = l->next)
- e_cal_component_free_id (l->data);
- g_list_free (id_list);
+ for (l = uid_list; l; l = l->next)
+ g_free (l->data);
+ g_list_free (uid_list);
}
static void
}
static void
-objects_removed_cb (ECalViewListener *listener, GList *ids, gpointer data)
+objects_removed_cb (ECalViewListener *listener, GList *uids, gpointer data)
{
ECalView *view;
view = E_CAL_VIEW (data);
g_object_ref (view);
- g_signal_emit (G_OBJECT (view), signals[OBJECTS_REMOVED], 0, ids);
+ g_signal_emit (G_OBJECT (view), signals[OBJECTS_REMOVED], 0, uids);
g_object_unref (view);
}
* Return value: TRUE on success, FALSE if the object was not found.
**/
gboolean
-e_cal_get_alarms_for_object (ECal *ecal, const ECalComponentId *id,
+e_cal_get_alarms_for_object (ECal *ecal, const char *uid,
time_t start, time_t end,
ECalComponentAlarms **alarms)
{
priv = ecal->priv;
g_return_val_if_fail (priv->load_state == E_CAL_LOAD_LOADED, FALSE);
- g_return_val_if_fail (id != NULL, FALSE);
+ g_return_val_if_fail (uid != NULL, FALSE);
g_return_val_if_fail (start >= 0 && end >= 0, FALSE);
g_return_val_if_fail (start <= end, FALSE);
g_return_val_if_fail (alarms != NULL, FALSE);
*alarms = NULL;
- if (!e_cal_get_object (ecal, id->uid, id->rid, &icalcomp, NULL))
+ if (!e_cal_get_object (ecal, uid, NULL, &icalcomp, NULL))
return FALSE;
if (!icalcomp)
return FALSE;
void e_cal_free_alarms (GSList *comp_alarms);
-gboolean e_cal_get_alarms_for_object (ECal *ecal, const ECalComponentId *id,
+gboolean e_cal_get_alarms_for_object (ECal *ecal, const char *uid,
time_t start, time_t end,
ECalComponentAlarms **alarms);
== GNOME_Evolution_Calendar_Success) {
e_data_cal_notify_object_modified (cal, status, old_object, calobj);
g_free (calobj);
- } else {
- ECalComponentId *id = g_new0 (ECalComponentId, 1);
- id->uid = g_strdup (uid);
-
- if (mod == CALOBJ_MOD_THIS)
- id->rid = g_strdup (rid);
-
- e_data_cal_notify_object_removed (cal, status, id, old_object, object);
-
- e_cal_component_free_id (id);
-
- }
+ } else
+ e_data_cal_notify_object_removed (cal, status, uid, old_object, object);
} else
- e_data_cal_notify_object_removed (cal, status, NULL, old_object, object);
+ e_data_cal_notify_object_removed (cal, status, uid, old_object, object);
g_free (object);
}
static void
match_query_and_notify (EDataCalView *query, const char *old_object, const char *object)
{
- gboolean old_match = FALSE, new_match = FALSE;
-
- if (old_object)
- old_match = e_data_cal_view_object_matches (query, old_object);
+ gboolean old_match, new_match;
+ old_match = e_data_cal_view_object_matches (query, old_object);
new_match = e_data_cal_view_object_matches (query, object);
if (old_match && new_match)
e_data_cal_view_notify_objects_modified_1 (query, object);
else if (new_match)
e_data_cal_view_notify_objects_added_1 (query, object);
else if (old_match) {
- ECalComponent *comp = NULL;
+ icalcomponent *icalcomp;
- comp = e_cal_component_new_from_string (old_object);
- if (comp) {
- ECalComponentId *id = e_cal_component_get_id (comp);
-
- e_data_cal_view_notify_objects_removed_1 (query, id);
-
- e_cal_component_free_id (id);
- g_object_unref (comp);
+ icalcomp = icalcomponent_new_from_string ((char *) old_object);
+ if (icalcomp) {
+ e_data_cal_view_notify_objects_removed_1 (query, icalcomponent_get_uid (icalcomp));
+ icalcomponent_free (icalcomp);
}
}
}
/**
* e_cal_backend_notify_object_removed:
* @backend: A calendar backend.
- * @id: the Id of the removed object
+ * @uid: the UID of the removed object
* @old_object: iCalendar representation of the removed object
* @new_object: iCalendar representation of the object after the removal. This
* only applies to recurrent appointments that had an instance removed. In that
* removed by non-EDS clients.
**/
void
-e_cal_backend_notify_object_removed (ECalBackend *backend, const ECalComponentId *id,
+e_cal_backend_notify_object_removed (ECalBackend *backend, const char *uid,
const char *old_object, const char *object)
{
ECalBackendPrivate *priv;
priv = backend->priv;
if (priv->notification_proxy) {
- e_cal_backend_notify_object_removed (priv->notification_proxy, id, old_object, object);
+ e_cal_backend_notify_object_removed (priv->notification_proxy, uid, old_object, object);
return;
}
/* if object == NULL, it means the object has been completely
removed from the backend */
if (e_data_cal_view_object_matches (query, old_object))
- e_data_cal_view_notify_objects_removed_1 (query, id);
+ e_data_cal_view_notify_objects_removed_1 (query, uid);
} else
match_query_and_notify (query, old_object, object);
void e_cal_backend_set_notification_proxy (ECalBackend *backend, ECalBackend *proxy);
void e_cal_backend_notify_object_created (ECalBackend *backend, const char *calobj);
void e_cal_backend_notify_object_modified (ECalBackend *backend, const char *old_object, const char *object);
-void e_cal_backend_notify_object_removed (ECalBackend *backend, const ECalComponentId *id, const char *old_object, const char *object);
+void e_cal_backend_notify_object_removed (ECalBackend *backend, const char *uid, const char *old_object, const char *object);
void e_cal_backend_notify_mode (ECalBackend *backend,
GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
}
static gboolean
-uncache_with_id_cb (gpointer key, gpointer value, gpointer user_data)
+uncache_with_uid_cb (gpointer key, gpointer value, gpointer user_data)
{
ECalComponent *comp;
- ECalComponentId *id;
const char *this_uid;
- char *object;
- gboolean remove = FALSE;
+ char *uid, *object;
- id = user_data;
+ uid = user_data;
object = value;
comp = e_cal_component_new_from_string (object);
if (comp) {
e_cal_component_get_uid (comp, &this_uid);
- if (this_uid && !strcmp (id->uid, this_uid)) {
- if (id->rid && *id->rid) {
- const char *rid = e_cal_component_get_recurid_as_string (comp);
-
- if (rid && !strcmp (id->rid, rid))
- remove = TRUE;
- } else
- remove = TRUE;
+ if (this_uid && *this_uid && !strcmp (uid, this_uid)) {
+ g_object_unref (comp);
+ return TRUE;
}
g_object_unref (comp);
}
- return remove;
+ return FALSE;
}
static void
-remove_object_from_cache (EDataCalView *query, const ECalComponentId *id)
+remove_object_from_cache (EDataCalView *query, const char *uid)
{
EDataCalViewPrivate *priv;
priv = query->priv;
- g_hash_table_foreach_remove (priv->matched_objects, (GHRFunc) uncache_with_id_cb, (gpointer) id);
+ g_hash_table_foreach_remove (priv->matched_objects, (GHRFunc) uncache_with_uid_cb, (gpointer) uid);
}
static void
/**
* e_data_cal_view_notify_objects_removed:
* @query: A query object.
- * @ids: List of IDs for the objects that have been removed.
+ * @uids: List of UIDs for the objects that have been removed.
*
* Notifies all query listener of the removal of a list of objects.
*/
void
-e_data_cal_view_notify_objects_removed (EDataCalView *query, const GList *ids)
+e_data_cal_view_notify_objects_removed (EDataCalView *query, const GList *uids)
{
EDataCalViewPrivate *priv;
- GNOME_Evolution_Calendar_CalObjIDSeq id_list;
+ GNOME_Evolution_Calendar_CalObjUIDSeq uid_list;
CORBA_Environment ev;
const GList *l;
- int num_ids, i;
+ int num_uids, i;
g_return_if_fail (query != NULL);
g_return_if_fail (IS_QUERY (query));
priv = query->priv;
g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
- num_ids = g_list_length ((GList*)ids);
- if (num_ids <= 0)
+ num_uids = g_list_length ((GList*)uids);
+ if (num_uids <= 0)
return;
-
- id_list._buffer = GNOME_Evolution_Calendar_CalObjIDSeq_allocbuf (num_ids);
- id_list._maximum = num_ids;
- id_list._length = num_ids;
-
- i = 0;
- for (l = ids; l; l = l->next, i++) {
- ECalComponentId *id = l->data;
- GNOME_Evolution_Calendar_CalObjID *c_id = &id_list._buffer[i];
-
- c_id->uid = CORBA_string_dup (id->uid);
-
- if (id->rid)
- c_id->rid = CORBA_string_dup (id->rid);
- else
- c_id->rid = CORBA_string_dup ("");
+
+ uid_list._buffer = GNOME_Evolution_Calendar_CalObjUIDSeq_allocbuf (num_uids);
+ uid_list._maximum = num_uids;
+ uid_list._length = num_uids;
+
+ for (l = uids, i = 0; l; l = l->next, i ++) {
+ uid_list._buffer[i] = CORBA_string_dup (l->data);
/* update our cache */
remove_object_from_cache (query, l->data);
}
-
+
for (l = priv->listeners; l != NULL; l = l->next) {
ListenerData *ld = l->data;
CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_CalViewListener_notifyObjectsRemoved (ld->listener, &id_list, &ev);
+ GNOME_Evolution_Calendar_CalViewListener_notifyObjectsRemoved (ld->listener, &uid_list, &ev);
if (BONOBO_EX (&ev))
g_warning (G_STRLOC ": could not notify the listener of object removal");
CORBA_exception_free (&ev);
}
- CORBA_free (id_list._buffer);
+ CORBA_free (uid_list._buffer);
}
/**
* e_data_cal_view_notify_objects_removed:
* @query: A query object.
- * @id: Id of the removed object.
+ * @uid: UID of the removed object.
*
* Notifies all query listener of the removal of a single object.
*/
void
-e_data_cal_view_notify_objects_removed_1 (EDataCalView *query, const ECalComponentId *id)
+e_data_cal_view_notify_objects_removed_1 (EDataCalView *query, const char *uid)
{
EDataCalViewPrivate *priv;
- GList ids;
+ GList uids;
g_return_if_fail (query != NULL);
g_return_if_fail (IS_QUERY (query));
- g_return_if_fail (id != NULL);
+ g_return_if_fail (uid != NULL);
priv = query->priv;
g_return_if_fail (priv->listeners != CORBA_OBJECT_NIL);
- ids.next = ids.prev = NULL;
- ids.data = (gpointer)id;
+ uids.next = uids.prev = NULL;
+ uids.data = (gpointer)uid;
- e_data_cal_view_notify_objects_removed (query, &ids);
+ e_data_cal_view_notify_objects_removed (query, &uids);
}
/**
void e_data_cal_view_notify_objects_modified_1 (EDataCalView *query,
const char *object);
void e_data_cal_view_notify_objects_removed (EDataCalView *query,
- const GList *ids);
+ const GList *uids);
void e_data_cal_view_notify_objects_removed_1 (EDataCalView *query,
- const ECalComponentId *id);
+ const char *uid);
void e_data_cal_view_notify_progress (EDataCalView *query,
const char *message,
int percent);
*/
void
e_data_cal_notify_object_removed (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
- const ECalComponentId *id, const char *old_object, const char *object)
+ const char *uid, const char *old_object, const char *object)
{
EDataCalPrivate *priv;
CORBA_Environment ev;
g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
if (status == GNOME_Evolution_Calendar_Success)
- e_cal_backend_notify_object_removed (priv->backend, id, old_object, object);
+ e_cal_backend_notify_object_removed (priv->backend, uid, old_object, object);
CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_CalListener_notifyObjectRemoved (priv->listener, status, &ev);
void e_data_cal_notify_object_modified (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
const char *old_object, const char *object);
void e_data_cal_notify_object_removed (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
- const ECalComponentId *id, const char *old_object, const char *object);
+ const char *uid, const char *old_object, const char *object);
void e_data_cal_notify_alarm_discarded (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status);
void e_data_cal_notify_objects_received (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status);