aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/itip-formatter/itip-formatter.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-01-19 21:56:42 +0800
committerMilan Crha <mcrha@src.gnome.org>2009-01-19 21:56:42 +0800
commit2be7cd3b2ab50047820da4a1e873785b53f41acd (patch)
tree50f07aacdc49a27e040e8470ad57e6fa21bdead5 /plugins/itip-formatter/itip-formatter.c
parentae26a9a5fb34beb48e4161c8f145b0fb2d3cb3a9 (diff)
downloadgsoc2013-evolution-2be7cd3b2ab50047820da4a1e873785b53f41acd.tar.gz
gsoc2013-evolution-2be7cd3b2ab50047820da4a1e873785b53f41acd.tar.zst
gsoc2013-evolution-2be7cd3b2ab50047820da4a1e873785b53f41acd.zip
** Fix for bug #225712
2009-01-19 Milan Crha <mcrha@redhat.com> ** Fix for bug #225712 * calendar/gui/dialogs/comp-editor.h: (CompEditorClass::send_comp), (comp_editor_send_comp): Changed function prototypes. * calendar/gui/dialogs/comp-editor.c: (real_send_comp), (save_comp_with_send), (comp_editor_send_comp): Strip alarms based on user's choice. * calendar/gui/dialogs/send-comp.h: (send_component_dialog): * calendar/gui/dialogs/send-comp.c: (have_nonprocedural_alarm), (send_component_dialog): Show option "Send my alarms with this event" when prompting to send event or not, but only if have any non-procedure alarms and if it the caller want to know user's opinion. Default is to strip all alarms. Procedure alarms are always strip out. * calendar/gui/dialogs/event-editor.c: (event_editor_send_comp): * calendar/gui/dialogs/task-editor.c: (task_editor_send_comp): Honor function prototype changes and use new parameter strip_alarms. * calendar/gui/itip-utils.h: (itip_send_comp): * calendar/gui/itip-utils.c: (comp_compliant), (itip_send_comp), (reply_to_calendar_comp): New parameter to strip all alarms or only procedure alarms. * calendar/gui/tasks-control.c: (tasks_control_forward_cmd): * calendar/gui/e-itip-control.c: (send_item), (send_freebusy), (ok_clicked_cb): * calendar/gui/e-calendar-table.c: (e_calendar_table_on_forward): * calendar/gui/e-memo-table.c: (e_memo_table_on_forward): * calendar/gui/e-calendar-view.c: (e_calendar_view_cut_clipboard), (delete_event), (e_calendar_view_delete_selected_occurrence), (on_forward): Always strip alarms when sending component. * calendar/gui/e-calendar-view.c: (e_calendar_view_add_event), (e_calendar_view_modify_and_send): * calendar/gui/e-cal-model-calendar.c: (ecmc_set_value_at): Strip alarms based on user's choice. * plugins/itip-formatter/itip-view.h: * plugins/itip-formatter/itip-view.c: (itip_view_set_show_keep_alarm_check), (itip_view_get_keep_alarm_check_state), (itip_view_set_show_inherit_alarm_check), (itip_view_get_inherit_alarm_check_state): New functions to new options to either inherit reminder from the incoming event or to preserve users reminders in already existing event in the calendar. * plugins/itip-formatter/itip-view.c: (struct _ItipViewPrivate), (alarm_check_toggled_cb), (itip_view_init): Properly initialize new option's members. * plugins/itip-formatter/itip-formatter.c: (find_cal_opened_cb), (update_item), (send_comp_to_attendee), (update_attendee_status), (send_item), (extract_itip_data), (view_response_cb), (format_itip_object): Setup new options based on the actual data. svn path=/trunk/; revision=37097
Diffstat (limited to 'plugins/itip-formatter/itip-formatter.c')
-rw-r--r--plugins/itip-formatter/itip-formatter.c84
1 files changed, 75 insertions, 9 deletions
diff --git a/plugins/itip-formatter/itip-formatter.c b/plugins/itip-formatter/itip-formatter.c
index 61d2234bd8..83ea0036fb 100644
--- a/plugins/itip-formatter/itip-formatter.c
+++ b/plugins/itip-formatter/itip-formatter.c
@@ -630,6 +630,16 @@ find_cal_opened_cb (ECal *ecal, ECalendarStatus status, gpointer data)
if (!pitip->current_ecal && e_cal_get_object (ecal, fd->uid, fd->rid, &icalcomp, NULL)) {
+ if ((pitip->method == ICAL_METHOD_PUBLISH || pitip->method == ICAL_METHOD_REQUEST) &&
+ (icalcomponent_get_first_component (icalcomp, ICAL_VALARM_COMPONENT) ||
+ icalcomponent_get_first_component (icalcomp, ICAL_XAUDIOALARM_COMPONENT) ||
+ icalcomponent_get_first_component (icalcomp, ICAL_XDISPLAYALARM_COMPONENT) ||
+ icalcomponent_get_first_component (icalcomp, ICAL_XPROCEDUREALARM_COMPONENT) ||
+ icalcomponent_get_first_component (icalcomp, ICAL_XEMAILALARM_COMPONENT)))
+ itip_view_set_show_keep_alarm_check (ITIP_VIEW (pitip->view), TRUE);
+ else
+ itip_view_set_show_keep_alarm_check (ITIP_VIEW (pitip->view), FALSE);
+
icalcomponent_free (icalcomp);
pitip->current_ecal = ecal;
@@ -652,7 +662,8 @@ find_cal_opened_cb (ECal *ecal, ECalendarStatus status, gpointer data)
_("Found the appointment in the calendar '%s'"), e_source_peek_name (source));
set_buttons_sensitive (pitip);
- }
+ } else if (!pitip->current_ecal)
+ itip_view_set_show_keep_alarm_check (ITIP_VIEW (pitip->view), FALSE);
if (pitip->current_ecal) {
if (e_cal_get_static_capability (pitip->current_ecal, CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER)) {
@@ -991,6 +1002,19 @@ update_item (struct _itip_puri *pitip, ItipViewResponse response)
icalcomponent_add_component (pitip->top_level, clone);
icalcomponent_set_method (pitip->top_level, pitip->method);
+ if (!itip_view_get_inherit_alarm_check_state (ITIP_VIEW (pitip->view))) {
+ icalcomponent *alarm_comp;
+ icalcompiter alarm_iter;
+
+ alarm_iter = icalcomponent_begin_component (clone, ICAL_VALARM_COMPONENT);
+ while ((alarm_comp = icalcompiter_deref (&alarm_iter)) != NULL) {
+ icalcompiter_next (&alarm_iter);
+
+ icalcomponent_remove_component (clone, alarm_comp);
+ icalcomponent_free (alarm_comp);
+ }
+ }
+
clone_comp = e_cal_component_new ();
if (!e_cal_component_set_icalcomponent (clone_comp, clone)) {
itip_view_add_lower_info_item (ITIP_VIEW (pitip->view), ITIP_VIEW_INFO_ITEM_TYPE_ERROR, _("Unable to parse item"));
@@ -999,6 +1023,35 @@ update_item (struct _itip_puri *pitip, ItipViewResponse response)
}
source = e_cal_get_source (pitip->current_ecal);
+ if (itip_view_get_keep_alarm_check_state (ITIP_VIEW (pitip->view))) {
+ ECalComponent *real_comp;
+ GList *alarms, *l;
+ ECalComponentAlarm *alarm;
+
+ real_comp = get_real_item (pitip);
+ if (real_comp != NULL) {
+ alarms = e_cal_component_get_alarm_uids (real_comp);
+
+ for (l = alarms; l; l = l->next) {
+ alarm = e_cal_component_get_alarm (real_comp, (const char *)l->data);
+
+ if (alarm) {
+ ECalComponentAlarm *aclone = e_cal_component_alarm_clone (alarm);
+
+ if (aclone) {
+ e_cal_component_add_alarm (clone_comp, aclone);
+ e_cal_component_alarm_free (aclone);
+ }
+
+ e_cal_component_alarm_free (alarm);
+ }
+ }
+
+ cal_obj_uid_list_free (alarms);
+ g_object_unref (real_comp);
+ }
+ }
+
if ((response != ITIP_VIEW_RESPONSE_CANCEL)
&& (response != ITIP_VIEW_RESPONSE_DECLINE)){
GSList *attachments = NULL, *new_attachments = NULL, *l;
@@ -1160,7 +1213,7 @@ send_comp_to_attendee (ECalComponentItipMethod method, ECalComponent *comp, cons
}
/* FIXME send the attachments in the request */
- status = itip_send_comp (method, send_comp, client, NULL, NULL, NULL);
+ status = itip_send_comp (method, send_comp, client, NULL, NULL, NULL, TRUE);
g_object_unref (send_comp);
@@ -1310,7 +1363,7 @@ update_attendee_status (struct _itip_puri *pitip)
if (itip_view_get_update (ITIP_VIEW (pitip->view))) {
e_cal_component_commit_sequence (comp);
- itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, pitip->current_ecal, NULL, NULL, NULL);
+ itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, pitip->current_ecal, NULL, NULL, NULL, TRUE);
}
if (!e_cal_modify_object (pitip->current_ecal, icalcomp, rid ? CALOBJ_MOD_THIS : CALOBJ_MOD_ALL, &error)) {
@@ -1340,7 +1393,7 @@ send_item (struct _itip_puri *pitip)
comp = get_real_item (pitip);
if (comp != NULL) {
- itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, pitip->current_ecal, NULL, NULL, NULL);
+ itip_send_comp (E_CAL_COMPONENT_METHOD_REQUEST, comp, pitip->current_ecal, NULL, NULL, NULL, TRUE);
g_object_unref (comp);
switch (pitip->type) {
@@ -1421,7 +1474,7 @@ set_itip_error (struct _itip_puri *pitip, GtkContainer *container, const char *p
}
static gboolean
-extract_itip_data (struct _itip_puri *pitip, GtkContainer *container)
+extract_itip_data (struct _itip_puri *pitip, GtkContainer *container, gboolean *have_alarms)
{
icalproperty *prop;
icalcomponent_kind kind = ICAL_NO_COMPONENT;
@@ -1581,14 +1634,24 @@ extract_itip_data (struct _itip_puri *pitip, GtkContainer *container)
prop = icalcomponent_get_next_property (pitip->ical_comp, ICAL_X_PROPERTY);
}
- /* Strip out alarms for security purposes */
+ /* Strip out procedural alarms for security purposes */
alarm_iter = icalcomponent_begin_component (pitip->ical_comp, ICAL_VALARM_COMPONENT);
while ((alarm_comp = icalcompiter_deref (&alarm_iter)) != NULL) {
+ icalproperty *p;
+
icalcompiter_next (&alarm_iter);
- icalcomponent_remove_component (pitip->ical_comp, alarm_comp);
+ p = icalcomponent_get_first_property (alarm_comp, ICAL_ACTION_PROPERTY);
+ if (icalproperty_get_action (p) == ICAL_ACTION_PROCEDURE)
+ icalcomponent_remove_component (pitip->ical_comp, alarm_comp);
+
icalcomponent_free (alarm_comp);
}
+
+ if (have_alarms) {
+ alarm_iter = icalcomponent_begin_component (pitip->ical_comp, ICAL_VALARM_COMPONENT);
+ *have_alarms = icalcompiter_deref (&alarm_iter) != NULL;
+ }
}
pitip->comp = e_cal_component_new ();
@@ -1911,7 +1974,7 @@ view_response_cb (GtkWidget *widget, ItipViewResponse response, gpointer data)
}
e_cal_component_rescan (comp);
- if (itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, pitip->current_ecal, pitip->top_level, NULL, NULL)) {
+ if (itip_send_comp (E_CAL_COMPONENT_METHOD_REPLY, comp, pitip->current_ecal, pitip->top_level, NULL, NULL, TRUE)) {
camel_folder_set_message_flags (pitip->folder, pitip->uid, CAMEL_MESSAGE_ANSWERED, CAMEL_MESSAGE_ANSWERED);
}
@@ -1974,6 +2037,7 @@ format_itip_object (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject
const char *string, *org;
int i;
gboolean response_enabled;
+ gboolean have_alarms = FALSE;
info = (struct _itip_puri *) em_format_find_puri((EMFormat *)efh, pobject->classid);
@@ -1991,7 +2055,7 @@ format_itip_object (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject
}
/* FIXME Handle multiple VEVENTS with the same UID, ie detached instances */
- if (!extract_itip_data (info, GTK_CONTAINER (eb)))
+ if (!extract_itip_data (info, GTK_CONTAINER (eb), &have_alarms))
return TRUE;
info->view = itip_view_new ();
@@ -2003,6 +2067,8 @@ format_itip_object (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject
if (!response_enabled) {
itip_view_set_mode (ITIP_VIEW (info->view), ITIP_VIEW_MODE_HIDE_ALL);
} else {
+ itip_view_set_show_inherit_alarm_check (ITIP_VIEW (info->view), have_alarms && (info->method == ICAL_METHOD_PUBLISH || info->method == ICAL_METHOD_REQUEST));
+
switch (info->method) {
case ICAL_METHOD_PUBLISH:
case ICAL_METHOD_REQUEST: