[evolution-patches] e-cal APIs for beagle (like) applications to query e-d-s.



Hi,

Attached patch exposes two new e-cal APIs to fetch events for a given
source from e-d-s.

1) e_cal_get_items_from_source (ESource* source, ESourceType type, const
char* query, GError** error)

	This API fetches all the events that satisfies the sexp given in
"query" for the given source of type "type".

	If "query" is null, it fetches all available events for the given
source "source".

2) e_cal_get_items_from_source_occur_in_range (ESource* source,
ESourceType type, time_t start_time, time_t end_time, GError** error)

	This API queries for all events available for a source between a
specified date-time range.
	This internally calls e_cal_get_items_from_source.

Let me know your comments.

Thanks,

V. Varadhan
? depcomp
? ecal-api-beagle-req.patch
? iconv-detect.h
? patch-configure-in-fix.diff
? calendar/depcomp
? calendar/install-sh
? calendar/missing
? calendar/mkinstalldirs
? calendar/ylwrap
? calendar/tests/ecal/test-recur
? camel/camel-mime-tables.c
? docs/reference/camel/Makefile
? docs/reference/camel/Makefile.in
? libedataserverui/test-contact-store
? libedataserverui/test-name-selector
? servers/exchange/Makefile
? servers/exchange/Makefile.in
? servers/exchange/lib/Makefile
? servers/exchange/lib/Makefile.in
? servers/exchange/lib/e2k-marshal.c
? servers/exchange/lib/e2k-marshal.h
? servers/exchange/lib/e2k-propnames.c
? servers/exchange/lib/e2k-propnames.h
? servers/exchange/lib/e2k-proptags.h
? servers/exchange/storage/Makefile
? servers/exchange/storage/Makefile.in
? servers/exchange/storage/e-shell-marshal.c
? servers/exchange/storage/e-shell-marshal.h
? servers/exchange/storage/libexchange-storage-1.2.pc
? servers/exchange/storage/libexchange-storage.pc
? servers/exchange/xntlm/Makefile
? servers/exchange/xntlm/Makefile.in
? src/GNOME_Evolution_DataServer_1.2.server
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.468
diff -u -p -r1.468 ChangeLog
--- calendar/ChangeLog	21 Jun 2005 05:25:48 -0000	1.468
+++ calendar/ChangeLog	21 Jun 2005 10:03:58 -0000
@@ -1,3 +1,9 @@
+2005-06-21  Veerapuram Varadhan  <vvaradhan novell com>
+
+	* libecal/e-cal.[c,h]: (e_cal_get_items_from_source) and 
+	(e_cal_get_items_from_souce_occur_in_range). Added two APIs for
+	fetching items/events available for a given source.
+	
 2005-06-21  Chenthill Palanisamy  <pchenthill novell com>
 
 	* backends/groupwise/e-cal-backend-groupwise-utils.h:
Index: calendar/libecal/e-cal.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libecal/e-cal.c,v
retrieving revision 1.102
diff -u -p -r1.102 e-cal.c
--- calendar/libecal/e-cal.c	6 May 2005 05:19:57 -0000	1.102
+++ calendar/libecal/e-cal.c	21 Jun 2005 10:03:58 -0000
@@ -5088,3 +5088,103 @@ e_cal_get_sources (ESourceList **sources
 	/* FIXME Fill in error */
 	return FALSE;	
 }
+
+/**
+ * e_cal_get_items_from_source:
+ * @source: An #ESource to be used for the client.
+ * @type: Type of the client.
+ *
+ * Fetches all the events available for the given #ESource.
+ *
+ * Return value: A list of strings representing the events available
+ * for the given @source
+ **/
+GSList* 
+e_cal_get_items_from_source (ESource* source,
+			     ECalSourceType type,
+			     const char* query,
+			     GError** error)
+{
+	GSList* ical_strings = NULL;
+	GList* ical_objects = NULL;
+	GList *l;
+	ECal *ecal = NULL;
+	gboolean ret = TRUE;
+
+	char* str;
+	char* buf = NULL;
+
+	ecal = e_cal_new (source, type);
+	if (!ecal)
+		return NULL;
+
+	if (!e_cal_open (ecal, TRUE, error))
+		goto cleanup;
+
+	if (query)
+		ret = e_cal_get_object_list (ecal, query, &ical_objects, error);
+	else
+		ret = e_cal_get_object_list (ecal, "#t", &ical_objects, error);
+
+	if (!ret)
+		goto cleanup;
+	
+	for (l = ical_objects; l; l = l->next) {
+		str = icalcomponent_as_ical_string (l->data);
+		if (str) { 
+			buf = g_strdup (str);
+			ical_strings = g_slist_append (ical_strings, buf);
+		}
+	}
+	e_cal_free_object_list (ical_objects);
+	g_object_unref (ecal);
+	return ical_strings;
+cleanup:
+	g_object_unref (ecal);
+        return NULL;
+}
+
+/**
+ * e_cal_get_items_from_source_occur_in_range:
+ * @source: An #ESource to be used for the client.
+ * @type: Type of the client.
+ * @start_date_time: Start date/time of the event/item.
+ * @end_date_time: End date/time of the event/item.
+ *
+ * Fetches all the events/items available for the given #ESource that 
+ * occur in the range @start_date_time and @end_date_time.
+ *
+ * Return value: A list of strings representing the events available
+ * for the given @source that occur in the given range.
+ **/
+GSList* 
+e_cal_get_items_from_source_occur_in_range (ESource* source,
+					    ECalSourceType type,
+					    time_t start_date_time,
+					    time_t end_date_time,
+					    GError** error)
+{
+	GSList* items_list = NULL;
+	char* start_date = NULL;
+	char* end_date = NULL;
+	char* query = NULL;
+	
+	start_date = isodate_from_time_t (start_date_time);
+	end_date = isodate_from_time_t (end_date_time);
+
+	if (!start_date || !end_date)
+		return NULL;
+	
+	query = g_strdup_printf ("(occur-in-time-range? (make-time \"%s\")"
+				 "                      (make-time \"%s\"))",
+				 start_date,
+				 end_date);
+	
+	items_list = e_cal_get_items_from_source (source, type, query, error);
+	
+	g_free (start_date);
+	g_free (end_date);
+	g_free (query);
+	
+	return items_list;
+}
Index: calendar/libecal/e-cal.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/libecal/e-cal.h,v
retrieving revision 1.23
diff -u -p -r1.23 e-cal.h
--- calendar/libecal/e-cal.h	24 Mar 2005 08:33:29 -0000	1.23
+++ calendar/libecal/e-cal.h	21 Jun 2005 10:03:58 -0000
@@ -205,6 +205,10 @@ gboolean    e_cal_set_default_source (ES
 gboolean    e_cal_get_sources (ESourceList **sources, ECalSourceType type, GError **error);
 const char * e_cal_get_local_attachment_store (ECal *ecal);
 
+/* Calendar utilities */
+GSList*     e_cal_get_items_from_source (ESource *source, ECalSourceType type, const char* query, GError **error);
+GSList*     e_cal_get_items_from_source_occur_in_range (ESource* source, ECalSourceType type, time_t start_date_time, time_t end_date_time, GError** error);
+
 G_END_DECLS
 
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]