aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog41
-rw-r--r--calendar/cal-util/cal-component.c51
-rw-r--r--calendar/cal-util/cal-component.h3
-rw-r--r--calendar/gui/dialogs/meeting-page.c15
-rw-r--r--calendar/gui/dialogs/meeting-page.h9
-rw-r--r--calendar/gui/e-itip-control.c21
-rw-r--r--calendar/gui/itip-utils.c409
-rw-r--r--calendar/gui/itip-utils.h2
-rw-r--r--calendar/pcs/query.c17
9 files changed, 467 insertions, 101 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 378e73b4e7..e0f8951ede 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,44 @@
+2001-10-09 JP Rosevear <jpr@ximian.com>
+
+ * gui/itip-utils.c (get_address): util function to get address
+ (itip_addresses_get_default): get only the default address
+ (itip_address_free): free single address
+ (itip_addresses_free): use above
+ (comp_limit_attendees): limit the number of attendees to one, the
+ user
+ (comp_sentby): set the sentby parameter if the user is not the
+ organizer
+ (comp_minimal): remove extraneous info for send (for refresh and
+ declinecounter)
+ (comp_compliant): remove all alarms, do various things to make the
+ components comply with itip spec based on method
+ (itip_send_comp): use comp_compliant method
+
+ * gui/itip-utils.h: new protos
+
+ * gui/e-itip-control.c: rescan the component when necessary
+ (get_next): don't get stuck in infinite loop if there are no
+ viewable components
+ (e_itip_control_set_data): if there are no viewable components,
+ spit an error message
+
+ * gui/dialogs/meeting-page.h: tidy
+
+ * gui/dialogs/meeting-page.c (meeting_page_fill_widgets): use
+ organizer's cn if possible
+ (other_clicked_cb): no longer doing the sent by stuff directly,
+ hide more widgets
+
+ * pcs/query.c: use bonobo exception stuff
+
+ * cal-util/cal-component.c (cal_component_rescan): have the comp
+ rescan its libical component (for when you change things directly)
+ (free_icalcomponent): take a param on whether to free the
+ component or just clean up the mappings
+ (cal_component_has_attendees): util function
+
+ * cal-util/cal-component.h: new protos
+
2001-10-09 Rodrigo Moya <rodrigo@ximian.com>
* pcs/cal-factory.c (lookup_backend, add_backend): deal correctly with
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c
index b4784c6124..0d58d41017 100644
--- a/calendar/cal-util/cal-component.c
+++ b/calendar/cal-util/cal-component.c
@@ -262,7 +262,7 @@ free_alarm_cb (gpointer key, gpointer value, gpointer data)
* does, it means we don't own it and we shouldn't free it.
*/
static void
-free_icalcomponent (CalComponent *comp)
+free_icalcomponent (CalComponent *comp, gboolean free)
{
CalComponentPrivate *priv;
@@ -273,11 +273,11 @@ free_icalcomponent (CalComponent *comp)
/* Free the icalcomponent */
- if (icalcomponent_get_parent (priv->icalcomp) == NULL)
+ if (free && icalcomponent_get_parent (priv->icalcomp) == NULL) {
icalcomponent_free (priv->icalcomp);
-
- priv->icalcomp = NULL;
-
+ priv->icalcomp = NULL;
+ }
+
/* Free the mappings */
priv->uid = NULL;
@@ -350,7 +350,7 @@ cal_component_destroy (GtkObject *object)
comp = CAL_COMPONENT (object);
priv = comp->priv;
- free_icalcomponent (comp);
+ free_icalcomponent (comp, TRUE);
g_hash_table_destroy (priv->alarm_uid_hash);
priv->alarm_uid_hash = NULL;
@@ -919,7 +919,7 @@ cal_component_set_new_vtype (CalComponent *comp, CalComponentVType type)
priv = comp->priv;
- free_icalcomponent (comp);
+ free_icalcomponent (comp, TRUE);
if (type == CAL_COMPONENT_NO_TYPE)
return;
@@ -997,7 +997,7 @@ cal_component_set_icalcomponent (CalComponent *comp, icalcomponent *icalcomp)
if (priv->icalcomp == icalcomp)
return TRUE;
- free_icalcomponent (comp);
+ free_icalcomponent (comp, TRUE);
if (!icalcomp) {
priv->icalcomp = NULL;
@@ -1045,6 +1045,25 @@ cal_component_get_icalcomponent (CalComponent *comp)
return priv->icalcomp;
}
+void
+cal_component_rescan (CalComponent *comp)
+{
+ CalComponentPrivate *priv;
+
+ g_return_if_fail (comp != NULL);
+ g_return_if_fail (IS_CAL_COMPONENT (comp));
+
+ priv = comp->priv;
+
+ /* Clear everything out */
+ free_icalcomponent (comp, FALSE);
+ g_hash_table_destroy (priv->alarm_uid_hash);
+ priv->alarm_uid_hash = NULL;
+
+ scan_icalcomponent (comp);
+ ensure_mandatory_properties (comp);
+}
+
/**
* cal_component_get_vtype:
* @comp: A calendar component object.
@@ -3749,6 +3768,22 @@ cal_component_set_attendee_list (CalComponent *comp, GSList *attendee_list)
set_attendee_list (comp, &priv->attendee_list, attendee_list);
}
+gboolean
+cal_component_has_attendees (CalComponent *comp)
+{
+ CalComponentPrivate *priv;
+
+ g_return_val_if_fail (comp != NULL, FALSE);
+ g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE);
+
+ priv = comp->priv;
+
+ if (g_slist_length (priv->attendee_list) > 0)
+ return TRUE;
+
+ return FALSE;
+}
+
diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h
index 801cdc51f0..b8bd010b63 100644
--- a/calendar/cal-util/cal-component.h
+++ b/calendar/cal-util/cal-component.h
@@ -206,6 +206,7 @@ void cal_component_set_new_vtype (CalComponent *comp, CalComponentVType type);
gboolean cal_component_set_icalcomponent (CalComponent *comp, icalcomponent *icalcomp);
icalcomponent *cal_component_get_icalcomponent (CalComponent *comp);
+void cal_component_rescan (CalComponent *comp);
CalComponentVType cal_component_get_vtype (CalComponent *comp);
@@ -270,6 +271,7 @@ void cal_component_set_last_modified (CalComponent *comp, struct icaltimetype *t
void cal_component_get_organizer (CalComponent *comp, CalComponentOrganizer *organizer);
void cal_component_set_organizer (CalComponent *comp, CalComponentOrganizer *organizer);
+gboolean cal_component_has_organizer (CalComponent *comp);
void cal_component_get_percent (CalComponent *comp, int **percent);
void cal_component_set_percent (CalComponent *comp, int *percent);
@@ -308,6 +310,7 @@ void cal_component_set_url (CalComponent *comp, const char *url);
void cal_component_get_attendee_list (CalComponent *comp, GSList **attendee_list);
void cal_component_set_attendee_list (CalComponent *comp, GSList *attendee_list);
+gboolean cal_component_has_attendees (CalComponent *comp);
gboolean cal_component_event_dates_match (CalComponent *comp1, CalComponent *comp2);
diff --git a/calendar/gui/dialogs/meeting-page.c b/calendar/gui/dialogs/meeting-page.c
index 3b20831093..22c8f6e05a 100644
--- a/calendar/gui/dialogs/meeting-page.c
+++ b/calendar/gui/dialogs/meeting-page.c
@@ -382,15 +382,21 @@ meeting_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
if (organizer.value != NULL) {
const gchar *strip = itip_strip_mailto (organizer.value);
- gchar *s = e_utf8_to_gtk_string (priv->existing_organizer, strip);
+ gchar *s, *string;
gtk_widget_hide (priv->organizer_table);
gtk_widget_show (priv->existing_organizer_table);
gtk_widget_hide (priv->invite);
+ if (organizer.cn != NULL)
+ string = g_strdup_printf ("%s <%s>", organizer.cn, strip);
+ else
+ string = g_strdup (strip);
+ s = e_utf8_to_gtk_string (priv->existing_organizer, string);
gtk_label_set_text (GTK_LABEL (priv->existing_organizer), s);
g_free (s);
-
+ g_free (string);
+
priv->existing = TRUE;
} else {
gtk_widget_hide (priv->other_organizer_lbl);
@@ -655,11 +661,12 @@ other_clicked_cb (GtkWidget *widget, gpointer data)
mpage = MEETING_PAGE (data);
priv = mpage->priv;
+ gtk_widget_hide (priv->organizer_lbl);
+ gtk_widget_hide (priv->organizer);
+ gtk_widget_hide (priv->other_organizer_btn);
gtk_widget_show (priv->other_organizer_lbl);
gtk_widget_show (priv->other_organizer);
- gtk_label_set_text (GTK_LABEL (priv->organizer_lbl), _("Sent By:"));
-
priv->other = TRUE;
}
diff --git a/calendar/gui/dialogs/meeting-page.h b/calendar/gui/dialogs/meeting-page.h
index 206ee90bb8..b2503f7018 100644
--- a/calendar/gui/dialogs/meeting-page.h
+++ b/calendar/gui/dialogs/meeting-page.h
@@ -52,10 +52,11 @@ typedef struct {
} MeetingPageClass;
-GtkType meeting_page_get_type (void);
-MeetingPage *meeting_page_construct (MeetingPage *mpage, EMeetingModel *emm);
-MeetingPage *meeting_page_new (EMeetingModel *emm);
-CalComponent *meeting_page_get_cancel_comp (MeetingPage *mpage);
+GtkType meeting_page_get_type (void);
+MeetingPage *meeting_page_construct (MeetingPage *mpage,
+ EMeetingModel *emm);
+MeetingPage *meeting_page_new (EMeetingModel *emm);
+CalComponent *meeting_page_get_cancel_comp (MeetingPage *mpage);
diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c
index 20e17d7eac..1f26c5d765 100644
--- a/calendar/gui/e-itip-control.c
+++ b/calendar/gui/e-itip-control.c
@@ -857,15 +857,16 @@ static icalcomponent *
get_next (icalcompiter *iter)
{
icalcomponent *ret = NULL;
- icalcomponent_kind kind = ICAL_NO_COMPONENT;
+ icalcomponent_kind kind;
- while (kind != ICAL_VEVENT_COMPONENT
- && kind != ICAL_VTODO_COMPONENT
- && kind != ICAL_VFREEBUSY_COMPONENT) {
+ do {
icalcompiter_next (iter);
ret = icalcompiter_deref (iter);
kind = icalcomponent_isa (ret);
- }
+ } while (ret != NULL
+ && kind != ICAL_VEVENT_COMPONENT
+ && kind != ICAL_VTODO_COMPONENT
+ && kind != ICAL_VFREEBUSY_COMPONENT);
return ret;
}
@@ -990,6 +991,11 @@ e_itip_control_set_data (EItipControl *itip, const gchar *text)
&& kind != ICAL_VFREEBUSY_COMPONENT)
priv->ical_comp = get_next (&priv->iter);
+ if (priv->ical_comp == NULL) {
+ write_error_html (itip, _("The attachment has no viewable calendar items"));
+ return;
+ }
+
priv->total = icalcomponent_count_components (priv->main_comp, ICAL_VEVENT_COMPONENT);
priv->total += icalcomponent_count_components (priv->main_comp, ICAL_VTODO_COMPONENT);
priv->total += icalcomponent_count_components (priv->main_comp, ICAL_VFREEBUSY_COMPONENT);
@@ -1130,6 +1136,7 @@ update_attendee_status (EItipControl *itip)
change_status (cal_component_get_icalcomponent (comp),
itip_strip_mailto (a->value),
partstat);
+ cal_component_rescan (comp);
} else {
dialog = gnome_warning_dialog (_("Attendee status could "
"not be updated because "
@@ -1334,14 +1341,17 @@ ok_clicked_cb (GtkHTML *html, const gchar *method, const gchar *url, const gchar
break;
case 'A':
change_status (priv->ical_comp, priv->my_address, ICAL_PARTSTAT_ACCEPTED);
+ cal_component_rescan (priv->comp);
update_item (itip);
break;
case 'T':
change_status (priv->ical_comp, priv->my_address, ICAL_PARTSTAT_TENTATIVE);
+ cal_component_rescan (priv->comp);
update_item (itip);
break;
case 'D':
change_status (priv->ical_comp, priv->my_address, ICAL_PARTSTAT_DECLINED);
+ cal_component_rescan (priv->comp);
update_item (itip);
break;
case 'F':
@@ -1399,6 +1409,7 @@ ok_clicked_cb (GtkHTML *html, const gchar *method, const gchar *url, const gchar
icalproperty_free (prop);
}
}
+ cal_component_rescan (comp);
itip_send_comp (CAL_COMPONENT_METHOD_REPLY, comp);
} else {
GtkWidget *dialog;
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c
index dcef42307e..9180fbc400 100644
--- a/calendar/gui/itip-utils.c
+++ b/calendar/gui/itip-utils.c
@@ -78,10 +78,34 @@ error_dialog (gchar *str)
gnome_dialog_run_and_close (GNOME_DIALOG (dlg));
}
+static Bonobo_ConfigDatabase db = NULL;
+
+static ItipAddress *
+get_address (long num)
+{
+ ItipAddress *a;
+ gchar *path;
+
+ a = g_new0 (ItipAddress, 1);
+
+ /* get the identity info */
+ path = g_strdup_printf ("/Mail/Accounts/identity_name_%ld", num);
+ a->name = bonobo_config_get_string (db, path, NULL);
+ g_free (path);
+
+ path = g_strdup_printf ("/Mail/Accounts/identity_address_%ld", num);
+ a->address = bonobo_config_get_string (db, path, NULL);
+ g_free (path);
+
+ a->full = g_strdup_printf ("%s <%s>", a->name, a->address);
+
+ return a;
+}
+
GList *
itip_addresses_get (void)
{
- static Bonobo_ConfigDatabase db = NULL;
+
CORBA_Environment ev;
GList *addresses = NULL;
glong len, def, i;
@@ -106,29 +130,55 @@ itip_addresses_get (void)
for (i = 0; i < len; i++) {
ItipAddress *a;
- gchar *path;
-
- a = g_new0 (ItipAddress, 1);
-
- /* get the identity info */
- path = g_strdup_printf ("/Mail/Accounts/identity_name_%ld", i);
- a->name = bonobo_config_get_string (db, path, NULL);
- g_free (path);
-
- path = g_strdup_printf ("/Mail/Accounts/identity_address_%ld", i);
- a->address = bonobo_config_get_string (db, path, NULL);
- g_free (path);
+ a = get_address (i);
if (i == def)
a->default_address = TRUE;
- a->full = g_strdup_printf ("%s <%s>", a->name, a->address);
addresses = g_list_append (addresses, a);
}
return addresses;
}
+ItipAddress *
+itip_addresses_get_default (void)
+{
+ CORBA_Environment ev;
+ ItipAddress *a;
+ glong def;
+
+ if (db == NULL) {
+ CORBA_exception_init (&ev);
+
+ db = bonobo_get_object ("wombat:",
+ "Bonobo/ConfigDatabase",
+ &ev);
+
+ if (BONOBO_EX (&ev) || db == CORBA_OBJECT_NIL) {
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+
+ CORBA_exception_free (&ev);
+ }
+
+ def = bonobo_config_get_long_with_default (db, "/Mail/Accounts/default_account", 0, NULL);
+ a = get_address (def);
+ a->default_address = TRUE;
+
+ return a;
+}
+
+void
+itip_address_free (ItipAddress *address)
+{
+ g_free (address->name);
+ g_free (address->address);
+ g_free (address->full);
+ g_free (address);
+}
+
void
itip_addresses_free (GList *addresses)
{
@@ -136,11 +186,7 @@ itip_addresses_free (GList *addresses)
for (l = addresses; l != NULL; l = l->next) {
ItipAddress *a = l->data;
-
- g_free (a->name);
- g_free (a->address);
- g_free (a->full);
- g_free (a);
+ itip_address_free (a);
}
g_list_free (addresses);
}
@@ -189,33 +235,6 @@ typedef struct {
icalcomponent *icomp;
} ItipUtilTZData;
-static void
-foreach_tzid_callback (icalparameter *param, gpointer data)
-{
- ItipUtilTZData *tz_data = data;
- const char *tzid;
- icaltimezone *zone;
- icalcomponent *vtimezone_comp;
-
- /* Get the TZID string from the parameter. */
- tzid = icalparameter_get_tzid (param);
- if (!tzid || g_hash_table_lookup (tz_data->tzids, tzid))
- return;
-
- /* Check if it is a builtin timezone. If it isn't, return. */
- zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
- if (!zone)
- return;
-
- /* Convert it to a string and add it to the hash. */
- vtimezone_comp = icaltimezone_get_component (zone);
- if (!vtimezone_comp)
- return;
-
- icalcomponent_add_component (tz_data->icomp, icalcomponent_new_clone (vtimezone_comp));
- g_hash_table_insert (tz_data->tzids, (char *)tzid, (char *)tzid);
-}
-
static GNOME_Evolution_Composer_RecipientList *
comp_to_list (CalComponentItipMethod method, CalComponent *comp)
{
@@ -230,6 +249,11 @@ comp_to_list (CalComponentItipMethod method, CalComponent *comp)
case CAL_COMPONENT_METHOD_CANCEL:
cal_component_get_attendee_list (comp, &attendees);
len = g_slist_length (attendees);
+ if (len <= 0) {
+ error_dialog (_("Atleast one attendee is necessary"));
+ cal_component_free_attendee_list (attendees);
+ return NULL;
+ }
to_list = GNOME_Evolution_Composer_RecipientList__alloc ();
to_list->_maximum = len;
@@ -246,6 +270,7 @@ comp_to_list (CalComponentItipMethod method, CalComponent *comp)
recipient->name = CORBA_string_dup ("");
recipient->address = CORBA_string_dup (itip_strip_mailto (att->value));
}
+ cal_component_free_attendee_list (attendees);
break;
case CAL_COMPONENT_METHOD_REPLY:
@@ -288,7 +313,6 @@ static CORBA_char *
comp_subject (CalComponent *comp)
{
CalComponentText caltext;
-
cal_component_get_summary (comp, &caltext);
if (caltext.value != NULL)
return CORBA_string_dup (caltext.value);
@@ -365,61 +389,295 @@ comp_description (CalComponent *comp)
}
}
+static void
+foreach_tzid_callback (icalparameter *param, gpointer data)
+{
+ ItipUtilTZData *tz_data = data;
+ const char *tzid;
+ icaltimezone *zone;
+ icalcomponent *vtimezone_comp;
+
+ /* Get the TZID string from the parameter. */
+ tzid = icalparameter_get_tzid (param);
+ if (!tzid || g_hash_table_lookup (tz_data->tzids, tzid))
+ return;
+
+ /* Check if it is a builtin timezone. If it isn't, return. */
+ zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+ if (!zone)
+ return;
+
+ /* Convert it to a string and add it to the hash. */
+ vtimezone_comp = icaltimezone_get_component (zone);
+ if (!vtimezone_comp)
+ return;
+
+ icalcomponent_add_component (tz_data->icomp, icalcomponent_new_clone (vtimezone_comp));
+ g_hash_table_insert (tz_data->tzids, (char *)tzid, (char *)tzid);
+}
+
static char *
comp_string (CalComponentItipMethod method, CalComponent *comp)
{
- CalComponent *clone;
- icalcomponent *icomp, *iclone;
+ icalcomponent *top_level, *icomp;
icalproperty *prop;
icalvalue *value;
gchar *ical_string;
ItipUtilTZData tz_data;
- icomp = cal_util_new_top_level ();
+ top_level = cal_util_new_top_level ();
prop = icalproperty_new (ICAL_METHOD_PROPERTY);
value = icalvalue_new_method (itip_methods_enum[method]);
icalproperty_set_value (prop, value);
- icalcomponent_add_property (icomp, prop);
+ icalcomponent_add_property (top_level, prop);
+
+ icomp = cal_component_get_icalcomponent (comp);
+
+ /* Add the timezones */
+ tz_data.tzids = g_hash_table_new (g_str_hash, g_str_equal);
+ tz_data.icomp = top_level;
+ icalcomponent_foreach_tzid (icomp, foreach_tzid_callback, &tz_data);
+ g_hash_table_destroy (tz_data.tzids);
+
+ icalcomponent_add_component (top_level, icomp);
+ ical_string = icalcomponent_as_ical_string (top_level);
+ icalcomponent_remove_component (top_level, icomp);
+
+ icalcomponent_free (top_level);
+
+ return ical_string;
+}
+
+static gboolean
+comp_limit_attendees (CalComponent *comp)
+{
+ icalcomponent *icomp;
+ GList *addresses;
+ icalproperty *prop;
+ gboolean found = FALSE, match = FALSE;
+
+ icomp = cal_component_get_icalcomponent (comp);
+ addresses = itip_addresses_get ();
+
+ for (prop = icalcomponent_get_first_property (icomp, ICAL_ATTENDEE_PROPERTY);
+ prop != NULL;
+ prop = icalcomponent_get_next_property (icomp, ICAL_ATTENDEE_PROPERTY))
+ {
+ icalvalue *value;
+ const char *attendee, *text;
+ GList *l;
+
+ /* If we've already found something, just erase the rest */
+ if (found) {
+ icalcomponent_remove_property (icomp, prop);
+ icalproperty_free (prop);
+ continue;
+ }
+
+ value = icalproperty_get_value (prop);
+ if (!value)
+ continue;
+
+ attendee = icalvalue_get_string (value);
+
+ text = itip_strip_mailto (attendee);
+ for (l = addresses; l != NULL; l = l->next) {
+ ItipAddress *a = l->data;
+
+ if (strstr (text, a->address))
+ found = match = TRUE;
+ }
+ if (!match) {
+ icalcomponent_remove_property (icomp, prop);
+ icalproperty_free (prop);
+ }
+ match = FALSE;
+ }
+ itip_addresses_free (addresses);
- /* Strip off attributes barred from appearing */
+ return found;
+}
+
+static void
+comp_sentby (CalComponent *comp)
+{
+ CalComponentOrganizer organizer;
+ GList *addresses, *l;
+ const char *strip;
+ gboolean is_user = FALSE;
+
+ cal_component_get_organizer (comp, &organizer);
+ if (!organizer.value) {
+ ItipAddress *a = itip_addresses_get_default ();
+
+ organizer.value = g_strdup_printf ("MAILTO:%s", a->address);
+ organizer.sentby = NULL;
+ organizer.cn = a->name;
+ organizer.language = NULL;
+
+ cal_component_set_organizer (comp, &organizer);
+ g_free ((char *) organizer.value);
+ itip_address_free (a);
+
+ return;
+ }
+
+ strip = itip_strip_mailto (organizer.value);
+
+ addresses = itip_addresses_get ();
+ for (l = addresses; l != NULL; l = l->next) {
+ ItipAddress *a = l->data;
+
+ if (!strcmp (a->address, strip)) {
+ is_user = TRUE;
+ break;
+ }
+ }
+ if (!is_user) {
+ ItipAddress *a = itip_addresses_get_default ();
+
+ organizer.value = g_strdup (organizer.value);
+ organizer.sentby = g_strdup_printf ("MAILTO:%s", a->address);
+ organizer.cn = g_strdup (organizer.cn);
+ organizer.language = g_strdup (organizer.language);
+
+ cal_component_set_organizer (comp, &organizer);
+
+ g_free ((char *)organizer.value);
+ g_free ((char *)organizer.sentby);
+ g_free ((char *)organizer.cn);
+ g_free ((char *)organizer.language);
+ itip_address_free (a);
+ }
+
+ itip_addresses_free (addresses);
+}
+static CalComponent *
+comp_minimal (CalComponent *comp, gboolean attendee)
+{
+ CalComponent *clone;
+ icalcomponent *icomp;
+ icalproperty *prop;
+ CalComponentOrganizer organizer;
+ const char *uid;
+ GSList *comments;
+ struct icaltimetype itt;
+ CalComponentRange *recur_id;
+
+ clone = cal_component_new ();
+ cal_component_set_new_vtype (clone, cal_component_get_vtype (comp));
+
+ if (attendee) {
+ GSList *attendees;
+
+ cal_component_get_attendee_list (comp, &attendees);
+ cal_component_set_attendee_list (clone, attendees);
+
+ if (!comp_limit_attendees (clone)) {
+ error_dialog ("You are not an attendee!");
+ goto error;
+ }
+ }
+
+ itt = icaltime_from_timet_with_zone (time (NULL), FALSE,
+ icaltimezone_get_utc_timezone ());
+ cal_component_set_dtstamp (clone, &itt);
+
+ cal_component_get_organizer (comp, &organizer);
+ if (organizer.value == NULL)
+ goto error;
+ cal_component_set_organizer (clone, &organizer);
+
+ cal_component_get_uid (comp, &uid);
+ cal_component_set_uid (clone, uid);
+
+ cal_component_get_comment_list (comp, &comments);
+ if (g_slist_length (comments) <= 1) {
+ cal_component_set_comment_list (clone, comments);
+ } else {
+ GSList *l = comments;
+
+ comments = g_slist_remove_link (comments, l);
+ cal_component_set_comment_list (clone, l);
+ cal_component_free_text_list (l);
+ }
+ cal_component_free_text_list (comments);
+
+ cal_component_get_recurid (comp, &recur_id);
+ cal_component_set_recurid (clone, recur_id);
+
+ icomp = cal_component_get_icalcomponent (comp);
+ for (prop = icalcomponent_get_first_property (icomp, ICAL_X_PROPERTY);
+ prop != NULL;
+ prop = icalcomponent_get_next_property (icomp, ICAL_X_PROPERTY))
+ {
+ icalproperty *p;
+
+ p = icalproperty_new_clone (prop);
+ icalcomponent_add_property (icomp, p);
+ }
+
+ cal_component_rescan (clone);
+
+ return clone;
+
+ error:
+ gtk_object_unref (GTK_OBJECT (clone));
+ return NULL;
+}
+
+static CalComponent *
+comp_compliant (CalComponentItipMethod method, CalComponent *comp)
+{
+ CalComponent *clone, *temp_clone;
+
clone = cal_component_clone (comp);
+
+ /* We delete incoming alarms anyhow, and this helps with outlook */
+ cal_component_remove_all_alarms (clone);
+
+ /* Comply with itip spec */
switch (method) {
case CAL_COMPONENT_METHOD_PUBLISH:
+ comp_sentby (clone);
cal_component_set_attendee_list (clone, NULL);
- break;
- case CAL_COMPONENT_METHOD_REPLY:
+ break;
+ case CAL_COMPONENT_METHOD_REQUEST:
+ comp_sentby (clone);
+ break;
case CAL_COMPONENT_METHOD_CANCEL:
+ comp_sentby (clone);
+ break;
+ case CAL_COMPONENT_METHOD_REPLY:
+ break;
+ case CAL_COMPONENT_METHOD_ADD:
+ break;
case CAL_COMPONENT_METHOD_REFRESH:
+ /* Need to remove almost everything */
+ temp_clone = comp_minimal (clone, TRUE);
+ gtk_object_unref (GTK_OBJECT (clone));
+ clone = temp_clone;
+ break;
+ case CAL_COMPONENT_METHOD_COUNTER:
+ break;
case CAL_COMPONENT_METHOD_DECLINECOUNTER:
- cal_component_remove_all_alarms (clone);
+ /* Need to remove almost everything */
+ temp_clone = comp_minimal (clone, FALSE);
+ clone = temp_clone;
break;
default:
}
- iclone = cal_component_get_icalcomponent (clone);
-
- /* Add the timezones */
- tz_data.tzids = g_hash_table_new (g_str_hash, g_str_equal);
- tz_data.icomp = icomp;
- icalcomponent_foreach_tzid (iclone, foreach_tzid_callback, &tz_data);
- g_hash_table_destroy (tz_data.tzids);
-
- icalcomponent_add_component (icomp, iclone);
- ical_string = icalcomponent_as_ical_string (icomp);
- icalcomponent_remove_component (icomp, iclone);
-
- icalcomponent_free (icomp);
- gtk_object_unref (GTK_OBJECT (clone));
-
- return ical_string;
+ return clone;
}
void
-itip_send_comp (CalComponentItipMethod method, CalComponent *comp)
+itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp)
{
BonoboObjectClient *bonobo_server;
GNOME_Evolution_Composer composer_server;
+ CalComponent *comp = NULL;
GNOME_Evolution_Composer_RecipientList *to_list = NULL;
GNOME_Evolution_Composer_RecipientList *cc_list = NULL;
GNOME_Evolution_Composer_RecipientList *bcc_list = NULL;
@@ -437,6 +695,10 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *comp)
g_return_if_fail (bonobo_server != NULL);
composer_server = BONOBO_OBJREF (bonobo_server);
+ comp = comp_compliant (method, send_comp);
+ if (comp == NULL)
+ goto cleanup;
+
to_list = comp_to_list (method, comp);
if (to_list == NULL)
goto cleanup;
@@ -492,6 +754,9 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *comp)
cleanup:
CORBA_exception_free (&ev);
+ if (comp != NULL)
+ gtk_object_unref (GTK_OBJECT (comp));
+
if (to_list != NULL)
CORBA_free (to_list);
if (cc_list != NULL)
diff --git a/calendar/gui/itip-utils.h b/calendar/gui/itip-utils.h
index 06108a4481..bf34f13a03 100644
--- a/calendar/gui/itip-utils.h
+++ b/calendar/gui/itip-utils.h
@@ -27,6 +27,8 @@ typedef struct {
} ItipAddress;
GList *itip_addresses_get (void);
+ItipAddress *itip_addresses_get_default (void);
+void itip_address_free (ItipAddress *address);
void itip_addresses_free (GList *addresses);
const gchar *itip_strip_mailto (const gchar *address);
diff --git a/calendar/pcs/query.c b/calendar/pcs/query.c
index 3efd2bde50..8ae9cfa697 100644
--- a/calendar/pcs/query.c
+++ b/calendar/pcs/query.c
@@ -28,6 +28,7 @@
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include <gtk/gtksignal.h>
+#include <bonobo/bonobo-exception.h>
#include <gal/widgets/e-unicode.h>
#include <e-util/e-sexp.h>
#include <cal-util/cal-recur.h>
@@ -163,7 +164,7 @@ query_destroy (GtkObject *object)
CORBA_exception_init (&ev);
bonobo_object_release_unref (priv->ql, &ev);
- if (ev._major != CORBA_NO_EXCEPTION)
+ if (BONOBO_EX (&ev))
g_message ("query_destroy(): Could not unref the listener\n");
CORBA_exception_free (&ev);
@@ -930,7 +931,7 @@ add_component (Query *query, const char *uid, gboolean query_in_progress, int n_
total,
&ev);
- if (ev._major != CORBA_NO_EXCEPTION)
+ if (BONOBO_EX (&ev))
g_message ("add_component(): Could not notify the listener of an "
"updated component");
@@ -963,7 +964,7 @@ remove_component (Query *query, const char *uid)
(char *) uid,
&ev);
- if (ev._major != CORBA_NO_EXCEPTION)
+ if (BONOBO_EX (&ev))
g_message ("remove_component(): Could not notify the listener of a "
"removed component");
@@ -1081,7 +1082,7 @@ ensure_sexp (Query *query)
error_str,
&ev);
- if (ev._major != CORBA_NO_EXCEPTION)
+ if (BONOBO_EX (&ev))
g_message ("ensure_sexp(): Could not notify the listener of "
"a parse error");
@@ -1140,7 +1141,7 @@ match_component (Query *query, const char *uid,
error_str,
&ev);
- if (ev._major != CORBA_NO_EXCEPTION)
+ if (BONOBO_EX (&ev))
g_message ("match_component(): Could not notify the listener of "
"an evaluation error");
@@ -1155,7 +1156,7 @@ match_component (Query *query, const char *uid,
_("Evaluation of the search expression did not yield a boolean value"),
&ev);
- if (ev._major != CORBA_NO_EXCEPTION)
+ if (BONOBO_EX (&ev))
g_message ("match_component(): Could not notify the listener of "
"an unexpected result value type when evaluating the "
"search expression");
@@ -1202,7 +1203,7 @@ process_component_cb (gpointer data)
"",
&ev);
- if (ev._major != CORBA_NO_EXCEPTION)
+ if (BONOBO_EX (&ev))
g_message ("process_component_cb(): Could not notify the listener of "
"a finished query");
@@ -1371,7 +1372,7 @@ query_construct (Query *query,
CORBA_exception_init (&ev);
priv->ql = CORBA_Object_duplicate (ql, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
+ if (BONOBO_EX (&ev)) {
g_message ("query_construct(): Could not duplicate the listener");
priv->ql = CORBA_OBJECT_NIL;
CORBA_exception_free (&ev);