From b8c12e58889810b8ec048fa8c3d933ae67857703 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Mon, 1 Mar 2004 15:46:01 +0000 Subject: [PATCH] added new arguments to the notifyObjectsSent method for backends to return 2004-03-01 Rodrigo Moya * idl/Evolution-DataServer-Calendar.idl: added new arguments to the notifyObjectsSent method for backends to return the list of users and events for which it operated. * libedata-cal/e-data-cal.[ch] (e_data_cal_notify_objects_sent): added new argument and call the listener's notifyObjectsSent method with a GNOME_Evolution_Calendar_UserList. * libedata-cal/e-cal-backend-sync.[ch] (e_cal_backend_sync_send_objects, _e_cal_backend_send_objects): added new arguments. * backends/file/e-cal-backend-file.c (e_cal_backend_file_send_objects): * backends/http/e-cal-backend-http.c (e_cal_backend_http_send_objects): * backends/contacts/e-cal-backend-contacts.c (e_cal_backend_contacts_send_objects): * backends/groupwise/e-cal-backend-groupwise.c (e_cal_backend_groupwise_send_objects): adapted to changes in ECalBackend/ECalBackendSync API. * backends/file/e-cal-backend-file.c (e_cal_backend_file_receive_objects, e_cal_backend_file_send_objects): removed wrong return statement. * libecal/e-cal-marshal.list: added new marshaller. * libecal/e-cal.[ch] (e_cal_send_objects): get the user list from the operation's result. (cal_objects_sent_cb): added the new arguments and copy them to the operation's result. * libecal/e-cal-listener.[ch]: added new arguments to "send_objects" signal. (impl_notifyObjectsSent): added UserList argument to CORBA method, and convert the CORBA user list to a GList to be passed to the signal handlers. (e_cal_listener_class_init): added new arguments to "send_objects" signal. --- calendar/ChangeLog | 39 ++++++++++++++++++++++ .../backends/contacts/e-cal-backend-contacts.c | 4 ++- calendar/backends/file/e-cal-backend-file.c | 8 +++-- .../backends/groupwise/e-cal-backend-groupwise.c | 6 +++- calendar/backends/http/e-cal-backend-http.c | 6 +++- calendar/idl/Evolution-DataServer-Calendar.idl | 2 +- calendar/libecal/e-cal-listener.c | 22 +++++++++--- calendar/libecal/e-cal-listener.h | 2 +- calendar/libecal/e-cal-marshal.list | 1 + calendar/libecal/e-cal.c | 12 +++++-- calendar/libecal/e-cal.h | 2 +- calendar/libedata-cal/e-cal-backend-sync.c | 14 +++++--- calendar/libedata-cal/e-cal-backend-sync.h | 9 +++-- calendar/libedata-cal/e-cal-backend.c | 4 +-- calendar/libedata-cal/e-data-cal.c | 19 +++++++++-- calendar/libedata-cal/e-data-cal.h | 3 +- 16 files changed, 125 insertions(+), 28 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 0493097..2c66b4e 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,42 @@ +2004-03-01 Rodrigo Moya + + * idl/Evolution-DataServer-Calendar.idl: added new arguments to the + notifyObjectsSent method for backends to return the list of users and + events for which it operated. + + * libedata-cal/e-data-cal.[ch] (e_data_cal_notify_objects_sent): added + new argument and call the listener's notifyObjectsSent method with + a GNOME_Evolution_Calendar_UserList. + + * libedata-cal/e-cal-backend-sync.[ch] (e_cal_backend_sync_send_objects, + _e_cal_backend_send_objects): added new arguments. + + * backends/file/e-cal-backend-file.c (e_cal_backend_file_send_objects): + * backends/http/e-cal-backend-http.c (e_cal_backend_http_send_objects): + * backends/contacts/e-cal-backend-contacts.c + (e_cal_backend_contacts_send_objects): + * backends/groupwise/e-cal-backend-groupwise.c + (e_cal_backend_groupwise_send_objects): adapted to changes in + ECalBackend/ECalBackendSync API. + + * backends/file/e-cal-backend-file.c (e_cal_backend_file_receive_objects, + e_cal_backend_file_send_objects): removed wrong return statement. + + * libecal/e-cal-marshal.list: added new marshaller. + + * libecal/e-cal.[ch] (e_cal_send_objects): get the user list from the + operation's result. + (cal_objects_sent_cb): added the new arguments and copy them to the + operation's result. + + * libecal/e-cal-listener.[ch]: added new arguments to "send_objects" + signal. + (impl_notifyObjectsSent): added UserList argument to CORBA method, and + convert the CORBA user list to a GList to be passed to the signal + handlers. + (e_cal_listener_class_init): added new arguments to "send_objects" + signal. + 2004-02-26 JP Rosevear * tests/ecal/test-ecal.c: make EXPECTED a macro so it compiles diff --git a/calendar/backends/contacts/e-cal-backend-contacts.c b/calendar/backends/contacts/e-cal-backend-contacts.c index 1cc846e..bd16667 100644 --- a/calendar/backends/contacts/e-cal-backend-contacts.c +++ b/calendar/backends/contacts/e-cal-backend-contacts.c @@ -586,8 +586,10 @@ e_cal_backend_contacts_receive_objects (ECalBackendSync *backend, EDataCal *cal, static ECalBackendSyncStatus e_cal_backend_contacts_send_objects (ECalBackendSync *backend, EDataCal *cal, - const char *calobj) + const char *calobj, GList **users, char **modified_calobj) { + *users = NULL; + *modified_calobj = NULL; /* TODO: Investigate this */ return GNOME_Evolution_Calendar_Success; } diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c index 2a13a8a..27a47f2 100644 --- a/calendar/backends/file/e-cal-backend-file.c +++ b/calendar/backends/file/e-cal-backend-file.c @@ -2157,10 +2157,12 @@ e_cal_backend_file_receive_objects (ECalBackendSync *backend, EDataCal *cal, con } static ECalBackendSyncStatus -e_cal_backend_file_send_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj) +e_cal_backend_file_send_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj, GList **users, + char **modified_calobj) { - /* FIXME Put in a util routine to send stuff via email */ - + *users = NULL; + *modified_calobj = NULL; + return GNOME_Evolution_Calendar_Success; } diff --git a/calendar/backends/groupwise/e-cal-backend-groupwise.c b/calendar/backends/groupwise/e-cal-backend-groupwise.c index 5ce4465..6d3ed86 100644 --- a/calendar/backends/groupwise/e-cal-backend-groupwise.c +++ b/calendar/backends/groupwise/e-cal-backend-groupwise.c @@ -1038,8 +1038,12 @@ e_cal_backend_groupwise_receive_objects (ECalBackendSync *backend, EDataCal *cal } static ECalBackendSyncStatus -e_cal_backend_groupwise_send_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj) +e_cal_backend_groupwise_send_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj, GList **users, + char **modified_calobj) { + /* FIXME */ + *users = NULL; + *modified_calobj = NULL; return GNOME_Evolution_Calendar_OtherError; } diff --git a/calendar/backends/http/e-cal-backend-http.c b/calendar/backends/http/e-cal-backend-http.c index 097ca0e..7f9e047 100644 --- a/calendar/backends/http/e-cal-backend-http.c +++ b/calendar/backends/http/e-cal-backend-http.c @@ -745,7 +745,8 @@ e_cal_backend_http_receive_objects (ECalBackendSync *backend, EDataCal *cal, con } static ECalBackendSyncStatus -e_cal_backend_http_send_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj) +e_cal_backend_http_send_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj, GList **users, + char **modified_calobj) { ECalBackendHttp *cbhttp; ECalBackendHttpPrivate *priv; @@ -753,6 +754,9 @@ e_cal_backend_http_send_objects (ECalBackendSync *backend, EDataCal *cal, const cbhttp = E_CAL_BACKEND_HTTP (backend); priv = cbhttp->priv; + *users = NULL; + *modified_calobj = NULL; + return GNOME_Evolution_Calendar_PermissionDenied; } diff --git a/calendar/idl/Evolution-DataServer-Calendar.idl b/calendar/idl/Evolution-DataServer-Calendar.idl index cc524ff..228ea10 100644 --- a/calendar/idl/Evolution-DataServer-Calendar.idl +++ b/calendar/idl/Evolution-DataServer-Calendar.idl @@ -235,7 +235,7 @@ module Calendar { oneway void notifyAlarmDiscarded (in CallStatus status); oneway void notifyObjectsReceived (in CallStatus status); - oneway void notifyObjectsSent (in CallStatus status); + oneway void notifyObjectsSent (in CallStatus status, in UserList users, in CalObj calobj); oneway void notifyDefaultObjectRequested (in CallStatus status, in CalObj object); oneway void notifyObjectRequested (in CallStatus status, in CalObj object); diff --git a/calendar/libecal/e-cal-listener.c b/calendar/libecal/e-cal-listener.c index 8c07cb7..019036d 100644 --- a/calendar/libecal/e-cal-listener.c +++ b/calendar/libecal/e-cal-listener.c @@ -309,18 +309,32 @@ impl_notifyObjectsReceived (PortableServer_Servant servant, static void impl_notifyObjectsSent (PortableServer_Servant servant, GNOME_Evolution_Calendar_CallStatus status, + GNOME_Evolution_Calendar_UserList *user_list, + const CORBA_char *modified_calobj, CORBA_Environment *ev) { ECalListener *listener; ECalListenerPrivate *priv; - + int i; + icalcomponent *icalcomp = NULL; + GList *users = NULL; + listener = E_CAL_LISTENER (bonobo_object_from_servant (servant)); priv = listener->priv; if (!priv->notify) return; - g_signal_emit (G_OBJECT (listener), signals[SEND_OBJECTS], 0, convert_status (status)); + for (i = 0; i < user_list->_length; i++) + users = g_list_append (users, g_strdup (user_list->_buffer[i])); + + icalcomp = icalparser_parse_string (modified_calobj); + + g_signal_emit (G_OBJECT (listener), signals[SEND_OBJECTS], 0, convert_status (status), users, icalcomp); + + g_list_foreach (users, (GFunc) g_free, NULL); + g_list_free (users); + icalcomponent_free (icalcomp); } static void @@ -829,8 +843,8 @@ e_cal_listener_class_init (ECalListenerClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ECalListenerClass, send_objects), NULL, NULL, - e_cal_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); + e_cal_marshal_VOID__INT_POINTER_POINTER, + G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_POINTER, G_TYPE_POINTER); signals[DEFAULT_OBJECT] = g_signal_new ("default_object", G_TYPE_FROM_CLASS (klass), diff --git a/calendar/libecal/e-cal-listener.h b/calendar/libecal/e-cal-listener.h index cd72ebb..756720a 100644 --- a/calendar/libecal/e-cal-listener.h +++ b/calendar/libecal/e-cal-listener.h @@ -67,7 +67,7 @@ typedef struct { void (*discard_alarm) (ECalListener *listener, ECalendarStatus status); void (*receive_objects) (ECalListener *listener, ECalendarStatus status); - void (*send_objects) (ECalListener *listener, ECalendarStatus status); + void (*send_objects) (ECalListener *listener, ECalendarStatus status, GList *users, icalcomponent *modified_icalcomp); void (*default_object) (ECalListener *listener, ECalendarStatus status, const char *object); void (*object) (ECalListener *listener, ECalendarStatus status, const char *object); diff --git a/calendar/libecal/e-cal-marshal.list b/calendar/libecal/e-cal-marshal.list index e65eb45..e7bb076 100644 --- a/calendar/libecal/e-cal-marshal.list +++ b/calendar/libecal/e-cal-marshal.list @@ -4,6 +4,7 @@ NONE:STRING NONE:INT,STRING NONE:INT,BOOL NONE:INT,POINTER +NONE:INT,POINTER,POINTER NONE:STRING,INT NONE:INT,INT NONE:ENUM,ENUM diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c index ef9843b..b234305 100644 --- a/calendar/libecal/e-cal.c +++ b/calendar/libecal/e-cal.c @@ -48,6 +48,7 @@ typedef struct { GList *list; gboolean bool; char *string; + icalcomponent *icalcomp; ECalView *query; ECalViewListener *listener; @@ -606,7 +607,7 @@ cal_objects_received_cb (ECalListener *listener, ECalendarStatus status, gpointe } static void -cal_objects_sent_cb (ECalListener *listener, ECalendarStatus status, gpointer data) +cal_objects_sent_cb (ECalListener *listener, ECalendarStatus status, GList *users, icalcomponent *modified_icalcomp, gpointer data) { ECal *ecal = data; ECalendarOp *op; @@ -621,6 +622,11 @@ cal_objects_sent_cb (ECalListener *listener, ECalendarStatus status, gpointer da g_mutex_lock (op->mutex); op->status = status; + op->list = g_list_copy (users); + if (modified_icalcomp) + op->icalcomp = icalcomponent_new_clone (modified_icalcomp); + else + op->icalcomp = NULL; g_cond_signal (op->cond); @@ -3468,7 +3474,7 @@ e_cal_receive_objects (ECal *ecal, icalcomponent *icalcomp, GError **error) } gboolean -e_cal_send_objects (ECal *ecal, icalcomponent *icalcomp, GError **error) +e_cal_send_objects (ECal *ecal, icalcomponent *icalcomp, GList **users, icalcomponent **modified_icalcomp, GError **error) { ECalPrivate *priv; CORBA_Environment ev; @@ -3520,6 +3526,8 @@ e_cal_send_objects (ECal *ecal, icalcomponent *icalcomp, GError **error) g_cond_wait (our_op->cond, our_op->mutex); status = our_op->status; + *users = our_op->list; + *modified_icalcomp = our_op->icalcomp; e_calendar_remove_op (ecal, our_op); g_mutex_unlock (our_op->mutex); diff --git a/calendar/libecal/e-cal.h b/calendar/libecal/e-cal.h index 1d90d33..8ae9686 100644 --- a/calendar/libecal/e-cal.h +++ b/calendar/libecal/e-cal.h @@ -168,7 +168,7 @@ gboolean e_cal_remove_object_with_mod (ECal *ecal, const char *uid, const char * gboolean e_cal_discard_alarm (ECal *ecal, ECalComponent *comp, const char *auid, GError **error); gboolean e_cal_receive_objects (ECal *ecal, icalcomponent *icalcomp, GError **error); -gboolean e_cal_send_objects (ECal *ecal, icalcomponent *icalcomp, GError **error); +gboolean e_cal_send_objects (ECal *ecal, icalcomponent *icalcomp, GList **users, icalcomponent **modified_icalcomp, GError **error); gboolean e_cal_get_timezone (ECal *ecal, const char *tzid, icaltimezone **zone, GError **error); gboolean e_cal_add_timezone (ECal *ecal, icaltimezone *izone, GError **error); diff --git a/calendar/libedata-cal/e-cal-backend-sync.c b/calendar/libedata-cal/e-cal-backend-sync.c index e28b0fc..214049a 100644 --- a/calendar/libedata-cal/e-cal-backend-sync.c +++ b/calendar/libedata-cal/e-cal-backend-sync.c @@ -158,13 +158,14 @@ e_cal_backend_sync_receive_objects (ECalBackendSync *backend, EDataCal *cal, con } ECalBackendSyncStatus -e_cal_backend_sync_send_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj) +e_cal_backend_sync_send_objects (ECalBackendSync *backend, EDataCal *cal, const char *calobj, GList **users, + char **modified_calobj) { g_return_val_if_fail (backend && E_IS_CAL_BACKEND_SYNC (backend), GNOME_Evolution_Calendar_OtherError); g_assert (E_CAL_BACKEND_SYNC_GET_CLASS (backend)->send_objects_sync); - return (* E_CAL_BACKEND_SYNC_GET_CLASS (backend)->send_objects_sync) (backend, cal, calobj); + return (* E_CAL_BACKEND_SYNC_GET_CLASS (backend)->send_objects_sync) (backend, cal, calobj, users, modified_calobj); } ECalBackendSyncStatus @@ -401,10 +402,15 @@ static void _e_cal_backend_send_objects (ECalBackend *backend, EDataCal *cal, const char *calobj) { ECalBackendSyncStatus status; + GList *users = NULL; + char *modified_calobj = NULL; - status = e_cal_backend_sync_send_objects (E_CAL_BACKEND_SYNC (backend), cal, calobj); + status = e_cal_backend_sync_send_objects (E_CAL_BACKEND_SYNC (backend), cal, calobj, &users, &modified_calobj); + e_data_cal_notify_objects_sent (cal, status, users, modified_calobj); - e_data_cal_notify_objects_sent (cal, status); + g_list_foreach (users, (GFunc) g_free, NULL); + g_list_free (users); + g_free (modified_calobj); } static void diff --git a/calendar/libedata-cal/e-cal-backend-sync.h b/calendar/libedata-cal/e-cal-backend-sync.h index 08de3c2..ad495cc 100644 --- a/calendar/libedata-cal/e-cal-backend-sync.h +++ b/calendar/libedata-cal/e-cal-backend-sync.h @@ -49,7 +49,8 @@ struct _ECalBackendSyncClass { ECalBackendSyncStatus (*discard_alarm_sync) (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *auid); ECalBackendSyncStatus (*receive_objects_sync) (ECalBackendSync *backend, EDataCal *cal, const char *calobj); - ECalBackendSyncStatus (*send_objects_sync) (ECalBackendSync *backend, EDataCal *cal, const char *calobj); + ECalBackendSyncStatus (*send_objects_sync) (ECalBackendSync *backend, EDataCal *cal, const char *calobj, GList **users, + char **modified_calobj); ECalBackendSyncStatus (*get_default_object_sync) (ECalBackendSync *backend, EDataCal *cal, char **object); ECalBackendSyncStatus (*get_object_sync) (ECalBackendSync *backend, EDataCal *cal, const char *uid, const char *rid, char **object); @@ -116,8 +117,10 @@ ECalBackendSyncStatus e_cal_backend_sync_receive_objects (ECalBackendSyn EDataCal *cal, const char *calobj); ECalBackendSyncStatus e_cal_backend_sync_send_objects (ECalBackendSync *backend, - EDataCal *cal, - const char *calobj); + EDataCal *cal, + const char *calobj, + GList **users, + char **modified_calobj); ECalBackendSyncStatus e_cal_backend_sync_get_default_object (ECalBackendSync *backend, EDataCal *cal, char **object); diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c index 866814c..2d3f158 100644 --- a/calendar/libedata-cal/e-cal-backend.c +++ b/calendar/libedata-cal/e-cal-backend.c @@ -852,7 +852,7 @@ e_cal_backend_receive_objects (ECalBackend *backend, EDataCal *cal, const char * g_return_if_fail (calobj != NULL); g_assert (CLASS (backend)->receive_objects != NULL); - return (* CLASS (backend)->receive_objects) (backend, cal, calobj); + (* CLASS (backend)->receive_objects) (backend, cal, calobj); } void @@ -863,7 +863,7 @@ e_cal_backend_send_objects (ECalBackend *backend, EDataCal *cal, const char *cal g_return_if_fail (calobj != NULL); g_assert (CLASS (backend)->send_objects != NULL); - return (* CLASS (backend)->send_objects) (backend, cal, calobj); + (* CLASS (backend)->send_objects) (backend, cal, calobj); } /** diff --git a/calendar/libedata-cal/e-data-cal.c b/calendar/libedata-cal/e-data-cal.c index 4090ba3..13dcaf1 100644 --- a/calendar/libedata-cal/e-data-cal.c +++ b/calendar/libedata-cal/e-data-cal.c @@ -888,10 +888,11 @@ e_data_cal_notify_alarm_discarded (EDataCal *cal, GNOME_Evolution_Calendar_CallS } void -e_data_cal_notify_objects_sent (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status) +e_data_cal_notify_objects_sent (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *users, const char *calobj) { EDataCalPrivate *priv; CORBA_Environment ev; + GNOME_Evolution_Calendar_UserList *corba_users; g_return_if_fail (cal != NULL); g_return_if_fail (E_IS_DATA_CAL (cal)); @@ -899,13 +900,25 @@ e_data_cal_notify_objects_sent (EDataCal *cal, GNOME_Evolution_Calendar_CallStat priv = cal->priv; g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); + corba_users = GNOME_Evolution_Calendar_UserList__alloc (); + corba_users->_length = g_list_length (users); + if (users) { + GList *l; + int n; + + corba_users->_buffer = CORBA_sequence_GNOME_Evolution_Calendar_User_allocbuf (corba_users->_length); + for (l = users, n = 0; l != NULL; l = l->next, n++) + corba_users->_buffer[n] = CORBA_string_dup (l->data); + } + CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_CalListener_notifyObjectsSent (priv->listener, status, &ev); + GNOME_Evolution_Calendar_CalListener_notifyObjectsSent (priv->listener, status, corba_users, calobj, &ev); if (BONOBO_EX (&ev)) g_message (G_STRLOC ": could not notify the listener of objects sent"); - CORBA_exception_free (&ev); + CORBA_exception_free (&ev); + CORBA_free (corba_users); } void diff --git a/calendar/libedata-cal/e-data-cal.h b/calendar/libedata-cal/e-data-cal.h index 48e934d..e0a5519 100644 --- a/calendar/libedata-cal/e-data-cal.h +++ b/calendar/libedata-cal/e-data-cal.h @@ -87,7 +87,8 @@ void e_data_cal_notify_object_removed (EDataCal *cal, GNOME_Evolution_Calendar_ 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); -void e_data_cal_notify_objects_sent (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status); +void e_data_cal_notify_objects_sent (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *users, + const char *calobj); void e_data_cal_notify_default_object (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object); -- 2.7.4