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



commit 7b49048094d68eb52ffce198819cb07de7488863
Author: Travis Reitter <treitter gmail com>
Date:   Thu Dec 17 09:50:03 2009 -0800

    Port EDataCal method 'getAlarmEmailAddress' 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 ++
 .../tests/ecal/test-ecal-get-alarm-email-address.c |   28 ++++++++++++++++++++
 6 files changed, 65 insertions(+), 2 deletions(-)
---
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index 3b9cf28..e55a48a 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -1645,7 +1645,7 @@ e_cal_get_alarm_email_address (ECal *ecal, gchar **alarm_address, GError **error
 	e_return_error_if_fail (alarm_address != 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);
 	*alarm_address = NULL;
 
 	if (priv->load_state != E_CAL_LOAD_LOADED) {
@@ -1653,7 +1653,7 @@ e_cal_get_alarm_email_address (ECal *ecal, gchar **alarm_address, GError **error
 	}
 
 	LOCK_CONN ();
-	if (!org_gnome_evolution_dataserver_calendar_Cal_get_alarm_email_address (priv->proxy, alarm_address, error)) {
+	if (!e_data_cal_gdbus_get_alarm_email_address_sync (priv->gdbus_proxy, alarm_address, 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 e47c7fa..9c8e451 100644
--- a/calendar/libecal/e-data-cal-gdbus-bindings.h
+++ b/calendar/libecal/e-data-cal-gdbus-bindings.h
@@ -131,6 +131,20 @@ e_data_cal_gdbus_remove_sync (GDBusProxy  *proxy,
 }
 
 static gboolean
+e_data_cal_gdbus_get_alarm_email_address_sync (GDBusProxy  *proxy,
+					       char       **address,
+					       GError     **error)
+{
+        GVariant *parameters;
+        GVariant *retvals;
+
+        parameters = g_variant_new ("()");
+	retvals = g_dbus_proxy_invoke_method_sync (proxy, "getAlarmEmailAddress", parameters, -1, NULL, error);
+
+        return demarshal_retvals__STRING (retvals, address);
+}
+
+static gboolean
 e_data_cal_gdbus_get_cal_address_sync (GDBusProxy  *proxy,
 				       char       **address,
 				       GError     **error)
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am
index f837567..c6f6401 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-alarm-email-address	\
         test-ecal-get-cal-address		\
         $(NULL)
 
@@ -45,6 +46,8 @@ TEST_ECAL_CPPFLAGS= \
 	$(NULL)
 
 # ordered alphanumerically
+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_open_LDADD=$(TEST_ECAL_LIBS)
diff --git a/calendar/tests/ecal/ecal-test-utils.c b/calendar/tests/ecal/ecal-test-utils.c
index 5e92cee..15338bd 100644
--- a/calendar/tests/ecal/ecal-test-utils.c
+++ b/calendar/tests/ecal/ecal-test-utils.c
@@ -135,6 +135,21 @@ ecal_test_utils_cal_remove (ECal *cal)
 }
 
 char*
+ecal_test_utils_cal_get_alarm_email_address (ECal *cal)
+{
+        GError *error = NULL;
+	char *address = NULL;
+
+        if (!e_cal_get_alarm_email_address (cal, &address, &error)) {
+                g_warning ("failed to get alarm email address; %s\n", error->message);
+                exit(1);
+        }
+        g_print ("successfully got the alarm email address\n");
+
+	return address;
+}
+
+char*
 ecal_test_utils_cal_get_cal_address (ECal *cal)
 {
         GError *error = NULL;
diff --git a/calendar/tests/ecal/ecal-test-utils.h b/calendar/tests/ecal/ecal-test-utils.h
index e4ffc40..afb7f88 100644
--- a/calendar/tests/ecal/ecal-test-utils.h
+++ b/calendar/tests/ecal/ecal-test-utils.h
@@ -48,6 +48,9 @@ void
 ecal_test_utils_cal_remove (ECal *cal);
 
 char*
+ecal_test_utils_cal_get_alarm_email_address (ECal *cal);
+
+char*
 ecal_test_utils_cal_get_cal_address (ECal *cal);
 
 #endif /* _ECAL_TEST_UTILS_H */
diff --git a/calendar/tests/ecal/test-ecal-get-alarm-email-address.c b/calendar/tests/ecal/test-ecal-get-alarm-email-address.c
new file mode 100644
index 0000000..4ac39ef
--- /dev/null
+++ b/calendar/tests/ecal/test-ecal-get-alarm-email-address.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 *address;
+
+	g_type_init ();
+
+	cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
+	ecal_test_utils_cal_open (cal, FALSE);
+
+	address = ecal_test_utils_cal_get_alarm_email_address (cal);
+	g_print ("alarm email address: '%s'\n", address);
+
+	ecal_test_utils_cal_remove (cal);
+
+	g_free (address);
+
+	return 0;
+}



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