Mercurial > pidgin.yaz
annotate plugins/autorecon.c @ 981:7e231bc0018a
[gaim-migrate @ 991]
I think I need a Pepsi.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 13 Oct 2000 07:24:40 +0000 |
parents | d96b511972fe |
children | 91b7377e7b45 |
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 | |
20 extern void dologin(GtkWidget *, GtkWidget *); | |
21 | |
22 void do_signon() { | |
631
d96b511972fe
[gaim-migrate @ 641]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
151
diff
changeset
|
23 if (!blist) |
d96b511972fe
[gaim-migrate @ 641]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
151
diff
changeset
|
24 dologin(NULL, NULL); |
d96b511972fe
[gaim-migrate @ 641]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
151
diff
changeset
|
25 if (!USE_OSCAR) { |
d96b511972fe
[gaim-migrate @ 641]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
151
diff
changeset
|
26 if (blist) { |
d96b511972fe
[gaim-migrate @ 641]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
151
diff
changeset
|
27 gtk_timeout_remove(recon); |
d96b511972fe
[gaim-migrate @ 641]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
151
diff
changeset
|
28 forced_off = 0; |
d96b511972fe
[gaim-migrate @ 641]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
151
diff
changeset
|
29 if (away_state) |
d96b511972fe
[gaim-migrate @ 641]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
151
diff
changeset
|
30 do_away_message(NULL, last_away); |
d96b511972fe
[gaim-migrate @ 641]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
151
diff
changeset
|
31 return; |
d96b511972fe
[gaim-migrate @ 641]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
151
diff
changeset
|
32 } |
d96b511972fe
[gaim-migrate @ 641]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
151
diff
changeset
|
33 } else { |
99 | 34 gtk_timeout_remove(recon); |
151
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
35 forced_off = 0; |
631
d96b511972fe
[gaim-migrate @ 641]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
151
diff
changeset
|
36 if (blist && away_state) do_away_message(NULL, last_away); |
99 | 37 return; |
38 } | |
39 } | |
40 | |
41 void reconnect(void *m) { | |
631
d96b511972fe
[gaim-migrate @ 641]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
151
diff
changeset
|
42 recon = gtk_timeout_add(8000, (GtkFunction)do_signon, NULL); |
151
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
43 forced_off = 1; |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
44 } |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
45 |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
46 void away_toggle(void *m) { |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
47 if ((int)m == 1) { |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
48 last_away = awaymessage; |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
49 away_state = 1; |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
50 } else if (!forced_off) |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
51 away_state = 0; |
99 | 52 } |
53 | |
54 void gaim_plugin_init(void *handle) { | |
151
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
55 if (imaway) { |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
56 away_state = 1; |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
57 last_away = awaymessage; |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
58 } else |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
59 away_state = 0; |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
60 |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
61 gaim_signal_connect(handle, event_away, away_toggle, (void *)1); |
c754e5ae442a
[gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
148
diff
changeset
|
62 gaim_signal_connect(handle, event_back, away_toggle, (void *)0); |
99 | 63 gaim_signal_connect(handle, event_signoff, reconnect, NULL); |
64 } |