aboutsummaryrefslogtreecommitdiffstats
path: root/mail
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
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')
-rw-r--r--mail/e-mail-autoconfig.c80
-rw-r--r--mail/e-mail-autoconfig.h8
-rw-r--r--mail/e-mail-config-assistant.c4
-rw-r--r--mail/test-mail-autoconfig.c18
4 files changed, 101 insertions, 9 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)
{
diff --git a/mail/e-mail-autoconfig.h b/mail/e-mail-autoconfig.h
index c59897c8b0..6bb4e2e2fa 100644
--- a/mail/e-mail-autoconfig.h
+++ b/mail/e-mail-autoconfig.h
@@ -57,10 +57,12 @@ struct _EMailAutoconfigClass {
GType e_mail_autoconfig_get_type (void) G_GNUC_CONST;
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);
-void e_mail_autoconfig_new (const gchar *email_address,
+void e_mail_autoconfig_new (ESourceRegistry *registry,
+ const gchar *email_address,
gint io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -68,6 +70,8 @@ void e_mail_autoconfig_new (const gchar *email_address,
EMailAutoconfig *
e_mail_autoconfig_finish (GAsyncResult *result,
GError **error);
+ESourceRegistry *
+ e_mail_autoconfig_get_registry (EMailAutoconfig *autoconfig);
const gchar * e_mail_autoconfig_get_email_address
(EMailAutoconfig *autoconfig);
gboolean e_mail_autoconfig_set_imap_details
diff --git a/mail/e-mail-config-assistant.c b/mail/e-mail-config-assistant.c
index 9d46764255..9091c8a8f5 100644
--- a/mail/e-mail-config-assistant.c
+++ b/mail/e-mail-config-assistant.c
@@ -821,10 +821,13 @@ mail_config_assistant_prepare (GtkAssistant *assistant,
if (E_IS_MAIL_CONFIG_LOOKUP_PAGE (page)) {
AutoconfigContext *context;
ESource *source;
+ ESourceRegistry *registry;
ESourceMailIdentity *extension;
const gchar *email_address;
const gchar *extension_name;
+ registry = e_mail_session_get_registry (priv->session);
+
source = priv->identity_source;
extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
extension = e_source_get_extension (source, extension_name);
@@ -833,6 +836,7 @@ mail_config_assistant_prepare (GtkAssistant *assistant,
context = autoconfig_context_new (assistant);
e_mail_autoconfig_new (
+ registry,
email_address,
G_PRIORITY_DEFAULT,
context->cancellable,
diff --git a/mail/test-mail-autoconfig.c b/mail/test-mail-autoconfig.c
index d6c431b8c9..252072bd84 100644
--- a/mail/test-mail-autoconfig.c
+++ b/mail/test-mail-autoconfig.c
@@ -17,6 +17,7 @@
*/
#include <stdlib.h>
+#include <libedataserver/libedataserver.h>
#include "e-mail-autoconfig.h"
@@ -24,6 +25,7 @@ gint
main (gint argc,
gchar **argv)
{
+ ESourceRegistry *registry;
EMailAutoconfig *autoconfig;
GError *error = NULL;
@@ -32,17 +34,25 @@ main (gint argc,
exit (EXIT_FAILURE);
}
- autoconfig = e_mail_autoconfig_new_sync (argv[1], NULL, &error);
+ registry = e_source_registry_new_sync (NULL, &error);
+
+ if (registry != NULL) {
+ autoconfig = e_mail_autoconfig_new_sync (
+ registry, argv[1], NULL, &error);
+ g_object_unref (registry);
+ }
+
+ /* Sanity check. */
+ g_assert (
+ ((autoconfig != NULL) && (error == NULL)) ||
+ ((autoconfig == NULL) && (error != NULL)));
if (error != NULL) {
- g_warn_if_fail (autoconfig == NULL);
g_printerr ("%s\n", error->message);
g_error_free (error);
exit (EXIT_FAILURE);
}
- g_assert (E_IS_MAIL_AUTOCONFIG (autoconfig));
-
e_mail_autoconfig_dump_results (autoconfig);
g_object_unref (autoconfig);