Esempio n. 1
0
static void
mail_config_ews_notebook_constructed (GObject *object)
{
	EMailConfigEwsNotebook *extension;
	EMailConfigNotebook *notebook;
	EMailSession *session;
	ESource *account_source;
	ESource *identity_source;
	ESource *collection_source;
	ESourceBackend *backend_ext;
	ESourceRegistry *registry;
	const gchar *backend_name;
	const gchar *extension_name;

	extension = E_MAIL_CONFIG_EWS_NOTEBOOK (object);
	notebook = mail_config_ews_notebook_get_extensible (extension);

	/* Chain up to parent's constructed() method. */
	G_OBJECT_CLASS (e_mail_config_ews_notebook_parent_class)->constructed (object);

	session = e_mail_config_notebook_get_session (notebook);
	registry = e_mail_session_get_registry (session);

	account_source =
		e_mail_config_notebook_get_account_source (notebook);
	identity_source =
		e_mail_config_notebook_get_identity_source (notebook);
	collection_source =
		e_mail_config_notebook_get_collection_source (notebook);

	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
	backend_ext = e_source_get_extension (account_source, extension_name);
	backend_name = e_source_backend_get_backend_name (backend_ext);

	if (g_strcmp0 (backend_name, "ews") == 0) {
		EMailConfigPage *page;

		page = e_mail_config_ews_ooo_page_new (
			registry,
			account_source,
			identity_source,
			collection_source);
		e_mail_config_notebook_add_page (notebook, page);

		page = e_mail_config_ews_delegates_page_new (
			registry,
			account_source,
			identity_source,
			collection_source);
		e_mail_config_notebook_add_page (notebook, page);

		page = e_mail_config_ews_folder_sizes_page_new (
			account_source,
			registry);
		e_mail_config_notebook_add_page (notebook, page);
	}
}
static void
e_mail_config_mapi_extension_constructed (GObject *object)
{
	EExtension *extension;
	EExtensible *extensible;
	ESource *source;
	ESourceBackend *backend_ext;
	EMailConfigNotebook *notebook;
	const gchar *backend_name;
	const gchar *extension_name;

	extension = E_EXTENSION (object);
	extensible = e_extension_get_extensible (extension);

	/* Chain up to parent's constructed() method. */
	G_OBJECT_CLASS (e_mail_config_mapi_extension_parent_class)->constructed (object);

	notebook = E_MAIL_CONFIG_NOTEBOOK (extensible);
	source = e_mail_config_notebook_get_account_source (notebook);

	extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
	backend_ext = e_source_get_extension (source, extension_name);
	backend_name = e_source_backend_get_backend_name (backend_ext);

	if (g_strcmp0 (backend_name, "mapi") == 0) {
		ESource *profile_source;
		ESourceCamel *camel_ext;
		ESourceRegistry *registry;
		EMailSession *mail_session;
		CamelSettings *settings;
		const gchar *profile;

		mail_session = e_mail_config_notebook_get_session (notebook);
		registry = e_mail_session_get_registry (mail_session);

		if (e_source_get_parent (source))
			profile_source = e_source_registry_ref_source (registry, e_source_get_parent (source));
		else
			profile_source = g_object_ref (source);

		camel_ext = e_source_get_extension (profile_source, e_source_camel_get_extension_name (backend_name));
		settings = e_source_camel_get_settings (camel_ext);
		profile = camel_mapi_settings_get_profile (CAMEL_MAPI_SETTINGS (settings));

		/* add page only when editing already configured accounts */
		if (profile && *profile) {
			EMailConfigPage *page;

			page = e_mail_config_mapi_page_new (source, registry);
			e_mail_config_notebook_add_page (notebook, page);
		}

		g_object_unref (profile_source);
	}
}