From a599d0dd765ac86cf0f1f069b19f15a8179b9c05 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Thu, 8 Aug 2002 19:47:45 +0000 Subject: check for an attendee in the list (comp_to_list): only add the user if 2002-08-08 JP Rosevear * gui/itip-utils.c (users_has_attendee): check for an attendee in the list (comp_to_list): only add the user if they aren't on the list (comp_server_send): don't remove the users, pass back the list (itip_send_comp): send to server before doing comp_minimal * gui/dialogs/comp-editor.c (real_send_comp): edit and save the updated comp * pcs/cal.c (impl_Cal_send_object): copy the correct item to pass back svn path=/trunk/; revision=17747 --- calendar/ChangeLog | 14 ++++++ calendar/gui/dialogs/comp-editor.c | 9 +++- calendar/gui/itip-utils.c | 92 ++++++++++++++------------------------ calendar/pcs/cal.c | 2 +- 4 files changed, 57 insertions(+), 60 deletions(-) (limited to 'calendar') diff --git a/calendar/ChangeLog b/calendar/ChangeLog index c4eee418e6..a1e79df163 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,17 @@ +2002-08-08 JP Rosevear + + * gui/itip-utils.c (users_has_attendee): check for an attendee in + the list + (comp_to_list): only add the user if they aren't on the list + (comp_server_send): don't remove the users, pass back the list + (itip_send_comp): send to server before doing comp_minimal + + * gui/dialogs/comp-editor.c (real_send_comp): edit and save the + updated comp + + * pcs/cal.c (impl_Cal_send_object): copy the correct item to pass + back + 2002-08-08 Dan Winship * pcs/query-backend.c (query_backend_new): Initialize diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 44e7f80c20..2322b3bb69 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -954,13 +954,20 @@ static void real_send_comp (CompEditor *editor, CalComponentItipMethod method) { CompEditorPrivate *priv; - + CalComponent *tmp_comp; + g_return_if_fail (editor != NULL); g_return_if_fail (IS_COMP_EDITOR (editor)); priv = editor->priv; itip_send_comp (method, priv->comp, priv->client, NULL); + + tmp_comp = priv->comp; + gtk_object_ref (GTK_OBJECT (tmp_comp)); + comp_editor_edit_comp (editor, tmp_comp); + gtk_object_unref (GTK_OBJECT (tmp_comp)); + save_comp (editor); } diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index 4e166efbf2..7f27749731 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -351,39 +351,27 @@ comp_toplevel_with_zones (CalComponentItipMethod method, CalComponent *comp, Cal return top_level; } -static icalproperty * -comp_has_attendee (icalcomponent *ical_comp, const char *address) +static gboolean +users_has_attendee (GList *users, const char *address) { - icalproperty *prop; - - 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; - - value = icalproperty_get_value (prop); - if (!value) - continue; - - attendee = icalvalue_get_string (value); + GList *l; - if (!g_strcasecmp (address, attendee)) - break; + for (l = users; l != NULL; l = l->next) { + if (!g_strcasecmp (address, l->data)) + return TRUE; } - - return prop; + + return FALSE; } static GNOME_Evolution_Composer_RecipientList * -comp_to_list (CalComponentItipMethod method, CalComponent *comp) +comp_to_list (CalComponentItipMethod method, CalComponent *comp, GList *users) { GNOME_Evolution_Composer_RecipientList *to_list; GNOME_Evolution_Composer_Recipient *recipient; CalComponentOrganizer organizer; GSList *attendees, *l; - gint cntr, len; + gint len; switch (method) { case CAL_COMPONENT_METHOD_REQUEST: @@ -399,18 +387,23 @@ comp_to_list (CalComponentItipMethod method, CalComponent *comp) to_list = GNOME_Evolution_Composer_RecipientList__alloc (); to_list->_maximum = len; - to_list->_length = len; + to_list->_length = 0; to_list->_buffer = CORBA_sequence_GNOME_Evolution_Composer_Recipient_allocbuf (len); - for (cntr = 0, l = attendees; cntr < len; cntr++, l = l->next) { + for (l = attendees; l != NULL; l = l->next) { CalComponentAttendee *att = l->data; - - recipient = &(to_list->_buffer[cntr]); + + if (users_has_attendee (users, att->value)) + continue; + + recipient = &(to_list->_buffer[to_list->_length]); if (att->cn) recipient->name = CORBA_string_dup (att->cn); else recipient->name = CORBA_string_dup (""); recipient->address = CORBA_string_dup (itip_strip_mailto (att->value)); + + to_list->_length++; } cal_component_free_attendee_list (attendees); break; @@ -555,46 +548,28 @@ comp_content_type (CalComponent *comp, CalComponentItipMethod method) } -static icalcomponent * +static GList * comp_server_send (CalComponentItipMethod method, CalComponent *comp, CalClient *client, icalcomponent *zones) { CalClientResult result; icalcomponent *top_level, *new_top_level = NULL; - GList *users; + GList *users = NULL; top_level = comp_toplevel_with_zones (method, comp, client, zones); result = cal_client_send_object (client, top_level, &new_top_level, &users); if (result == CAL_CLIENT_SEND_SUCCESS) { - icalcomponent *ical_comp, *clone; - icalproperty *prop; - GList *l; + icalcomponent *ical_comp; ical_comp = icalcomponent_get_inner (new_top_level); - clone = icalcomponent_new_clone (ical_comp); - - for (l = users; l != NULL; l = l->next) { - prop = comp_has_attendee (ical_comp, l->data); - if (prop != NULL) - icalcomponent_remove_property (ical_comp, prop); - } - - cal_component_set_icalcomponent (comp, clone); - - if (icalcomponent_count_properties (ical_comp, ICAL_ATTENDEE_PROPERTY) == 0) { - icalcomponent_free (new_top_level); - icalcomponent_free (top_level); - return NULL; - } + icalcomponent_remove_component (new_top_level, ical_comp); + cal_component_set_icalcomponent (comp, ical_comp); + icalcomponent_free (new_top_level); } - /* Just return what was sent if something broke */ - if (new_top_level == NULL) - return top_level; - icalcomponent_free (top_level); - return new_top_level; + return users; } static gboolean @@ -839,6 +814,7 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp, GNOME_Evolution_Composer composer_server; CalComponent *comp = NULL; icalcomponent *top_level = NULL; + GList *users; GNOME_Evolution_Composer_RecipientList *to_list = NULL; GNOME_Evolution_Composer_RecipientList *cc_list = NULL; GNOME_Evolution_Composer_RecipientList *bcc_list = NULL; @@ -854,18 +830,17 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp, bonobo_server = bonobo_object_activate (GNOME_EVOLUTION_COMPOSER_OAFIID, 0); g_return_if_fail (bonobo_server != NULL); composer_server = BONOBO_OBJREF (bonobo_server); + + /* Give the server a chance to manipulate the comp */ + users = comp_server_send (method, send_comp, client, zones); + /* Tidy up the comp */ comp = comp_compliant (method, send_comp); if (comp == NULL) goto cleanup; - - /* Give the server a chance to manipulate the comp */ - top_level = comp_server_send (method, comp, client, zones); - if (top_level == NULL) - goto cleanup; - + /* Recipients */ - to_list = comp_to_list (method, comp); + to_list = comp_to_list (method, comp, users); if (to_list == NULL) goto cleanup; @@ -887,6 +862,7 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp, /* Content type */ content_type = comp_content_type (comp, method); + top_level = comp_toplevel_with_zones (method, comp, client, zones); ical_string = icalcomponent_as_ical_string (top_level); attach_data = GNOME_Evolution_Composer_AttachmentData__alloc (); attach_data->_length = strlen (ical_string) + 1; diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c index 4f8ff173f0..3abff9cf98 100644 --- a/calendar/pcs/cal.c +++ b/calendar/pcs/cal.c @@ -460,7 +460,7 @@ impl_Cal_send_object (PortableServer_Servant servant, result = cal_backend_send_object (priv->backend, calobj, &new_calobj, user_list); switch (result) { case CAL_BACKEND_SEND_SUCCESS: - calobj_copy = CORBA_string_dup (calobj); + calobj_copy = CORBA_string_dup (new_calobj); g_free (new_calobj); return calobj_copy; -- cgit v1.2.3