From fc2c499f8bc737190309484a96e13dccd3cefbdf Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 27 Sep 2002 20:23:20 +0000 Subject: Non-Connector part of #29334 (meeting created by a delegate in the delegator's calendar should have the delegator as Organizer). * idl/evolution-calendar.idl: add Cal_getEmailAddress, to return the email address associated with a backend (if any). * pcs/cal-backend.c (cal_backend_get_email_address): New. * pcs/cal-backend-file.c (cal_backend_file_get_email_address): Return NULL (for now). * pcs/cal.c (impl_Cal_get_email_address): Implement this by calling cal_backend_get_email_address and returning a NotFound exception if it returns NULL. * cal-client/cal-client.c (cal_client_get_email_address): New. (cal_client_init, cal_client_destroy, etc): initialize/free email_address * gui/dialogs/event-editor.c (event_editor_construct): Split this out of event_editor_init. Take and set a CalClient. (event_editor_new): Take a CalClient. * gui/dialogs/task-editor.c (task_editor_construct, task_editor_new): Likewise. * gui/dialogs/meeting-page.c (meeting_page_new, meeting_page_construct): Take a CalClient and call cal_client_get_email_address to find the default organizer address. (Also fix a bug if the default account's name has non-ASCII characters.) * gui/itip-utils.c (comp_from): New. When sending a REQUEST or CANCEL, use the Organizer as the From address. (itip_send_comp): Call comp_from and pass the result to Composer_setHeaders. * gui/comp-editor-factory.c (edit_existing, edit_new): Pass the CalClient to event_editor_new/task_editor_new * gui/e-calendar-table.c (open_task): Likewise. * gui/e-tasks.c (e_tasks_new_task): Likewise. * gui/gnome-cal.c (gnome_calendar_edit_object, gnome_calendar_new_task): Likewise. svn path=/trunk/; revision=18253 --- calendar/gui/comp-editor-factory.c | 14 ++++++-------- calendar/gui/dialogs/event-editor.c | 31 +++++++++++++++++++++++-------- calendar/gui/dialogs/event-editor.h | 5 +++-- calendar/gui/dialogs/meeting-page.c | 20 +++++++++++++++----- calendar/gui/dialogs/meeting-page.h | 6 ++++-- calendar/gui/dialogs/task-editor.c | 32 ++++++++++++++++++++++++-------- calendar/gui/dialogs/task-editor.h | 5 +++-- calendar/gui/e-calendar-table.c | 3 +-- calendar/gui/e-tasks.c | 3 +-- calendar/gui/gnome-cal.c | 6 ++---- calendar/gui/itip-utils.c | 31 +++++++++++++++++++++++++++++-- 11 files changed, 111 insertions(+), 45 deletions(-) (limited to 'calendar/gui') diff --git a/calendar/gui/comp-editor-factory.c b/calendar/gui/comp-editor-factory.c index 8cba8baade..31746ae55b 100644 --- a/calendar/gui/comp-editor-factory.c +++ b/calendar/gui/comp-editor-factory.c @@ -272,11 +272,11 @@ edit_existing (OpenClient *oc, const char *uid) switch (vtype) { case CAL_COMPONENT_EVENT: - editor = COMP_EDITOR (event_editor_new ()); + editor = COMP_EDITOR (event_editor_new (oc->client)); break; case CAL_COMPONENT_TODO: - editor = COMP_EDITOR (task_editor_new ()); + editor = COMP_EDITOR (task_editor_new (oc->client)); break; default: @@ -285,8 +285,7 @@ edit_existing (OpenClient *oc, const char *uid) return; } - /* Set the client/object on the editor */ - comp_editor_set_cal_client (editor, oc->client); + /* Set the object on the editor */ comp_editor_edit_comp (editor, comp); comp_editor_focus (editor); @@ -360,15 +359,15 @@ edit_new (OpenClient *oc, const GNOME_Evolution_Calendar_CompEditorFactory_CompE switch (type) { case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_EVENT: case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_MEETING: - editor = COMP_EDITOR (event_editor_new ()); + editor = COMP_EDITOR (event_editor_new (oc->client)); comp = get_default_event (FALSE); break; case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_ALLDAY_EVENT: - editor = COMP_EDITOR (event_editor_new ()); + editor = COMP_EDITOR (event_editor_new (oc->client)); comp = get_default_event (TRUE); break; case GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_TODO: - editor = COMP_EDITOR (task_editor_new ()); + editor = COMP_EDITOR (task_editor_new (oc->client)); comp = get_default_task (); break; default: @@ -376,7 +375,6 @@ edit_new (OpenClient *oc, const GNOME_Evolution_Calendar_CompEditorFactory_CompE return; } - comp_editor_set_cal_client (editor, oc->client); comp_editor_edit_comp (editor, comp); if (type == GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_MEETING) event_editor_show_meeting (EVENT_EDITOR (editor)); diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c index 20b91475d4..4ee2556d97 100644 --- a/calendar/gui/dialogs/event-editor.c +++ b/calendar/gui/dialogs/event-editor.c @@ -188,6 +188,18 @@ event_editor_init (EventEditor *ee) priv = g_new0 (EventEditorPrivate, 1); ee->priv = priv; + priv->model = E_MEETING_MODEL (e_meeting_model_new ()); + priv->meeting_shown = TRUE; + priv->updating = FALSE; +} + +EventEditor * +event_editor_construct (EventEditor *ee, CalClient *client) +{ + EventEditorPrivate *priv; + + priv = ee->priv; + priv->event_page = event_page_new (); comp_editor_append_page (COMP_EDITOR (ee), COMP_EDITOR_PAGE (priv->event_page), @@ -203,25 +215,24 @@ event_editor_init (EventEditor *ee) COMP_EDITOR_PAGE (priv->recur_page), _("Recurrence")); - priv->model = E_MEETING_MODEL (e_meeting_model_new ()); - priv->sched_page = schedule_page_new (priv->model); comp_editor_append_page (COMP_EDITOR (ee), COMP_EDITOR_PAGE (priv->sched_page), _("Scheduling")); - priv->meet_page = meeting_page_new (priv->model); + priv->meet_page = meeting_page_new (priv->model, client); comp_editor_append_page (COMP_EDITOR (ee), COMP_EDITOR_PAGE (priv->meet_page), _("Meeting")); - comp_editor_merge_ui (COMP_EDITOR (ee), "evolution-event-editor.xml", verbs, pixmaps); + comp_editor_set_cal_client (COMP_EDITOR (ee), client); - priv->meeting_shown = TRUE; - priv->updating = FALSE; + comp_editor_merge_ui (COMP_EDITOR (ee), "evolution-event-editor.xml", verbs, pixmaps); init_widgets (ee); set_menu_sens (ee); + + return ee; } static void @@ -382,6 +393,7 @@ event_editor_destroy (GtkObject *object) /** * event_editor_new: + * @client: a CalClient * * Creates a new event editor dialog. * @@ -389,9 +401,12 @@ event_editor_destroy (GtkObject *object) * editor could not be created. **/ EventEditor * -event_editor_new (void) +event_editor_new (CalClient *client) { - return EVENT_EDITOR (gtk_type_new (TYPE_EVENT_EDITOR)); + EventEditor *ee; + + ee = EVENT_EDITOR (gtk_type_new (TYPE_EVENT_EDITOR)); + return event_editor_construct (ee, client); } static void diff --git a/calendar/gui/dialogs/event-editor.h b/calendar/gui/dialogs/event-editor.h index d27bb8e52d..1b6f72829a 100644 --- a/calendar/gui/dialogs/event-editor.h +++ b/calendar/gui/dialogs/event-editor.h @@ -52,8 +52,9 @@ struct _EventEditorClass { }; GtkType event_editor_get_type (void); -EventEditor *event_editor_construct (EventEditor *ee); -EventEditor *event_editor_new (void); +EventEditor *event_editor_construct (EventEditor *ee, + CalClient *client); +EventEditor *event_editor_new (CalClient *client); void event_editor_show_meeting (EventEditor *ee); diff --git a/calendar/gui/dialogs/meeting-page.c b/calendar/gui/dialogs/meeting-page.c index 011f1301af..44ff76eb08 100644 --- a/calendar/gui/dialogs/meeting-page.c +++ b/calendar/gui/dialogs/meeting-page.c @@ -733,11 +733,13 @@ table_canvas_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, gpointer dat * be created. **/ MeetingPage * -meeting_page_construct (MeetingPage *mpage, EMeetingModel *emm) +meeting_page_construct (MeetingPage *mpage, EMeetingModel *emm, + CalClient *client) { MeetingPagePrivate *priv; ETable *real_table; gchar *filename; + const char *backend_address; GList *l; priv = mpage->priv; @@ -757,6 +759,8 @@ meeting_page_construct (MeetingPage *mpage, EMeetingModel *emm) } /* Address information */ + backend_address = cal_client_get_email_address (client); + priv->addresses = itip_addresses_get (); for (l = priv->addresses; l != NULL; l = l->next) { ItipAddress *a = l->data; @@ -764,8 +768,14 @@ meeting_page_construct (MeetingPage *mpage, EMeetingModel *emm) s = e_utf8_to_gtk_string (GTK_COMBO (priv->organizer)->entry, a->full); priv->address_strings = g_list_append (priv->address_strings, s); - if (a->default_address) - priv->default_address = s; + + /* Note that the address specified by the backend gets + * precedence over the default mail address. + */ + if (backend_address && !strcmp (backend_address, a->address)) + priv->default_address = a->full; + else if (a->default_address && !priv->default_address) + priv->default_address = a->full; } /* The etable displaying attendees and their status */ @@ -803,12 +813,12 @@ meeting_page_construct (MeetingPage *mpage, EMeetingModel *emm) * not be created. **/ MeetingPage * -meeting_page_new (EMeetingModel *emm) +meeting_page_new (EMeetingModel *emm, CalClient *client) { MeetingPage *mpage; mpage = gtk_type_new (TYPE_MEETING_PAGE); - if (!meeting_page_construct (mpage, emm)) { + if (!meeting_page_construct (mpage, emm, client)) { gtk_object_unref (GTK_OBJECT (mpage)); return NULL; } diff --git a/calendar/gui/dialogs/meeting-page.h b/calendar/gui/dialogs/meeting-page.h index b7c8571b44..be55aecf98 100644 --- a/calendar/gui/dialogs/meeting-page.h +++ b/calendar/gui/dialogs/meeting-page.h @@ -53,8 +53,10 @@ typedef struct { GtkType meeting_page_get_type (void); MeetingPage *meeting_page_construct (MeetingPage *mpage, - EMeetingModel *emm); -MeetingPage *meeting_page_new (EMeetingModel *emm); + EMeetingModel *emm, + CalClient *client); +MeetingPage *meeting_page_new (EMeetingModel *emm, + CalClient *client); CalComponent *meeting_page_get_cancel_comp (MeetingPage *mpage); diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c index 6261b8deda..e3c55ffe29 100644 --- a/calendar/gui/dialogs/task-editor.c +++ b/calendar/gui/dialogs/task-editor.c @@ -176,6 +176,19 @@ task_editor_init (TaskEditor *te) priv = g_new0 (TaskEditorPrivate, 1); te->priv = priv; + priv->model = E_MEETING_MODEL (e_meeting_model_new ()); + priv->assignment_shown = TRUE; + priv->updating = FALSE; + +} + +TaskEditor * +task_editor_construct (TaskEditor *te, CalClient *client) +{ + TaskEditorPrivate *priv; + + priv = te->priv; + priv->task_page = task_page_new (); comp_editor_append_page (COMP_EDITOR (te), COMP_EDITOR_PAGE (priv->task_page), @@ -186,20 +199,19 @@ task_editor_init (TaskEditor *te) COMP_EDITOR_PAGE (priv->task_details_page), _("Details")); - priv->model = E_MEETING_MODEL (e_meeting_model_new ()); - - priv->meet_page = meeting_page_new (priv->model); + priv->meet_page = meeting_page_new (priv->model, client); comp_editor_append_page (COMP_EDITOR (te), COMP_EDITOR_PAGE (priv->meet_page), _("Assignment")); - comp_editor_merge_ui (COMP_EDITOR (te), "evolution-task-editor.xml", verbs, NULL); + comp_editor_set_cal_client (COMP_EDITOR (te), client); - priv->assignment_shown = TRUE; - priv->updating = FALSE; + comp_editor_merge_ui (COMP_EDITOR (te), "evolution-task-editor.xml", verbs, NULL); init_widgets (te); set_menu_sens (te); + + return te; } static void @@ -334,6 +346,7 @@ task_editor_destroy (GtkObject *object) /** * task_editor_new: + * @client: a CalClient * * Creates a new event editor dialog. * @@ -341,9 +354,12 @@ task_editor_destroy (GtkObject *object) * editor could not be created. **/ TaskEditor * -task_editor_new (void) +task_editor_new (CalClient *client) { - return TASK_EDITOR (gtk_type_new (TYPE_TASK_EDITOR)); + TaskEditor *te; + + te = TASK_EDITOR (gtk_type_new (TYPE_TASK_EDITOR)); + return task_editor_construct (te, client); } static void diff --git a/calendar/gui/dialogs/task-editor.h b/calendar/gui/dialogs/task-editor.h index e9888f446a..070546bee0 100644 --- a/calendar/gui/dialogs/task-editor.h +++ b/calendar/gui/dialogs/task-editor.h @@ -53,8 +53,9 @@ struct _TaskEditorClass { }; GtkType task_editor_get_type (void); -TaskEditor *task_editor_construct (TaskEditor *te); -TaskEditor *task_editor_new (void); +TaskEditor *task_editor_construct (TaskEditor *te, + CalClient *client); +TaskEditor *task_editor_new (CalClient *client); void task_editor_show_assignment(TaskEditor *te); diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index f775b68f1a..91786ea389 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -910,9 +910,8 @@ open_task (ECalendarTable *cal_table, CalComponent *comp, gboolean assign) tedit = e_comp_editor_registry_find (comp_editor_registry, uid); if (tedit == NULL) { - tedit = COMP_EDITOR (task_editor_new ()); + tedit = COMP_EDITOR (task_editor_new (calendar_model_get_cal_client (cal_table->model))); - comp_editor_set_cal_client (tedit, calendar_model_get_cal_client (cal_table->model)); comp_editor_edit_comp (tedit, comp); if (assign) task_editor_show_assignment (TASK_EDITOR (tedit)); diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c index 61c55e1598..d0097cc015 100644 --- a/calendar/gui/e-tasks.c +++ b/calendar/gui/e-tasks.c @@ -485,8 +485,7 @@ e_tasks_new_task (ETasks *tasks) priv = tasks->priv; - tedit = task_editor_new (); - comp_editor_set_cal_client (COMP_EDITOR (tedit), priv->client); + tedit = task_editor_new (priv->client); comp = cal_component_new (); cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 1d694e7eae..32f6cd15ed 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -2208,14 +2208,13 @@ gnome_calendar_edit_object (GnomeCalendar *gcal, CalComponent *comp, if (!ce) { EventEditor *ee; - ee = event_editor_new (); + ee = event_editor_new (priv->client); if (!ee) { g_message ("gnome_calendar_edit_object(): Could not create the event editor"); return; } ce = COMP_EDITOR (ee); - comp_editor_set_cal_client (ce, priv->client); comp_editor_edit_comp (ce, comp); if (meeting) event_editor_show_meeting (ee); @@ -2341,8 +2340,7 @@ gnome_calendar_new_task (GnomeCalendar *gcal) priv = gcal->priv; - tedit = task_editor_new (); - comp_editor_set_cal_client (COMP_EDITOR (tedit), priv->task_pad_client); + tedit = task_editor_new (priv->task_pad_client); comp = cal_component_new (); cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index 65634d9759..224d8b9d52 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -352,6 +352,28 @@ users_has_attendee (GList *users, const char *address) return FALSE; } +static CORBA_char * +comp_from (CalComponentItipMethod method, CalComponent *comp) +{ + CalComponentOrganizer organizer; + + switch (method) { + case CAL_COMPONENT_METHOD_REQUEST: + case CAL_COMPONENT_METHOD_CANCEL: + cal_component_get_organizer (comp, &organizer); + if (organizer.value == NULL) { + e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, + _("An organizer must be set.")); + return NULL; + } + + return CORBA_string_dup (itip_strip_mailto (organizer.value)); + + default: + return CORBA_string_dup (""); + } +} + static GNOME_Evolution_Composer_RecipientList * comp_to_list (CalComponentItipMethod method, CalComponent *comp, GList *users) { @@ -862,7 +884,7 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp, GNOME_Evolution_Composer_RecipientList *cc_list = NULL; GNOME_Evolution_Composer_RecipientList *bcc_list = NULL; CORBA_char *subject = NULL, *body = NULL, *content_type = NULL; - CORBA_char *filename = NULL, *description = NULL; + CORBA_char *from = NULL, *filename = NULL, *description = NULL; GNOME_Evolution_Composer_AttachmentData *attach_data = NULL; char *ical_string; CORBA_Environment ev; @@ -904,8 +926,11 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp, /* Subject information */ subject = comp_subject (method, comp); + /* From address */ + from = comp_from (method, comp); + /* Set recipients, subject */ - GNOME_Evolution_Composer_setHeaders (composer_server, to_list, cc_list, bcc_list, subject, &ev); + GNOME_Evolution_Composer_setHeaders (composer_server, from, to_list, cc_list, bcc_list, subject, &ev); if (BONOBO_EX (&ev)) { g_warning ("Unable to set composer headers while sending iTip message"); goto cleanup; @@ -982,6 +1007,8 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp, if (bcc_list != NULL) CORBA_free (bcc_list); + if (from != NULL) + CORBA_free (from); if (subject != NULL) CORBA_free (subject); if (body != NULL) -- cgit v1.2.3