2 * Copyright (C) 2015 Red Hat, Inc. (www.redhat.com)
4 * This library is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library. If not, see <http://www.gnu.org/licenses/>.
18 #if !defined (__LIBEDATASERVERUI_H_INSIDE__) && !defined (LIBEDATASERVERUI_COMPILATION)
19 #error "Only <libedataserverui/libedataserverui.h> should be included directly."
22 #ifndef E_CREDENTIALS_PROMPTER_H
23 #define E_CREDENTIALS_PROMPTER_H
26 #include <glib-object.h>
31 #include <libedataserver/libedataserver.h>
33 #include <libedataserverui/e-credentials-prompter-impl.h>
35 /* Standard GObject macros */
36 #define E_TYPE_CREDENTIALS_PROMPTER \
37 (e_credentials_prompter_get_type ())
38 #define E_CREDENTIALS_PROMPTER(obj) \
39 (G_TYPE_CHECK_INSTANCE_CAST \
40 ((obj), E_TYPE_CREDENTIALS_PROMPTER, ECredentialsPrompter))
41 #define E_CREDENTIALS_PROMPTER_CLASS(cls) \
42 (G_TYPE_CHECK_CLASS_CAST \
43 ((cls), E_TYPE_CREDENTIALS_PROMPTER, ECredentialsPrompterClass))
44 #define E_IS_CREDENTIALS_PROMPTER(obj) \
45 (G_TYPE_CHECK_INSTANCE_TYPE \
46 ((obj), E_TYPE_CREDENTIALS_PROMPTER))
47 #define E_IS_CREDENTIALS_PROMPTER_CLASS(cls) \
48 (G_TYPE_CHECK_CLASS_TYPE \
49 ((cls), E_TYPE_CREDENTIALS_PROMPTER))
50 #define E_CREDENTIALS_PROMPTER_GET_CLASS(obj) \
51 (G_TYPE_INSTANCE_GET_CLASS \
52 ((obj), E_TYPE_CREDENTIALS_PROMPTER, ECredentialsPrompterClass))
56 typedef struct _ECredentialsPrompter ECredentialsPrompter
;
57 typedef struct _ECredentialsPrompterClass ECredentialsPrompterClass
;
58 typedef struct _ECredentialsPrompterPrivate ECredentialsPrompterPrivate
;
61 * ECredentialsPrompterPromptFlags:
62 * @E_CREDENTIALS_PROMPTER_PROMPT_FLAG_NONE:
64 * @E_CREDENTIALS_PROMPTER_PROMPT_FLAG_ALLOW_SOURCE_SAVE:
65 * If set, any source changes during the credentials prompts, like
66 * the "remember-password" or user name changes, will be automatically
67 * stored in the source (written on the disk).
68 * @E_CREDENTIALS_PROMPTER_PROMPT_FLAG_ALLOW_STORED_CREDENTIALS:
69 * If set, the stored credentials will be returned first. If there are no
70 * credentials saved, then the user will be asked. Any credentials
71 * reprompt should not have set this flag.
73 * An #ECredentialsPrompter prompt flags, influencing behaviour
74 * of the e_credentials_prompter_prompt().
79 E_CREDENTIALS_PROMPTER_PROMPT_FLAG_NONE
= 0,
80 E_CREDENTIALS_PROMPTER_PROMPT_FLAG_ALLOW_SOURCE_SAVE
= 1 << 0,
81 E_CREDENTIALS_PROMPTER_PROMPT_FLAG_ALLOW_STORED_CREDENTIALS
= 1 << 1
82 } ECredentialsPrompterPromptFlags
;
85 * ECredentialsPrompterLoopPromptFunc:
86 * @prompter: an #ECredentialsPrompter
87 * @source: an #ESource, as passed to e_credentials_prompter_loop_prompt_sync()
88 * @credentials: an #ENamedParameters with provided credentials
89 * @out_authenticated: (out): set to %TRUE, when the authentication was successful
90 * @user_data: user data, as passed to e_credentials_prompter_loop_prompt_sync()
91 * @cancellable: a #GCancellable, as passed to e_credentials_prompter_loop_prompt_sync()
92 * @error: a #GError, to get an error, or %NULL
94 * Returns: %TRUE to continue the loop (reprompt credentials), unless @authenticated is
95 * also set to %TRUE, or %FALSE on error, as an indication that the loop should
98 typedef gboolean (*ECredentialsPrompterLoopPromptFunc
) (ECredentialsPrompter
*prompter
,
100 const ENamedParameters
*credentials
,
101 gboolean
*out_authenticated
,
103 GCancellable
*cancellable
,
106 * ECredentialsPrompter:
108 * Contains only private data that should be read and manipulated using the
113 struct _ECredentialsPrompter
{
115 ECredentialsPrompterPrivate
*priv
;
118 struct _ECredentialsPrompterClass
{
119 GObjectClass parent_class
;
122 GtkWindow
* (*get_dialog_parent
) (ECredentialsPrompter
*prompter
);
125 GType
e_credentials_prompter_get_type (void) G_GNUC_CONST
;
126 ECredentialsPrompter
*
127 e_credentials_prompter_new (ESourceRegistry
*registry
);
129 e_credentials_prompter_get_registry
130 (ECredentialsPrompter
*prompter
);
131 ESourceCredentialsProvider
*
132 e_credentials_prompter_get_provider
133 (ECredentialsPrompter
*prompter
);
134 gboolean e_credentials_prompter_get_auto_prompt
135 (ECredentialsPrompter
*prompter
);
136 void e_credentials_prompter_set_auto_prompt
137 (ECredentialsPrompter
*prompter
,
138 gboolean auto_prompt
);
139 void e_credentials_prompter_set_auto_prompt_disabled_for
140 (ECredentialsPrompter
*prompter
,
142 gboolean is_disabled
);
143 gboolean e_credentials_prompter_get_auto_prompt_disabled_for
144 (ECredentialsPrompter
*prompter
,
146 GtkWindow
* e_credentials_prompter_get_dialog_parent
147 (ECredentialsPrompter
*prompter
);
148 gboolean e_credentials_prompter_register_impl
149 (ECredentialsPrompter
*prompter
,
150 const gchar
*authentication_method
,
151 ECredentialsPrompterImpl
*prompter_impl
);
152 void e_credentials_prompter_unregister_impl
153 (ECredentialsPrompter
*prompter
,
154 const gchar
*authentication_method
,
155 ECredentialsPrompterImpl
*prompter_impl
);
156 void e_credentials_prompter_process_awaiting_credentials
157 (ECredentialsPrompter
*prompter
);
158 gboolean e_credentials_prompter_process_source
159 (ECredentialsPrompter
*prompter
,
161 void e_credentials_prompter_prompt (ECredentialsPrompter
*prompter
,
163 const gchar
*error_text
,
164 ECredentialsPrompterPromptFlags flags
,
165 GAsyncReadyCallback callback
,
167 gboolean e_credentials_prompter_prompt_finish
168 (ECredentialsPrompter
*prompter
,
169 GAsyncResult
*result
,
170 ESource
**out_source
,
171 ENamedParameters
**out_credentials
,
173 void e_credentials_prompter_complete_prompt_call
174 (ECredentialsPrompter
*prompter
,
175 GSimpleAsyncResult
*async_result
,
177 const ENamedParameters
*credentials
,
178 const GError
*error
);
179 gboolean e_credentials_prompter_loop_prompt_sync
180 (ECredentialsPrompter
*prompter
,
182 ECredentialsPrompterPromptFlags flags
,
183 ECredentialsPrompterLoopPromptFunc func
,
185 GCancellable
*cancellable
,
189 #endif /* E_CREDENTIALS_PROMPTER_H */