diff options
author | Rodrigo Moya <rodrigo@ximian.com> | 2003-12-24 13:17:29 +0000 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2003-12-24 13:17:29 +0000 |
commit | ed1b2e0a53c815ab93e4f0c1f7aac5ebaa46fcb7 (patch) | |
tree | aec26cd4a44fbadeeeca1bd69e6d19b57bfe3c20 | |
parent | 6da6d1ffae46d3a16d4e20d6227520ac8d7ace74 (diff) | |
download | evolution-data-server-ed1b2e0a53c815ab93e4f0c1f7aac5ebaa46fcb7.tar.gz |
added 'session_id' argument, to add the <Header> SOAP part if not NULL.
2003-12-24 Rodrigo Moya <rodrigo@ximian.com>
* backends/groupwise/e-gw-message.[ch] (e_gw_message_new_with_header):
added 'session_id' argument, to add the <Header> SOAP part if not NULL.
* backends/groupwise/e-gw-connection.c (e_gw_connection_get_items): use
e_gw_message_new_with_header to create the SOAP message. Also, unref
the correct object if we don't get a response from
e_gw_connection_send_message, or we when we can't find a parameter in
the response.
(logout): pass session ID to e_gw_message_new_with_header().
(e_gw_connection_new): ditto.
* backends/groupwise/e-cal-backend-groupwise.c: removed 'icalcomp'
field from the ECalBackendGroupwisePrivate structure.
(e_cal_backend_groupwise_get_timezone): don't use priv->icalcomp
to retrieve timezones, since that object is empty, use the libical's
built-in timezones.
(populate_cache): fixed C99'isms and re-enabled g_mutex_lock/_unlock
calls.
2003-12-24 Harish Krishnaswamy <kharish@novell.com>
* backends/groupwise/e-gw-connection.[ch] (e_gw_connection_get_items):
new function.
* backends/groupwise/e-cal-backend-groupwise.c (populate_cache): new
function to populate the cache with all objects from the server.
(e_cal_backend_groupwise_open): call populate_cache when opening the
connection, to get all objects from the server.
(e_cal_backend_groupwise_get_default_object): implemented.
(e_cal_backend_groupwise_get_timezone): implemented.
-rw-r--r-- | calendar/ChangeLog | 33 | ||||
-rw-r--r-- | calendar/backends/groupwise/e-cal-backend-groupwise.c | 118 | ||||
-rw-r--r-- | calendar/backends/groupwise/e-gw-connection.c | 61 | ||||
-rw-r--r-- | calendar/backends/groupwise/e-gw-connection.h | 3 | ||||
-rw-r--r-- | calendar/backends/groupwise/e-gw-message.c | 11 | ||||
-rw-r--r-- | calendar/backends/groupwise/e-gw-message.h | 2 | ||||
-rw-r--r-- | servers/groupwise/e-gw-connection.c | 61 | ||||
-rw-r--r-- | servers/groupwise/e-gw-connection.h | 3 | ||||
-rw-r--r-- | servers/groupwise/e-gw-message.c | 11 | ||||
-rw-r--r-- | servers/groupwise/e-gw-message.h | 2 |
10 files changed, 289 insertions, 16 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 1f585ed0c..cf4b160cb 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,36 @@ +2003-12-24 Rodrigo Moya <rodrigo@ximian.com> + + * backends/groupwise/e-gw-message.[ch] (e_gw_message_new_with_header): + added 'session_id' argument, to add the <Header> SOAP part if not NULL. + + * backends/groupwise/e-gw-connection.c (e_gw_connection_get_items): use + e_gw_message_new_with_header to create the SOAP message. Also, unref + the correct object if we don't get a response from + e_gw_connection_send_message, or we when we can't find a parameter in + the response. + (logout): pass session ID to e_gw_message_new_with_header(). + (e_gw_connection_new): ditto. + + * backends/groupwise/e-cal-backend-groupwise.c: removed 'icalcomp' + field from the ECalBackendGroupwisePrivate structure. + (e_cal_backend_groupwise_get_timezone): don't use priv->icalcomp + to retrieve timezones, since that object is empty, use the libical's + built-in timezones. + (populate_cache): fixed C99'isms and re-enabled g_mutex_lock/_unlock + calls. + +2003-12-24 Harish Krishnaswamy <kharish@novell.com> + + * backends/groupwise/e-gw-connection.[ch] (e_gw_connection_get_items): + new function. + + * backends/groupwise/e-cal-backend-groupwise.c (populate_cache): new + function to populate the cache with all objects from the server. + (e_cal_backend_groupwise_open): call populate_cache when opening the + connection, to get all objects from the server. + (e_cal_backend_groupwise_get_default_object): implemented. + (e_cal_backend_groupwise_get_timezone): implemented. + 2003-12-22 Rodrigo Moya <rodrigo@ximian.com> * libedata-cal/e-cal-backend-sexp.c (func_has_alarms): removed useless diff --git a/calendar/backends/groupwise/e-cal-backend-groupwise.c b/calendar/backends/groupwise/e-cal-backend-groupwise.c index 5ca99a3d1..d93050074 100644 --- a/calendar/backends/groupwise/e-cal-backend-groupwise.c +++ b/calendar/backends/groupwise/e-cal-backend-groupwise.c @@ -174,6 +174,53 @@ convert_uri (const char *gw_uri) return vuri; } +/* Initialy populate the cache from the server */ +//static EGwConnectionStatus +EGwConnectionStatus +populate_cache (ECalBackendGroupwisePrivate *priv) +{ + EGwConnectionStatus status; + SoupSoapParameter *param; + const char *uid; + const char *rid; + const char *calobj; + GSList *list = NULL, *l; + + /* get all the objects from the server */ + status = e_gw_connection_get_items (priv->cnc, &list); + if (status != E_GW_CONNECTION_STATUS_OK) + return status; + + /* update the cache */ + g_mutex_lock (priv->mutex); + + for (l = list; l; l = l->next) { + param = (SoupSoapParameter *) l->data; + uid = soup_soap_parameter_get_first_child_by_name (param, "iCalId"); + rid = soup_soap_parameter_get_first_child_by_name (param, "recurrance"); + calobj = soup_soap_parameter_get_string_value (param); + e_cal_backend_cache_add_component (priv->cache, uid, rid, calobj); + } + + g_mutex_unlock (priv->mutex); + + return E_GW_CONNECTION_STATUS_OK; + +} + +static void +update_cache (gpointer *data) +{ + EGwConnection *cnc; + GList *list; + EGwConnectionStatus status; + + cnc = E_GW_CONNECTION (data); + /* FIXME: Get all changes from the server since last poll */ + /* FIXME: parse the response and update the cache*/ + /*status = e_gw_connection_get_items_with_Filter (cnc, &list);*/ +} + /* Open handler for the file backend */ static ECalBackendSyncStatus e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists, @@ -226,15 +273,25 @@ e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean cbgw->priv->read_only = FALSE; if (E_IS_GW_CONNECTION (priv->cnc)) { + /* Populate the cache for the first time.*/ + /* start a timed polling thread set to 10 minutes*/ + status = populate_cache (priv); + if (status != E_GW_CONNECTION_STATUS_OK) { + g_object_unref (priv->cnc); + priv->cnc = NULL; + g_mutex_unlock (priv->mutex); + g_warning (G_STRLOC ": Could not populate the cache"); + + return GNOME_Evolution_Calendar_OtherError; + } + + /* FIXME : add a symbolic constant for the time-out */ g_mutex_unlock (priv->mutex); + g_timeout_add (600000, (GSourceFunc) update_cache, (gpointer) cbgw); + return GNOME_Evolution_Calendar_Success; } - - /* free memory */ - g_object_unref (priv->cnc); - priv->cnc = NULL; - g_mutex_unlock (priv->mutex); return GNOME_Evolution_Calendar_AuthenticationFailed; @@ -278,6 +335,30 @@ e_cal_backend_groupwise_set_mode (ECalBackend *backend, CalMode mode) static ECalBackendSyncStatus e_cal_backend_groupwise_get_default_object (ECalBackendSync *backend, EDataCal *cal, char **object) { + + ECalComponent *comp; + + comp = e_cal_component_new (); + + switch (e_cal_backend_get_kind (E_CAL_BACKEND (backend))) { + case ICAL_VEVENT_COMPONENT: + e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_EVENT); + break; + case ICAL_VTODO_COMPONENT: + e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_TODO); + break; + case ICAL_VJOURNAL_COMPONENT: + e_cal_component_set_new_vtype (comp, E_CAL_COMPONENT_JOURNAL); + break; + default: + g_object_unref (comp); + return GNOME_Evolution_Calendar_ObjectNotFound; + } + + *object = e_cal_component_get_as_string (comp); + g_object_unref (comp); + + return GNOME_Evolution_Calendar_Success; } /* Get_object_component handler for the file backend */ @@ -301,7 +382,7 @@ e_cal_backend_groupwise_get_object (ECalBackendSync *backend, EDataCal *cal, con return GNOME_Evolution_Calendar_Success; } - /* FIXME: get the object from the server */ + /* callers will never have a uuid that is in server but not in cache */ return GNOME_Evolution_Calendar_ObjectNotFound; } @@ -309,6 +390,31 @@ e_cal_backend_groupwise_get_object (ECalBackendSync *backend, EDataCal *cal, con static ECalBackendSyncStatus e_cal_backend_groupwise_get_timezone (ECalBackendSync *backend, EDataCal *cal, const char *tzid, char **object) { + ECalBackendGroupwise *cbfile; + ECalBackendGroupwisePrivate *priv; + icaltimezone *zone; + icalcomponent *icalcomp; + + cbfile = E_CAL_BACKEND_GROUPWISE (backend); + priv = cbfile->priv; + + g_return_val_if_fail (tzid != NULL, GNOME_Evolution_Calendar_ObjectNotFound); + + if (!strcmp (tzid, "UTC")) { + zone = icaltimezone_get_utc_timezone (); + } else { + zone = icaltimezone_get_builtin_timezone_from_tzid (tzid); + if (!zone) + return GNOME_Evolution_Calendar_ObjectNotFound; + } + + icalcomp = icaltimezone_get_component (zone); + if (!icalcomp) + return GNOME_Evolution_Calendar_InvalidObject; + + *object = g_strdup (icalcomponent_as_ical_string (icalcomp)); + + return GNOME_Evolution_Calendar_Success; } /* Add_timezone handler for the file backend */ diff --git a/calendar/backends/groupwise/e-gw-connection.c b/calendar/backends/groupwise/e-gw-connection.c index 462c6559b..0fd4081b9 100644 --- a/calendar/backends/groupwise/e-gw-connection.c +++ b/calendar/backends/groupwise/e-gw-connection.c @@ -75,7 +75,7 @@ logout (EGwConnection *cnc) g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT); /* build the SOAP message */ - msg = e_gw_message_new_with_header (cnc->priv->uri, "logoutRequest"); + msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "logoutRequest"); e_gw_message_write_string_parameter (msg, "session", cnc->priv->session_id); e_gw_message_write_footer (msg); @@ -264,7 +264,7 @@ e_gw_connection_new (const char *uri, const char *username, const char *password cnc = g_object_new (E_TYPE_GW_CONNECTION, NULL); /* build the SOAP message */ - msg = e_gw_message_new_with_header (uri, "loginRequest"); + msg = e_gw_message_new_with_header (uri, NULL, "loginRequest"); soup_soap_message_start_element (msg, "auth", "types", NULL); soup_soap_message_add_attribute (msg, "type", "types:PlainText", "xsi", "http://www.w3.org/2001/XMLSchema-instance"); @@ -365,6 +365,62 @@ e_gw_connection_logout (EGwConnection *cnc) return E_GW_CONNECTION_STATUS_OK; } +EGwConnectionStatus +e_gw_connection_get_items (EGwConnection *cnc, GSList **list) +{ + SoupSoapMessage *msg; + SoupSoapResponse *response; + EGwConnectionStatus status; + SoupSoapParameter *param; + GList *l; + + g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT); + + /* build the SOAP message */ + /* FIXME : e_gw_message_new_with_header does not allow additional elements to be + added in the header. Using soap_message functions directly.*/ + msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getItemsRequest"); + if (!msg) { + g_warning (G_STRLOC ": Could not build SOAP message"); + return E_GW_CONNECTION_STATUS_UNKNOWN; + } + + /* FIXME: Need to obtain the uid for calendar and use here */ + e_gw_message_write_string_parameter (msg, "container", "A.dom1.po1.100.0.1.0.1@19"); + e_gw_message_write_footer (msg); + + /* send message to server */ + response = e_gw_connection_send_message (cnc, msg); + if (!response) { + g_object_unref (msg); + return E_GW_CONNECTION_STATUS_INVALID_RESPONSE; + } + + status = parse_response_status (response); + if (status != E_GW_CONNECTION_STATUS_OK) { + g_object_unref (response); + return status; + } + + /* if status is OK - parse result. return the list */ + param = soup_soap_response_get_first_parameter_by_name (response, "items"); + if (!param) { + g_object_unref (response); + g_object_unref (msg); + return E_GW_CONNECTION_STATUS_INVALID_RESPONSE; + } + + /* FIXME: iterate through the response and populate the list */ + *l = soup_soap_response_get_parameters (response); + + /* free memory */ + g_object_unref (response); + g_object_unref (msg); + + /* FIXME: when will the cache be cleared ? */ + return E_GW_CONNECTION_STATUS_OK; +} + const char* e_gw_connection_get_user_email (EGwConnection *cnc) { @@ -373,3 +429,4 @@ e_gw_connection_get_user_email (EGwConnection *cnc) return (const char*) cnc->priv->user_email; } + diff --git a/calendar/backends/groupwise/e-gw-connection.h b/calendar/backends/groupwise/e-gw-connection.h index ace08fa42..f402030a1 100644 --- a/calendar/backends/groupwise/e-gw-connection.h +++ b/calendar/backends/groupwise/e-gw-connection.h @@ -62,8 +62,9 @@ typedef enum { SoupSoapResponse *e_gw_connection_send_message (EGwConnection *cnc, SoupSoapMessage *msg); EGwConnectionStatus e_gw_connection_logout (EGwConnection *cnc); +EGwConnectionStatus e_gw_connection_get_items (EGwConnection *cnc, GSList **list); -const char *e_gw_connection_get_user_email (EGwConnection *cnc); +const char *e_gw_connection_get_user_email (EGwConnection *cnc); G_END_DECLS diff --git a/calendar/backends/groupwise/e-gw-message.c b/calendar/backends/groupwise/e-gw-message.c index 299ed3123..25467116a 100644 --- a/calendar/backends/groupwise/e-gw-message.c +++ b/calendar/backends/groupwise/e-gw-message.c @@ -73,7 +73,7 @@ setup_debug (SoupSoapMessage *msg) #endif SoupSoapMessage * -e_gw_message_new_with_header (const char *uri, const char *method_name) +e_gw_message_new_with_header (const char *uri, const char *session_id, const char *method_name) { SoupSoapMessage *msg; @@ -93,6 +93,15 @@ e_gw_message_new_with_header (const char *uri, const char *method_name) #endif soup_soap_message_start_envelope (msg); + if (session_id && *session_id) { + soup_soap_message_start_element (msg, "Header","SOAP-ENV", NULL); + soup_soap_message_add_attribute (msg, "encodingStyle", "", "SOAP-ENV", NULL); + /* FIXME: cannot use e_gw_message_write_string_parameter as it sets prefix -types*/ + soup_soap_message_start_element (msg, "session", NULL, NULL); + soup_soap_message_write_string (msg, session_id); + soup_soap_message_end_element (msg); + soup_soap_message_end_element (msg); + } soup_soap_message_start_body (msg); soup_soap_message_add_attribute (msg, "encodingStyle", "", "SOAP-ENV", NULL); soup_soap_message_add_namespace (msg, "types", "http://schemas.novell.com/2003/10/NCSP/types.xsd"); diff --git a/calendar/backends/groupwise/e-gw-message.h b/calendar/backends/groupwise/e-gw-message.h index 0f5e3899f..aa73b74f0 100644 --- a/calendar/backends/groupwise/e-gw-message.h +++ b/calendar/backends/groupwise/e-gw-message.h @@ -28,7 +28,7 @@ G_BEGIN_DECLS -SoupSoapMessage *e_gw_message_new_with_header (const char *uri, const char *method_name); +SoupSoapMessage *e_gw_message_new_with_header (const char *uri, const char *session_id, const char *method_name); void e_gw_message_write_string_parameter (SoupSoapMessage *msg, const char *name, const char *value); void e_gw_message_write_footer (SoupSoapMessage *msg); diff --git a/servers/groupwise/e-gw-connection.c b/servers/groupwise/e-gw-connection.c index 462c6559b..0fd4081b9 100644 --- a/servers/groupwise/e-gw-connection.c +++ b/servers/groupwise/e-gw-connection.c @@ -75,7 +75,7 @@ logout (EGwConnection *cnc) g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT); /* build the SOAP message */ - msg = e_gw_message_new_with_header (cnc->priv->uri, "logoutRequest"); + msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "logoutRequest"); e_gw_message_write_string_parameter (msg, "session", cnc->priv->session_id); e_gw_message_write_footer (msg); @@ -264,7 +264,7 @@ e_gw_connection_new (const char *uri, const char *username, const char *password cnc = g_object_new (E_TYPE_GW_CONNECTION, NULL); /* build the SOAP message */ - msg = e_gw_message_new_with_header (uri, "loginRequest"); + msg = e_gw_message_new_with_header (uri, NULL, "loginRequest"); soup_soap_message_start_element (msg, "auth", "types", NULL); soup_soap_message_add_attribute (msg, "type", "types:PlainText", "xsi", "http://www.w3.org/2001/XMLSchema-instance"); @@ -365,6 +365,62 @@ e_gw_connection_logout (EGwConnection *cnc) return E_GW_CONNECTION_STATUS_OK; } +EGwConnectionStatus +e_gw_connection_get_items (EGwConnection *cnc, GSList **list) +{ + SoupSoapMessage *msg; + SoupSoapResponse *response; + EGwConnectionStatus status; + SoupSoapParameter *param; + GList *l; + + g_return_val_if_fail (E_IS_GW_CONNECTION (cnc), E_GW_CONNECTION_STATUS_INVALID_OBJECT); + + /* build the SOAP message */ + /* FIXME : e_gw_message_new_with_header does not allow additional elements to be + added in the header. Using soap_message functions directly.*/ + msg = e_gw_message_new_with_header (cnc->priv->uri, cnc->priv->session_id, "getItemsRequest"); + if (!msg) { + g_warning (G_STRLOC ": Could not build SOAP message"); + return E_GW_CONNECTION_STATUS_UNKNOWN; + } + + /* FIXME: Need to obtain the uid for calendar and use here */ + e_gw_message_write_string_parameter (msg, "container", "A.dom1.po1.100.0.1.0.1@19"); + e_gw_message_write_footer (msg); + + /* send message to server */ + response = e_gw_connection_send_message (cnc, msg); + if (!response) { + g_object_unref (msg); + return E_GW_CONNECTION_STATUS_INVALID_RESPONSE; + } + + status = parse_response_status (response); + if (status != E_GW_CONNECTION_STATUS_OK) { + g_object_unref (response); + return status; + } + + /* if status is OK - parse result. return the list */ + param = soup_soap_response_get_first_parameter_by_name (response, "items"); + if (!param) { + g_object_unref (response); + g_object_unref (msg); + return E_GW_CONNECTION_STATUS_INVALID_RESPONSE; + } + + /* FIXME: iterate through the response and populate the list */ + *l = soup_soap_response_get_parameters (response); + + /* free memory */ + g_object_unref (response); + g_object_unref (msg); + + /* FIXME: when will the cache be cleared ? */ + return E_GW_CONNECTION_STATUS_OK; +} + const char* e_gw_connection_get_user_email (EGwConnection *cnc) { @@ -373,3 +429,4 @@ e_gw_connection_get_user_email (EGwConnection *cnc) return (const char*) cnc->priv->user_email; } + diff --git a/servers/groupwise/e-gw-connection.h b/servers/groupwise/e-gw-connection.h index ace08fa42..f402030a1 100644 --- a/servers/groupwise/e-gw-connection.h +++ b/servers/groupwise/e-gw-connection.h @@ -62,8 +62,9 @@ typedef enum { SoupSoapResponse *e_gw_connection_send_message (EGwConnection *cnc, SoupSoapMessage *msg); EGwConnectionStatus e_gw_connection_logout (EGwConnection *cnc); +EGwConnectionStatus e_gw_connection_get_items (EGwConnection *cnc, GSList **list); -const char *e_gw_connection_get_user_email (EGwConnection *cnc); +const char *e_gw_connection_get_user_email (EGwConnection *cnc); G_END_DECLS diff --git a/servers/groupwise/e-gw-message.c b/servers/groupwise/e-gw-message.c index 299ed3123..25467116a 100644 --- a/servers/groupwise/e-gw-message.c +++ b/servers/groupwise/e-gw-message.c @@ -73,7 +73,7 @@ setup_debug (SoupSoapMessage *msg) #endif SoupSoapMessage * -e_gw_message_new_with_header (const char *uri, const char *method_name) +e_gw_message_new_with_header (const char *uri, const char *session_id, const char *method_name) { SoupSoapMessage *msg; @@ -93,6 +93,15 @@ e_gw_message_new_with_header (const char *uri, const char *method_name) #endif soup_soap_message_start_envelope (msg); + if (session_id && *session_id) { + soup_soap_message_start_element (msg, "Header","SOAP-ENV", NULL); + soup_soap_message_add_attribute (msg, "encodingStyle", "", "SOAP-ENV", NULL); + /* FIXME: cannot use e_gw_message_write_string_parameter as it sets prefix -types*/ + soup_soap_message_start_element (msg, "session", NULL, NULL); + soup_soap_message_write_string (msg, session_id); + soup_soap_message_end_element (msg); + soup_soap_message_end_element (msg); + } soup_soap_message_start_body (msg); soup_soap_message_add_attribute (msg, "encodingStyle", "", "SOAP-ENV", NULL); soup_soap_message_add_namespace (msg, "types", "http://schemas.novell.com/2003/10/NCSP/types.xsd"); diff --git a/servers/groupwise/e-gw-message.h b/servers/groupwise/e-gw-message.h index 0f5e3899f..aa73b74f0 100644 --- a/servers/groupwise/e-gw-message.h +++ b/servers/groupwise/e-gw-message.h @@ -28,7 +28,7 @@ G_BEGIN_DECLS -SoupSoapMessage *e_gw_message_new_with_header (const char *uri, const char *method_name); +SoupSoapMessage *e_gw_message_new_with_header (const char *uri, const char *session_id, const char *method_name); void e_gw_message_write_string_parameter (SoupSoapMessage *msg, const char *name, const char *value); void e_gw_message_write_footer (SoupSoapMessage *msg); |