aboutsummaryrefslogtreecommitdiffstats
path: root/mail/e-mail-autoconfig.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-11-27 00:58:13 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-11-27 00:58:13 +0800
commit05c5d2998e6acd0216917ffd8bffe33ccfbc345c (patch)
tree233fa0ffc3e8d713b543e410bc5bbf4794a52568 /mail/e-mail-autoconfig.c
parent99120a0f18a24059004022c1a079e6fc31de3d2a (diff)
downloadgsoc2013-evolution-05c5d2998e6acd0216917ffd8bffe33ccfbc345c.tar
gsoc2013-evolution-05c5d2998e6acd0216917ffd8bffe33ccfbc345c.tar.gz
gsoc2013-evolution-05c5d2998e6acd0216917ffd8bffe33ccfbc345c.tar.bz2
gsoc2013-evolution-05c5d2998e6acd0216917ffd8bffe33ccfbc345c.tar.lz
gsoc2013-evolution-05c5d2998e6acd0216917ffd8bffe33ccfbc345c.tar.xz
gsoc2013-evolution-05c5d2998e6acd0216917ffd8bffe33ccfbc345c.tar.zst
gsoc2013-evolution-05c5d2998e6acd0216917ffd8bffe33ccfbc345c.zip
EMailAutoconfig: Add an ESourceRegistry property.
Diffstat (limited to 'mail/e-mail-autoconfig.c')
-rw-r--r--mail/e-mail-autoconfig.c80
1 files changed, 77 insertions, 3 deletions
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 */
@@ -496,6 +498,16 @@ mail_autoconfig_set_email_address (EMailAutoconfig *autoconfig,
}
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,
const GValue *value,
@@ -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,12 +543,32 @@ 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)
{
EMailAutoconfigPrivate *priv;
@@ -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)
{