[evolution] Bug 336195 - Do not ask to notify attendees when there are none



commit 163380dff932079c0ca21d2332b31a6de37d641e
Author: Milan Crha <mcrha redhat com>
Date:   Thu Oct 13 21:28:22 2016 +0200

    Bug 336195 - Do not ask to notify attendees when there are none

 src/calendar/gui/e-calendar-view.c |    9 ++++--
 src/calendar/gui/e-day-view.c      |    9 ++++--
 src/calendar/gui/itip-utils.c      |   45 ++++++++++++++++++++++++++++++++++++
 src/calendar/gui/itip-utils.h      |    1 +
 4 files changed, 58 insertions(+), 6 deletions(-)
---
diff --git a/src/calendar/gui/e-calendar-view.c b/src/calendar/gui/e-calendar-view.c
index 4b44c22..4a785b0 100644
--- a/src/calendar/gui/e-calendar-view.c
+++ b/src/calendar/gui/e-calendar-view.c
@@ -197,7 +197,8 @@ calendar_view_delete_event (ECalendarView *cal_view,
 
                rid = e_cal_component_get_recurid_as_string (comp);
 
-               if ((itip_organizer_is_user (registry, comp, event->comp_data->client) ||
+               if (itip_has_any_attendees (comp) &&
+                   (itip_organizer_is_user (registry, comp, event->comp_data->client) ||
                     itip_sentby_is_user (registry, comp, event->comp_data->client))
                    && e_cal_dialogs_cancel_component ((GtkWindow *) gtk_widget_get_toplevel (GTK_WIDGET 
(cal_view)),
                                                event->comp_data->client,
@@ -628,7 +629,8 @@ calendar_view_component_created_cb (ECalModel *model,
        if (new_uid)
                e_cal_component_set_uid (comp, new_uid);
 
-       if ((itip_organizer_is_user (registry, comp, client) ||
+       if (itip_has_any_attendees (comp) &&
+           (itip_organizer_is_user (registry, comp, client) ||
             itip_sentby_is_user (registry, comp, client)) &&
             e_cal_dialogs_send_component ((GtkWindow *) toplevel, client, comp, TRUE, &strip_alarms, NULL)) {
                itip_send_component_with_model (model, E_CAL_COMPONENT_METHOD_REQUEST,
@@ -780,7 +782,8 @@ paste_clipboard_data_free (gpointer ptr)
                                comp = e_cal_component_new ();
                                e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone 
(comp_data->icalcomp));
 
-                               if ((itip_organizer_is_user (registry, comp, comp_data->client) ||
+                               if (itip_has_any_attendees (comp) &&
+                                   (itip_organizer_is_user (registry, comp, comp_data->client) ||
                                    itip_sentby_is_user (registry, comp, comp_data->client))
                                    && e_cal_dialogs_cancel_component ((GtkWindow *) pcd->top_level, 
comp_data->client, comp, TRUE))
                                        itip_send_component_with_model (model, E_CAL_COMPONENT_METHOD_CANCEL,
diff --git a/src/calendar/gui/e-day-view.c b/src/calendar/gui/e-day-view.c
index aec869b..c4a3469 100644
--- a/src/calendar/gui/e-day-view.c
+++ b/src/calendar/gui/e-day-view.c
@@ -5524,7 +5524,8 @@ e_day_view_finish_resize (EDayView *day_view)
 
        toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view)));
 
-       if ((itip_organizer_is_user (registry, comp, client) ||
+       if (itip_has_any_attendees (comp) &&
+           (itip_organizer_is_user (registry, comp, client) ||
             itip_sentby_is_user (registry, comp, client)))
                send = e_cal_dialogs_send_dragged_or_resized_component (
                                toplevel, client, comp, &strip_alarms, &only_new_attendees);
@@ -9143,7 +9144,8 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
 
                        toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view)));
 
-                       if ((itip_organizer_is_user (registry, comp, client) ||
+                       if (itip_has_any_attendees (comp) &&
+                           (itip_organizer_is_user (registry, comp, client) ||
                             itip_sentby_is_user (registry, comp, client)))
                                send = e_cal_dialogs_send_dragged_or_resized_component (
                                                toplevel, client, comp, &strip_alarms, &only_new_attendees);
@@ -9386,7 +9388,8 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
 
                        toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (day_view)));
 
-                       if ((itip_organizer_is_user (registry, comp, client) ||
+                       if (itip_has_any_attendees (comp) &&
+                           (itip_organizer_is_user (registry, comp, client) ||
                             itip_sentby_is_user (registry, comp, client)))
                                send = e_cal_dialogs_send_dragged_or_resized_component (
                                                toplevel, client, comp, &strip_alarms, &only_new_attendees);
diff --git a/src/calendar/gui/itip-utils.c b/src/calendar/gui/itip-utils.c
index 49464e5..ec3c8db 100644
--- a/src/calendar/gui/itip-utils.c
+++ b/src/calendar/gui/itip-utils.c
@@ -334,6 +334,51 @@ itip_sentby_is_user (ESourceRegistry *registry,
        return user_sentby;
 }
 
+gboolean
+itip_has_any_attendees (ECalComponent *comp)
+{
+       ECalComponentOrganizer organizer;
+       ECalComponentAttendee *attendee;
+       GSList *attendees = NULL;
+       gboolean res;
+
+       g_return_val_if_fail (E_IS_CAL_COMPONENT (comp), FALSE);
+
+       if (!e_cal_component_has_attendees (comp))
+               return FALSE;
+
+       e_cal_component_get_attendee_list (comp, &attendees);
+
+       /* No attendee */
+       if (!attendees)
+               return FALSE;
+
+       /* More than one attendee */
+       if (attendees->next) {
+               e_cal_component_free_attendee_list (attendees);
+               return TRUE;
+       }
+
+       /* Exactly one attendee, check if it's not the organizer */
+       attendee = attendees->data;
+
+       g_return_val_if_fail (attendee != NULL, FALSE);
+
+       if (!e_cal_component_has_organizer (comp)) {
+               e_cal_component_free_attendee_list (attendees);
+               return FALSE;
+       }
+
+       e_cal_component_get_organizer (comp, &organizer);
+
+       res = attendee->value && (!organizer.value ||
+               g_ascii_strcasecmp (itip_strip_mailto (attendee->value), itip_strip_mailto (organizer.value)) 
!= 0);
+
+       e_cal_component_free_attendee_list (attendees);
+
+       return res;
+}
+
 static ECalComponentAttendee *
 get_attendee (GSList *attendees,
               gchar *address)
diff --git a/src/calendar/gui/itip-utils.h b/src/calendar/gui/itip-utils.h
index 981ab69..47b19fc 100644
--- a/src/calendar/gui/itip-utils.h
+++ b/src/calendar/gui/itip-utils.h
@@ -68,6 +68,7 @@ gboolean      itip_organizer_is_user_ex       (ESourceRegistry *registry,
 gboolean       itip_sentby_is_user             (ESourceRegistry *registry,
                                                 ECalComponent *comp,
                                                 ECalClient *cal_client);
+gboolean       itip_has_any_attendees          (ECalComponent *comp);
 const gchar *  itip_strip_mailto               (const gchar *address);
 gchar *                itip_get_comp_attendee          (ESourceRegistry *registry,
                                                 ECalComponent *comp,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]