changeset 1089:f0f5c10cce63

[gaim-migrate @ 1099] added a cancel button to the progress meter committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 13 Nov 2000 02:58:00 +0000
parents 18a14e6dd0af
children 79cdc86ef4c6
files plugins/irc.c plugins/yay/yay.c src/buddy.c src/multi.c src/multi.h src/oscar.c src/server.c src/toc.c
diffstat 8 files changed, 55 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/irc.c	Mon Nov 13 00:37:02 2000 +0000
+++ b/plugins/irc.c	Mon Nov 13 02:58:00 2000 +0000
@@ -820,7 +820,7 @@
 	struct sockaddr_in site;
 	char buf[4096];
 	
-	struct gaim_connection *gc = new_gaim_conn(PROTO_IRC, user->username, user->password);
+	struct gaim_connection *gc = new_gaim_conn(user);
 	struct irc_data *idata = gc->proto_data = g_new0(struct irc_data, 1);
 	char c;
 	int i;
@@ -869,7 +869,7 @@
 
 
 	/* Now lets sign ourselves on */
-        account_online(user, gc);
+        account_online(gc);
 	serv_finish_login(gc);
 
 	if (bud_list_cache_exists(gc))
--- a/plugins/yay/yay.c	Mon Nov 13 00:37:02 2000 +0000
+++ b/plugins/yay/yay.c	Mon Nov 13 02:58:00 2000 +0000
@@ -196,7 +196,7 @@
 }
 
 static void yahoo_login(struct aim_user *user) {
-	struct gaim_connection *gc = new_gaim_conn(PROTO_YAHOO, user->username, user->password);
+	struct gaim_connection *gc = new_gaim_conn(user);
 	struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1);
 	int i;
 
@@ -247,7 +247,7 @@
 	}
 
 	debug_printf("Yahoo: logged in %s\n", gc->username);
-	account_online(user, gc);
+	account_online(gc);
 	serv_finish_login(gc);
 
 	gc->inpa = gdk_input_add(ctxt->sockfd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
--- a/src/buddy.c	Mon Nov 13 00:37:02 2000 +0000
+++ b/src/buddy.c	Mon Nov 13 02:58:00 2000 +0000
@@ -1535,7 +1535,7 @@
 	return g;
 }
 
-static int log_timeout(struct buddy_show *b) {
+static gint log_timeout(struct buddy_show *b) {
 	if (!b->connlist) {
 		struct group_show *g = find_gs_by_bs(b);
 		g->members = g_slist_remove(g->members, b);
@@ -1545,8 +1545,7 @@
 			gtk_container_remove(GTK_CONTAINER(buddies), g->item);
 			g_free(g->name);
 			g_free(g);
-		} else
-			update_num_group(g);
+		}
 		g_free(b->name);
 		g_free(b->show);
 		g_free(b);
--- a/src/multi.c	Mon Nov 13 00:37:02 2000 +0000
+++ b/src/multi.c	Mon Nov 13 02:58:00 2000 +0000
@@ -46,13 +46,13 @@
 	int opt;
 };
 
-struct gaim_connection *new_gaim_conn(int proto, char *username, char *password)
+struct gaim_connection *new_gaim_conn(struct aim_user *user)
 {
 	struct gaim_connection *gc = g_new0(struct gaim_connection, 1);
-	gc->protocol = proto;
-	gc->prpl = find_prpl(proto);
-	g_snprintf(gc->username, sizeof(gc->username), "%s", username);
-	g_snprintf(gc->password, sizeof(gc->password), "%s", password);
+	gc->protocol = user->protocol;
+	gc->prpl = find_prpl(user->protocol);
+	g_snprintf(gc->username, sizeof(gc->username), "%s", user->username);
+	g_snprintf(gc->password, sizeof(gc->password), "%s", user->password);
 	gc->keepalive = -1;
 	gc->inpa = -1;
 	gc->buddy_chats = NULL;
@@ -62,6 +62,9 @@
 
 	connections = g_slist_append(connections, gc);
 
+	user->gc = gc;
+	gc->user = user;
+
 	return gc;
 }
 
@@ -619,6 +622,7 @@
 #ifdef USE_APPLET
 				set_user_state(signing_on);
 #endif /* USE_APPLET */
+				gtk_clist_set_text(GTK_CLIST(list), row, 1, "Attempting");
 				serv_login(u);
 			}
 		} else {
@@ -704,13 +708,10 @@
 	gtk_widget_show(acctedit);
 }
 
