diff options
Diffstat (limited to 'calendar/gui/dialogs')
-rw-r--r-- | calendar/gui/dialogs/comp-editor.c | 68 | ||||
-rw-r--r-- | calendar/gui/dialogs/event-editor.c | 37 | ||||
-rw-r--r-- | calendar/gui/dialogs/meeting-page.c | 71 |
3 files changed, 136 insertions, 40 deletions
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 495de600be..abd16741c4 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -731,19 +731,26 @@ save_comp_with_send (CompEditor *editor) { CompEditorPrivate *priv; gboolean send; + gboolean delegate; priv = editor->priv; - + send = priv->changed && priv->needs_send; + delegate = priv->flags & COMP_EDITOR_DELEGATE; if (!save_comp (editor)) return FALSE; - if (send && send_component_dialog ((GtkWindow *) editor, priv->client, priv->comp, !priv->existing_org)) { + if (delegate || (send && send_component_dialog ((GtkWindow *) editor, priv->client, priv->comp, !priv->existing_org))) { if (itip_organizer_is_user (priv->comp, priv->client)) return comp_editor_send_comp (editor, E_CAL_COMPONENT_METHOD_REQUEST); - else - return comp_editor_send_comp (editor, E_CAL_COMPONENT_METHOD_REPLY); + else { + if (!comp_editor_send_comp (editor, E_CAL_COMPONENT_METHOD_REQUEST)) + return FALSE; + + if (delegate) + return comp_editor_send_comp (editor, E_CAL_COMPONENT_METHOD_REPLY); + } } return TRUE; @@ -1801,6 +1808,9 @@ real_edit_comp (CompEditor *editor, ECalComponent *comp) e_cal_get_local_attachment_store (priv->client)); cal_attachment_bar_set_comp_uid (priv->attachment_bar, g_strdup (uid)); + if (!itip_organizer_is_user (comp, priv->client)) + comp_editor_sensitize_attachment_bar (editor, FALSE); + fill_widgets (editor); priv->changed =FALSE; @@ -1808,20 +1818,58 @@ real_edit_comp (CompEditor *editor, ECalComponent *comp) listen_for_changes (editor); } +/* TODO These functions should be available in e-cal-component.c */ +static void +set_attendees_for_delegation (ECalComponent *comp, const char *address, ECalComponentItipMethod method) +{ + GSList *attendees, *l, *new; + icalproperty *prop; + icalparameter *param; + icalcomponent *icalcomp; + + icalcomp = e_cal_component_get_icalcomponent (comp); + + for (prop = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY); + prop; + prop = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY)) { + const char *attendee = icalproperty_get_attendee (prop); + const char *delfrom; + + param = icalproperty_get_first_parameter(prop, ICAL_DELEGATEDFROM_PARAMETER); + delfrom = icalparameter_get_delegatedfrom (param); + if (!(g_str_equal (itip_strip_mailto (attendee), address) || + ((delfrom && *delfrom) && + g_str_equal (itip_strip_mailto (delfrom), address)))) { + icalcomponent_remove_property (icalcomp, prop); + } + + } + +} static gboolean real_send_comp (CompEditor *editor, ECalComponentItipMethod method) { CompEditorPrivate *priv; - ECalComponent *tmp_comp; + ECalComponent *tmp_comp, *send_comp; + char *address = NULL; g_return_val_if_fail (editor != NULL, FALSE); g_return_val_if_fail (IS_COMP_EDITOR (editor), FALSE); priv = editor->priv; + send_comp = e_cal_component_clone (priv->comp); + /* The user updates the delegated status to the Organizer, so remove all other attendees */ + if ((priv->flags & COMP_EDITOR_DELEGATE)) { + address = itip_get_comp_attendee (send_comp, priv->client); + + if (address) + set_attendees_for_delegation (send_comp, address, method); + } + if (!e_cal_component_has_attachments (priv->comp)) { - if (itip_send_comp (method, priv->comp, priv->client, + if (itip_send_comp (method, send_comp, priv->client, NULL, NULL)) { #if 0 tmp_comp = priv->comp; @@ -1830,20 +1878,19 @@ real_send_comp (CompEditor *editor, ECalComponentItipMethod method) g_object_unref (tmp_comp); comp_editor_set_changed (editor, TRUE); - save_comp (editor); #endif + save_comp (editor); + g_object_unref (send_comp); return TRUE; } } else { /* Clone the component with attachments set to CID:... */ - ECalComponent *send_comp; int num_attachments, i; GSList *attach_list = NULL; GSList *mime_attach_list; - send_comp = e_cal_component_clone (priv->comp); num_attachments = e_cal_component_get_num_attachments (send_comp); for (i = 0; i < num_attachments ; i++) { @@ -1865,9 +1912,10 @@ real_send_comp (CompEditor *editor, ECalComponentItipMethod method) g_object_unref (send_comp); return TRUE; } - g_object_unref (send_comp); } + g_object_unref (send_comp); + g_free (address); comp_editor_set_changed (editor, TRUE); return FALSE; diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c index 72b4d8246b..01ec3936f1 100644 --- a/calendar/gui/dialogs/event-editor.c +++ b/calendar/gui/dialogs/event-editor.c @@ -208,6 +208,7 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp) EventEditor *ee; EventEditorPrivate *priv; ECalComponentOrganizer organizer; + gboolean delegate; ECal *client; GSList *attendees = NULL; @@ -215,17 +216,13 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp) priv = ee->priv; priv->updating = TRUE; - - - client = comp_editor_get_e_cal (COMP_EDITOR (editor)); - if (priv->is_meeting && itip_organizer_is_user (comp, client)) { - COMP_EDITOR_PAGE (priv->event_page)->flags |= COMP_EDITOR_PAGE_USER_ORG; - COMP_EDITOR_PAGE (priv->recur_page)->flags |= COMP_EDITOR_PAGE_USER_ORG; - } - + delegate = (comp_editor_get_flags (COMP_EDITOR (editor)) & COMP_EDITOR_DELEGATE); + if (COMP_EDITOR_CLASS (event_editor_parent_class)->edit_comp) COMP_EDITOR_CLASS (event_editor_parent_class)->edit_comp (editor, comp); + client = comp_editor_get_e_cal (COMP_EDITOR (editor)); + /* Get meeting related stuff */ e_cal_component_get_organizer (comp, &organizer); e_cal_component_get_attendee_list (comp, &attendees); @@ -243,8 +240,9 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp) } else { GSList *l; int row; - const char *user_email; - + char *user_email; + + user_email = itip_get_comp_attendee (comp, client); if (!priv->meeting_shown) { comp_editor_append_page (COMP_EDITOR (ee), COMP_EDITOR_PAGE (priv->sched_page), @@ -254,16 +252,21 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp) _("Invitations")); } - if (! (comp_editor_get_flags (COMP_EDITOR (editor)) & COMP_EDITOR_DELEGATE)) { + if (!(delegate && e_cal_get_static_capability (client, CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY))) { for (l = attendees; l != NULL; l = l->next) { ECalComponentAttendee *ca = l->data; EMeetingAttendee *ia; - + + if (delegate && !g_str_equal (itip_strip_mailto (ca->value), user_email)) + continue; + ia = E_MEETING_ATTENDEE (e_meeting_attendee_new_from_e_cal_component_attendee (ca)); - /* If we aren't the organizer or the attendee is just delegating, don't allow editing */ + /* If we aren't the organizer or the attendee is just delegated, don't allow editing */ if (!comp_editor_get_user_org (editor) || e_meeting_attendee_is_set_delto (ia)) e_meeting_attendee_set_edit_level (ia, E_MEETING_ATTENDEE_EDIT_NONE); + + e_meeting_store_add_attendee (priv->model, ia); g_object_unref(ia); @@ -299,9 +302,6 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp) e_cal_component_free_attendee_list (attendees); comp_editor_set_needs_send (COMP_EDITOR (ee), priv->meeting_shown && itip_organizer_is_user (comp, client)); - if (e_cal_component_has_organizer (comp) && (COMP_EDITOR_PAGE (priv->event_page)->flags & - COMP_EDITOR_PAGE_MEETING)) - comp_editor_sensitize_attachment_bar (editor, itip_organizer_is_user (comp, client)); priv->updating = FALSE; } @@ -332,6 +332,8 @@ event_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method) if (!result) return FALSE; + else + return TRUE; } parent: @@ -428,8 +430,7 @@ show_meeting (EventEditor *ee) } if (comp_editor_get_flags (COMP_EDITOR (ee)) & COMP_EDITOR_DELEGATE) comp_editor_show_page (COMP_EDITOR (ee), COMP_EDITOR_PAGE (priv->meet_page)); - if (comp_editor_get_existing_org (COMP_EDITOR (ee)) && !comp_editor_get_user_org (COMP_EDITOR (ee))) - comp_editor_remove_page (COMP_EDITOR (ee), COMP_EDITOR_PAGE (priv->sched_page)); + } void diff --git a/calendar/gui/dialogs/meeting-page.c b/calendar/gui/dialogs/meeting-page.c index 263a415f41..93ae8353b5 100644 --- a/calendar/gui/dialogs/meeting-page.c +++ b/calendar/gui/dialogs/meeting-page.c @@ -101,7 +101,7 @@ static GtkWidget *meeting_page_get_widget (CompEditorPage *page); static void meeting_page_focus_main_widget (CompEditorPage *page); static gboolean meeting_page_fill_widgets (CompEditorPage *page, ECalComponent *comp); static gboolean meeting_page_fill_component (CompEditorPage *page, ECalComponent *comp); - +static void attendee_added_cb (EMeetingListView *emlv, EMeetingAttendee *attendee, gpointer user_data); G_DEFINE_TYPE (MeetingPage, meeting_page, TYPE_COMP_EDITOR_PAGE); /* Class initialization function for the task page */ @@ -304,7 +304,7 @@ clear_widgets (MeetingPage *mpage) } if (e_cal_get_static_capability (COMP_EDITOR_PAGE (mpage)->client, CAL_STATIC_CAPABILITY_NO_ORGANIZER)) { - gtk_label_set_label (GTK_LABEL (priv->org_label), _("From:")); + gtk_label_set_markup (GTK_LABEL (priv->org_label), _("<b>From:</b>")); gtk_widget_hide (priv->existing_organizer_btn); } @@ -371,7 +371,9 @@ meeting_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) /* Component for cancellation */ priv->comp = e_cal_component_clone (comp); - + + priv->user_add = itip_get_comp_attendee (comp, COMP_EDITOR_PAGE (mpage)->client); + /* If there is an existing organizer show it properly */ if (e_cal_component_has_organizer (comp)) { e_cal_component_get_organizer (comp, &organizer); @@ -401,7 +403,7 @@ meeting_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) priv->user_org = FALSE; } - if (e_cal_get_static_capability (COMP_EDITOR_PAGE (mpage)->client, CAL_STATIC_CAPABILITY_NO_ORGANIZER)) + if (e_cal_get_static_capability (COMP_EDITOR_PAGE (mpage)->client, CAL_STATIC_CAPABILITY_NO_ORGANIZER) && (COMP_EDITOR_PAGE (mpage)->flags & COMP_EDITOR_PAGE_DELEGATE)) string = g_strdup (priv->user_add); else if ( organizer.cn != NULL) string = g_strdup_printf ("%s <%s>", organizer.cn, strip); @@ -495,6 +497,18 @@ meeting_page_fill_component (CompEditorPage *page, ECalComponent *comp) EMeetingAttendee *ia = g_ptr_array_index (attendees, i); ECalComponentAttendee *ca; + /* Remove the duplicate user from the component if present */ + if (e_meeting_attendee_is_set_delto (ia)) { + for (l = attendee_list; l; l = l->next) { + ECalComponentAttendee *a = l->data; + + if (g_str_equal (a->value, e_meeting_attendee_get_address (ia))) { + attendee_list = g_slist_remove (attendee_list, l->data); + break; + } + } + } + ca = e_meeting_attendee_as_e_cal_component_attendee (ia); attendee_list = g_slist_append (attendee_list, ca); @@ -635,7 +649,7 @@ add_clicked_cb (GtkButton *btn, MeetingPage *mpage) attendee = e_meeting_store_add_attendee_with_defaults (mpage->priv->model); if (COMP_EDITOR_PAGE (mpage)->flags & COMP_EDITOR_PAGE_DELEGATE) { - e_meeting_attendee_set_delfrom (attendee, g_strdup (mpage->priv->user_add)); + e_meeting_attendee_set_delfrom (attendee, g_strdup_printf ("MAILTO:%s", mpage->priv->user_add)); } e_meeting_list_view_edit (mpage->priv->list_view, attendee); @@ -674,6 +688,7 @@ remove_attendee (MeetingPage *mpage, EMeetingAttendee *ia) { MeetingPagePrivate *priv; int pos = 0; + gboolean delegate = (COMP_EDITOR_PAGE (mpage)->flags & COMP_EDITOR_PAGE_DELEGATE); priv = mpage->priv; @@ -691,7 +706,9 @@ remove_attendee (MeetingPage *mpage, EMeetingAttendee *ia) ib = e_meeting_store_find_attendee (priv->model, e_meeting_attendee_get_delfrom (ia), &pos); if (ib != NULL) { e_meeting_attendee_set_delto (ib, NULL); - e_meeting_attendee_set_edit_level (ib, E_MEETING_ATTENDEE_EDIT_FULL); + + if (!delegate) + e_meeting_attendee_set_edit_level (ib, E_MEETING_ATTENDEE_EDIT_FULL); } } @@ -710,7 +727,7 @@ remove_attendee (MeetingPage *mpage, EMeetingAttendee *ia) ia = ib; } - + sensitize_widgets (mpage); } @@ -751,6 +768,8 @@ remove_clicked_cb (GtkButton *btn, MeetingPage *mpage) g_free (address); if (!ia) return; + else if (e_meeting_attendee_get_edit_level (ia) != E_MEETING_ATTENDEE_EDIT_FULL) + return; remove_attendee (mpage, ia); @@ -803,6 +822,39 @@ init_widgets (MeetingPage *mpage) /* Contacts button */ g_signal_connect(priv->invite, "clicked", G_CALLBACK (invite_cb), mpage); + + /* Meeting List View */ + g_signal_connect (priv->list_view, "attendee_added", G_CALLBACK (attendee_added_cb), mpage); +} + +static void +attendee_added_cb (EMeetingListView *emlv, EMeetingAttendee *ia, gpointer user_data) +{ + MeetingPage *mpage = MEETING_PAGE (user_data); + MeetingPagePrivate *priv; + gboolean delegate = (COMP_EDITOR_PAGE (mpage)->flags & COMP_EDITOR_PAGE_DELEGATE); + + priv = mpage->priv; + + if (delegate) { + if (existing_attendee (ia, priv->comp)) + e_meeting_store_remove_attendee (priv->model, ia); + else { + if (!e_cal_get_static_capability (COMP_EDITOR_PAGE(mpage)->client, + CAL_STATIC_CAPABILITY_DELEGATE_TO_MANY)) { + const char *delegator_id = e_meeting_attendee_get_delfrom (ia); + EMeetingAttendee *delegator; + + delegator = e_meeting_store_find_attendee (priv->model, delegator_id, NULL); + e_meeting_attendee_set_delto (delegator, + g_strdup (e_meeting_attendee_get_address (ia))); + + gtk_widget_set_sensitive (priv->invite, FALSE); + gtk_widget_set_sensitive (priv->add, FALSE); + } + } + } + } static void @@ -953,11 +1005,6 @@ meeting_page_construct (MeetingPage *mpage, EMeetingStore *ems, } } - if (backend_address) - priv->user_add = backend_address; - else - priv->user_add = g_strdup (a->id->address); - g_object_unref(it); if (address_strings) |