1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
/*
*
* This program 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; either
* version 2 of the License, or (at your option) version 3.
*
* This program 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 the program; if not, see <http://www.gnu.org/licenses/>
*
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
/* exchange-change-password: Change Password code */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "exchange-change-password.h"
#include <exchange-account.h>
#include <e2k-utils.h>
#include <glade/glade-xml.h>
#include <gtk/gtk.h>
#define FILENAME EVOLUTION_GLADEDIR "/exchange-change-password.glade"
#define ROOTNODE "pass_dialog"
#define STARTNODE "pass_vbox"
static void
entry_changed (GtkEntry *entry, gpointer user_data)
{
GladeXML *xml = user_data;
GtkEntry *new_entry, *confirm_entry;
GtkWidget *ok_button;
const gchar *text;
new_entry = GTK_ENTRY (glade_xml_get_widget (xml, "new_pass_entry"));
confirm_entry = GTK_ENTRY (glade_xml_get_widget (xml, "confirm_pass_entry"));
ok_button = glade_xml_get_widget (xml, "okbutton1");
text = gtk_entry_get_text (new_entry);
if (!text || !*text) {
gtk_widget_set_sensitive (ok_button, FALSE);
return;
}
text = gtk_entry_get_text (confirm_entry);
if (!text || !*text) {
gtk_widget_set_sensitive (ok_button, FALSE);
return;
}
gtk_widget_set_sensitive (ok_button, TRUE);
}
/**
* exchange_get_new_password:
* @existing_password: The user's current password
* @voluntary: %TRUE if the user has chosen "Change Password",
* %FALSE if their old password has expired.
*
* Prompt the user for a new password.
*/
gchar *
exchange_get_new_password (const gchar *existing_password, gboolean voluntary)
{
GladeXML *xml;
GtkWidget *top_widget;
GtkEntry *cur_entry, *new_entry, *confirm_entry;
GtkResponseType response;
GtkLabel *top_label;
gchar *new_pass;
xml = glade_xml_new (FILENAME, ROOTNODE, NULL);
top_widget = glade_xml_get_widget (xml, ROOTNODE);
cur_entry = GTK_ENTRY (glade_xml_get_widget (xml, "current_pass_entry"));
new_entry = GTK_ENTRY (glade_xml_get_widget (xml, "new_pass_entry"));
g_signal_connect (new_entry, "changed",
G_CALLBACK (entry_changed), xml);
confirm_entry = GTK_ENTRY (glade_xml_get_widget (xml, "confirm_pass_entry"));
g_signal_connect (confirm_entry, "changed",
G_CALLBACK (entry_changed), xml);
entry_changed (NULL, xml);
top_label = GTK_LABEL (glade_xml_get_widget (xml, "pass_label"));
if (voluntary)
gtk_widget_hide (GTK_WIDGET (top_label));
run_dialog_again:
response = gtk_dialog_run (GTK_DIALOG (top_widget));
if (response == GTK_RESPONSE_OK) {
const gchar *cur_pass, *new_pass1, *new_pass2;
cur_pass = gtk_entry_get_text (cur_entry);
new_pass1 = gtk_entry_get_text (new_entry);
new_pass2 = gtk_entry_get_text (confirm_entry);
if (existing_password) {
if (strcmp (cur_pass, existing_password) != 0) {
/* User entered a wrong existing
* password. Prompt him again.
*/
gtk_label_set_text (top_label, _("The current password does not match the existing password for your account. Please enter the correct password"));
gtk_widget_show (GTK_WIDGET (top_label));
goto run_dialog_again;
}
}
if (strcmp (new_pass1, new_pass2) != 0) {
gtk_label_set_text (top_label, _("The two passwords do not match. Please re-enter the passwords."));
gtk_widget_show (GTK_WIDGET (top_label));
goto run_dialog_again;
}
new_pass = g_strdup (new_pass1);
} else
new_pass = NULL;
gtk_widget_destroy (top_widget);
g_object_unref (xml);
return new_pass;
}
|