comparison plugins/autorecon.c @ 1378:aedeb1218a0a

[gaim-migrate @ 1388] libfaim has a bad cap for Games, update the TODO for Jabber stuff, and make autorecon.c work better, I hope committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 05 Jan 2001 00:17:43 +0000
parents 3daec853f3c6
children 96e93119268d
comparison
equal deleted inserted replaced
1377:569835fcabc3 1378:aedeb1218a0a
2 #include "gaim.h" 2 #include "gaim.h"
3 #include <gtk/gtk.h> 3 #include <gtk/gtk.h>
4 4
5 extern GtkWidget *imaway; 5 extern GtkWidget *imaway;
6 6
7 static int recon;
8 static int away_state; 7 static int away_state;
9 static int forced_off = 0; 8 static int forced_off = 0;
10 static struct away_message *last_away; 9 static struct away_message *last_away = NULL;
10 GSList *reconnects = NULL;
11 GSList *recontim = NULL;
11 12
12 char *name() { 13 char *name() {
13 return "Auto Reconnect"; 14 return "Auto Reconnect";
14 } 15 }
15 16
16 char *description() { 17 char *description() {
17 return "When AOL kicks you off, this auto-reconnects you."; 18 return "When AOL kicks you off, this auto-reconnects you.";
18 } 19 }
19 20
20 void do_signon(char *name) { 21 static void now_online(struct gaim_connection *gc, void *m) {
21 struct aim_user *u = find_user(name, -1); 22 gint place;
22 g_free(name); 23 guint recon;
23 gtk_timeout_remove(recon); 24 if (!g_slist_find(reconnects, gc->user))
24 if (!u) return; 25 return;
25 serv_login(u); 26 place = g_slist_index(reconnects, gc->user);
26 forced_off = 0; 27 recon = (guint)g_slist_nth(recontim, place);
28 reconnects = g_slist_remove(reconnects, gc->user);
29 recontim = g_slist_remove(recontim, (void *)recon);
27 if (away_state) do_away_message(NULL, last_away); 30 if (away_state) do_away_message(NULL, last_away);
28 } 31 }
29 32
30 void reconnect(struct gaim_connection *gc, void *m) { 33 static void do_signon(struct aim_user *u) {
31 char *name = g_strdup(gc->username); 34 gint place;
32 recon = gtk_timeout_add(8000, (GtkFunction)do_signon, name); 35 guint recon;
36 place = g_slist_index(reconnects, u);
37 recon = (guint)g_slist_nth(recontim, place);
38 gtk_timeout_remove(recon);
39 forced_off = 0;
40 serv_login(u);
41 }
42
43 static void reconnect(struct gaim_connection *gc, void *m) {
44 guint recon;
45 if (g_slist_find(reconnects, gc->user))
46 return;
47 recon = gtk_timeout_add(8000, (GtkFunction)do_signon, gc->user);
48 reconnects = g_slist_append(reconnects, gc->user);
49 recontim = g_slist_append(recontim, (void *)recon);
33 forced_off = 1; 50 forced_off = 1;
34 } 51 }
35 52
36 void away_toggle(void *m) { 53 static void away_toggle(void *m) {
37 if ((int)m == 1) { 54 if ((int)m == 1) {
38 last_away = awaymessage; 55 last_away = awaymessage;
39 away_state = 1; 56 away_state = 1;
40 } else if (!forced_off) 57 } else if (!forced_off)
41 away_state = 0; 58 away_state = 0;
49 away_state = 0; 66 away_state = 0;
50 67
51 gaim_signal_connect(handle, event_away, away_toggle, (void *)1); 68 gaim_signal_connect(handle, event_away, away_toggle, (void *)1);
52 gaim_signal_connect(handle, event_back, away_toggle, (void *)0); 69 gaim_signal_connect(handle, event_back, away_toggle, (void *)0);
53 gaim_signal_connect(handle, event_signoff, reconnect, NULL); 70 gaim_signal_connect(handle, event_signoff, reconnect, NULL);
71 gaim_signal_connect(handle, event_signon, now_online, NULL);
54 72
55 return NULL; 73 return NULL;
56 } 74 }