~ubuntu-branches/ubuntu/wily/evolution-data-server/wily

« back to all changes in this revision

Viewing changes to libedataserverui/e-credentials-prompter-impl-password.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2015-07-20 13:34:59 UTC
  • mfrom: (1.1.126) (1.2.48 sid)
  • Revision ID: package-import@ubuntu.com-20150720133459-g6y46hnu5ewtoz08
Tags: 3.16.4-0ubuntu2
debian/patches/0001-Bug-752373-Monthly-events-do-not-recur-correctly.patch:
Cherry-pick patch from upstream to fix events not recurring correctly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2015 Red Hat, Inc. (www.redhat.com)
 
3
 *
 
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.
 
7
 *
 
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
 
11
 * for more details.
 
12
 *
 
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/>.
 
15
 *
 
16
 */
 
17
 
 
18
#ifdef HAVE_CONFIG_H
 
19
#include <config.h>
 
20
#endif
 
21
 
 
22
#include <glib.h>
 
23
#include <glib/gi18n-lib.h>
 
24
 
 
25
#include <gtk/gtk.h>
 
26
 
 
27
#include <libedataserver/libedataserver.h>
 
28
 
 
29
#include "e-credentials-prompter.h"
 
30
#include "e-credentials-prompter-impl-password.h"
 
31
 
 
32
struct _ECredentialsPrompterImplPasswordPrivate {
 
33
        gpointer prompt_id;
 
34
        ESource *auth_source;
 
35
        ESource *cred_source;
 
36
        gchar *error_text;
 
37
        ENamedParameters *credentials;
 
38
 
 
39
        GtkDialog *dialog;
 
40
        gulong show_dialog_idle_id;
 
41
};
 
42
 
 
43
G_DEFINE_TYPE (ECredentialsPrompterImplPassword, e_credentials_prompter_impl_password, E_TYPE_CREDENTIALS_PROMPTER_IMPL)
 
44
 
 
45
static gboolean
 
46
password_dialog_map_event_cb (GtkWidget *dialog,
 
47
                              GdkEvent *event,
 
48
                              GtkWidget *password_entry)
 
49
{
 
50
        gtk_widget_grab_focus (password_entry);
 
51
 
 
52
        return FALSE;
 
53
}
 
54
 
 
55
static void
 
56
credentials_prompter_impl_password_get_prompt_strings (ESource *source,
 
57
                                                       gchar **prompt_title,
 
58
                                                       GString **prompt_description)
 
59
{
 
60
        GString *description;
 
61
        const gchar *message;
 
62
        gchar *display_name;
 
63
        gchar *host_name = NULL;
 
64
 
 
65
        /* Known types */
 
66
        enum {
 
67
                TYPE_UNKNOWN,
 
68
                TYPE_AMBIGUOUS,
 
69
                TYPE_ADDRESS_BOOK,
 
70
                TYPE_CALENDAR,
 
71
                TYPE_MAIL_ACCOUNT,
 
72
                TYPE_MAIL_TRANSPORT,
 
73
                TYPE_MEMO_LIST,
 
74
                TYPE_TASK_LIST
 
75
        } type = TYPE_UNKNOWN;
 
76
 
 
77
        /* XXX This is kind of a hack but it should work for now.  Build a
 
78
         *     suitable password prompt by checking for various extensions
 
79
         *     in the ESource.  If no recognizable extensions are found, or
 
80
         *     if the result is ambiguous, just refer to the data source as
 
81
         *     an "account". */
 
82
 
 
83
        display_name = e_source_dup_display_name (source);
 
84
 
 
85
        if (e_source_has_extension (source, E_SOURCE_EXTENSION_AUTHENTICATION)) {
 
86
                ESourceAuthentication *extension;
 
87
 
 
88
                extension = e_source_get_extension (source, E_SOURCE_EXTENSION_AUTHENTICATION);
 
89
                host_name = e_source_authentication_dup_host (extension);
 
90
        }
 
91
 
 
92
        if (e_source_has_extension (source, E_SOURCE_EXTENSION_ADDRESS_BOOK)) {
 
93
                type = TYPE_ADDRESS_BOOK;
 
94
        }
 
95
 
 
96
        if (e_source_has_extension (source, E_SOURCE_EXTENSION_CALENDAR)) {
 
97
                if (type == TYPE_UNKNOWN)
 
98
                        type = TYPE_CALENDAR;
 
99
                else
 
100
                        type = TYPE_AMBIGUOUS;
 
101
        }
 
102
 
 
103
        if (e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_ACCOUNT)) {
 
104
                if (type == TYPE_UNKNOWN)
 
105
                        type = TYPE_MAIL_ACCOUNT;
 
106
                else
 
107
                        type = TYPE_AMBIGUOUS;
 
108
        }
 
