aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/pcs
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
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')
-rw-r--r--calendar/pcs/cal-backend-file.c55
-rw-r--r--calendar/pcs/cal-backend.c9
-rw-r--r--calendar/pcs/cal-backend.h4
-rw-r--r--calendar/pcs/cal.c55
4 files changed, 76 insertions, 47 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
diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c
index b19c141446..20f3a74ee1 100644
--- a/calendar/pcs/cal-backend.c
+++ b/calendar/pcs/cal-backend.c
@@ -476,15 +476,16 @@ cal_backend_get_objects_in_range (CalBackend *backend, CalObjType type,
/**
* cal_backend_get_free_busy:
* @backend: A calendar backend.
+ * @users: List of users to get free/busy information for.
* @start: Start time for query.
* @end: End time for query.
*
* Gets a free/busy object for the given time interval
*
- * Return value: a free/busy object
+ * Return value: a list of CalObj's
**/
-char *
-cal_backend_get_free_busy (CalBackend *backend, time_t start, time_t end)
+GList *
+cal_backend_get_free_busy (CalBackend *backend, GList *users, time_t start, time_t end)
{
g_return_val_if_fail (backend != NULL, NULL);
g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL);
@@ -492,7 +493,7 @@ cal_backend_get_free_busy (CalBackend *backend, time_t start, time_t end)
g_return_val_if_fail (start <= end, NULL);
g_assert (CLASS (backend)->get_free_busy != NULL);
- return (* CLASS (backend)->get_free_busy) (backend, start, end);
+ return (* CLASS (backend)->get_free_busy) (backend, users, start, end);
}
/**
diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h
index 59b5023a7d..1864a08f73 100644
--- a/calendar/pcs/cal-backend.h
+++ b/calendar/pcs/cal-backend.h
@@ -91,7 +91,7 @@ struct _CalBackendClass {
GList *(* get_objects_in_range) (CalBackend *backend, CalObjType type,
time_t start, time_t end);
- char *(* get_free_busy) (CalBackend *backend, time_t start, time_t end);
+ GList *(* get_free_busy) (CalBackend *backend, GList *users, time_t start, time_t end);
/* Change related virtual methods */
GNOME_Evolution_Calendar_CalObjChangeSeq * (* get_changes) (
@@ -138,7 +138,7 @@ GList *cal_backend_get_uids (CalBackend *backend, CalObjType type);
GList *cal_backend_get_objects_in_range (CalBackend *backend, CalObjType type,
time_t start, time_t end);
-char *cal_backend_get_free_busy (CalBackend *backend, time_t start, time_t end);
+GList *cal_backend_get_free_busy (CalBackend *backend, GList *users, time_t start, time_t end);
GNOME_Evolution_Calendar_CalObjChangeSeq * cal_backend_get_changes (
CalBackend *backend, CalObjType type, const char *change_id);
diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c
index 213ad35c31..9532e8265a 100644
--- a/calendar/pcs/cal.c
+++ b/calendar/pcs/cal.c
@@ -233,16 +233,19 @@ impl_Cal_get_objects_in_range (PortableServer_Servant servant,
}
/* Cal::get_free_busy method */
-static GNOME_Evolution_Calendar_CalObj
+static GNOME_Evolution_Calendar_CalObjSeq *
impl_Cal_get_free_busy (PortableServer_Servant servant,
- GNOME_Evolution_Calendar_Time_t start,
- GNOME_Evolution_Calendar_Time_t end,
+ const GNOME_Evolution_Calendar_UserList *user_list,
+ const GNOME_Evolution_Calendar_Time_t start,
+ const GNOME_Evolution_Calendar_Time_t end,
CORBA_Environment *ev)
{
Cal *cal;
CalPrivate *priv;
time_t t_start, t_end;
- char *calobj;
+ GList *users = NULL;
+ GList *obj_list;
+ GNOME_Evolution_Calendar_CalObjSeq *seq;
cal = CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
@@ -257,20 +260,46 @@ impl_Cal_get_free_busy (PortableServer_Servant servant,
return NULL;
}
- calobj = cal_backend_get_free_busy (priv->backend, t_start, t_end);
- if (calobj) {
- CORBA_char *calobj_copy;
+ /* convert the CORBA user list to a GList */
+ if (user_list) {
+ int i;
- calobj_copy = CORBA_string_dup (calobj);
- g_free (calobj);
- return calobj_copy;
+ for (i = 0; i < user_list->_length; i++)
+ users = g_list_append (users, user_list->_buffer[i]);
+ }
+
+ /* call the backend's get_free_busy method */
+ obj_list = cal_backend_get_free_busy (priv->backend, users, t_start, t_end);
+ g_list_free (users);
+ if (obj_list) {
+ GList *l;
+ gint count;
+ gint n;
+
+ count = g_list_length (obj_list);
+
+ seq = GNOME_Evolution_Calendar_CalObjSeq__alloc ();
+ CORBA_sequence_set_release (seq, TRUE);
+ seq->_length = count;
+ seq->_buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObj_allocbuf (count);
+
+ for (l = obj_list, n = 0; l; l = l->next, n++) {
+ gchar *calobj = (gchar *) l->data;
+
+ seq->_buffer[n] = CORBA_string_dup (calobj);
+ g_free (calobj);
+ }
+
+ g_list_free (obj_list);
+
+ return seq;
}
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
- ex_GNOME_Evolution_Calendar_Cal_NotFound,
- NULL);
+ ex_GNOME_Evolution_Calendar_Cal_NotFound,
+ NULL);
- return NULL;
+ return NULL;
}
/* Cal::get_alarms_in_range method */