Mercurial > pidgin.yaz
changeset 6113:30d4c432101c
[gaim-migrate @ 6575]
Fix a memleak in the status code (a temporary g_hash_table was not getting
freed)
Make the auto-reconnect plugin fully multi-protocol aware. Previously, if
it was waiting to sign on more than one account, and you unload the plugin,
it would continue to attempt to sign on all but one of the accounts.
Set wants_to_die to TRUE if Buddies->Signoff was chosen.
Get rid of some unneeded oscar debugging lines for faceprint :-)
Make oscar not attempt to signon again if you were disconnected because
you signed on from another location.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 13 Jul 2003 20:36:53 +0000 |
parents | a22c151463e1 |
children | 3c70f8be8558 |
files | plugins/autorecon.c src/connection.c src/protocols/oscar/info.c src/protocols/oscar/oscar.c src/status.c |
diffstat | 5 files changed, 55 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/autorecon.c Sun Jul 13 19:25:44 2003 +0000 +++ b/plugins/autorecon.c Sun Jul 13 20:36:53 2003 +0000 @@ -9,42 +9,70 @@ #define INITIAL 8000 #define MAXTIME 2048000 -static GHashTable *hash = NULL; +typedef struct { + int delay; + guint timeout; +} GaimAutoRecon; -static guint tim = 0; +static GHashTable *hash = NULL; static gboolean do_signon(gpointer data) { GaimAccount *account = data; + GaimAutoRecon *info; + gaim_debug(GAIM_DEBUG_INFO, "autorecon", "do_signon called\n"); + g_return_val_if_fail(account != NULL, FALSE); + info = g_hash_table_lookup(hash, account); if (g_list_index(gaim_accounts_get_all(), account) < 0) return FALSE; + gaim_debug(GAIM_DEBUG_INFO, "autorecon", "calling gaim_account_connect\n"); gaim_account_connect(account); gaim_debug(GAIM_DEBUG_INFO, "autorecon", "done calling gaim_account_connect\n"); - tim = 0; + + info->timeout = 0; + return FALSE; } static void reconnect(GaimConnection *gc, void *m) { + GaimAccount *account; + GaimAutoRecon *info; + + g_return_if_fail(gc != NULL); + account = gaim_connection_get_account(gc); + info = g_hash_table_lookup(hash, account); + if (!gc->wants_to_die) { - int del; - del = (int)g_hash_table_lookup(hash, gc->account); - if (!del) - del = INITIAL; - else - del = MIN(2 * del, MAXTIME); - tim = g_timeout_add(del, do_signon, gc->account); - g_hash_table_insert(hash, gc->account, (gpointer)del); - } else { - g_hash_table_remove(hash, gc->account); + if (info == NULL) { + info = g_new0(GaimAutoRecon, 1); + g_hash_table_insert(hash, account, info); + info->delay = INITIAL; + } else + info->delay = MIN(2 * info->delay, MAXTIME); + info->timeout = g_timeout_add(info->delay, do_signon, account); + } else if (info != NULL) { + g_hash_table_remove(hash, account); + g_free(info); } } +static void +free_auto_recon(gpointer data) +{ + GaimAutoRecon *info = data; + + if (info->timeout != 0) + g_source_remove(info->timeout); + + g_free(info); +} + static gboolean plugin_load(GaimPlugin *plugin) { - hash = g_hash_table_new(g_int_hash, g_int_equal); + hash = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, free_auto_recon); gaim_signal_connect(plugin, event_signoff, reconnect, NULL); @@ -54,15 +82,10 @@ static gboolean plugin_unload(GaimPlugin *plugin) { - if (tim) - g_source_remove(tim); - gaim_signal_disconnect(plugin, event_signoff, reconnect); g_hash_table_destroy(hash); - hash = NULL; - tim = 0; return TRUE; }
--- a/src/connection.c Sun Jul 13 19:25:44 2003 +0000 +++ b/src/connection.c Sun Jul 13 20:36:53 2003 +0000 @@ -407,9 +407,13 @@ gaim_connections_disconnect_all(void) { GList *l; + GaimConnection *gc; - while ((l = gaim_connections_get_all()) != NULL) - gaim_connection_destroy(l->data); + while ((l = gaim_connections_get_all()) != NULL) { + gc = l->data; + gc->wants_to_die = TRUE; + gaim_connection_destroy(gc); + } } GList *
--- a/src/protocols/oscar/info.c Sun Jul 13 19:25:44 2003 +0000 +++ b/src/protocols/oscar/info.c Sun Jul 13 20:36:53 2003 +0000 @@ -643,7 +643,10 @@ outinfo->present |= AIM_USERINFO_PRESENT_SESSIONLEN; } else if (type == 0x0019) { - faimdprintf(sess, 0, "userinfo: **warning: unexpected TLV type 0x0019: from %s\n", outinfo->sn); +/* faimdprintf(sess, 0, "userinfo: **warning: unexpected TLV type 0x0019: from %s\n", outinfo->sn); */ + + } else if (type == 0x001b) { +/* faimdprintf(sess, 0, "userinfo: **warning: unexpected TLV type 0x001b: from %s\n", outinfo->sn); */ } else if (type == 0x001d) { /*
--- a/src/protocols/oscar/oscar.c Sun Jul 13 19:25:44 2003 +0000 +++ b/src/protocols/oscar/oscar.c Sun Jul 13 20:36:53 2003 +0000 @@ -3699,6 +3699,7 @@ "Disconnected. Code is 0x%04x and msg is %s\n", code, msg); if ((fr) && (fr->conn) && (fr->conn->type == AIM_CONN_TYPE_BOS)) { if (code == 0x0001) { + gc->wants_to_die = TRUE; gaim_connection_error(gc, _("You have been disconnected because you have signed on with this screen name at another location.")); } else { gaim_connection_error(gc, _("You have been signed off for an unknown reason."));