109
 
 
110
        if (e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_TRANSPORT)) {
 
111
                if (type == TYPE_UNKNOWN)
 
112
                        type = TYPE_MAIL_TRANSPORT;
 
113
                else
 
114
                        type = TYPE_AMBIGUOUS;
 
115
        }
 
116
 
 
117
        if (e_source_has_extension (source, E_SOURCE_EXTENSION_MEMO_LIST)) {
 
118
                if (type == TYPE_UNKNOWN)
 
119
                        type = TYPE_MEMO_LIST;
 
120
                else
 
121
                        type = TYPE_AMBIGUOUS;
 
122
        }
 
123
 
 
124
        if (e_source_has_extension (source, E_SOURCE_EXTENSION_TASK_LIST)) {
 
125
                if (type == TYPE_UNKNOWN)
 
126
                        type = TYPE_TASK_LIST;
 
127
                else
 
128
                        type = TYPE_AMBIGUOUS;
 
129
        }
 
130
 
 
131
        switch (type) {
 
132
                case TYPE_ADDRESS_BOOK:
 
133
                        message = _("Address book authentication request");
 
134
                        break;
 
135
                case TYPE_CALENDAR:
 
136
                case TYPE_MEMO_LIST:
 
137
                case TYPE_TASK_LIST:
 
138
                        message = _("Calendar authentication request");
 
139
                        break;
 
140
                case TYPE_MAIL_ACCOUNT:
 
141
                case TYPE_MAIL_TRANSPORT:
 
142
                        message = _("Mail authentication request");
 
143
                        break;
 
144
                default:  /* generic account prompt */
 
145
                        message = _("Authentication request");
 
146
                        break;
 
147
        }
 
148
 
 
149
        description = g_string_sized_new (256);
 
150
 
 
151
        g_string_append_printf (description, "<big><b>%s</b></big>\n\n", message);
 
152
 
 
153
        switch (type) {
 
154
                case TYPE_ADDRESS_BOOK:
 
155
                        g_string_append_printf (description,
 
156
                                _("Please enter the password for address book \"%s\"."), display_name);
 
157
                        break;
 
158
                case TYPE_CALENDAR:
 
159
                        g_string_append_printf (description,
 
160
                                _("Please enter the password for calendar \"%s\"."), display_name);
 
161
                        break;
 
162
                case TYPE_MAIL_ACCOUNT:
 
163
                        g_string_append_printf (description,
 
164
                                _("Please enter the password for mail account \"%s\"."), display_name);
 
165
                        break;
 
166
                case TYPE_MAIL_TRANSPORT:
 
167
                        g_string_append_printf (description,
 
168
                                _("Please enter the password for mail transport \"%s\"."), display_name);
 
169
                        break;
 
170
                case TYPE_MEMO_LIST:
 
171
                        g_string_append_printf (description,
 
172
                                _("Please enter the password for memo list \"%s\"."), display_name);
 
173
                        break;
 
174
                case TYPE_TASK_LIST:
 
175
                        g_string_append_printf (description,
 
176
                                _("Please enter the password for task list \"%s\"."), display_name);
 
177
                        break;
 
178
                default:  /* generic account prompt */
 
179
                        g_string_append_printf (description,
 
180
                                _("Please enter the password for account \"%s\"."), display_name);
 
181
                        break;
 
182
        }
 
