changeset 988:9523b772e546

[gaim-migrate @ 998] progress meters for signing in. UI should be changed but at least there's something there now committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 13 Oct 2000 19:56:11 +0000
parents cf6662982b40
children bd8eb3efe14e
files src/aim.c src/gaim.h src/multi.c src/multi.h src/oscar.c src/toc.c
diffstat 6 files changed, 113 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/aim.c	Fri Oct 13 18:55:04 2000 +0000
+++ b/src/aim.c	Fri Oct 13 19:56:11 2000 +0000
@@ -108,13 +108,6 @@
 #endif /* USE_APPLET */
 }
 
-void hide_login_progress(char *name, char *why)
-{
-	char buf[2048];
-	sprintf(buf, _("%s was unable to sign on: %s"), name, why);
-	do_error_dialog(buf, _("Signon Error"));
-}
-
 static int snd_tmout;
 int logins_not_muted = 1;
 static void sound_timeout() {
--- a/src/gaim.h	Fri Oct 13 18:55:04 2000 +0000
+++ b/src/gaim.h	Fri Oct 13 19:56:11 2000 +0000
@@ -752,7 +752,6 @@
 extern void away_list_clicked(GtkWidget *, struct away_message *);
 
 /* Functions in aim.c */
-extern void hide_login_progress(char *, char *);
 extern void show_login();
 extern void gaim_setup(struct gaim_connection *gc);
 #ifdef USE_APPLET
--- a/src/multi.c	Fri Oct 13 18:55:04 2000 +0000
+++ b/src/multi.c	Fri Oct 13 19:56:11 2000 +0000
@@ -87,6 +87,8 @@
 	connections = g_slist_remove(connections, gc);
 	g_free(gc);
 	redo_convo_menus();
+	if (!connections && mainwindow)
+		gtk_widget_show(mainwindow);
 }
 
 struct gaim_connection *find_gaim_conn_by_name(char *name) {
@@ -620,6 +622,9 @@
 {
 	struct aim_user *u;
 	int i;
+	if (gc->meter)
+		gtk_widget_destroy(gc->meter);
+	gc->meter = NULL;
 	if (!acctedit) return;
 	u = find_user(gc->username);
 	i = gtk_clist_find_row_from_data(GTK_CLIST(list), u);
@@ -654,3 +659,63 @@
 		u = u->next;
 	}
 }
+
+static void meter_destroy(GtkWidget *meter, struct gaim_connection *gc) {
+	gtk_widget_destroy(meter);
+	gc->meter = NULL;
+}
+
+void set_login_progress(struct gaim_connection *gc, float howfar, char *message) {
+	if (mainwindow)
+		gtk_widget_hide(mainwindow);
+
+	if (!gc->meter) {
+		GtkWidget *box, *label;
+		char buf[256];
+
+		gc->meter = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+		gtk_window_set_policy(GTK_WINDOW(gc->meter), 0, 0, 1);
+		gtk_window_set_wmclass(GTK_WINDOW(gc->meter), "signon", "Gaim");
+		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_FUNC(meter_destroy), gc);
+		gtk_widget_realize(gc->meter);
+		aol_icon(gc->meter->window);
+
+		box = gtk_vbox_new(FALSE, 5);
+		gtk_container_add(GTK_CONTAINER(gc->meter), box);
+		gtk_widget_show(box);
+
+		label = gtk_label_new(buf);
+		gtk_box_pack_start(GTK_BOX(box), label, 0, 0, 5);
+		gtk_widget_show(label);
+
+		gc->progress = gtk_progress_bar_new();
+		gtk_widget_set_usize(gc->progress, 150, 0);
+		gtk_box_pack_start(GTK_BOX(box), gc->progress, 0, 0, 5);
+		gtk_widget_show(gc->progress);
+
+		gc->status = gtk_statusbar_new();
+		gtk_widget_set_usize(gc->status, 150, 0);
+		gtk_box_pack_start(GTK_BOX(box), gc->status, 0, 0, 5);
+		gtk_widget_show(gc->status);
+
+		gtk_widget_show(gc->meter);
+	}
+
+	gtk_progress_bar_update(GTK_PROGRESS_BAR(gc->progress), howfar / 5);
+	gtk_statusbar_pop(GTK_STATUSBAR(gc->status), 1);
+	gtk_statusbar_push(GTK_STATUSBAR(gc->status), 1, message);
+}
+
+void hide_login_progress(struct gaim_connection *gc, char *why)
+{
+	char buf[2048];
+	sprintf(buf, _("%s was unable to sign on: %s"), gc->username, why);
+	do_error_dialog(buf, _("Signon Error"));
+	if (gc->meter)
+		gtk_widget_destroy(gc->meter);
+	gc->meter = NULL;
+}
--- a/src/multi.h	Fri Oct 13 18:55:04 2000 +0000
+++ b/src/multi.h	Fri Oct 13 19:56:11 2000 +0000
@@ -69,6 +69,11 @@
 	time_t login_time;
 	time_t lastsent;
 	int is_idle;
