[evolution-data-server/treitter-client-gdbus] Port EDataCal method 'getFreeBusy' and add a basic regression test.
- From: Travis Reitter <treitter src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server/treitter-client-gdbus] Port EDataCal method 'getFreeBusy' and add a basic regression test.
- Date: Wed, 23 Dec 2009 20:04:41 +0000 (UTC)
commit 12f57cd692bae3b5174517dd353b0939f0ed9593
Author: Travis Reitter <treitter gmail com>
Date: Tue Dec 22 16:38:37 2009 -0800
Port EDataCal method 'getFreeBusy' and add a basic regression test.
calendar/libecal/e-cal.c | 4 +-
calendar/libecal/e-data-cal-gdbus-bindings.h | 19 ++++++++++++
calendar/tests/ecal/Makefile.am | 3 ++
calendar/tests/ecal/ecal-test-utils.c | 32 ++++++++++++++++++++
calendar/tests/ecal/ecal-test-utils.h | 6 ++++
calendar/tests/ecal/test-ecal-get-free-busy.c | 39 +++++++++++++++++++++++++
6 files changed, 101 insertions(+), 2 deletions(-)
---
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index cd71cce..7faceac 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -2474,7 +2474,7 @@ e_cal_get_free_busy (ECal *ecal, GList *users, time_t start, time_t end,
e_return_error_if_fail (freebusy != NULL, E_CALENDAR_STATUS_INVALID_ARG);
e_return_error_if_fail (E_IS_CAL (ecal), E_CALENDAR_STATUS_INVALID_ARG);
priv = ecal->priv;
- e_return_error_if_fail (priv->proxy, E_CALENDAR_STATUS_REPOSITORY_OFFLINE);
+ e_return_error_if_fail (priv->gdbus_proxy, E_CALENDAR_STATUS_REPOSITORY_OFFLINE);
*freebusy = NULL;
if (priv->load_state != E_CAL_LOAD_LOADED) {
@@ -2486,7 +2486,7 @@ e_cal_get_free_busy (ECal *ecal, GList *users, time_t start, time_t end,
users_list[i] = g_strdup (l->data);
LOCK_CONN ();
- if (!org_gnome_evolution_dataserver_calendar_Cal_get_free_busy (priv->proxy, (const gchar **)users_list, start, end, &freebusy_array, error)) {
+ if (!e_data_cal_gdbus_get_free_busy_sync (priv->gdbus_proxy, (const gchar **)users_list, start, end, &freebusy_array, error)) {
UNLOCK_CONN ();
g_strfreev (users_list);
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_CORBA_EXCEPTION, error);
diff --git a/calendar/libecal/e-data-cal-gdbus-bindings.h b/calendar/libecal/e-data-cal-gdbus-bindings.h
index 36286b9..c3ce19e 100644
--- a/calendar/libecal/e-data-cal-gdbus-bindings.h
+++ b/calendar/libecal/e-data-cal-gdbus-bindings.h
@@ -334,4 +334,23 @@ e_data_cal_gdbus_set_default_timezone_sync (GDBusProxy *proxy,
return demarshal_retvals__VOID (retvals);
}
+static gboolean
+e_data_cal_gdbus_get_free_busy_sync (GDBusProxy *proxy,
+ const char **IN_users,
+ const guint IN_start,
+ const guint IN_end,
+ char ***OUT_free_busy,
+ GError **error)
+{
+ GVariant *parameters;
+ GVariant *retvals;
+
+ parameters = g_variant_new ("(^asuu)", IN_users, -1, IN_start, IN_end);
+
+ retvals = g_dbus_proxy_invoke_method_sync (proxy, "getFreeBusy", parameters, -1, NULL, error);
+
+ return demarshal_retvals__STRINGVECTOR (retvals, OUT_free_busy);
+}
+
+
G_END_DECLS
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am
index fd30692..c3c3fa8 100644
--- a/calendar/tests/ecal/Makefile.am
+++ b/calendar/tests/ecal/Makefile.am
@@ -34,6 +34,7 @@ test_scripts = \
TESTS = \
test-ecal-remove \
test-ecal-open \
+ test-ecal-get-free-busy \
test-ecal-get-timezone \
test-ecal-add-timezone \
test-ecal-set-default-timezone \
@@ -71,6 +72,8 @@ test_ecal_get_cal_address_LDADD=$(TEST_ECAL_LIBS)
test_ecal_get_cal_address_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
test_ecal_get_default_object_LDADD=$(TEST_ECAL_LIBS)
test_ecal_get_default_object_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
+test_ecal_get_free_busy_LDADD=$(TEST_ECAL_LIBS)
+test_ecal_get_free_busy_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
test_ecal_get_ldap_attribute_LDADD=$(TEST_ECAL_LIBS)
test_ecal_get_ldap_attribute_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
test_ecal_get_capabilities_LDADD=$(TEST_ECAL_LIBS)
diff --git a/calendar/tests/ecal/ecal-test-utils.c b/calendar/tests/ecal/ecal-test-utils.c
index 4cc2597..7b41a54 100644
--- a/calendar/tests/ecal/ecal-test-utils.c
+++ b/calendar/tests/ecal/ecal-test-utils.c
@@ -579,3 +579,35 @@ ecal_test_utils_cal_set_default_timezone (ECal *cal,
}
g_print ("successfully set default icaltimezone '%s'\n", name);
}
+
+GList*
+ecal_test_utils_cal_get_free_busy (ECal *cal,
+ GList *users,
+ time_t start,
+ time_t end)
+{
+ GList *free_busy = NULL;
+ GList *l = NULL;
+ GError *error = NULL;
+
+ if (!e_cal_get_free_busy (cal, users, start, end, &free_busy, &error)) {
+ g_error ("Test free/busy : Could not retrieve free busy information : %s\n", error->message);
+ }
+ if (free_busy) {
+ g_print ("Printing free/busy information\n");
+
+ for (l = free_busy; l; l = l->next) {
+ gchar *comp_string;
+ ECalComponent *comp = E_CAL_COMPONENT (l->data);
+
+ comp_string = e_cal_component_get_as_string (comp);
+ g_print ("%s\n", comp_string);
+ g_object_unref (comp);
+ g_free (comp_string);
+ }
+ } else {
+ g_error ("got empty free/busy information");
+ }
+
+ return free_busy;
+}
diff --git a/calendar/tests/ecal/ecal-test-utils.h b/calendar/tests/ecal/ecal-test-utils.h
index 3deaf3f..a3db11d 100644
--- a/calendar/tests/ecal/ecal-test-utils.h
+++ b/calendar/tests/ecal/ecal-test-utils.h
@@ -60,6 +60,12 @@ ecal_test_utils_cal_get_ldap_attribute (ECal *cal);
void
ecal_test_utils_cal_get_capabilities (ECal *cal);
+GList*
+ecal_test_utils_cal_get_free_busy (ECal *cal,
+ GList *users,
+ time_t start,
+ time_t end);
+
void
ecal_test_utils_cal_assert_objects_equal_shallow (icalcomponent *a,
icalcomponent *b);
diff --git a/calendar/tests/ecal/test-ecal-get-free-busy.c b/calendar/tests/ecal/test-ecal-get-free-busy.c
new file mode 100644
index 0000000..3708fe0
--- /dev/null
+++ b/calendar/tests/ecal/test-ecal-get-free-busy.c
@@ -0,0 +1,39 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <libecal/e-cal.h>
+#include <libecal/e-cal-time-util.h>
+#include <libical/ical.h>
+
+#include "ecal-test-utils.h"
+
+gint
+main (gint argc, gchar **argv)
+{
+ ECal *cal;
+ char *uri = NULL;
+ GList *users = NULL;
+ icaltimezone *utc;
+ time_t start = time (NULL), end;
+ GList *free_busy;
+
+ g_type_init ();
+
+ cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
+ ecal_test_utils_cal_open (cal, FALSE);
+
+ utc = icaltimezone_get_utc_timezone ();
+ start = time_from_isodate ("20040212T000000Z");
+ end = time_add_day_with_zone (start, 2, utc);
+ /* XXX: create dummy list, which the file backend will ignore */
+ users = g_list_prepend (users, NULL);
+
+ free_busy = ecal_test_utils_cal_get_free_busy (cal, users, start, end);
+
+ ecal_test_utils_cal_remove (cal);
+
+ g_list_foreach (free_busy, (GFunc) icalcomponent_free, NULL);
+ g_list_free (free_busy);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]