diff options
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/calendar-commands.c | 2 | ||||
-rw-r--r-- | calendar/gui/dialogs/comp-editor.c | 2 | ||||
-rw-r--r-- | calendar/gui/dialogs/event-editor.c | 7 | ||||
-rw-r--r-- | calendar/gui/dialogs/task-editor.c | 7 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 13 | ||||
-rw-r--r-- | calendar/gui/e-itip-control.c | 119 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 3 | ||||
-rw-r--r-- | calendar/gui/itip-utils.c | 43 | ||||
-rw-r--r-- | calendar/gui/itip-utils.h | 4 |
9 files changed, 137 insertions, 63 deletions
diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c index 779e2b9441..efbcaf44a6 100644 --- a/calendar/gui/calendar-commands.c +++ b/calendar/gui/calendar-commands.c @@ -367,7 +367,7 @@ publish_freebusy_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path) for (l = comp_list; l; l = l->next) { CalComponent *comp = CAL_COMPONENT (l->data); - itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp); + itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, comp, client, NULL); gtk_object_unref (GTK_OBJECT (comp)); } diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 14bee4e9a7..7615e79589 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -852,7 +852,7 @@ real_send_comp (CompEditor *editor, CalComponentItipMethod method) priv = editor->priv; - itip_send_comp (method, priv->comp); + itip_send_comp (method, priv->comp, priv->client, NULL); } diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c index 9e6f501efe..4c0862c9f7 100644 --- a/calendar/gui/dialogs/event-editor.c +++ b/calendar/gui/dialogs/event-editor.c @@ -299,8 +299,11 @@ event_editor_send_comp (CompEditor *editor, CalComponentItipMethod method) goto parent; comp = meeting_page_get_cancel_comp (priv->meet_page); - if (comp != NULL) { - itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp); + if (comp != NULL) { + CalClient *client; + + client = e_meeting_model_get_cal_client (priv->model); + itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp, client, NULL); gtk_object_unref (GTK_OBJECT (comp)); } diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c index e59582873f..c5c4d61826 100644 --- a/calendar/gui/dialogs/task-editor.c +++ b/calendar/gui/dialogs/task-editor.c @@ -261,8 +261,11 @@ task_editor_send_comp (CompEditor *editor, CalComponentItipMethod method) goto parent; comp = meeting_page_get_cancel_comp (priv->meet_page); - if (comp != NULL) { - itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp); + if (comp != NULL) { + CalClient *client; + + client = e_meeting_model_get_cal_client (priv->model); + itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp, client, NULL); gtk_object_unref (GTK_OBJECT (comp)); } diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index cb4bf37a62..986096bdfc 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -4438,7 +4438,7 @@ e_day_view_finish_long_event_resize (EDayView *day_view) if (cal_client_update_object (day_view->client, comp)) { if (cal_component_has_attendees (comp) && send_component_dialog (comp, FALSE)) - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp); + itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, day_view->client, NULL); } else { g_message ("e_day_view_finish_long_event_resize(): Could not update the object!"); } @@ -4499,7 +4499,7 @@ e_day_view_finish_resize (EDayView *day_view) if (cal_client_update_object (day_view->client, comp)) { if (cal_component_has_attendees (comp) && send_component_dialog (comp, FALSE)) - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp); + itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, day_view->client, NULL); } else { g_message ("e_day_view_finish_resize(): Could not update the object!"); } @@ -5842,7 +5842,8 @@ e_day_view_on_editing_stopped (EDayView *day_view, if (cal_client_update_object (day_view->client, event->comp)) { if (cal_component_has_attendees (event->comp) && send_component_dialog (event->comp, FALSE)) - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, event->comp); + itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, event->comp, + day_view->client, NULL); } else { g_message ("e_day_view_on_editing_stopped(): Could not update the object!"); } @@ -6890,7 +6891,8 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget, if (cal_client_update_object (day_view->client, comp)) { if (cal_component_has_attendees (comp) && send_component_dialog (comp, FALSE)) - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp); + itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, + day_view->client, NULL); } else { g_message ("e_day_view_on_top_canvas_drag_data_received(): Could " "not update the object!"); @@ -7002,7 +7004,8 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget, if (cal_client_update_object (day_view->client, comp)) { if (cal_component_has_attendees (comp) && send_component_dialog (comp, FALSE)) - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp); + itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, + day_view->client, NULL); } else { g_message ("e_day_view_on_main_canvas_drag_data_received(): " "Could not update the object!"); diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c index 12ed92e93e..cac16500cf 100644 --- a/calendar/gui/e-itip-control.c +++ b/calendar/gui/e-itip-control.c @@ -341,7 +341,8 @@ find_my_address (EItipControl *itip, icalcomponent *ical_comp) { EItipControlPrivate *priv; icalproperty *prop; - const char *attendee, *text; + const char *attendee; + char *text; icalvalue *value; priv = itip->priv; @@ -358,15 +359,17 @@ find_my_address (EItipControl *itip, icalcomponent *ical_comp) attendee = icalvalue_get_string (value); - text = itip_strip_mailto (attendee); + text = g_strdup (itip_strip_mailto (attendee)); + text = g_strstrip (text); for (l = priv->addresses; l != NULL; l = l->next) { ItipAddress *a = l->data; - if (!strcmp (a->address, text)) { + if (!g_strcasecmp (a->address, text)) { priv->my_address = a->address; return; } } + g_free (text); } } @@ -374,24 +377,31 @@ static icalproperty * find_attendee (icalcomponent *ical_comp, const char *address) { icalproperty *prop; - const char *attendee, *text; + const char *attendee; icalvalue *value; - g_return_val_if_fail (address != NULL, NULL); + if (address == NULL) + return NULL; for (prop = icalcomponent_get_first_property (ical_comp, ICAL_ATTENDEE_PROPERTY); prop != NULL; prop = icalcomponent_get_next_property (ical_comp, ICAL_ATTENDEE_PROPERTY)) { + char *text; + value = icalproperty_get_value (prop); if (!value) continue; attendee = icalvalue_get_string (value); - text = itip_strip_mailto (attendee); - if (strstr (text, address)) + text = g_strdup (itip_strip_mailto (attendee)); + text = g_strstrip (text); + if (!g_strcasecmp (address, text)) { + g_free (text); break; + } + g_free (text); } return prop; @@ -1310,7 +1320,7 @@ e_itip_control_get_from_address (EItipControl *itip) } -static void +static gboolean change_status (icalcomponent *ical_comp, const char *address, icalparameter_partstat status) { icalproperty *prop; @@ -1322,7 +1332,17 @@ change_status (icalcomponent *ical_comp, const char *address, icalparameter_part icalproperty_remove_parameter (prop, ICAL_PARTSTAT_PARAMETER); param = icalparameter_new_partstat (status); icalproperty_add_parameter (prop, param); + } else { + GtkWidget *dialog; + + dialog = gnome_warning_dialog (_("Unable to find any of your identities " + "in the attendees list!\n")); + gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); + + return FALSE; } + + return TRUE; } static void @@ -1443,14 +1463,25 @@ send_item (EItipControl *itip) { EItipControlPrivate *priv; CalComponent *comp; + CalComponentVType vtype; GtkWidget *dialog; priv = itip->priv; comp = get_real_item (itip); - + vtype = cal_component_get_vtype (comp); + if (comp != NULL) { - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp); + switch (vtype) { + case CAL_COMPONENT_EVENT: + itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, priv->event_client, NULL); + break; + case CAL_COMPONENT_TODO: + itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, priv->task_client, NULL); + break; + default: + itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, NULL, NULL); + } gtk_object_unref (GTK_OBJECT (comp)); dialog = gnome_ok_dialog (_("Item sent!\n")); } else { @@ -1498,7 +1529,7 @@ send_freebusy (EItipControl *itip) for (l = comp_list; l; l = l->next) { CalComponent *comp = CAL_COMPONENT (l->data); - itip_send_comp (CAL_COMPONENT_METHOD_REPLY, comp); + itip_send_comp (CAL_COMPONENT_METHOD_REPLY, comp, priv->event_client, NULL); gtk_object_unref (GTK_OBJECT (comp)); } @@ -1578,7 +1609,7 @@ ok_clicked_cb (GtkHTML *html, const gchar *method, const gchar *url, const gchar EItipControl *itip = E_ITIP_CONTROL (data); EItipControlPrivate *priv; gchar **fields; - gboolean rsvp = FALSE; + gboolean rsvp = FALSE, status = FALSE; int i; priv = itip->priv; @@ -1598,19 +1629,28 @@ ok_clicked_cb (GtkHTML *html, const gchar *method, const gchar *url, const gchar update_item (itip); break; case 'A': - change_status (priv->ical_comp, priv->my_address, ICAL_PARTSTAT_ACCEPTED); - cal_component_rescan (priv->comp); - update_item (itip); + status = change_status (priv->ical_comp, priv->my_address, + ICAL_PARTSTAT_ACCEPTED); + if (status) { + 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); + status = change_status (priv->ical_comp, priv->my_address, + ICAL_PARTSTAT_TENTATIVE); + if (status) { + 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); - remove_item (itip); + status = change_status (priv->ical_comp, priv->my_address, + ICAL_PARTSTAT_DECLINED); + if (status) { + cal_component_rescan (priv->comp); + remove_item (itip); + } break; case 'F': send_freebusy (itip); @@ -1636,18 +1676,20 @@ ok_clicked_cb (GtkHTML *html, const gchar *method, const gchar *url, const gchar } g_strfreev (fields); - if (rsvp) { + if (rsvp && status) { CalComponent *comp = NULL; - + CalComponentVType vtype; + comp = cal_component_clone (priv->comp); if (comp == NULL) return; - + vtype = cal_component_get_vtype (comp); + if (priv->my_address != NULL) { icalcomponent *ical_comp; icalproperty *prop; icalvalue *value; - const char *attendee, *text; + const char *attendee; GSList *l, *list = NULL; ical_comp = cal_component_get_icalcomponent (comp); @@ -1656,15 +1698,19 @@ ok_clicked_cb (GtkHTML *html, const gchar *method, const gchar *url, const gchar prop != NULL; prop = icalcomponent_get_next_property (ical_comp, ICAL_ATTENDEE_PROPERTY)) { + char *text; + value = icalproperty_get_value (prop); if (!value) continue; attendee = icalvalue_get_string (value); - text = itip_strip_mailto (attendee); - if (!strstr (text, priv->my_address)) + text = g_strdup (itip_strip_mailto (attendee)); + text = g_strstrip (text); + if (g_strcasecmp (priv->my_address, text)) list = g_slist_prepend (list, prop); + g_free (text); } for (l = list; l; l = l->next) { @@ -1675,13 +1721,18 @@ ok_clicked_cb (GtkHTML *html, const gchar *method, const gchar *url, const gchar g_slist_free (list); cal_component_rescan (comp); - itip_send_comp (CAL_COMPONENT_METHOD_REPLY, comp); - } else { - GtkWidget *dialog; - - dialog = gnome_warning_dialog (_("Unable to find any of your identities " - "in the attendees list!\n")); - gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); + switch (vtype) { + case CAL_COMPONENT_EVENT: + itip_send_comp (CAL_COMPONENT_METHOD_REPLY, comp, + priv->event_client, priv->top_level); + break; + case CAL_COMPONENT_TODO: + itip_send_comp (CAL_COMPONENT_METHOD_REPLY, comp, + priv->task_client, priv->top_level); + break; + default: + itip_send_comp (CAL_COMPONENT_METHOD_REPLY, comp, NULL, NULL); + } } gtk_object_unref (GTK_OBJECT (comp)); } diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 9fbf26b979..85434e2099 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -3193,7 +3193,8 @@ e_week_view_on_editing_stopped (EWeekView *week_view, if (cal_client_update_object (week_view->client, event->comp)) { if (cal_component_has_attendees (event->comp) && send_component_dialog (event->comp, FALSE)) - itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, event->comp); + itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, event->comp, + week_view->client, NULL); } else { g_message ("e_week_view_on_editing_stopped(): Could not update the object!"); } diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c index 405240e9da..1f1a0a9883 100644 --- a/calendar/gui/itip-utils.c +++ b/calendar/gui/itip-utils.c @@ -84,6 +84,7 @@ get_address (long num) path = g_strdup_printf ("/Mail/Accounts/identity_address_%ld", num); a->address = bonobo_config_get_string (db, path, NULL); + a->address = g_strstrip (a->address); g_free (path); a->full = g_strdup_printf ("%s <%s>", a->name, a->address); @@ -183,13 +184,10 @@ itip_addresses_free (GList *addresses) const gchar * itip_strip_mailto (const gchar *address) { - const gchar *text; - if (address == NULL) return NULL; - text = e_strstrcase (address, "mailto:"); - if (text != NULL && strlen (address) > 7) + if (!g_strncasecmp (address, "mailto:", 7)) address += 7; return address; @@ -222,6 +220,8 @@ get_label (struct icaltimetype *tt) typedef struct { GHashTable *tzids; icalcomponent *icomp; + CalClient *client; + icalcomponent *zones; } ItipUtilTZData; static GNOME_Evolution_Composer_RecipientList * @@ -388,7 +388,7 @@ foreach_tzid_callback (icalparameter *param, gpointer data) { ItipUtilTZData *tz_data = data; const char *tzid; - icaltimezone *zone; + icaltimezone *zone = NULL; icalcomponent *vtimezone_comp; /* Get the TZID string from the parameter. */ @@ -396,9 +396,14 @@ foreach_tzid_callback (icalparameter *param, gpointer data) 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) + /* Look for the timezone */ + if (tz_data->zones != NULL) + zone = icalcomponent_get_timezone (tz_data->zones, tzid); + if (zone == NULL) + zone = icaltimezone_get_builtin_timezone_from_tzid (tzid); + if (zone == NULL && tz_data->client != NULL) + cal_client_get_timezone (tz_data->client, tzid, &zone); + if (zone == NULL) return; /* Convert it to a string and add it to the hash. */ @@ -411,7 +416,7 @@ foreach_tzid_callback (icalparameter *param, gpointer data) } static char * -comp_string (CalComponentItipMethod method, CalComponent *comp) +comp_string (CalComponentItipMethod method, CalComponent *comp, CalClient *client, icalcomponent *zones) { icalcomponent *top_level, *icomp; icalproperty *prop; @@ -430,7 +435,9 @@ comp_string (CalComponentItipMethod method, CalComponent *comp) /* Add the timezones */ tz_data.tzids = g_hash_table_new (g_str_hash, g_str_equal); - tz_data.icomp = top_level; + tz_data.icomp = top_level; + tz_data.client = client; + tz_data.zones = zones; icalcomponent_foreach_tzid (icomp, foreach_tzid_callback, &tz_data); g_hash_table_destroy (tz_data.tzids); @@ -460,7 +467,8 @@ comp_limit_attendees (CalComponent *comp) prop = icalcomponent_get_next_property (icomp, ICAL_ATTENDEE_PROPERTY)) { icalvalue *value; - const char *attendee, *text; + const char *attendee; + char *text; GList *l; /* If we've already found something, just erase the rest */ @@ -475,14 +483,16 @@ comp_limit_attendees (CalComponent *comp) attendee = icalvalue_get_string (value); - text = itip_strip_mailto (attendee); + text = g_strdup (itip_strip_mailto (attendee)); + text = g_strstrip (text); for (l = addresses; l != NULL; l = l->next) { ItipAddress *a = l->data; - if (strstr (text, a->address)) + if (!g_strcasecmp (a->address, text)) found = match = TRUE; } - + g_free (text); + if (!match) list = g_slist_prepend (list, prop); match = FALSE; @@ -679,7 +689,8 @@ comp_compliant (CalComponentItipMethod method, CalComponent *comp) } void -itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp) +itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp, + CalClient *client, icalcomponent *zones) { BonoboObjectClient *bonobo_server; GNOME_Evolution_Composer composer_server; @@ -740,7 +751,7 @@ itip_send_comp (CalComponentItipMethod method, CalComponent *send_comp) description = comp_description (comp); show_inline = TRUE; - ical_string = comp_string (method, comp); + ical_string = comp_string (method, comp, client, zones); attach_data = GNOME_Evolution_Composer_AttachmentData__alloc (); attach_data->_length = strlen (ical_string) + 1; attach_data->_maximum = attach_data->_length; diff --git a/calendar/gui/itip-utils.h b/calendar/gui/itip-utils.h index bf34f13a03..2863d871e2 100644 --- a/calendar/gui/itip-utils.h +++ b/calendar/gui/itip-utils.h @@ -5,6 +5,7 @@ #include <ical.h> #include <string.h> #include <glib.h> +#include <cal-client/cal-client.h> #include <cal-util/cal-component.h> typedef enum { @@ -33,7 +34,8 @@ void itip_addresses_free (GList *addresses); const gchar *itip_strip_mailto (const gchar *address); -void itip_send_comp (CalComponentItipMethod method, CalComponent *comp); +void itip_send_comp (CalComponentItipMethod method, CalComponent *comp, + CalClient *client, icalcomponent *zones); #endif |