annotate plugins/autorecon.c @ 1000:91b7377e7b45

[gaim-migrate @ 1010] Plugins work again, I think. There may still be some bugginess. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 16 Oct 2000 20:11:18 +0000
parents d96b511972fe
children 38452403563b
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"
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 #include <gtk/gtk.h>
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
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
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 char *name() {
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 return "Auto Reconnect";
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 }
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 char *description() {
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 return "When AOL kicks you off, this auto-reconnects you.";
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 }
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19
1000
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 631
diff changeset
20 void do_signon(char *name) {
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 631
diff changeset
21 struct aim_user *u = find_user(name);
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 631
diff changeset
22 g_free(name);
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 631
diff changeset
23 serv_login(u);
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 631
diff changeset
24 gtk_timeout_remove(recon);
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 631
diff changeset
25 forced_off = 0;
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 631
diff changeset
26 if (away_state) do_away_message(NULL, last_away);
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 }
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28
1000
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 631
diff changeset
29 void reconnect(struct gaim_connection *gc, void *m) {
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 631
diff changeset
30 char *name = g_strdup(gc->username);
91b7377e7b45 [gaim-migrate @ 1010]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 631
diff changeset
31 recon = gtk_timeout_add(8000, (GtkFunction)do_signon, name);
151
c754e5ae442a [gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 148
diff changeset
32 forced_off = 1;
c754e5ae442a [gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 148
diff changeset
33 }
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 void away_toggle(void *m) {
c754e5ae442a [gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 148
diff changeset
36 if ((int)m == 1) {
c754e5ae442a [gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 148
diff changeset
37 last_away = awaymessage;
c754e5ae442a [gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 148
diff changeset
38 away_state = 1;
c754e5ae442a [gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 148
diff changeset
39 } else if (!forced_off)
c754e5ae442a [gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 148
diff changeset
40 away_state = 0;
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 }
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 void gaim_plugin_init(void *handle) {
151
c754e5ae442a [gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 148
diff changeset
44 if (imaway) {
c754e5ae442a [gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 148
diff changeset
45 away_state = 1;
c754e5ae442a [gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 148
diff changeset
46 last_away = awaymessage;
c754e5ae442a [gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 148
diff changeset
47 } else
c754e5ae442a [gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 148
diff changeset
48 away_state = 0;
c754e5ae442a [gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 148
diff changeset
49
c754e5ae442a [gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 148
diff changeset
50 gaim_signal_connect(handle, event_away, away_toggle, (void *)1);
c754e5ae442a [gaim-migrate @ 161]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 148
diff changeset
51 gaim_signal_connect(handle, event_back, away_toggle, (void *)0);
99
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 gaim_signal_connect(handle, event_signoff, reconnect, NULL);
f810fc7d423f [gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 }