static void
google_backend_calendar_update_auth_method (ESource *source)
{
	EOAuth2Support *oauth2_support;
	ESourceAuthentication *auth_extension;
	ESourceWebdav *webdav_extension;
	const gchar *extension_name;
	const gchar *host;
	const gchar *method;
	const gchar *path_format;
	gchar *path;
	gchar *user;

	oauth2_support = e_server_side_source_ref_oauth2_support (
		E_SERVER_SIDE_SOURCE (source));

	/* The host name and WebDAV resource path depend on the
	 * authentication method used, so update those here too. */

	if (oauth2_support != NULL) {
		method = "OAuth2";
		host = GOOGLE_CALDAV_V2_HOST;
		path_format = GOOGLE_CALDAV_V2_PATH;
	} else {
		method = "plain/password";
		host = GOOGLE_CALDAV_V1_HOST;
		path_format = GOOGLE_CALDAV_V1_PATH;
	}

	extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
	auth_extension = e_source_get_extension (source, extension_name);
	e_source_authentication_set_host (auth_extension, host);
	e_source_authentication_set_method (auth_extension, method);

	extension_name = E_SOURCE_EXTENSION_WEBDAV_BACKEND;
	webdav_extension = e_source_get_extension (source, extension_name);

	user = e_source_authentication_dup_user (auth_extension);
	path = g_strdup_printf (path_format, (user != NULL) ? user : "");
	e_source_webdav_set_resource_path (webdav_extension, path);
	g_free (path);
	g_free (user);

	g_clear_object (&oauth2_support);
}
static void
yahoo_backend_config_calendar_child (ECollectionBackend *backend,
                                     ESource *source)
{
	EYahooBackend *yahoo_backend;
	ESource *collection_source;
	ESource *mail_identity_source;
	ESourceExtension *extension;
	ESourceCollection *collection_extension;
	const gchar *extension_name;
	const gchar *identity;
	gchar *display_name = NULL;

	/* FIXME As a future enhancement, we should query Yahoo!
	 *       for a list of user calendars and add them to the
	 *       collection with matching display names and colors. */

	yahoo_backend = E_YAHOO_BACKEND (backend);

	collection_source = e_backend_get_source (E_BACKEND (backend));

	collection_extension = e_source_get_extension (
		collection_source, E_SOURCE_EXTENSION_COLLECTION);

	identity = e_source_collection_get_identity (collection_extension);

	/* XXX Assume the calendar's display name can be derived from
	 *     the user's mail identity.  As mentioned above, we should
	 *     really just query Yahoo! for a list of user calendars. */
	mail_identity_source =
		g_weak_ref_get (&yahoo_backend->mail_identity_source);
	if (mail_identity_source != NULL) {
		extension = e_source_get_extension (
			mail_identity_source,
			E_SOURCE_EXTENSION_MAIL_IDENTITY);
		display_name = e_source_mail_identity_dup_name (
			E_SOURCE_MAIL_IDENTITY (extension));
		if (display_name != NULL)
			g_strdelimit (display_name, " ", '_');
		g_object_unref (mail_identity_source);
	}

	extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
	extension = e_source_get_extension (source, extension_name);

	e_source_authentication_set_host (
		E_SOURCE_AUTHENTICATION (extension),
		YAHOO_CALENDAR_HOST);

	e_binding_bind_property (
		collection_extension, "identity",
		extension, "user",
		G_BINDING_SYNC_CREATE);

	extension_name = E_SOURCE_EXTENSION_SECURITY;
	extension = e_source_get_extension (source, extension_name);

	e_source_security_set_secure (
		E_SOURCE_SECURITY (extension), TRUE);

	extension_name = E_SOURCE_EXTENSION_WEBDAV_BACKEND;
	extension = e_source_get_extension (source, extension_name);

	e_source_webdav_set_display_name (
		E_SOURCE_WEBDAV (extension), display_name);

	if (identity != NULL && display_name != NULL) {
		gchar *resource_path;

		resource_path = g_strdup_printf (
			YAHOO_CALENDAR_CALDAV_PATH, identity, display_name);
		e_source_webdav_set_resource_path (
			E_SOURCE_WEBDAV (extension), resource_path);
		g_free (resource_path);
	}

	g_free (display_name);
}