[evolution] I#992 - CompEditor: Allow editing meetings if not owner



commit 6f9e3ed57c673a53f2a3adab907c027b3fd27c67
Author: Milan Crha <mcrha redhat com>
Date:   Thu Feb 4 11:47:36 2021 +0100

    I#992 - CompEditor: Allow editing meetings if not owner
    
    Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/992

 src/calendar/gui/e-comp-editor-event.c            | 12 ++++++------
 src/calendar/gui/e-comp-editor-memo.c             |  2 +-
 src/calendar/gui/e-comp-editor-page-attachments.c |  7 +------
 src/calendar/gui/e-comp-editor-page-general.c     |  2 +-
 src/calendar/gui/e-comp-editor-page-recurrence.c  | 10 +---------
 src/calendar/gui/e-comp-editor-task.c             |  4 ++--
 src/calendar/gui/e-comp-editor.c                  | 12 +++++++++++-
 7 files changed, 23 insertions(+), 26 deletions(-)
---
diff --git a/src/calendar/gui/e-comp-editor-event.c b/src/calendar/gui/e-comp-editor-event.c
index a3e0b6f371..33ecb9df83 100644
--- a/src/calendar/gui/e-comp-editor-event.c
+++ b/src/calendar/gui/e-comp-editor-event.c
@@ -168,16 +168,16 @@ ece_event_sensitize_widgets (ECompEditor *comp_editor,
        is_organizer = (flags & (E_COMP_EDITOR_FLAG_IS_NEW | E_COMP_EDITOR_FLAG_ORGANIZER_IS_USER)) != 0;
        event_editor = E_COMP_EDITOR_EVENT (comp_editor);
 
-       gtk_widget_set_sensitive (event_editor->priv->all_day_check, !force_insensitive && is_organizer);
+       gtk_widget_set_sensitive (event_editor->priv->all_day_check, !force_insensitive);
 
        #define sensitize_part(x) G_STMT_START { \
                widget = e_comp_editor_property_part_get_label_widget (x); \
                if (widget) \
-                       gtk_widget_set_sensitive (widget, !force_insensitive && is_organizer); \
+                       gtk_widget_set_sensitive (widget, !force_insensitive); \
                \
                widget = e_comp_editor_property_part_get_edit_widget (x); \
                if (widget) \
-                       gtk_widget_set_sensitive (widget, !force_insensitive && is_organizer); \
+                       gtk_widget_set_sensitive (widget, !force_insensitive); \
        } G_STMT_END
 
        sensitize_part (event_editor->priv->dtstart);
