aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/pcs
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/pcs')
-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
4 files changed, 66 insertions, 18 deletions
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;