annotate plugins/autorecon.c @ 5713:def92be89b97

[gaim-migrate @ 6134] 0.64 is already out. let's change 0.65 ;-) committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Tue, 03 Jun 2003 15:22:39 +0000
parents eeba9205dd0f
children 059d95c67cda
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
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 #include "gaim.h"
1404
96e93119268d [gaim-migrate @ 1414]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1378
diff changeset
4 #include "prpl.h"
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
5
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
6 #ifdef _WIN32
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
7 #include "win32dep.h"
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
8 #endif
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
9
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
10 #define AUTORECON_PLUGIN_ID "core-autorecon"
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
11
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
12 #define INITIAL 8000
4590
3b8e6c2b4a50 [gaim-migrate @ 4874]
Luke Schierer <lschiere@pidgin.im>
parents: 4585
diff changeset
13 #define MAXTIME 2048000
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
14
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
15 static GHashTable *hash = NULL;
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 guint tim = 0;
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
19 static gboolean do_signon(gpointer data) {
5587
1c55b1540e18 [gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents: 5227
diff changeset
20 GaimAccount *account = data;
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
21 gaim_debug(GAIM_DEBUG_INFO, "autorecon", "do_signon called\n");
4494
b5a50a6a13b0 [gaim-migrate @ 4769]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4491
diff changeset
22
5607
eeba9205dd0f [gaim-migrate @ 6011]
Nathan Walp <nwalp@pidgin.im>
parents: 5587
diff changeset
23 if (g_list_index(gaim_accounts_get_all(), account) < 0)
1817
b367beee6448 [gaim-migrate @ 1827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1404
diff changeset
24 return FALSE;
5587
1c55b1540e18 [gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents: 5227
diff changeset
25 gaim_debug(GAIM_DEBUG_INFO, "autorecon", "calling gaim_account_connect\n");
1c55b1540e18 [gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents: 5227
diff changeset
26 gaim_account_connect(account);
1c55b1540e18 [gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents: 5227
diff changeset
27 gaim_debug(GAIM_DEBUG_INFO, "autorecon", "done calling gaim_account_connect\n");
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
28 tim = 0;
1817
b367beee6448 [gaim-migrate @ 1827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1404
diff changeset
29 return FALSE;
1378
aedeb1218a0a [gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1165
diff changeset
30 }
aedeb1218a0a [gaim-migrate @ 1388]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1165
diff changeset
31
5587
1c55b1540e18 [gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents: 5227
diff changeset
32 static void reconnect(GaimConnection *gc, void *m) {
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
33 if (!gc->wants_to_die) {
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
34 int del;
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4202
diff changeset
35 del = (int)g_hash_table_lookup(hash, gc->account);
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
36 if (!del)
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
37 del = INITIAL;
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
38 else
4590
3b8e6c2b4a50 [gaim-migrate @ 4874]
Luke Schierer <lschiere@pidgin.im>
parents: 4585
diff changeset
39 del = MIN(2 * del, MAXTIME);
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4202
diff changeset
40 tim = g_timeout_add(del, do_signon, gc->account);
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4202
diff changeset
41 g_hash_table_insert(hash, gc->account, (gpointer)del);
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
42 } else {
4491
3196d9044a45 [gaim-migrate @ 4766]
Nathan Walp <nwalp@pidgin.im>
parents: 4202
diff changeset
43 g_hash_table_remove(hash, gc->account);
2216
66783ad29e55 [gaim-migrate @ 2226]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1818
diff changeset
44 }
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 }
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
47 static gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
48 plugin_load(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
49 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
50 hash = g_hash_table_new(g_int_hash, g_int_equal);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
51
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
52 gaim_signal_connect(plugin, event_signoff, reconnect, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
53
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
54 return TRUE;
3802
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
55 }
9bcb42faccc0 [gaim-migrate @ 3945]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
56
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
57 static gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
58 plugin_unload(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
59 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
60 if (tim)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
61 g_source_remove(tim);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
62
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
63 gaim_signal_disconnect(plugin, event_signoff, reconnect);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
64
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
65 g_hash_table_destroy(hash);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
66
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
67 hash = NULL;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
68 tim = 0;
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
69
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
70 return TRUE;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
71 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
72
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
73 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
74 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
75 2, /**< api_version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
76 GAIM_PLUGIN_STANDARD, /**< type */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
77 NULL, /**< ui_requirement */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
78 0, /**< flags */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
79 NULL, /**< dependencies */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
80 GAIM_PRIORITY_DEFAULT, /**< priority */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
81
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
82 AUTORECON_PLUGIN_ID, /**< id */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
83 N_("Auto-Reconnect"), /**< name */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
84 VERSION, /**< version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
85 /** summary */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
86 N_("When you are kicked offline, this reconnects you."),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
87 /** description */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
88 N_("When you are kicked offline, this reconnects you."),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
89 "Eric Warmenhoven <eric@warmenhoven.org>", /**< author */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
90 WEBSITE, /**< homepage */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
91
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
92 plugin_load, /**< load */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
93 plugin_unload, /**< unload */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
94 NULL, /**< destroy */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
95
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
96 NULL, /**< ui_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
97 NULL /**< extra_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
98 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
99
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
100 static void
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
101 __init_plugin(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
102 {
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
103 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 2398
diff changeset
104
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 4590
diff changeset
105 GAIM_INIT_PLUGIN(autorecon, __init_plugin, info);