diff options
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/Makefile.am | 2 | ||||
-rw-r--r-- | calendar/gui/e-itip-control.c | 165 | ||||
-rw-r--r-- | calendar/gui/e-meeting-edit.c | 36 | ||||
-rw-r--r-- | calendar/gui/itip-utils.c | 49 | ||||
-rw-r--r-- | calendar/gui/itip-utils.h | 16 |
5 files changed, 220 insertions, 48 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 9a4c7a300e..5b44d76f70 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -105,6 +105,8 @@ evolution_calendar_SOURCES = \ gnome-month-item.c \ gnome-month-item.h \ goto.c \ + itip-utils.c \ + itip-utils.h \ main.c \ mark.c \ mark.h \ diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c index 5d4ca06a74..6c9ae51509 100644 --- a/calendar/gui/e-itip-control.c +++ b/calendar/gui/e-itip-control.c @@ -20,6 +20,7 @@ #include "e-itip-control.h" #include <cal-util/cal-component.h> #include <cal-client/cal-client.h> +#include "itip-utils.h" #define DEFAULT_WIDTH 400 @@ -46,6 +47,7 @@ struct _EItipControlPrivate { CalComponent *cal_comp; char *vcalendar; gchar *from_address, *my_address, *organizer; + icalparameter_partstat new_partstat; }; enum E_ITIP_BONOBO_ARGS { @@ -53,18 +55,6 @@ enum E_ITIP_BONOBO_ARGS { MY_ADDRESS_ARG_ID }; -static icalparameter * -get_icalparam_by_type (icalproperty *prop, icalparameter_kind kind) -{ - icalparameter *param; - - for (param = icalproperty_get_first_parameter (prop, ICAL_ANY_PARAMETER); - param != NULL && icalparameter_isa (param) != kind; - param = icalproperty_get_next_parameter (prop, ICAL_ANY_PARAMETER) ); - - return param; -} - /******** * find_attendee() searches through the attendee properties of `comp' @@ -184,7 +174,7 @@ update_calendar (EItipControlPrivate *priv) gchar cal_uri[255]; CalClient *client; - sprintf (cal_uri, "%s/local/Calendar/calendar.ics", evolution_dir); + snprintf (cal_uri, 250, "%s/local/Calendar/calendar.ics", evolution_dir); client = cal_client_new (); if (cal_client_load_calendar (client, cal_uri) == FALSE) { @@ -380,6 +370,114 @@ accept_button_clicked_cb (GtkWidget *widget, gpointer data) return; } +static void +tentative_button_clicked_cb (GtkWidget *widget, gpointer data) +{ + EItipControlPrivate *priv = data; + + change_my_status (ICAL_PARTSTAT_TENTATIVE, priv); + send_itip_reply (priv); + update_calendar (priv); + + return; +} + +static void +decline_button_clicked_cb (GtkWidget *widget, gpointer data) +{ + EItipControlPrivate *priv = data; + + change_my_status (ICAL_PARTSTAT_DECLINED, priv); + send_itip_reply (priv); + + return; +} + +static void +update_reply_cb (GtkWidget *widget, gpointer data) +{ + EItipControlPrivate *priv = data; + CalClient *cal_client; + CalComponent *cal_comp; + icalcomponent *comp; + icalproperty *prop; + icalparameter *param; + const char *uid; + char cal_uri[255]; + + + /* First we must load our calendar object from the calendar store. */ + snprintf (cal_uri, 250, "%s/local/Calendar/calendar.ics", evolution_dir); + + cal_client = cal_client_new (); + if (cal_client_load_calendar (cal_client, cal_uri) == FALSE) { + GtkWidget *dialog; + + dialog = gnome_warning_dialog("I couldn't open your calendar file!\n"); + gnome_dialog_run (GNOME_DIALOG(dialog)); + gtk_object_unref (GTK_OBJECT (cal_client)); + + return; + } + + while (!cal_client_is_loaded (cal_client)) { + usleep (200000L); /* Pause for 1/5th of a second before checking again.*/ + } + + cal_component_get_uid (priv->cal_comp, &uid); + if (cal_client_get_object (cal_client, uid, &cal_comp) != CAL_CLIENT_GET_SUCCESS) { + GtkWidget *dialog; + + dialog = gnome_warning_dialog("I couldn't read your calendar file!\n"); + gnome_dialog_run (GNOME_DIALOG(dialog)); + gtk_object_unref (GTK_OBJECT (cal_client)); + + return; + } + + comp = cal_component_get_icalcomponent (cal_comp); + + prop = find_attendee (comp, priv->from_address); + if (!prop) { + GtkWidget *dialog; + + dialog = gnome_warning_dialog("This is a reply from someone who was uninvited!"); + gnome_dialog_run (GNOME_DIALOG(dialog)); + gtk_object_unref (GTK_OBJECT (cal_client)); + gtk_object_unref (GTK_OBJECT (cal_comp)); + + return; + } + + icalproperty_remove_parameter (prop, ICAL_PARTSTAT_PARAMETER); + param = icalparameter_new_partstat (priv->new_partstat); + icalproperty_add_parameter (prop, param); + + /* Now we need to update the object in the calendar store. */ + if (!cal_client_update_object (cal_client, cal_comp)) { + GtkWidget *dialog; + + dialog = gnome_warning_dialog("I couldn't update your calendar store."); + gnome_dialog_run (GNOME_DIALOG(dialog)); + gtk_object_unref (GTK_OBJECT (cal_client)); + gtk_object_unref (GTK_OBJECT (cal_comp)); + + return; + } + else { + /* We have success. */ + GtkWidget *dialog; + + dialog = gnome_ok_dialog("Component successfully updated."); + gnome_dialog_run (GNOME_DIALOG(dialog)); + } + + + gtk_object_unref (GTK_OBJECT (cal_client)); + gtk_object_unref (GTK_OBJECT (cal_comp)); +} + + /* * Bonobo::PersistStream * @@ -644,6 +742,10 @@ pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream, gtk_signal_connect (GTK_OBJECT (accept_button), "clicked", GTK_SIGNAL_FUNC (accept_button_clicked_cb), priv); + gtk_signal_connect (GTK_OBJECT (tentative_button), "clicked", + GTK_SIGNAL_FUNC (tentative_button_clicked_cb), priv); + gtk_signal_connect (GTK_OBJECT (decline_button), "clicked", + GTK_SIGNAL_FUNC (decline_button_clicked_cb), priv); gtk_widget_show (accept_button); gtk_widget_show (decline_button); @@ -652,6 +754,43 @@ pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream, } break; + case ICAL_METHOD_REPLY: + { + icalproperty *prop; + icalparameter *param; + gboolean success = FALSE; + + prop = find_attendee (priv->comp, priv->from_address); + if (prop) { + param = get_icalparam_by_type (prop, ICAL_PARTSTAT_PARAMETER); + if (param) { + success = TRUE; + + priv->new_partstat = icalparameter_get_partstat (param); + } + } + + if (!success) { + sprintf (message, "%s sent a reply to a meeting request, but " + "the reply is not properly formed.", + priv->from_address); + } + else { + GtkWidget *button; + + button = gtk_button_new_with_label ("Update Calendar"); + gtk_box_pack_start (GTK_BOX (priv->button_box), button, FALSE, FALSE, 3); + gtk_widget_show (button); + + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (update_reply_cb), priv); + + sprintf (message, "%s responded to your request, replying with: %s", + priv->from_address, partstat_values[priv->new_partstat]); + } + + } + break; default: sprintf (message, "I haven't the slightest notion what this calendar " "object represents. Sorry."); diff --git a/calendar/gui/e-meeting-edit.c b/calendar/gui/e-meeting-edit.c index daf5c73035..6d72ea2c66 100644 --- a/calendar/gui/e-meeting-edit.c +++ b/calendar/gui/e-meeting-edit.c @@ -28,6 +28,7 @@ #include <Evolution-Composer.h> #include <string.h> #include "e-meeting-edit.h" +#include "itip-utils.h" #define E_MEETING_GLADE_XML "e-meeting-dialog.glade" @@ -63,41 +64,6 @@ struct _EMeetingEditorPrivate { enum column_names {ADDRESS_COL, ROLE_COL, RSVP_COL, STATUS_COL}; -static gchar *partstat_values[] = { - "Needs action", - "Accepted", - "Declined", - "Tentative", - "Delegated", - "Completed", - "In Progress", - "Unknown" -}; - -static gchar *role_values[] = { - "Chair", - "Required Participant", - "Optional Participant", - "Non-Participant", - "Other" -}; - - -/* Note that I have to iterate and check myself because - ical_property_get_xxx_parameter doesn't take into account the - kind of parameter for which you wish to search! */ -static icalparameter * -get_icalparam_by_type (icalproperty *prop, icalparameter_kind kind) -{ - icalparameter *param; - - for (param = icalproperty_get_first_parameter (prop, ICAL_ANY_PARAMETER); - param != NULL && icalparameter_isa (param) != kind; - param = icalproperty_get_next_parameter (prop, ICAL_ANY_PARAMETER) ); - - return param; -} - static void save_organizer (EMeetingEditorPrivate *priv) diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c new file mode 100644 index 0000000000..f090f051d6 --- /dev/null +++ b/calendar/gui/itip-utils.c @@ -0,0 +1,49 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * itip-utils.c + * + * Authors: + * Jesse Pavel <jpavel@helixcode.com> + * + * Copyright 2000, Helix Code, Inc. + */ + +#include "itip-utils.h" + +gchar *partstat_values[] = { + "Needs action", + "Accepted", + "Declined", + "Tentative", + "Delegated", + "Completed", + "In Progress", + "Unknown" +}; + +gchar *role_values[] = { + "Chair", + "Required Participant", + "Optional Participant", + "Non-Participant", + "Other" +}; + + + +/* Note that I have to iterate and check myself because + ical_property_get_xxx_parameter doesn't take into account the + kind of parameter for which you wish to search! */ +icalparameter * +get_icalparam_by_type (icalproperty *prop, icalparameter_kind kind) +{ + icalparameter *param; + + for (param = icalproperty_get_first_parameter (prop, ICAL_ANY_PARAMETER); + param != NULL && icalparameter_isa (param) != kind; + param = icalproperty_get_next_parameter (prop, ICAL_ANY_PARAMETER) ); + + return param; +} + + diff --git a/calendar/gui/itip-utils.h b/calendar/gui/itip-utils.h new file mode 100644 index 0000000000..0d2b073e4f --- /dev/null +++ b/calendar/gui/itip-utils.h @@ -0,0 +1,16 @@ + +#ifndef ITIP_UTILS_HEADER +#define ITIP_UTILS_HEADER + +#include <config.h> +#include <icaltypes.h> +#include <ical.h> +#include <string.h> +#include <gnome.h> + +extern gchar *partstat_values[]; +extern gchar *role_values[]; + +icalparameter * get_icalparam_by_type (icalproperty *prop, icalparameter_kind kind); + +#endif |