183
 
 
184
        if (host_name != NULL)
 
185
                g_string_append_printf (
 
186
                        description, "\n(host: %s)", host_name);
 
187
 
 
188
        *prompt_title = g_strdup (message);
 
189
        *prompt_description = description;
 
190
 
 
191
        g_free (display_name);
 
192
        g_free (host_name);
 
193
}
 
194
 
 
195
static gboolean
 
196
e_credentials_prompter_impl_password_show_dialog (ECredentialsPrompterImplPassword *prompter_password)
 
197
{
 
198
        GtkWidget *dialog, *content_area, *widget;
 
199
        GtkGrid *grid;
 
200
        GtkEntry *username_entry = NULL;
 
201
        GtkEntry *password_entry;
 
202
        GtkToggleButton *remember_toggle = NULL;
 
203
        GtkWindow *dialog_parent;
 
204
        ECredentialsPrompter *prompter;
 
205
        gchar *title;
 
206
        GString *info_markup;
 
207
        gint row = 0;
 
208
        ESourceAuthentication *auth_extension = NULL;
 
209
        gboolean success;
 
210
 
 
211
        g_return_val_if_fail (E_IS_CREDENTIALS_PROMPTER_IMPL_PASSWORD (prompter_password), FALSE);
 
212
        g_return_val_if_fail (prompter_password->priv->prompt_id != NULL, FALSE);
 
213
        g_return_val_if_fail (prompter_password->priv->dialog == NULL, FALSE);
 
214
 
 
215
        prompter = e_credentials_prompter_impl_get_credentials_prompter (E_CREDENTIALS_PROMPTER_IMPL (prompter_password));
 
216
        g_return_val_if_fail (prompter != NULL, FALSE);
 
217
 
 
218
        dialog_parent = e_credentials_prompter_get_dialog_parent (prompter);
 
219
 
 
220
        credentials_prompter_impl_password_get_prompt_strings (prompter_password->priv->auth_source, &title, &info_markup);
 
221
        if (prompter_password->priv->error_text && *prompter_password->priv->error_text) {
 
222
                gchar *escaped = g_markup_printf_escaped ("%s", prompter_password->priv->error_text);
 
223
 
 
224
                g_string_append_printf (info_markup, "\n\n%s", escaped);
 
225
                g_free (escaped);
 
226
        }
 
227
 
 
228
        dialog = gtk_dialog_new_with_buttons (title, dialog_parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
 
229
                _("_Cancel"), GTK_RESPONSE_CANCEL,
 
230
                _("_OK"), GTK_RESPONSE_OK,
 
231
                NULL);
 
232
 
 
233
        prompter_password->priv->dialog = GTK_DIALOG (dialog);
 
234
        gtk_dialog_set_default_response (prompter_password->priv->dialog, GTK_RESPONSE_OK);
 
235
        gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
 
236
        if (dialog_parent)
 
237
                gtk_window_set_transient_for (GTK_WINDOW (dialog), dialog_parent);
 
238
        gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ON_PARENT);
 
239
        gtk_container_set_border_width (GTK_CONTAINER (dialog), 12);
 
240
 
 
241
        widget = gtk_dialog_get_action_area (prompter_password->priv->dialog);
 
242
        content_area = gtk_dialog_get_content_area (prompter_password->priv->dialog);
 
243
 
 
244
        /* Override GtkDialog defaults */
 
245
        gtk_box_set_spacing (GTK_BOX (widget), 12);
 
246
        gtk_container_set_border_width (GTK_CONTAINER (widget), 0);
 
247
        gtk_box_set_spacing (GTK_BOX (content_area), 12);
 
248
        gtk_container_set_border_width (GTK_CONTAINER (content_area), 0);
 
249
 
 
250
        grid = GTK_GRID (gtk_grid_new ());
 
251
        gtk_grid_set_column_spacing (grid, 12);
 
252
        gtk_grid_set_row_spacing (grid, 6);
 
