changeset 6109:0922bb7a7bbc

[gaim-migrate @ 6571] Make attempting to sign on to an account twice not crash Gaim, and make the prompt for password request window only open once at max. I might change this in a few minutes, but this works, and I wanted to commit it before I break something. Move the gaim_request_input() call for "Please enter your password" to connection.c instead of gtkconn.c. There is no need for this to be in gtkconn.c, and doing it in core means less work for UIs. Make closing a notify window call the cancel action. Set the titles for request windows, when given. Remove a bit of odd, un-needed code from main.c (hitting "enter" in the password field was calling doenter which called dologin. Now it just calls dologin). committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 13 Jul 2003 18:33:25 +0000
parents edbd278822a0
children d1d8e70cf33d
files src/account.c src/connection.c src/connection.h src/gtkconn.c src/gtkrequest.c src/main.c
diffstat 6 files changed, 35 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/src/account.c	Sun Jul 13 15:38:02 2003 +0000
+++ b/src/account.c	Sun Jul 13 18:33:25 2003 +0000
@@ -177,8 +177,8 @@
 	g_return_val_if_fail(account != NULL, NULL);
 	g_return_val_if_fail(!gaim_account_is_connected(account), NULL);
 
-//	if (gaim_account_is_connected(account))
-//		return gaim_account_get_connection(account);
+	if (gaim_account_get_connection(account) != NULL)
+		return NULL;
 
 	gc = gaim_connection_new(account);
 
--- a/src/connection.c	Sun Jul 13 15:38:02 2003 +0000
+++ b/src/connection.c	Sun Jul 13 18:33:25 2003 +0000
@@ -85,6 +85,21 @@
 	g_free(gc);
 }
 
+static void request_pass_ok_cb(GaimConnection *gc, const char *entry)
+{
+	GaimAccount *account = gaim_connection_get_account(gc);
+
+	gaim_account_set_password(account, (*entry != '\0') ? entry : NULL);
+
+	gaim_connection_connect(gc);
+}
+
+static void request_pass_cancel_cb(GaimConnection *gc, const char *entry)
+{
+	gaim_connection_destroy(gc);
+}
+
+
 void
 gaim_connection_connect(GaimConnection *gc)
 {
@@ -103,14 +118,19 @@
 
 	account = gaim_connection_get_account(gc);
 
+	if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED)
+		return;
+
 	if (!(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
 		!(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL) &&
 		gaim_account_get_password(account) == NULL) {
 
 		gaim_debug(GAIM_DEBUG_INFO, "connection", "Requesting password\n");
 
-		if (ops != NULL && ops->request_pass != NULL)
-			ops->request_pass(gc);
+		gaim_request_input(gc, NULL, _("Please enter your password"), NULL, 
+						   NULL, FALSE, TRUE,
+						   _("OK"), G_CALLBACK(request_pass_ok_cb),
+						   _("Cancel"), G_CALLBACK(request_pass_cancel_cb), gc);
 
 		return;
 	}
--- a/src/connection.h	Sun Jul 13 15:38:02 2003 +0000
+++ b/src/connection.h	Sun Jul 13 18:33:25 2003 +0000
@@ -48,7 +48,6 @@
 	void (*connect_progress)(GaimConnection *gc, const char *text,
 							 size_t step, size_t step_count);
 	void (*connected)(GaimConnection *gc);
-	void (*request_pass)(GaimConnection *gc);
 	void (*disconnected)(GaimConnection *gc, const char *reason);
 	void (*notice)(GaimConnection *gc, const char *text);
 
--- a/src/gtkconn.c	Sun Jul 13 15:38:02 2003 +0000
+++ b/src/gtkconn.c	Sun Jul 13 18:33:25 2003 +0000
@@ -25,7 +25,6 @@
 #include "util.h"
 
 #include "gtkblist.h"
-#include "gtkrequest.h"
 #include "gtkutils.h"
 
 #include "ui.h"
@@ -238,28 +237,6 @@
 		kill_meter(meter, _("Done."));
 }
 
