# HG changeset patch # User Eric Warmenhoven # Date 956533580 0 # Node ID c754e5ae442a9922eed2191b9077c37992b78288 # Parent d4e99c17e399a1cb7eb75e059f7a6e9eff641b78 [gaim-migrate @ 161] Implemented "save state" - if you were away, and you get kicked off, it signs you back on, and sets you as being away with the away message you had been using. committer: Tailor Script diff -r d4e99c17e399 -r c754e5ae442a plugins/autorecon.c --- a/plugins/autorecon.c Sun Apr 23 23:30:50 2000 +0000 +++ b/plugins/autorecon.c Sun Apr 23 23:46:20 2000 +0000 @@ -1,28 +1,13 @@ -/* TODO: save state - * I'm not at my computer right now, so I'm not going to bother - * writing it, but if someone wants to before I get back (hint, - * hint), go for it. Here's how to do it. - * - * First, add a global "state", which is either 'away' or not. - * - * In gaim_plugin_init, set state, and add two more signal - * handlers: event_away and event_back, and if you can't figure - * out what you're supposed to do for them, you shouldn't be - * editing this plugin. - * - * In the reconnect function, if "state" was away, then reset - * the away message. You may have to remember the away message - * on your own; I haven't checked yet to see if there's a global - * that remembers it that isn't erased on signoff/signon. - * - * Anyway, that should be it. - */ - #define GAIM_PLUGINS #include "gaim.h" #include +extern GtkWidget *imaway; + static int recon; +static int away_state; +static int forced_off = 0; +static struct away_message *last_away; char *name() { return "Auto Reconnect"; @@ -36,16 +21,36 @@ void do_signon() { dologin(NULL, NULL); - if (query_state() != STATE_OFFLINE) { + if (blist) { gtk_timeout_remove(recon); + forced_off = 0; + if (away_state) + do_away_message(NULL, last_away); return; } } void reconnect(void *m) { recon = gtk_timeout_add(2000, (GtkFunction)do_signon, NULL); + forced_off = 1; +} + +void away_toggle(void *m) { + if ((int)m == 1) { + last_away = awaymessage; + away_state = 1; + } else if (!forced_off) + away_state = 0; } void gaim_plugin_init(void *handle) { + if (imaway) { + away_state = 1; + last_away = awaymessage; + } else + away_state = 0; + + gaim_signal_connect(handle, event_away, away_toggle, (void *)1); + gaim_signal_connect(handle, event_back, away_toggle, (void *)0); gaim_signal_connect(handle, event_signoff, reconnect, NULL); }