aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-client
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/cal-client')
-rw-r--r--calendar/cal-client/cal-client.c55
-rw-r--r--calendar/cal-client/cal-client.h2
-rw-r--r--calendar/cal-client/cal-util.c25
-rw-r--r--calendar/cal-client/cal-util.h12
4 files changed, 93 insertions, 1 deletions
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
index af8b83db34..3e0659357d 100644
--- a/calendar/cal-client/cal-client.c
+++ b/calendar/cal-client/cal-client.c
@@ -473,6 +473,60 @@ cal_client_get_object (CalClient *client, const char *uid)
}
GList *
+cal_client_get_uids (CalClient *client, CalObjType type)
+{
+ CalClientPrivate *priv;
+ CORBA_Environment ev;
+ 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);
+
+ 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_OTHER) ? Evolution_Calendar_TYPE_OTHER : 0)
+ | ((type & CALOBJ_TYPE_ANY) ? Evolution_Calendar_TYPE_ANY : 0));
+
+ CORBA_exception_init (&ev);
+
+ seq = Evolution_Calendar_Cal_get_uids (priv->cal, t, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_message ("cal_client_get_uids(): could not get the list of UIDs");
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+
+ /* Create the list */
+
+ uids = NULL;
+
+ for (i = 0; i < seq->_length; i++)
+ uids = g_list_prepend (uids, g_strdup (seq->_buffer[i]));
+
+ CORBA_free (seq);
+
+ return uids;
+}
+
+/**
+ * cal_client_get_events_in_range:
+ * @client: A calendar client.
+ * @start: Start time for query.
+ * @end: End time for query.
+ *
+ * Queries a calendar for the events that occur or recur in the specified range
+ * of time.
+ *
+ * Return value: A list of #CalObjInstance structures.
+ **/
+GList *
cal_client_get_events_in_range (CalClient *client, time_t start, time_t end)
{
CalClientPrivate *priv;
@@ -513,6 +567,7 @@ cal_client_get_events_in_range (CalClient *client, time_t start, time_t end)
corba_icoi = &seq->_buffer[i];
icoi = g_new (CalObjInstance, 1);
+ icoi->uid = g_strdup (corba_icoi->uid);
icoi->calobj = g_strdup (corba_icoi->calobj);
icoi->start = corba_icoi->start;
icoi->end = corba_icoi->end;
diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h
index e81ec8c13a..738d013f35 100644
--- a/calendar/cal-client/cal-client.h
+++ b/calendar/cal-client/cal-client.h
@@ -74,6 +74,8 @@ gboolean cal_client_load_calendar (CalClient *client, const char *str_uri);
char *cal_client_get_object (CalClient *client, const 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);
diff --git a/calendar/cal-client/cal-util.c b/calendar/cal-client/cal-util.c
index 97f4724ed0..f3054af958 100644
--- a/calendar/cal-client/cal-util.c
+++ b/calendar/cal-client/cal-util.c
@@ -41,11 +41,34 @@ cal_obj_instance_list_free (GList *list)
i = l->data;
g_assert (i != NULL);
+ g_assert (i->uid != NULL);
g_assert (i->calobj != NULL);
+ g_free (i->uid);
g_free (i->calobj);
g_free (i);
}
- g_list_free (l);
+ g_list_free (list);
+}
+
+/**
+ * cal_obj_uid_list_free:
+ * @list: List of strings with unique identifiers.
+ *
+ * Frees a list of unique identifiers for calendar objects.
+ **/
+void
+cal_obj_uid_list_free (GList *list)
+{
+ GList *l;
+
+ for (l = list; l; l = l->next) {
+ char *uid;
+
+ uid = l->data;
+ g_free (uid);
+ }
+
+ g_list_free (list);
}
diff --git a/calendar/cal-client/cal-util.h b/calendar/cal-client/cal-util.h
index 3d83890d0e..45be343a28 100644
--- a/calendar/cal-client/cal-util.h
+++ b/calendar/cal-client/cal-util.h
@@ -25,6 +25,7 @@
#include <libgnome/gnome-defs.h>
#include <time.h>
#include <glib.h>
+#include "calobj.h"
BEGIN_GNOME_DECLS
@@ -34,6 +35,7 @@ BEGIN_GNOME_DECLS
* recurrence, or an alarm trigger of a `real' calendar object.
*/
typedef struct {
+ char *uid; /* Identifier for the object wrapped in calobj */
char *calobj; /* String representation of calendar object */
time_t start; /* Start time of instance */
time_t end; /* End time of instance */
@@ -41,6 +43,16 @@ typedef struct {
void cal_obj_instance_list_free (GList *list);
+/* Used for multiple UID queries */
+typedef enum {
+ CALOBJ_TYPE_EVENT = 1 << 0,
+ CALOBJ_TYPE_TODO = 1 << 1,
+ CALOBJ_TYPE_JOURNAL = 1 << 2,
+ CALOBJ_TYPE_OTHER = 1 << 3,
+ CALOBJ_TYPE_ANY = 0x0f
+} CalObjType;
+
+void cal_obj_uid_list_free (GList *list);