[evolution-patches] Exchange, calendar fixes deletion, decline problem
- From: Arunprakash <arunp novell com>
- To: evolution-patches <evolution-patches lists ximian com>
- Subject: [evolution-patches] Exchange, calendar fixes deletion, decline problem
- Date: Fri, 12 Aug 2005 18:18:15 +0530
Hi,
Attached fixes #310478, #310445.
It now enables to delete non-recurring items
and properly updates the calendar items if a
meeting request is declined.
Please review it.
Thanks,
Arunprakash.
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-exchange/ChangeLog,v
retrieving revision 1.369
diff -u -p -r1.369 ChangeLog
--- ChangeLog 9 Aug 2005 08:15:40 -0000 1.369
+++ ChangeLog 12 Aug 2005 12:26:11 -0000
@@ -1,3 +1,15 @@
+2005-08-12 Arunprakash <arunp novell com>
+
+ * calendar/e-cal-backend-exchange-calendar.c (get_cal_owner_email)
+ (find_attendee) (check_owner_partstatus_for_declined) : Newly added
+ to check the partstatus of the calendar item owner.
+ (remove_object) : Rearranged the code to enable the deletion of
+ non-recurring items also.
+ (receive_objects) : Included checks to remove the calendar item
+ if the request is declined later. Also not to create the item if
+ the request is declined.
+ Fixes #310478, #310445.
+
2005-08-08 Sarfraaz Ahmed <asarfraaz novell com>
* configure.in : Bumped the version to 2.3.7
Index: calendar/e-cal-backend-exchange-calendar.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/calendar/e-cal-backend-exchange-calendar.c,v
retrieving revision 1.44
diff -u -p -r1.44 e-cal-backend-exchange-calendar.c
--- calendar/e-cal-backend-exchange-calendar.c 14 Jun 2005 13:12:43 -0000 1.44
+++ calendar/e-cal-backend-exchange-calendar.c 12 Aug 2005 12:26:16 -0000
@@ -35,6 +35,7 @@
#include <e2k-xml-utils.h>
#include <e-folder-exchange.h>
#include <exchange-account.h>
+#include <exchange-hierarchy.h>
#include <mapi.h>
struct ECalBackendExchangeCalendarPrivate {
@@ -548,6 +549,74 @@ check_for_send_options (icalcomponent *i
return exists;
}
+static gchar *
+get_cal_owner_email (ECalBackendSync *backend)
+{
+ ECalBackendExchange *cbex = E_CAL_BACKEND_EXCHANGE (backend);
+ ExchangeHierarchy *hier;
+
+ hier = e_folder_exchange_get_hierarchy (cbex->folder);
+ return g_strdup (hier->owner_email);
+}
+
+/* stolen from e-itip-control.c with some modifications */
+static icalproperty *
+find_attendee (icalcomponent *ical_comp, const char *address)
+{
+ icalproperty *prop;
+
+ if (address == NULL)
+ return NULL;
+
+ for (prop = icalcomponent_get_first_property (ical_comp, ICAL_ATTENDEE_PROPERTY);
+ prop != NULL;
+ prop = icalcomponent_get_next_property (ical_comp, ICAL_ATTENDEE_PROPERTY)) {
+ icalvalue *value;
+ const char *attendee;
+ char *text;
+
+ value = icalproperty_get_value (prop);
+ if (!value)
+ continue;
+
+ attendee = icalvalue_get_string (value);
+
+ if (!g_strncasecmp (attendee, "mailto:", 7))
+ attendee += 7;
+ text = g_strstrip (g_strdup (attendee));
+ if (!g_strcasecmp (address, text)) {
+ g_free (text);
+ return prop;
+ }
+ g_free (text);
+ }
+
+ return NULL;
+}
+
+static gboolean
+check_owner_partstatus_for_declined (ECalBackendSync *backend,
+ icalcomponent *icalcomp)
+{
+ icalproperty *icalprop;
+ icalparameter *param;
+ gchar *email;
+
+ g_return_val_if_fail (E_IS_CAL_BACKEND (backend), FALSE);
+ g_return_val_if_fail (icalcomp != NULL, FALSE);
+
+ email = get_cal_owner_email (backend);
+ icalprop = find_attendee (icalcomp, email);
+ g_free (email);
+
+ param = icalproperty_get_first_parameter (icalprop, ICAL_PARTSTAT_PARAMETER);
+
+ if (icalparameter_get_partstat (param) == ICAL_PARTSTAT_DECLINED) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
static ECalBackendSyncStatus
create_object (ECalBackendSync *backend, EDataCal *cal,
char **calobj, char **uid)
@@ -1195,6 +1264,9 @@ remove_object (ECalBackendSync *backend,
struct icaltimetype time_rid;
ECalBackendSyncStatus ebs_status;
+ /* Will handle only deleting singe instance and all instances of
+ recurring appointments and meetings and non-recurring. */
+
cbexc = E_CAL_BACKEND_EXCHANGE_CALENDAR (backend);
g_return_val_if_fail (E_IS_CAL_BACKEND_EXCHANGE_CALENDAR (cbexc), GNOME_Evolution_Calendar_InvalidObject);
@@ -1214,38 +1286,32 @@ remove_object (ECalBackendSync *backend,
if (old_object)
*old_object = e_cal_component_get_as_string (comp);
- switch (mod) {
+ if (mod == CALOBJ_MOD_THIS && rid && *rid) {
+ /*remove a single instance of a recurring event and modify */
+ if (rid && *rid) {
+ time_rid = icaltime_from_string (rid);
+ e_cal_util_remove_instances (ecomp->icomp, time_rid, mod);
+ }
+ calobj = (char *) icalcomponent_as_ical_string (ecomp->icomp);
+ ebs_status = modify_object (backend, cal, calobj, mod, &obj, NULL);
+ if (ebs_status != GNOME_Evolution_Calendar_Success)
+ goto error;
- case CALOBJ_MOD_ALL:
- ctx = exchange_account_get_context (E_CAL_BACKEND_EXCHANGE (cbexc)->account);
-
- status = e2k_context_delete (ctx, NULL, ecomp->href);
- if (E2K_HTTP_STATUS_IS_SUCCESSFUL (status)) {
-
- if (e_cal_backend_exchange_remove_object (E_CAL_BACKEND_EXCHANGE (cbexc), uid)) {
- g_object_unref (comp);
- return GNOME_Evolution_Calendar_Success;
- }
- }
- *object = NULL;
- break;
- case CALOBJ_MOD_THIS:
- /*remove_instance and modify */
- if (rid && *rid) {
- time_rid = icaltime_from_string (rid);
- e_cal_util_remove_instances (ecomp->icomp, time_rid, mod);
- }
- calobj = (char *) icalcomponent_as_ical_string (ecomp->icomp);
- ebs_status = modify_object (backend, cal, calobj, mod, &obj, NULL);
- if (ebs_status != GNOME_Evolution_Calendar_Success)
- goto error;
-
- g_free (obj);
- return ebs_status;
+ g_free (obj);
+ return ebs_status;
+ }
+
+ ctx = exchange_account_get_context (E_CAL_BACKEND_EXCHANGE (cbexc)->account);
+
+ status = e2k_context_delete (ctx, NULL, ecomp->href);
+ if (E2K_HTTP_STATUS_IS_SUCCESSFUL (status)) {
- default:
- break;
+ if (e_cal_backend_exchange_remove_object (E_CAL_BACKEND_EXCHANGE (cbexc), uid)) {
+ g_object_unref (comp);
+ return GNOME_Evolution_Calendar_Success;
+ }
}
+ *object = NULL;
error:
return GNOME_Evolution_Calendar_OtherError;
@@ -1300,26 +1366,38 @@ receive_objects (ECalBackendSync *backen
case ICAL_METHOD_REQUEST:
case ICAL_METHOD_REPLY:
if (get_exchange_comp (E_CAL_BACKEND_EXCHANGE (cbexc), uid)) {
- char *old_object;
+ char *old_object = NULL;
calobj = (char *) icalcomponent_as_ical_string (subcomp);
- status = modify_object (backend, cal, calobj, CALOBJ_MOD_THIS, &old_object, NULL);
- if (status != GNOME_Evolution_Calendar_Success)
- goto error;
-
- e_cal_backend_notify_object_modified (E_CAL_BACKEND (backend), old_object, calobj);
+ if (check_owner_partstatus_for_declined (backend, subcomp)) {
+ status = remove_object (backend, cal, uid, NULL,
+ CALOBJ_MOD_ALL, &old_object,
+ NULL);
+ if (status != GNOME_Evolution_Calendar_Success)
+ goto error;
+ e_cal_backend_notify_object_removed (E_CAL_BACKEND (backend), uid,
+ old_object, NULL);
+ } else {
+ status = modify_object_with_href (backend, cal, calobj,
+ CALOBJ_MOD_THIS,
+ &old_object, NULL);
+ if (status != GNOME_Evolution_Calendar_Success)
+ goto error;
+ e_cal_backend_notify_object_modified (E_CAL_BACKEND (backend),
+ old_object, calobj);
+ }
g_free (old_object);
- } else {
+ } else if (!check_owner_partstatus_for_declined (backend, subcomp)) {
char *returned_uid;
-
calobj = (char *) icalcomponent_as_ical_string (subcomp);
status = create_object (backend, cal, &calobj, &returned_uid);
if (status != GNOME_Evolution_Calendar_Success)
goto error;
e_cal_backend_notify_object_created (E_CAL_BACKEND (backend), calobj);
- }
+ } else
+ status = GNOME_Evolution_Calendar_Success;
break;
case ICAL_METHOD_ADD:
/* FIXME This should be doable once all the recurid stuff is done ??*/
@@ -1634,7 +1712,7 @@ send_objects (ECalBackendSync *backend,
tzcomp = icalcomponent_get_next_component (top_level,
ICAL_VTIMEZONE_COMPONENT);
}
-
+
for (prop = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY);
prop != NULL;
prop = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]