comparison src/account.c @ 11042:a5c31b83063f

[gaim-migrate @ 12954] Patch #1228093 from Sadrul Habib Chowdhury "This patch adds a checkbox `Save password' in the request-password dialog." -- sadrul committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Thu, 30 Jun 2005 05:13:41 +0000
parents 50224ac8184d
children da05145441ca
comparison
equal deleted inserted replaced
11041:84dd837a4445 11042:a5c31b83063f
754 754
755 gaim_connection_new(account, TRUE, NULL); 755 gaim_connection_new(account, TRUE, NULL);
756 } 756 }
757 757
758 static void 758 static void
759 request_password_ok_cb(GaimAccount *account, const char *entry) 759 request_password_ok_cb(GaimAccount *account, GaimRequestFields *fields)
760 { 760 {
761 const char *entry;
762 gboolean remember;
763
764 entry = gaim_request_fields_get_string(fields, "password");
765 remember = gaim_request_fields_get_bool(fields, "remember");
766
761 if (!entry || !*entry) 767 if (!entry || !*entry)
762 { 768 {
763 gaim_notify_error(account, NULL, _("Password is required to sign on."), NULL); 769 gaim_notify_error(account, NULL, _("Password is required to sign on."), NULL);
764 return; 770 return;
765 } 771 }
766 772
773 if(remember)
774 gaim_account_set_remember_password(account, TRUE);
775
767 if (gaim_account_get_remember_password(account)) 776 if (gaim_account_get_remember_password(account))
768 gaim_account_set_password(account, entry); 777 gaim_account_set_password(account, entry);
769 778
770 gaim_connection_new(account, FALSE, entry); 779 gaim_connection_new(account, FALSE, entry);
771 } 780 }
772 781
773 /*
774 * TODO: Make the entry box a required field, and add a
775 * "save password" checkbox.
776 */
777 static void 782 static void
778 request_password(GaimAccount *account) 783 request_password(GaimAccount *account)
779 { 784 {
780 gchar *primary; 785 gchar *primary;
781 const gchar *username; 786 const gchar *username;
787 GaimRequestFieldGroup *group;
788 GaimRequestField *field;
789 GaimRequestFields *fields;
782 790
783 /* Close any previous password request windows */ 791 /* Close any previous password request windows */
784 gaim_request_close_with_handle(account); 792 gaim_request_close_with_handle(account);
785 793
786 username = gaim_account_get_username(account); 794 username = gaim_account_get_username(account);
787 primary = g_strdup_printf(_("Enter password for %s (%s)"), username, 795 primary = g_strdup_printf(_("Enter password for %s (%s)"), username,
788 gaim_account_get_protocol_name(account)); 796 gaim_account_get_protocol_name(account));
789 gaim_request_input(account, _("Enter Password"), primary, NULL, NULL, 797
790 FALSE, TRUE, NULL, 798 fields = gaim_request_fields_new();
791 _("OK"), G_CALLBACK(request_password_ok_cb), 799 group = gaim_request_field_group_new(NULL);
792 _("Cancel"), NULL, account); 800 gaim_request_fields_add_group(fields, group);
801
802 field = gaim_request_field_string_new("password", _("Enter Password"), NULL, FALSE);
803 gaim_request_field_string_set_masked(field, TRUE);
804 gaim_request_field_set_required(field, TRUE);
805 gaim_request_field_group_add_field(group, field);
806
807 field = gaim_request_field_bool_new("remember", _("Save password"), FALSE);
808 gaim_request_field_group_add_field(group, field);
809
810 gaim_request_fields(account,
811 NULL,
812 primary,
813 NULL,
814 fields,
815 _("OK"), G_CALLBACK(request_password_ok_cb),
816 _("Cancel"), NULL,
817 account);
793 g_free(primary); 818 g_free(primary);
794 } 819 }
795 820
796 void 821 void
797 gaim_account_connect(GaimAccount *account) 822 gaim_account_connect(GaimAccount *account)