From d99aeae7edf0e639c866389d537ea33a11b3cd45 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Mon, 17 Sep 2001 05:56:16 +0000 Subject: for each call back, removes the alarms (cal_component_remove_all_alarms): 2001-09-17 JP Rosevear * cal-util/cal-component.c (for_each_remove_all_alarms): for each call back, removes the alarms (cal_component_remove_all_alarms): remove all alarms from the component * cal-util/cal-component.h: new proto * gui/e-itip-control.c (write_error_html): writes error messages rather than normal html * gui/itip-utils.c (itip_send_comp): remove all alarms if the method warrants it svn path=/trunk/; revision=12897 --- calendar/ChangeLog | 15 ++++++ calendar/cal-util/cal-component.c | 35 ++++++++++++++ calendar/cal-util/cal-component.h | 1 + calendar/gui/e-itip-control.c | 98 ++++++++++++++++++++++++++++++++------- calendar/gui/itip-utils.c | 17 +++++-- 5 files changed, 146 insertions(+), 20 deletions(-) (limited to 'calendar') diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 82eb813a6a..0194f8871a 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,18 @@ +2001-09-17 JP Rosevear + + * cal-util/cal-component.c (for_each_remove_all_alarms): for each + call back, removes the alarms + (cal_component_remove_all_alarms): remove all alarms from the + component + + * cal-util/cal-component.h: new proto + + * gui/e-itip-control.c (write_error_html): writes error messages + rather than normal html + + * gui/itip-utils.c (itip_send_comp): remove all alarms if the + method warrants it + 2001-09-16 Christopher James Lahey * gui/dialogs/meeting-page.c (build_etable): Updated this to match diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c index 7ef6f9e477..b4784c6124 100644 --- a/calendar/cal-util/cal-component.c +++ b/calendar/cal-util/cal-component.c @@ -4066,6 +4066,41 @@ cal_component_remove_alarm (CalComponent *comp, const char *auid) icalcomponent_free (alarm); } +static gboolean +for_each_remove_all_alarms (gpointer key, gpointer value, gpointer data) +{ + CalComponent *comp = CAL_COMPONENT (data); + CalComponentPrivate *priv; + icalcomponent *alarm = value; + + priv = comp->priv; + + icalcomponent_remove_component (priv->icalcomp, alarm); + icalcomponent_free (alarm); + + return TRUE; +} + +/** + * cal_component_remove_all_alarms: + * @comp: A calendar component + * + * Remove all alarms from the calendar component + **/ +void +cal_component_remove_all_alarms (CalComponent *comp) +{ + CalComponentPrivate *priv; + + g_return_if_fail (comp != NULL); + g_return_if_fail (IS_CAL_COMPONENT (comp)); + + priv = comp->priv; + g_return_if_fail (priv->icalcomp != NULL); + + g_hash_table_foreach_remove (priv->alarm_uid_hash, for_each_remove_all_alarms, comp); +} + /* Scans an icalproperty from a calendar component and adds its mapping to our * own alarm structure. diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h index 1ab8ee24bd..801cdc51f0 100644 --- a/calendar/cal-util/cal-component.h +++ b/calendar/cal-util/cal-component.h @@ -394,6 +394,7 @@ typedef struct { gboolean cal_component_has_alarms (CalComponent *comp); void cal_component_add_alarm (CalComponent *comp, CalComponentAlarm *alarm); void cal_component_remove_alarm (CalComponent *comp, const char *auid); +void cal_component_remove_all_alarms (CalComponent *comp); GList *cal_component_get_alarm_uids (CalComponent *comp); CalComponentAlarm *cal_component_get_alarm (CalComponent *comp, const char *auid); diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c index 2450acab91..c6638bfa29 100644 --- a/calendar/gui/e-itip-control.c +++ b/calendar/gui/e-itip-control.c @@ -217,8 +217,6 @@ init (EItipControl *itip) priv->addresses = itip_addresses_get (); /* Header */ - priv->count = gtk_label_new ("0 of 0"); - gtk_widget_show (priv->count); priv->prev = gnome_stock_button (GNOME_STOCK_BUTTON_PREV); gtk_widget_show (priv->prev); priv->next = gnome_stock_button (GNOME_STOCK_BUTTON_NEXT); @@ -230,8 +228,6 @@ init (EItipControl *itip) gtk_box_pack_start (GTK_BOX (hbox), priv->next, FALSE, FALSE, 4); gtk_widget_show (hbox); -// gtk_box_pack_start (GTK_BOX (itip), hbox, FALSE, FALSE, 4); - gtk_signal_connect (GTK_OBJECT (priv->prev), "clicked", GTK_SIGNAL_FUNC (prev_clicked_cb), itip); gtk_signal_connect (GTK_OBJECT (priv->next), "clicked", @@ -522,6 +518,64 @@ set_message (GtkHTML *html, GtkHTMLStream *html_stream, gchar *message, gboolean g_free (buffer); } +static void +write_error_html (EItipControl *itip, gchar *itip_err) +{ + EItipControlPrivate *priv; + GtkHTMLStream *html_stream; + CalComponentText text; + CalComponentOrganizer organizer; + CalComponentAttendee *attendee; + GSList *attendees, *l = NULL; + gchar *html; + + priv = itip->priv; + + /* Html widget */ + html_stream = gtk_html_begin (GTK_HTML (priv->html)); + gtk_html_write (GTK_HTML (priv->html), html_stream, + HTML_HEADER, strlen(HTML_HEADER)); + gtk_html_write (GTK_HTML (priv->html), html_stream, + HTML_BODY_START, strlen(HTML_BODY_START)); + + /* The table */ + html = g_strdup (""); + gtk_html_write (GTK_HTML (priv->html), html_stream, html, strlen(html)); + g_free (html); + + /* The column for the image */ + html = g_strdup (""); + gtk_html_write (GTK_HTML (priv->html), html_stream, html, strlen(html)); + g_free (html); + + html = g_strdup ("
"); + gtk_html_write (GTK_HTML (priv->html), html_stream, html, strlen(html)); + g_free (html); + + /* The image */ + html = g_strdup (""); + gtk_html_write (GTK_HTML (priv->html), html_stream, html, strlen(html)); + g_free (html); + + /* Title */ + set_message (GTK_HTML (priv->html), html_stream, "iCalendar Error", TRUE); + + /* Error */ + gtk_html_write (GTK_HTML (priv->html), html_stream, itip_err, strlen(itip_err)); + + /* Clean up */ + html = g_strdup ("
"); + gtk_html_write (GTK_HTML (priv->html), html_stream, html, strlen(html)); + g_free (html); + + gtk_html_write (GTK_HTML (priv->html), html_stream, + HTML_BODY_END, strlen(HTML_BODY_END)); + gtk_html_write (GTK_HTML (priv->html), html_stream, + HTML_FOOTER, strlen(HTML_FOOTER)); + + gtk_html_end (GTK_HTML (priv->html), html_stream, GTK_HTML_STREAM_OK); +} + static void write_html (EItipControl *itip, gchar *itip_desc, gchar *itip_title, gchar *options) { @@ -813,7 +867,9 @@ show_current (EItipControl *itip) { EItipControlPrivate *priv; CalComponentVType type; - + icalcomponent *alarm_comp; + icalcompiter alarm_iter; + priv = itip->priv; set_label (itip); @@ -822,9 +878,17 @@ show_current (EItipControl *itip) if (priv->comp) gtk_object_unref (GTK_OBJECT (priv->comp)); + /* Strip out alarms for security purposes */ + alarm_iter = icalcomponent_begin_component (priv->ical_comp, ICAL_VALARM_COMPONENT); + while ((alarm_comp = icalcompiter_deref (&alarm_iter)) != NULL) { + icalcomponent_remove_component (priv->ical_comp, alarm_comp); + + icalcompiter_next (&alarm_iter); + } + priv->comp = cal_component_new (); if (!cal_component_set_icalcomponent (priv->comp, priv->ical_comp)) { -// set_message (itip, _("The message does not appear to be properly formed"), TRUE); + write_error_html (itip, _("The message does not appear to be properly formed")); gtk_object_unref (GTK_OBJECT (priv->comp)); priv->comp = NULL; return; @@ -843,7 +907,7 @@ show_current (EItipControl *itip) show_current_freebusy (itip); break; default: -// set_message (itip, _("The message contains only unsupported requests."), TRUE); + write_error_html (itip, _("The message contains only unsupported requests.")); } find_my_address (itip, priv->ical_comp); @@ -861,23 +925,26 @@ e_itip_control_set_data (EItipControl *itip, const gchar *text) priv = itip->priv; clean_up (itip); + + priv->comp = NULL; + priv->total = 0; + priv->current = 0; priv->vcalendar = g_strdup (text); priv->top_level = cal_util_new_top_level (); priv->main_comp = icalparser_parse_string (priv->vcalendar); if (priv->main_comp == NULL) { -// set_message (itip, _("The information contained in this attachment was not valid"), TRUE); - priv->comp = NULL; - priv->total = 0; - priv->current = 0; - goto show; - + write_error_html (itip, _("The attachment does not contain a valid calendar message")); + return; } prop = icalcomponent_get_first_property (priv->main_comp, ICAL_METHOD_PROPERTY); - if (prop == NULL) - goto show; + if (prop == NULL) { + write_error_html (itip, _("The attachment does not contain a valid calendar message")); + return; + } + priv->method = icalproperty_get_method (prop); tz_iter = icalcomponent_begin_component (priv->main_comp, ICAL_VTIMEZONE_COMPONENT); @@ -907,7 +974,6 @@ e_itip_control_set_data (EItipControl *itip, const gchar *text) else priv->current = 0; - show: show_current (itip); } diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index 459f6e1a9e..8811db3487 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -389,7 +389,8 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *comp) /* Create a top level component, and add our component */ { - icalcomponent *icomp, *clone; + CalComponent *clone; + icalcomponent *icomp, *iclone; icalproperty *prop; icalvalue *value; gchar *ical_string; @@ -401,10 +402,18 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *comp) icalproperty_set_value (prop, value); icalcomponent_add_property (icomp, prop); - clone = icalcomponent_new_clone (cal_component_get_icalcomponent (comp)); - icalcomponent_add_component (icomp, clone); + /* Strip alarms if necessary */ + clone = cal_component_clone (comp); + if (method == CAL_COMPONENT_METHOD_REPLY + || method == CAL_COMPONENT_METHOD_CANCEL + || method == CAL_COMPONENT_METHOD_REFRESH + || method == CAL_COMPONENT_METHOD_DECLINECOUNTER) + cal_component_remove_all_alarms (clone); + + iclone = cal_component_get_icalcomponent (clone); + icalcomponent_add_component (icomp, iclone); - icalcomponent_foreach_tzid (clone, foreach_tzid_callback, icomp); + icalcomponent_foreach_tzid (iclone, foreach_tzid_callback, icomp); ical_string = icalcomponent_as_ical_string (icomp); attach_data = GNOME_Evolution_Composer_AttachmentData__alloc (); -- cgit v1.2.3