aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamon Chaplin <damon@ximian.com>2001-10-25 05:02:43 +0800
committerDamon Chaplin <damon@src.gnome.org>2001-10-25 05:02:43 +0800
commit1c61950527e07b6f0343f0c1a9ecf7d043b7873e (patch)
tree65886d121b33109e53f9c93ece7923bec6c81764
parentbb7d2c44996f10c4e768f0e86d5f894d607f3864 (diff)
downloadgsoc2013-evolution-1c61950527e07b6f0343f0c1a9ecf7d043b7873e.tar.gz
gsoc2013-evolution-1c61950527e07b6f0343f0c1a9ecf7d043b7873e.tar.zst
gsoc2013-evolution-1c61950527e07b6f0343f0c1a9ecf7d043b7873e.zip
when iterating over the subcomponents, use 'subcomp' rather than
2001-10-24 Damon Chaplin <damon@ximian.com> * pcs/cal-backend-file.c (cal_backend_file_update_objects): when iterating over the subcomponents, use 'subcomp' rather than 'icalcomp'. That meant it wasn't working at all well when an entire VCALENDAR was passed in. * cal-util/cal-component.c: handle DURATION property used instead of DTEND or DUE. In cal_component_get_dtend/due we will return DTSTART + DURATION if necessary. In set_dtend/due we remove any DURATION property. Fixes bug #11262. * gui/e-meeting-model.c (build_etable): * gui/e-calendar-table.c (e_calendar_table_init): use U_ for the ECellCombo popdown strings, as it expects UTF-8 strings. svn path=/trunk/; revision=13992
-rw-r--r--calendar/ChangeLog16
-rw-r--r--calendar/cal-util/cal-component.c89
-rw-r--r--calendar/gui/e-calendar-table.c49
-rw-r--r--calendar/gui/e-meeting-model.c35
-rw-r--r--calendar/pcs/cal-backend-file.c4
5 files changed, 150 insertions, 43 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 48b1693825..dc8ba109fe 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,19 @@
+2001-10-24 Damon Chaplin <damon@ximian.com>
+
+ * pcs/cal-backend-file.c (cal_backend_file_update_objects): when
+ iterating over the subcomponents, use 'subcomp' rather than 'icalcomp'.
+ That meant it wasn't working at all well when an entire VCALENDAR
+ was passed in.
+
+ * cal-util/cal-component.c: handle DURATION property used instead of
+ DTEND or DUE. In cal_component_get_dtend/due we will return DTSTART
+ + DURATION if necessary. In set_dtend/due we remove any DURATION
+ property. Fixes bug #11262.
+
+ * gui/e-meeting-model.c (build_etable):
+ * gui/e-calendar-table.c (e_calendar_table_init): use U_ for the
+ ECellCombo popdown strings, as it expects UTF-8 strings.
+
2001-10-24 JP Rosevear <jpr@ximian.com>
* gui/e-meeting-time-sel.c (e_meeting_time_selector_construct):
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c
index 58e1d4a945..7750bb224f 100644
--- a/calendar/cal-util/cal-component.c
+++ b/calendar/cal-util/cal-component.c
@@ -88,6 +88,13 @@ struct _CalComponentPrivate {
icalproperty *dtstamp;
+ /* The DURATION property can be used instead of the VEVENT DTEND or
+ the VTODO DUE dates. We do not use it directly ourselves, but we
+ must be able to handle it from incoming data. If a DTEND or DUE
+ is requested, we convert the DURATION if necessary. If DTEND or
+ DUE is set, we remove any DURATION. */
+ icalproperty *duration;
+
struct datetime due;
GSList *exdate_list; /* list of struct datetime */
@@ -306,6 +313,8 @@ free_icalcomponent (CalComponent *comp, gboolean free)
priv->due.prop = NULL;
priv->due.tzid_param = NULL;
+ priv->duration = NULL;
+
priv->exdate_list = free_slist (priv->exdate_list);
g_slist_free (priv->exrule_list);
@@ -633,6 +642,10 @@ scan_property (CalComponent *comp, icalproperty *prop)
scan_datetime (comp, &priv->due, prop);
break;
+ case ICAL_DURATION_PROPERTY:
+ priv->duration = prop;
+ break;
+
case ICAL_EXDATE_PROPERTY:
scan_exdate (comp, prop);
break;
@@ -1971,6 +1984,54 @@ set_datetime (CalComponent *comp, struct datetime *datetime,
}
}
+
+/* This tries to get the DTSTART + DURATION for a VEVENT or VTODO. In a
+ VEVENT this is used for the DTEND if no DTEND exists, In a VTOTO it is
+ used for the DUE date if DUE doesn't exist. */
+static void
+cal_component_get_start_plus_duration (CalComponent *comp,
+ CalComponentDateTime *dt)
+{
+ CalComponentPrivate *priv;
+ struct icaldurationtype duration;
+
+ priv = comp->priv;
+
+ if (!priv->duration)
+ return;
+
+ /* Get the DTSTART time. */
+ get_datetime (&priv->dtstart, icalproperty_get_dtstart, dt);
+ if (!dt->value)
+ return;
+
+ duration = icalproperty_get_duration (priv->duration);
+
+ /* The DURATION shouldn't be negative, but just return DTSTART if it
+ is, i.e. assume it is 0. */
+ if (duration.is_neg)
+ return;
+
+ /* If DTSTART is a DATE value, then we need to check if the DURATION
+ includes any hours, minutes or seconds. If it does, we need to
+ make the DTEND/DUE a DATE-TIME value. If not, we need to subtract
+ one from the days, since the end date will be inclusive. */
+ duration.days += duration.weeks * 7;
+ if (dt->value->is_date) {
+ if (duration.hours != 0 || duration.minutes != 0
+ || duration.seconds != 0) {
+ dt->value->is_date = 0;
+ } else {
+ duration.days--;
+ }
+ }
+
+ /* Add on the DURATION. */
+ icaltime_adjust (dt->value, duration.days, duration.hours,
+ duration.minutes, duration.seconds);
+}
+
+
/**
* cal_component_get_dtend:
* @comp: A calendar component object.
@@ -1992,6 +2053,11 @@ cal_component_get_dtend (CalComponent *comp, CalComponentDateTime *dt)
g_return_if_fail (priv->icalcomp != NULL);
get_datetime (&priv->dtend, icalproperty_get_dtend, dt);
+
+ /* If we don't have a DTEND property, then we try to get DTSTART
+ + DURATION. */
+ if (!dt->value)
+ cal_component_get_start_plus_duration (comp, dt);
}
/**
@@ -2017,6 +2083,15 @@ cal_component_set_dtend (CalComponent *comp, CalComponentDateTime *dt)
icalproperty_set_dtend,
dt);
+ /* Make sure we remove any existing DURATION property, as it can't be
+ used with a DTEND. If DTEND is set to NULL, i.e. removed, we also
+ want to remove any DURATION. */
+ if (priv->duration) {
+ icalcomponent_remove_property (priv->icalcomp, priv->duration);
+ icalproperty_free (priv->duration);
+ priv->duration = NULL;
+ }
+
priv->need_sequence_inc = TRUE;
}
@@ -2143,6 +2218,11 @@ cal_component_get_due (CalComponent *comp, CalComponentDateTime *dt)
g_return_if_fail (priv->icalcomp != NULL);
get_datetime (&priv->due, icalproperty_get_due, dt);
+
+ /* If we don't have a DTEND property, then we try to get DTSTART
+ + DURATION. */
+ if (!dt->value)
+ cal_component_get_start_plus_duration (comp, dt);
}
/**
@@ -2168,6 +2248,15 @@ cal_component_set_due (CalComponent *comp, CalComponentDateTime *dt)
icalproperty_set_due,
dt);
+ /* Make sure we remove any existing DURATION property, as it can't be
+ used with a DTEND. If DTEND is set to NULL, i.e. removed, we also
+ want to remove any DURATION. */
+ if (priv->duration) {
+ icalcomponent_remove_property (priv->icalcomp, priv->duration);
+ icalproperty_free (priv->duration);
+ priv->duration = NULL;
+ }
+
priv->need_sequence_inc = TRUE;
}
diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c
index 9002811f09..46516db8a8 100644
--- a/calendar/gui/e-calendar-table.c
+++ b/calendar/gui/e-calendar-table.c
@@ -41,6 +41,7 @@
#include <gal/widgets/e-popup-menu.h>
#include <widgets/misc/e-cell-date-edit.h>
#include <widgets/misc/e-cell-percent.h>
+#include <e-util/e-unicode-i18n.h>
#include "e-calendar-table.h"
#include "e-cell-date-edit-text.h"
#include "calendar-config.h"
@@ -382,9 +383,9 @@ e_calendar_table_init (ECalendarTable *cal_table)
gtk_object_unref (GTK_OBJECT (cell));
strings = NULL;
- strings = g_list_append (strings, _("Public"));
- strings = g_list_append (strings, _("Private"));
- strings = g_list_append (strings, _("Confidential"));
+ strings = g_list_append (strings, (char*) U_("Public"));
+ strings = g_list_append (strings, (char*) U_("Private"));
+ strings = g_list_append (strings, (char*) U_("Confidential"));
e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell),
strings);
@@ -404,10 +405,10 @@ e_calendar_table_init (ECalendarTable *cal_table)
gtk_object_unref (GTK_OBJECT (cell));
strings = NULL;
- strings = g_list_append (strings, _("High"));
- strings = g_list_append (strings, _("Normal"));
- strings = g_list_append (strings, _("Low"));
- strings = g_list_append (strings, _("Undefined"));
+ strings = g_list_append (strings, (char*) U_("High"));
+ strings = g_list_append (strings, (char*) U_("Normal"));
+ strings = g_list_append (strings, (char*) U_("Low"));
+ strings = g_list_append (strings, (char*) U_("Undefined"));
e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell),
strings);
@@ -426,17 +427,17 @@ e_calendar_table_init (ECalendarTable *cal_table)
gtk_object_unref (GTK_OBJECT (cell));
strings = NULL;
- strings = g_list_append (strings, _("0%"));
- strings = g_list_append (strings, _("10%"));
- strings = g_list_append (strings, _("20%"));
- strings = g_list_append (strings, _("30%"));
- strings = g_list_append (strings, _("40%"));
- strings = g_list_append (strings, _("50%"));
- strings = g_list_append (strings, _("60%"));
- strings = g_list_append (strings, _("70%"));
- strings = g_list_append (strings, _("80%"));
- strings = g_list_append (strings, _("90%"));
- strings = g_list_append (strings, _("100%"));
+ strings = g_list_append (strings, (char*) U_("0%"));
+ strings = g_list_append (strings, (char*) U_("10%"));
+ strings = g_list_append (strings, (char*) U_("20%"));
+ strings = g_list_append (strings, (char*) U_("30%"));
+ strings = g_list_append (strings, (char*) U_("40%"));
+ strings = g_list_append (strings, (char*) U_("50%"));
+ strings = g_list_append (strings, (char*) U_("60%"));
+ strings = g_list_append (strings, (char*) U_("70%"));
+ strings = g_list_append (strings, (char*) U_("80%"));
+ strings = g_list_append (strings, (char*) U_("90%"));
+ strings = g_list_append (strings, (char*) U_("100%"));
e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell),
strings);
@@ -456,8 +457,8 @@ e_calendar_table_init (ECalendarTable *cal_table)
gtk_object_unref (GTK_OBJECT (cell));
strings = NULL;
- strings = g_list_append (strings, _("Free"));
- strings = g_list_append (strings, _("Busy"));
+ strings = g_list_append (strings, (char*) U_("Free"));
+ strings = g_list_append (strings, (char*) U_("Busy"));
e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell),
strings);
@@ -477,10 +478,10 @@ e_calendar_table_init (ECalendarTable *cal_table)
gtk_object_unref (GTK_OBJECT (cell));
strings = NULL;
- strings = g_list_append (strings, _("Not Started"));
- strings = g_list_append (strings, _("In Progress"));
- strings = g_list_append (strings, _("Completed"));
- strings = g_list_append (strings, _("Cancelled"));
+ strings = g_list_append (strings, (char*) U_("Not Started"));
+ strings = g_list_append (strings, (char*) U_("In Progress"));
+ strings = g_list_append (strings, (char*) U_("Completed"));
+ strings = g_list_append (strings, (char*) U_("Cancelled"));
e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell),
strings);
diff --git a/calendar/gui/e-meeting-model.c b/calendar/gui/e-meeting-model.c
index 24e8913431..d0d877e133 100644
--- a/calendar/gui/e-meeting-model.c
+++ b/calendar/gui/e-meeting-model.c
@@ -43,6 +43,7 @@
#include <e-card.h>
#include <e-card-simple.h>
#include <e-destination.h>
+#include <e-util/e-unicode-i18n.h>
#include <cal-util/cal-component.h>
#include <cal-util/cal-util.h>
#include <cal-util/timeutil.h>
@@ -684,11 +685,11 @@ build_etable (ETableModel *model, const gchar *spec_file, const gchar *state_fil
gtk_object_unref (GTK_OBJECT (cell));
strings = NULL;
- strings = g_list_append (strings, _("Individual"));
- strings = g_list_append (strings, _("Group"));
- strings = g_list_append (strings, _("Resource"));
- strings = g_list_append (strings, _("Room"));
- strings = g_list_append (strings, _("Unknown"));
+ strings = g_list_append (strings, (char*) U_("Individual"));
+ strings = g_list_append (strings, (char*) U_("Group"));
+ strings = g_list_append (strings, (char*) U_("Resource"));
+ strings = g_list_append (strings, (char*) U_("Room"));
+ strings = g_list_append (strings, (char*) U_("Unknown"));
e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), strings);
e_table_extras_add_cell (extras, "typeedit", popup_cell);
@@ -700,11 +701,11 @@ build_etable (ETableModel *model, const gchar *spec_file, const gchar *state_fil
gtk_object_unref (GTK_OBJECT (cell));
strings = NULL;
- strings = g_list_append (strings, _("Chair"));
- strings = g_list_append (strings, _("Required Participant"));
- strings = g_list_append (strings, _("Optional Participant"));
- strings = g_list_append (strings, _("Non-Participant"));
- strings = g_list_append (strings, _("Unknown"));
+ strings = g_list_append (strings, (char*) U_("Chair"));
+ strings = g_list_append (strings, (char*) U_("Required Participant"));
+ strings = g_list_append (strings, (char*) U_("Optional Participant"));
+ strings = g_list_append (strings, (char*) U_("Non-Participant"));
+ strings = g_list_append (strings, (char*) U_("Unknown"));
e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), strings);
e_table_extras_add_cell (extras, "roleedit", popup_cell);
@@ -716,8 +717,8 @@ build_etable (ETableModel *model, const gchar *spec_file, const gchar *state_fil
gtk_object_unref (GTK_OBJECT (cell));
strings = NULL;
- strings = g_list_append (strings, _("Yes"));
- strings = g_list_append (strings, _("No"));
+ strings = g_list_append (strings, (char*) U_("Yes"));
+ strings = g_list_append (strings, (char*) U_("No"));
e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), strings);
e_table_extras_add_cell (extras, "rsvpedit", popup_cell);
@@ -729,11 +730,11 @@ build_etable (ETableModel *model, const gchar *spec_file, const gchar *state_fil
gtk_object_unref (GTK_OBJECT (cell));
strings = NULL;
- strings = g_list_append (strings, _("Needs Action"));
- strings = g_list_append (strings, _("Accepted"));
- strings = g_list_append (strings, _("Declined"));
- strings = g_list_append (strings, _("Tentative"));
- strings = g_list_append (strings, _("Delegated"));
+ strings = g_list_append (strings, (char*) U_("Needs Action"));
+ strings = g_list_append (strings, (char*) U_("Accepted"));
+ strings = g_list_append (strings, (char*) U_("Declined"));
+ strings = g_list_append (strings, (char*) U_("Tentative"));
+ strings = g_list_append (strings, (char*) U_("Delegated"));
e_cell_combo_set_popdown_strings (E_CELL_COMBO (popup_cell), strings);
e_table_extras_add_cell (extras, "statusedit", popup_cell);
diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c
index adf323023a..139db949f8 100644
--- a/calendar/pcs/cal-backend-file.c
+++ b/calendar/pcs/cal-backend-file.c
@@ -1751,14 +1751,14 @@ cal_backend_file_update_objects (CalBackend *backend, const char *calobj)
while (subcomp) {
/* We ignore anything except VEVENT, VTODO and VJOURNAL
components. */
- icalcomponent_kind child_kind = icalcomponent_isa (icalcomp);
+ icalcomponent_kind child_kind = icalcomponent_isa (subcomp);
if (child_kind == ICAL_VEVENT_COMPONENT
|| child_kind == ICAL_VTODO_COMPONENT
|| child_kind == ICAL_VJOURNAL_COMPONENT) {
const char *comp_uid;
comp_uid = cal_backend_file_update_object (cbfile,
- icalcomp);
+ subcomp);
if (comp_uid) {
/* We add a copy of the UID to a list, so we
can emit notification signals later. We do