-static void request_pass_ok_cb(GaimConnection *gc, const char *entry)
-{
-	GaimAccount *account = gaim_connection_get_account(gc);
-
-	gaim_account_set_password(account, (*entry != '\0') ? entry : NULL);
-
-	gaim_connection_connect(gc);
-}
-
-static void request_pass_cancel_cb(GaimConnection *gc, const char *entry)
-{
-	gaim_connection_destroy(gc);
-}
-
-static void gaim_gtk_connection_request_pass(GaimConnection *gc)
-{
-	gaim_request_input(gc, NULL, _("Enter your password."), NULL, 
-		NULL, FALSE, TRUE,
-		_("OK"), G_CALLBACK(request_pass_ok_cb),
-		_("Cancel"), G_CALLBACK(request_pass_cancel_cb), gc);
-}
-
 static void gaim_gtk_connection_disconnected(GaimConnection *gc,
 		const char *reason)
 {
@@ -291,7 +268,6 @@
 {
 	gaim_gtk_connection_connect_progress,
 	gaim_gtk_connection_connected,
-	gaim_gtk_connection_request_pass,
 	gaim_gtk_connection_disconnected,
 	gaim_gtk_connection_notice
 };
--- a/src/gtkrequest.c	Sun Jul 13 15:38:02 2003 +0000
+++ b/src/gtkrequest.c	Sun Jul 13 18:33:25 2003 +0000
@@ -79,6 +79,8 @@
 
 	if (id < data->cb_count && data->cbs[id] != NULL)
 		((GaimRequestInputCb)data->cbs[id])(data->user_data, value);
+	else
+		((GaimRequestInputCb)data->cbs[1])(data->user_data, value);
 
 	gaim_request_close(GAIM_REQUEST_INPUT, data);
 }
@@ -205,7 +207,7 @@
 	data->cbs[1] = cancel_cb;
 
 	/* Create the dialog. */
-	dialog = gtk_dialog_new_with_buttons("", NULL, 0,
+	dialog = gtk_dialog_new_with_buttons(title, NULL, 0,
 					     text_to_stock(cancel_text), 1,
 					     text_to_stock(ok_text),     0,
 					     NULL);
@@ -343,6 +345,8 @@
 
 	/* Create the dialog. */
 	data->dialog = dialog = gtk_dialog_new();
+	if (title != NULL)
+		gtk_window_set_title(GTK_WINDOW(dialog), title);
 
 	for (i = 0; i < action_count; i++) {
 		gtk_dialog_add_button(GTK_DIALOG(dialog),
@@ -436,6 +440,8 @@
 	data->cbs[1] = cancel_cb;
 
 	data->dialog = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+	if (title != NULL)
+		gtk_window_set_title(GTK_WINDOW(win), title);
 	gtk_window_set_role(GTK_WINDOW(win), "multifield");
 	gtk_container_set_border_width(GTK_CONTAINER(win), 12);
 	gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
--- a/src/main.c	Sun Jul 13 15:38:02 2003 +0000
+++ b/src/main.c	Sun Jul 13 18:33:25 2003 +0000
@@ -292,13 +292,9 @@
 
 static void doenter(GtkWidget *widget, GtkWidget *w)
 {
-	if (widget == name) {
-		gtk_entry_set_text(GTK_ENTRY(pass), "");
-		gtk_editable_select_region(GTK_EDITABLE(GTK_COMBO(name)->entry), 0, 0);
-		gtk_widget_grab_focus(pass);
-	} else if (widget == pass) {
-		dologin(widget, w);
-	}
+	gtk_entry_set_text(GTK_ENTRY(pass), "");
+	gtk_editable_select_region(GTK_EDITABLE(GTK_COMBO(name)->entry), 0, 0);
+	gtk_widget_grab_focus(pass);
 }
 
 
@@ -407,7 +403,7 @@
 	pass = gtk_entry_new();
 	gtk_entry_set_visibility(GTK_ENTRY(pass), FALSE);
 	g_signal_connect(G_OBJECT(pass), "activate",
-					 G_CALLBACK(doenter), mainwindow);
+					 G_CALLBACK(dologin), mainwindow);
 	gtk_box_pack_start(GTK_BOX(vbox2), pass, FALSE, TRUE, 0);
 	gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, TRUE, 0);