aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/pcs
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@ximian.com>2001-07-30 21:23:17 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2001-07-30 21:23:17 +0800
commitca87e4cc43fa191f87cd2bf88e2447d40f54c244 (patch)
treede69851895e6fbc8da18d1be84bd2a0a268a3455 /calendar/pcs
parent153fede73c69681301ab1b8b890c332370bb47e2 (diff)
downloadgsoc2013-evolution-ca87e4cc43fa191f87cd2bf88e2447d40f54c244.tar.gz
gsoc2013-evolution-ca87e4cc43fa191f87cd2bf88e2447d40f54c244.tar.zst
gsoc2013-evolution-ca87e4cc43fa191f87cd2bf88e2447d40f54c244.zip
implemented
2001-07-30 Rodrigo Moya <rodrigo@ximian.com> * pcs/cal-backend-file.c (cal_backend_file_get_free_busy): implemented svn path=/trunk/; revision=11472
Diffstat (limited to 'calendar/pcs')
-rw-r--r--calendar/pcs/cal-backend-file.c58
1 files changed, 57 insertions, 1 deletions
diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c
index 028949aa1a..219683e4f9 100644
--- a/calendar/pcs/cal-backend-file.c
+++ b/calendar/pcs/cal-backend-file.c
@@ -1033,7 +1033,63 @@ cal_backend_file_get_objects_in_range (CalBackend *backend, CalObjType type,
static char *
cal_backend_file_get_free_busy (CalBackend *backend, time_t start, time_t end)
{
- return NULL;
+ CalBackendFile *cbfile;
+ CalBackendFilePrivate *priv;
+ icalcomponent *vfb;
+ char *calobj;
+ struct icaltimetype itime;
+ GList *uids;
+ GList *l;
+
+ cbfile = CAL_BACKEND_FILE (backend);
+ priv = cbfile->priv;
+
+ g_return_val_if_fail (priv->icalcomp != NULL, NULL);
+ g_return_val_if_fail (start != -1 && end != -1, NULL);
+ g_return_val_if_fail (start <= end, NULL);
+
+ /* create the iCal VFREEBUSY component */
+ vfb = icalcomponent_new_vfreebusy ();
+ itime = icaltime_from_timet (start, 1);
+ icalcomponent_set_dtstart (vfb, itime);
+ itime = icaltime_from_timet (end, 1);
+ icalcomponent_set_dtend (vfb, itime);
+
+ /* add all objects in the given interval */
+ uids = cal_backend_get_objects_in_range (CAL_BACKEND (cbfile),
+ CALOBJ_TYPE_ANY, start, end);
+ for (l = uids; l != NULL; l = l->next) {
+ char *comp_str;
+ icalcomponent *icalcomp;
+ icalproperty *icalprop;
+ struct icalperiodtype ipt;
+ char *uid = (char *) l->data;
+
+ comp_str = cal_backend_get_object (CAL_BACKEND (cbfile), uid);
+ if (!comp_str)
+ continue;
+
+ icalcomp = icalparser_parse_string (comp_str);
+ g_free (comp_str);
+ if (!icalcomp)
+ continue;
+
+ ipt.start = icalcomponent_get_dtstart (icalcomp);
+ ipt.end = icalcomponent_get_dtend (icalcomp);
+ ipt.duration = icalcomponent_get_duration (icalcomp);
+
+ /* add busy information to the vfb component */
+ icalprop = icalproperty_new (ICAL_FREEBUSY_PROPERTY);
+ icalproperty_set_freebusy (icalprop, ipt);
+ icalcomponent_add_property (vfb, icalprop);
+ }
+
+ calobj = g_strdup (icalcomponent_as_ical_string (vfb));
+
+ icalcomponent_free (vfb);
+ cal_obj_uid_list_free (uids);
+
+ return calobj;
}
typedef struct