Mercurial > pidgin.yaz
comparison plugins/autorecon.c @ 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 | 84782d1cb051 |
children | f7f5a23b6f76 |
comparison
equal
deleted
inserted
replaced
2215:cda7147ccece | 2216:66783ad29e55 |
---|---|
1 #define GAIM_PLUGINS | 1 #define GAIM_PLUGINS |
2 #include "gaim.h" | 2 #include "gaim.h" |
3 #include "prpl.h" | 3 #include "prpl.h" |
4 #include <gtk/gtk.h> | 4 |
5 #define INITIAL 8000 | |
6 #define MAXTIME 1024000 | |
7 | |
8 static GHashTable *hash = NULL; | |
9 | |
10 static guint tim = 0; | |
5 | 11 |
6 char *name() { | 12 char *name() { |
7 return "Auto Reconnect"; | 13 return "Auto Reconnect"; |
8 } | 14 } |
9 | 15 |
10 char *description() { | 16 char *description() { |
11 return "When you are kicked offline, this reconnects you."; | 17 return "When you are kicked offline, this reconnects you."; |
12 } | 18 } |
13 | 19 |
14 static gboolean do_signon(struct aim_user *u) { | 20 static gboolean do_signon(gpointer data) { |
21 struct aim_user *u = data; | |
15 if (g_list_index(aim_users, u) < 0) | 22 if (g_list_index(aim_users, u) < 0) |
16 return FALSE; | 23 return FALSE; |
17 serv_login(u); | 24 serv_login(u); |
25 tim = 0; | |
18 return FALSE; | 26 return FALSE; |
19 } | 27 } |
20 | 28 |
21 static void reconnect(struct gaim_connection *gc, void *m) { | 29 static void reconnect(struct gaim_connection *gc, void *m) { |
22 if (!gc->wants_to_die) | 30 if (!gc->wants_to_die) { |
23 gtk_timeout_add(8000, (GtkFunction)do_signon, gc->user); | 31 int del; |
32 del = (int)g_hash_table_lookup(hash, gc->user); | |
33 if (!del) | |
34 del = INITIAL; | |
35 else | |
36 del = 2 * del; | |
37 tim = g_timeout_add(del, do_signon, gc->user); | |
38 g_hash_table_insert(hash, gc->user, (gpointer)del); | |
39 } else { | |
40 g_hash_table_remove(hash, gc->user); | |
41 } | |
24 } | 42 } |
25 | 43 |
26 char *gaim_plugin_init(GModule *handle) { | 44 char *gaim_plugin_init(GModule *handle) { |
45 hash = g_hash_table_new(g_int_hash, g_int_equal); | |
46 | |
27 gaim_signal_connect(handle, event_signoff, reconnect, NULL); | 47 gaim_signal_connect(handle, event_signoff, reconnect, NULL); |
28 | 48 |
29 return NULL; | 49 return NULL; |
30 } | 50 } |
51 | |
52 void gaim_plugin_remove() { | |
53 if (tim) | |
54 g_source_remove(tim); | |
55 g_hash_table_destroy(hash); | |
56 hash = NULL; | |
57 tim = 0; | |
58 } |