Mercurial > pidgin.yaz
changeset 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 | 86ed8b2aa665 |
children | 3fc2e843abfc |
files | src/account.c src/account.h src/dialogs.c src/protocols/gg/gg.c src/protocols/oscar/oscar.c src/protocols/toc/toc.c |
diffstat | 6 files changed, 108 insertions(+), 120 deletions(-) [+] |
line wrap: on
line diff
--- a/src/account.c Tue Sep 30 06:43:17 2003 +0000 +++ b/src/account.c Tue Sep 30 07:47:38 2003 +0000 @@ -23,8 +23,10 @@ #include "internal.h" #include "account.h" #include "debug.h" +#include "notify.h" #include "prefs.h" #include "prpl.h" +#include "request.h" #include "signals.h" #include "server.h" #include "util.h" @@ -248,6 +250,83 @@ ui_ops->notify_added(account, remote_user, id, alias, message); } +static void +change_password_cb(GaimAccount *account, GaimRequestFields *fields) +{ + const char *orig_pass, *new_pass_1, *new_pass_2; + + orig_pass = gaim_request_fields_get_string(fields, "password"); + new_pass_1 = gaim_request_fields_get_string(fields, "new_password_1"); + new_pass_2 = gaim_request_fields_get_string(fields, "new_password_2"); + + if (g_utf8_collate(new_pass_1, new_pass_2)) + { + gaim_notify_error(NULL, NULL, + _("New passwords do not match."), NULL); + + return; + } + + if (*orig_pass == '\0' || *new_pass_1 == '\0' || *new_pass_2 == '\0') + { + gaim_notify_error(NULL, NULL, + _("Fill out all fields completely."), NULL); + return; + } + + serv_change_passwd(gaim_account_get_connection(account), + orig_pass, new_pass_1); + gaim_account_set_password(account, new_pass_1); + +} + +void +gaim_account_request_change_password(GaimAccount *account) +{ + GaimRequestFields *fields; + GaimRequestFieldGroup *group; + GaimRequestField *field; + char primary[256]; + + g_return_if_fail(account != NULL); + g_return_if_fail(gaim_account_is_connected(account)); + + fields = gaim_request_fields_new(); + + group = gaim_request_field_group_new(NULL); + gaim_request_fields_add_group(fields, group); + + field = gaim_request_field_string_new("password", _("Original password"), + NULL, FALSE); + gaim_request_field_string_set_masked(field, TRUE); + gaim_request_field_group_add_field(group, field); + + field = gaim_request_field_string_new("new_password_1", + _("New password"), + NULL, FALSE); + gaim_request_field_string_set_masked(field, TRUE); + gaim_request_field_group_add_field(group, field); + + field = gaim_request_field_string_new("new_password_2", + _("New password (again)"), + NULL, FALSE); + gaim_request_field_string_set_masked(field, TRUE); + gaim_request_field_group_add_field(group, field); + + g_snprintf(primary, sizeof(primary), _("Change password for %s"), + gaim_account_get_username(account)); + + gaim_request_fields(gaim_account_get_connection(account), + NULL, + primary, + _("Please enter your current password and your " + "new password."), + fields, + _("OK"), G_CALLBACK(change_password_cb), + _("Cancel"), NULL, + account); +} + void gaim_account_set_username(GaimAccount *account, const char *username) {
--- a/src/account.h Tue Sep 30 06:43:17 2003 +0000 +++ b/src/account.h Tue Sep 30 07:47:38 2003 +0000 @@ -45,6 +45,7 @@ void (*notify_added)(GaimAccount *account, const char *remote_user, const char *id, const char *alias, const char *message); + void (*request_change_pass)(GaimAccount *account); }; struct _GaimAccount @@ -144,6 +145,13 @@ const char *message); /** + * Requests information from the user to change the account's password. + * + * @param account The account to change the password on. + */ +void gaim_account_request_change_password(GaimAccount *account); + +/** * Sets the account's username. * * @param account The account.
--- a/src/dialogs.c Tue Sep 30 06:43:17 2003 +0000 +++ b/src/dialogs.c Tue Sep 30 07:47:38 2003 +0000 @@ -1014,119 +1014,6 @@ gtk_widget_show_all(b->window); } -void do_change_password(GtkWidget *widget, struct passwddlg *b) -{ - const gchar *orig, *new1, *new2; - - orig = gtk_entry_get_text(GTK_ENTRY(b->original)); - new1 = gtk_entry_get_text(GTK_ENTRY(b->new1)); - new2 = gtk_entry_get_text(GTK_ENTRY(b->new2)); - - if (g_utf8_collate(new1, new2)) { - gaim_notify_error(NULL, NULL, - _("New passwords do not match."), NULL); - return; - } - - if ((strlen(orig) < 1) || (strlen(new1) < 1) || (strlen(new2) < 1)) { - gaim_notify_error(NULL, NULL, - _("Fill out all fields completely."), NULL); - return; - } - - serv_change_passwd(b->gc, orig, new1); - gaim_account_set_password(gaim_connection_get_account(b->gc), new1); - - destroy_dialog(NULL, b->window); - g_free(b); -} - -void show_change_passwd(GaimConnection *gc) -{ - GaimAccount *account; - GtkWidget *hbox; - GtkWidget *label; - GtkWidget *vbox; - GtkWidget *fbox; - GtkWidget *frame; - char buf[256]; - - struct passwddlg *b = g_new0(struct passwddlg, 1); - b->gc = gc; - - account = gaim_connection_get_account(gc); - - GAIM_DIALOG(b->window); - gtk_window_set_resizable(GTK_WINDOW(b->window), TRUE); - gtk_window_set_role(GTK_WINDOW(b->window), "change_passwd"); - gtk_window_set_title(GTK_WINDOW(b->window), _("Change Password")); - g_signal_connect(G_OBJECT(b->window), "destroy", G_CALLBACK(destroy_dialog), b->window); - gtk_widget_realize(b->window); - dialogwindows = g_list_prepend(dialogwindows, b->window); - - fbox = gtk_vbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(fbox), 5); - gtk_container_add(GTK_CONTAINER(b->window), fbox); - - frame = gtk_frame_new(_("Change Password")); - gtk_box_pack_start(GTK_BOX(fbox), frame, FALSE, FALSE, 0); - - vbox = gtk_vbox_new(FALSE, 5); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); - gtk_container_add(GTK_CONTAINER(frame), vbox); - - g_snprintf(buf, sizeof(buf), _("Changing password for %s:"), gaim_account_get_username(account)); - label = gtk_label_new(buf); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 5); - - /* First Line */ - hbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new(_("Original Password")); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - b->original = gtk_entry_new(); - gtk_entry_set_visibility(GTK_ENTRY(b->original), FALSE); - gtk_box_pack_end(GTK_BOX(hbox), b->original, FALSE, FALSE, 0); - - /* Next Line */ - hbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new(_("New Password")); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - b->new1 = gtk_entry_new(); - gtk_entry_set_visibility(GTK_ENTRY(b->new1), FALSE); - gtk_box_pack_end(GTK_BOX(hbox), b->new1, FALSE, FALSE, 0); - - /* Next Line */ - hbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); - - label = gtk_label_new(_("New Password (again)")); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - - b->new2 = gtk_entry_new(); - gtk_entry_set_visibility(GTK_ENTRY(b->new2), FALSE); - gtk_box_pack_end(GTK_BOX(hbox), b->new2, FALSE, FALSE, 0); - - /* Now do our row of buttons */ - hbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(fbox), hbox, FALSE, FALSE, 0); - - b->ok = gaim_pixbuf_button_from_stock(_("OK"), GTK_STOCK_OK, GAIM_BUTTON_HORIZONTAL); - gtk_box_pack_end(GTK_BOX(hbox), b->ok, FALSE, FALSE, 0); - g_signal_connect(G_OBJECT(b->ok), "clicked", G_CALLBACK(do_change_password), b); - - b->cancel = gaim_pixbuf_button_from_stock(_("Cancel"), GTK_STOCK_CANCEL, GAIM_BUTTON_HORIZONTAL); - gtk_box_pack_end(GTK_BOX(hbox), b->cancel, FALSE, FALSE, 0); - g_signal_connect(G_OBJECT(b->cancel), "clicked", G_CALLBACK(destroy_dialog), b->window); - - gtk_widget_show_all(b->window); -} - void show_set_info(GaimConnection *gc) { GtkWidget *buttons;
--- a/src/protocols/gg/gg.c Tue Sep 30 06:43:17 2003 +0000 +++ b/src/protocols/gg/gg.c Tue Sep 30 07:47:38 2003 +0000 @@ -1,6 +1,6 @@ /* * gaim - Gadu-Gadu Protocol Plugin - * $Id: gg.c 7626 2003-09-30 06:43:17Z chipx86 $ + * $Id: gg.c 7627 2003-09-30 07:47:38Z chipx86 $ * * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL> * @@ -34,9 +34,6 @@ #include "server.h" #include "util.h" -#warning Replace show_change_passwd and remove #include <gaim.h> -#include "gaim.h" - #define GG_CONNECT_STEPS 5 #define AGG_BUF_LEN 1024 @@ -728,6 +725,12 @@ g_free(buf); } +static void +change_pass(GaimConnection *gc) +{ + gaim_account_request_change_password(gaim_connection_get_account(gc)); +} + static void import_buddies_server_results(GaimConnection *gc, gchar *webdata) { gchar *ptr; @@ -1199,7 +1202,7 @@ pam = g_new0(struct proto_actions_menu, 1); pam->label = _("Change Password"); - pam->callback = show_change_passwd; + pam->callback = change_pass; pam->gc = gc; m = g_list_append(m, pam);
--- a/src/protocols/oscar/oscar.c Tue Sep 30 06:43:17 2003 +0000 +++ b/src/protocols/oscar/oscar.c Tue Sep 30 07:47:38 2003 +0000 @@ -6267,6 +6267,11 @@ } #endif +static void oscar_change_pass(GaimConnection *gc) +{ + gaim_account_request_change_password(gaim_connection_get_account(gc)); +} + static void oscar_show_chpassurl(GaimConnection *gc) { struct oscar_data *od = gc->proto_data; @@ -6335,7 +6340,7 @@ pam = g_new0(struct proto_actions_menu, 1); pam->label = _("Change Password"); - pam->callback = show_change_passwd; + pam->callback = oscar_change_pass; pam->gc = gc; m = g_list_append(m, pam);
--- a/src/protocols/toc/toc.c Tue Sep 30 06:43:17 2003 +0000 +++ b/src/protocols/toc/toc.c Tue Sep 30 07:47:38 2003 +0000 @@ -1514,6 +1514,12 @@ return g_list_append(NULL, GAIM_AWAY_CUSTOM); } +static void +change_pass(GaimConnection *gc) +{ + gaim_account_request_change_password(gaim_connection_get_account(gc)); +} + static GList *toc_actions(GaimConnection *gc) { GList *m = NULL; @@ -1533,7 +1539,7 @@ pam = g_new0(struct proto_actions_menu, 1); pam->label = _("Change Password"); - pam->callback = show_change_passwd; + pam->callback = change_pass; pam->gc = gc; m = g_list_append(m, pam);