aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/itip-formatter
diff options
context:
space:
mode:
authorJP Rosevear <jpr@novell.com>2005-01-10 11:54:42 +0800
committerJP Rosevear <jpr@src.gnome.org>2005-01-10 11:54:42 +0800
commitbb2c3ad2ddb1bb73e952a7cf7c4783bb83f6370f (patch)
tree8371b838a277e81d1756b4c00ccca2109cd76e1b /plugins/itip-formatter
parent884bc8d16329b4b2c197bba627aca7e8e1e32a06 (diff)
downloadgsoc2013-evolution-bb2c3ad2ddb1bb73e952a7cf7c4783bb83f6370f.tar.gz
gsoc2013-evolution-bb2c3ad2ddb1bb73e952a7cf7c4783bb83f6370f.tar.zst
gsoc2013-evolution-bb2c3ad2ddb1bb73e952a7cf7c4783bb83f6370f.zip
remove error mode
2005-01-09 JP Rosevear <jpr@novell.com> * itip-view.h: remove error mode * itip-formatter.c (set_itip_error): show error information to the user (extract_itip_data): use above (format_itip_object): no more "error" mode svn path=/trunk/; revision=28306
Diffstat (limited to 'plugins/itip-formatter')
-rw-r--r--plugins/itip-formatter/ChangeLog9
-rw-r--r--plugins/itip-formatter/itip-formatter.c76
-rw-r--r--plugins/itip-formatter/itip-view.h3
3 files changed, 64 insertions, 24 deletions
diff --git a/plugins/itip-formatter/ChangeLog b/plugins/itip-formatter/ChangeLog
index cc5b9bbea1..e22d9eba59 100644
--- a/plugins/itip-formatter/ChangeLog
+++ b/plugins/itip-formatter/ChangeLog
@@ -1,5 +1,14 @@
2005-01-09 JP Rosevear <jpr@novell.com>
+ * itip-view.h: remove error mode
+
+ * itip-formatter.c (set_itip_error): show error information to the
+ user
+ (extract_itip_data): use above
+ (format_itip_object): no more "error" mode
+
+2005-01-09 JP Rosevear <jpr@novell.com>
+
* itip-view.c (itip_view_set_delegator): accessor
(itip_view_get_delegator): ditto
diff --git a/plugins/itip-formatter/itip-formatter.c b/plugins/itip-formatter/itip-formatter.c
index fa1ed343e5..ac4322d374 100644
--- a/plugins/itip-formatter/itip-formatter.c
+++ b/plugins/itip-formatter/itip-formatter.c
@@ -831,7 +831,32 @@ get_next (icalcompiter *iter)
}
static void
-extract_itip_data (FormatItipPObject *pitip)
+set_itip_error (FormatItipPObject *pitip, GtkContainer *container, const char *primary, const char *secondary)
+{
+ GtkWidget *vbox, *label;
+ char *message;
+
+ vbox = gtk_vbox_new (FALSE, 12);
+ gtk_widget_show (vbox);
+
+ message = g_strdup_printf ("<b>%s</b>", primary);
+ label = gtk_label_new (NULL);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_label_set_markup (GTK_LABEL (label), message);
+ g_free (message);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ label = gtk_label_new (secondary);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+
+ gtk_container_add (container, vbox);
+}
+
+static gboolean
+extract_itip_data (FormatItipPObject *pitip, GtkContainer *container)
{
CamelDataWrapper *content;
CamelStream *mem;
@@ -854,10 +879,13 @@ extract_itip_data (FormatItipPObject *pitip)
pitip->main_comp = icalparser_parse_string (pitip->vcalendar);
if (pitip->main_comp == NULL) {
-// write_error_html (itip, _("The attachment does not contain a valid calendar message"));
- return;
- }
+ set_itip_error (pitip, container,
+ _("The calendar attached is not valid"),
+ _("The message claims to contain a calendar, but the calendar is not valid iCalendar."));
+ return FALSE;
+ }
+
prop = icalcomponent_get_first_property (pitip->main_comp, ICAL_METHOD_PROPERTY);
if (prop == NULL) {
pitip->method = ICAL_METHOD_PUBLISH;
@@ -886,10 +914,13 @@ extract_itip_data (FormatItipPObject *pitip)
}
if (pitip->ical_comp == NULL) {
-// write_error_html (itip, _("The attachment has no viewable calendar items"));
- return;
- }
+ set_itip_error (pitip, container,
+ _("The item in the calendar is not valid"),
+ _("The message does contain a calendar, but the calendar contains no events, tasks or free/busy information"));
+ return FALSE;
+ }
+
pitip->total = icalcomponent_count_components (pitip->main_comp, ICAL_VEVENT_COMPONENT);
pitip->total += icalcomponent_count_components (pitip->main_comp, ICAL_VTODO_COMPONENT);
pitip->total += icalcomponent_count_components (pitip->main_comp, ICAL_VFREEBUSY_COMPONENT);
@@ -929,10 +960,14 @@ extract_itip_data (FormatItipPObject *pitip)
pitip->comp = e_cal_component_new ();
if (!e_cal_component_set_icalcomponent (pitip->comp, pitip->ical_comp)) {
-// write_error_html (itip, _("The message does not appear to be properly formed"));
g_object_unref (pitip->comp);
pitip->comp = NULL;
- return;
+
+ set_itip_error (pitip, container,
+ _("The item in the calendar is not valid"),
+ _("The message does contain a calendar, but the calendar contains no events, tasks or free/busy information"));
+
+ return FALSE;
};
/* Add default reminder if the config says so */
@@ -975,6 +1010,8 @@ extract_itip_data (FormatItipPObject *pitip)
}
find_my_address (pitip, pitip->ical_comp, NULL);
+
+ return TRUE;
}
static gboolean
@@ -1150,13 +1187,14 @@ format_itip_object (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject
/* Initialize the ecal hashes */
pitip->ecals[i] = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, cleanup_ecal);
- }
-
- /* FIXME Error handling? */
+ }
+
/* FIXME Handle multiple VEVENTS with the same UID, ie detached instances */
- extract_itip_data (pitip);
+ if (!extract_itip_data (pitip, GTK_CONTAINER (eb)))
+ return TRUE;
pitip->view = itip_view_new ();
+ gtk_container_add (GTK_CONTAINER (eb), pitip->view);
gtk_widget_show (pitip->view);
switch (pitip->method) {
@@ -1185,8 +1223,8 @@ format_itip_object (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject
itip_view_set_mode (ITIP_VIEW (pitip->view), ITIP_VIEW_MODE_DECLINECOUNTER);
break;
default:
- /* FIXME What to do here? */
- itip_view_set_mode (ITIP_VIEW (pitip->view), ITIP_VIEW_MODE_ERROR);
+ g_assert_not_reached ();
+ break;
}
itip_view_set_item_type (ITIP_VIEW (pitip->view), pitip->type);
@@ -1227,8 +1265,7 @@ format_itip_object (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject
}
break;
default:
- /* FIXME What to do here? */
- itip_view_set_mode (ITIP_VIEW (pitip->view), ITIP_VIEW_MODE_ERROR);
+ g_assert_not_reached ();
break;
}
@@ -1351,8 +1388,6 @@ format_itip_object (EMFormatHTML *efh, GtkHTMLEmbedded *eb, EMFormatHTMLPObject
break;
}
}
-
- gtk_container_add (GTK_CONTAINER (eb), pitip->view);
g_signal_connect (pitip->view, "response", G_CALLBACK (view_response_cb), pitip);
@@ -1388,9 +1423,6 @@ pitip_free (EMFormatHTMLPObject *pobject)
}
pitip->ical_comp = NULL;
- pitip->current = 0;
- pitip->total = 0;
-
g_free (pitip->calendar_uid);
pitip->calendar_uid = NULL;
diff --git a/plugins/itip-formatter/itip-view.h b/plugins/itip-formatter/itip-view.h
index 5e921a97d7..a8605a9564 100644
--- a/plugins/itip-formatter/itip-view.h
+++ b/plugins/itip-formatter/itip-view.h
@@ -52,8 +52,7 @@ typedef enum {
ITIP_VIEW_MODE_ADD,
ITIP_VIEW_MODE_REPLY,
ITIP_VIEW_MODE_REFRESH,
- ITIP_VIEW_MODE_CANCEL,
- ITIP_VIEW_MODE_ERROR
+ ITIP_VIEW_MODE_CANCEL
} ItipViewMode;
typedef enum {