aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/pcs/cal-backend-file.c
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@ximian.com>2001-09-19 04:16:39 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2001-09-19 04:16:39 +0800
commit2b78b5294a6a047a971446595c9e7f5f32f583a2 (patch)
tree6b74cd7376bb1ab8024871a5e2b059d669ebf6d8 /calendar/pcs/cal-backend-file.c
parent3e079da9b69b8f5c47c79bcbb269ac17cc094c6e (diff)
downloadgsoc2013-evolution-2b78b5294a6a047a971446595c9e7f5f32f583a2.tar.gz
gsoc2013-evolution-2b78b5294a6a047a971446595c9e7f5f32f583a2.tar.zst
gsoc2013-evolution-2b78b5294a6a047a971446595c9e7f5f32f583a2.zip
new class for managing multiple calendars, with an API very similar to the
2001-09-18 Rodrigo Moya <rodrigo@ximian.com> * cal-client/cal-client-multi.[ch]: new class for managing multiple calendars, with an API very similar to the CalClient one, for ease of transition from one to the other * gui/component-factory.c (xfer_folder, remove_folder, create_folder): reworked to be able to manage folders for any calendar backend, and not only the file: one 2001-09-18 Rodrigo Moya <rodrigo@ximian.com> * idl/evolution-calendar.idl: changed signature for the getFreeBusy method, to return a sequence of CalObj's, and added sequence of users as a new parameter to that method * cal-client/cal-client.c (cal_client_get_free_busy): adapted to new IDL method signature, by adding a new "GList *users" parameter, for callers to be able to specify a list of users * pcs/cal-backend.[ch] (cal_backend_get_free_busy): * pcs/cal-backend-file.c (cal_backend_file_get_free_busy): add the "GList *users" parameter. In cal_backend_file_get_free_busy, call lookup_component to get the CalComponent for each uid, instead of calling cal_backend_get_object, which meant converting the component to a string and then parsing it again. * cal-client/client-test.c (cal_opened_cb): * gui/e-itip-control.c (send_freebusy): * gui/calendar-commands.c (publish_freebusy_cmd): adapted to new getFreeBusy method signature svn path=/trunk/; revision=12951
Diffstat (limited to 'calendar/pcs/cal-backend-file.c')
-rw-r--r--calendar/pcs/cal-backend-file.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c
index fd4e3a2cd0..5649cc39f5 100644
--- a/calendar/pcs/cal-backend-file.c
+++ b/calendar/pcs/cal-backend-file.c
@@ -92,7 +92,7 @@ static char *cal_backend_file_get_timezone_object (CalBackend *backend, const ch
static GList *cal_backend_file_get_uids (CalBackend *backend, CalObjType type);
static GList *cal_backend_file_get_objects_in_range (CalBackend *backend, CalObjType type,
time_t start, time_t end);
-static char *cal_backend_file_get_free_busy (CalBackend *backend, time_t start, time_t end);
+static GList *cal_backend_file_get_free_busy (CalBackend *backend, GList *users, time_t start, time_t end);
static GNOME_Evolution_Calendar_CalObjChangeSeq *cal_backend_file_get_changes (
CalBackend *backend, CalObjType type, const char *change_id);
@@ -1113,16 +1113,16 @@ cal_backend_file_get_objects_in_range (CalBackend *backend, CalObjType type,
}
/* Get_free_busy handler for the file backend */
-static char *
-cal_backend_file_get_free_busy (CalBackend *backend, time_t start, time_t end)
+static GList *
+cal_backend_file_get_free_busy (CalBackend *backend, GList *users, time_t start, time_t end)
{
CalBackendFile *cbfile;
CalBackendFilePrivate *priv;
- icalcomponent *vfb;
- char *calobj;
- struct icaltimetype itime;
GList *uids;
GList *l;
+ icalcomponent *vfb;
+ char *calobj;
+ GList *obj_list = NULL;
cbfile = CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
@@ -1131,34 +1131,28 @@ cal_backend_file_get_free_busy (CalBackend *backend, time_t start, time_t end)
g_return_val_if_fail (start != -1 && end != -1, NULL);
g_return_val_if_fail (start <= end, NULL);
- /* create the iCal VFREEBUSY component */
+ /* create the (unique) VFREEBUSY object that we'll return */
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);
+ icalcomponent_set_dtstart (vfb, icaltime_from_timet (start, 1));
+ icalcomponent_set_dtend (vfb, icaltime_from_timet (end, 1));
/* 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;
+ CalComponent *comp;
icalcomponent *icalcomp;
- icalproperty *icalprop, *prop;
+ icalparameter *param;
+ icalproperty *prop;
struct icalperiodtype ipt;
char *uid = (char *) l->data;
- /* FIXME: This looks quite inefficient. It is converting the
- component to a string and then parsing it again. It would
- be better to use lookup_component(). It needs to handle
- timezones as well, so it is probably easier to use the
- CalComponent wrapper functions. - Damon. */
- comp_str = cal_backend_get_object (CAL_BACKEND (cbfile), uid);
- if (!comp_str)
+ /* get the component from our internal list */
+ comp = lookup_component (cbfile, uid);
+ if (!comp)
continue;
- icalcomp = icalparser_parse_string (comp_str);
- g_free (comp_str);
+ icalcomp = cal_component_get_icalcomponent (comp);
if (!icalcomp)
continue;
@@ -1177,17 +1171,22 @@ cal_backend_file_get_free_busy (CalBackend *backend, time_t start, time_t end)
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);
- }
+ prop = icalproperty_new (ICAL_FREEBUSY_PROPERTY);
+ icalproperty_set_freebusy (prop, ipt);
- calobj = g_strdup (icalcomponent_as_ical_string (vfb));
+ param = icalparameter_new_fbtype (ICAL_FBTYPE_BUSY);
+ icalproperty_add_parameter (prop, param);
+ icalcomponent_add_property (vfb, prop);
+ }
+
+ calobj = icalcomponent_as_ical_string (vfb);
+ obj_list = g_list_append (obj_list, g_strdup (calobj));
icalcomponent_free (vfb);
+
cal_obj_uid_list_free (uids);
- return calobj;
+ return obj_list;
}
typedef struct