@@ -187,10 +187,10 @@ ece_event_sensitize_widgets (ECompEditor *comp_editor,
        #undef sensitize_part
 
        action = e_comp_editor_get_action (comp_editor, "all-day-event");
-       gtk_action_set_sensitive (action, !force_insensitive && is_organizer);
+       gtk_action_set_sensitive (action, !force_insensitive);
 
        action = e_comp_editor_get_action (comp_editor, "classification-menu");
-       gtk_action_set_sensitive (action, !force_insensitive && is_organizer);
+       gtk_action_set_sensitive (action, !force_insensitive);
 
        if (event_editor->priv->insensitive_info_alert)
                e_alert_response (event_editor->priv->insensitive_info_alert, GTK_RESPONSE_OK);
@@ -205,7 +205,7 @@ ece_event_sensitize_widgets (ECompEditor *comp_editor,
                else if (e_client_is_readonly (E_CLIENT (client)))
                        message = _("Event cannot be edited, because the selected calendar is read only");
                else if (!is_organizer)
-                       message = _("Event cannot be fully edited, because you are not the organizer");
+                       message = _("Changes made to the event will not be sent to the attendees, because you 
are not the organizer");
 
                if (message) {
                        EAlert *alert;
diff --git a/src/calendar/gui/e-comp-editor-memo.c b/src/calendar/gui/e-comp-editor-memo.c
index c720cf48e3..c265fc92ab 100644
--- a/src/calendar/gui/e-comp-editor-memo.c
+++ b/src/calendar/gui/e-comp-editor-memo.c
@@ -212,7 +212,7 @@ ece_memo_sensitize_widgets (ECompEditor *comp_editor,
                else if (e_client_is_readonly (E_CLIENT (client)))
                        message = _("Memo cannot be edited, because the selected memo list is read only");
                else if (!is_organizer)
-                       message = _("Memo cannot be fully edited, because you are not the organizer");
+                       message = _("Changes made to the memo will not be sent to the attendees, because you 
are not the organizer");
 
                if (message) {
                        EAlert *alert;
diff --git a/src/calendar/gui/e-comp-editor-page-attachments.c 
b/src/calendar/gui/e-comp-editor-page-attachments.c
index 7c3ab0015d..51eadc6ede 100644
--- a/src/calendar/gui/e-comp-editor-page-attachments.c
+++ b/src/calendar/gui/e-comp-editor-page-attachments.c
@@ -221,20 +221,15 @@ ecep_attachments_sensitize_widgets (ECompEditorPage *page,
 {
        ECompEditor *comp_editor;
        GtkAction *action;
-       guint32 flags;
-       gboolean is_organizer;
 
        g_return_if_fail (E_IS_COMP_EDITOR_PAGE_ATTACHMENTS (page));
 
        E_COMP_EDITOR_PAGE_CLASS (e_comp_editor_page_attachments_parent_class)->sensitize_widgets (page, 
force_insensitive);
 
        comp_editor = e_comp_editor_page_ref_editor (page);
-       flags = e_comp_editor_get_flags (comp_editor);
-
-       is_organizer = (flags & (E_COMP_EDITOR_FLAG_IS_NEW | E_COMP_EDITOR_FLAG_ORGANIZER_IS_USER)) != 0;
 
        action = e_comp_editor_get_action (comp_editor, "attachments-attach");
-       gtk_action_set_sensitive (action, !force_insensitive && is_organizer);
+       gtk_action_set_sensitive (action, !force_insensitive);
 
        g_clear_object (&comp_editor);
 }
diff --git a/src/calendar/gui/e-comp-editor-page-general.c b/src/calendar/gui/e-comp-editor-page-general.c
index 1c4816dea5..6d6d543801 100644
--- a/src/calendar/gui/e-comp-editor-page-general.c
+++ b/src/calendar/gui/e-comp-editor-page-general.c
@@ -849,7 +849,7 @@ ecep_general_sensitize_widgets (ECompEditorPage *page,
        gtk_widget_set_sensitive (page_general->priv->attendees_list_view, !read_only && !force_insensitive);
 
        action = e_comp_editor_get_action (comp_editor, "option-attendees");
-       gtk_action_set_sensitive (action, !force_insensitive && !read_only && organizer_is_user);
+       gtk_action_set_sensitive (action, !force_insensitive && !read_only);
 
        if (page_general->priv->comp_color &&
            !e_comp_editor_property_part_get_sensitize_handled (page_general->priv->comp_color)) {
diff --git a/src/calendar/gui/e-comp-editor-page-recurrence.c 
b/src/calendar/gui/e-comp-editor-page-recurrence.c
index 8e4ada285a..e3f308d473 100644
--- a/src/calendar/gui/e-comp-editor-page-recurrence.c
+++ b/src/calendar/gui/e-comp-editor-page-recurrence.c
@@ -1490,19 +1490,13 @@ ecep_recurrence_sensitize_widgets (ECompEditorPage *page,
                                   gboolean force_insensitive)
 {
        ECompEditorPageRecurrence *page_recurrence;
-       ECompEditor *comp_editor;
        GtkTreeSelection *selection;
-       gboolean create_recurrence, any_selected, is_organizer;
-       guint32 flags;
+       gboolean create_recurrence, any_selected;
 
        g_return_if_fail (E_IS_COMP_EDITOR_PAGE_RECURRENCE (page));
 
        E_COMP_EDITOR_PAGE_CLASS (e_comp_editor_page_recurrence_parent_class)->sensitize_widgets (page, 
force_insensitive);
 
-       comp_editor = e_comp_editor_page_ref_editor (page);
-       flags = e_comp_editor_get_flags (comp_editor);
-       g_clear_object (&comp_editor);
-
        page_recurrence = E_COMP_EDITOR_PAGE_RECURRENCE (page);
 
        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (page_recurrence->priv->exceptions_tree_view));
@@ -1510,8 +1504,6 @@ ecep_recurrence_sensitize_widgets (ECompEditorPage *page,
        force_insensitive = force_insensitive || page_recurrence->priv->is_custom;
        create_recurrence = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(page_recurrence->priv->recr_check_box));
        any_selected = gtk_tree_selection_count_selected_rows (selection) > 0;
-       is_organizer = (flags & (E_COMP_EDITOR_FLAG_IS_NEW | E_COMP_EDITOR_FLAG_ORGANIZER_IS_USER)) != 0;
-       force_insensitive = force_insensitive || !is_organizer;
 
        gtk_widget_set_sensitive (page_recurrence->priv->recr_check_box, !force_insensitive);
        gtk_widget_set_sensitive (page_recurrence->priv->recr_hbox, !force_insensitive && create_recurrence);
diff --git a/src/calendar/gui/e-comp-editor-task.c b/src/calendar/gui/e-comp-editor-task.c
index 7274e774d7..96c575961d 100644
--- a/src/calendar/gui/e-comp-editor-task.c
+++ b/src/calendar/gui/e-comp-editor-task.c
@@ -509,7 +509,7 @@ ece_task_sensitize_widgets (ECompEditor *comp_editor,
        task_editor = E_COMP_EDITOR_TASK (comp_editor);
 
        action = e_comp_editor_get_action (comp_editor, "all-day-task");
-       gtk_action_set_sensitive (action, !force_insensitive && is_organizer);
+       gtk_action_set_sensitive (action, !force_insensitive);
 
        if (task_editor->priv->insensitive_info_alert)
                e_alert_response (task_editor->priv->insensitive_info_alert, GTK_RESPONSE_OK);
@@ -524,7 +524,7 @@ ece_task_sensitize_widgets (ECompEditor *comp_editor,
                else if (e_client_is_readonly (E_CLIENT (client)))
                        message = _("Task cannot be edited, because the selected task list is read only");
                else if (!is_organizer)
-                       message = _("Task cannot be fully edited, because you are not the organizer");
+                       message = _("Changes made to the task will not be sent to the attendees, because you 
are not the organizer");
 
                if (message) {
                        EAlert *alert;
diff --git a/src/calendar/gui/e-comp-editor.c b/src/calendar/gui/e-comp-editor.c
index 98cc498dc9..011582d1b8 100644
--- a/src/calendar/gui/e-comp-editor.c
+++ b/src/calendar/gui/e-comp-editor.c
@@ -970,6 +970,9 @@ ece_save_component (ECompEditor *comp_editor,
                    gboolean close_after_save)
 {
        EActivity *activity;
+       ECalComponent *comp;
+       EShell *shell;
+       ESourceRegistry *registry;
        const gchar *summary;
        ECalObjModType recur_mod = E_CAL_OBJ_MOD_THIS;
        SaveData *sd;
@@ -996,12 +999,18 @@ ece_save_component (ECompEditor *comp_editor,
 
        e_comp_editor_enable (comp_editor, FALSE);
 
+       shell = e_comp_editor_get_shell (comp_editor);
+       registry = e_shell_get_registry (shell);
+       comp = e_cal_component_new_from_icalcomponent (i_cal_component_clone (component));
+
        sd = g_slice_new0 (SaveData);
        sd->comp_editor = g_object_ref (comp_editor);
        sd->source_client = comp_editor->priv->source_client ? g_object_ref 
(comp_editor->priv->source_client) : NULL;
        sd->target_client = g_object_ref (comp_editor->priv->target_client);
        sd->component = i_cal_component_clone (component);
-       sd->with_send = with_send;
+       sd->with_send = with_send && (!itip_has_any_attendees (comp) ||
+                   (itip_organizer_is_user (registry, comp, sd->target_client) ||
+                    itip_sentby_is_user (registry, comp, sd->target_client)));
        sd->close_after_save = close_after_save;
        sd->recur_mod = recur_mod;
        sd->first_send = E_CAL_COMPONENT_METHOD_NONE;
@@ -1018,6 +1027,7 @@ ece_save_component (ECompEditor *comp_editor,
        if (activity)
                e_activity_bar_set_activity (comp_editor->priv->activity_bar, activity);
 
+       g_clear_object (&comp);
        g_clear_object (&activity);
        g_free (source_display_name);
 }


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