summaryrefslogtreecommitdiff
path: root/src/libedataserverui
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2021-05-24 19:56:16 +0200
committerMilan Crha <mcrha@redhat.com>2021-05-24 19:56:16 +0200
commit900472c52a37aa3033ee9de5a329a9da7422dee2 (patch)
tree76d3bb9598cccc7892014309505fc30d1415f385 /src/libedataserverui
parent2a94c06f27c7078922464fcf2453cce56a792ca4 (diff)
downloadevolution-data-server-900472c52a37aa3033ee9de5a329a9da7422dee2.tar.gz
evo-I#1499 - ECredentialsPrompter: Ask for dialog parent with the auth_source
Add a signal to ask for the credential prompt dialog parent with the auth_source, thus the listener can decide what window to use also by the source being asked credentials for. Related to https://gitlab.gnome.org/GNOME/evolution/-/issues/1499
Diffstat (limited to 'src/libedataserverui')
-rw-r--r--src/libedataserverui/e-credentials-prompter-impl-oauth2.c2
-rw-r--r--src/libedataserverui/e-credentials-prompter-impl-password.c2
-rw-r--r--src/libedataserverui/e-credentials-prompter.c61
-rw-r--r--src/libedataserverui/e-credentials-prompter.h5
4 files changed, 68 insertions, 2 deletions
diff --git a/src/libedataserverui/e-credentials-prompter-impl-oauth2.c b/src/libedataserverui/e-credentials-prompter-impl-oauth2.c
index df1c0964f..65b66da97 100644
--- a/src/libedataserverui/e-credentials-prompter-impl-oauth2.c
+++ b/src/libedataserverui/e-credentials-prompter-impl-oauth2.c
@@ -589,7 +589,7 @@ e_credentials_prompter_impl_oauth2_show_dialog (ECredentialsPrompterImplOAuth2 *
prompter = e_credentials_prompter_impl_get_credentials_prompter (E_CREDENTIALS_PROMPTER_IMPL (prompter_oauth2));
g_return_val_if_fail (prompter != NULL, FALSE);
- dialog_parent = e_credentials_prompter_get_dialog_parent (prompter);
+ dialog_parent = e_credentials_prompter_get_dialog_parent_full (prompter, prompter_oauth2->priv->auth_source);
credentials_prompter_impl_oauth2_get_prompt_strings (e_credentials_prompter_get_registry (prompter),
prompter_oauth2->priv->auth_source,
diff --git a/src/libedataserverui/e-credentials-prompter-impl-password.c b/src/libedataserverui/e-credentials-prompter-impl-password.c
index 97c23339f..59ed3a641 100644
--- a/src/libedataserverui/e-credentials-prompter-impl-password.c
+++ b/src/libedataserverui/e-credentials-prompter-impl-password.c
@@ -219,7 +219,7 @@ e_credentials_prompter_impl_password_show_dialog (ECredentialsPrompterImplPasswo
prompter = e_credentials_prompter_impl_get_credentials_prompter (E_CREDENTIALS_PROMPTER_IMPL (prompter_password));
g_return_val_if_fail (prompter != NULL, FALSE);
- dialog_parent = e_credentials_prompter_get_dialog_parent (prompter);
+ dialog_parent = e_credentials_prompter_get_dialog_parent_full (prompter, prompter_password->priv->auth_source);
credentials_prompter_impl_password_get_prompt_strings (
e_credentials_prompter_get_registry (prompter),
diff --git a/src/libedataserverui/e-credentials-prompter.c b/src/libedataserverui/e-credentials-prompter.c
index 131927be8..47a661e23 100644
--- a/src/libedataserverui/e-credentials-prompter.c
+++ b/src/libedataserverui/e-credentials-prompter.c
@@ -71,6 +71,7 @@ enum {
enum {
GET_DIALOG_PARENT,
+ GET_DIALOG_PARENT_FULL,
LAST_SIGNAL
};
@@ -1157,6 +1158,28 @@ e_credentials_prompter_class_init (ECredentialsPrompterClass *class)
credentials_prompter_get_dialog_parent_accumulator, NULL, NULL,
GTK_TYPE_WINDOW, 0, G_TYPE_NONE);
+ /**
+ * ECredentialsPrompter::get-dialog-parent-full:
+ * @prompter: the #ECredentialsPrompter which emitted the signal
+ * @auth_source: (nullable): an #ESource, for which to show the credentials prompt
+ *
+ * Emitted when a new dialog will be shown, to get the right parent
+ * window for it. If the result of the call is %NULL, then it tries
+ * to get the window from the default GtkApplication.
+ *
+ * Returns: (transfer none): a #GtkWindow, to be used as a dialog parent,
+ * or %NULL.
+ *
+ * Since: 3.42
+ **/
+ signals[GET_DIALOG_PARENT_FULL] = g_signal_new (
+ "get-dialog-parent-full",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ /*G_STRUCT_OFFSET (ECredentialsPrompterClass, get_dialog_parent_full)*/ 0,
+ credentials_prompter_get_dialog_parent_accumulator, NULL, NULL,
+ GTK_TYPE_WINDOW, 1, E_TYPE_SOURCE);
+
/* Ensure built-in credential providers implementation types */
g_type_ensure (E_TYPE_CREDENTIALS_PROMPTER_IMPL_PASSWORD);
g_type_ensure (E_TYPE_CREDENTIALS_PROMPTER_IMPL_OAUTH2);
@@ -1398,6 +1421,44 @@ e_credentials_prompter_get_dialog_parent (ECredentialsPrompter *prompter)
}
/**
+ * e_credentials_prompter_get_dialog_parent_full:
+ * @prompter: an #ECredentialsPrompter
+ * @auth_source: (nullable): an #ESource
+ *
+ * Returns a #GtkWindow, which should be used as a dialog parent for the @auth_source.
+ *
+ * This is determined by an ECredentialsPrompter::get-dialog-parent-full signal emission
+ * and an ECredentialsPrompter::get-dialog-parent when the first doesn't return anything.
+ * If there is no callback registered or the current callbacks don't have any suitable
+ * window, then there's chosen the last active window from the default GApplication,
+ * if any available.
+ *
+ * Returns: (transfer none): a #GtkWindow, to be used as a dialog parent, or %NULL.
+ *
+ * Since: 3.42
+ **/
+GtkWindow *
+e_credentials_prompter_get_dialog_parent_full (ECredentialsPrompter *prompter,
+ ESource *auth_source)
+{
+ GtkWindow *parent = NULL;
+
+ g_return_val_if_fail (E_IS_CREDENTIALS_PROMPTER (prompter), NULL);
+ if (auth_source)
+ g_return_val_if_fail (E_IS_SOURCE (auth_source), NULL);
+
+ g_signal_emit (prompter, signals[GET_DIALOG_PARENT_FULL], 0, auth_source, &parent);
+
+ if (!parent)
+ g_signal_emit (prompter, signals[GET_DIALOG_PARENT], 0, &parent);
+
+ if (!parent)
+ parent = credentials_prompter_guess_dialog_parent (prompter);
+
+ return parent;
+}
+
+/**
* e_credentials_prompter_register_impl:
* @prompter: an #ECredentialsPrompter
* @authentication_method: (allow-none): an authentication method to registr @prompter_impl for; or %NULL
diff --git a/src/libedataserverui/e-credentials-prompter.h b/src/libedataserverui/e-credentials-prompter.h
index 6aa724c13..7750e24d7 100644
--- a/src/libedataserverui/e-credentials-prompter.h
+++ b/src/libedataserverui/e-credentials-prompter.h
@@ -120,6 +120,8 @@ struct _ECredentialsPrompterClass {
/* Signals */
GtkWindow * (*get_dialog_parent) (ECredentialsPrompter *prompter);
+ /*GtkWindow * (*get_dialog_parent_full)(ECredentialsPrompter *prompter,
+ ESource *auth_source); */
};
GType e_credentials_prompter_get_type (void) G_GNUC_CONST;
@@ -145,6 +147,9 @@ gboolean e_credentials_prompter_get_auto_prompt_disabled_for
ESource *source);
GtkWindow * e_credentials_prompter_get_dialog_parent
(ECredentialsPrompter *prompter);
+GtkWindow * e_credentials_prompter_get_dialog_parent_full
+ (ECredentialsPrompter *prompter,
+ ESource *auth_source);
gboolean e_credentials_prompter_register_impl
(ECredentialsPrompter *prompter,
const gchar *authentication_method,