comparison src/account.c @ 7063:7fdac700deb1

[gaim-migrate @ 7627] show_change_pass, or whatever it was called, is now core/UI split. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 30 Sep 2003 07:47:38 +0000
parents dece74f05509
children 71e0da45abe6
comparison
equal deleted inserted replaced
7062:86ed8b2aa665 7063:7fdac700deb1
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */ 22 */
23 #include "internal.h" 23 #include "internal.h"
24 #include "account.h" 24 #include "account.h"
25 #include "debug.h" 25 #include "debug.h"
26 #include "notify.h"
26 #include "prefs.h" 27 #include "prefs.h"
27 #include "prpl.h" 28 #include "prpl.h"
29 #include "request.h"
28 #include "signals.h" 30 #include "signals.h"
29 #include "server.h" 31 #include "server.h"
30 #include "util.h" 32 #include "util.h"
31 33
32 typedef enum 34 typedef enum
244 246
245 ui_ops = gaim_accounts_get_ui_ops(); 247 ui_ops = gaim_accounts_get_ui_ops();
246 248
247 if (ui_ops != NULL && ui_ops->notify_added != NULL) 249 if (ui_ops != NULL && ui_ops->notify_added != NULL)
248 ui_ops->notify_added(account, remote_user, id, alias, message); 250 ui_ops->notify_added(account, remote_user, id, alias, message);
251 }
252
253 static void
254 change_password_cb(GaimAccount *account, GaimRequestFields *fields)
255 {
256 const char *orig_pass, *new_pass_1, *new_pass_2;
257
258 orig_pass = gaim_request_fields_get_string(fields, "password");
259 new_pass_1 = gaim_request_fields_get_string(fields, "new_password_1");
260 new_pass_2 = gaim_request_fields_get_string(fields, "new_password_2");
261
262 if (g_utf8_collate(new_pass_1, new_pass_2))
263 {
264 gaim_notify_error(NULL, NULL,
265 _("New passwords do not match."), NULL);
266
267 return;
268 }
269
270 if (*orig_pass == '\0' || *new_pass_1 == '\0' || *new_pass_2 == '\0')
271 {
272 gaim_notify_error(NULL, NULL,
273 _("Fill out all fields completely."), NULL);
274 return;
275 }
276
277 serv_change_passwd(gaim_account_get_connection(account),
278 orig_pass, new_pass_1);
279 gaim_account_set_password(account, new_pass_1);
280
281 }
282
283 void
284 gaim_account_request_change_password(GaimAccount *account)
285 {
286 GaimRequestFields *fields;
287 GaimRequestFieldGroup *group;
288 GaimRequestField *field;
289 char primary[256];
290
291 g_return_if_fail(account != NULL);
292 g_return_if_fail(gaim_account_is_connected(account));
293
294 fields = gaim_request_fields_new();
295
296 group = gaim_request_field_group_new(NULL);
297 gaim_request_fields_add_group(fields, group);
298
299 field = gaim_request_field_string_new("password", _("Original password"),
300 NULL, FALSE);
301 gaim_request_field_string_set_masked(field, TRUE);
302 gaim_request_field_group_add_field(group, field);
303
304 field = gaim_request_field_string_new("new_password_1",
305 _("New password"),
306 NULL, FALSE);
307 gaim_request_field_string_set_masked(field, TRUE);
308 gaim_request_field_group_add_field(group, field);
309
310 field = gaim_request_field_string_new("new_password_2",
311 _("New password (again)"),
312 NULL, FALSE);
313 gaim_request_field_string_set_masked(field, TRUE);
314 gaim_request_field_group_add_field(group, field);
315
316 g_snprintf(primary, sizeof(primary), _("Change password for %s"),
317 gaim_account_get_username(account));
318
319 gaim_request_fields(gaim_account_get_connection(account),
320 NULL,
321 primary,
322 _("Please enter your current password and your "
323 "new password."),
324 fields,
325 _("OK"), G_CALLBACK(change_password_cb),
326 _("Cancel"), NULL,
327 account);
249 } 328 }
250 329
251 void 330 void
252 gaim_account_set_username(GaimAccount *account, const char *username) 331 gaim_account_set_username(GaimAccount *account, const char *username)
253 { 332 {