+
+	/* stuff for a signin progress meter */
+	GtkWidget *meter;
+	GtkWidget *progress;
+	GtkWidget *status;
 };
 
 /* now that we have our struct, we're going to need lots of them. Maybe even a list of them. */
@@ -86,4 +91,7 @@
 
 void auto_login();
 
+void set_login_progress(struct gaim_connection *, float, char *);
+void hide_login_progress(struct gaim_connection *, char *);
+
 #endif /* _GAIMMULTI_H_ */
--- a/src/oscar.c	Fri Oct 13 18:55:04 2000 +0000
+++ b/src/oscar.c	Fri Oct 13 19:56:11 2000 +0000
@@ -194,7 +194,7 @@
 	}
 
 	if (condition & GDK_INPUT_EXCEPTION) {
-		hide_login_progress(gc->username, _("Disconnected."));
+		hide_login_progress(gc, _("Disconnected."));
 		signoff(gc);
 		return;
 	}
@@ -220,7 +220,7 @@
 				} else if ((conn->type == AIM_CONN_TYPE_BOS) ||
 					   !(aim_getconn_type(gc->oscar_sess, AIM_CONN_TYPE_BOS))) {
 					debug_print(_("major connection error\n"));
-					hide_login_progress(gc->username, _("Disconnected."));
+					hide_login_progress(gc, _("Disconnected."));
 					signoff(gc);
 				} else if (conn->type == AIM_CONN_TYPE_CHAT) {
 					struct chat_connection *c = find_oscar_chat_by_conn(gc, conn);
@@ -256,12 +256,11 @@
 	struct aim_session_t *sess;
 	struct aim_conn_t *conn;
 	char buf[256];
-	struct gaim_connection *gc;
+	struct gaim_connection *gc = new_gaim_conn(PROTO_OSCAR, user->username, user->password);
 
 	sprintf(debug_buff, _("Logging in %s\n"), user->username);
 	debug_print(debug_buff);
 
-	gc = new_gaim_conn(PROTO_OSCAR, user->username, user->password);
 	sess = g_new0(struct aim_session_t, 1);
 	aim_session_init(sess);
 	/* we need an immediate queue because we don't use a while-loop to
@@ -270,27 +269,32 @@
 	gc->oscar_sess = sess;
 
 	sprintf(buf, _("Looking up %s"), 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, FAIM_LOGIN_SERVER);
 
 	if (conn == NULL) {
 		debug_print(_("internal connection error\n"));
-		hide_login_progress(gc->username, _("Unable to login to AIM"));
+		hide_login_progress(gc, _("Unable to login to AIM"));
 		destroy_gaim_conn(gc);
 		return;
 	} else if (conn->fd == -1) {
 		if (conn->status & AIM_CONN_STATUS_RESOLVERR) {
 			sprintf(debug_buff, _("couldn't resolve host"));
 			debug_print(debug_buff); debug_print("\n");
-			hide_login_progress(gc->username, debug_buff);
+			hide_login_progress(gc, debug_buff);
 		} else if (conn->status & AIM_CONN_STATUS_CONNERR) {
 			sprintf(debug_buff, _("couldn't connect to host"));
 			debug_print(debug_buff); debug_print("\n");
-			hide_login_progress(gc->username, debug_buff);
+			hide_login_progress(gc, debug_buff);
 		}
 		destroy_gaim_conn(gc);
 		return;
 	}
 	g_snprintf(buf, sizeof(buf), _("Signon: %s"), gc->username);
+	set_login_progress(gc, 2, buf);
 
 	aim_conn_addhandler(sess, conn, 0x0017, 0x0007, gaim_parse_login, 0);
 	aim_conn_addhandler(sess, conn, 0x0017, 0x0003, gaim_parse_auth_resp, 0);
@@ -359,7 +363,7 @@
 		set_user_state(offline);
 #endif
 		gdk_input_remove(gc->inpa);
-		hide_login_progress(gc->username, _("Authentication Failed"));
+		hide_login_progress(gc, _("Authentication Failed"));
 		signoff(gc);
 		return 0;
 	}
@@ -381,14 +385,14 @@
 #ifdef USE_APPLET
 		set_user_state(offline);
 #endif
-		hide_login_progress(gc->username, _("Internal Error"));
+		hide_login_progress(gc, _("Internal Error"));
 		destroy_gaim_conn(gc);
 		return -1;
 	} else if (bosconn->status != 0) {
 #ifdef USE_APPLET
 		set_user_state(offline);
 #endif
-		hide_login_progress(gc->username, _("Could Not Connect"));
+		hide_login_progress(gc, _("Could Not Connect"));
 		destroy_gaim_conn(gc);
 		return -1;
 	}
@@ -419,6 +423,7 @@
 	gc->oscar_conn = bosconn;
 	gc->inpa = gdk_input_add(bosconn->fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
 			oscar_callback, bosconn);
+	set_login_progress(gc, 4, _("Connection established, cookie sent"));
 	return 1;
 }
 
--- a/src/toc.c	Fri Oct 13 18:55:04 2000 +0000
+++ b/src/toc.c	Fri Oct 13 19:56:11 2000 +0000
@@ -40,7 +40,7 @@
 #include "gaim.h"
 #include "gnome_applet_mgr.h"
 
-#define REVISION "gaim:$Revision: 991 $"
+#define REVISION "gaim:$Revision: 998 $"
 
 
 static unsigned int peer_ver=0;
@@ -63,28 +63,35 @@
 	char buf[80];
 	char buf2[2048];
 
+	gc = new_gaim_conn(PROTO_TOC, user->username, user->password);
+	
 	g_snprintf(buf, sizeof(buf), "Looking up %s", aim_host);	
+	set_login_progress(gc, 1, buf);
+	while (gtk_events_pending())
+		gtk_main_iteration();
 
 	sin = (struct in_addr *)get_address(aim_host);
 	if (!sin) {
 		g_snprintf(buf, sizeof(buf), "Unable to lookup %s", aim_host);
-		hide_login_progress(user->username, buf);
+		hide_login_progress(gc, buf);
+		destroy_gaim_conn(gc);
 		return;
 	}
 	
 	g_snprintf(toc_addy, sizeof(toc_addy), "%s", inet_ntoa(*sin));
 	g_snprintf(buf, sizeof(buf), "Connecting to %s", inet_ntoa(*sin));
+	set_login_progress(gc, 2, buf);
+	while (gtk_events_pending())
+		gtk_main_iteration();
 	
 
 
-	gc = new_gaim_conn(PROTO_TOC, user->username, user->password);
-	
 	gc->toc_fd = connect_address(sin->s_addr, aim_port);
 
         if (gc->toc_fd < 0) {
 		g_snprintf(buf, sizeof(buf), "Connect to %s failed",
 			 inet_ntoa(*sin));
-		hide_login_progress(gc->username, buf);
+		hide_login_progress(gc, buf);
 		destroy_gaim_conn(gc);
 		return;
         }
@@ -92,16 +99,22 @@
         g_free(sin);
 	
 	g_snprintf(buf, sizeof(buf), "Signon: %s", gc->username);
+	set_login_progress(gc, 3, buf);
+	while (gtk_events_pending())
+		gtk_main_iteration();
 	
 	if (toc_signon(gc) < 0) {
-		hide_login_progress(gc->username, "Disconnected.");
+		hide_login_progress(gc, "Disconnected.");
 		destroy_gaim_conn(gc);
 		return;
 	}
 
 	g_snprintf(buf, sizeof(buf), "Waiting for reply...");
+	set_login_progress(gc, 4, buf);
+	while (gtk_events_pending())
+		gtk_main_iteration();
 	if (toc_wait_signon(gc) < 0) {
-		hide_login_progress(gc->username, "Authentication Failed");
+		hide_login_progress(gc, "Authentication Failed");
 		destroy_gaim_conn(gc);
 		return;
 	}
@@ -111,6 +124,10 @@
 	save_prefs();
 
 	g_snprintf(buf, sizeof(buf), "Retrieving config...");
+	set_login_progress(gc, 5, buf);
+	while (gtk_events_pending())
+		gtk_main_iteration();
+
 	config = toc_wait_config(gc);
 	gc->state = STATE_ONLINE;
 
@@ -342,7 +359,7 @@
 
         buf = g_malloc(2 * BUF_LONG);
         if (wait_reply(gc, buf, 2 * BUF_LONG) < 0) {
-                hide_login_progress(gc->username, "Connection Closed");
+                hide_login_progress(gc, "Connection Closed");
                 signoff(gc); /* this will free gc for us */
                 g_free(buf);
 		return;