changeset 2216:66783ad29e55

[gaim-migrate @ 2226] i haven't even loaded this. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 06 Sep 2001 00:21:28 +0000
parents cda7147ccece
children f7f5a23b6f76
files plugins/autorecon.c
diffstat 1 files changed, 32 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/autorecon.c	Wed Sep 05 21:37:00 2001 +0000
+++ b/plugins/autorecon.c	Thu Sep 06 00:21:28 2001 +0000
@@ -1,7 +1,13 @@
 #define GAIM_PLUGINS
 #include "gaim.h"
 #include "prpl.h"
-#include <gtk/gtk.h>
+
+#define INITIAL 8000
+#define MAXTIME 1024000
+
+static GHashTable *hash = NULL;
+
+static guint tim = 0;
 
 char *name() {
 	return "Auto Reconnect";
@@ -11,20 +17,42 @@
 	return "When you are kicked offline, this reconnects you.";
 }
 
-static gboolean do_signon(struct aim_user *u) {
+static gboolean do_signon(gpointer data) {
+	struct aim_user *u = data;
 	if (g_list_index(aim_users, u) < 0)
 		return FALSE;
 	serv_login(u);
+	tim = 0;
 	return FALSE;
 }
 
 static void reconnect(struct gaim_connection *gc, void *m) {
-	if (!gc->wants_to_die)
-		gtk_timeout_add(8000, (GtkFunction)do_signon, gc->user);
+	if (!gc->wants_to_die) {
+		int del;
+		del = (int)g_hash_table_lookup(hash, gc->user);
+		if (!del)
+			del = INITIAL;
+		else
+			del = 2 * del;
+		tim = g_timeout_add(del, do_signon, gc->user);
+		g_hash_table_insert(hash, gc->user, (gpointer)del);
+	} else {
+		g_hash_table_remove(hash, gc->user);
+	}
 }
 
 char *gaim_plugin_init(GModule *handle) {
+	hash = g_hash_table_new(g_int_hash, g_int_equal);
+
 	gaim_signal_connect(handle, event_signoff, reconnect, NULL);
 
 	return NULL;
 }
+
+void gaim_plugin_remove() {
+	if (tim)
+		g_source_remove(tim);
+	g_hash_table_destroy(hash);
+	hash = NULL;
+	tim = 0;
+}