253
 
 
254
        gtk_box_pack_start (GTK_BOX (content_area), GTK_WIDGET (grid), FALSE, TRUE, 0);
 
255
 
 
256
        /* Password Image */
 
257
        widget = gtk_image_new_from_icon_name ("dialog-password", GTK_ICON_SIZE_DIALOG);
 
258
        g_object_set (
 
259
                G_OBJECT (widget),
 
260
                "halign", GTK_ALIGN_START,
 
261
                "vexpand", TRUE,
 
262
                "valign", GTK_ALIGN_START,
 
263
                NULL);
 
264
 
 
265
        gtk_grid_attach (grid, widget, 0, row, 1, 1);
 
266
 
 
267
        /* Password Label */
 
268
        widget = gtk_label_new (NULL);
 
269
        gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
 
270
        gtk_label_set_markup (GTK_LABEL (widget), info_markup->str);
 
271
        g_object_set (
 
272
                G_OBJECT (widget),
 
273
                "hexpand", TRUE,
 
274
                "halign", GTK_ALIGN_FILL,
 
275
                "valign", GTK_ALIGN_CENTER,
 
276
                "width-chars", 60,
 
277
                "max-width-chars", 80,
 
278
                "xalign", 0.0,
 
279
                NULL);
 
280
 
 
281
        gtk_grid_attach (grid, widget, 1, row, 1, 1);
 
282
        row++;
 
283
 
 
284
        if (e_source_has_extension (prompter_password->priv->cred_source, E_SOURCE_EXTENSION_AUTHENTICATION)) {
 
285
                auth_extension = e_source_get_extension (prompter_password->priv->cred_source, E_SOURCE_EXTENSION_AUTHENTICATION);
 
286
 
 
287
                if (e_source_get_writable (prompter_password->priv->cred_source)) {
 
288
                        gchar *username;
 
289
 
 
290
                        username = e_source_authentication_dup_user (auth_extension);
 
291
                        if ((!username || !*username) &&
 
292
                            e_source_has_extension (prompter_password->priv->cred_source, E_SOURCE_EXTENSION_COLLECTION)) {
 
293
                                ESourceCollection *collection_extension;
 
294
                                gchar *tmp;
 
295
 
 
296
                                collection_extension = e_source_get_extension (prompter_password->priv->cred_source, E_SOURCE_EXTENSION_COLLECTION);
 
297
 
 
298
                                tmp = e_source_collection_dup_identity (collection_extension);
 
299
                                if (tmp && *tmp) {
 
300
                                        g_free (username);
 
301
                                        username = tmp;
 
302
                                        tmp = NULL;
 
303
                                }
 
304
 
 
305
                                g_free (tmp);
 
306
                        }
 
307
 
 
308
                        username_entry = GTK_ENTRY (gtk_entry_new ());
 
309
                        g_object_set (
 
310
                                G_OBJECT (username_entry),
 
311
                                "hexpand", TRUE,
 
312
                                "halign", GTK_ALIGN_FILL,
 
313
                                NULL);
 
314
 
 
315
                        gtk_grid_attach (grid, GTK_WIDGET (username_entry), 1, row, 1, 1);
 
316
                        row++;
 
317
 
 
318
                        if (username && *username) {
 
319
                                gtk_entry_set_text (username_entry, username);
 
320
                        }
 
321
 
 
322
                        g_free (username);
 
323
                }
 
324
        }
 
325
 
 
326
        password_entry = GTK_ENTRY (gtk_entry_new ());
 
327
        gtk_entry_set_visibility (password_entry, FALSE);
 
328
        gtk_entry_set_activates_default (password_entry, TRUE);
 
329
        g_object_set (
 
330
                G_OBJECT (password_entry),
 
331
                "hexpand", TRUE,
 
332
                "halign", GTK_ALIGN_FILL,
 
333
                NULL);
 
334
        if (e_named_parameters_get (prompter_password->priv->credentials, E_SOURCE_CREDENTIAL_PASSWORD))
 
