changeset 1817:b367beee6448

[gaim-migrate @ 1827] reworked autorecon.c. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sun, 06 May 2001 10:08:40 +0000
parents aa2bb1bfbd4b
children 84782d1cb051
files plugins/autorecon.c src/buddy.c src/dialogs.c src/gaim.h src/multi.c src/multi.h
diffstat 6 files changed, 30 insertions(+), 61 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/autorecon.c	Sun May 06 09:43:20 2001 +0000
+++ b/plugins/autorecon.c	Sun May 06 10:08:40 2001 +0000
@@ -3,78 +3,28 @@
 #include "prpl.h"
 #include <gtk/gtk.h>
 
-extern GtkWidget *imaway;
-
-static int away_state;
-static int forced_off = 0;
-static char *last_away = NULL;
-GSList *reconnects = NULL;
-GSList *recontim = NULL;
-
 char *name() {
 	return "Auto Reconnect";
 }
 
 char *description() {
-	return "When AOL kicks you off, this auto-reconnects you.";
+	return "When you are kicked offline, this reconnects you.";
 }
 
-static void now_online(struct gaim_connection *gc, void *m) {
-	gint place;
-	guint recon;
-	if (!g_slist_find(reconnects, gc->user))
-		return;
-	place = g_slist_index(reconnects, gc->user);
-	recon = (guint)g_slist_nth(recontim, place);
-	reconnects = g_slist_remove(reconnects, gc->user);
-	recontim = g_slist_remove(recontim, (void *)recon);
-	if (away_state) serv_set_away(gc, GAIM_AWAY_CUSTOM, last_away);
-}
-
-static void do_signon(struct aim_user *u) {
-	gint place;
-	guint recon;
-	place = g_slist_index(reconnects, u);
-	recon = (guint)g_slist_nth(recontim, place);
-	gtk_timeout_remove(recon);
-	forced_off = 0;
+static gboolean do_signon(struct aim_user *u) {
+	if (!g_list_index(aim_users, u))
+		return FALSE;
 	serv_login(u);
+	return FALSE;
 }
 
 static void reconnect(struct gaim_connection *gc, void *m) {
-	guint recon;
-	if (g_slist_find(reconnects, gc->user))
-		return;
-	recon = gtk_timeout_add(8000, (GtkFunction)do_signon, gc->user);
-	reconnects = g_slist_append(reconnects, gc->user);
-	recontim = g_slist_append(recontim, (void *)recon);
-	forced_off = 1;
-}
-
-static void away_toggle(struct gaim_connection *gc, char *state, char *message, gpointer data) {
-	if (gc->away) {
-		if (last_away)
-			g_free(last_away);
-		last_away = g_strdup(gc->away);
-		away_state = 1;
-	} else if (!forced_off)
-		away_state = 0;
+	if (gc->wants_to_die)
+		gtk_timeout_add(8000, (GtkFunction)do_signon, gc->user);
 }
 
 char *gaim_plugin_init(GModule *handle) {
-	if (awaymessage) {
-		away_state = 1;
-		last_away = g_strdup(awaymessage->message);
-	} else
-		away_state = 0;
-
-	gaim_signal_connect(handle, event_away, away_toggle, NULL);
 	gaim_signal_connect(handle, event_signoff, reconnect, NULL);
-	gaim_signal_connect(handle, event_signon, now_online, NULL);
 
 	return NULL;
 }
-
-void gaim_plugin_remove() {
-	g_free(last_away);
-}
--- a/src/buddy.c	Sun May 06 09:43:20 2001 +0000
+++ b/src/buddy.c	Sun May 06 10:08:40 2001 +0000
@@ -470,6 +470,7 @@
 
 	while (c) {
 		g = (struct gaim_connection *)c->data;
+		g->wants_to_die = TRUE;
 		signoff(g);
 		c = connections;
 	}
--- a/src/dialogs.c	Sun May 06 09:43:20 2001 +0000
+++ b/src/dialogs.c	Sun May 06 10:08:40 2001 +0000
@@ -420,7 +420,7 @@
 /*  The dialog for getting an error                                       */
 /*------------------------------------------------------------------------*/
 
-void
+GtkWidget*
 do_error_dialog(char *message, char *title)
 {
         GtkWidget *d;
@@ -451,6 +451,7 @@
 	aol_icon(d->window);
 
 	gtk_widget_show(d);
+	return d;
 }
 
 
--- a/src/gaim.h	Sun May 06 09:43:20 2001 +0000
+++ b/src/gaim.h	Sun May 06 10:08:40 2001 +0000
@@ -139,6 +139,9 @@
 	/* stuff for password prompt */
 	GtkWidget *passprmt;
 	GtkWidget *passentry;
+
+	/* when you get kicked offline, only show one dialog */
+	GtkWidget *kick_dlg;
 };
 
 struct save_pos {
@@ -815,7 +818,7 @@
 extern void alias_dialog_bud(struct buddy *);
 extern void do_export(struct gaim_connection *);
 extern void show_warn_dialog(struct gaim_connection *, char *);
-extern void do_error_dialog(char *, char *);
+extern GtkWidget *do_error_dialog(char *, char *);
 extern void show_error_dialog(char *);
 extern void show_im_dialog();
 extern void some_name(char *);
--- a/src/multi.c	Sun May 06 09:43:20 2001 +0000
+++ b/src/multi.c	Sun May 06 10:08:40 2001 +0000
@@ -613,6 +613,7 @@
 				serv_login(u);
 			}
 		} else {
+			u->gc->wants_to_die = TRUE;
 			signoff(u->gc);
 		}
 	}
@@ -627,8 +628,10 @@
 	if (row != -1) {
 		u = g_list_nth_data(aim_users, row);
 		if (u) {
-			if (u->gc)
+			if (u->gc) {
+				u->gc->wants_to_die = TRUE;
 				signoff(u->gc);
+			}
 			aim_users = g_list_remove(aim_users, u);
 			save_prefs();
 		}
@@ -784,6 +787,7 @@
 
 static void cancel_signon(GtkWidget *button, struct gaim_connection *gc)
 {
+	gc->wants_to_die = TRUE;
 	signoff(gc);
 }
 
@@ -843,11 +847,20 @@
 	gtk_statusbar_push(GTK_STATUSBAR(gc->status), 1, message);
 }
 
+static void set_kick_null(GtkObject *obj, struct aim_user *u)
+{
+	u->kick_dlg = NULL;
+}
+
 void hide_login_progress(struct gaim_connection *gc, char *why)
 {
 	char buf[2048];
 	sprintf(buf, _("%s\n%s was unable to sign on: %s"), full_date(), gc->username, why);
-	do_error_dialog(buf, _("Signon Error"));
+	if (gc->user->kick_dlg)
+		gtk_widget_destroy(gc->user->kick_dlg);
+	gc->user->kick_dlg = do_error_dialog(buf, _("Signon Error"));
+	gtk_signal_connect(GTK_OBJECT(gc->user->kick_dlg), "destroy",
+			   GTK_SIGNAL_FUNC(set_kick_null), gc->user);
 	if (gc->meter)
 		gtk_widget_destroy(gc->meter);
 	gc->meter = NULL;
--- a/src/multi.h	Sun May 06 09:43:20 2001 +0000
+++ b/src/multi.h	Sun May 06 10:08:40 2001 +0000
@@ -72,6 +72,7 @@
 	int is_auto_away;
 
 	int evil;
+	gboolean wants_to_die; /* defaults to FALSE */
 };
 
 /* now that we have our struct, we're going to need lots of them. Maybe even a list of them. */