Commit a6bf868a authored by Milan Crha's avatar Milan Crha

Use SRV records for configuration lookup

These are marked as incomplete, because the SRV record contains only
host name and port, thus all the other values being set are just a guess.
The change also makes prefer complete lookup results over those incomplete.
parent 9b8ddaf1
......@@ -439,6 +439,7 @@ src/modules/calendar/e-task-shell-view.c
src/modules/calendar/e-task-shell-view-private.c
src/modules/composer-to-meeting/e-composer-to-meeting.c
src/modules/composer-to-meeting/e-meeting-to-composer.c
src/modules/config-lookup/e-srv-config-lookup.c
src/modules/itip-formatter/e-mail-formatter-itip.c
src/modules/itip-formatter/itip-view.c
src/modules/itip-formatter/org-gnome-itip-formatter.error.xml
......
......@@ -42,6 +42,7 @@
struct _EConfigLookupResultSimplePrivate {
EConfigLookupResultKind kind;
gint priority;
gboolean is_complete;
gchar *protocol;
gchar *display_name;
gchar *description;
......@@ -52,6 +53,7 @@ enum {
PROP_0,
PROP_KIND,
PROP_PRIORITY,
PROP_IS_COMPLETE,
PROP_PROTOCOL,
PROP_DISPLAY_NAME,
PROP_DESCRIPTION
......@@ -114,6 +116,14 @@ config_lookup_result_simple_get_priority (EConfigLookupResult *lookup_result)
return E_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result)->priv->priority;
}
static gboolean
config_lookup_result_simple_get_is_complete (EConfigLookupResult *lookup_result)
{
g_return_val_if_fail (E_IS_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result), FALSE);
return E_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result)->priv->is_complete;
}
static const gchar *
config_lookup_result_simple_get_protocol (EConfigLookupResult *lookup_result)
{
......@@ -155,16 +165,26 @@ config_lookup_result_simple_configure_source (EConfigLookupResult *lookup_result
for (link = result_simple->priv->values; link; link = g_slist_next (link)) {
ValueData *vd = link->data;
gpointer extension;
gpointer object;
if (!vd)
return FALSE;
extension = e_source_get_extension (source, vd->extension_name);
g_warn_if_fail (extension != NULL);
if (vd->extension_name && *vd->extension_name) {
object = e_source_get_extension (source, vd->extension_name);
/* Special-case the ESourceCamel extension, where the properties
reference the CamelSettings object, not the extension itself. */
if (object && E_IS_SOURCE_CAMEL (object))
object = e_source_camel_get_settings (object);
} else {
object = source;
}
g_warn_if_fail (object != NULL);
if (extension)
g_object_set_property (extension, vd->property_name, &vd->value);
if (object)
g_object_set_property (object, vd->property_name, &vd->value);
}
return TRUE;
......@@ -205,6 +225,15 @@ config_lookup_result_simple_set_priority (EConfigLookupResultSimple *result_simp
result_simple->priv->priority = priority;
}
static void
config_lookup_result_simple_set_is_complete (EConfigLookupResultSimple *result_simple,
gboolean is_complete)
{
g_return_if_fail (E_IS_CONFIG_LOOKUP_RESULT_SIMPLE (result_simple));
result_simple->priv->is_complete = is_complete;
}
static void
config_lookup_result_simple_set_string (EConfigLookupResultSimple *result_simple,
const gchar *value,
......@@ -236,6 +265,11 @@ config_lookup_result_simple_set_property (GObject *object,
result_simple, g_value_get_int (value));
return;
case PROP_IS_COMPLETE:
config_lookup_result_simple_set_is_complete (
result_simple, g_value_get_boolean (value));
return;
case PROP_PROTOCOL:
config_lookup_result_simple_set_string (
result_simple, g_value_get_string (value),
......@@ -279,6 +313,13 @@ config_lookup_result_simple_get_property (GObject *object,
E_CONFIG_LOOKUP_RESULT (object)));
return;
case PROP_IS_COMPLETE:
g_value_set_boolean (
value,
config_lookup_result_simple_get_is_complete (
E_CONFIG_LOOKUP_RESULT (object)));
return;
case PROP_PROTOCOL:
g_value_set_string (
value,
......@@ -371,6 +412,26 @@ e_config_lookup_result_simple_class_init (EConfigLookupResultSimpleClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
/**
* EConfigLookupResultSimple:is-complete:
*
* Whether the #EConfigLookupResult is complete, that is, whether it doesn't
* require any further user interaction.
*
* Since: 3.26
**/
g_object_class_install_property (
object_class,
PROP_IS_COMPLETE,
g_param_spec_boolean (
"is-complete",
"Is Complete",
NULL,
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
/**
* EConfigLookupResultSimple:protocol:
*
......@@ -434,6 +495,7 @@ e_config_lookup_result_simple_result_init (EConfigLookupResultInterface *iface)
{
iface->get_kind = config_lookup_result_simple_get_kind;
iface->get_priority = config_lookup_result_simple_get_priority;
iface->get_is_complete = config_lookup_result_simple_get_is_complete;
iface->get_protocol = config_lookup_result_simple_get_protocol;
iface->get_display_name = config_lookup_result_simple_get_display_name;
iface->get_description = config_lookup_result_simple_get_description;
......@@ -450,6 +512,7 @@ e_config_lookup_result_simple_init (EConfigLookupResultSimple *result_simple)
* e_config_lookup_result_simple_new:
* @kind: a kind of the result, one of #EConfigLookupResultKind
* @priority: a priority of the result
* @is_complete: whether the result is complete
* @protocol: (nullable): protocol name of the result, or %NULL
* @display_name: display name of the result
* @description: description of the result
......@@ -463,6 +526,7 @@ e_config_lookup_result_simple_init (EConfigLookupResultSimple *result_simple)
EConfigLookupResult *
e_config_lookup_result_simple_new (EConfigLookupResultKind kind,
gint priority,
gboolean is_complete,
const gchar *protocol,
const gchar *display_name,
const gchar *description)
......@@ -474,6 +538,7 @@ e_config_lookup_result_simple_new (EConfigLookupResultKind kind,
return g_object_new (E_TYPE_CONFIG_LOOKUP_RESULT_SIMPLE,
"kind", kind,
"priority", priority,
"is-complete", is_complete,
"protocol", protocol,
"display-name", display_name,
"description", description,
......@@ -483,13 +548,13 @@ e_config_lookup_result_simple_new (EConfigLookupResultKind kind,
/**
* e_config_lookup_result_simple_add_value:
* @lookup_result: an #EConfigLookupResultSimple
* @extension_name: extension name
* @extension_name: (nullable): extension name, or %NULL, to change property of the #ESource itself
* @property_name: property name within the extension
* @value: value to be set
*
* Adds a value to be stored into an #ESource when e_config_lookup_result_configure_source().
* is called. The @value is identified as a property named @property_name in an extension
* named @extension_name.
* named @extension_name, or in the #ESource itself, when @extension_name is %NULL.
*
* In case multiple values are stored for the same extension and property,
* then the first is saved.
......@@ -505,7 +570,6 @@ e_config_lookup_result_simple_add_value (EConfigLookupResult *lookup_result,
EConfigLookupResultSimple *result_simple;
g_return_if_fail (E_IS_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result));
g_return_if_fail (extension_name != NULL);
g_return_if_fail (property_name != NULL);
g_return_if_fail (value != NULL);
......@@ -518,7 +582,7 @@ e_config_lookup_result_simple_add_value (EConfigLookupResult *lookup_result,
/**
* e_config_lookup_result_simple_add_boolean:
* @lookup_result: an #EConfigLookupResultSimple
* @extension_name: extension name
* @extension_name: (nullable): extension name, or %NULL, to change property of the #ESource itself
* @property_name: property name within the extension
* @value: value to set
*
......@@ -536,7 +600,6 @@ e_config_lookup_result_simple_add_boolean (EConfigLookupResult *lookup_result,
GValue gvalue;
g_return_if_fail (E_IS_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result));
g_return_if_fail (extension_name != NULL);
g_return_if_fail (property_name != NULL);
memset (&gvalue, 0, sizeof (GValue));
......@@ -551,7 +614,7 @@ e_config_lookup_result_simple_add_boolean (EConfigLookupResult *lookup_result,
/**
* e_config_lookup_result_simple_add_int:
* @lookup_result: an #EConfigLookupResultSimple
* @extension_name: extension name
* @extension_name: (nullable): extension name, or %NULL, to change property of the #ESource itself
* @property_name: property name within the extension
* @value: value to set
*
......@@ -569,7 +632,6 @@ e_config_lookup_result_simple_add_int (EConfigLookupResult *lookup_result,
GValue gvalue;
g_return_if_fail (E_IS_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result));
g_return_if_fail (extension_name != NULL);
g_return_if_fail (property_name != NULL);
memset (&gvalue, 0, sizeof (GValue));
......@@ -584,7 +646,7 @@ e_config_lookup_result_simple_add_int (EConfigLookupResult *lookup_result,
/**
* e_config_lookup_result_simple_add_uint:
* @lookup_result: an #EConfigLookupResultSimple
* @extension_name: extension name
* @extension_name: (nullable): extension name, or %NULL, to change property of the #ESource itself
* @property_name: property name within the extension
* @value: value to set
*
......@@ -602,7 +664,6 @@ e_config_lookup_result_simple_add_uint (EConfigLookupResult *lookup_result,
GValue gvalue;
g_return_if_fail (E_IS_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result));
g_return_if_fail (extension_name != NULL);
g_return_if_fail (property_name != NULL);
memset (&gvalue, 0, sizeof (GValue));
......@@ -617,7 +678,7 @@ e_config_lookup_result_simple_add_uint (EConfigLookupResult *lookup_result,
/**
* e_config_lookup_result_simple_add_int64:
* @lookup_result: an #EConfigLookupResultSimple
* @extension_name: extension name
* @extension_name: (nullable): extension name, or %NULL, to change property of the #ESource itself
* @property_name: property name within the extension
* @value: value to set
*
......@@ -635,7 +696,6 @@ e_config_lookup_result_simple_add_int64 (EConfigLookupResult *lookup_result,
GValue gvalue;
g_return_if_fail (E_IS_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result));
g_return_if_fail (extension_name != NULL);
g_return_if_fail (property_name != NULL);
memset (&gvalue, 0, sizeof (GValue));
......@@ -650,7 +710,7 @@ e_config_lookup_result_simple_add_int64 (EConfigLookupResult *lookup_result,
/**
* e_config_lookup_result_simple_add_uint64:
* @lookup_result: an #EConfigLookupResultSimple
* @extension_name: extension name
* @extension_name: (nullable): extension name, or %NULL, to change property of the #ESource itself
* @property_name: property name within the extension
* @value: value to set
*
......@@ -668,7 +728,6 @@ e_config_lookup_result_simple_add_uint64 (EConfigLookupResult *lookup_result,
GValue gvalue;
g_return_if_fail (E_IS_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result));
g_return_if_fail (extension_name != NULL);
g_return_if_fail (property_name != NULL);
memset (&gvalue, 0, sizeof (GValue));
......@@ -683,7 +742,7 @@ e_config_lookup_result_simple_add_uint64 (EConfigLookupResult *lookup_result,
/**
* e_config_lookup_result_simple_add_double:
* @lookup_result: an #EConfigLookupResultSimple
* @extension_name: extension name
* @extension_name: (nullable): extension name, or %NULL, to change property of the #ESource itself
* @property_name: property name within the extension
* @value: value to set
*
......@@ -701,7 +760,6 @@ e_config_lookup_result_simple_add_double (EConfigLookupResult *lookup_result,
GValue gvalue;
g_return_if_fail (E_IS_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result));
g_return_if_fail (extension_name != NULL);
g_return_if_fail (property_name != NULL);
memset (&gvalue, 0, sizeof (GValue));
......@@ -716,7 +774,7 @@ e_config_lookup_result_simple_add_double (EConfigLookupResult *lookup_result,
/**
* e_config_lookup_result_simple_add_string:
* @lookup_result: an #EConfigLookupResultSimple
* @extension_name: extension name
* @extension_name: (nullable): extension name, or %NULL, to change property of the #ESource itself
* @property_name: property name within the extension
* @value: value to set
*
......@@ -734,7 +792,6 @@ e_config_lookup_result_simple_add_string (EConfigLookupResult *lookup_result,
GValue gvalue;
g_return_if_fail (E_IS_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result));
g_return_if_fail (extension_name != NULL);
g_return_if_fail (property_name != NULL);
memset (&gvalue, 0, sizeof (GValue));
......@@ -749,7 +806,7 @@ e_config_lookup_result_simple_add_string (EConfigLookupResult *lookup_result,
/**
* e_config_lookup_result_simple_add_enum:
* @lookup_result: an #EConfigLookupResultSimple
* @extension_name: extension name
* @extension_name: (nullable): extension name, or %NULL, to change property of the #ESource itself
* @property_name: property name within the extension
* @enum_type: a #GType of the enum
* @value: value to set
......@@ -769,7 +826,6 @@ e_config_lookup_result_simple_add_enum (EConfigLookupResult *lookup_result,
GValue gvalue;
g_return_if_fail (E_IS_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result));
g_return_if_fail (extension_name != NULL);
g_return_if_fail (property_name != NULL);
memset (&gvalue, 0, sizeof (GValue));
......
......@@ -76,6 +76,7 @@ GType e_config_lookup_result_simple_get_type (void) G_GNUC_CONST;
EConfigLookupResult *
e_config_lookup_result_simple_new (EConfigLookupResultKind kind,
gint priority,
gboolean is_complete,
const gchar *protocol,
const gchar *display_name,
const gchar *description);
......
......@@ -42,6 +42,7 @@ e_config_lookup_result_default_init (EConfigLookupResultInterface *iface)
{
iface->get_kind = NULL;
iface->get_priority = NULL;
iface->get_is_complete = NULL;
iface->get_protocol = NULL;
iface->get_display_name = NULL;
iface->get_description = NULL;
......@@ -92,6 +93,29 @@ e_config_lookup_result_get_priority (EConfigLookupResult *lookup_result)
return iface->get_priority (lookup_result);
}
/**
* e_config_lookup_result_get_is_complete:
* @lookup_result: an #EConfigLookupResult
*
* Returns: whether the result is complete, that is, whether it doesn't require
* any further user interaction
*
* Since: 3.26
**/
gboolean
e_config_lookup_result_get_is_complete (EConfigLookupResult *lookup_result)
{
EConfigLookupResultInterface *iface;
g_return_val_if_fail (E_IS_CONFIG_LOOKUP_RESULT (lookup_result), FALSE);
iface = E_CONFIG_LOOKUP_RESULT_GET_INTERFACE (lookup_result);
g_return_val_if_fail (iface != NULL, FALSE);
g_return_val_if_fail (iface->get_is_complete != NULL, FALSE);
return iface->get_is_complete (lookup_result);
}
/**
* e_config_lookup_result_get_protocol:
* @lookup_result: an #EConfigLookupResult
......@@ -194,7 +218,8 @@ e_config_lookup_result_configure_source (EConfigLookupResult *lookup_result,
* when @lookup_result_a is before @lookup_result_b, 0 when they are the same
* and value greater than 0, when @lookup_result_a is after @lookup_result_b.
*
* The comparison is done on kind, priority and display name values, in this order.
* The comparison is done on kind, is-complete, priority and display name values,
* in this order.
*
* Returns: strcmp()-like value, what the position between @lookup_result_a and
* @lookup_result_b is.
......@@ -216,6 +241,9 @@ e_config_lookup_result_compare (gconstpointer lookup_result_a,
res = e_config_lookup_result_get_kind (lra) - e_config_lookup_result_get_kind (lrb);
if (!res)
res = (e_config_lookup_result_get_is_complete (lra) ? -1 : 0) - (e_config_lookup_result_get_is_complete (lrb) ? -1 : 0);
if (!res)
res = e_config_lookup_result_get_priority (lra) - e_config_lookup_result_get_priority (lrb);
......
......@@ -60,6 +60,7 @@ struct _EConfigLookupResultInterface {
EConfigLookupResultKind
(* get_kind) (EConfigLookupResult *lookup_result);
gint (* get_priority) (EConfigLookupResult *lookup_result);
gboolean (* get_is_complete) (EConfigLookupResult *lookup_result);
const gchar * (* get_protocol) (EConfigLookupResult *lookup_result);
const gchar * (* get_display_name) (EConfigLookupResult *lookup_result);
const gchar * (* get_description) (EConfigLookupResult *lookup_result);
......@@ -71,6 +72,7 @@ GType e_config_lookup_result_get_type (void);
EConfigLookupResultKind
e_config_lookup_result_get_kind (EConfigLookupResult *lookup_result);
gint e_config_lookup_result_get_priority (EConfigLookupResult *lookup_result);
gboolean e_config_lookup_result_get_is_complete (EConfigLookupResult *lookup_result);
const gchar * e_config_lookup_result_get_protocol (EConfigLookupResult *lookup_result);
const gchar * e_config_lookup_result_get_display_name (EConfigLookupResult *lookup_result);
const gchar * e_config_lookup_result_get_description (EConfigLookupResult *lookup_result);
......
......@@ -585,6 +585,7 @@ e_mail_config_lookup_result_new (EConfigLookupResultKind kind,
mail_result = g_object_new (E_TYPE_MAIL_CONFIG_LOOKUP_RESULT,
"kind", kind,
"priority", priority,
"is-complete", TRUE,
"protocol", protocol,
"display-name", display_name,
"description", description,
......
......@@ -290,8 +290,9 @@ mail_config_assistant_config_lookup_run_cb (GObject *source_object,
{
EMailConfigAssistantPrivate *priv;
ConfigLookupContext *context;
gint n_pages, ii;
gint n_pages, ii, complete = 0;
gboolean any_configured = FALSE;
gboolean is_complete;
context = (ConfigLookupContext *) user_data;
......@@ -299,21 +300,37 @@ mail_config_assistant_config_lookup_run_cb (GObject *source_object,
e_config_lookup_run_finish (E_CONFIG_LOOKUP (source_object), result);
if (e_mail_config_service_page_auto_configure (priv->receiving_page, context->config_lookup)) {
is_complete = FALSE;
if (e_mail_config_service_page_auto_configure (priv->receiving_page, context->config_lookup, &is_complete)) {
any_configured = TRUE;
/* Add the page to the visited pages hash table to
* prevent calling e_mail_config_page_setup_defaults(). */
g_hash_table_add (priv->visited_pages, priv->receiving_page);
if (is_complete)
complete++;
}
if (e_mail_config_service_page_auto_configure (priv->sending_page, context->config_lookup)) {
is_complete = FALSE;
if (e_mail_config_service_page_auto_configure (priv->sending_page, context->config_lookup, &is_complete)) {
any_configured = TRUE;
/* Add the page to the visited pages hash table to
* prevent calling e_mail_config_page_setup_defaults(). */
g_hash_table_add (priv->visited_pages, priv->sending_page);
if (is_complete)
complete++;
}
if (!any_configured) {
if (!any_configured || complete != 2) {
if (any_configured) {
/* Set the initial display name to the email address
* given so the user can just click past the Summary page. */
e_source_set_display_name (priv->identity_source, context->email_address);
}
gtk_assistant_next_page (context->assistant);
goto exit;
}
......
......@@ -187,7 +187,8 @@ mail_config_service_backend_setup_defaults (EMailConfigServiceBackend *backend)
static gboolean
mail_config_service_backend_auto_configure (EMailConfigServiceBackend *backend,
EConfigLookup *config_lookup,
gint *out_priority)
gint *out_priority,
gboolean *out_is_complete)
{
return FALSE;
}
......@@ -480,7 +481,8 @@ e_mail_config_service_backend_setup_defaults (EMailConfigServiceBackend *backend
gboolean
e_mail_config_service_backend_auto_configure (EMailConfigServiceBackend *backend,
EConfigLookup *config_lookup,
gint *out_priority)
gint *out_priority,
gboolean *out_is_complete)
{
EMailConfigServiceBackendClass *class;
......@@ -490,7 +492,7 @@ e_mail_config_service_backend_auto_configure (EMailConfigServiceBackend *backend
class = E_MAIL_CONFIG_SERVICE_BACKEND_GET_CLASS (backend);
g_return_val_if_fail (class->auto_configure != NULL, FALSE);
return class->auto_configure (backend, config_lookup, out_priority);
return class->auto_configure (backend, config_lookup, out_priority, out_is_complete);
}
gboolean
......@@ -527,6 +529,7 @@ e_mail_config_service_backend_commit_changes (EMailConfigServiceBackend *backend
* @protocol: (nullable): optional protocol name, or %NULL
* @source: (nullable): optioanl #ESource to configure, or %NULL
* @out_priority: (out) (nullable): priority of the chosen lookup result
* @out_is_complete: (out) (nullable): whether the config is complete
*
* Finds a config lookup result for the given @kind and @protocol and
* configures the @source with it. The @out_priority is set to the priority
......@@ -545,7 +548,8 @@ e_mail_config_service_backend_auto_configure_for_kind (EMailConfigServiceBackend
EConfigLookupResultKind kind,
const gchar *protocol,
ESource *source,
gint *out_priority)
gint *out_priority,
gboolean *out_is_complete)
{
EMailConfigServiceBackendClass *klass;
GSList *results;
......@@ -571,8 +575,13 @@ e_mail_config_service_backend_auto_configure_for_kind (EMailConfigServiceBackend
changed = e_config_lookup_result_configure_source (lookup_result, source);
if (changed && out_priority)
*out_priority = e_config_lookup_result_get_priority (lookup_result);
if (changed) {
if (out_priority)
*out_priority = e_config_lookup_result_get_priority (lookup_result);
if (out_is_complete)
*out_is_complete = e_config_lookup_result_get_is_complete (lookup_result);
}
}
g_slist_free_full (results, g_object_unref);
......
......@@ -73,7 +73,8 @@ struct _EMailConfigServiceBackendClass {
gboolean (*auto_configure)
(EMailConfigServiceBackend *backend,
EConfigLookup *config_lookup,
gint *out_priority);
gint *out_priority,
gboolean *out_is_complete);
gboolean (*check_complete)
(EMailConfigServiceBackend *backend);
void (*commit_changes)
......@@ -109,7 +110,8 @@ void e_mail_config_service_backend_setup_defaults
gboolean e_mail_config_service_backend_auto_configure
(EMailConfigServiceBackend *backend,
EConfigLookup *config_lookup,
gint *out_priority);
gint *out_priority,
gboolean *out_is_complete);
gboolean e_mail_config_service_backend_check_complete
(EMailConfigServiceBackend *backend);
void e_mail_config_service_backend_commit_changes
......@@ -120,7 +122,8 @@ gboolean e_mail_config_service_backend_auto_configure_for_kind
EConfigLookupResultKind kind,
const gchar *protocol,
ESource *source,
gint *out_priority);
gint *out_priority,
gboolean *out_is_complete);
G_END_DECLS
......
......@@ -894,10 +894,12 @@ e_mail_config_service_page_lookup_backend (EMailConfigServicePage *page,
gboolean
e_mail_config_service_page_auto_configure (EMailConfigServicePage *page,
EConfigLookup *config_lookup)
EConfigLookup *config_lookup,
gboolean *out_is_complete)
{
EMailConfigServiceBackend *select_backend = NULL;
gint selected_priority = G_MAXINT;
gboolean selected_is_complete = FALSE;
gboolean any_configured = FALSE;
guint ii;
......@@ -909,14 +911,16 @@ e_mail_config_service_page_auto_configure (EMailConfigServicePage *page,
Candidate *candidate;
gboolean configured;
gint priority = G_MAXINT;
gboolean is_complete = FALSE;
candidate = page->priv->candidates->pdata[ii];
backend = candidate->backend;
configured = e_mail_config_service_backend_auto_configure (backend, config_lookup, &priority);
configured = e_mail_config_service_backend_auto_configure (backend, config_lookup, &priority, &is_complete);
if (configured && priority < selected_priority) {
selected_priority = priority;
selected_is_complete = is_complete;
select_backend = backend;
}
......@@ -926,6 +930,9 @@ e_mail_config_service_page_auto_configure (EMailConfigServicePage *page,
if (select_backend)
e_mail_config_service_page_set_active_backend (page, select_backend);
if (out_is_complete)
*out_is_complete = selected_is_complete;
return any_configured;
}
......@@ -93,7 +93,8 @@ EMailConfigServiceBackend *
const gchar *backend_name);
gboolean e_mail_config_service_page_auto_configure
(EMailConfigServicePage *page,
EConfigLookup *config_lookup);
EConfigLookup *config_lookup,
gboolean *out_is_complete);
G_END_DECLS
......
......@@ -6,6 +6,8 @@ set(sources
config-lookup.c
e-gnome-config-lookup.c
e-gnome-config-lookup.h
e-srv-config-lookup.c
e-srv-config-lookup.h
)
set(extra_defines)
set(extra_cflags)
......
......@@ -21,6 +21,7 @@
#include <glib-object.h>
#include "e-gnome-config-lookup.h"
#include "e-srv-config-lookup.h"
/* Module Entry Points */
void e_module_load (GTypeModule *type_module);
......@@ -30,6 +31,7 @@ G_MODULE_EXPORT void
e_module_load (GTypeModule *type_module)
{
e_gnome_config_lookup_type_register (type_module);
e_srv_config_lookup_type_register (type_module);
}
G_MODULE_EXPORT void
......
......@@ -17,8 +17,6 @@
#include "evolution-config.h"
#include <glib/gi18n-lib.h>
#include "mail/e-mail-autoconfig.h"
#include "e-util/e-util.h"
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2017 Red Hat, Inc. (www.redhat.com)
*
* This library is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "evolution-config.h"
#include <string.h>
#include <gio/gio.h>
#include <glib/gi18n-lib.h>
#include "e-util/e-util.h"
#include "e-srv-config-lookup.h"
/* Standard GObject macros */
#define E_TYPE_SRV_CONFIG_LOOKUP \
(e_srv_config_lookup_get_type ())
#define E_SRV_CONFIG_LOOKUP(obj) \
(G_TYPE_CHECK_INSTANCE_CAST \
((obj), E_TYPE_SRV_CONFIG_LOOKUP, ESrvConfigLookup))
#define E_SRV_CONFIG_LOOKUP_CLASS(cls) \
(G_TYPE_CHECK_CLASS_CAST \
((cls), E_TYPE_SRV_CONFIG_LOOKUP, ESrvConfigLookupClass))
#define E_IS_SRV_CONFIG_LOOKUP(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE \
((obj), E_TYPE_SRV_CONFIG_LOOKUP))
#define E_IS_SRV_CONFIG_LOOKUP_CLASS(cls) \
(G_TYPE_CHECK_CLASS_TYPE \
((cls), E_TYPE_SRV_CONFIG_LOOKUP))
#define E_SRV_CONFIG_LOOKUP_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS \
((obj), E_TYPE_SRV_CONFIG_LOOKUP, ESrvConfigLookupClass))
#define PRIORITY_OFFSET 100
#define PRIORITY_DEFAULT E_CONFIG_LOOKUP_RESULT_PRIORITY_IMAP
typedef struct _ESrvConfigLookup ESrvConfigLookup;
typedef struct _ESrvConfigLookupClass ESrvConfigLookupClass;
struct _ESrvConfigLookup {
EExtension parent;
};
struct _ESrvConfigLookupClass {
EExtensionClass parent_class;
};
GType e_srv_config_lookup_get_type (void) G_GNUC_CONST;
G_DEFINE_DYNAMIC_TYPE (ESrvConfigLookup, e_srv_config_lookup, E_TYPE_EXTENSION)
static void
srv_config_lookup_domain_sync (EConfigLookup *config_lookup,
const gchar *email_address,
const gchar *domain,
GCancellable *cancellable)
{
struct _services {
const gchar *gio_protocol;
EConfigLookupResultKind kind;
const gchar *evo_protocol;
const gchar *display_name;
gint priority_base;
} known_services[] = {
{ "imaps", E_CONFIG_LOOKUP_RESULT_MAIL_RECEIVE, "imapx", _("IMAP server"), E_CONFIG_LOOKUP_RESULT_PRIORITY_IMAP },
{ "imap", E_CONFIG_LOOKUP_RESULT_MAIL_RECEIVE, "imapx", _("IMAP server"), E_CONFIG_LOOKUP_RESULT_PRIORITY_IMAP + PRIORITY_OFFSET / 2 },
{ "pop3s", E_CONFIG_LOOKUP_RESULT_MAIL_RECEIVE, "pop", _("POP3 server"), E_CONFIG_LOOKUP_RESULT_PRIORITY_POP3 },
{ "pop3", E_CONFIG_LOOKUP_RESULT_MAIL_RECEIVE, "pop", _("POP3 server"), E_CONFIG_LOOKUP_RESULT_PRIORITY_POP3 + PRIORITY_OFFSET / 2 },
{ "submission", E_CONFIG_LOOKUP_RESULT_MAIL_SEND, "smtp", _("SMTP server"), E_CONFIG_LOOKUP_RESULT_PRIORITY_SMTP },
{ "caldavs", E_CONFIG_LOOKUP_RESULT_COLLECTION, "caldav", _("CalDAV server"), PRIORITY_DEFAULT },
{ "caldav", E_CONFIG_LOOKUP_RESULT_COLLECTION, "caldav", _("CalDAV server"), PRIORITY_DEFAULT + PRIORITY_OFFSET / 2 },
{ "carddavs", E_CONFIG_LOOKUP_RESULT_COLLECTION, "carddav", _("CardDAV server"), PRIORITY_DEFAULT },
{ "carddav", E_CONFIG_LOOKUP_RESULT_COLLECTION, "carddav", _("CardDAV server"), PRIORITY_DEFAULT + PRIORITY_OFFSET / 2 },
{ "ldaps", E_CONFIG_LOOKUP_RESULT_ADDRESS_BOOK, "ldap", _("LDAP server"), PRIORITY_DEFAULT },
{ "ldap", E_CONFIG_LOOKUP_RESULT_ADDRESS_BOOK, "ldap", _("LDAP server"), PRIORITY_DEFAULT + PRIORITY_OFFSET / 2 }
};
GResolver *resolver;
gint ii;
gboolean success = TRUE;
g_return_if_fail (E_IS_CONFIG_LOOKUP (config_lookup));
if (!domain || !*domain)
return;