summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Reitter <treitter@gmail.com>2009-12-17 17:23:58 -0800
committerTravis Reitter <treitter@gmail.com>2009-12-17 17:23:58 -0800
commit904f1209614162276b67e4a4f2fd18790db9929a (patch)
tree2056a85bb4a20f89a9dc5ccd16f56b712d3a472e
parentddd83eda103462dbeb122e1eaf041fab59987058 (diff)
downloadevolution-data-server-904f1209614162276b67e4a4f2fd18790db9929a.tar.gz
Port EDataCal method 'getDefaultObject' and add a regression test.
-rw-r--r--calendar/libecal/e-cal.c4
-rw-r--r--calendar/libecal/e-data-cal-gdbus-bindings.h14
-rw-r--r--calendar/tests/ecal/Makefile.am3
-rw-r--r--calendar/tests/ecal/ecal-test-utils.c19
-rw-r--r--calendar/tests/ecal/ecal-test-utils.h3
-rw-r--r--calendar/tests/ecal/test-ecal-get-default-object.c31
6 files changed, 72 insertions, 2 deletions
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index 9dc0953d2..141055099 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -1912,7 +1912,7 @@ e_cal_get_default_object (ECal *ecal, icalcomponent **icalcomp, GError **error)
e_return_error_if_fail (icalcomp != 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);
*icalcomp = NULL;
if (priv->load_state != E_CAL_LOAD_LOADED) {
@@ -1920,7 +1920,7 @@ e_cal_get_default_object (ECal *ecal, icalcomponent **icalcomp, GError **error)
}
LOCK_CONN ();
- if (!org_gnome_evolution_dataserver_calendar_Cal_get_default_object (priv->proxy, &object, error)) {
+ if (!e_data_cal_gdbus_get_default_object_sync (priv->gdbus_proxy, &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 00a12ad5d..9f524d6ec 100644
--- a/calendar/libecal/e-data-cal-gdbus-bindings.h
+++ b/calendar/libecal/e-data-cal-gdbus-bindings.h
@@ -200,4 +200,18 @@ e_data_cal_gdbus_set_mode (GDBusProxy *proxy,
return demarshal_retvals__VOID (retvals);
}
+static gboolean
+e_data_cal_gdbus_get_default_object_sync (GDBusProxy *proxy,
+ char **object,
+ GError **error)
+{
+ GVariant *parameters;
+ GVariant *retvals;
+
+ parameters = g_variant_new ("()");
+ retvals = g_dbus_proxy_invoke_method_sync (proxy, "getDefaultObject", parameters, -1, NULL, error);
+
+ return demarshal_retvals__STRING (retvals, object);
+}
+
G_END_DECLS
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am
index c98ee45ba..93e16dbf1 100644
--- a/calendar/tests/ecal/Makefile.am
+++ b/calendar/tests/ecal/Makefile.am
@@ -38,6 +38,7 @@ TESTS = \
test-ecal-get-cal-address \
test-ecal-get-ldap-attribute \
test-ecal-get-capabilities \
+ test-ecal-get-default-object \
test-ecal-set-mode \
$(NULL)
@@ -53,6 +54,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_default_object_LDADD=$(TEST_ECAL_LIBS)
+test_ecal_get_default_object_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 d399bea15..3bdd96e57 100644
--- a/calendar/tests/ecal/ecal-test-utils.c
+++ b/calendar/tests/ecal/ecal-test-utils.c
@@ -263,6 +263,25 @@ ecal_test_utils_cal_get_capabilities (ECal *cal)
);
}
+icalcomponent*
+ecal_test_utils_cal_get_default_object (ECal *cal)
+{
+ GError *error = NULL;
+ icalcomponent *component = NULL;
+
+ if (!e_cal_get_default_object (cal, &component, &error)) {
+ g_warning ("failed to get default icalcomponent object; %s\n", error->message);
+ exit(1);
+ }
+ if (!icalcomponent_is_valid (component)) {
+ g_warning ("default icalcomponent is invalid\n");
+ exit(1);
+ }
+ g_print ("successfully got the default icalcomponent object\n");
+
+ return component;
+}
+
static void
cal_set_mode_cb (ECal *cal,
ECalendarStatus status,
diff --git a/calendar/tests/ecal/ecal-test-utils.h b/calendar/tests/ecal/ecal-test-utils.h
index 5e69a85a7..3e82c5296 100644
--- a/calendar/tests/ecal/ecal-test-utils.h
+++ b/calendar/tests/ecal/ecal-test-utils.h
@@ -60,6 +60,9 @@ ecal_test_utils_cal_get_ldap_attribute (ECal *cal);
void
ecal_test_utils_cal_get_capabilities (ECal *cal);
+icalcomponent*
+ecal_test_utils_cal_get_default_object (ECal *cal);
+
void
ecal_test_utils_cal_set_mode (ECal *cal,
CalMode mode,
diff --git a/calendar/tests/ecal/test-ecal-get-default-object.c b/calendar/tests/ecal/test-ecal-get-default-object.c
new file mode 100644
index 000000000..39d0afa35
--- /dev/null
+++ b/calendar/tests/ecal/test-ecal-get-default-object.c
@@ -0,0 +1,31 @@
+/* -*- 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;
+ icalcomponent *component;
+ char *component_string;
+
+ g_type_init ();
+
+ cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
+ ecal_test_utils_cal_open (cal, FALSE);
+
+ component = ecal_test_utils_cal_get_default_object (cal);
+ component_string = icalcomponent_as_ical_string (component);
+ g_print ("default object:\n%s", component_string);
+
+ ecal_test_utils_cal_remove (cal);
+
+ g_free (component_string);
+
+ return 0;
+}