Mercurial > pidgin
comparison plugins/autorecon.c @ 1404:96e93119268d
[gaim-migrate @ 1414]
argh
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 13 Jan 2001 08:49:15 +0000 |
parents | aedeb1218a0a |
children | b367beee6448 |
comparison
equal
deleted
inserted
replaced
1403:c0aa7fdc0a93 | 1404:96e93119268d |
---|---|
1 #define GAIM_PLUGINS | 1 #define GAIM_PLUGINS |
2 #include "gaim.h" | 2 #include "gaim.h" |
3 #include "prpl.h" | |
3 #include <gtk/gtk.h> | 4 #include <gtk/gtk.h> |
4 | 5 |
5 extern GtkWidget *imaway; | 6 extern GtkWidget *imaway; |
6 | 7 |
7 static int away_state; | 8 static int away_state; |
8 static int forced_off = 0; | 9 static int forced_off = 0; |
9 static struct away_message *last_away = NULL; | 10 static char *last_away = NULL; |
10 GSList *reconnects = NULL; | 11 GSList *reconnects = NULL; |
11 GSList *recontim = NULL; | 12 GSList *recontim = NULL; |
12 | 13 |
13 char *name() { | 14 char *name() { |
14 return "Auto Reconnect"; | 15 return "Auto Reconnect"; |
25 return; | 26 return; |
26 place = g_slist_index(reconnects, gc->user); | 27 place = g_slist_index(reconnects, gc->user); |
27 recon = (guint)g_slist_nth(recontim, place); | 28 recon = (guint)g_slist_nth(recontim, place); |
28 reconnects = g_slist_remove(reconnects, gc->user); | 29 reconnects = g_slist_remove(reconnects, gc->user); |
29 recontim = g_slist_remove(recontim, (void *)recon); | 30 recontim = g_slist_remove(recontim, (void *)recon); |
30 if (away_state) do_away_message(NULL, last_away); | 31 if (away_state) serv_set_away(gc, GAIM_AWAY_CUSTOM, last_away); |
31 } | 32 } |
32 | 33 |
33 static void do_signon(struct aim_user *u) { | 34 static void do_signon(struct aim_user *u) { |
34 gint place; | 35 gint place; |
35 guint recon; | 36 guint recon; |
48 reconnects = g_slist_append(reconnects, gc->user); | 49 reconnects = g_slist_append(reconnects, gc->user); |
49 recontim = g_slist_append(recontim, (void *)recon); | 50 recontim = g_slist_append(recontim, (void *)recon); |
50 forced_off = 1; | 51 forced_off = 1; |
51 } | 52 } |
52 | 53 |
53 static void away_toggle(void *m) { | 54 static void away_toggle(struct gaim_connection *gc, char *state, char *message, gpointer data) { |
54 if ((int)m == 1) { | 55 if (gc->away) { |
55 last_away = awaymessage; | 56 if (last_away) |
57 g_free(last_away); | |
58 last_away = g_strdup(gc->away); | |
56 away_state = 1; | 59 away_state = 1; |
57 } else if (!forced_off) | 60 } else if (!forced_off) |
58 away_state = 0; | 61 away_state = 0; |
59 } | 62 } |
60 | 63 |
61 char *gaim_plugin_init(GModule *handle) { | 64 char *gaim_plugin_init(GModule *handle) { |
62 if (imaway) { | 65 if (awaymessage) { |
63 away_state = 1; | 66 away_state = 1; |
64 last_away = awaymessage; | 67 last_away = g_strdup(awaymessage->message); |
65 } else | 68 } else |
66 away_state = 0; | 69 away_state = 0; |
67 | 70 |
68 gaim_signal_connect(handle, event_away, away_toggle, (void *)1); | 71 gaim_signal_connect(handle, event_away, away_toggle, NULL); |
69 gaim_signal_connect(handle, event_back, away_toggle, (void *)0); | |
70 gaim_signal_connect(handle, event_signoff, reconnect, NULL); | 72 gaim_signal_connect(handle, event_signoff, reconnect, NULL); |
71 gaim_signal_connect(handle, event_signon, now_online, NULL); | 73 gaim_signal_connect(handle, event_signon, now_online, NULL); |
72 | 74 |
73 return NULL; | 75 return NULL; |
74 } | 76 } |
77 | |
78 void gaim_plugin_remove() { | |
79 g_free(last_away); | |
80 } |