annotate plugins/autorecon.c @ 3984:e0f868943dee

[gaim-migrate @ 4175] Flashing window feature now implemented for all Win versions committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Tue, 19 Nov 2002 17:38:11 +0000
parents 9bcb42faccc0
children 74d27aa5b686
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 #define GAIM_PLUGINS
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 #include "gaim.h"
1404
96e93119268d [gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1378
diff changeset
3 #include "prpl.h"
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
4
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
5 #ifdef _WIN32
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
6 #include "win32dep.h"
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
7 #endif
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
8
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
9 #define INITIAL 8000
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
10 #define MAXTIME 1024000
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
11
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
12 static GHashTable *hash = NULL;
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
13
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
14 static guint tim = 0;
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
16 static gboolean do_signon(gpointer data) {
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
17 struct aim_user *u = data;
2398
837f8ff999be [gaim-migrate @ 2411]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2217
diff changeset
18 if (g_slist_index(aim_users, u) < 0)
1817
b367beee6448 [gaim-migrate @ 1827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1404
diff changeset
19 return FALSE;
1378
aedeb1218a0a [gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1165
diff changeset
20 serv_login(u);
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
21 tim = 0;
1817
b367beee6448 [gaim-migrate @ 1827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1404
diff changeset
22 return FALSE;
1378
aedeb1218a0a [gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1165
diff changeset
23 }
aedeb1218a0a [gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1165
diff changeset
24
aedeb1218a0a [gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1165
diff changeset
25 static void reconnect(struct gaim_connection *gc, void *m) {
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
26 if (!gc->wants_to_die) {
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
27 int del;
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
28 del = (int)g_hash_table_lookup(hash, gc->user);
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
29 if (!del)
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
30 del = INITIAL;
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
31 else
2217
f7f5a23b6f76 [gaim-migrate @ 2227]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2216
diff changeset
32 del = MAX(2 * del, MAXTIME);
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
33 tim = g_timeout_add(del, do_signon, gc->user);
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
34 g_hash_table_insert(hash, gc->user, (gpointer)del);
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
35 } else {
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
36 g_hash_table_remove(hash, gc->user);
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
37 }
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 }
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
40 /*
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
41 * EXPORTED FUNCTIONS
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
42 */
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
43
3802
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
44 struct gaim_plugin_description desc;
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
45 G_MODULE_EXPORT struct gaim_plugin_description *gaim_plugin_desc() {
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
46 desc.api_version = PLUGIN_API_VERSION;
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
47 desc.name = g_strdup("Autoreconnect");
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
48 desc.version = g_strdup(VERSION);
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
49 desc.description = g_strdup("When you are kicked offline, this reconnects you.");
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
50 desc.authors = g_strdup("Eric Warmenhoven &lt;eric@warmenhoven.org>");
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
51 desc.url = g_strdup(WEBSITE);
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
52 return &desc;
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
53 }
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
54
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
55 G_MODULE_EXPORT char *name() {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
56 return "Auto Reconnect";
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
57 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
58
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
59 G_MODULE_EXPORT char *description() {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
60 return "When you are kicked offline, this reconnects you.";
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
61 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
62
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
63 G_MODULE_EXPORT char *gaim_plugin_init(GModule *handle) {
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
64 hash = g_hash_table_new(g_int_hash, g_int_equal);
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
65
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 gaim_signal_connect(handle, event_signoff, reconnect, NULL);
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1030
diff changeset
67
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1030
diff changeset
68 return NULL;
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 }
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
70
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
71 G_MODULE_EXPORT void gaim_plugin_remove() {
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
72 if (tim)
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
73 g_source_remove(tim);
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
74 g_hash_table_destroy(hash);
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
75 hash = NULL;
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
76 tim = 0;
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
77 }