From 05c5d2998e6acd0216917ffd8bffe33ccfbc345c Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 26 Nov 2013 11:58:13 -0500 Subject: EMailAutoconfig: Add an ESourceRegistry property. --- mail/e-mail-autoconfig.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 3 deletions(-) (limited to 'mail/e-mail-autoconfig.c') diff --git a/mail/e-mail-autoconfig.c b/mail/e-mail-autoconfig.c index 72a627b6d5..2333610420 100644 --- a/mail/e-mail-autoconfig.c +++ b/mail/e-mail-autoconfig.c @@ -94,6 +94,7 @@ struct _EMailAutoconfigResult { }; struct _EMailAutoconfigPrivate { + ESourceRegistry *registry; gchar *email_address; gchar *email_local_part; gchar *email_domain_part; @@ -109,7 +110,8 @@ struct _ParserClosure { enum { PROP_0, - PROP_EMAIL_ADDRESS + PROP_EMAIL_ADDRESS, + PROP_REGISTRY }; /* Forward Declarations */ @@ -495,6 +497,16 @@ mail_autoconfig_set_email_address (EMailAutoconfig *autoconfig, autoconfig->priv->email_address = g_strdup (email_address); } +static void +mail_autoconfig_set_registry (EMailAutoconfig *autoconfig, + ESourceRegistry *registry) +{ + g_return_if_fail (E_IS_SOURCE_REGISTRY (registry)); + g_return_if_fail (autoconfig->priv->registry == NULL); + + autoconfig->priv->registry = g_object_ref (registry); +} + static void mail_autoconfig_set_property (GObject *object, guint property_id, @@ -507,6 +519,12 @@ mail_autoconfig_set_property (GObject *object, E_MAIL_AUTOCONFIG (object), g_value_get_string (value)); return; + + case PROP_REGISTRY: + mail_autoconfig_set_registry ( + E_MAIL_AUTOCONFIG (object), + g_value_get_object (value)); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -525,11 +543,31 @@ mail_autoconfig_get_property (GObject *object, e_mail_autoconfig_get_email_address ( E_MAIL_AUTOCONFIG (object))); return; + + case PROP_REGISTRY: + g_value_set_object ( + value, + e_mail_autoconfig_get_registry ( + E_MAIL_AUTOCONFIG (object))); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } +static void +mail_autoconfig_dispose (GObject *object) +{ + EMailAutoconfigPrivate *priv; + + priv = E_MAIL_AUTOCONFIG_GET_PRIVATE (object); + + g_clear_object (&priv->registry); + + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (e_mail_autoconfig_parent_class)->dispose (object); +} + static void mail_autoconfig_finalize (GObject *object) { @@ -661,6 +699,7 @@ e_mail_autoconfig_class_init (EMailAutoconfigClass *class) object_class = G_OBJECT_CLASS (class); object_class->set_property = mail_autoconfig_set_property; object_class->get_property = mail_autoconfig_get_property; + object_class->dispose = mail_autoconfig_dispose; object_class->finalize = mail_autoconfig_finalize; g_object_class_install_property ( @@ -674,6 +713,18 @@ e_mail_autoconfig_class_init (EMailAutoconfigClass *class) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property ( + object_class, + PROP_REGISTRY, + g_param_spec_object ( + "registry", + "Registry", + "Data source registry", + E_TYPE_SOURCE_REGISTRY, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); } static void @@ -689,32 +740,38 @@ e_mail_autoconfig_init (EMailAutoconfig *autoconfig) } EMailAutoconfig * -e_mail_autoconfig_new_sync (const gchar *email_address, +e_mail_autoconfig_new_sync (ESourceRegistry *registry, + const gchar *email_address, GCancellable *cancellable, GError **error) { + g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL); g_return_val_if_fail (email_address != NULL, NULL); return g_initable_new ( E_TYPE_MAIL_AUTOCONFIG, cancellable, error, + "registry", registry, "email-address", email_address, NULL); } void -e_mail_autoconfig_new (const gchar *email_address, +e_mail_autoconfig_new (ESourceRegistry *registry, + const gchar *email_address, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { + g_return_if_fail (E_IS_SOURCE_REGISTRY (registry)); g_return_if_fail (email_address != NULL); g_async_initable_new_async ( E_TYPE_MAIL_AUTOCONFIG, io_priority, cancellable, callback, user_data, + "registry", registry, "email-address", email_address, NULL); } @@ -742,6 +799,23 @@ e_mail_autoconfig_finish (GAsyncResult *result, return E_MAIL_AUTOCONFIG (autoconfig); } +/** + * e_mail_autoconfig_get_registry: + * @autoconfig: an #EMailAutoconfig + * + * Returns the #ESourceRegistry passed to e_mail_autoconfig_new() or + * e_mail_autoconfig_new_sync(). + * + * Returns: an #ESourceRegistry + **/ +ESourceRegistry * +e_mail_autoconfig_get_registry (EMailAutoconfig *autoconfig) +{ + g_return_val_if_fail (E_IS_MAIL_AUTOCONFIG (autoconfig), NULL); + + return autoconfig->priv->registry; +} + const gchar * e_mail_autoconfig_get_email_address (EMailAutoconfig *autoconfig) { -- cgit v1.2.3