diff options
author | JP Rosevear <jpr@ximian.com> | 2001-06-20 03:24:08 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2001-06-20 03:24:08 +0800 |
commit | ca603236ed6d7a43bc4587b70d6163ee1d95e310 (patch) | |
tree | 458dd3880e4c65f417758684936ef30a2f7dba7f /calendar/gui/itip-utils.c | |
parent | 4b11ecbffc519e8dfccdebaa26b021f131254d78 (diff) | |
download | gsoc2013-evolution-ca603236ed6d7a43bc4587b70d6163ee1d95e310.tar gsoc2013-evolution-ca603236ed6d7a43bc4587b70d6163ee1d95e310.tar.gz gsoc2013-evolution-ca603236ed6d7a43bc4587b70d6163ee1d95e310.tar.bz2 gsoc2013-evolution-ca603236ed6d7a43bc4587b70d6163ee1d95e310.tar.lz gsoc2013-evolution-ca603236ed6d7a43bc4587b70d6163ee1d95e310.tar.xz gsoc2013-evolution-ca603236ed6d7a43bc4587b70d6163ee1d95e310.tar.zst gsoc2013-evolution-ca603236ed6d7a43bc4587b70d6163ee1d95e310.zip |
itip/imip send dialog
2001-06-19 JP Rosevear <jpr@ximian.com>
* gui/dialogs/send-comp.c: itip/imip send dialog
* gui/dialogs/send-comp.h: new proto
* gui/dialogs/recurrence-page.c (recurrence_page_set_dates): only
use the weekday picker if visible
* gui/dialogs/meeting-page.c: just show the meeting list
* gui/dialogs/event-editor.c (event_editor_edit_comp): remove the
meeting page if no attendees
(schedule_meeting_cmd): schedule a meeting menu item
(refresh_meeting_cmd): refresh meeting request menu item
(cancel_meeting_cmd): ditto for cancel
(forward_cmd): send as attachment
* gui/dialogs/comp-editor.c (comp_editor_remove_page): remove page
from dialog
(comp_editor_show_page): show a given page
(comp_editor_get_current_comp): return a cal component
representing the current widget state
(comp_editor_save_comp): save the cal component
(comp_editor_delete_comp): delete the cal component
(comp_editor_send_comp): send the cal component
(comp_editor_merge_ui): merge xml in to the bonobo gui
(setup_widgets): use a bonobo window instead of a gtk window, add menus again
(save_as_cmd): save to file on disk - still broken
(save_close_cmd): close menu command
(save_close_cmd): save and close menu command
* gui/dialogs/comp-editor.h: new protos
* gui/dialogs/cancel-comp.c (cancel_component_dialog): itip/imip
cancellation dialog
* gui/dialogs/cancel-comp.h: new proto
* gui/dialogs/Makefile.am: build new files
* gui/dialogs/comp-editor-page.c
(comp_editor_page_notify_needs_send): emit needs_send signal
* gui/dialogs/comp-editor-page.h: new signal protos
* gui/itip-utils.c (itip_send_comp): new function to send cal
components
* gui/itip-utils.h: new proto
* gui/e-itip-control.c (pstream_load): trim using cal-component
wrapper stuff
(accept_button_clicked_cb): use itip_send_comp
(tentative_button_clicked_cb): ditto
(decline_button_clicked_cb): ditto
* gui/Makefile.am: compile select name idl stuff
* cal-util/cal-component.c (cal_component_get_organizer): get the organizer
(cal_component_set_organizer): set the organizer
(cal_component_get_recurid): get the recurrence id
(cal_component_set_recurid): set the recurrence id
(set_attendee_list): actually set the attendee list
(get_attendee_list): build the attendee list
* cal-util/cal-component.h: new protos
svn path=/trunk/; revision=10299
Diffstat (limited to 'calendar/gui/itip-utils.c')
-rw-r--r-- | calendar/gui/itip-utils.c | 228 |
1 files changed, 227 insertions, 1 deletions
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index 5bf442dec9..239a16ae00 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -4,12 +4,46 @@ * * Authors: * Jesse Pavel <jpavel@helixcode.com> + * JP Rosevear <jpr@ximian.com> * - * Copyright 2000, Helix Code, Inc. + * Copyright 2001, Ximian, Inc. */ +#include <bonobo/bonobo-object.h> +#include <bonobo/bonobo-object-client.h> +#include <libgnome/gnome-defs.h> +#include <libgnome/gnome-i18n.h> +#include <libgnomeui/gnome-dialog.h> +#include <libgnomeui/gnome-dialog-util.h> +#include <gtk/gtkwidget.h> +#include <ical.h> +#include <Evolution-Composer.h> #include "itip-utils.h" +#define GNOME_EVOLUTION_COMPOSER_OAFIID "OAFIID:GNOME_Evolution_Mail_Composer" + +static gchar *itip_methods[] = { + "PUBLISH", + "REQUEST", + "REPLY", + "ADD", + "CANCEL" + "RERESH" + "COUNTER" + "DECLINECOUNTER" +}; + +static icalproperty_method itip_methods_enum[] = { + ICAL_METHOD_PUBLISH, + ICAL_METHOD_REQUEST, + ICAL_METHOD_REPLY, + ICAL_METHOD_ADD, + ICAL_METHOD_CANCEL, + ICAL_METHOD_REFRESH, + ICAL_METHOD_COUNTER, + ICAL_METHOD_DECLINECOUNTER, +}; + gchar *partstat_values[] = { "Needs action", "Accepted", @@ -45,4 +79,196 @@ get_icalparam_by_type (icalproperty *prop, icalparameter_kind kind) return param; } +static void +error_dialog (gchar *str) +{ + GtkWidget *dlg; + + dlg = gnome_error_dialog (str); + gnome_dialog_run_and_close (GNOME_DIALOG (dlg)); +} + +void +itip_send_comp (CalComponentItipMethod method, CalComponent *comp) +{ + BonoboObjectClient *bonobo_server; + GNOME_Evolution_Composer composer_server; + CORBA_Environment ev; + GSList *attendees, *l; + GNOME_Evolution_Composer_RecipientList *to_list, *cc_list, *bcc_list; + GNOME_Evolution_Composer_Recipient *recipient; + CORBA_char *subject; + gint cntr; + gint len; + CalComponentText caltext; + CalComponentOrganizer organizer; + CORBA_char *content_type, *filename, *description, *attach_data; + CORBA_boolean show_inline; + CORBA_char tempstr[200]; + + CORBA_exception_init (&ev); + + /* First, I obtain an object reference that represents the Composer. */ + bonobo_server = bonobo_object_activate (GNOME_EVOLUTION_COMPOSER_OAFIID, 0); + g_return_if_fail (bonobo_server != NULL); + + composer_server = BONOBO_OBJREF (bonobo_server); + + switch (method) { + case CAL_COMPONENT_METHOD_PUBLISH: + case CAL_COMPONENT_METHOD_REQUEST: + case CAL_COMPONENT_METHOD_CANCEL: + cal_component_get_attendee_list (comp, &attendees); + len = g_slist_length (attendees); + + to_list = GNOME_Evolution_Composer_RecipientList__alloc (); + to_list->_maximum = len; + to_list->_length = len; + to_list->_buffer = CORBA_sequence_GNOME_Evolution_Composer_Recipient_allocbuf (len); + + for (cntr = 0, l = attendees; cntr < len; cntr++, l = l->next) { + CalComponentAttendee *att = l->data; + + recipient = &(to_list->_buffer[cntr]); + if (att->cn) + recipient->name = CORBA_string_dup (att->cn); + else + recipient->name = CORBA_string_dup (""); + recipient->address = CORBA_string_dup (att->value); + } + break; + + case CAL_COMPONENT_METHOD_REPLY: + case CAL_COMPONENT_METHOD_ADD: + case CAL_COMPONENT_METHOD_REFRESH: + case CAL_COMPONENT_METHOD_COUNTER: + case CAL_COMPONENT_METHOD_DECLINECOUNTER: + cal_component_get_organizer (comp, &organizer); + if (organizer.value == NULL) { + error_dialog (_("An organizer must be set.")); + return; + } + + len = 1; + + to_list = GNOME_Evolution_Composer_RecipientList__alloc (); + to_list->_maximum = len; + to_list->_length = len; + to_list->_buffer = CORBA_sequence_GNOME_Evolution_Composer_Recipient_allocbuf (len); + recipient = &(to_list->_buffer[0]); + + if (organizer.cn != NULL) + recipient->name = CORBA_string_dup (organizer.cn); + else + recipient->name = CORBA_string_dup (""); + recipient->address = CORBA_string_dup (organizer.value); + break; + } + + cc_list = GNOME_Evolution_Composer_RecipientList__alloc (); + cc_list->_maximum = cc_list->_length = 0; + bcc_list = GNOME_Evolution_Composer_RecipientList__alloc (); + bcc_list->_maximum = bcc_list->_length = 0; + + cal_component_get_summary (comp, &caltext); + subject = CORBA_string_dup (caltext.value); + + GNOME_Evolution_Composer_setHeaders (composer_server, to_list, cc_list, bcc_list, subject, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("Unable to set composer headers while sending iTip message"); + CORBA_exception_free (&ev); + return; + } + + sprintf (tempstr, "text/calendar;METHOD=%s", itip_methods[method]); + content_type = CORBA_string_dup (tempstr); + filename = CORBA_string_dup (""); + sprintf (tempstr, "Calendar attachment"); + description = CORBA_string_dup (tempstr); + show_inline = FALSE; + + /* I need to create an encapsulating iCalendar component, and stuff our vEvent + into it. */ + { + icalcomponent *icomp, *clone; + icalproperty *prop; + icalvalue *value; + gchar *ical_string; + + icomp = icalcomponent_new (ICAL_VCALENDAR_COMPONENT); + + prop = icalproperty_new (ICAL_PRODID_PROPERTY); + value = icalvalue_new_text ("-//Ximian/Evolution//EN"); + icalproperty_set_value (prop, value); + icalcomponent_add_property (icomp, prop); + + prop = icalproperty_new (ICAL_VERSION_PROPERTY); + value = icalvalue_new_text ("2.0"); + icalproperty_set_value (prop, value); + icalcomponent_add_property (icomp, prop); + + prop = icalproperty_new (ICAL_METHOD_PROPERTY); + value = icalvalue_new_method (itip_methods_enum[method]); + icalproperty_set_value (prop, value); + icalcomponent_add_property (icomp, prop); + + clone = icalcomponent_new_clone (cal_component_get_icalcomponent (comp)); + icalcomponent_add_component (icomp, clone); + + ical_string = icalcomponent_as_ical_string (icomp); + attach_data = CORBA_string_dup (ical_string); + + icalcomponent_free (icomp); + } + + GNOME_Evolution_Composer_attachData (composer_server, + content_type, filename, description, + show_inline, attach_data, + &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("Unable to attach data to the composer while sending iTip message"); + CORBA_exception_free (&ev); + return; + } + + GNOME_Evolution_Composer_show (composer_server, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("Unable to show the composer while sending iTip message"); + CORBA_exception_free (&ev); + return; + } + + CORBA_exception_free (&ev); + + /* Let's free shit up. */ + + /* Beware--depending on whether CORBA_free is recursive, which I + think is is, we might have memory leaks, in which case the code + below is necessary. */ +#if 0 + for (cntr = 0; cntr < priv->numentries; cntr++) { + recipient = &(to_list->_buffer[cntr]); + CORBA_free (recipient->name); + CORBA_free (recipient->address); + recipient->name = recipient->address = NULL; + } +#endif + + if (CORBA_sequence_get_release (to_list) != FALSE) + CORBA_free (to_list->_buffer); + + CORBA_free (to_list); + CORBA_free (cc_list); + CORBA_free (bcc_list); + + CORBA_free (subject); + CORBA_free (content_type); + CORBA_free (filename); + CORBA_free (description); + CORBA_free (attach_data); + + /* bonobo_object_unref (BONOBO_OBJECT (bonobo_server)); */ +} |