annotate plugins/autorecon.c @ 4959:6ae40a9c5514

[gaim-migrate @ 5293] Thanks, Lumiere committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Wed, 02 Apr 2003 05:50:04 +0000
parents 3b8e6c2b4a50
children fefad67de2c7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
10 #ifdef _WIN32
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
11 #include "win32dep.h"
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
12 #endif
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
13
4494
b5a50a6a13b0 [gaim-migrate @ 4769]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4491
diff changeset
14 G_MODULE_IMPORT GSList *gaim_accounts;
b5a50a6a13b0 [gaim-migrate @ 4769]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4491
diff changeset
15
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
16 #define INITIAL 8000
4590
3b8e6c2b4a50 [gaim-migrate @ 4874]
Luke Schierer <lschiere@pidgin.im>
parents: 4585
diff changeset
17 #define MAXTIME 2048000
2216
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 GHashTable *hash = NULL;
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
20
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
21 static guint tim = 0;
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
23 static gboolean do_signon(gpointer data) {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4202
diff changeset
24 struct gaim_account *account = data;
4494
b5a50a6a13b0 [gaim-migrate @ 4769]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4491
diff changeset
25 debug_printf("do_signon called\n");
b5a50a6a13b0 [gaim-migrate @ 4769]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4491
diff changeset
26
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4202
diff changeset
27 if (g_slist_index(gaim_accounts, account) < 0)
1817
b367beee6448 [gaim-migrate @ 1827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1404
diff changeset
28 return FALSE;
4494
b5a50a6a13b0 [gaim-migrate @ 4769]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4491
diff changeset
29 debug_printf("calling serv_login\n");
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4202
diff changeset
30 serv_login(account);
4494
b5a50a6a13b0 [gaim-migrate @ 4769]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4491
diff changeset
31 debug_printf("done calling serv_login\n");
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
32 tim = 0;
1817
b367beee6448 [gaim-migrate @ 1827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1404
diff changeset
33 return FALSE;
1378
aedeb1218a0a [gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1165
diff changeset
34 }
aedeb1218a0a [gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1165
diff changeset
35
aedeb1218a0a [gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1165
diff changeset
36 static void reconnect(struct gaim_connection *gc, void *m) {
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
37 if (!gc->wants_to_die) {
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
38 int del;
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4202
diff changeset
39 del = (int)g_hash_table_lookup(hash, gc->account);
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
40 if (!del)
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
41 del = INITIAL;
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
42 else
4590
3b8e6c2b4a50 [gaim-migrate @ 4874]
Luke Schierer <lschiere@pidgin.im>
parents: 4585
diff changeset
43 del = MIN(2 * del, MAXTIME);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4202
diff changeset
44 tim = g_timeout_add(del, do_signon, gc->account);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4202
diff changeset
45 g_hash_table_insert(hash, gc->account, (gpointer)del);
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
46 } else {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4202
diff changeset
47 g_hash_table_remove(hash, gc->account);
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
48 }
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 }
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
51 /*
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
52 * EXPORTED FUNCTIONS
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
53 */
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
54
3802
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
55 struct gaim_plugin_description desc;
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
56 G_MODULE_EXPORT struct gaim_plugin_description *gaim_plugin_desc() {
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
57 desc.api_version = PLUGIN_API_VERSION;
4585
2427d847e39c [gaim-migrate @ 4869]
Luke Schierer <lschiere@pidgin.im>
parents: 4494
diff changeset
58 desc.name = g_strdup(_("Autoreconnect"));
3802
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
59 desc.version = g_strdup(VERSION);
4113
74d27aa5b686 [gaim-migrate @ 4329]
Luke Schierer <lschiere@pidgin.im>
parents: 3802
diff changeset
60 desc.description = g_strdup(_("When you are kicked offline, this reconnects you."));
3802
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
61 desc.authors = g_strdup("Eric Warmenhoven &lt;eric@warmenhoven.org>");
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
62 desc.url = g_strdup(WEBSITE);
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
63 return &desc;
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
64 }
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
65
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
66 G_MODULE_EXPORT char *name() {
4113
74d27aa5b686 [gaim-migrate @ 4329]
Luke Schierer <lschiere@pidgin.im>
parents: 3802
diff changeset
67 return _("Auto Reconnect");
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
68 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
69
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
70 G_MODULE_EXPORT char *description() {
4113
74d27aa5b686 [gaim-migrate @ 4329]
Luke Schierer <lschiere@pidgin.im>
parents: 3802
diff changeset
71 return _("When you are kicked offline, this reconnects you.");
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
72 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
73
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
74 G_MODULE_EXPORT char *gaim_plugin_init(GModule *handle) {
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
75 hash = g_hash_table_new(g_int_hash, g_int_equal);
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
76
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 gaim_signal_connect(handle, event_signoff, reconnect, NULL);
1047
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1030
diff changeset
78
ece2d1543b20 [gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1030
diff changeset
79 return NULL;
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 }
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
81
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
82 G_MODULE_EXPORT void gaim_plugin_remove() {
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
83 if (tim)
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
84 g_source_remove(tim);
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
85 g_hash_table_destroy(hash);
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
86 hash = NULL;
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
87 tim = 0;
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
88 }