| 87 |
86 |
| 88 static void |
87 static void |
| 89 save_account_cb(AccountEditDialog *dialog) |
88 save_account_cb(AccountEditDialog *dialog) |
| 90 { |
89 { |
| 91 PurpleAccount *account; |
90 PurpleAccount *account; |
| 92 PurpleCredentialManager *manager = NULL; |
|
| 93 PurpleProtocol *protocol; |
91 PurpleProtocol *protocol; |
| 94 const char *value; |
92 const char *value; |
| 95 GString *username; |
93 GString *username; |
| 96 |
94 |
| 97 /* XXX: Do some error checking first. */ |
95 /* XXX: Do some error checking first. */ |
| 98 |
|
| 99 manager = purple_credential_manager_get_default(); |
|
| 100 |
96 |
| 101 protocol = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); |
97 protocol = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(dialog->protocol)); |
| 102 |
98 |
| 103 /* Username && user-splits */ |
99 /* Username && user-splits */ |
| 104 value = gnt_entry_get_text(GNT_ENTRY(dialog->username)); |
100 value = gnt_entry_get_text(GNT_ENTRY(dialog->username)); |
| 187 purple_account_set_private_alias(account, value); |
183 purple_account_set_private_alias(account, value); |
| 188 |
184 |
| 189 /* Remember password and password */ |
185 /* Remember password and password */ |
| 190 purple_account_set_remember_password(account, |
186 purple_account_set_remember_password(account, |
| 191 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->remember))); |
187 gnt_check_box_get_checked(GNT_CHECK_BOX(dialog->remember))); |
| 192 value = gnt_entry_get_text(GNT_ENTRY(dialog->password)); |
|
| 193 if (value && *value) { |
|
| 194 purple_credential_manager_write_password_async(manager, account, value, |
|
| 195 NULL, NULL, NULL); |
|
| 196 } else { |
|
| 197 purple_credential_manager_clear_password_async(manager, account, NULL, |
|
| 198 NULL, NULL); |
|
| 199 } |
|
| 200 |
188 |
| 201 /* Protocol options */ |
189 /* Protocol options */ |
| 202 if (protocol) |
190 if (protocol) |
| 203 { |
191 { |
| 204 GList *iter, *entries, *opts; |
192 GList *iter, *entries, *opts; |
| 518 gnt_box_readjust(GNT_BOX(dialog->window)); |
506 gnt_box_readjust(GNT_BOX(dialog->window)); |
| 519 gnt_widget_draw(dialog->window); |
507 gnt_widget_draw(dialog->window); |
| 520 } |
508 } |
| 521 |
509 |
| 522 static void |
510 static void |
| 523 edit_account_continue(GObject *obj, GAsyncResult *res, gpointer data) |
511 edit_account(PurpleAccount *account) |
| 524 { |
512 { |
| 525 PurpleAccount *account = PURPLE_ACCOUNT(data); |
|
| 526 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj); |
|
| 527 GntWidget *window, *hbox; |
513 GntWidget *window, *hbox; |
| 528 GntWidget *combo, *button, *entry; |
514 GntWidget *combo, *button, *entry; |
| 529 GList *list, *iter; |
515 GList *list, *iter; |
| 530 AccountEditDialog *dialog; |
516 AccountEditDialog *dialog; |
| 531 PurpleProtocol *protocol; |
517 PurpleProtocol *protocol; |
| 532 PurpleProtocolManager *protocol_manager = NULL; |
518 PurpleProtocolManager *protocol_manager = NULL; |
| 533 gchar *password = NULL; |
|
| 534 |
|
| 535 password = purple_credential_manager_read_password_finish(manager, res, |
|
| 536 NULL); |
|
| 537 |
519 |
| 538 if (account) |
520 if (account) |
| 539 { |
521 { |
| 540 GList *iter; |
522 GList *iter; |
| 541 for (iter = accountdialogs; iter; iter = iter->next) |
523 for (iter = accountdialogs; iter; iter = iter->next) |
| 605 |
587 |
| 606 hbox = gnt_hbox_new(TRUE); |
588 hbox = gnt_hbox_new(TRUE); |
| 607 gnt_box_set_pad(GNT_BOX(hbox), 0); |
589 gnt_box_set_pad(GNT_BOX(hbox), 0); |
| 608 gnt_box_add_widget(GNT_BOX(window), hbox); |
590 gnt_box_add_widget(GNT_BOX(window), hbox); |
| 609 |
591 |
| 610 dialog->password = entry = gnt_entry_new(NULL); |
|
| 611 gnt_entry_set_masked(GNT_ENTRY(entry), TRUE); |
|
| 612 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Password:"))); |
|
| 613 gnt_box_add_widget(GNT_BOX(hbox), entry); |
|
| 614 if (account) { |
|
| 615 gnt_entry_set_text(GNT_ENTRY(entry), password); |
|
| 616 } |
|
| 617 |
|
| 618 hbox = gnt_hbox_new(TRUE); |
|
| 619 gnt_box_set_pad(GNT_BOX(hbox), 0); |
|
| 620 gnt_box_add_widget(GNT_BOX(window), hbox); |
|
| 621 |
|
| 622 dialog->alias = entry = gnt_entry_new(NULL); |
592 dialog->alias = entry = gnt_entry_new(NULL); |
| 623 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Alias:"))); |
593 gnt_box_add_widget(GNT_BOX(hbox), gnt_label_new(_("Alias:"))); |
| 624 gnt_box_add_widget(GNT_BOX(hbox), entry); |
594 gnt_box_add_widget(GNT_BOX(hbox), entry); |
| 625 if (account) |
595 if (account) |
| 626 gnt_entry_set_text(GNT_ENTRY(entry), purple_account_get_private_alias(account)); |
596 gnt_entry_set_text(GNT_ENTRY(entry), purple_account_get_private_alias(account)); |
| 658 |
628 |
| 659 gnt_widget_show(window); |
629 gnt_widget_show(window); |
| 660 gnt_box_readjust(GNT_BOX(window)); |
630 gnt_box_readjust(GNT_BOX(window)); |
| 661 gnt_widget_draw(window); |
631 gnt_widget_draw(window); |
| 662 |
632 |
| 663 g_free(password); |
|
| 664 g_list_free(list); |
633 g_list_free(list); |
| 665 } |
|
| 666 |
|
| 667 static void |
|
| 668 edit_account(PurpleAccount *account) |
|
| 669 { |
|
| 670 PurpleCredentialManager *manager = NULL; |
|
| 671 |
|
| 672 manager = purple_credential_manager_get_default(); |
|
| 673 purple_credential_manager_read_password_async(manager, account, NULL, |
|
| 674 edit_account_continue, |
|
| 675 account); |
|
| 676 } |
634 } |
| 677 |
635 |
| 678 static void |
636 static void |
| 679 add_account_cb(GntWidget *widget, gpointer null) |
637 add_account_cb(GntWidget *widget, gpointer null) |
| 680 { |
638 { |