-void account_online(struct aim_user *u, struct gaim_connection *gc)
+void account_online(struct gaim_connection *gc)
 {
 	int i;
 
-	gc->user = u;
-	u->gc = gc;
-
 	/* first we hide the login progress meter */
 	if (gc->meter)
 		gtk_widget_destroy(gc->meter);
@@ -753,6 +754,9 @@
 void account_offline(struct gaim_connection *gc)
 {
 	int i;
+	if (gc->meter)
+		gtk_widget_destroy(gc->meter);
+	gc->meter = NULL;
 	gc->user->gc = NULL; /* wasn't that awkward? */
 	if (!acctedit) return;
 	i = gtk_clist_find_row_from_data(GTK_CLIST(list), gc->user);
@@ -777,9 +781,12 @@
 	}
 }
 
-static void meter_destroy(GtkWidget *meter, struct gaim_connection *gc) {
-	gtk_widget_destroy(meter);
-	gc->meter = NULL;
+static void cancel_signon(GtkWidget *button, struct gaim_connection *gc) {
+	signoff(gc);
+}
+
+static gint meter_destroy(GtkWidget *meter, GdkEvent *evt, struct gaim_connection *gc) {
+	return TRUE;
 }
 
 void set_login_progress(struct gaim_connection *gc, float howfar, char *message) {
@@ -787,7 +794,7 @@
 		gtk_widget_hide(mainwindow);
 
 	if (!gc->meter) {
-		GtkWidget *box, *label;
+		GtkWidget *box, *label, *button;
 		char buf[256];
 
 		gc->meter = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -796,7 +803,7 @@
 		gtk_container_set_border_width(GTK_CONTAINER(gc->meter), 5);
 		g_snprintf(buf, sizeof(buf), "%s Signing On", gc->username);
 		gtk_window_set_title(GTK_WINDOW(gc->meter), buf);
-		gtk_signal_connect(GTK_OBJECT(gc->meter), "destroy",
+		gtk_signal_connect(GTK_OBJECT(gc->meter), "delete_event",
 				   GTK_SIGNAL_FUNC(meter_destroy), gc);
 		gtk_widget_realize(gc->meter);
 		aol_icon(gc->meter->window);
@@ -819,6 +826,11 @@
 		gtk_box_pack_start(GTK_BOX(box), gc->status, 0, 0, 5);
 		gtk_widget_show(gc->status);
 
+		button = gtk_button_new_with_label(_("Cancel"));
+		gtk_box_pack_start(GTK_BOX(box), button, 0, 0, 5);
+		gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(cancel_signon), gc);
+		gtk_widget_show(button);
+
 		gtk_widget_show(gc->meter);
 	}
 
--- a/src/multi.h	Mon Nov 13 00:37:02 2000 +0000
+++ b/src/multi.h	Mon Nov 13 02:58:00 2000 +0000
@@ -71,14 +71,14 @@
 /* now that we have our struct, we're going to need lots of them. Maybe even a list of them. */
 extern GSList *connections;
 
-struct gaim_connection *new_gaim_conn(int, char *, char *);
+struct gaim_connection *new_gaim_conn(struct aim_user *);
 void destroy_gaim_conn(struct gaim_connection *);
 
 struct gaim_connection *find_gaim_conn_by_name(char *);
 
 void account_editor(GtkWidget *, GtkWidget *);
 
-void account_online(struct aim_user *, struct gaim_connection *);
+void account_online(struct gaim_connection *);
 void account_offline(struct gaim_connection *);
 
 void auto_login();
--- a/src/oscar.c	Mon Nov 13 00:37:02 2000 +0000
+++ b/src/oscar.c	Mon Nov 13 02:58:00 2000 +0000
@@ -308,7 +308,7 @@
 	struct aim_conn_t *conn;
 	char buf[256];
 	char *finalauth = NULL;
-	struct gaim_connection *gc = new_gaim_conn(PROTO_OSCAR, user->username, user->password);
+	struct gaim_connection *gc = new_gaim_conn(user);
 	struct oscar_data *odata = gc->proto_data = g_new0(struct oscar_data, 1);
 	gc->user = user;
 
@@ -343,11 +343,6 @@
 	sess->tx_enqueue = &aim_tx_enqueue__immediate;
 	odata->sess = sess;
 
-	sprintf(buf, _("Looking up %s"), finalauth ? finalauth : FAIM_LOGIN_SERVER);
-	set_login_progress(gc, 1, buf);
-	/* this creates a possible race condition, but hey, what can you do */
-	while (gtk_events_pending())
-		gtk_main_iteration();
 	conn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, finalauth ? finalauth : FAIM_LOGIN_SERVER);
 
         if (finalauth)
@@ -356,7 +351,7 @@
 	if (conn == NULL) {
 		debug_print(_("internal connection error\n"));
 		hide_login_progress(gc, _("Unable to login to AIM"));
-		destroy_gaim_conn(gc);
+		serv_close(gc);
 		return;
 	} else if (conn->fd == -1) {
 		if (conn->status & AIM_CONN_STATUS_RESOLVERR) {
@@ -368,7 +363,7 @@
 			debug_print(debug_buff); debug_print("\n");
 			hide_login_progress(gc, debug_buff);
 		}
-		destroy_gaim_conn(gc);
+		serv_close(gc);
 		return;
 	}
 	g_snprintf(buf, sizeof(buf), _("Signon: %s"), gc->username);
@@ -472,14 +467,14 @@
 		set_user_state(offline);
 #endif
 		hide_login_progress(gc, _("Internal Error"));
-		destroy_gaim_conn(gc);
+		serv_close(gc);
 		return -1;
 	} else if (bosconn->status & AIM_CONN_STATUS_CONNERR) {
 #ifdef USE_APPLET
 		set_user_state(offline);
 #endif
 		hide_login_progress(gc, _("Could Not Connect"));
-		destroy_gaim_conn(gc);
+		serv_close(gc);
 		return -1;
 	}
 
