[evolution-data-server/treitter-client-gdbus] Port EDataCal method 'getLdapAttribute' and add a regression test.



commit 54ef890157ce450ae012d5053abc9e886c8d54fd
Author: Travis Reitter <treitter gmail com>
Date:   Thu Dec 17 09:59:28 2009 -0800

    Port EDataCal method 'getLdapAttribute' and add a regression test.

 calendar/libecal/e-cal.c                           |    4 +-
 calendar/libecal/e-data-cal-gdbus-bindings.h       |   14 ++++++++++
 calendar/tests/ecal/Makefile.am                    |    3 ++
 calendar/tests/ecal/ecal-test-utils.c              |   15 ++++++++++
 calendar/tests/ecal/ecal-test-utils.h              |    3 ++
 calendar/tests/ecal/test-ecal-get-ldap-attribute.c |   28 ++++++++++++++++++++
 6 files changed, 65 insertions(+), 2 deletions(-)
---
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index e55a48a..f15a7e4 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -1681,7 +1681,7 @@ e_cal_get_ldap_attribute (ECal *ecal, gchar **ldap_attribute, GError **error)
 	e_return_error_if_fail (ldap_attribute != 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);
 	*ldap_attribute = NULL;
 
 	if (priv->load_state != E_CAL_LOAD_LOADED) {
@@ -1689,7 +1689,7 @@ e_cal_get_ldap_attribute (ECal *ecal, gchar **ldap_attribute, GError **error)
 	}
 
 	LOCK_CONN ();
-	if (!org_gnome_evolution_dataserver_calendar_Cal_get_ldap_attribute (priv->proxy, ldap_attribute, error)) {
+	if (!e_data_cal_gdbus_get_ldap_attribute_sync (priv->gdbus_proxy, ldap_attribute, error)) {
 		UNLOCK_CONN ();
 		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 9c8e451..4964169 100644
--- a/calendar/libecal/e-data-cal-gdbus-bindings.h
+++ b/calendar/libecal/e-data-cal-gdbus-bindings.h
@@ -158,4 +158,18 @@ e_data_cal_gdbus_get_cal_address_sync (GDBusProxy  *proxy,
         return demarshal_retvals__STRING (retvals, address);
 }
 
+static gboolean
+e_data_cal_gdbus_get_ldap_attribute_sync (GDBusProxy  *proxy,
+					  char       **attr,
+					  GError     **error)
+{
+        GVariant *parameters;
+        GVariant *retvals;
+
+        parameters = g_variant_new ("()");
+	retvals = g_dbus_proxy_invoke_method_sync (proxy, "getLdapAttribute", parameters, -1, NULL, error);
+
+        return demarshal_retvals__STRING (retvals, attr);
+}
+
 G_END_DECLS
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am
index c6f6401..6c5910e 100644
--- a/calendar/tests/ecal/Makefile.am
+++ b/calendar/tests/ecal/Makefile.am
@@ -36,6 +36,7 @@ TESTS = \
         test-ecal-open				\
         test-ecal-get-alarm-email-address	\
         test-ecal-get-cal-address		\
+        test-ecal-get-ldap-attribute		\
         $(NULL)
 
 # The test program
@@ -50,6 +51,8 @@ test_ecal_get_alarm_email_address_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_get_alarm_email_address_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_get_cal_address_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_get_cal_address_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
+test_ecal_get_ldap_attribute_LDADD=$(TEST_ECAL_LIBS)
+test_ecal_get_ldap_attribute_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_open_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_open_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_remove_LDADD=$(TEST_ECAL_LIBS)
diff --git a/calendar/tests/ecal/ecal-test-utils.c b/calendar/tests/ecal/ecal-test-utils.c
index 15338bd..1eea7d8 100644
--- a/calendar/tests/ecal/ecal-test-utils.c
+++ b/calendar/tests/ecal/ecal-test-utils.c
@@ -163,3 +163,18 @@ ecal_test_utils_cal_get_cal_address (ECal *cal)
 
 	return address;
 }
+
+char*
+ecal_test_utils_cal_get_ldap_attribute (ECal *cal)
+{
+        GError *error = NULL;
+	char *attr = NULL;
+
+        if (!e_cal_get_ldap_attribute (cal, &attr, &error)) {
+                g_warning ("failed to get ldap attribute; %s\n", error->message);
+                exit(1);
+        }
+        g_print ("successfully got the ldap attribute\n");
+
+	return attr;
+}
diff --git a/calendar/tests/ecal/ecal-test-utils.h b/calendar/tests/ecal/ecal-test-utils.h
index afb7f88..ebcb767 100644
--- a/calendar/tests/ecal/ecal-test-utils.h
+++ b/calendar/tests/ecal/ecal-test-utils.h
@@ -53,4 +53,7 @@ ecal_test_utils_cal_get_alarm_email_address (ECal *cal);
 char*
 ecal_test_utils_cal_get_cal_address (ECal *cal);
 
+char*
+ecal_test_utils_cal_get_ldap_attribute (ECal *cal);
+
 #endif /* _ECAL_TEST_UTILS_H */
diff --git a/calendar/tests/ecal/test-ecal-get-ldap-attribute.c b/calendar/tests/ecal/test-ecal-get-ldap-attribute.c
new file mode 100644
index 0000000..a1758e9
--- /dev/null
+++ b/calendar/tests/ecal/test-ecal-get-ldap-attribute.c
@@ -0,0 +1,28 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <libecal/e-cal.h>
+
+#include "ecal-test-utils.h"
+
+gint
+main (gint argc, gchar **argv)
+{
+	ECal *cal;
+	char *uri = NULL;
+	char *attr;
+
+	g_type_init ();
+
+	cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
+	ecal_test_utils_cal_open (cal, FALSE);
+
+	attr = ecal_test_utils_cal_get_ldap_attribute (cal);
+	g_print ("LDAP attribute: '%s'\n", attr);
+
+	ecal_test_utils_cal_remove (cal);
+
+	g_free (attr);
+
+	return 0;
+}



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