[evolution-patches] Patch for implementation of modify Cal objects in GW backend
- From: Harish Krishnaswamy <kharish novell com>
- To: patches <evolution-patches lists ximian com>
- Subject: [evolution-patches] Patch for implementation of modify Cal objects in GW backend
- Date: Wed, 12 May 2004 16:00:48 +0530
hi,
the patch contains code that allows modification of calendar objects
using the modifyItemRequest of the GW SOAP interface instead of the
sendItems call.
Also included is a fix for letting evo set the default timezone on the
GW backend.
regards,
harish
Index: servers/groupwise/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/groupwise/ChangeLog,v
retrieving revision 1.40
diff -u -p -r1.40 ChangeLog
--- servers/groupwise/ChangeLog 10 May 2004 08:44:07 -0000 1.40
+++ servers/groupwise/ChangeLog 12 May 2004 10:08:59 -0000
@@ -1,3 +1,11 @@
+2004-05-12 Harish Krishnaswamy <kharish novell com>
+
+ * e-gw-item.c: (append_event_changes_to_soap_message) :
+ check for added, modified and deleted fields and update
+ the soap message.
+ (e_gw_item_append_changes_to_soap_message):
+ Add handlers for Appointment and Task items
+
2004-05-10 Sivaiah Nallagatla <snallagatla novell com>
* e-gw-container.[ch] (e_gw_container_get_is_frequent_contacts)
Index: servers/groupwise/e-gw-item.c
===================================================================
RCS file:
/cvs/gnome/evolution-data-server/servers/groupwise/e-gw-item.c,v
retrieving revision 1.28
diff -u -p -r1.28 e-gw-item.c
--- servers/groupwise/e-gw-item.c 4 May 2004 14:58:41 -0000 1.28
+++ servers/groupwise/e-gw-item.c 12 May 2004 10:08:59 -0000
@@ -506,11 +506,13 @@ e_gw_item_set_category_name (EGwItem *it
{
item->priv->category_name = category_name;
}
+
char*
e_gw_item_get_category_name (EGwItem *item)
{
return item->priv->category_name;
}
+
void e_gw_item_set_change (EGwItem *item, EGwItemChangeType
change_type, char *field_name, gpointer field_value)
{
GHashTable *hash_table;
@@ -1817,6 +1819,88 @@ append_contact_changes_to_soap_message (
}
+static void
+append_event_changes_to_soap_message (EGwItem *item, SoupSoapMessage
*msg, int change_type)
+{
+ GHashTable *changes;
+ EGwItemPrivate *priv;
+ char *dtstring;
+
+ priv = item->priv;
+ changes = NULL;
+ switch (change_type) {
+ case E_GW_ITEM_CHANGE_TYPE_ADD :
+ changes = priv->additions;
+ soup_soap_message_start_element (msg, "add", NULL, NULL);
+ break;
+ case E_GW_ITEM_CHANGE_TYPE_UPDATE :
+ changes = priv->updates;
+ soup_soap_message_start_element (msg, "update", NULL, NULL);
+ break;
+ case E_GW_ITEM_CHANGE_TYPE_DELETE :
+ changes = priv->deletions;
+ soup_soap_message_start_element (msg, "delete", NULL, NULL);
+ break;
+ }
+ if (!changes)
+ return;
+
+ if (g_hash_table_lookup (changes, "subject"))
+ e_gw_message_write_string_parameter (msg, "subject", NULL,
priv->subject ? priv->subject : "");
+ if (g_hash_table_lookup (changes, "startDate")) {
+ if (priv->start_date != -1) {
+ dtstring = timet_to_string (priv->start_date);
+ e_gw_message_write_string_parameter (msg, "startDate", NULL,
dtstring);
+ g_free (dtstring);
+ }
+ }
+ if (g_hash_table_lookup (changes, "endDate")) {
+ if (priv->end_date != -1) {
+ dtstring = timet_to_string (priv->end_date);
+ e_gw_message_write_string_parameter (msg, "endDate", NULL,
dtstring);
+ g_free (dtstring);
+ }
+ }
+ if (g_hash_table_lookup (changes, "message")) {
+ soup_soap_message_start_element (msg, "message", NULL, NULL);
+ if (priv->message) {
+ char *str;
+
+ str = soup_base64_encode (priv->message, strlen (priv->message));
+ dtstring = g_strdup_printf ("%d", strlen (str));
+ soup_soap_message_add_attribute (msg, "length", dtstring, NULL,
NULL);
+ g_free (dtstring);
+ soup_soap_message_write_string (msg, str);
+ g_free (str);
+ } else {
+ soup_soap_message_add_attribute (msg, "length", "0", NULL, NULL);
+ soup_soap_message_write_string (msg, "");
+ }
+
+ soup_soap_message_end_element (msg);
+ }
+ if (g_hash_table_lookup (changes, "class"))
+ e_gw_message_write_string_parameter (msg, "class", NULL,
priv->classification);
+
+ if (g_hash_table_lookup (changes, "acceptLevel"))
+ e_gw_message_write_string_parameter (msg, "acceptLevel", NULL,
priv->accept_level ? priv->accept_level : "");
+ if (g_hash_table_lookup (changes, "place"))
+ e_gw_message_write_string_parameter (msg, "place", NULL, priv->place
? priv->place : "");
+ if (g_hash_table_lookup (changes, "alarm")) {
+ if (priv->trigger != 0) {
+ char *alarm = g_strdup_printf ("%d", priv->trigger);
+ e_gw_message_write_string_parameter_with_attribute (msg, "alarm",
NULL, alarm, "enabled", "true");
+ g_free (alarm);
+ }
+ else
+ e_gw_message_write_string_parameter_with_attribute (msg, "alarm",
NULL, "0", "enabled", "false");
+ }
+ if (g_hash_table_lookup (changes, "completed"))
+ e_gw_message_write_string_parameter (msg, "completed", NULL,
priv->completed ? "1" : "0");
+ soup_soap_message_end_element (msg);
+
+}
+
gboolean
e_gw_item_append_changes_to_soap_message (EGwItem *item,
SoupSoapMessage *msg)
{
@@ -1843,6 +1927,12 @@ e_gw_item_append_changes_to_soap_message
e_gw_message_write_string_parameter (msg, "name", NULL, value);
soup_soap_message_end_element (msg);
soup_soap_message_end_element(msg);
+ return TRUE;
+ case E_GW_ITEM_TYPE_APPOINTMENT:
+ case E_GW_ITEM_TYPE_TASK :
+ append_event_changes_to_soap_message (item, msg,
E_GW_ITEM_CHANGE_TYPE_ADD);
+ append_event_changes_to_soap_message (item, msg,
E_GW_ITEM_CHANGE_TYPE_UPDATE);
+ append_event_changes_to_soap_message (item, msg,
E_GW_ITEM_CHANGE_TYPE_DELETE);
return TRUE;
default :
g_warning (G_STRLOC ": Unknown type for item");
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.257
diff -u -p -r1.257 ChangeLog
--- calendar/ChangeLog 7 May 2004 16:04:17 -0000 1.257
+++ calendar/ChangeLog 12 May 2004 10:09:00 -0000
@@ -1,3 +1,19 @@
+2004-05-12 Harish Krishnaswamy <kharish novell com>
+
+
+ * backends/groupwise/e-cal-backend-groupwise-utils.c:
+ (set_properties_from_cal_component), (e_gw_item_to_cal_component),
+ (e_gw_connection_get_freebusy_info), (e_gw_item_set_changes):
+ Add implementation for modification of objects.
+ * backends/groupwise/e-cal-backend-groupwise-utils.h:
+ Add declaration for e_gw_item_set_changes.
+ * backends/groupwise/e-cal-backend-groupwise.c:
+ (e_cal_backend_groupwise_set_default_timezone):
+ Allow evo to set the timezone in the groupwise backend.
+ (e_cal_backend_groupwise_modify_object):
+ Modify implementation to use modifyItemRequest rather than
+ a sendItem.
+
2004-05-07 JP Rosevear <jpr ximian com>
Fixes #57908
Index: calendar/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.66
diff -u -p -r1.66 e-cal-backend-groupwise.c
--- calendar/backends/groupwise/e-cal-backend-groupwise.c 6 May 2004
04:06:19 -0000 1.66
+++ calendar/backends/groupwise/e-cal-backend-groupwise.c 12 May 2004
10:09:00 -0000
@@ -636,7 +636,16 @@ e_cal_backend_groupwise_add_timezone (EC
static ECalBackendSyncStatus
e_cal_backend_groupwise_set_default_timezone (ECalBackendSync *backend,
EDataCal *cal, const char *tzid)
{
- return GNOME_Evolution_Calendar_OtherError;
+ ECalBackendGroupwise *cbgw;
+ ECalBackendGroupwisePrivate *priv;
+
+ cbgw = E_CAL_BACKEND_GROUPWISE (backend);
+ priv = cbgw->priv;
+
+ /* Set the default timezone to it. */
+ priv->default_zone = icaltimezone_get_builtin_timezone_from_tzid
(tzid);
+
+ return GNOME_Evolution_Calendar_Success;
}
/* Get_objects_in_range handler for the groupwise backend */
@@ -955,8 +964,10 @@ e_cal_backend_groupwise_modify_object (E
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
icalcomponent *icalcomp;
- ECalComponent *comp;
+ ECalComponent *comp, *cache_comp;
EGwConnectionStatus status;
+ EGwItem *item, *cache_item;
+ char *id;
cbgw = E_CAL_BACKEND_GROUPWISE (backend);
priv = cbgw->priv;
@@ -971,18 +982,30 @@ e_cal_backend_groupwise_modify_object (E
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomp);
+ item = e_gw_item_new_from_cal_component (priv->container_id, comp);
/* check if the object exists */
switch (priv->mode) {
case CAL_MODE_ANY :
case CAL_MODE_REMOTE :
/* when online, send the item to the server */
- status = e_gw_connection_send_appointment (priv->cnc,
priv->container_id, comp, NULL);
+ cache_comp = e_cal_backend_cache_get_component (priv->cache,
e_gw_item_get_icalid (item), NULL);
+ if (!cache_comp) {
+ g_message ("CRITICAL : Could not find the object in cache");
+ return GNOME_Evolution_Calendar_InvalidObject;
+ }
+
+ cache_item = e_gw_item_new_from_cal_component (priv->container_id,
cache_comp);
+ e_gw_item_set_changes (item, cache_item);
+
+ // the second argument is redundant.
+ status = e_gw_connection_modify_item (priv->cnc, e_gw_item_get_id
(item), item);
if (status != E_GW_CONNECTION_STATUS_OK) {
g_object_unref (comp);
return GNOME_Evolution_Calendar_OtherError;
}
/* if successful, update the cache */
+
case CAL_MODE_LOCAL :
/* in offline mode, we just update the cache */
e_cal_backend_cache_put_component (priv->cache, comp);
@@ -992,6 +1015,7 @@ e_cal_backend_groupwise_modify_object (E
}
g_object_unref (comp);
+ g_object_unref (cache_comp);
return GNOME_Evolution_Calendar_Success;
}
Index: calendar/backends/groupwise/e-cal-backend-groupwise-utils.h
===================================================================
RCS file:
/cvs/gnome/evolution-data-server/calendar/backends/groupwise/e-cal-backend-groupwise-utils.h,v
retrieving revision 1.3
diff -u -p -r1.3 e-cal-backend-groupwise-utils.h
--- calendar/backends/groupwise/e-cal-backend-groupwise-utils.h 22 Mar
2004 11:07:32 -0000 1.3
+++ calendar/backends/groupwise/e-cal-backend-groupwise-utils.h 12 May
2004 10:09:00 -0000
@@ -34,6 +34,7 @@ G_BEGIN_DECLS
*/
EGwItem *e_gw_item_new_from_cal_component (const char *container,
ECalComponent *comp);
ECalComponent *e_gw_item_to_cal_component (EGwItem *item);
+void e_gw_item_set_changes (EGwItem *item, EGwItem
*cached_item);
/*
* Connection-related utility functions
@@ -41,7 +42,6 @@ ECalComponent *e_gw_item_to_cal_componen
EGwConnectionStatus e_gw_connection_send_appointment (EGwConnection
*cnc, const char *container, ECalComponent *comp, char **id);
EGwConnectionStatus e_gw_connection_get_freebusy_info (EGwConnection
*cnc, GList *users,
time_t start, time_t end, GList **freebusy);
-
G_END_DECLS
Index: calendar/backends/groupwise/e-cal-backend-groupwise-utils.c
===================================================================
RCS file:
/cvs/gnome/evolution-data-server/calendar/backends/groupwise/e-cal-backend-groupwise-utils.c,v
retrieving revision 1.16
diff -u -p -r1.16 e-cal-backend-groupwise-utils.c
--- calendar/backends/groupwise/e-cal-backend-groupwise-utils.c 4 May
2004 05:47:41 -0000 1.16
+++ calendar/backends/groupwise/e-cal-backend-groupwise-utils.c 12 May
2004 10:09:00 -0000
@@ -92,6 +92,12 @@ set_properties_from_cal_component (EGwIt
e_gw_item_set_recipient_list (item, recipient_list);
}
+ /* end date */
+ e_cal_component_get_dtend (comp, &dt);
+ if (dt.value)
+ e_gw_item_set_end_date (item, icaltime_as_timet_with_zone
(*dt.value,
+ icaltimezone_get_builtin_timezone_from_tzid (dt.tzid)));
+
break;
case E_CAL_COMPONENT_TODO :
@@ -182,22 +188,20 @@ set_properties_from_cal_component (EGwIt
/* start date */
e_cal_component_get_dtstart (comp, &dt);
if (dt.value) {
- e_gw_item_set_start_date (item, icaltime_as_timet (*dt.value));
+ e_gw_item_set_start_date (item,
+ icaltime_as_timet_with_zone (*dt.value,
icaltimezone_get_builtin_timezone_from_tzid (dt.tzid)));
} else if (e_gw_item_get_item_type (item) ==
E_GW_ITEM_TYPE_APPOINTMENT) {
/* appointments need the start date property */
g_object_unref (item);
return NULL;
}
- /* end date */
- e_cal_component_get_dtend (comp, &dt);
- if (dt.value)
- e_gw_item_set_end_date (item, icaltime_as_timet (*dt.value));
/* creation date */
e_cal_component_get_created (comp, &dt.value);
if (dt.value) {
- e_gw_item_set_creation_date (item, icaltime_as_timet (*dt.value));
+ e_gw_item_set_creation_date (item,
+ icaltime_as_timet_with_zone (*dt.value,
icaltimezone_get_builtin_timezone_from_tzid (dt.tzid)));
e_cal_component_free_datetime (&dt);
} else {
struct icaltimetype itt;
@@ -302,6 +306,7 @@ e_gw_item_to_cal_component (EGwItem *ite
/* creation date */
t = e_gw_item_get_creation_date (item);
itt = icaltime_from_timet (t, 0);
+
e_cal_component_set_created (comp, &itt);
e_cal_component_set_dtstamp (comp, &itt);
@@ -700,4 +705,74 @@ e_gw_connection_get_freebusy_info (EGwCo
/* closeFreeBusySession*/
return close_freebusy_session (cnc, session);
+}
+
+#define SET_DELTA(fieldname)
G_STMT_START{ \
+ fieldname = e_gw_item_get_##fieldname
(item); \
+ cache_##fieldname = e_gw_item_get_##fieldname
(cache_item); \
+ if ( cache_##fieldname )
{ \
+ if (!fieldname
) \
+ e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_DELETE,
#fieldname, cache_##fieldname );\
+ else if (strcmp ( fieldname, cache_##fieldname
)) \
+ e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_UPDATE,
#fieldname, fieldname );\
+ } \
+ else if ( fieldname
) \
+ e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_ADD, #fieldname,
fieldname ); \
+ }G_STMT_END
+
+void
+e_gw_item_set_changes (EGwItem *item, EGwItem *cache_item)
+{
+ char *subject, *cache_subject;
+ char *message, *cache_message;
+ char *classification, *cache_classification;
+ char *accept_level, *cache_accept_level;
+ char *place, *cache_place;
+ char *priority, *cache_priority;
+
+ /* TODO assert the types of the items are the same */
+
+ SET_DELTA(subject);
+ SET_DELTA(message);
+ SET_DELTA(classification);
+
+ if (difftime (e_gw_item_get_start_date (item),
e_gw_item_get_start_date (cache_item)))
+ e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_UPDATE,
"startDate", e_gw_item_get_start_date (item));
+ if (difftime (e_gw_item_get_end_date (item), e_gw_item_get_end_date
(cache_item)))
+ e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_UPDATE, "endDate",
e_gw_item_get_end_date (item));
+
+ if ( e_gw_item_get_item_type (item) == E_GW_ITEM_TYPE_APPOINTMENT) {
+ accept_level = e_gw_item_get_accept_level
(item);
+ cache_accept_level = e_gw_item_get_accept_level
(cache_item);
+ if ( cache_accept_level )
{
+ if (!accept_level
)
+ e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_DELETE,
"acceptLevel", cache_accept_level );
+ else if (strcmp ( accept_level, cache_accept_level
))
+ e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_UPDATE,
"acceptLevel", accept_level );
+ }
+ else if ( accept_level
)
+ e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_ADD,
"acceptLevel", accept_level );
+
+ SET_DELTA(place);
+ if ( e_gw_item_get_trigger (cache_item) )
{
+ if (!e_gw_item_get_trigger (item)
)
+ e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_DELETE, "alarm",
e_gw_item_get_trigger (cache_item));
+ else if (e_gw_item_get_trigger (item) != e_gw_item_get_trigger
(cache_item))
+ e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_UPDATE, "alarm",
e_gw_item_get_trigger (item));
+ }
+ else if ( e_gw_item_get_trigger (item)
)
+ e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_ADD, "alarm",
e_gw_item_get_trigger (item));
+ }
+
+ if ( e_gw_item_get_item_type (item) == E_GW_ITEM_TYPE_TASK) {
+ gboolean completed, cache_completed;
+
+ if (difftime (e_gw_item_get_due_date (item), e_gw_item_get_due_date
(cache_item)))
+ e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_UPDATE, "dueDate",
e_gw_item_get_due_date (item));
+ completed = e_gw_item_get_completed (item);
+ cache_completed = e_gw_item_get_completed (cache_item);
+ if ((completed && !cache_completed) || (!completed &&
cache_completed))
+ e_gw_item_set_change (item, E_GW_ITEM_CHANGE_TYPE_UPDATE,
"completed", completed);
+ SET_DELTA (priority);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]