Mercurial > pidgin.yaz
annotate plugins/autorecon.c @ 4399:ce8d35b435de
[gaim-migrate @ 4668]
Fixes the problem where doing a gesture and then clicking the right mouse
button causes it to stay in gesture mode forever. It's hacky, though..
hope it doesn't cause other issues.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Thu, 23 Jan 2003 00:19:57 +0000 |
parents | 59751fe608c5 |
children | 3196d9044a45 |
rev | line source |
---|---|
4202
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4113
diff
changeset
|
1 #include "config.h" |
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4113
diff
changeset
|
2 |
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4113
diff
changeset
|
3 #ifndef GAIM_PLUGINS |
99 | 4 #define GAIM_PLUGINS |
4202
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4113
diff
changeset
|
5 #endif |
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4113
diff
changeset
|
6 |
99 | 7 #include "gaim.h" |
1404
96e93119268d
[gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1378
diff
changeset
|
8 #include "prpl.h" |
2216
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
9 |
3630 | 10 #ifdef _WIN32 |
11 #include "win32dep.h" | |
12 #endif | |
13 | |
2216
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
14 #define INITIAL 8000 |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
15 #define MAXTIME 1024000 |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
16 |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
17 static GHashTable *hash = NULL; |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
18 |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
19 static guint tim = 0; |
99 | 20 |
2216
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
21 static gboolean do_signon(gpointer data) { |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
22 struct aim_user *u = data; |
2398
837f8ff999be
[gaim-migrate @ 2411]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2217
diff
changeset
|
23 if (g_slist_index(aim_users, u) < 0) |
1817
b367beee6448
[gaim-migrate @ 1827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
24 return FALSE; |
1378
aedeb1218a0a
[gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1165
diff
changeset
|
25 serv_login(u); |
2216
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
26 tim = 0; |
1817
b367beee6448
[gaim-migrate @ 1827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1404
diff
changeset
|
27 return FALSE; |
1378
aedeb1218a0a
[gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1165
diff
changeset
|
28 } |
aedeb1218a0a
[gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1165
diff
changeset
|
29 |
aedeb1218a0a
[gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1165
diff
changeset
|
30 static void reconnect(struct gaim_connection *gc, void *m) { |
2216
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
31 if (!gc->wants_to_die) { |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
32 int del; |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
33 del = (int)g_hash_table_lookup(hash, gc->user); |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
34 if (!del) |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
35 del = INITIAL; |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
36 else |
2217
f7f5a23b6f76
[gaim-migrate @ 2227]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2216
diff
changeset
|
37 del = MAX(2 * del, MAXTIME); |
2216
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
38 tim = g_timeout_add(del, do_signon, gc->user); |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
39 g_hash_table_insert(hash, gc->user, (gpointer)del); |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
40 } else { |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
41 g_hash_table_remove(hash, gc->user); |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
42 } |
99 | 43 } |
44 | |
3630 | 45 /* |
46 * EXPORTED FUNCTIONS | |
47 */ | |
48 | |
3802 | 49 struct gaim_plugin_description desc; |
50 G_MODULE_EXPORT struct gaim_plugin_description *gaim_plugin_desc() { | |
51 desc.api_version = PLUGIN_API_VERSION; | |
52 desc.name = g_strdup("Autoreconnect"); | |
53 desc.version = g_strdup(VERSION); | |
4113 | 54 desc.description = g_strdup(_("When you are kicked offline, this reconnects you.")); |
3802 | 55 desc.authors = g_strdup("Eric Warmenhoven <eric@warmenhoven.org>"); |
56 desc.url = g_strdup(WEBSITE); | |
57 return &desc; | |
58 } | |
59 | |
3630 | 60 G_MODULE_EXPORT char *name() { |
4113 | 61 return _("Auto Reconnect"); |
3630 | 62 } |
63 | |
64 G_MODULE_EXPORT char *description() { | |
4113 | 65 return _("When you are kicked offline, this reconnects you."); |
3630 | 66 } |
67 | |
68 G_MODULE_EXPORT char *gaim_plugin_init(GModule *handle) { | |
2216
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
69 hash = g_hash_table_new(g_int_hash, g_int_equal); |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
70 |
99 | 71 gaim_signal_connect(handle, event_signoff, reconnect, NULL); |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
72 |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
73 return NULL; |
99 | 74 } |
2216
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
75 |
3630 | 76 G_MODULE_EXPORT void gaim_plugin_remove() { |
2216
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
77 if (tim) |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
78 g_source_remove(tim); |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
79 g_hash_table_destroy(hash); |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
80 hash = NULL; |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
81 tim = 0; |
66783ad29e55
[gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1818
diff
changeset
|
82 } |