335
                gtk_entry_set_text (password_entry, e_named_parameters_get (prompter_password->priv->credentials, E_SOURCE_CREDENTIAL_PASSWORD));
 
336
 
 
337
        g_signal_connect (dialog, "map-event", G_CALLBACK (password_dialog_map_event_cb), password_entry);
 
338
 
 
339
        gtk_grid_attach (grid, GTK_WIDGET (password_entry), 1, row, 1, 1);
 
340
        row++;
 
341
 
 
342
        if (username_entry && password_entry) {
 
343
                widget = gtk_label_new_with_mnemonic (_("_User Name:"));
 
344
                g_object_set (
 
345
                        G_OBJECT (widget),
 
346
                        "hexpand", FALSE,
 
347
                        "vexpand", FALSE,
 
348
                        "halign", GTK_ALIGN_END,
 
349
                        "valign", GTK_ALIGN_CENTER,
 
350
                        NULL);
 
351
 
 
352
                gtk_label_set_mnemonic_widget (GTK_LABEL (widget), GTK_WIDGET (username_entry));
 
353
                gtk_grid_attach (grid, widget, 0, row - 2, 1, 1);
 
354
 
 
355
                widget = gtk_label_new_with_mnemonic (_("_Password:"));
 
356
                g_object_set (
 
357
                        G_OBJECT (widget),
 
358
                        "hexpand", FALSE,
 
359
                        "vexpand", FALSE,
 
360
                        "halign", GTK_ALIGN_END,
 
361
                        "valign", GTK_ALIGN_CENTER,
 
362
                        NULL);
 
363
 
 
364
                gtk_label_set_mnemonic_widget (GTK_LABEL (widget), GTK_WIDGET (password_entry));
 
365
 
 
366
                gtk_grid_attach (grid, widget, 0, row - 1, 1, 1);
 
367
        }
 
368
 
 
369
        if (auth_extension) {
 
370
                /* Remember password check */
 
371
                widget = gtk_check_button_new_with_mnemonic (_("_Add this password to your keyring"));
 
372
                remember_toggle = GTK_TOGGLE_BUTTON (widget);
 
373
                gtk_toggle_button_set_active (remember_toggle, e_source_authentication_get_remember_password (auth_extension));
 
374
                g_object_set (
 
375
                        G_OBJECT (widget),
 
376
                        "hexpand", TRUE,
 
377
                        "halign", GTK_ALIGN_FILL,
 
378
                        "valign", GTK_ALIGN_FILL,
 
379
                        "margin-top", 12,
 
380
                        NULL);
 
381
 
 
382
                gtk_grid_attach (grid, widget, 1, row, 1, 1);
 
383
        }
 
384
 
 
385
        gtk_widget_show_all (GTK_WIDGET (grid));
 
386
 
 
387
        success = gtk_dialog_run (prompter_password->priv->dialog) == GTK_RESPONSE_OK;
 
388
 
 
389
        if (success) {
 
390
                if (username_entry)
 
391
                        e_named_parameters_set (prompter_password->priv->credentials,
 
392
                                E_SOURCE_CREDENTIAL_USERNAME, gtk_entry_get_text (username_entry));
 
393
                e_named_parameters_set (prompter_password->priv->credentials,
 
394
                        E_SOURCE_CREDENTIAL_PASSWORD, gtk_entry_get_text (password_entry));
 
395
 
 
396
                if (auth_extension && remember_toggle) {
 
397
                        e_source_authentication_set_remember_password (auth_extension,
 
398
                                gtk_toggle_button_get_active (remember_toggle));
 
399
                }
 
400
        }
 
401
 
 
402
        gtk_widget_destroy (dialog);
 
403
        prompter_password->priv->dialog = NULL;
 
404
 
 
405
        g_string_free (info_markup, TRUE);
 
406
        g_free (title);
 
407
 
 
408
        return success;
 
409
}
 
410
 
 
411
static void
 
412
e_credentials_prompter_impl_password_free_prompt_data (ECredentialsPrompterImplPassword *prompter_password)
 
