aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorDamon Chaplin <damon@ximian.com>2001-07-03 14:06:18 +0800
committerDamon Chaplin <damon@src.gnome.org>2001-07-03 14:06:18 +0800
commit2c95c4d8e9f237bc2428b05d976d01241d3394ba (patch)
treeb6f880580e7fef54fb777c1981cad63f463c530c /calendar
parenteb52ee5a862b132e6c0655cd44b5887d64ead3ca (diff)
downloadgsoc2013-evolution-2c95c4d8e9f237bc2428b05d976d01241d3394ba.tar
gsoc2013-evolution-2c95c4d8e9f237bc2428b05d976d01241d3394ba.tar.gz
gsoc2013-evolution-2c95c4d8e9f237bc2428b05d976d01241d3394ba.tar.bz2
gsoc2013-evolution-2c95c4d8e9f237bc2428b05d976d01241d3394ba.tar.lz
gsoc2013-evolution-2c95c4d8e9f237bc2428b05d976d01241d3394ba.tar.xz
gsoc2013-evolution-2c95c4d8e9f237bc2428b05d976d01241d3394ba.tar.zst
gsoc2013-evolution-2c95c4d8e9f237bc2428b05d976d01241d3394ba.zip
added virtual method to get a VTIMEZONE component given a TZID. We need
2001-07-03 Damon Chaplin <damon@ximian.com> * pcs/cal-backend.[hc]: added virtual method to get a VTIMEZONE component given a TZID. We need this to resolve TZIDs when expanding an event using cal_recur_generate_instances() in query.c. * pcs/cal-backend-file.c (cal_backend_file_get_timezone): implemented virtual method. (cal_backend_file_update_object): fixed bug, kind -> child_kind. * pcs/query.c (func_occur_in_time_range): use the virtual method for resolving TZIDs. The other way didn't work anyway, as we didn't have the entire VCALENDAR with VTIMEZONEs in it. * gui/dialogs/recurrence-page.c (init_widgets): (make_ending_until_special): moved the call to e_date_edit_set_get_time_callback() from init_widgets to make_ending_until_special(), since that is where the widget gets created. * gui/e-timezone-entry.c (e_timezone_entry_set_timezone): handle zone being NULL. svn path=/trunk/; revision=10732
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog23
-rw-r--r--calendar/gui/dialogs/recurrence-page.c9
-rw-r--r--calendar/gui/e-timezone-entry.c2
-rw-r--r--calendar/pcs/cal-backend-file.c33
-rw-r--r--calendar/pcs/cal-backend.c25
-rw-r--r--calendar/pcs/cal-backend.h5
-rw-r--r--calendar/pcs/query.c21
7 files changed, 96 insertions, 22 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 9498fa1cc7..58e7050336 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,26 @@
+2001-07-03 Damon Chaplin <damon@ximian.com>
+
+ * pcs/cal-backend.[hc]: added virtual method to get a VTIMEZONE
+ component given a TZID. We need this to resolve TZIDs when expanding
+ an event using cal_recur_generate_instances() in query.c.
+
+ * pcs/cal-backend-file.c (cal_backend_file_get_timezone): implemented
+ virtual method.
+ (cal_backend_file_update_object): fixed bug, kind -> child_kind.
+
+ * pcs/query.c (func_occur_in_time_range): use the virtual method for
+ resolving TZIDs. The other way didn't work anyway, as we didn't have
+ the entire VCALENDAR with VTIMEZONEs in it.
+
+ * gui/dialogs/recurrence-page.c (init_widgets):
+ (make_ending_until_special): moved the call to
+ e_date_edit_set_get_time_callback() from init_widgets to
+ make_ending_until_special(), since that is where the widget gets
+ created.
+
+ * gui/e-timezone-entry.c (e_timezone_entry_set_timezone): handle zone
+ being NULL.
+
2001-07-02 Federico Mena Quintero <federico@ximian.com>
* gui/dialogs/alarm-options.[ch]: New files with the alarm options
diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c
index 4023cd6b5a..a8961fef7b 100644
--- a/calendar/gui/dialogs/recurrence-page.c
+++ b/calendar/gui/dialogs/recurrence-page.c
@@ -1220,6 +1220,12 @@ make_ending_until_special (RecurrencePage *rpage)
gtk_signal_connect (GTK_OBJECT (de), "changed",
GTK_SIGNAL_FUNC (ending_until_changed_cb), rpage);
+
+ /* Make sure the EDateEdit widget uses our timezones to get the
+ current time. */
+ e_date_edit_set_get_time_callback (de,
+ (EDateEditGetTimeCallback) comp_editor_get_current_time,
+ rpage, NULL);
}
/* Callback used when the ending-count value changes */
@@ -2113,9 +2119,6 @@ init_widgets (RecurrencePage *rpage)
e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->exception_date),
(EDateEditGetTimeCallback) comp_editor_get_current_time,
rpage, NULL);
- e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->ending_date_edit),
- (EDateEditGetTimeCallback) comp_editor_get_current_time,
- rpage, NULL);
e_calendar_item_set_get_time_callback (ecal->calitem,
(ECalendarItemGetTimeCallback) comp_editor_get_current_time,
rpage, NULL);
diff --git a/calendar/gui/e-timezone-entry.c b/calendar/gui/e-timezone-entry.c
index e7e64f0934..2b4f06af6d 100644
--- a/calendar/gui/e-timezone-entry.c
+++ b/calendar/gui/e-timezone-entry.c
@@ -286,7 +286,7 @@ e_timezone_entry_set_timezone (ETimezoneEntry *tentry,
priv->changed = FALSE;
gtk_entry_set_text (GTK_ENTRY (priv->entry),
- e_timezone_entry_get_display_name (zone));
+ zone ? e_timezone_entry_get_display_name (zone) : "");
}
diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c
index 17765f918c..06c90b79f8 100644
--- a/calendar/pcs/cal-backend-file.c
+++ b/calendar/pcs/cal-backend-file.c
@@ -93,6 +93,8 @@ static gboolean cal_backend_file_update_object (CalBackend *backend, const char
const char *calobj);
static gboolean cal_backend_file_remove_object (CalBackend *backend, const char *uid);
+static icaltimezone* cal_backend_file_get_timezone (CalBackend *backend, const char *tzid);
+
static CalBackendClass *parent_class;
@@ -159,6 +161,8 @@ cal_backend_file_class_init (CalBackendFileClass *class)
backend_class->get_alarms_for_object = cal_backend_file_get_alarms_for_object;
backend_class->update_object = cal_backend_file_update_object;
backend_class->remove_object = cal_backend_file_remove_object;
+
+ backend_class->get_timezone = cal_backend_file_get_timezone;
}
/* Object initialization function for the file backend */
@@ -947,13 +951,14 @@ add_instance (CalComponent *comp, time_t start, time_t end, gpointer data)
}
-/* FIXME */
static icaltimezone*
resolve_tzid (const char *tzid, gpointer data)
{
icalcomponent *vcalendar_comp = data;
- if (!strcmp (tzid, "UTC"))
+ if (!tzid || !tzid[0])
+ return NULL;
+ else if (!strcmp (tzid, "UTC"))
return icaltimezone_get_utc_timezone ();
else
return icalcomponent_get_timezone (vcalendar_comp, tzid);
@@ -1664,9 +1669,9 @@ cal_backend_file_update_object (CalBackend *backend, const char *uid, const char
ICAL_ANY_COMPONENT);
while (subcomp) {
child_kind = icalcomponent_isa (subcomp);
- if (kind == ICAL_VEVENT_COMPONENT
- || kind == ICAL_VTODO_COMPONENT
- || kind == ICAL_VJOURNAL_COMPONENT) {
+ if (child_kind == ICAL_VEVENT_COMPONENT
+ || child_kind == ICAL_VTODO_COMPONENT
+ || child_kind == ICAL_VJOURNAL_COMPONENT) {
icalcomp = subcomp;
num_found++;
}
@@ -1761,3 +1766,21 @@ cal_backend_file_remove_object (CalBackend *backend, const char *uid)
return TRUE;
}
+
+static icaltimezone*
+cal_backend_file_get_timezone (CalBackend *backend, const char *tzid)
+{
+ CalBackendFile *cbfile;
+ CalBackendFilePrivate *priv;
+
+ cbfile = CAL_BACKEND_FILE (backend);
+ priv = cbfile->priv;
+
+ g_return_val_if_fail (priv->icalcomp != NULL, NULL);
+
+ if (!strcmp (tzid, "UTC"))
+ return icaltimezone_get_utc_timezone ();
+ else
+ return icalcomponent_get_timezone (priv->icalcomp, tzid);
+}
+
diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c
index a9eae9f212..1ca13028a9 100644
--- a/calendar/pcs/cal-backend.c
+++ b/calendar/pcs/cal-backend.c
@@ -588,3 +588,28 @@ cal_backend_obj_removed (CalBackend *backend, const char *uid)
gtk_signal_emit (GTK_OBJECT (backend), cal_backend_signals[OBJ_REMOVED],
uid);
}
+
+
+/**
+ * cal_backend_get_timezone:
+ * @backend: A calendar backend.
+ * @tzid: Unique identifier of a VTIMEZONE object. Note that this must not be
+ * NULL.
+ *
+ * Returns the icaltimezone* corresponding to the TZID, or NULL if the TZID
+ * can't be found.
+ *
+ * Return value: TRUE on success, FALSE on being passed an UID for an object
+ * that does not exist in the backend.
+ **/
+icaltimezone*
+cal_backend_get_timezone (CalBackend *backend, const char *tzid)
+{
+ g_return_val_if_fail (backend != NULL, NULL);
+ g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL);
+ g_return_val_if_fail (tzid != NULL, NULL);
+
+ g_assert (CLASS (backend)->get_timezone != NULL);
+ return (* CLASS (backend)->get_timezone) (backend, tzid);
+}
+
diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h
index e5d475452b..568ae45034 100644
--- a/calendar/pcs/cal-backend.h
+++ b/calendar/pcs/cal-backend.h
@@ -106,6 +106,9 @@ struct _CalBackendClass {
/* Object manipulation virtual methods */
gboolean (* update_object) (CalBackend *backend, const char *uid, const char *calobj);
gboolean (* remove_object) (CalBackend *backend, const char *uid);
+
+ /* Timezone related virtual methods */
+ icaltimezone *(* get_timezone) (CalBackend *backend, const char *tzid);
};
GtkType cal_backend_get_type (void);
@@ -148,6 +151,8 @@ gboolean cal_backend_update_object (CalBackend *backend, const char *uid, const
gboolean cal_backend_remove_object (CalBackend *backend, const char *uid);
+icaltimezone* cal_backend_get_timezone (CalBackend *backend, const char *tzid);
+
void cal_backend_last_client_gone (CalBackend *backend);
void cal_backend_opened (CalBackend *backend, CalBackendOpenStatus status);
void cal_backend_obj_updated (CalBackend *backend, const char *uid);
diff --git a/calendar/pcs/query.c b/calendar/pcs/query.c
index 237b2524e1..6f3e276ae0 100644
--- a/calendar/pcs/query.c
+++ b/calendar/pcs/query.c
@@ -442,17 +442,16 @@ instance_occur_cb (CalComponent *comp, time_t start, time_t end, gpointer data)
return FALSE;
}
-/* FIXME. This is the same as the function in cal-backend-file.c. It needs
- to be added to the backend interface, I think. */
+/* Call the backend function to get a timezone from a TZID. */
static icaltimezone*
resolve_tzid (const char *tzid, gpointer data)
{
- icalcomponent *vcalendar_comp = data;
+ Query *query = data;
- if (!strcmp (tzid, "UTC"))
- return icaltimezone_get_utc_timezone ();
+ if (!tzid || !tzid[0])
+ return NULL;
else
- return icalcomponent_get_timezone (vcalendar_comp, tzid);
+ return cal_backend_get_timezone (query->priv->backend, tzid);
}
@@ -473,7 +472,6 @@ func_occur_in_time_range (ESExp *esexp, int argc, ESExpResult **argv, void *data
time_t start, end;
gboolean occurs;
ESExpResult *result;
- icalcomponent *icalcomp, *vcalendar_comp;
query = QUERY (data);
priv = query->priv;
@@ -506,12 +504,9 @@ func_occur_in_time_range (ESExp *esexp, int argc, ESExpResult **argv, void *data
occurs = FALSE;
- /* Get the parent VCALENDAR component, so we can resolve TZIDs. */
- icalcomp = cal_component_get_icalcomponent (comp);
- vcalendar_comp = icalcomponent_get_parent (icalcomp);
- g_assert (vcalendar_comp != NULL);
-
- cal_recur_generate_instances (comp, start, end, instance_occur_cb, &occurs, resolve_tzid, vcalendar_comp);
+ cal_recur_generate_instances (comp, start, end,
+ instance_occur_cb, &occurs,
+ resolve_tzid, query);
result = e_sexp_result_new (esexp, ESEXP_RES_BOOL);
result->value.bool = occurs;