aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/e-itip-control.c
diff options
context:
space:
mode:
authorJesse Pavel <jpavel@src.gnome.org>2000-11-14 08:26:12 +0800
committerJesse Pavel <jpavel@src.gnome.org>2000-11-14 08:26:12 +0800
commitc633a80c1e353f8c56e6a97bd8996a33fbf3b384 (patch)
treece4f19dc68dd941e8865a827e71bf96537b7845a /calendar/gui/e-itip-control.c
parent4bc4ee63bea0b2eaa1215be0df33f454a2918f37 (diff)
downloadgsoc2013-evolution-c633a80c1e353f8c56e6a97bd8996a33fbf3b384.tar.gz
gsoc2013-evolution-c633a80c1e353f8c56e6a97bd8996a33fbf3b384.tar.zst
gsoc2013-evolution-c633a80c1e353f8c56e6a97bd8996a33fbf3b384.zip
I created this file to store some commonly used enumeration to string
* gui/itip-utils.[ch]: I created this file to store some commonly used enumeration to string mappings and functions. * gui/Makefile.am: this was changed to reflect the addition of the above file. * gui/e-itip-control.c: added code to take action on a REPLY message. * gui/e-meeting-edit.c: bug fixes. svn path=/trunk/; revision=6566
Diffstat (limited to 'calendar/gui/e-itip-control.c')
-rw-r--r--calendar/gui/e-itip-control.c165
1 files changed, 152 insertions, 13 deletions
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.");