413
{
 
414
        g_return_if_fail (E_IS_CREDENTIALS_PROMPTER_IMPL_PASSWORD (prompter_password));
 
415
 
 
416
        prompter_password->priv->prompt_id = NULL;
 
417
 
 
418
        g_clear_object (&prompter_password->priv->auth_source);
 
419
        g_clear_object (&prompter_password->priv->cred_source);
 
420
 
 
421
        g_free (prompter_password->priv->error_text);
 
422
        prompter_password->priv->error_text = NULL;
 
423
 
 
424
        e_named_parameters_free (prompter_password->priv->credentials);
 
425
        prompter_password->priv->credentials = NULL;
 
426
}
 
427
 
 
428
static gboolean
 
429
e_credentials_prompter_impl_password_show_dialog_idle_cb (gpointer user_data)
 
430
{
 
431
        ECredentialsPrompterImplPassword *prompter_password = user_data;
 
432
 
 
433
        if (g_source_is_destroyed (g_main_current_source ()))
 
434
                return FALSE;
 
435
 
 
436
        g_return_val_if_fail (E_IS_CREDENTIALS_PROMPTER_IMPL_PASSWORD (prompter_password), FALSE);
 
437
 
 
438
        if (g_source_get_id (g_main_current_source ()) == prompter_password->priv->show_dialog_idle_id) {
 
439
                gboolean success;
 
440
 
 
441
                prompter_password->priv->show_dialog_idle_id = 0;
 
442
 
 
443
                g_warn_if_fail (prompter_password->priv->dialog == NULL);
 
444
 
 
445
                success = e_credentials_prompter_impl_password_show_dialog (prompter_password);
 
446
 
 
447
                e_credentials_prompter_impl_prompt_finish (
 
448
                        E_CREDENTIALS_PROMPTER_IMPL (prompter_password),
 
449
                        prompter_password->priv->prompt_id,
 
450
                        success ? prompter_password->priv->credentials : NULL);
 
451
 
 
452
                e_credentials_prompter_impl_password_free_prompt_data (prompter_password);
 
453
        }
 
454
 
 
455
        return FALSE;
 
456
}
 
457
 
 
458
static void
 
459
e_credentials_prompter_impl_password_process_prompt (ECredentialsPrompterImpl *prompter_impl,
 
460
                                                     gpointer prompt_id,
 
461
                                                     ESource *auth_source,
 
462
                                                     ESource *cred_source,
 
463
                                                     const gchar *error_text,
 
464
                                                     const ENamedParameters *credentials)
 
465
{
 
466
        ECredentialsPrompterImplPassword *prompter_password;
 
467
 
 
468
        g_return_if_fail (E_IS_CREDENTIALS_PROMPTER_IMPL_PASSWORD (prompter_impl));
 
469
 
 
470
        prompter_password = E_CREDENTIALS_PROMPTER_IMPL_PASSWORD (prompter_impl);
 
471
        g_return_if_fail (prompter_password->priv->prompt_id == NULL);
 
472
        g_return_if_fail (prompter_password->priv->show_dialog_idle_id == 0);
 
473
 
 
474
        prompter_password->priv->prompt_id = prompt_id;
 
475
        prompter_password->priv->auth_source = g_object_ref (auth_source);
 
476
        prompter_password->priv->cred_source = g_object_ref (cred_source);
 
477
        prompter_password->priv->error_text = g_strdup (error_text);
 
478
        prompter_password->priv->credentials = e_named_parameters_new_clone (credentials);
 
479
        prompter_password->priv->show_dialog_idle_id = g_idle_add (
 
480
                e_credentials_prompter_impl_password_show_dialog_idle_cb,
 
481
                prompter_password);
 
482
}
 
483
 
 
484
static void
 
485
e_credentials_prompter_impl_password_cancel_prompt (ECredentialsPrompterImpl *prompter_impl,
 
486
                                                    gpointer prompt_id)
 
