Commit 1bd5a348 authored by Milan Crha's avatar Milan Crha

Bug 760329 - Try to poke autodiscovery when creating new account

parent 521cde69
......@@ -260,9 +260,11 @@
<xi:include href="xml/e-calendar.xml"/>
<xi:include href="xml/e-charset.xml"/>
<xi:include href="xml/e-charset-combo-box.xml"/>
<xi:include href="xml/e-collection-account-wizard.xml"/>
<xi:include href="xml/e-config-lookup.xml"/>
<xi:include href="xml/e-config-lookup-result.xml"/>
<xi:include href="xml/e-config-lookup-result-simple.xml"/>
<xi:include href="xml/e-config-lookup-worker.xml"/>
<xi:include href="xml/e-conflict-search-selector.xml"/>
<xi:include href="xml/e-contact-store.xml"/>
<xi:include href="xml/e-data-capture.xml"/>
......@@ -322,6 +324,10 @@
<title>Index</title>
<xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-3.28" role="3.28">
<title>Index of new symbols in 3.28</title>
<xi:include href="xml/api-index-3.28.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-3.26" role="3.26">
<title>Index of new symbols in 3.26</title>
<xi:include href="xml/api-index-3.26.xml"><xi:fallback /></xi:include>
......
......@@ -195,8 +195,10 @@ src/e-util/e-cell-text.c
src/e-util/e-charset.c
src/e-util/e-charset-combo-box.c
src/e-util/e-client-cache.c
src/e-util/e-collection-account-wizard.c
src/e-util/e-color-chooser-widget.c
src/e-util/e-color-combo.c
src/e-util/e-config-lookup.c
src/e-util/e-dateedit.c
src/e-util/e-datetime-format.c
src/e-util/e-dialog-utils.c
......@@ -384,6 +386,7 @@ src/mail/message-list.etspec
src/mail/searchtypes.xml.in
src/mail/vfoldertypes.xml.in
src/modules/accounts-window/e-accounts-window-editors.c
src/modules/accounts-window/e-collection-wizard-page.c
src/modules/accounts-window/e-webdav-browser-page.c
src/modules/addressbook/autocompletion-config.c
src/modules/addressbook/eab-composer-util.c
......@@ -439,7 +442,9 @@ 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-gnome-config-lookup.c
src/modules/config-lookup/e-srv-config-lookup.c
src/modules/config-lookup/e-webdav-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
......
......@@ -96,12 +96,14 @@ set(SOURCES
e-client-cache.c
e-client-combo-box.c
e-client-selector.c
e-collection-account-wizard.c
e-color-chooser-widget.c
e-color-combo.c
e-config.c
e-config-lookup.c
e-config-lookup-result.c
e-config-lookup-result-simple.c
e-config-lookup-worker.c
e-conflict-search-selector.c
e-contact-store.c
e-content-editor.c
......@@ -365,12 +367,14 @@ set(HEADERS
e-client-cache.h
e-client-combo-box.h
e-client-selector.h
e-collection-account-wizard.h
e-color-chooser-widget.h
e-color-combo.h
e-config.h
e-config-lookup.h
e-config-lookup-result.h
e-config-lookup-result-simple.h
e-config-lookup-worker.h
e-conflict-search-selector.h
e-contact-store.h
e-content-editor.h
......
......@@ -61,6 +61,7 @@ struct _EAccountsWindowPrivate {
GtkWidget *delete_button; /* not referenced */
GHashTable *references; /* gchar *UID ~> GtkTreeRowReference * */
gchar *select_source_uid; /* Which source to select, or NULL */
gulong source_enabled_handler_id;
gulong source_disabled_handler_id;
......@@ -177,10 +178,10 @@ accounts_window_emit_delete_source (EAccountsWindow *accounts_window)
}
static gboolean
accounts_window_find_source_iter (EAccountsWindow *accounts_window,
ESource *source,
GtkTreeIter *out_iter,
GtkTreeModel **out_model)
accounts_window_find_source_uid_iter (EAccountsWindow *accounts_window,
const gchar *uid,
GtkTreeIter *out_iter,
GtkTreeModel **out_model)
{
GtkTreeRowReference *reference;
GtkTreePath *path;
......@@ -188,13 +189,13 @@ accounts_window_find_source_iter (EAccountsWindow *accounts_window,
gboolean valid;
g_return_val_if_fail (E_IS_ACCOUNTS_WINDOW (accounts_window), FALSE);
g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
g_return_val_if_fail (uid != NULL, FALSE);
g_return_val_if_fail (out_iter != NULL, FALSE);
reference = g_hash_table_lookup (accounts_window->priv->references, e_source_get_uid (source));
reference = g_hash_table_lookup (accounts_window->priv->references, uid);
if (!reference ||
!gtk_tree_row_reference_valid (reference)) {
g_hash_table_remove (accounts_window->priv->references, e_source_get_uid (source));
g_hash_table_remove (accounts_window->priv->references, uid);
return FALSE;
}
......@@ -214,6 +215,19 @@ accounts_window_find_source_iter (EAccountsWindow *accounts_window,
return valid;
}
static gboolean
accounts_window_find_source_iter (EAccountsWindow *accounts_window,
ESource *source,
GtkTreeIter *out_iter,
GtkTreeModel **out_model)
{
g_return_val_if_fail (E_IS_ACCOUNTS_WINDOW (accounts_window), FALSE);
g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
g_return_val_if_fail (out_iter != NULL, FALSE);
return accounts_window_find_source_uid_iter (accounts_window, e_source_get_uid (source), out_iter, out_model);
}
static gboolean
accounts_window_find_child_with_sort_hint (EAccountsWindow *accounts_window,
GtkTreeStore *tree_store,
......@@ -346,7 +360,7 @@ accounts_window_fill_row_with_source (EAccountsWindow *accounts_window,
use_type = g_strconcat ("UOA:", backend_name, NULL);
icon_name = "credentials-preferences";
enabled_visible = FALSE;
} else {
} else if (g_strcmp0 (backend_name, "none") != 0) {
use_type = backend_name;
backend_name = NULL;
}
......@@ -502,7 +516,7 @@ accounts_window_fill_children (EAccountsWindow *accounts_window,
gboolean *subroot_set;
GtkTreeIter iter, *subroot;
if (accounts_window_get_sort_hint_for_source (source) == -1)
if (accounts_window_get_sort_hint_for_source (source) == UNKNOWN_SORT_HINT)
continue;
if (e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_ACCOUNT)) {
......@@ -551,7 +565,9 @@ accounts_window_fill_children (EAccountsWindow *accounts_window,
subroot_display_name, subroot_icon_name, subroot_sort_hint);
}
gtk_tree_store_append (tree_store, &iter, subroot);
if (!lookup_subroot ||
!accounts_window_find_source_iter (accounts_window, source, &iter, NULL))
gtk_tree_store_append (tree_store, &iter, subroot);
accounts_window_fill_row_with_source (accounts_window, tree_store, &iter, source, mail_account_slaves, !is_managed_collection);
}
......@@ -772,6 +788,7 @@ accounts_window_source_added_cb (ESourceRegistry *registry,
GtkTreeIter iter, root;
GSList *children_and_siblings = NULL;
GList *sources, *llink;
gboolean restart = FALSE;
g_return_if_fail (E_IS_SOURCE (source));
g_return_if_fail (E_IS_ACCOUNTS_WINDOW (accounts_window));
......@@ -780,15 +797,19 @@ accounts_window_source_added_cb (ESourceRegistry *registry,
accounts_window_find_source_iter (accounts_window, source, &iter, NULL))
return;
g_object_ref (source);
tree_store = GTK_TREE_STORE (gtk_tree_model_sort_get_model (
GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (
GTK_TREE_VIEW (accounts_window->priv->tree_view)))));
sources = e_source_registry_list_sources (accounts_window->priv->registry, NULL);
for (llink = sources; llink; llink = g_list_next (llink)) {
for (llink = sources; llink; llink = restart ? sources : g_list_next (llink)) {
ESource *other_source = llink->data;
const gchar *parent_uid;
restart = FALSE;
if (!E_IS_SOURCE (other_source) ||
e_source_has_extension (other_source, E_SOURCE_EXTENSION_PROXY) ||
e_source_has_extension (other_source, E_SOURCE_EXTENSION_MAIL_SIGNATURE))
......@@ -799,6 +820,16 @@ accounts_window_source_added_cb (ESourceRegistry *registry,
g_strcmp0 (parent_uid, e_source_get_parent (source)) == 0 ||
g_strcmp0 (parent_uid, e_source_get_uid (source)) == 0)) {
children_and_siblings = g_slist_prepend (children_and_siblings, g_object_ref (other_source));
} else if (e_source_has_extension (other_source, E_SOURCE_EXTENSION_COLLECTION) && other_source != source &&
!e_source_has_extension (source, E_SOURCE_EXTENSION_COLLECTION) &&
g_strcmp0 (e_source_get_uid (other_source), e_source_get_parent (source)) == 0) {
/* Use the collection source when there's any such found */
g_object_unref (source);
source = g_object_ref (other_source);
g_slist_free_full (children_and_siblings, g_object_unref);
children_and_siblings = NULL;
restart = TRUE;
}
}
......@@ -807,12 +838,14 @@ accounts_window_source_added_cb (ESourceRegistry *registry,
if (e_source_has_extension (source, E_SOURCE_EXTENSION_COLLECTION)) {
gboolean is_managed_collection;
gtk_tree_store_append (tree_store, &iter, NULL);
is_managed_collection = e_source_has_extension (source, E_SOURCE_EXTENSION_GOA) ||
e_source_has_extension (source, E_SOURCE_EXTENSION_UOA);
accounts_window_fill_row_with_source (accounts_window, tree_store, &iter, source, NULL, TRUE);
if (!accounts_window_find_source_iter (accounts_window, source, &iter, NULL)) {
gtk_tree_store_append (tree_store, &iter, NULL);
accounts_window_fill_row_with_source (accounts_window, tree_store, &iter, source, NULL, TRUE);
}
accounts_window_fill_children (accounts_window, tree_store, &iter, is_managed_collection, TRUE, children_and_siblings);
} else if (e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_ACCOUNT) && (
!e_source_get_parent (source) || g_strcmp0 (e_source_get_parent (source), "") == 0)) {
......@@ -898,6 +931,10 @@ accounts_window_source_added_cb (ESourceRegistry *registry,
}
g_slist_free_full (children_and_siblings, g_object_unref);
g_object_unref (source);
if (accounts_window->priv->select_source_uid)
e_accounts_window_select_source (accounts_window, accounts_window->priv->select_source_uid);
}
static void
......@@ -1406,7 +1443,7 @@ accounts_window_show_add_popup (EAccountsWindow *accounts_window,
const gchar *text;
const gchar *icon_name;
} items[] = {
/* { "collection", N_("Collection _Account"), "evolution" }, */
{ "collection", N_("Collection _Account"), "evolution" },
{ "mail", N_("_Mail Account"), "evolution-mail" },
{ "book", N_("Address _Book"), "x-office-address-book" },
{ "calendar", N_("_Calendar"), "x-office-calendar" },
......@@ -1585,6 +1622,7 @@ accounts_window_finalize (GObject *object)
EAccountsWindow *accounts_window = E_ACCOUNTS_WINDOW (object);
g_hash_table_destroy (accounts_window->priv->references);
g_clear_pointer (&accounts_window->priv->select_source_uid, g_free);
/* Chain up to parent's method. */
G_OBJECT_CLASS (e_accounts_window_parent_class)->finalize (object);
......@@ -1604,7 +1642,7 @@ accounts_window_constructed (GObject *object)
/* Chain up to parent's method. */
G_OBJECT_CLASS (e_accounts_window_parent_class)->constructed (object);
gtk_window_set_default_size (GTK_WINDOW (accounts_window), 480, 360);
gtk_window_set_default_size (GTK_WINDOW (accounts_window), 480, 410);
gtk_window_set_title (GTK_WINDOW (accounts_window), _("Evolution Accounts"));
gtk_container_set_border_width (GTK_CONTAINER (accounts_window), 12);
......@@ -1701,6 +1739,8 @@ accounts_window_constructed (GObject *object)
GTK_ACCEL_VISIBLE);
gtk_window_add_accel_group (GTK_WINDOW (accounts_window), accel_group);
registry = e_accounts_window_get_registry (accounts_window);
gtk_widget_show_all (GTK_WIDGET (grid));
/* First load extensions, thus the fill-tree-view can call them. */
......@@ -1708,8 +1748,6 @@ accounts_window_constructed (GObject *object)
accounts_window_fill_tree_view (accounts_window);
registry = e_accounts_window_get_registry (accounts_window);
accounts_window->priv->source_enabled_handler_id =
g_signal_connect (registry, "source-enabled",
G_CALLBACK (accounts_window_source_enabled_cb), accounts_window);
......@@ -2022,6 +2060,67 @@ e_accounts_window_ref_selected_source (EAccountsWindow *accounts_window)
return source;
}
/**
* e_accounts_window_select_source:
* @accounts_window: an #EAccountsWindow
* @uid: (nullable): an #ESource UID to select
*
* Selects an #ESource with the given @uid. If no such is available in time
* of this call, then it is remembered and selected once it appears.
* The function doesn't change selection, when @uid is %NULL, but it
* unsets remembered UID from any previous call.
*
* Since: 3.28
**/
void
e_accounts_window_select_source (EAccountsWindow *accounts_window,
const gchar *uid)
{
GtkTreeModel *model;
GtkTreeIter child_iter;
g_return_if_fail (E_IS_ACCOUNTS_WINDOW (accounts_window));
if (!uid || !*uid) {
g_clear_pointer (&accounts_window->priv->select_source_uid, g_free);
return;
}
if (accounts_window_find_source_uid_iter (accounts_window, uid, &child_iter, &model)) {
GtkTreeModel *sort_model;
GtkTreeView *tree_view;
GtkTreeIter iter;
g_clear_pointer (&accounts_window->priv->select_source_uid, g_free);
tree_view = GTK_TREE_VIEW (accounts_window->priv->tree_view);
sort_model = gtk_tree_view_get_model (tree_view);
if (gtk_tree_model_sort_convert_child_iter_to_iter (GTK_TREE_MODEL_SORT (sort_model), &iter, &child_iter)) {
GtkTreeSelection *selection;
GtkTreePath *path;
path = gtk_tree_model_get_path (sort_model, &iter);
if (path) {
gtk_tree_view_expand_to_path (tree_view, path);
gtk_tree_view_scroll_to_cell (tree_view, path, NULL, FALSE, 0.0, 0.0);
}
gtk_tree_path_free (path);
selection = gtk_tree_view_get_selection (tree_view);
gtk_tree_selection_select_iter (selection, &iter);
}
return;
}
if (g_strcmp0 (accounts_window->priv->select_source_uid, uid) != 0) {
g_clear_pointer (&accounts_window->priv->select_source_uid, g_free);
accounts_window->priv->select_source_uid = g_strdup (uid);
}
}
/**
* e_accounts_window_insert_to_add_popup:
* @accounts_window: an #EAccountsWindow
......
......@@ -98,6 +98,8 @@ ESourceRegistry *
void e_accounts_window_show_with_parent (EAccountsWindow *accounts_window,
GtkWindow *parent);
ESource * e_accounts_window_ref_selected_source (EAccountsWindow *accounts_window);
void e_accounts_window_select_source (EAccountsWindow *accounts_window,
const gchar *uid);
void e_accounts_window_insert_to_add_popup (EAccountsWindow *accounts_window,
GtkMenuShell *popup_menu,
const gchar *kind,
......
This diff is collapsed.
/* -*- 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/>.
*/
#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
#error "Only <e-util/e-util.h> should be included directly."
#endif
#ifndef E_COLLECTION_ACCOUNT_WIZARD_H
#define E_COLLECTION_ACCOUNT_WIZARD_H
#include <gtk/gtk.h>
#include <libedataserver/libedataserver.h>
/* Standard GObject macros */
#define E_TYPE_COLLECTION_ACCOUNT_WIZARD \
(e_collection_account_wizard_get_type ())
#define E_COLLECTION_ACCOUNT_WIZARD(obj) \
(G_TYPE_CHECK_INSTANCE_CAST \
((obj), E_TYPE_COLLECTION_ACCOUNT_WIZARD, ECollectionAccountWizard))
#define E_COLLECTION_ACCOUNT_WIZARD_CLASS(cls) \
(G_TYPE_CHECK_CLASS_CAST \
((cls), E_TYPE_COLLECTION_ACCOUNT_WIZARD, ECollectionAccountWizardClass))
#define E_IS_COLLECTION_ACCOUNT_WIZARD(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE \
((obj), E_TYPE_COLLECTION_ACCOUNT_WIZARD))
#define E_IS_COLLECTION_ACCOUNT_WIZARD_CLASS(cls) \
(G_TYPE_CHECK_CLASS_TYPE \
((cls), E_TYPE_COLLECTION_ACCOUNT_WIZARD))
#define E_COLLECTION_ACCOUNT_WIZARD_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS \
((obj), E_TYPE_COLLECTION_ACCOUNT_WIZARD, ECollectionAccountWizardClass))
G_BEGIN_DECLS
typedef struct _ECollectionAccountWizard ECollectionAccountWizard;
typedef struct _ECollectionAccountWizardClass ECollectionAccountWizardClass;
typedef struct _ECollectionAccountWizardPrivate ECollectionAccountWizardPrivate;
/**
* ECollectionAccountWizard:
*
* Contains only private data that should be read and manipulated using
* the functions below.
*
* Since: 3.28
**/
struct _ECollectionAccountWizard {
/*< private >*/
GtkNotebook parent;
ECollectionAccountWizardPrivate *priv;
};
struct _ECollectionAccountWizardClass {
/*< private >*/
GtkNotebookClass parent_class;
/* Signals */
void (* done) (ECollectionAccountWizard *wizard,
const gchar *uid);
};
GType e_collection_account_wizard_get_type (void) G_GNUC_CONST;
GtkWidget * e_collection_account_wizard_new (ESourceRegistry *registry);
ESourceRegistry *
e_collection_account_wizard_get_registry (ECollectionAccountWizard *wizard);
gboolean e_collection_account_wizard_get_can_run (ECollectionAccountWizard *wizard);
void e_collection_account_wizard_reset (ECollectionAccountWizard *wizard);
gboolean e_collection_account_wizard_next (ECollectionAccountWizard *wizard);
gboolean e_collection_account_wizard_prev (ECollectionAccountWizard *wizard);
gboolean e_collection_account_wizard_is_finish_page (ECollectionAccountWizard *wizard);
void e_collection_account_wizard_run (ECollectionAccountWizard *wizard,
GAsyncReadyCallback callback,
gpointer user_data);
void e_collection_account_wizard_run_finish (ECollectionAccountWizard *wizard,
GAsyncResult *result);
void e_collection_account_wizard_abort (ECollectionAccountWizard *wizard);
G_END_DECLS
#endif /* E_COLLECTION_ACCOUNT_WIZARD_H */
......@@ -35,6 +35,7 @@
#include <libedataserver/libedataserver.h>
#include "e-util-enumtypes.h"
#include "e-config-lookup.h"
#include "e-config-lookup-result.h"
#include "e-config-lookup-result-simple.h"
......@@ -46,6 +47,7 @@ struct _EConfigLookupResultSimplePrivate {
gchar *protocol;
gchar *display_name;
gchar *description;
gchar *password;
GSList *values; /* ValueData * */
};
......@@ -56,7 +58,8 @@ enum {
PROP_IS_COMPLETE,
PROP_PROTOCOL,
PROP_DISPLAY_NAME,
PROP_DESCRIPTION
PROP_DESCRIPTION,
PROP_PASSWORD
};
static void e_config_lookup_result_simple_result_init (EConfigLookupResultInterface *iface);
......@@ -148,14 +151,24 @@ config_lookup_result_simple_get_description (EConfigLookupResult *lookup_result)
return E_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result)->priv->description;
}
static const gchar *
config_lookup_result_simple_get_password (EConfigLookupResult *lookup_result)
{
g_return_val_if_fail (E_IS_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result), NULL);
return E_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result)->priv->password;
}
static gboolean
config_lookup_result_simple_configure_source (EConfigLookupResult *lookup_result,
EConfigLookup *config_lookup,
ESource *source)
{
EConfigLookupResultSimple *result_simple;
GSList *link;
g_return_val_if_fail (E_IS_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result), FALSE);
g_return_val_if_fail (E_IS_CONFIG_LOOKUP (config_lookup), FALSE);
g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
result_simple = E_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result);
......@@ -192,18 +205,20 @@ config_lookup_result_simple_configure_source (EConfigLookupResult *lookup_result
static gboolean
config_lookup_result_simple_configure_source_wrapper (EConfigLookupResult *lookup_result,
EConfigLookup *config_lookup,
ESource *source)
{
EConfigLookupResultSimpleClass *klass;
g_return_val_if_fail (E_IS_CONFIG_LOOKUP_RESULT_SIMPLE (lookup_result), FALSE);
g_return_val_if_fail (E_IS_CONFIG_LOOKUP (config_lookup), FALSE);
g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
klass = E_CONFIG_LOOKUP_RESULT_SIMPLE_GET_CLASS (lookup_result);
g_return_val_if_fail (klass != NULL, FALSE);
g_return_val_if_fail (klass->configure_source != NULL, FALSE);
return klass->configure_source (lookup_result, source);
return klass->configure_source (lookup_result, config_lookup, source);
}
static void
......@@ -287,6 +302,12 @@ config_lookup_result_simple_set_property (GObject *object,
result_simple, g_value_get_string (value),
&result_simple->priv->description);
return;
case PROP_PASSWORD:
config_lookup_result_simple_set_string (
result_simple, g_value_get_string (value),
&result_simple->priv->password);
return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -340,6 +361,13 @@ config_lookup_result_simple_get_property (GObject *object,
config_lookup_result_simple_get_description (
E_CONFIG_LOOKUP_RESULT (object)));
return;
case PROP_PASSWORD:
g_value_set_string (
value,
config_lookup_result_simple_get_password (
E_CONFIG_LOOKUP_RESULT (object)));
return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -353,6 +381,7 @@ config_lookup_result_simple_finalize (GObject *object)
g_free (result_simple->priv->protocol);
g_free (result_simple->priv->display_name);
g_free (result_simple->priv->description);
e_util_safe_free_string (result_simple->priv->password);
g_slist_free_full (result_simple->priv->values, value_data_free);
/* Chain up to parent's method. */
......@@ -488,6 +517,26 @@ e_config_lookup_result_simple_class_init (EConfigLookupResultSimpleClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
/**
* EConfigLookupResultSimple:password:
*
* The password to store for the #EConfigLookupResult.
* Can be %NULL, to not store any.
*
* Since: 3.28
**/
g_object_class_install_property (
object_class,
PROP_PASSWORD,
g_param_spec_string (
"password",
"Password",
NULL,
NULL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
}
static void
......@@ -499,6 +548,7 @@ e_config_lookup_result_simple_result_init (EConfigLookupResultInterface *iface)
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;
iface->get_password = config_lookup_result_simple_get_password;
iface->configure_source = config_lookup_result_simple_configure_source_wrapper;
}
......@@ -516,6 +566,7 @@ e_config_lookup_result_simple_init (EConfigLookupResultSimple *result_simple)
* @protocol: (nullable): protocol name of the result, or %NULL
* @display_name: display name of the result
* @description: description of the result
* @password: (nullable): password to store with the result
*
* Creates a new #EConfigLookupResultSimple instance with prefilled values.
*
......@@ -529,7 +580,8 @@ e_config_lookup_result_simple_new (EConfigLookupResultKind kind,
gboolean is_complete,
const gchar *protocol,
const gchar *display_name,
const gchar *description)
const gchar *description,
const gchar *password)
{
g_return_val_if_fail (kind != E_CONFIG_LOOKUP_RESULT_UNKNOWN, NULL);
g_return_val_if_fail (display_name != NULL, NULL);
......@@ -542,6 +594,7 @@ e_config_lookup_result_simple_new (EConfigLookupResultKind kind,
"protocol", protocol,
"display-name", display_name,
"description", description,
"password", password,
NULL);
}
......
......@@ -46,6 +46,8 @@
G_BEGIN_DECLS
struct _EConfigLookup;
typedef struct _EConfigLookupResultSimple EConfigLookupResultSimple;
typedef struct _EConfigLookupResultSimpleClass EConfigLookupResultSimpleClass;
typedef struct _EConfigLookupResultSimplePrivate EConfigLookupResultSimplePrivate;
......@@ -69,6 +71,7 @@ struct _EConfigLookupResultSimpleClass {
GObjectClass parent_class;
gboolean (* configure_source) (EConfigLookupResult *lookup_result,
struct _EConfigLookup *config_lookup,
ESource *source);
};
......@@ -79,7 +82,8 @@ EConfigLookupResult *
gboolean is_complete,
const gchar *protocol,
const gchar *display_name,
const gchar *description);
const gchar *description,
const gchar *password);
void e_config_lookup_result_simple_add_value (EConfigLookupResult *lookup_result,
const gchar *extension_name,
const gchar *property_name,
......
......@@ -32,6 +32,7 @@
#include <libedataserver/libedataserver.h>
#include "e-util-enums.h"
#include "e-config-lookup.h"
#include "e-config-lookup-result.h"
......@@ -46,6 +47,7 @@ e_config_lookup_result_default_init (EConfigLookupResultInterface *iface)
iface->get_protocol = NULL;
iface->get_display_name = NULL;
iface->get_description = NULL;
iface->get_password = NULL;
iface->configure_source = NULL;
}
......@@ -183,12 +185,36 @@ e_config_lookup_result_get_description (EConfigLookupResult *lookup_result)
return iface->get_description (lookup_result);
}
/**
* e_config_lookup_result_get_password:
* @lookup_result: an #EConfigLookupResult
*
* Returns: password to store with this @lookup_result, or %NULL for none
*
* Since: 3.28
**/
const gchar *
e_config_lookup_result_get_password (EConfigLookupResult *lookup_result)
{
EConfigLookupResultInterface *iface;
g_return_val_if_fail (E_IS_CONFIG_LOOKUP_RESULT (lookup_result), NULL);
iface = E_CONFIG_LOOKUP_RESULT_GET_INTERFACE (lookup_result);
g_return_val_if_fail (iface != NULL, NULL);
g_return_val_if_fail (iface->get_password != NULL, NULL);
return iface->get_password (lookup_result);
}
/**
* e_config_lookup_result_configure_source:
* @lookup_result: an #EConfigLookupResult
* @config_lookup: an #EConfigLookup
* @source: an #ESource to configure
*
* Configures the @source with the looked up configuration.
* Configures the @source with the looked up configuration. The @config_lookup
* can be used to get other than the provided @source.
*
* Returns: %TRUE when made any changes to the @source, %FALSE otherwise
*
......@@ -196,17 +222,19 @@ e_config_lookup_result_get_description (EConfigLookupResult *lookup_result)
**/
gboolean
e_config_lookup_result_configure_source (EConfigLookupResult *lookup_result,
EConfigLookup *config_lookup,
ESource *source)
{
EConfigLookupResultInterface *iface;
g_return_val_if_fail (E_IS_CONFIG_LOOKUP_RESULT (lookup_result), FALSE);
g_return_val_if_fail (E_IS_CONFIG_LOOKUP (config_lookup), FALSE);
iface = E_CONFIG_LOOKUP_RESULT_GET_INTERFACE (lookup_result);
g_return_val_if_fail (iface != NULL, FALSE);
g_return_val_if_fail (iface->configure_source != NULL, FALSE);
return iface->configure_source (lookup_result, source);
return iface->configure_source (lookup_result, config_lookup, source);
}
/**
......@@ -219,7 +247,9 @@ e_config_lookup_result_configure_source (EConfigLookupResult *lookup_result,
* and value greater than 0, when @lookup_result_a is after @lookup_result_b.
*
* The comparison is done on kind, is-complete, priority and display name values,
* in this order.
* in this order. Due to this it doesn't mean that the two results are equal when
* the function returns 0, use e_config_lookup_result_equal() to check complete
* equality instead.
*