aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2000-08-09 06:39:13 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2000-08-09 06:39:13 +0800
commit14e163207e7bea5a383f8b538041156dc2cb1c84 (patch)
treece88eb76dbadd9a4093e8a6ad544ffe715b19d9c /calendar
parent9734f4252d8d24fede29bef124b9b5104cf8f0c6 (diff)
downloadgsoc2013-evolution-14e163207e7bea5a383f8b538041156dc2cb1c84.tar
gsoc2013-evolution-14e163207e7bea5a383f8b538041156dc2cb1c84.tar.gz
gsoc2013-evolution-14e163207e7bea5a383f8b538041156dc2cb1c84.tar.bz2
gsoc2013-evolution-14e163207e7bea5a383f8b538041156dc2cb1c84.tar.lz
gsoc2013-evolution-14e163207e7bea5a383f8b538041156dc2cb1c84.tar.xz
gsoc2013-evolution-14e163207e7bea5a383f8b538041156dc2cb1c84.tar.zst
gsoc2013-evolution-14e163207e7bea5a383f8b538041156dc2cb1c84.zip
Added a get_objects_in_range() method. Takes in a time range and the type
2000-08-08 Federico Mena Quintero <federico@helixcode.com> * idl/evolution-calendar.idl (Cal): Added a get_objects_in_range() method. Takes in a time range and the type of component we are interested in; returns a list of UIDs. The idea is that ocurrences get computed in the client; we can have multiple recurrences in iCalendar and we cannot identify them trivially across the wire. (Cal): Removed the get_events_in_range() method. * pcs/cal-backend.c (cal_backend_free_uid_list): New function. (cal_backend_get_objects_in_range): New function. (cal_backend_get_events_in_range): Removed. * pcs/cal-backend-file.c (cal_backend_file_get_objects_in_range): Implemented new method. (cal_backend_file_get_events_in_range): Removed. * pcs/cal.c (Cal_get_events_in_range): Removed. (uncorba_obj_type): New function. (Cal_get_uids): Use uncorba_obj_type(). (Cal_get_n_objects): Likewise. (Cal_get_objects_in_range): Implemented new method. * cal-client/cal-client.c (cal_client_get_events_in_range): Removed. (cal_client_get_objects_in_range): Implemented. (corba_obj_type): New function. (cal_client_get_n_objects): Use corba_obj_type(). (cal_client_get_uids): Likewise. svn path=/trunk/; revision=4613
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog30
-rw-r--r--calendar/cal-client/cal-client.c78
-rw-r--r--calendar/cal-client/cal-client.h3
-rw-r--r--calendar/idl/evolution-calendar.idl5
-rw-r--r--calendar/pcs/cal-backend-file.c102
-rw-r--r--calendar/pcs/cal-backend.c26
-rw-r--r--calendar/pcs/cal-backend.h9
-rw-r--r--calendar/pcs/cal.c120
8 files changed, 201 insertions, 172 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 833e195b76..22d351240d 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,33 @@
+2000-08-08 Federico Mena Quintero <federico@helixcode.com>
+
+ * idl/evolution-calendar.idl (Cal): Added a get_objects_in_range()
+ method. Takes in a time range and the type of component we are
+ interested in; returns a list of UIDs. The idea is that
+ ocurrences get computed in the client; we can have multiple
+ recurrences in iCalendar and we cannot identify them trivially
+ across the wire.
+ (Cal): Removed the get_events_in_range() method.
+
+ * pcs/cal-backend.c (cal_backend_free_uid_list): New function.
+ (cal_backend_get_objects_in_range): New function.
+ (cal_backend_get_events_in_range): Removed.
+
+ * pcs/cal-backend-file.c (cal_backend_file_get_objects_in_range):
+ Implemented new method.
+ (cal_backend_file_get_events_in_range): Removed.
+
+ * pcs/cal.c (Cal_get_events_in_range): Removed.
+ (uncorba_obj_type): New function.
+ (Cal_get_uids): Use uncorba_obj_type().
+ (Cal_get_n_objects): Likewise.
+ (Cal_get_objects_in_range): Implemented new method.
+
+ * cal-client/cal-client.c (cal_client_get_events_in_range): Removed.
+ (cal_client_get_objects_in_range): Implemented.
+ (corba_obj_type): New function.
+ (cal_client_get_n_objects): Use corba_obj_type().
+ (cal_client_get_uids): Likewise.
+
2000-08-07 Federico Mena Quintero <federico@helixcode.com>
* cal-util/cal-component.c (cal_component_clone): New function.
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
index 88685dd1aa..cb35bafc71 100644
--- a/calendar/cal-client/cal-client.c
+++ b/calendar/cal-client/cal-client.c
@@ -548,6 +548,15 @@ cal_client_create_calendar (CalClient *client, const char *str_uri)
return load_or_create (client, str_uri, FALSE);
}
+/* Converts our representation of a calendar component type into its CORBA representation */
+static Evolution_Calendar_CalObjType
+corba_obj_type (CalObjType type)
+{
+ return (((type & CALOBJ_TYPE_EVENT) ? Evolution_Calendar_TYPE_EVENT : 0)
+ | ((type & CALOBJ_TYPE_TODO) ? Evolution_Calendar_TYPE_TODO : 0)
+ | ((type & CALOBJ_TYPE_JOURNAL) ? Evolution_Calendar_TYPE_JOURNAL : 0));
+}
+
/**
* cal_client_get_n_objects:
* @client: A calendar client.
@@ -572,13 +581,7 @@ cal_client_get_n_objects (CalClient *client, CalObjType type)
priv = client->priv;
g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, -1);
- t = (((type & CALOBJ_TYPE_EVENT) ? Evolution_Calendar_TYPE_EVENT : 0)
- | ((type & CALOBJ_TYPE_TODO) ? Evolution_Calendar_TYPE_TODO : 0)
- | ((type & CALOBJ_TYPE_JOURNAL) ? Evolution_Calendar_TYPE_JOURNAL : 0)
- /*
- | ((type & CALOBJ_TYPE_ANY) ? Evolution_Calendar_TYPE_ANY : 0)
- */
- );
+ t = corba_obj_type (type);
CORBA_exception_init (&ev);
n = Evolution_Calendar_Cal_get_n_objects (priv->cal, t, &ev);
@@ -730,7 +733,20 @@ void cal_client_update_pilot_id (CalClient *client, char *uid,
CORBA_exception_free (&ev);
}
+/* Builds an UID list out of a CORBA UID sequence */
+static GList *
+build_uid_list (Evolution_Calendar_CalObjUIDSeq *seq)
+{
+ GList *uids;
+ int i;
+ uids = NULL;
+
+ for (i = 0; i < seq->_length; i++)
+ uids = g_list_prepend (uids, g_strdup (seq->_buffer[i]));
+
+ return uids;
+}
/**
* cal_client_get_uids:
@@ -750,23 +766,14 @@ cal_client_get_uids (CalClient *client, CalObjType type)
Evolution_Calendar_CalObjUIDSeq *seq;
int t;
GList *uids;
- int i;
g_return_val_if_fail (client != NULL, NULL);
g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
priv = client->priv;
- /*g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, NULL);*/
- if (priv->load_state != LOAD_STATE_LOADED)
- return NULL;
+ g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, NULL);
- t = (((type & CALOBJ_TYPE_EVENT) ? Evolution_Calendar_TYPE_EVENT : 0)
- | ((type & CALOBJ_TYPE_TODO) ? Evolution_Calendar_TYPE_TODO : 0)
- | ((type & CALOBJ_TYPE_JOURNAL) ? Evolution_Calendar_TYPE_JOURNAL : 0)
- /*
- | ((type & CALOBJ_TYPE_ANY) ? Evolution_Calendar_TYPE_ANY : 0)
- */
- );
+ t = corba_obj_type (type);
CORBA_exception_init (&ev);
@@ -779,13 +786,7 @@ cal_client_get_uids (CalClient *client, CalObjType type)
CORBA_exception_free (&ev);
- /* Create the list */
-
- uids = NULL;
-
- for (i = 0; i < seq->_length; i++)
- uids = g_list_prepend (uids, g_strdup (seq->_buffer[i]));
-
+ uids = build_uid_list (seq);
CORBA_free (seq);
return uids;
@@ -820,23 +821,26 @@ build_object_instance_list (Evolution_Calendar_CalObjInstanceSeq *seq)
}
/**
- * cal_client_get_events_in_range:
+ * cal_client_get_objects_in_range:
* @client: A calendar client.
+ * @type: Bitmask with types of objects to return.
* @start: Start time for query.
* @end: End time for query.
*
- * Queries a calendar for the events that occur or recur in the specified range
+ * Queries a calendar for the objects that occur or recur in the specified range
* of time.
*
- * Return value: A list of #CalObjInstance structures.
+ * Return value: A list of UID strings. This should be freed using the
+ * cal_obj_uid_list_free() function.
**/
GList *
-cal_client_get_events_in_range (CalClient *client, time_t start, time_t end)
+cal_client_get_objects_in_range (CalClient *client, CalObjType type, time_t start, time_t end)
{
CalClientPrivate *priv;
CORBA_Environment ev;
- Evolution_Calendar_CalObjInstanceSeq *seq;
- GList *events;
+ Evolution_Calendar_CalObjUIDSeq *seq;
+ GList *uids;
+ int t;
g_return_val_if_fail (client != NULL, NULL);
g_return_val_if_fail (IS_CAL_CLIENT (client), NULL);
@@ -850,18 +854,20 @@ cal_client_get_events_in_range (CalClient *client, time_t start, time_t end)
CORBA_exception_init (&ev);
- seq = Evolution_Calendar_Cal_get_events_in_range (priv->cal, start, end, &ev);
+ t = corba_obj_type (type);
+
+ seq = Evolution_Calendar_Cal_get_objects_in_range (priv->cal, t, start, end, &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("cal_client_get_events_in_range(): could not get the event range");
+ g_message ("cal_client_get_objects_in_range(): could not get the objects");
CORBA_exception_free (&ev);
return NULL;
}
CORBA_exception_free (&ev);
- events = build_object_instance_list (seq);
+ uids = build_uid_list (seq);
CORBA_free (seq);
- return events;
+ return uids;
}
#if 0
@@ -1103,7 +1109,7 @@ cal_client_remove_object (CalClient *client, const char *uid)
strcmp (CORBA_exception_id (&ev), ex_Evolution_Calendar_Cal_NotFound) == 0)
goto out;
else if (ev._major != CORBA_NO_EXCEPTION) {
- /*g_message ("cal_client_remove_object(): could not remove the object");*/
+ g_message ("cal_client_remove_object(): could not remove the object");
goto out;
}
diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h
index e395fa2e46..379980cd3f 100644
--- a/calendar/cal-client/cal-client.h
+++ b/calendar/cal-client/cal-client.h
@@ -98,7 +98,8 @@ void cal_client_update_pilot_id (CalClient *client, char *uid,
GList *cal_client_get_uids (CalClient *client, CalObjType type);
-GList *cal_client_get_events_in_range (CalClient *client, time_t start, time_t end);
+GList *cal_client_get_objects_in_range (CalClient *client, CalObjType type,
+ time_t start, time_t end);
GList *cal_client_get_alarms_in_range (CalClient *client, time_t start, time_t end);
diff --git a/calendar/idl/evolution-calendar.idl b/calendar/idl/evolution-calendar.idl
index 8fc84ab233..4b9b9a7b34 100644
--- a/calendar/idl/evolution-calendar.idl
+++ b/calendar/idl/evolution-calendar.idl
@@ -92,8 +92,9 @@ module Calendar {
/* Gets a list of UIDs based on object type */
CalObjUIDSeq get_uids (in CalObjType type);
- /* Gets the events that occur or recur in the specified time range */
- CalObjInstanceSeq get_events_in_range (in Time_t start, in Time_t end)
+ /* Gets a list of objects that occur or recur in the specified time range */
+ CalObjUIDSeq get_objects_in_range (in CalObjType type,
+ in Time_t start, in Time_t end)
raises (InvalidRange);
/* Gets the objects whose alarms trigger in the specified time
diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c
index f23024cec6..5e74689095 100644
--- a/calendar/pcs/cal-backend-file.c
+++ b/calendar/pcs/cal-backend-file.c
@@ -71,7 +71,8 @@ static void cal_backend_file_create (CalBackend *backend, GnomeVFSURI *uri);
static int cal_backend_file_get_n_objects (CalBackend *backend, CalObjType type);
static char *cal_backend_file_get_object (CalBackend *backend, const char *uid);
static GList *cal_backend_file_get_uids (CalBackend *backend, CalObjType type);
-static GList *cal_backend_file_get_events_in_range (CalBackend *backend, time_t start, time_t end);
+static GList *cal_backend_file_get_objects_in_range (CalBackend *backend, CalObjType type,
+ time_t start, time_t end);
static GList *cal_backend_file_get_alarms_in_range (CalBackend *backend, time_t start, time_t end);
static gboolean cal_backend_file_get_alarms_for_object (CalBackend *backend, const char *uid,
time_t start, time_t end,
@@ -143,7 +144,7 @@ cal_backend_file_class_init (CalBackendFileClass *class)
backend_class->get_n_objects = cal_backend_file_get_n_objects;
backend_class->get_object = cal_backend_file_get_object;
backend_class->get_uids = cal_backend_file_get_uids;
- backend_class->get_events_in_range = cal_backend_file_get_events_in_range;
+ backend_class->get_objects_in_range = cal_backend_file_get_objects_in_range;
backend_class->get_alarms_in_range = cal_backend_file_get_alarms_in_range;
backend_class->get_alarms_for_object = cal_backend_file_get_alarms_for_object;
backend_class->update_object = cal_backend_file_update_object;
@@ -740,64 +741,74 @@ cal_backend_file_get_uids (CalBackend *backend, CalObjType type)
return list;
}
-/* Allocates and fills in a new CalComponentInstance structure */
-static CalObjInstance *
-build_cal_obj_instance (CalComponent *comp, time_t start, time_t end)
+/* Callback used from cal_recur_generate_instances(); adds the component's UID
+ * to our hash table.
+ */
+static gboolean
+add_instance (CalComponent *comp, time_t start, time_t end, gpointer data)
{
- CalObjInstance *icoi;
+ GHashTable *uid_hash;
const char *uid;
+ const char *old_uid;
+
+ uid_hash = data;
+
+ /* We only care that the component's UID is listed in the hash table;
+ * that's why we only allow generation of one instance (i.e. return
+ * FALSE every time).
+ */
cal_component_get_uid (comp, &uid);
- icoi = g_new (CalObjInstance, 1);
- icoi->uid = g_strdup (uid);
- icoi->start = start;
- icoi->end = end;
+ old_uid = g_hash_table_lookup (uid_hash, uid);
+ if (old_uid)
+ return FALSE;
- return icoi;
+ g_hash_table_insert (uid_hash, (char *) uid, NULL);
+ return FALSE;
}
-/* Builds a list of event component instances. Used as a callback from
- * cal_recur_generate_instances().
+/* Populates a hash table with the UIDs of the components that occur or recur
+ * within a specific time range.
*/
-static gboolean
-build_event_list (CalComponent *comp, time_t start, time_t end, gpointer data)
+static void
+get_instances_in_range (GHashTable *uid_hash, GList *components, time_t start, time_t end)
{
- CalObjInstance *icoi;
- GList **l;
-
- l = data;
+ GList *l;
- icoi = build_cal_obj_instance (comp, start, end);
- *l = g_list_prepend (*l, icoi);
+ for (l = components; l; l = l->next) {
+ CalComponent *comp;
- return TRUE;
+ comp = CAL_COMPONENT (l->data);
+ cal_recur_generate_instances (comp, start, end, add_instance, uid_hash);
+ }
}
-/* Compares two CalObjInstance structures by their start times. Called from
- * g_list_sort().
- */
-static gint
-compare_instance_func (gconstpointer a, gconstpointer b)
+/* Used from g_hash_table_foreach(), adds a UID from the hash table to our list */
+static void
+add_uid_to_list (gpointer key, gpointer value, gpointer data)
{
- const CalObjInstance *ca, *cb;
- time_t diff;
+ GList **list;
+ const char *uid;
+ char *uid_copy;
- ca = a;
- cb = b;
+ list = data;
- diff = ca->start - cb->start;
- return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
+ uid = key;
+ uid_copy = g_strdup (uid);
+
+ *list = g_list_prepend (*list, uid_copy);
}
-/* Get_events_in_range handler for the file backend */
+/* Get_objects_in_range handler for the file backend */
static GList *
-cal_backend_file_get_events_in_range (CalBackend *backend, time_t start, time_t end)
+cal_backend_file_get_objects_in_range (CalBackend *backend, CalObjType type,
+ time_t start, time_t end)
{
CalBackendFile *cbfile;
CalBackendFilePrivate *priv;
- GList *l;
GList *event_list;
+ GHashTable *uid_hash;
cbfile = CAL_BACKEND_FILE (backend);
priv = cbfile->priv;
@@ -807,16 +818,21 @@ cal_backend_file_get_events_in_range (CalBackend *backend, time_t start, time_t
g_return_val_if_fail (start != -1 && end != -1, NULL);
g_return_val_if_fail (start <= end, NULL);
- event_list = NULL;
+ uid_hash = g_hash_table_new (g_str_hash, g_str_equal);
- for (l = priv->events; l; l = l->next) {
- CalComponent *comp;
+ if (type & CALOBJ_TYPE_EVENT)
+ get_instances_in_range (uid_hash, priv->events, start, end);
- comp = l->data;
- cal_recur_generate_instances (comp, start, end, build_event_list, &event_list);
- }
+ if (type & CALOBJ_TYPE_TODO)
+ get_instances_in_range (uid_hash, priv->todos, start, end);
+
+ if (type & CALOBJ_TYPE_JOURNAL)
+ get_instances_in_range (uid_hash, priv->journals, start, end);
+
+ event_list = NULL;
+ g_hash_table_foreach (uid_hash, add_uid_to_list, &event_list);
+ g_hash_table_destroy (uid_hash);
- event_list = g_list_sort (event_list, compare_instance_func);
return event_list;
}
diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c
index 97d09fac24..e33cedeae8 100644
--- a/calendar/pcs/cal-backend.c
+++ b/calendar/pcs/cal-backend.c
@@ -226,7 +226,8 @@ cal_backend_get_object (CalBackend *backend, const char *uid)
* Builds a list of unique identifiers corresponding to calendar objects whose
* type matches one of the types specified in the @type flags.
*
- * Return value: A list of strings that are the sought UIDs.
+ * Return value: A list of strings that are the sought UIDs. The list should be
+ * freed using the cal_obj_uid_list_free() function.
**/
GList *
cal_backend_get_uids (CalBackend *backend, CalObjType type)
@@ -239,28 +240,29 @@ cal_backend_get_uids (CalBackend *backend, CalObjType type)
}
/**
- * cal_backend_get_events_in_range:
+ * cal_backend_get_objects_in_range:
* @backend: A calendar backend.
+ * @type: Bitmask with types of objects to return.
* @start: Start time for query.
* @end: End time for query.
- *
- * Builds a sorted list of calendar event object instances that occur or recur
- * within the specified time range. Each object instance contains the object
- * itself and the start/end times at which it occurs or recurs.
- *
- * Return value: A list of calendar event object instances, sorted by their
- * start times.
+ *
+ * Builds a list of unique identifiers corresponding to calendar objects of the
+ * specified type that occur or recur within the specified time range.
+ *
+ * Return value: A list of UID strings. The list should be freed using the
+ * cal_obj_uid_list_free() function.
**/
GList *
-cal_backend_get_events_in_range (CalBackend *backend, time_t start, time_t end)
+cal_backend_get_objects_in_range (CalBackend *backend, CalObjType type,
+ time_t start, time_t end)
{
g_return_val_if_fail (backend != NULL, NULL);
g_return_val_if_fail (IS_CAL_BACKEND (backend), NULL);
g_return_val_if_fail (start != -1 && end != -1, NULL);
g_return_val_if_fail (start <= end, NULL);
- g_assert (CLASS (backend)->get_events_in_range != NULL);
- return (* CLASS (backend)->get_events_in_range) (backend, start, end);
+ g_assert (CLASS (backend)->get_objects_in_range != NULL);
+ return (* CLASS (backend)->get_objects_in_range) (backend, type, start, end);
}
/**
diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h
index 2daa4ad56b..e1122f4d1c 100644
--- a/calendar/pcs/cal-backend.h
+++ b/calendar/pcs/cal-backend.h
@@ -69,7 +69,8 @@ struct _CalBackendClass {
int (* get_n_objects) (CalBackend *backend, CalObjType type);
char *(* get_object) (CalBackend *backend, const char *uid);
GList *(* get_uids) (CalBackend *backend, CalObjType type);
- GList *(* get_events_in_range) (CalBackend *backend, time_t start, time_t end);
+ GList *(* get_objects_in_range) (CalBackend *backend, CalObjType type,
+ time_t start, time_t end);
GList *(* get_alarms_in_range) (CalBackend *backend, time_t start, time_t end);
gboolean (* get_alarms_for_object) (CalBackend *backend, const char *uid,
time_t start, time_t end,
@@ -77,7 +78,8 @@ struct _CalBackendClass {
gboolean (* update_object) (CalBackend *backend, const char *uid, const char *calobj);
gboolean (* remove_object) (CalBackend *backend, const char *uid);
char *(* get_uid_by_pilot_id) (CalBackend *backend, unsigned long int pilot_id);
- void (* update_pilot_id) (CalBackend *backend, const char *uid, unsigned long int pilot_id, unsigned long int pilot_status);
+ void (* update_pilot_id) (CalBackend *backend, const char *uid,
+ unsigned long int pilot_id, unsigned long int pilot_status);
};
GtkType cal_backend_get_type (void);
@@ -96,7 +98,8 @@ char *cal_backend_get_object (CalBackend *backend, const char *uid);
GList *cal_backend_get_uids (CalBackend *backend, CalObjType type);
-GList *cal_backend_get_events_in_range (CalBackend *backend, time_t start, time_t end);
+GList *cal_backend_get_objects_in_range (CalBackend *backend, CalObjType type,
+ time_t start, time_t end);
GList *cal_backend_get_alarms_in_range (CalBackend *backend, time_t start, time_t end);
diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c
index 36791fefcd..5610267b9a 100644
--- a/calendar/pcs/cal.c
+++ b/calendar/pcs/cal.c
@@ -168,6 +168,17 @@ Cal_get_uri (PortableServer_Servant servant,
return str_uri_copy;
}
+/* Converts a calendar object type from its CORBA representation to our own
+ * representation.
+ */
+static CalObjType
+uncorba_obj_type (Evolution_Calendar_CalObjType type)
+{
+ return (((type & Evolution_Calendar_TYPE_EVENT) ? CALOBJ_TYPE_EVENT : 0)
+ | ((type & Evolution_Calendar_TYPE_TODO) ? CALOBJ_TYPE_TODO : 0)
+ | ((type & Evolution_Calendar_TYPE_JOURNAL) ? CALOBJ_TYPE_JOURNAL : 0));
+}
+
/* Cal::get_n_objects method */
static CORBA_long
Cal_get_n_objects (PortableServer_Servant servant,
@@ -182,16 +193,7 @@ Cal_get_n_objects (PortableServer_Servant servant,
cal = CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
- /* Translate the CORBA flags to our own flags */
-
- t = (((type & Evolution_Calendar_TYPE_EVENT) ? CALOBJ_TYPE_EVENT : 0)
- | ((type & Evolution_Calendar_TYPE_TODO) ? CALOBJ_TYPE_TODO : 0)
- | ((type & Evolution_Calendar_TYPE_JOURNAL) ? CALOBJ_TYPE_JOURNAL : 0)
- /*
- | ((type & Evolution_Calendar_TYPE_ANY) ? CALOBJ_TYPE_ANY : 0)
- */
- );
-
+ t = uncorba_obj_type (type);
n = cal_backend_get_n_objects (priv->backend, t);
return n;
}
@@ -225,33 +227,13 @@ Cal_get_object (PortableServer_Servant servant,
}
}
-/* Cal::get_uids method */
static Evolution_Calendar_CalObjUIDSeq *
-Cal_get_uids (PortableServer_Servant servant,
- Evolution_Calendar_CalObjType type,
- CORBA_Environment *ev)
+build_uid_seq (GList *uids)
{
- Cal *cal;
- CalPrivate *priv;
- GList *uids, *l;
Evolution_Calendar_CalObjUIDSeq *seq;
- int t;
+ GList *l;
int n, i;
- cal = CAL (bonobo_object_from_servant (servant));
- priv = cal->priv;
-
- /* Translate the CORBA flags to our own flags */
-
- t = (((type & Evolution_Calendar_TYPE_EVENT) ? CALOBJ_TYPE_EVENT : 0)
- | ((type & Evolution_Calendar_TYPE_TODO) ? CALOBJ_TYPE_TODO : 0)
- | ((type & Evolution_Calendar_TYPE_JOURNAL) ? CALOBJ_TYPE_JOURNAL : 0)
- /*
- | ((type & Evolution_Calendar_TYPE_ANY) ? CALOBJ_TYPE_ANY : 0)
- */
- );
-
- uids = cal_backend_get_uids (priv->backend, t);
n = g_list_length (uids);
seq = Evolution_Calendar_CalObjUIDSeq__alloc ();
@@ -265,67 +247,56 @@ Cal_get_uids (PortableServer_Servant servant,
char *uid;
uid = l->data;
-
seq->_buffer[i] = CORBA_string_dup (uid);
}
- /* Done */
-
- cal_obj_uid_list_free (uids);
-
return seq;
}
-/* Builds a CORBA sequence of calendar object instances from a CalObjInstance
- * list.
- */
-static Evolution_Calendar_CalObjInstanceSeq *
-build_object_instance_seq (GList *list)
+/* Cal::get_uids method */
+static Evolution_Calendar_CalObjUIDSeq *
+Cal_get_uids (PortableServer_Servant servant,
+ Evolution_Calendar_CalObjType type,
+ CORBA_Environment *ev)
{
- GList *l;
- int n, i;
- Evolution_Calendar_CalObjInstanceSeq *seq;
-
- n = g_list_length (list);
-
- seq = Evolution_Calendar_CalObjInstanceSeq__alloc ();
- CORBA_sequence_set_release (seq, TRUE);
- seq->_length = n;
- seq->_buffer = CORBA_sequence_Evolution_Calendar_CalObjInstance_allocbuf (n);
+ Cal *cal;
+ CalPrivate *priv;
+ GList *uids;
+ Evolution_Calendar_CalObjUIDSeq *seq;
+ int t;
- /* Fill the sequence */
+ cal = CAL (bonobo_object_from_servant (servant));
+ priv = cal->priv;
- for (i = 0, l = list; l; i++, l = l->next) {
- CalObjInstance *icoi;
- Evolution_Calendar_CalObjInstance *corba_icoi;
+ t = uncorba_obj_type (type);
- icoi = l->data;
- corba_icoi = &seq->_buffer[i];
+ uids = cal_backend_get_uids (priv->backend, t);
+ seq = build_uid_seq (uids);
- corba_icoi->uid = CORBA_string_dup (icoi->uid);
- corba_icoi->start = icoi->start;
- corba_icoi->end = icoi->end;
- }
+ cal_obj_uid_list_free (uids);
return seq;
}
-/* Cal::get_events_in_range method */
-static Evolution_Calendar_CalObjInstanceSeq *
-Cal_get_events_in_range (PortableServer_Servant servant,
- Evolution_Calendar_Time_t start,
- Evolution_Calendar_Time_t end,
- CORBA_Environment *ev)
+/* Cal::get_objects_in_range method */
+static Evolution_Calendar_CalObjUIDSeq *
+Cal_get_objects_in_range (PortableServer_Servant servant,
+ Evolution_Calendar_CalObjType type,
+ Evolution_Calendar_Time_t start,
+ Evolution_Calendar_Time_t end,
+ CORBA_Environment *ev)
{
Cal *cal;
CalPrivate *priv;
+ int t;
time_t t_start, t_end;
- Evolution_Calendar_CalObjInstanceSeq *seq;
- GList *elist;
+ Evolution_Calendar_CalObjUIDSeq *seq;
+ GList *uids;
cal = CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
+ t = uncorba_obj_type (type);
t_start = (time_t) start;
t_end = (time_t) end;
@@ -336,11 +307,10 @@ Cal_get_events_in_range (PortableServer_Servant servant,
return NULL;
}
- /* Figure out the list and allocate the sequence */
+ uids = cal_backend_get_objects_in_range (priv->backend, t, t_start, t_end);
+ seq = build_uid_seq (uids);
- elist = cal_backend_get_events_in_range (priv->backend, t_start, t_end);
- seq = build_object_instance_seq (elist);
- cal_obj_instance_list_free (elist);
+ cal_obj_uid_list_free (uids);
return seq;
}
@@ -588,7 +558,7 @@ cal_get_epv (void)
epv->get_n_objects = Cal_get_n_objects;
epv->get_object = Cal_get_object;
epv->get_uids = Cal_get_uids;
- epv->get_events_in_range = Cal_get_events_in_range;
+ epv->get_objects_in_range = Cal_get_objects_in_range;
epv->get_alarms_in_range = Cal_get_alarms_in_range;
epv->get_alarms_for_object = Cal_get_alarms_for_object;
epv->update_object = Cal_update_object;