# HG changeset patch # User Eric Warmenhoven # Date 999735688 0 # Node ID 66783ad29e55627947d4a19f5a5b2890c9d52941 # Parent cda7147ccecec7ca621dd2fb168ae4bf0e6e37ef [gaim-migrate @ 2226] i haven't even loaded this. committer: Tailor Script diff -r cda7147ccece -r 66783ad29e55 plugins/autorecon.c --- 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 + +#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; +}