[evolution-data-server/treitter-client-gdbus] Port EDataCal method 'sendObjects' 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 'sendObjects' and add a basic regression test.
- Date: Wed, 23 Dec 2009 20:04:46 +0000 (UTC)
commit 10f3c38d50b1ea4aceb3aef99bc0c7fa7d99bae4
Author: Travis Reitter <treitter gmail com>
Date: Tue Dec 22 18:21:10 2009 -0800
Port EDataCal method 'sendObjects' and add a basic regression test.
calendar/libecal/e-cal.c | 10 ++--
calendar/libecal/e-data-cal-gdbus-bindings.h | 17 ++++++++
calendar/tests/ecal/Makefile.am | 3 +
calendar/tests/ecal/ecal-test-utils.c | 23 +++++++++++
calendar/tests/ecal/ecal-test-utils.h | 7 +++
calendar/tests/ecal/test-ecal-send-objects.c | 41 ++++++++++++++++++++
.../e-data-gdbus-bindings-common.h | 39 +++++++++++++++++++
7 files changed, 135 insertions(+), 5 deletions(-)
---
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index 7faceac..3981e6f 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -3605,7 +3605,7 @@ e_cal_receive_objects (ECal *ecal, icalcomponent *icalcomp, GError **error)
* e_cal_send_objects:
* @ecal: A calendar client.
* @icalcomp: An icalcomponent.
- * @users: List of users to send the objects to.
+ * @users: Return value for the list of users the objects are sent to.
* @modified_icalcomp: Return value for the icalcomponent after all the operations
* performed.
* @error: Placeholder for error information.
@@ -3620,8 +3620,8 @@ e_cal_send_objects (ECal *ecal, icalcomponent *icalcomp, GList **users, icalcomp
{
ECalPrivate *priv;
ECalendarStatus status;
- gchar **users_array;
- gchar *object;
+ gchar **users_array = NULL;
+ gchar *object = NULL;
e_return_error_if_fail (users != NULL, E_CALENDAR_STATUS_INVALID_ARG);
e_return_error_if_fail (modified_icalcomp != NULL, E_CALENDAR_STATUS_INVALID_ARG);
@@ -3629,7 +3629,7 @@ e_cal_send_objects (ECal *ecal, icalcomponent *icalcomp, GList **users, icalcomp
e_return_error_if_fail (icalcomponent_is_valid (icalcomp), 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);
*users = NULL;
*modified_icalcomp = NULL;
@@ -3638,7 +3638,7 @@ e_cal_send_objects (ECal *ecal, icalcomponent *icalcomp, GList **users, icalcomp
}
LOCK_CONN ();
- if (!org_gnome_evolution_dataserver_calendar_Cal_send_objects (priv->proxy, icalcomponent_as_ical_string (icalcomp), &users_array, &object, error)) {
+ if (!e_data_cal_gdbus_send_objects_sync (priv->gdbus_proxy, icalcomponent_as_ical_string (icalcomp), &users_array, &object, 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 c3ce19e..c522eb6 100644
--- a/calendar/libecal/e-data-cal-gdbus-bindings.h
+++ b/calendar/libecal/e-data-cal-gdbus-bindings.h
@@ -352,5 +352,22 @@ e_data_cal_gdbus_get_free_busy_sync (GDBusProxy *proxy,
return demarshal_retvals__STRINGVECTOR (retvals, OUT_free_busy);
}
+static gboolean
+e_data_cal_gdbus_send_objects_sync (GDBusProxy *proxy,
+ const char *IN_object,
+ char ***OUT_users,
+ char **OUT_object,
+ GError **error)
+{
+ GVariant *parameters;
+ GVariant *retvals;
+
+ parameters = g_variant_new ("(s)", IN_object);
+
+ retvals = g_dbus_proxy_invoke_method_sync (proxy, "sendObjects", parameters, -1, NULL, error);
+
+ return demarshal_retvals__STRINGVECTOR_STRING (retvals, OUT_users, OUT_object);
+}
+
G_END_DECLS
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am
index c3c3fa8..74e082b 100644
--- a/calendar/tests/ecal/Makefile.am
+++ b/calendar/tests/ecal/Makefile.am
@@ -50,6 +50,7 @@ TESTS = \
test-ecal-remove-object \
test-ecal-get-object-list \
test-ecal-modify-object \
+ test-ecal-send-objects \
$(NULL)
# The test program
@@ -92,6 +93,8 @@ test_ecal_remove_LDADD=$(TEST_ECAL_LIBS)
test_ecal_remove_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
test_ecal_remove_object_LDADD=$(TEST_ECAL_LIBS)
test_ecal_remove_object_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
+test_ecal_send_objects_LDADD=$(TEST_ECAL_LIBS)
+test_ecal_send_objects_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
test_ecal_set_default_timezone_LDADD=$(TEST_ECAL_LIBS)
test_ecal_set_default_timezone_CPPFLAGS=$(TEST_ECAL_CPPFLAGS)
test_ecal_set_mode_LDADD=$(TEST_ECAL_LIBS)
diff --git a/calendar/tests/ecal/ecal-test-utils.c b/calendar/tests/ecal/ecal-test-utils.c
index 7b41a54..0b1be76 100644
--- a/calendar/tests/ecal/ecal-test-utils.c
+++ b/calendar/tests/ecal/ecal-test-utils.c
@@ -611,3 +611,26 @@ ecal_test_utils_cal_get_free_busy (ECal *cal,
return free_busy;
}
+
+void
+ecal_test_utils_cal_send_objects (ECal *cal,
+ icalcomponent *component,
+ GList **users,
+ icalcomponent **component_final)
+{
+ GList *l = NULL;
+ GError *error = NULL;
+
+ if (!e_cal_send_objects (cal, component, users, component_final, &error)) {
+ g_error ("sending objects: %s\n", error->message);
+ }
+
+ g_print ("successfully sent the objects to the following users:\n");
+ if (g_list_length (*users) <= 0) {
+ g_print (" (none)\n");
+ return;
+ }
+ for (l = *users; l; l = l->next) {
+ g_print (" %s\n", (const char*) l->data);
+ }
+}
diff --git a/calendar/tests/ecal/ecal-test-utils.h b/calendar/tests/ecal/ecal-test-utils.h
index a3db11d..641d6f1 100644
--- a/calendar/tests/ecal/ecal-test-utils.h
+++ b/calendar/tests/ecal/ecal-test-utils.h
@@ -134,4 +134,11 @@ void
ecal_test_utils_cal_set_default_timezone (ECal *cal,
icaltimezone *zone);
+void
+ecal_test_utils_cal_send_objects (ECal *cal,
+ icalcomponent *component,
+ GList **users,
+ icalcomponent **component_final);
+
+
#endif /* _ECAL_TEST_UTILS_H */
diff --git a/calendar/tests/ecal/test-ecal-send-objects.c b/calendar/tests/ecal/test-ecal-send-objects.c
new file mode 100644
index 0000000..fcd7c95
--- /dev/null
+++ b/calendar/tests/ecal/test-ecal-send-objects.c
@@ -0,0 +1,41 @@
+/* -*- 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;
+ GList *users = NULL;
+ ECalComponent *e_component = NULL;
+ icalcomponent *component = NULL;
+ icalcomponent *modified_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", "new event", &e_component,
+ &uid);
+
+ component = e_cal_component_get_icalcomponent (e_component);
+ ecal_test_utils_cal_send_objects (cal, component, &users, &modified_component);
+
+ ecal_test_utils_cal_remove (cal);
+
+ g_list_foreach (users, (GFunc) g_free, NULL);
+ g_list_free (users);
+
+ g_object_unref (e_component);
+ g_free (uid);
+
+ return 0;
+}
diff --git a/libedata-gdbus-bindings/e-data-gdbus-bindings-common.h b/libedata-gdbus-bindings/e-data-gdbus-bindings-common.h
index 28abfeb..853470c 100644
--- a/libedata-gdbus-bindings/e-data-gdbus-bindings-common.h
+++ b/libedata-gdbus-bindings/e-data-gdbus-bindings-common.h
@@ -124,6 +124,45 @@ demarshal_retvals__STRINGVECTOR (GVariant *retvals, char ***OUT_strv1)
}
static gboolean
+demarshal_retvals__STRINGVECTOR_STRING (GVariant *retvals,
+ char ***OUT_strv1,
+ char **OUT_string1)
+{
+ gboolean success = TRUE;
+
+ if (retvals) {
+ GVariant *strv1_variant;
+ char **strv1 = NULL;
+ GVariant *string1_variant;
+ char *string1 = NULL;
+
+ strv1_variant = g_variant_get_child_value (retvals, 0);
+ strv1 = g_variant_dup_strv (strv1_variant, NULL);
+
+ if (strv1) {
+ *OUT_strv1 = strv1;
+ } else {
+ success = FALSE;
+ }
+
+ string1_variant = g_variant_get_child_value (retvals, 1);
+ string1 = g_variant_dup_string (string1_variant, NULL);
+
+ if (string1) {
+ *OUT_string1 = string1;
+ } else {
+ success = FALSE;
+ }
+
+ g_variant_unref (retvals);
+ } else {
+ success = FALSE;
+ }
+
+ return success;
+}
+
+static gboolean
demarshal_retvals__GPTRARRAY_with_GVALUEARRAY_with_UINT_STRING_endwith_endwith
(GVariant *retvals,
GPtrArray **OUT_ptrarray1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]