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



commit 55e5dc1816c403ee548dd24ecd3074dcc65c9f03
Author: Travis Reitter <treitter gmail com>
Date:   Tue Dec 22 21:01:54 2009 -0800

    Port EDataCal method 'receiveObjects' and add a basic 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           |   13 ++++++++
 calendar/tests/ecal/ecal-test-utils.h           |    3 ++
 calendar/tests/ecal/test-ecal-receive-objects.c |   36 +++++++++++++++++++++++
 6 files changed, 71 insertions(+), 2 deletions(-)
---
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index 3981e6f..f97de81 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -3585,14 +3585,14 @@ e_cal_receive_objects (ECal *ecal, icalcomponent *icalcomp, GError **error)
 	e_return_error_if_fail (icalcomp, E_CALENDAR_STATUS_INVALID_ARG);
 	e_return_error_if_fail (icalcomponent_is_valid (icalcomp), 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);
 
 	if (priv->load_state != E_CAL_LOAD_LOADED) {
 		E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_URI_NOT_LOADED, error);
 	}
 
 	LOCK_CONN ();
-	if (!org_gnome_evolution_dataserver_calendar_Cal_receive_objects (priv->proxy, icalcomponent_as_ical_string (icalcomp), error)) {
+	if (!e_data_cal_gdbus_receive_objects_sync (priv->gdbus_proxy, icalcomponent_as_ical_string (icalcomp), 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 c522eb6..4fe3de9 100644
--- a/calendar/libecal/e-data-cal-gdbus-bindings.h
+++ b/calendar/libecal/e-data-cal-gdbus-bindings.h
@@ -369,5 +369,19 @@ e_data_cal_gdbus_send_objects_sync (GDBusProxy   *proxy,
 	return demarshal_retvals__STRINGVECTOR_STRING (retvals, OUT_users, OUT_object);
 }
 
+static gboolean
+e_data_cal_gdbus_receive_objects_sync (GDBusProxy  *proxy,
+				       const char  *IN_object,
+				       GError     **error)
+{
+	GVariant *parameters;
+	GVariant *retvals;
+
+	parameters = g_variant_new ("(s)", IN_object);
+
+	retvals = g_dbus_proxy_invoke_method_sync (proxy, "receiveObjects", parameters, -1, NULL, error);
+
+	return demarshal_retvals__VOID (retvals);
+}
 
 G_END_DECLS
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am
index 74e082b..38edcb8 100644
--- a/calendar/tests/ecal/Makefile.am
+++ b/calendar/tests/ecal/Makefile.am
@@ -51,6 +51,7 @@ TESTS = \
         test-ecal-get-object-list		\
         test-ecal-modify-object			\
         test-ecal-send-objects			\
+        test-ecal-receive-objects		\
         $(NULL)
 
 # The test program
@@ -89,6 +90,8 @@ test_ecal_modify_object_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_modify_object_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_open_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_open_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
+test_ecal_receive_objects_LDADD=$(TEST_ECAL_LIBS)
+test_ecal_receive_objects_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_remove_LDADD=$(TEST_ECAL_LIBS)
 test_ecal_remove_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
 test_ecal_remove_object_LDADD=$(TEST_ECAL_LIBS)
diff --git a/calendar/tests/ecal/ecal-test-utils.c b/calendar/tests/ecal/ecal-test-utils.c
index 0b1be76..ea82c46 100644
--- a/calendar/tests/ecal/ecal-test-utils.c
+++ b/calendar/tests/ecal/ecal-test-utils.c
@@ -634,3 +634,16 @@ ecal_test_utils_cal_send_objects (ECal           *cal,
 		g_print ("        %s\n", (const char*) l->data);
 	}
 }
+
+void
+ecal_test_utils_cal_receive_objects (ECal          *cal,
+				     icalcomponent *component)
+{
+	GError *error = NULL;
+
+	if (!e_cal_receive_objects (cal, component, &error)) {
+		g_error ("receiving objects: %s\n", error->message);
+	}
+
+	g_print ("successfully received the objects\n");
+}
diff --git a/calendar/tests/ecal/ecal-test-utils.h b/calendar/tests/ecal/ecal-test-utils.h
index 641d6f1..ff3adaf 100644
--- a/calendar/tests/ecal/ecal-test-utils.h
+++ b/calendar/tests/ecal/ecal-test-utils.h
@@ -140,5 +140,8 @@ ecal_test_utils_cal_send_objects (ECal           *cal,
                                   GList         **users,
                                   icalcomponent **component_final);
 
+void
+ecal_test_utils_cal_receive_objects (ECal          *cal,
+                                     icalcomponent *component);
 
 #endif /* _ECAL_TEST_UTILS_H */
diff --git a/calendar/tests/ecal/test-ecal-receive-objects.c b/calendar/tests/ecal/test-ecal-receive-objects.c
new file mode 100644
index 0000000..6500d8f
--- /dev/null
+++ b/calendar/tests/ecal/test-ecal-receive-objects.c
@@ -0,0 +1,36 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <libecal/e-cal.h>
+#include <libical/ical.h>
+
+#include "ecal-test-utils.h"
+
+gint
+main (gint argc, gchar **argv)
+{
+	ECal *cal;
+	char *uri = NULL;
+	ECalComponent *e_component = NULL;
+	icalcomponent *component = NULL;
+	char *uid = NULL;
+
+	g_type_init ();
+
+	cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
+	ecal_test_utils_cal_open (cal, FALSE);
+
+        ecal_test_utils_create_component (cal, "20040109T090000Z", "UTC",
+			"20040109T103000", "UTC", "meeting request",
+			&e_component, &uid);
+
+	component = e_cal_component_get_icalcomponent (e_component);
+	ecal_test_utils_cal_receive_objects (cal, component);
+
+	ecal_test_utils_cal_remove (cal);
+
+	g_object_unref (e_component);
+	g_free (uid);
+
+	return 0;
+}



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