aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorChenthill Palanisamy <pchen@src.gnome.org>2006-04-03 16:36:50 +0800
committerChenthill Palanisamy <pchen@src.gnome.org>2006-04-03 16:36:50 +0800
commit998f971fb8973f07e59e39957e23ee10e36f5c61 (patch)
tree557caa589a79fd4f503387f101e0d9d96c5e275e /calendar
parentbb34bf11dc425498b3dda90a95fbabe179a1eaba (diff)
downloadgsoc2013-evolution-998f971fb8973f07e59e39957e23ee10e36f5c61.tar
gsoc2013-evolution-998f971fb8973f07e59e39957e23ee10e36f5c61.tar.gz
gsoc2013-evolution-998f971fb8973f07e59e39957e23ee10e36f5c61.tar.bz2
gsoc2013-evolution-998f971fb8973f07e59e39957e23ee10e36f5c61.tar.lz
gsoc2013-evolution-998f971fb8973f07e59e39957e23ee10e36f5c61.tar.xz
gsoc2013-evolution-998f971fb8973f07e59e39957e23ee10e36f5c61.tar.zst
gsoc2013-evolution-998f971fb8973f07e59e39957e23ee10e36f5c61.zip
Added retract support.
svn path=/trunk/; revision=31759
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog12
-rw-r--r--calendar/gui/dialogs/delete-comp.c91
-rw-r--r--calendar/gui/dialogs/delete-comp.h1
-rw-r--r--calendar/gui/e-calendar-table.c78
-rw-r--r--calendar/gui/e-calendar-view.c127
5 files changed, 299 insertions, 10 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 7100395af9..f400598a58 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,15 @@
+2006-04-03 Chenthill Palanisamy <pchenthill@novell.com>
+
+ Fixes #158107
+ * gui/dialogs/delete-comp.c: (delete_component_dialog),
+ (cb_toggled_cb), (prompt_retract_dialog):
+ * gui/dialogs/delete-comp.h:
+ * gui/e-calendar-table.c: (add_retract_data), (check_for_retract),
+ (e_calendar_table_delete_selected):
+ * gui/e-calendar-view.c: (add_retract_data), (check_for_retract),
+ (delete_event), (e_calendar_view_delete_selected_occurrence): Added
+ retract support.
+
2006-03-29 Chenthill Palanisamy <pchenthill@novell.com>
Fixes #160357 [b.n.c]
diff --git a/calendar/gui/dialogs/delete-comp.c b/calendar/gui/dialogs/delete-comp.c
index dab62ae8b9..113849b81c 100644
--- a/calendar/gui/dialogs/delete-comp.c
+++ b/calendar/gui/dialogs/delete-comp.c
@@ -24,6 +24,7 @@
#include <glib.h>
#include <gtk/gtkstock.h>
+#include <gtk/gtk.h>
#include <gtk/gtkmessagedialog.h>
#include <libgnome/gnome-i18n.h>
#include <e-util/e-icon-factory.h>
@@ -155,3 +156,93 @@ delete_component_dialog (ECalComponent *comp,
return response == GTK_RESPONSE_YES;
}
+
+static void
+cb_toggled_cb (GtkWidget *toggle, gpointer data)
+{
+ gboolean active = FALSE;
+ GtkWidget *entry = (GtkWidget *) data;
+
+ active = GTK_TOGGLE_BUTTON (toggle)->active;
+ gtk_widget_set_sensitive (entry, active);
+}
+
+gboolean
+prompt_retract_dialog (ECalComponent *comp, char **retract_text, GtkWidget *parent)
+{
+ char *message = NULL;
+ ECalComponentVType type = E_CAL_COMPONENT_NO_TYPE;
+ GtkMessageDialog *dialog = NULL;
+ GtkWidget *cb, *label, *entry, *vbox, *sw, *frame;
+ gboolean ret_val = FALSE;
+
+ type = e_cal_component_get_vtype (comp);
+
+ switch (type) {
+ case E_CAL_COMPONENT_EVENT:
+ message = g_strdup_printf (_("Are you sure you want to delete this meeting?"));
+ break;
+ case E_CAL_COMPONENT_TODO:
+ message = g_strdup_printf (_("Are you sure you want to delete this task?"));
+ break;
+ case E_CAL_COMPONENT_JOURNAL:
+ message = g_strdup_printf (_("Are you sure you want to delete this journal entry?"));
+ break;
+ default:
+ g_message ("Retract: Unsupported object type \n");
+ return FALSE;
+ }
+
+ dialog = (GtkMessageDialog *) gtk_message_dialog_new_with_markup
+ ((GtkWindow *) gtk_widget_get_toplevel (parent), GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, "<b>%s</b>", message);
+ g_free (message);
+
+ gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
+
+ gtk_box_set_spacing ((GtkBox *) (GTK_DIALOG (dialog)->vbox), 12);
+ vbox = GTK_CONTAINER (GTK_DIALOG (dialog)->vbox);
+
+ cb = gtk_check_button_new_with_mnemonic (_("_Delete this item from all other recipient's mailboxes?"));
+ gtk_container_add (GTK_CONTAINER (vbox), cb);
+
+ label = gtk_label_new_with_mnemonic ("_Retract comment");
+
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget ((GtkFrame *) frame, label);
+ gtk_frame_set_label_align ((GtkFrame *) frame, 0, 0);
+ gtk_container_add (GTK_CONTAINER (vbox), frame);
+ gtk_frame_set_shadow_type ((GtkFrame *)frame, GTK_SHADOW_NONE);
+
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy ((GtkScrolledWindow *)sw, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ entry = gtk_text_view_new ();
+ gtk_scrolled_window_add_with_viewport ((GtkScrolledWindow *)sw, entry);
+ gtk_label_set_mnemonic_widget ((GtkLabel *)label, entry);
+ gtk_container_add (GTK_CONTAINER (frame), sw);
+
+ g_signal_connect ((GtkToggleButton *)cb, "toggled", G_CALLBACK (cb_toggled_cb), entry);
+
+ gtk_widget_show_all ((GtkWidget *)dialog);
+
+ ret_val = (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK);
+
+ if (ret_val) {
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (cb))) {
+ GtkTextIter text_iter_start, text_iter_end;
+ GtkTextBuffer *text_buffer;
+
+ text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (entry));
+ gtk_text_buffer_get_start_iter (text_buffer, &text_iter_start);
+ gtk_text_buffer_get_end_iter (text_buffer, &text_iter_end);
+
+ *retract_text = gtk_text_buffer_get_text (text_buffer, &text_iter_start,
+ &text_iter_end, FALSE);
+ }
+ }
+
+ gtk_widget_destroy ((GtkWidget *) dialog);
+
+ return ret_val;
+}
diff --git a/calendar/gui/dialogs/delete-comp.h b/calendar/gui/dialogs/delete-comp.h
index f8773c25d0..d0260f313f 100644
--- a/calendar/gui/dialogs/delete-comp.h
+++ b/calendar/gui/dialogs/delete-comp.h
@@ -28,5 +28,6 @@ gboolean delete_component_dialog (ECalComponent *comp,
gboolean consider_as_untitled,
int n_comps, ECalComponentVType vtype,
GtkWidget *widget);
+gboolean prompt_retract_dialog (ECalComponent *comp, char **retract_text, GtkWidget *parent);
#endif
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c
index 74865debdf..ff6c8a19da 100644
--- a/calendar/gui/e-calendar-table.c
+++ b/calendar/gui/e-calendar-table.c
@@ -716,6 +716,46 @@ delete_selected_components (ECalendarTable *cal_table)
g_slist_free (objs);
}
+static void
+add_retract_data (ECalComponent *comp, const char *retract_comment)
+{
+ icalcomponent *icalcomp = NULL;
+ icalproperty *icalprop = NULL;
+
+ icalcomp = e_cal_component_get_icalcomponent (comp);
+ if (retract_comment && *retract_comment)
+ icalprop = icalproperty_new_x (retract_comment);
+ else
+ icalprop = icalproperty_new_x ("0");
+ icalproperty_set_x_name (icalprop, "X-EVOLUTION-RETRACT-COMMENT");
+ icalcomponent_add_property (icalcomp, icalprop);
+}
+
+static gboolean
+check_for_retract (ECalComponent *comp, ECal *client)
+{
+ ECalComponentOrganizer org;
+ char *email = NULL;
+ const char *strip = NULL;
+ gboolean ret_val = FALSE;
+
+ if (!(e_cal_component_has_attendees (comp) &&
+ e_cal_get_save_schedules (client)))
+ return ret_val;
+
+ e_cal_component_get_organizer (comp, &org);
+ strip = itip_strip_mailto (org.value);
+
+ if (e_cal_get_cal_address (client, &email, NULL) && !g_ascii_strcasecmp (email, strip)) {
+ ret_val = TRUE;
+ }
+
+ if (!ret_val)
+ ret_val = e_account_list_find(itip_addresses_get(), E_ACCOUNT_FIND_ID_ADDRESS, strip) != NULL;
+
+ g_free (email);
+ return ret_val;
+}
/**
* e_calendar_table_delete_selected:
@@ -730,6 +770,8 @@ e_calendar_table_delete_selected (ECalendarTable *cal_table)
int n_selected;
ECalModelComponent *comp_data;
ECalComponent *comp = NULL;
+ gboolean delete = FALSE;
+ GError *error = NULL;
g_return_if_fail (cal_table != NULL);
g_return_if_fail (E_IS_CALENDAR_TABLE (cal_table));
@@ -752,8 +794,40 @@ e_calendar_table_delete_selected (ECalendarTable *cal_table)
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (comp_data->icalcomp));
}
- if (delete_component_dialog (comp, FALSE, n_selected, E_CAL_COMPONENT_TODO,
- GTK_WIDGET (cal_table)))
+ if ((n_selected == 1) && comp && check_for_retract (comp, comp_data->client)) {
+ char *retract_comment = NULL;
+ gboolean retract = FALSE;
+
+ retract = prompt_retract_dialog (comp, &retract_comment, GTK_WIDGET (cal_table));
+ if (retract) {
+ GList *users = NULL;
+ icalcomponent *icalcomp = NULL, *mod_comp = NULL;
+
+ add_retract_data (comp, retract_comment);
+ icalcomp = e_cal_component_get_icalcomponent (comp);
+ icalcomponent_set_method (icalcomp, ICAL_METHOD_CANCEL);
+ if (!e_cal_send_objects (comp_data->client, icalcomp, &users,
+ &mod_comp, &error)) {
+ delete_error_dialog (error, E_CAL_COMPONENT_TODO);
+ g_clear_error (&error);
+ error = NULL;
+ } else {
+
+ if (mod_comp)
+ icalcomponent_free (mod_comp);
+
+ if (users) {
+ g_list_foreach (users, (GFunc) g_free, NULL);
+ g_list_free (users);
+ }
+ }
+
+ }
+ } else {
+ delete = delete_component_dialog (comp, FALSE, 1, E_CAL_COMPONENT_TODO, GTK_WIDGET (cal_table));
+ }
+
+ if (delete)
delete_selected_components (cal_table);
/* free memory */
diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c
index 148d0f0a1e..0fb1ad8abe 100644
--- a/calendar/gui/e-calendar-view.c
+++ b/calendar/gui/e-calendar-view.c
@@ -859,10 +859,60 @@ e_calendar_view_paste_clipboard (ECalendarView *cal_view)
}
static void
+add_retract_data (ECalComponent *comp, const char *retract_comment, CalObjModType mod)
+{
+ icalcomponent *icalcomp = NULL;
+ icalproperty *icalprop = NULL;
+
+ icalcomp = e_cal_component_get_icalcomponent (comp);
+ if (retract_comment && *retract_comment)
+ icalprop = icalproperty_new_x (retract_comment);
+ else
+ icalprop = icalproperty_new_x ("0");
+ icalproperty_set_x_name (icalprop, "X-EVOLUTION-RETRACT-COMMENT");
+ icalcomponent_add_property (icalcomp, icalprop);
+
+ if (mod == CALOBJ_MOD_ALL)
+ icalprop = icalproperty_new_x ("All");
+ else
+ icalprop = icalproperty_new_x ("This");
+ icalproperty_set_x_name (icalprop, "X-EVOLUTION-RECUR-MOD");
+ icalcomponent_add_property (icalcomp, icalprop);
+}
+
+static gboolean
+check_for_retract (ECalComponent *comp, ECal *client)
+{
+ ECalComponentOrganizer org;
+ char *email = NULL;
+ const char *strip = NULL;
+ gboolean ret_val = FALSE;
+
+ if (!(e_cal_component_has_attendees (comp) &&
+ e_cal_get_save_schedules (client)))
+ return ret_val;
+
+ e_cal_component_get_organizer (comp, &org);
+ strip = itip_strip_mailto (org.value);
+
+ if (e_cal_get_cal_address (client, &email, NULL) && !g_ascii_strcasecmp (email, strip)) {
+ ret_val = TRUE;
+ }
+
+ if (!ret_val)
+ ret_val = e_account_list_find(itip_addresses_get(), E_ACCOUNT_FIND_ID_ADDRESS, strip) != NULL;
+
+ g_free (email);
+ return ret_val;
+}
+
+static void
delete_event (ECalendarView *cal_view, ECalendarViewEvent *event)
{
ECalComponent *comp;
ECalComponentVType vtype;
+ gboolean delete = FALSE;
+ GError *error = NULL;
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
@@ -872,9 +922,39 @@ delete_event (ECalendarView *cal_view, ECalendarViewEvent *event)
if (!e_cal_get_static_capability (event->comp_data->client, CAL_STATIC_CAPABILITY_RECURRENCES_NO_MASTER))
e_cal_component_set_recurid (comp, NULL);
- if (delete_component_dialog (comp, FALSE, 1, vtype, GTK_WIDGET (cal_view))) {
+ if (check_for_retract (comp, event->comp_data->client)) {
+ char *retract_comment = NULL;
+ gboolean retract = FALSE;
+
+ retract = prompt_retract_dialog (comp, &retract_comment, GTK_WIDGET (cal_view));
+ if (retract) {
+ GList *users = NULL;
+ icalcomponent *icalcomp = NULL, *mod_comp = NULL;
+
+ add_retract_data (comp, retract_comment, CALOBJ_MOD_ALL);
+ icalcomp = e_cal_component_get_icalcomponent (comp);
+ icalcomponent_set_method (icalcomp, ICAL_METHOD_CANCEL);
+ if (!e_cal_send_objects (event->comp_data->client, icalcomp, &users,
+ &mod_comp, &error)) {
+ delete_error_dialog (error, E_CAL_COMPONENT_EVENT);
+ g_clear_error (&error);
+ error = NULL;
+ } else {
+
+ if (mod_comp)
+ icalcomponent_free (mod_comp);
+
+ if (users) {
+ g_list_foreach (users, (GFunc) g_free, NULL);
+ g_list_free (users);
+ }
+ }
+ }
+ } else
+ delete = delete_component_dialog (comp, FALSE, 1, vtype, GTK_WIDGET (cal_view));
+
+ if (delete) {
const char *uid;
- GError *error = NULL;
if (itip_organizer_is_user (comp, event->comp_data->client)
&& cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET (cal_view)),
@@ -888,13 +968,13 @@ delete_event (ECalendarView *cal_view, ECalendarViewEvent *event)
g_object_unref (comp);
return;
}
-
+
if (e_cal_util_component_is_instance (event->comp_data->icalcomp) || e_cal_util_component_has_recurrences (event->comp_data->icalcomp))
e_cal_remove_object_with_mod (event->comp_data->client, uid,
e_cal_component_get_recurid_as_string (comp), CALOBJ_MOD_ALL, &error);
else
e_cal_remove_object (event->comp_data->client, uid, &error);
-
+
delete_error_dialog (error, E_CAL_COMPONENT_EVENT);
g_clear_error (&error);
}
@@ -944,18 +1024,49 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view)
GList *selected;
ECalComponent *comp;
ECalendarViewEvent *event;
+ ECalComponentVType vtype;
+ gboolean delete = FALSE;
+ GError *error = NULL;
selected = e_calendar_view_get_selected_events (cal_view);
if (!selected)
return;
-
event = (ECalendarViewEvent *) selected->data;
comp = e_cal_component_new ();
e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp));
+ vtype = e_cal_component_get_vtype (comp);
- if (delete_component_dialog (comp, FALSE, 1, e_cal_component_get_vtype (comp), GTK_WIDGET (cal_view))) {
+ if (check_for_retract (comp, event->comp_data->client)) {
+ char *retract_comment = NULL;
+ gboolean retract = FALSE;
+
+ retract = prompt_retract_dialog (comp, &retract_comment, GTK_WIDGET (cal_view));
+ if (retract) {
+ GList *users = NULL;
+ icalcomponent *icalcomp = NULL, *mod_comp = NULL;
+
+ add_retract_data (comp, retract_comment, CALOBJ_MOD_THIS);
+ icalcomp = e_cal_component_get_icalcomponent (comp);
+ icalcomponent_set_method (icalcomp, ICAL_METHOD_CANCEL);
+ if (!e_cal_send_objects (event->comp_data->client, icalcomp, &users,
+ &mod_comp, &error)) {
+ delete_error_dialog (error, E_CAL_COMPONENT_EVENT);
+ g_clear_error (&error);
+ error = NULL;
+ } else {
+ if (mod_comp)
+ icalcomponent_free (mod_comp);
+ if (users) {
+ g_list_foreach (users, (GFunc) g_free, NULL);
+ g_list_free (users);
+ }
+ }
+ }
+ } else
+ delete = delete_component_dialog (comp, FALSE, 1, vtype, GTK_WIDGET (cal_view));
+
+ if (delete) {
const char *uid, *rid = NULL;
- GError *error = NULL;
ECalComponentDateTime dt;
icaltimezone *zone = NULL;
gboolean is_instance = FALSE;
@@ -1011,7 +1122,7 @@ e_calendar_view_delete_selected_occurrence (ECalendarView *cal_view)
e_cal_modify_object (event->comp_data->client, event->comp_data->icalcomp, CALOBJ_MOD_THIS,
&error);
}
-
+
delete_error_dialog (error, E_CAL_COMPONENT_EVENT);
g_clear_error (&error);
}