487
{
 
488
        ECredentialsPrompterImplPassword *prompter_password;
 
489
 
 
490
        g_return_if_fail (E_IS_CREDENTIALS_PROMPTER_IMPL_PASSWORD (prompter_impl));
 
491
 
 
492
        prompter_password = E_CREDENTIALS_PROMPTER_IMPL_PASSWORD (prompter_impl);
 
493
        g_return_if_fail (prompter_password->priv->prompt_id == prompt_id);
 
494
 
 
495
        /* This also closes the dialog. */
 
496
        gtk_dialog_response (prompter_password->priv->dialog, GTK_RESPONSE_CANCEL);
 
497
}
 
498
 
 
499
static void
 
500
e_credentials_prompter_impl_password_dispose (GObject *object)
 
501
{
 
502
        ECredentialsPrompterImplPassword *prompter_password = E_CREDENTIALS_PROMPTER_IMPL_PASSWORD (object);
 
503
 
 
504
        if (prompter_password->priv->show_dialog_idle_id) {
 
505
                g_source_remove (prompter_password->priv->show_dialog_idle_id);
 
506
                prompter_password->priv->show_dialog_idle_id = 0;
 
507
        }
 
508
 
 
509
        g_warn_if_fail (prompter_password->priv->prompt_id == NULL);
 
510
        g_warn_if_fail (prompter_password->priv->dialog == NULL);
 
511
 
 
512
        e_credentials_prompter_impl_password_free_prompt_data (prompter_password);
 
513
 
 
514
        /* Chain up to parent's method. */
 
515
        G_OBJECT_CLASS (e_credentials_prompter_impl_password_parent_class)->dispose (object);
 
516
}
 
517
 
 
518
static void
 
519
e_credentials_prompter_impl_password_class_init (ECredentialsPrompterImplPasswordClass *class)
 
520
{
 
521
        static const gchar *authentication_methods[] = {
 
522
                "",  /* register as the default credentials prompter */
 
523
                NULL
 
524
        };
 
525
 
 
526
        GObjectClass *object_class;
 
527
        ECredentialsPrompterImplClass *prompter_impl_class;
 
528
 
 
529
        g_type_class_add_private (class, sizeof (ECredentialsPrompterImplPasswordPrivate));
 
530
 
 
531
        object_class = G_OBJECT_CLASS (class);
 
532
        object_class->dispose = e_credentials_prompter_impl_password_dispose;
 
533
 
 
534
        prompter_impl_class = E_CREDENTIALS_PROMPTER_IMPL_CLASS (class);
 
535
        prompter_impl_class->authentication_methods = (const gchar * const *) authentication_methods;
 
536
        prompter_impl_class->process_prompt = e_credentials_prompter_impl_password_process_prompt;
 
537
        prompter_impl_class->cancel_prompt = e_credentials_prompter_impl_password_cancel_prompt;
 
538
}
 
539
 
 
540
static void
 
541
e_credentials_prompter_impl_password_init (ECredentialsPrompterImplPassword *prompter_password)
 
542
{
 
543
        prompter_password->priv = G_TYPE_INSTANCE_GET_PRIVATE (prompter_password,
 
544
                E_TYPE_CREDENTIALS_PROMPTER_IMPL_PASSWORD, ECredentialsPrompterImplPasswordPrivate);
 
545
}
 
546
 
 
547
/**
 
548
 * e_credentials_prompter_impl_password_new:
 
549
 *
 
550
 * Creates a new instance of an #ECredentialsPrompterImplPassword.
 
551
 *
 
552
 * Returns: (transfer full): a newly created #ECredentialsPrompterImplPassword,
 
553
 *    which should be freed with g_object_unref() when no longer needed.
 
554
 *
 
555
 * Since: 3.16
 
556
 **/
 
557
ECredentialsPrompterImpl *
 
558
e_credentials_prompter_impl_password_new (void)
 
559
{
 
560
        return g_object_new (E_TYPE_CREDENTIALS_PROMPTER_IMPL_PASSWORD, NULL);
 
561
}