コード例 #1
0
static gchar *
test_e_cal_new (ECal **cal,
                const gchar *uri)
{
	GError *error = NULL;
	gchar *cal_uri, *cal_file;
	gboolean created = 0;

	cal_uri = g_strconcat ("file://", uri, NULL);
	*cal = e_cal_new_from_uri (cal_uri, E_CAL_SOURCE_TYPE_EVENT);
	if (!*cal) {
		g_message (G_STRLOC ": could not create the client");
		g_free (cal_uri);
		return "Test Creation of new calendar : Failed";
	}
	g_object_weak_ref (G_OBJECT (*cal), client_destroy_cb, NULL);

	cl_printf (*cal, "Calendar loading `%s'...\n", uri);

	if (!e_cal_open (*cal, FALSE, &error)) {
		cl_printf (*cal, "Load/create %s\n", error->message);
		g_free (cal_uri);
		return "Test creation of new calendar : Failed";
	}

	cal_file = g_strconcat (uri, "/calendar.ics", NULL);

	created = g_file_test (cal_file, G_FILE_TEST_EXISTS);
	g_free (cal_uri);
	g_free (cal_file);

	mu_assert ("Test creation of new calendar : Failed", created);

	return NULL;
}
コード例 #2
0
void open_calendar(const char *uri, ECalSourceType source_type)
{
	ECal *cal = NULL;
	GError *gerror = NULL;
	cal = e_cal_new_from_uri(uri, source_type);

	if (!cal) {
		printf("Failed to allocate calendar\n");
		return;
	}
	if (!e_cal_open(cal, TRUE, &gerror)) {
		printf("Failed to open calendar:\n%s\n", gerror->message);
		g_clear_error(&gerror);
		return;
	}
	printf("Successfully opened %s\n", uri);
	g_object_unref(cal);
}