Mercurial > pidgin
annotate plugins/autorecon.c @ 1342:84aef77f0add
[gaim-migrate @ 1352]
Umm, I forgot this :-).
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Thu, 21 Dec 2000 02:11:56 +0000 |
parents | 3daec853f3c6 |
children | aedeb1218a0a |
rev | line source |
---|---|
99 | 1 #define GAIM_PLUGINS |
2 #include "gaim.h" | |
3 #include <gtk/gtk.h> | |
4 | |
151
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
5 extern GtkWidget *imaway; |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
6 |
99 | 7 static int recon; |
151
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
8 static int away_state; |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
9 static int forced_off = 0; |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
10 static struct away_message *last_away; |
99 | 11 |
12 char *name() { | |
13 return "Auto Reconnect"; | |
14 } | |
15 | |
16 char *description() { | |
17 return "When AOL kicks you off, this auto-reconnects you."; | |
18 } | |
19 | |
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
631
diff
changeset
|
20 void do_signon(char *name) { |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1000
diff
changeset
|
21 struct aim_user *u = find_user(name, -1); |
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
631
diff
changeset
|
22 g_free(name); |
1165
3daec853f3c6
[gaim-migrate @ 1175]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
23 gtk_timeout_remove(recon); |
3daec853f3c6
[gaim-migrate @ 1175]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1047
diff
changeset
|
24 if (!u) return; |
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
631
diff
changeset
|
25 serv_login(u); |
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
631
diff
changeset
|
26 forced_off = 0; |
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
631
diff
changeset
|
27 if (away_state) do_away_message(NULL, last_away); |
99 | 28 } |
29 | |
1000
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
631
diff
changeset
|
30 void reconnect(struct gaim_connection *gc, void *m) { |
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
631
diff
changeset
|
31 char *name = g_strdup(gc->username); |
91b7377e7b45
[gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
631
diff
changeset
|
32 recon = gtk_timeout_add(8000, (GtkFunction)do_signon, name); |
151
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
33 forced_off = 1; |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
34 } |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
35 |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
36 void away_toggle(void *m) { |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
37 if ((int)m == 1) { |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
38 last_away = awaymessage; |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
39 away_state = 1; |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
40 } else if (!forced_off) |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
41 away_state = 0; |
99 | 42 } |
43 | |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
44 char *gaim_plugin_init(GModule *handle) { |
151
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
45 if (imaway) { |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
46 away_state = 1; |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
47 last_away = awaymessage; |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
48 } else |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
49 away_state = 0; |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
50 |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
51 gaim_signal_connect(handle, event_away, away_toggle, (void *)1); |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
52 gaim_signal_connect(handle, event_back, away_toggle, (void *)0); |
99 | 53 gaim_signal_connect(handle, event_signoff, reconnect, NULL); |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
54 |
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
55 return NULL; |
99 | 56 } |