pidgin/gtkaccount.c

changeset 41435
c46c43e89f34
parent 41392
b5c84f55d5d2
child 41446
45fef383cf60
equal deleted inserted replaced
41434:31c7fd8a23f2 41435:c46c43e89f34
78 GtkWidget *register_button; 78 GtkWidget *register_button;
79 79
80 /* Login Options */ 80 /* Login Options */
81 GtkWidget *login_frame; 81 GtkWidget *login_frame;
82 GtkWidget *protocol_menu; 82 GtkWidget *protocol_menu;
83 gchar *password;
84 GtkWidget *username_entry; 83 GtkWidget *username_entry;
85 GdkRGBA username_entry_hint_color; 84 GdkRGBA username_entry_hint_color;
86 GtkWidget *alias_entry; 85 GtkWidget *alias_entry;
87 86
88 /* User Options */ 87 /* User Options */
926 925
927 g_clear_object(&dialog->icon_filesel); 926 g_clear_object(&dialog->icon_filesel);
928 927
929 purple_signals_disconnect_by_handle(dialog); 928 purple_signals_disconnect_by_handle(dialog);
930 929
931 purple_str_wipe(dialog->password);
932
933 g_free(dialog); 930 g_free(dialog);
934 return FALSE; 931 return FALSE;
935 } 932 }
936 933
937 static void 934 static void
1171 default: 1168 default:
1172 break; 1169 break;
1173 } 1170 }
1174 } 1171 }
1175 1172
1176 static void 1173 void
1177 pidgin_account_dialog_show_continue(PidginAccountDialogType type, 1174 pidgin_account_dialog_show(PidginAccountDialogType type,
1178 PurpleAccount *account, 1175 PurpleAccount *account)
1179 const gchar *password)
1180 { 1176 {
1181 AccountPrefsDialog *dialog; 1177 AccountPrefsDialog *dialog;
1182 GtkWidget *win; 1178 GtkWidget *win;
1183 GtkWidget *main_vbox; 1179 GtkWidget *main_vbox;
1184 GtkWidget *vbox; 1180 GtkWidget *vbox;
1190 if(PURPLE_IS_ACCOUNT(account)) { 1186 if(PURPLE_IS_ACCOUNT(account)) {
1191 dialog->protocol_id = g_strdup(purple_account_get_protocol_id(account)); 1187 dialog->protocol_id = g_strdup(purple_account_get_protocol_id(account));
1192 } 1188 }
1193 1189
1194 dialog->account = account; 1190 dialog->account = account;
1195 dialog->password = g_strdup(password);
1196 dialog->type = type; 1191 dialog->type = type;
1197 dialog->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); 1192 dialog->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
1198 1193
1199 if(dialog->protocol_id != NULL) { 1194 if(dialog->protocol_id != NULL) {
1200 PurpleProtocolManager *manager = purple_protocol_manager_get_default(); 1195 PurpleProtocolManager *manager = purple_protocol_manager_get_default();
1269 1264
1270 /* Show the window. */ 1265 /* Show the window. */
1271 gtk_widget_show(win); 1266 gtk_widget_show(win);
1272 if (!account) 1267 if (!account)
1273 gtk_widget_grab_focus(dialog->protocol_menu); 1268 gtk_widget_grab_focus(dialog->protocol_menu);
1274 }
1275
1276 static void
1277 pidgin_account_dialog_read_password_cb(GObject *obj, GAsyncResult *res,
1278 gpointer data)
1279 {
1280 PurpleCredentialManager *manager = PURPLE_CREDENTIAL_MANAGER(obj);
1281 PidginAccountDialogShowData *d = (PidginAccountDialogShowData *)data;
1282 GError *error = NULL;
1283 gchar *password;
1284
1285 password = purple_credential_manager_read_password_finish(manager, res,
1286 &error);
1287
1288 if(error != NULL) {
1289 purple_debug_warning("gtkaccount", "failed to read password: %s",
1290 error->message);
1291
1292 g_error_free(error);
1293 }
1294
1295 pidgin_account_dialog_show_continue(d->type, d->account, password);
1296
1297 g_free(password);
1298 g_free(d);
1299 }
1300
1301 void
1302 pidgin_account_dialog_show(PidginAccountDialogType type, PurpleAccount *account)
1303 {
1304 PurpleCredentialManager *manager = NULL;
1305
1306 manager = purple_credential_manager_get_default();
1307
1308 if(PURPLE_IS_ACCOUNT(account)) {
1309 /* this is kind of dangerous, but it's no worse than the old version.
1310 * Regardless this dialog needs a lot of TLC.
1311 */
1312 PidginAccountDialogShowData *data = NULL;
1313 data = g_new0(PidginAccountDialogShowData, 1);
1314 data->account = account;
1315 data->type = type;
1316
1317 purple_credential_manager_read_password_async(manager, account, NULL,
1318 pidgin_account_dialog_read_password_cb,
1319 data);
1320 } else {
1321 pidgin_account_dialog_show_continue(type, account, NULL);
1322 }
1323 } 1269 }
1324 1270
1325 /************************************************************************** 1271 /**************************************************************************
1326 * Accounts Dialog 1272 * Accounts Dialog
1327 **************************************************************************/ 1273 **************************************************************************/

mercurial