@@ -1260,7 +1255,7 @@
 		aim_bos_setprofile(sess, command->conn, gc->user->user_info, NULL, gaim_caps);
 		aim_bos_reqbuddyrights(sess, command->conn);
 
-		account_online(gc->user, gc); /* this is an awkward hack */
+		account_online(gc);
 		serv_finish_login(gc);
 
 		if (bud_list_cache_exists(gc))
--- a/src/server.c	Mon Nov 13 00:37:02 2000 +0000
+++ b/src/server.c	Mon Nov 13 02:58:00 2000 +0000
@@ -47,6 +47,7 @@
 void serv_login(struct aim_user *user)
 {
 	struct prpl *p = find_prpl(user->protocol);
+	if (user->gc != NULL) return;
 	if (p && p->login) {
 		debug_printf("Logging in using %s\n", (*p->name)());
 		(*p->login)(user);
--- a/src/toc.c	Mon Nov 13 00:37:02 2000 +0000
+++ b/src/toc.c	Mon Nov 13 02:58:00 2000 +0000
@@ -47,7 +47,7 @@
 #include "pixmaps/dt_icon.xpm"
 #include "pixmaps/free_icon.xpm"
 
-#define REVISION "gaim:$Revision: 1098 $"
+#define REVISION "gaim:$Revision: 1099 $"
 
 struct toc_data {
 	int toc_fd;
@@ -81,7 +81,7 @@
 	char buf[80];
 	char buf2[2048];
 
-	gc = new_gaim_conn(PROTO_TOC, user->username, user->password);
+	gc = new_gaim_conn(user);
 	gc->proto_data = tdt = g_new0(struct toc_data, 1);
 	
 	g_snprintf(buf, sizeof(buf), "Looking up %s", 
@@ -89,6 +89,8 @@
 	set_login_progress(gc, 1, buf);
 	while (gtk_events_pending())
 		gtk_main_iteration();
+	if (!g_slist_find(connections, gc))
+		return;
 
 	tdt->toc_fd = proxy_connect(
 		user->proto_opt[USEROPT_AUTH][0] ? user->proto_opt[USEROPT_AUTH] : TOC_HOST,
@@ -100,7 +102,7 @@
 		g_snprintf(buf, sizeof(buf), "Connect to %s failed",
 			 user->proto_opt[USEROPT_AUTH]);
 		hide_login_progress(gc, buf);
-		destroy_gaim_conn(gc);
+		serv_close(gc);
 		return;
         }
 
@@ -108,10 +110,12 @@
 	set_login_progress(gc, 3, buf);
 	while (gtk_events_pending())
 		gtk_main_iteration();
+	if (!g_slist_find(connections, gc))
+		return;
 	
 	if (toc_signon(gc) < 0) {
 		hide_login_progress(gc, "Disconnected.");
-		destroy_gaim_conn(gc);
+		serv_close(gc);
 		return;
 	}
 
@@ -119,9 +123,11 @@
 	set_login_progress(gc, 4, buf);
 	while (gtk_events_pending())
 		gtk_main_iteration();
+	if (!g_slist_find(connections, gc))
+		return;
 	if (toc_wait_signon(gc) < 0) {
 		hide_login_progress(gc, "Authentication Failed");
-		destroy_gaim_conn(gc);
+		serv_close(gc);
 		return;
 	}
 
@@ -132,8 +138,10 @@
 	set_login_progress(gc, 5, buf);
 	while (gtk_events_pending())
 		gtk_main_iteration();
+	if (!g_slist_find(connections, gc))
+		return;
 
-	account_online(user, gc);
+	account_online(gc);
 	serv_finish_login(gc);
 
 	config = toc_wait_config(gc);