diff options
author | JP Rosevear <jpr@ximian.com> | 2001-09-14 03:06:15 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2001-09-14 03:06:15 +0800 |
commit | b280d814d60baee0a3fb9f6885f1a0c4b9553606 (patch) | |
tree | f4c01123e9883cf3aa077e0a8589d806bceaece5 /calendar | |
parent | a24242acd4924aa88625b32f1d96cb92cadbbf7c (diff) | |
download | gsoc2013-evolution-b280d814d60baee0a3fb9f6885f1a0c4b9553606.tar gsoc2013-evolution-b280d814d60baee0a3fb9f6885f1a0c4b9553606.tar.gz gsoc2013-evolution-b280d814d60baee0a3fb9f6885f1a0c4b9553606.tar.bz2 gsoc2013-evolution-b280d814d60baee0a3fb9f6885f1a0c4b9553606.tar.lz gsoc2013-evolution-b280d814d60baee0a3fb9f6885f1a0c4b9553606.tar.xz gsoc2013-evolution-b280d814d60baee0a3fb9f6885f1a0c4b9553606.tar.zst gsoc2013-evolution-b280d814d60baee0a3fb9f6885f1a0c4b9553606.zip |
use ical partstat, role, cutypes directly
2001-09-13 JP Rosevear <jpr@ximian.com>
* cal-util/cal-component.h: use ical partstat, role, cutypes
directly
* cal-util/cal-component.c: ditto
* gui/e-itip-control.c (find_my_address): set my addresses if the
addresses match
(find_attendee): strstr returns non-null on a match
(write_html): use new icon, select the name displayed (organizer
or attendee) based on method,
(ok_clicked_cb): when rsvp'ing strip off all but the attendee
being replied for as is specified in the spec
(find_attendee_partstat): new util function to extract the
partstat of an attendee
(update_attendee_status): updates the partstat of a specific
attendee in the reply message
* gui/dialogs/meeting-page.c: use ical partstat, role, cutypes
directly
(popup_delegate_cb): if we delegate, notify of needs send and
changed
(popup_delete_cb): notify of needs send and changed for each
deletion
svn path=/trunk/; revision=12806
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 26 | ||||
-rw-r--r-- | calendar/cal-util/cal-component.c | 141 | ||||
-rw-r--r-- | calendar/cal-util/cal-component.h | 35 | ||||
-rw-r--r-- | calendar/gui/dialogs/meeting-page.c | 99 | ||||
-rw-r--r-- | calendar/gui/e-itip-control.c | 215 |
5 files changed, 268 insertions, 248 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 551a977439..848f678a5b 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,29 @@ +2001-09-13 JP Rosevear <jpr@ximian.com> + + * cal-util/cal-component.h: use ical partstat, role, cutypes + directly + + * cal-util/cal-component.c: ditto + + * gui/e-itip-control.c (find_my_address): set my addresses if the + addresses match + (find_attendee): strstr returns non-null on a match + (write_html): use new icon, select the name displayed (organizer + or attendee) based on method, + (ok_clicked_cb): when rsvp'ing strip off all but the attendee + being replied for as is specified in the spec + (find_attendee_partstat): new util function to extract the + partstat of an attendee + (update_attendee_status): updates the partstat of a specific + attendee in the reply message + + * gui/dialogs/meeting-page.c: use ical partstat, role, cutypes + directly + (popup_delegate_cb): if we delegate, notify of needs send and + changed + (popup_delete_cb): notify of needs send and changed for each + deletion + 2001-09-12 JP Rosevear <jpr@ximian.com> * gui/calendar-commands.c (publish_freebusy_cmd): send 6 weeks of diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c index d74c1238b2..7ef6f9e477 100644 --- a/calendar/cal-util/cal-component.c +++ b/calendar/cal-util/cal-component.c @@ -3587,78 +3587,17 @@ get_attendee_list (GSList *attendee_list, GSList **al) a->value = icalproperty_get_attendee (attendee->prop); if (attendee->member_param) - a->member = icalparameter_get_member (attendee->member_param); - if (attendee->cutype_param) { - switch (icalparameter_get_cutype (attendee->cutype_param)) { - case ICAL_CUTYPE_INDIVIDUAL: - a->cutype = CAL_COMPONENT_CUTYPE_INDIVIDUAL; - break; - case ICAL_CUTYPE_GROUP: - a->cutype = CAL_COMPONENT_CUTYPE_GROUP; - break; - case ICAL_CUTYPE_RESOURCE: - a->cutype = CAL_COMPONENT_CUTYPE_RESOURCE; - break; - case ICAL_CUTYPE_ROOM: - a->cutype = CAL_COMPONENT_CUTYPE_ROOM; - break; - default: - a->cutype = CAL_COMPONENT_CUTYPE_UNKNOWN; - } - } - - if (attendee->role_param) { - switch (icalparameter_get_role (attendee->role_param)) { - case ICAL_ROLE_CHAIR: - a->role = CAL_COMPONENT_ROLE_CHAIR; - break; - case ICAL_ROLE_REQPARTICIPANT: - a->role = CAL_COMPONENT_ROLE_REQUIRED; - break; - case ICAL_ROLE_OPTPARTICIPANT: - a->role = CAL_COMPONENT_ROLE_OPTIONAL; - break; - case ICAL_ROLE_NONPARTICIPANT: - a->role = CAL_COMPONENT_ROLE_NON; - break; - default: - a->role = CAL_COMPONENT_ROLE_UNKNOWN; - } - } - - if (attendee->partstat_param) { - switch (icalparameter_get_role (attendee->partstat_param)) { - case ICAL_PARTSTAT_NEEDSACTION: - a->status = CAL_COMPONENT_PARTSTAT_NEEDSACTION; - break; - case ICAL_PARTSTAT_ACCEPTED: - a->status = CAL_COMPONENT_PARTSTAT_ACCEPTED; - break; - case ICAL_PARTSTAT_DECLINED: - a->status = CAL_COMPONENT_PARTSTAT_DECLINED; - break; - case ICAL_PARTSTAT_TENTATIVE: - a->status = CAL_COMPONENT_PARTSTAT_TENTATIVE; - break; - case ICAL_PARTSTAT_DELEGATED: - a->status = CAL_COMPONENT_PARTSTAT_DELEGATED; - break; - case ICAL_PARTSTAT_COMPLETED: - a->status = CAL_COMPONENT_PARTSTAT_COMPLETED; - break; - case ICAL_PARTSTAT_INPROCESS: - a->status = CAL_COMPONENT_PARTSTAT_INPROCESS; - break; - default: - a->status = CAL_COMPONENT_PARTSTAT_UNKNOWN; - } - } - + a->member = icalparameter_get_member (attendee->member_param); + if (attendee->cutype_param) + a->cutype = icalparameter_get_cutype (attendee->cutype_param); + if (attendee->role_param) + a->role = icalparameter_get_role (attendee->role_param); + if (attendee->partstat_param) + a->status = icalparameter_get_role (attendee->partstat_param); if (attendee->rsvp_param && icalparameter_get_rsvp (attendee->rsvp_param) == ICAL_RSVP_TRUE) a->rsvp = TRUE; else a->rsvp = FALSE; - if (attendee->delfrom_param) a->delfrom = icalparameter_get_sentby (attendee->delfrom_param); if (attendee->delto_param) @@ -3709,9 +3648,6 @@ set_attendee_list (CalComponent *comp, for (l = al; l; l = l->next) { CalComponentAttendee *a; struct attendee *attendee; - icalparameter_cutype ct; - icalparameter_role r; - icalparameter_partstat p; a = l->data; g_return_if_fail (a->value != NULL); @@ -3726,70 +3662,13 @@ set_attendee_list (CalComponent *comp, icalproperty_add_parameter (attendee->prop, attendee->member_param); } - switch (a->cutype) { - case CAL_COMPONENT_CUTYPE_INDIVIDUAL: - ct = ICAL_CUTYPE_INDIVIDUAL; - break; - case CAL_COMPONENT_CUTYPE_GROUP: - ct = ICAL_CUTYPE_GROUP; - break; - case CAL_COMPONENT_CUTYPE_RESOURCE: - ct = ICAL_CUTYPE_RESOURCE; - break; - case CAL_COMPONENT_CUTYPE_ROOM: - ct = ICAL_CUTYPE_ROOM; - break; - default: - ct = ICAL_CUTYPE_UNKNOWN; - } - attendee->cutype_param = icalparameter_new_cutype (ct); + attendee->cutype_param = icalparameter_new_cutype (a->cutype); icalproperty_add_parameter (attendee->prop, attendee->cutype_param); - switch (a->role) { - case CAL_COMPONENT_ROLE_CHAIR: - r = ICAL_ROLE_CHAIR; - break; - case CAL_COMPONENT_ROLE_REQUIRED: - r = ICAL_ROLE_REQPARTICIPANT; - break; - case CAL_COMPONENT_ROLE_OPTIONAL: - r = ICAL_ROLE_OPTPARTICIPANT; - break; - case CAL_COMPONENT_ROLE_NON: - r = ICAL_ROLE_NONPARTICIPANT; - break; - default: - r = ICAL_ROLE_NONE; - } - attendee->role_param = icalparameter_new_role (r); + attendee->role_param = icalparameter_new_role (a->role); icalproperty_add_parameter (attendee->prop, attendee->role_param); - switch (a->status) { - case CAL_COMPONENT_PARTSTAT_NEEDSACTION: - p = ICAL_PARTSTAT_NEEDSACTION; - break; - case CAL_COMPONENT_PARTSTAT_ACCEPTED: - p = ICAL_PARTSTAT_ACCEPTED; - break; - case CAL_COMPONENT_PARTSTAT_DECLINED: - p = ICAL_PARTSTAT_DECLINED; - break; - case CAL_COMPONENT_PARTSTAT_TENTATIVE: - p = ICAL_PARTSTAT_TENTATIVE; - break; - case CAL_COMPONENT_PARTSTAT_DELEGATED: - p = ICAL_PARTSTAT_DELEGATED; - break; - case CAL_COMPONENT_PARTSTAT_COMPLETED: - p = ICAL_PARTSTAT_COMPLETED; - break; - case CAL_COMPONENT_PARTSTAT_INPROCESS: - p = ICAL_PARTSTAT_INPROCESS; - break; - default: - p = ICAL_PARTSTAT_NONE; - } - attendee->partstat_param = icalparameter_new_partstat (p); + attendee->partstat_param = icalparameter_new_partstat (a->status); icalproperty_add_parameter (attendee->prop, attendee->partstat_param); if (a->rsvp) diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h index ef38483c68..1ab8ee24bd 100644 --- a/calendar/cal-util/cal-component.h +++ b/calendar/cal-util/cal-component.h @@ -150,41 +150,14 @@ typedef enum { CAL_COMPONENT_TRANSP_UNKNOWN } CalComponentTransparency; -/* Organizer & Attendee */ -typedef enum { - CAL_COMPONENT_CUTYPE_INDIVIDUAL, - CAL_COMPONENT_CUTYPE_GROUP, - CAL_COMPONENT_CUTYPE_RESOURCE, - CAL_COMPONENT_CUTYPE_ROOM, - CAL_COMPONENT_CUTYPE_UNKNOWN -} CalComponentCUType; - -typedef enum { - CAL_COMPONENT_ROLE_CHAIR, - CAL_COMPONENT_ROLE_REQUIRED, - CAL_COMPONENT_ROLE_OPTIONAL, - CAL_COMPONENT_ROLE_NON, - CAL_COMPONENT_ROLE_UNKNOWN -} CalComponentRole; - -typedef enum { - CAL_COMPONENT_PARTSTAT_NEEDSACTION, - CAL_COMPONENT_PARTSTAT_ACCEPTED, - CAL_COMPONENT_PARTSTAT_DECLINED, - CAL_COMPONENT_PARTSTAT_TENTATIVE, - CAL_COMPONENT_PARTSTAT_DELEGATED, - CAL_COMPONENT_PARTSTAT_COMPLETED, - CAL_COMPONENT_PARTSTAT_INPROCESS, - CAL_COMPONENT_PARTSTAT_UNKNOWN -} CalComponentPartStat; - +/* Organizer & Attendee */ typedef struct { const char *value; const char *member; - CalComponentCUType cutype; - CalComponentRole role; - CalComponentPartStat status; + icalparameter_cutype cutype; + icalparameter_role role; + icalparameter_partstat status; gboolean rsvp; const char *delto; diff --git a/calendar/gui/dialogs/meeting-page.c b/calendar/gui/dialogs/meeting-page.c index b02efe4735..55ca96975c 100644 --- a/calendar/gui/dialogs/meeting-page.c +++ b/calendar/gui/dialogs/meeting-page.c @@ -78,9 +78,9 @@ struct attendee { char *address; char *member; - CalComponentCUType cutype; - CalComponentRole role; - CalComponentPartStat status; + icalparameter_cutype cutype; + icalparameter_role role; + icalparameter_partstat status; gboolean rsvp; char *delto; @@ -562,32 +562,32 @@ get_widgets (MeetingPage *mpage) } -static CalComponentCUType +static icalparameter_cutype text_to_type (const char *type) { if (!g_strcasecmp (type, _("Individual"))) - return CAL_COMPONENT_CUTYPE_INDIVIDUAL; + return ICAL_CUTYPE_INDIVIDUAL; else if (!g_strcasecmp (type, _("Group"))) - return CAL_COMPONENT_CUTYPE_GROUP; + return ICAL_CUTYPE_GROUP; else if (!g_strcasecmp (type, _("Resource"))) - return CAL_COMPONENT_CUTYPE_RESOURCE; + return ICAL_CUTYPE_RESOURCE; else if (!g_strcasecmp (type, _("Room"))) - return CAL_COMPONENT_CUTYPE_ROOM; + return ICAL_CUTYPE_ROOM; else - return CAL_COMPONENT_ROLE_UNKNOWN; + return ICAL_CUTYPE_NONE; } static char * -type_to_text (CalComponentCUType type) +type_to_text (icalparameter_cutype type) { switch (type) { - case CAL_COMPONENT_CUTYPE_INDIVIDUAL: + case ICAL_CUTYPE_INDIVIDUAL: return _("Individual"); - case CAL_COMPONENT_CUTYPE_GROUP: + case ICAL_CUTYPE_GROUP: return _("Group"); - case CAL_COMPONENT_CUTYPE_RESOURCE: + case ICAL_CUTYPE_RESOURCE: return _("Resource"); - case CAL_COMPONENT_CUTYPE_ROOM: + case ICAL_CUTYPE_ROOM: return _("Room"); default: return _("Unknown"); @@ -597,32 +597,32 @@ type_to_text (CalComponentCUType type) } -static CalComponentRole +static icalparameter_role text_to_role (const char *role) { if (!g_strcasecmp (role, _("Chair"))) - return CAL_COMPONENT_ROLE_CHAIR; + return ICAL_ROLE_CHAIR; else if (!g_strcasecmp (role, _("Required Participant"))) - return CAL_COMPONENT_ROLE_REQUIRED; + return ICAL_ROLE_REQPARTICIPANT; else if (!g_strcasecmp (role, _("Optional Participant"))) - return CAL_COMPONENT_ROLE_OPTIONAL; + return ICAL_ROLE_OPTPARTICIPANT; else if (!g_strcasecmp (role, _("Non-Participant"))) - return CAL_COMPONENT_ROLE_NON; + return ICAL_ROLE_NONPARTICIPANT; else - return CAL_COMPONENT_ROLE_UNKNOWN; + return ICAL_ROLE_NONE; } static char * -role_to_text (CalComponentRole role) +role_to_text (icalparameter_role role) { switch (role) { - case CAL_COMPONENT_ROLE_CHAIR: + case ICAL_ROLE_CHAIR: return _("Chair"); - case CAL_COMPONENT_ROLE_REQUIRED: + case ICAL_ROLE_REQPARTICIPANT: return _("Required Participant"); - case CAL_COMPONENT_ROLE_OPTIONAL: + case ICAL_ROLE_OPTPARTICIPANT: return _("Optional Participant"); - case CAL_COMPONENT_ROLE_NON: + case ICAL_ROLE_NONPARTICIPANT: return _("Non-Participant"); default: return _("Unknown"); @@ -649,46 +649,45 @@ boolean_to_text (gboolean b) return _("No"); } -static CalComponentPartStat +static icalparameter_partstat text_to_partstat (const char *partstat) { if (!g_strcasecmp (partstat, _("Needs Action"))) - return CAL_COMPONENT_PARTSTAT_NEEDSACTION; + return ICAL_PARTSTAT_NEEDSACTION; else if (!g_strcasecmp (partstat, _("Accepted"))) - return CAL_COMPONENT_PARTSTAT_ACCEPTED; + return ICAL_PARTSTAT_ACCEPTED; else if (!g_strcasecmp (partstat, _("Declined"))) - return CAL_COMPONENT_PARTSTAT_DECLINED; + return ICAL_PARTSTAT_DECLINED; else if (!g_strcasecmp (partstat, _("Tentative"))) - return CAL_COMPONENT_PARTSTAT_TENTATIVE; + return ICAL_PARTSTAT_TENTATIVE; else if (!g_strcasecmp (partstat, _("Delegated"))) - return CAL_COMPONENT_PARTSTAT_DELEGATED; + return ICAL_PARTSTAT_DELEGATED; else if (!g_strcasecmp (partstat, _("Completed"))) - return CAL_COMPONENT_PARTSTAT_COMPLETED; + return ICAL_PARTSTAT_COMPLETED; else if (!g_strcasecmp (partstat, _("In Process"))) - return CAL_COMPONENT_PARTSTAT_INPROCESS; + return ICAL_PARTSTAT_INPROCESS; else - return CAL_COMPONENT_PARTSTAT_UNKNOWN; + return ICAL_PARTSTAT_NONE; } static char * -partstat_to_text (CalComponentPartStat partstat) +partstat_to_text (icalparameter_partstat partstat) { switch (partstat) { - case CAL_COMPONENT_PARTSTAT_NEEDSACTION: + case ICAL_PARTSTAT_NEEDSACTION: return _("Needs Action"); - case CAL_COMPONENT_PARTSTAT_ACCEPTED: + case ICAL_PARTSTAT_ACCEPTED: return _("Accepted"); - case CAL_COMPONENT_PARTSTAT_DECLINED: + case ICAL_PARTSTAT_DECLINED: return _("Declined"); - case CAL_COMPONENT_PARTSTAT_TENTATIVE: + case ICAL_PARTSTAT_TENTATIVE: return _("Tentative"); - case CAL_COMPONENT_PARTSTAT_DELEGATED: + case ICAL_PARTSTAT_DELEGATED: return _("Delegated"); - case CAL_COMPONENT_PARTSTAT_COMPLETED: + case ICAL_PARTSTAT_COMPLETED: return _("Completed"); - case CAL_COMPONENT_PARTSTAT_INPROCESS: + case ICAL_PARTSTAT_INPROCESS: return _("In Process"); - case CAL_COMPONENT_PARTSTAT_UNKNOWN: default: return _("Unknown"); } @@ -778,13 +777,13 @@ invite_entry_changed (BonoboListener *listener, g_free (str); if (!strcmp (section, _("Chair Persons"))) - a->role = CAL_COMPONENT_ROLE_CHAIR; + a->role = ICAL_ROLE_CHAIR; else if (!strcmp (section, _("Required Participants"))) - a->role = CAL_COMPONENT_ROLE_REQUIRED; + a->role = ICAL_ROLE_REQPARTICIPANT; else if (!strcmp (section, _("Optional Participants"))) - a->role = CAL_COMPONENT_ROLE_OPTIONAL; + a->role = ICAL_ROLE_OPTPARTICIPANT; else if (!strcmp (section, _("Non-Participants"))) - a->role = CAL_COMPONENT_ROLE_NON; + a->role = ICAL_ROLE_NONPARTICIPANT; str = init_value (NULL, MEETING_RSVP_COL, mpage); a->rsvp = text_to_boolean (str); @@ -1417,6 +1416,9 @@ popup_delegate_cb (GtkWidget *widget, gpointer data) row_cnt = row_count (priv->model, mpage) - 1; e_table_model_row_changed (priv->model, priv->row); e_table_model_row_inserted (priv->model, row_cnt); + + comp_editor_page_notify_needs_send (COMP_EDITOR_PAGE (mpage)); + comp_editor_page_notify_changed (COMP_EDITOR_PAGE (mpage)); } cleanup: @@ -1462,6 +1464,9 @@ popup_delete_cb (GtkWidget *widget, gpointer data) e_table_model_row_deleted (priv->model, pos); + comp_editor_page_notify_needs_send (COMP_EDITOR_PAGE (mpage)); + comp_editor_page_notify_changed (COMP_EDITOR_PAGE (mpage)); + if (a->delto != NULL) b = find_match (mpage, a->delto, &pos); a = b; diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c index 88745ff654..1d54fb6a01 100644 --- a/calendar/gui/e-itip-control.c +++ b/calendar/gui/e-itip-control.c @@ -98,7 +98,7 @@ struct _EItipControlPrivate { <input TYPE=Submit name=\"ok\" value=\"OK\"></form>" #define REPLY_OPTIONS "<form><b>Choose an action:</b><select NAME=\"action\" SIZE=\"1\"> \ -<option VALUE=\"R\">Update</option></select>    \ +<option VALUE=\"R\">Update respondent status</option></select>    \ <input TYPE=Submit name=\"ok\" value=\"OK\"></form>" #define REFRESH_OPTIONS "<form><b>Choose an action:</b><select NAME=\"action\" SIZE=\"1\"> \ @@ -348,7 +348,7 @@ find_my_address (EItipControl *itip, icalcomponent *ical_comp) for (l = priv->addresses; l != NULL; l = l->next) { ItipAddress *a = l->data; - if (strcmp (a->address, text)) { + if (!strcmp (a->address, text)) { priv->my_address = a->address; return; } @@ -357,7 +357,7 @@ find_my_address (EItipControl *itip, icalcomponent *ical_comp) } static icalproperty * -find_attendee (icalcomponent *ical_comp, char *address) +find_attendee (icalcomponent *ical_comp, const char *address) { icalproperty *prop; const char *attendee, *text; @@ -376,13 +376,30 @@ find_attendee (icalcomponent *ical_comp, char *address) attendee = icalvalue_get_string (value); text = itip_strip_mailto (attendee); - if (!strstr (text, address)) + if (strstr (text, address)) break; } return prop; } +static icalparameter_partstat +find_attendee_partstat (icalcomponent *ical_comp, const char *address) +{ + icalproperty *prop; + + prop = find_attendee (ical_comp, address); + if (prop != NULL) { + icalparameter *param; + + param = icalproperty_get_first_parameter (prop, ICAL_PARTSTAT_PARAMETER); + if (param != NULL) + return icalparameter_get_partstat (param); + } + + return ICAL_PARTSTAT_NONE; +} + static void set_label (EItipControl *itip) { @@ -512,7 +529,8 @@ write_html (EItipControl *itip, gchar *itip_desc, gchar *itip_title, gchar *opti GtkHTMLStream *html_stream; CalComponentText text; CalComponentOrganizer organizer; - GSList *l = NULL; + CalComponentAttendee *attendee; + GSList *attendees, *l = NULL; gchar *html; priv = itip->priv; @@ -535,7 +553,7 @@ write_html (EItipControl *itip, gchar *itip_desc, gchar *itip_title, gchar *opti g_free (html); /* The image */ - html = g_strdup ("<img src=\"/talking-heads.png\"></td>"); + html = g_strdup ("<img src=\"/meeting-request.png\"></td>"); gtk_html_write (GTK_HTML (priv->html), html_stream, html, strlen(html)); g_free (html); @@ -543,15 +561,38 @@ write_html (EItipControl *itip, gchar *itip_desc, gchar *itip_title, gchar *opti gtk_html_write (GTK_HTML (priv->html), html_stream, html, strlen(html)); g_free (html); - /* The organizer */ - cal_component_get_organizer (priv->comp, &organizer); - if (organizer.value != NULL) { - html = g_strdup_printf (itip_desc, - organizer.cn ? organizer.cn : itip_strip_mailto (organizer.value)); - gtk_html_write (GTK_HTML (priv->html), html_stream, html, strlen(html)); - g_free (html); + switch (priv->method) { + case ICAL_METHOD_REFRESH: + case ICAL_METHOD_REPLY: + /* An attendee sent this */ + cal_component_get_attendee_list (priv->comp, &attendees); + if (attendees != NULL) { + attendee = attendees->data; + html = g_strdup_printf (itip_desc, + attendee->cn ? + attendee->cn : + itip_strip_mailto (attendee->value)); + } else { + html = g_strdup_printf (itip_desc, "An unknown person"); + } + break; + case ICAL_METHOD_PUBLISH: + case ICAL_METHOD_REQUEST: + case ICAL_METHOD_ADD: + case ICAL_METHOD_CANCEL: + default: + /* The organizer sent this */ + cal_component_get_organizer (priv->comp, &organizer); + if (organizer.value != NULL) + html = g_strdup_printf (itip_desc, + organizer.cn ? + organizer.cn : + itip_strip_mailto (organizer.value)); + break; } - + gtk_html_write (GTK_HTML (priv->html), html_stream, html, strlen(html)); + g_free (html); + /* Describe what the user can do */ html = U_("<br> Please review the following information, " "and then select an action from the menu below."); @@ -916,6 +957,22 @@ e_itip_control_get_from_address (EItipControl *itip) return priv->from_address; } + +static void +change_status (icalcomponent *ical_comp, const char *address, icalparameter_partstat status) +{ + icalproperty *prop; + + prop = find_attendee (ical_comp, address); + if (prop) { + icalparameter *param; + + icalproperty_remove_parameter (prop, ICAL_PARTSTAT_PARAMETER); + param = icalparameter_new_partstat (status); + icalproperty_add_parameter (prop, param); + } +} + static void update_item (EItipControl *itip) { @@ -937,7 +994,7 @@ update_item (EItipControl *itip) icalcomponent_add_component (priv->top_level, clone); if (!cal_client_update_objects (client, priv->top_level)) - dialog = gnome_warning_dialog (_("I couldn't update your calendar file!\n")); + dialog = gnome_warning_dialog (_("Calendar file could not be updated!\n")); else dialog = gnome_ok_dialog (_("Update complete\n")); gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); @@ -946,6 +1003,65 @@ update_item (EItipControl *itip) } static void +update_attendee_status (EItipControl *itip) +{ + EItipControlPrivate *priv; + CalClient *client; + CalClientGetStatus status; + CalComponent *comp; + CalComponentVType type; + const char *uid; + GtkWidget *dialog; + + priv = itip->priv; + + type = cal_component_get_vtype (priv->comp); + if (type == CAL_COMPONENT_TODO) + client = priv->task_client; + else + client = priv->event_client; + + /* Obtain our version */ + cal_component_get_uid (priv->comp, &uid); + status = cal_client_get_object (client, uid, &comp); + + if (status == CAL_CLIENT_GET_SUCCESS) { + GSList *attendees; + + cal_component_get_attendee_list (priv->comp, &attendees); + if (attendees != NULL) { + CalComponentAttendee *a = attendees->data; + icalparameter_partstat partstat; + + partstat = find_attendee_partstat (priv->ical_comp, itip_strip_mailto (a->value)); + + if (partstat != ICAL_PARTSTAT_NONE) { + change_status (cal_component_get_icalcomponent (comp), + itip_strip_mailto (a->value), + partstat); + } else { + dialog = gnome_warning_dialog (_("Attendee status could " + "not be updated because " + "of an invalid status!\n")); + goto cleanup; + } + } + + if (!cal_client_update_object (client, comp)) + dialog = gnome_warning_dialog (_("Attendee status ould not be updated!\n")); + else + dialog = gnome_ok_dialog (_("Attendee status updated\n")); + } else { + dialog = gnome_warning_dialog (_("Attendee status can not be updated " + "because the item no longer exists")); + } + + cleanup: + gtk_object_unref (GTK_OBJECT (comp)); + gnome_dialog_run_and_close (GNOME_DIALOG (dialog)); +} + +static void remove_item (EItipControl *itip) { EItipControlPrivate *priv; @@ -1034,24 +1150,6 @@ send_freebusy (EItipControl *itip) } static void -change_status (EItipControl *itip, gchar *address, icalparameter_partstat status) -{ - EItipControlPrivate *priv; - icalproperty *prop; - - priv = itip->priv; - - prop = find_attendee (priv->ical_comp, address); - if (prop) { - icalparameter *param; - - icalproperty_remove_parameter (prop, ICAL_PARTSTAT_PARAMETER); - param = icalparameter_new_partstat (status); - icalproperty_add_parameter (prop, param); - } -} - -static void prev_clicked_cb (GtkWidget *widget, gpointer data) { EItipControl *itip = E_ITIP_CONTROL (data); @@ -1136,22 +1234,22 @@ ok_clicked_cb (GtkHTML *html, const gchar *method, const gchar *url, const gchar update_item (itip); break; case 'A': - change_status (itip, priv->my_address, ICAL_PARTSTAT_ACCEPTED); + change_status (priv->ical_comp, priv->my_address, ICAL_PARTSTAT_ACCEPTED); update_item (itip); break; case 'T': - change_status (itip, priv->my_address, ICAL_PARTSTAT_TENTATIVE); + change_status (priv->ical_comp, priv->my_address, ICAL_PARTSTAT_TENTATIVE); update_item (itip); break; case 'D': - change_status (itip, priv->my_address, ICAL_PARTSTAT_DECLINED); + change_status (priv->ical_comp, priv->my_address, ICAL_PARTSTAT_DECLINED); update_item (itip); break; case 'F': send_freebusy (itip); break; case 'R': - update_item (itip); + update_attendee_status (itip); break; case 'S': send_item (itip); @@ -1171,6 +1269,45 @@ ok_clicked_cb (GtkHTML *html, const gchar *method, const gchar *url, const gchar } g_strfreev (fields); - if (rsvp) - itip_send_comp (CAL_COMPONENT_METHOD_REPLY, priv->comp); + if (rsvp) { + CalComponent *comp = NULL; + + comp = cal_component_clone (priv->comp); + if (comp == NULL) + return; + + if (priv->my_address != NULL) { + icalcomponent *ical_comp; + icalproperty *prop; + const char *attendee, *text; + icalvalue *value; + + ical_comp = cal_component_get_icalcomponent (comp); + + for (prop = icalcomponent_get_first_property (ical_comp, ICAL_ATTENDEE_PROPERTY); + prop != NULL; + prop = icalcomponent_get_next_property (ical_comp, ICAL_ATTENDEE_PROPERTY)) + { + value = icalproperty_get_value (prop); + if (!value) + continue; + + attendee = icalvalue_get_string (value); + text = itip_strip_mailto (attendee); + + if (!strstr (text, priv->my_address)) { + icalcomponent_remove_property (ical_comp, prop); + icalproperty_free (prop); + } + } + 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)); + } + gtk_object_unref (GTK_OBJECT (comp)); + } } |