gint
main (gint argc, gchar **argv)
{
	ECal *cal;
	gchar *uri = NULL;
	GMainLoop *loop;

	g_type_init ();

	/* Sync version */
	cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
	ecal_test_utils_cal_open (cal, FALSE);
	ecal_test_utils_cal_remove (cal);

	/* Async version */
	cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
	open_timeout_id = g_timeout_add_seconds (OPEN_ASYNC_TIMEOUT,
			(GSourceFunc) open_timeout_cb, cal);

	loop = g_main_loop_new (NULL, TRUE);
	ecal_test_utils_cal_async_open (cal, FALSE,
			(GSourceFunc) open_complete_cb, loop);
	g_main_loop_run (loop);

	ecal_test_utils_cal_remove (cal);

	return 0;
}
gint
main (gint argc, gchar **argv)
{
	ECal *cal;
	gchar *uri = NULL;
	ECalComponent *e_component, *e_component_final;
	icalcomponent *icalcomponent_final;
	gchar *uid;

	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", EVENT_SUMMARY, &e_component,
			&uid);

	icalcomponent_final = ecal_test_utils_cal_get_object (cal, uid);
	e_component_final = e_cal_component_new ();
	ecal_test_utils_cal_component_set_icalcomponent (e_component_final,
				icalcomponent_final);
	ecal_test_utils_cal_assert_e_cal_components_equal (e_component,
			e_component_final);

	g_object_unref (e_component_final);
	g_object_unref (e_component);
	g_free (uid);

	return 0;
}
gint
main (gint argc,
      gchar **argv)
{
	gchar *uri = NULL;
	ECal *cals[NUM_CALS];
	gint i;

	g_type_init ();

	/* Create and open many calendars; then remove each of them */

	for (i = 0; i < NUM_CALS; i++) {
		cals[i] = ecal_test_utils_cal_new_temp (&uri,
				E_CAL_SOURCE_TYPE_EVENT);
		ecal_test_utils_cal_open (cals[i], FALSE);

		g_free (uri);
	}

	for (i = 0; i < NUM_CALS; i++) {
		ecal_test_utils_cal_remove (cals[i]);
	}

	return 0;
}
gint
main (gint argc, gchar **argv)
{
	ECal *cal;
	gchar *uri = NULL;
	ECalComponent *e_component = NULL;
	icalcomponent *component = NULL;
	gchar *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;
}
gint
main (gint argc,
      gchar **argv)
{
	ECal *cal;
	gchar *uri = NULL;
	ECalComponent *e_component;
	ECalComponent *e_component_final;
	icalcomponent *component;
	icalcomponent *component_final;
	struct icaltimetype icaltime;
	gchar *uid;

	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, INITIAL_BEGIN_TIME,
			INITIAL_BEGIN_TIMEZONE, INITIAL_END_TIME,
			INITIAL_END_TIMEZONE, EVENT_SUMMARY, &e_component,
			&uid);
	component = e_cal_component_get_icalcomponent (e_component);

	component_final = ecal_test_utils_cal_get_object (cal, uid);
	ecal_test_utils_cal_assert_objects_equal_shallow (component,
			component_final);
	icalcomponent_free (component_final);

	/* make and commit changes */
	icaltime = icaltime_from_string (FINAL_BEGIN_TIME);
	icalcomponent_set_dtstart (component, icaltime);
	ecal_test_utils_cal_component_set_icalcomponent (e_component,
			component);
	ecal_test_utils_cal_modify_object (cal, component, CALOBJ_MOD_ALL);

	/* verify */
	component_final = ecal_test_utils_cal_get_object (cal, uid);
	e_component_final = e_cal_component_new ();
	ecal_test_utils_cal_component_set_icalcomponent (e_component_final,
				component_final);

	ecal_test_utils_cal_assert_e_cal_components_equal (e_component,
			e_component_final);

	/* Clean-up */
	ecal_test_utils_cal_remove (cal);

	g_object_unref (e_component_final);
	g_free (uid);
	icalcomponent_free (component);

	return 0;
}
gint
main (gint argc, gchar **argv)
{
	ECal *cal;
	gchar *uri = NULL;
	gchar *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);
	test_print ("LDAP attribute: '%s'\n", attr);

	ecal_test_utils_cal_remove (cal);

	g_free (attr);

	return 0;
}
gint
main (gint argc,
      gchar **argv)
{
	ECal *cal;
	gchar *uri = NULL;
	icalproperty *property;
	icalcomponent *component;
	icaltimezone *zone;
	icaltimezone *zone_final;

	g_type_init ();

	cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT);
	ecal_test_utils_cal_open (cal, FALSE);

	/* Build up new timezone */
	component = icalcomponent_new_vtimezone ();
	property = icalproperty_new_tzid (TZID_NEW);
	icalcomponent_add_property (component, property);
	property = icalproperty_new_tzname (TZNAME_NEW);
	icalcomponent_add_property (component, property);
	zone = icaltimezone_new ();
	icaltimezone_set_component (zone, component);

	/* add */
	ecal_test_utils_cal_add_timezone (cal, zone);

	/* verify */
	zone_final = ecal_test_utils_cal_get_timezone (cal, TZID_NEW);
	g_assert (!g_strcmp0 (icaltimezone_get_tzid (zone),
			icaltimezone_get_tzid (zone_final)));
	g_assert (!g_strcmp0 (icaltimezone_get_tznames (zone),
			icaltimezone_get_tznames (zone_final)));

	ecal_test_utils_cal_remove (cal);
	icaltimezone_free (zone, TRUE);

	return 0;
}
gint
main (gint argc,
      gchar **argv)
{
	ECal *cal;
	gchar *uri = NULL;
	gchar *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_cal_address (cal);
	test_print ("calendar address: '%s'\n", address);

	ecal_test_utils_cal_remove (cal);

	g_free (address);

	return 0;
}
gint
main (gint argc, gchar **argv)
{
	ECal *cal;
	gchar *uri = NULL;
	icalcomponent *component;
	gchar *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);
	test_print ("default object:\n%s", component_string);

	ecal_test_utils_cal_remove (cal);

	g_free (component_string);

	return 0;
}