aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/itip-utils.c
diff options
context:
space:
mode:
authorJP Rosevear <jpr@ximian.com>2002-09-26 01:45:50 +0800
committerJP Rosevear <jpr@src.gnome.org>2002-09-26 01:45:50 +0800
commit541c29f0d9914395cf5a2b840edc5e88c5f809bd (patch)
treed8055d8bc4ee0927b2a08452340f12ac3055a19b /calendar/gui/itip-utils.c
parenta6f94541f4c39e1ab7b3bd2bbf0b0c97aa000a36 (diff)
downloadgsoc2013-evolution-541c29f0d9914395cf5a2b840edc5e88c5f809bd.tar
gsoc2013-evolution-541c29f0d9914395cf5a2b840edc5e88c5f809bd.tar.gz
gsoc2013-evolution-541c29f0d9914395cf5a2b840edc5e88c5f809bd.tar.bz2
gsoc2013-evolution-541c29f0d9914395cf5a2b840edc5e88c5f809bd.tar.lz
gsoc2013-evolution-541c29f0d9914395cf5a2b840edc5e88c5f809bd.tar.xz
gsoc2013-evolution-541c29f0d9914395cf5a2b840edc5e88c5f809bd.tar.zst
gsoc2013-evolution-541c29f0d9914395cf5a2b840edc5e88c5f809bd.zip
if the item being sent is not a meeting, send it as a mixed item with a
2002-09-25 JP Rosevear <jpr@ximian.com> * gui/itip-utils.c (itip_send_comp): if the item being sent is not a meeting, send it as a mixed item with a description and the calendar text in an attachment Fixes #30638 svn path=/trunk/; revision=18215
Diffstat (limited to 'calendar/gui/itip-utils.c')
-rw-r--r--calendar/gui/itip-utils.c104
1 files changed, 97 insertions, 7 deletions
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c
index c268589e03..65634d9759 100644
--- a/calendar/gui/itip-utils.c
+++ b/calendar/gui/itip-utils.c
@@ -254,6 +254,21 @@ itip_strip_mailto (const gchar *address)
return address;
}
+static char *
+get_label (struct icaltimetype *tt)
+{
+ char buffer[1000];
+ struct tm tmp_tm;
+
+ tmp_tm = icaltimetype_to_tm (tt);
+ e_time_format_date_and_time (&tmp_tm,
+ calendar_config_get_24_hour_format (),
+ FALSE, FALSE,
+ buffer, 1000);
+
+ return g_strdup (buffer);
+}
+
typedef struct {
GHashTable *tzids;
icalcomponent *icomp;
@@ -521,6 +536,57 @@ comp_content_type (CalComponent *comp, CalComponentItipMethod method)
}
+static CORBA_char *
+comp_filename (CalComponent *comp)
+{
+ switch (cal_component_get_vtype (comp)) {
+ case CAL_COMPONENT_FREEBUSY:
+ return CORBA_string_dup ("freebusy.ifb");
+ default:
+ return CORBA_string_dup ("calendar.ics");
+ }
+}
+
+static CORBA_char *
+comp_description (CalComponent *comp)
+{
+ CORBA_char *description;
+ CalComponentDateTime dt;
+ char *start = NULL, *end = NULL;
+
+ switch (cal_component_get_vtype (comp)) {
+ case CAL_COMPONENT_EVENT:
+ return CORBA_string_dup (U_("Event information"));
+ case CAL_COMPONENT_TODO:
+ return CORBA_string_dup (U_("Task information"));
+ case CAL_COMPONENT_JOURNAL:
+ return CORBA_string_dup (U_("Journal information"));
+ case CAL_COMPONENT_FREEBUSY:
+ cal_component_get_dtstart (comp, &dt);
+ if (dt.value) {
+ start = get_label (dt.value);
+ cal_component_get_dtend (comp, &dt);
+ if (dt.value)
+ end = get_label (dt.value);
+ }
+ if (start != NULL && end != NULL) {
+ char *tmp, *tmp_utf;
+ tmp = g_strdup_printf (_("Free/Busy information (%s to %s)"), start, end);
+ tmp_utf = e_utf8_from_locale_string (tmp);
+ description = CORBA_string_dup (tmp_utf);
+ g_free (tmp_utf);
+ g_free (tmp);
+ } else {
+ description = CORBA_string_dup (U_("Free/Busy information"));
+ }
+ g_free (start);
+ g_free (end);
+ return description;
+ default:
+ return CORBA_string_dup (U_("iCalendar information"));
+ }
+}
+
static gboolean
comp_server_send (CalComponentItipMethod method, CalComponent *comp, CalClient *client,
icalcomponent *zones, GList **users)
@@ -845,21 +911,45 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp,
goto cleanup;
}
+
/* Content type */
content_type = comp_content_type (comp, method);
top_level = comp_toplevel_with_zones (method, comp, client, zones);
ical_string = icalcomponent_as_ical_string (top_level);
- attach_data = GNOME_Evolution_Composer_AttachmentData__alloc ();
- attach_data->_length = strlen (ical_string) + 1;
- attach_data->_maximum = attach_data->_length;
- attach_data->_buffer = CORBA_sequence_CORBA_char_allocbuf (attach_data->_length);
- strcpy (attach_data->_buffer, ical_string);
- GNOME_Evolution_Composer_setBody (composer_server, ical_string, content_type, &ev);
+ if (cal_component_get_vtype (comp) == CAL_COMPONENT_EVENT) {
+ GNOME_Evolution_Composer_setBody (composer_server, ical_string, content_type, &ev);
+ } else {
+ GNOME_Evolution_Composer_setMultipartType (composer_server, GNOME_Evolution_Composer_MIXED, &ev);
+ if (BONOBO_EX (&ev)) {
+ g_warning ("Unable to set multipart type while sending iTip message");
+ goto cleanup;
+ }
+
+ filename = comp_filename (comp);
+ description = comp_description (comp);
+ GNOME_Evolution_Composer_setBody (composer_server, description, "text/plain", &ev);
+ if (BONOBO_EX (&ev)) {
+ g_warning ("Unable to set body text while sending iTip message");
+ goto cleanup;
+ }
+
+ attach_data = GNOME_Evolution_Composer_AttachmentData__alloc ();
+ attach_data->_length = strlen (ical_string) + 1;
+ attach_data->_maximum = attach_data->_length;
+ attach_data->_buffer = CORBA_sequence_CORBA_char_allocbuf (attach_data->_length);
+ strcpy (attach_data->_buffer, ical_string);
+
+ GNOME_Evolution_Composer_attachData (composer_server,
+ content_type, filename, description,
+ TRUE, attach_data,
+ &ev);
+ }
+
if (BONOBO_EX (&ev)) {
- g_warning ("Unable to attach data to the composer while sending iTip message");
+ g_warning ("Unable to place iTip message in composer");
goto cleanup;
}