# HG changeset patch # User Luke Schierer # Date 1095025079 0 # Node ID c06c4a697b31248a8fe9c681a5166275af173241 # Parent 8cc6f0bfa215b1baf2ce74ebec8a1ef2c320c78e [gaim-migrate @ 10944] autorecon can give you an even less dialog-ful reconnection committer: Tailor Script diff -r 8cc6f0bfa215 -r c06c4a697b31 ChangeLog --- a/ChangeLog Sat Sep 11 21:56:18 2004 +0000 +++ b/ChangeLog Sun Sep 12 21:37:59 2004 +0000 @@ -1,7 +1,9 @@ Gaim: The Pimpin' Penguin IM Client that's good for the soul! version 2.0.0 + New Features: * gaim-remote can send text (John B. Silvestri) + * Autoreconnect plugin can hide the reconnect dialog (François Gagné) version 0.83: New Features: diff -r 8cc6f0bfa215 -r c06c4a697b31 plugins/autorecon.c --- a/plugins/autorecon.c Sat Sep 11 21:56:18 2004 +0000 +++ b/plugins/autorecon.c Sun Sep 12 21:37:59 2004 +0000 @@ -20,16 +20,82 @@ static GHashTable *hash = NULL; +static GSList *accountReconnecting = NULL; + #define AUTORECON_OPT "/plugins/core/autorecon" -#define OPT_HIDE_CONNECTED AUTORECON_OPT "/hide_connected_error" -#define OPT_HIDE_CONNECTING AUTORECON_OPT "/hide_connecting_error" -#define OPT_RESTORE_STATE AUTORECON_OPT "/restore_state" +#define OPT_HIDE_CONNECTED AUTORECON_OPT "/hide_connected_error" +#define OPT_HIDE_CONNECTING AUTORECON_OPT "/hide_connecting_error" +#define OPT_RESTORE_STATE AUTORECON_OPT "/restore_state" +#define OPT_HIDE_RECONNECTING_DIALOG AUTORECON_OPT "/hide_reconnecting_dialog" /* storage of original (old_ops) and modified (new_ops) ui ops to allow us to intercept calls to report_disconnect */ static GaimConnectionUiOps *old_ops = NULL; static GaimConnectionUiOps *new_ops = NULL; +static void connect_progress(GaimConnection *gc, const char *text, + size_t step, size_t step_count) { + if(old_ops == NULL || old_ops->connect_progress == NULL) { + /* there's nothing to call through to, so don't bother + checking prefs */ + return; + } else if(gaim_prefs_get_bool(OPT_HIDE_RECONNECTING_DIALOG) && accountReconnecting && + g_slist_find(accountReconnecting, gc->account)) { + /* this is a reconnecting, and we're hiding those */ + gaim_debug(GAIM_DEBUG_INFO, "autorecon", + "hide connecting dialog while reconnecting\n"); + return; + } + + old_ops->connect_progress(gc, text, step, step_count); +} + +static void connected(GaimConnection *gc) { + if(old_ops == NULL || old_ops->connected == NULL) { + /* there's nothing to call through to, so don't bother + checking prefs */ + return; + } else if(gaim_prefs_get_bool(OPT_HIDE_RECONNECTING_DIALOG) && accountReconnecting && + g_slist_find(accountReconnecting, gc->account)) { + /* this is a reconnecting, and we're hiding those */ + gaim_debug(GAIM_DEBUG_INFO, "autorecon", + "hide connecting dialog while reconnecting\n"); + return; + } + + old_ops->connected(gc); +} + +static void disconnected(GaimConnection *gc) { + if(old_ops == NULL || old_ops->disconnected == NULL) { + /* there's nothing to call through to, so don't bother + checking prefs */ + return; + } else if(gaim_prefs_get_bool(OPT_HIDE_RECONNECTING_DIALOG) && accountReconnecting && + g_slist_find(accountReconnecting, gc->account)) { + /* this is a reconnecting, and we're hiding those */ + gaim_debug(GAIM_DEBUG_INFO, "autorecon", + "hide connecting dialog while reconnecting\n"); + return; + } + + old_ops->disconnected(gc); +} + +static void notice(GaimConnection *gc, const char *text) { + if(old_ops == NULL || old_ops->notice == NULL) { + /* there's nothing to call through to, so don't bother + checking prefs */ + return; + } else if(gaim_prefs_get_bool(OPT_HIDE_RECONNECTING_DIALOG) && accountReconnecting && + g_slist_find(accountReconnecting, gc->account)) { + /* this is a reconnecting, and we're hiding those */ + gaim_debug(GAIM_DEBUG_INFO, "autorecon", + "hide connecting dialog while reconnecting\n"); + } + + old_ops->notice(gc, text); +} static void report_disconnect(GaimConnection *gc, const char *text) { @@ -84,10 +150,15 @@ static void reconnect(GaimConnection *gc, void *m) { GaimAccount *account; GaimAutoRecon *info; + GSList* listAccount; g_return_if_fail(gc != NULL); account = gaim_connection_get_account(gc); info = g_hash_table_lookup(hash, account); + if (accountReconnecting) + listAccount = g_slist_find(accountReconnecting, account); + else + listAccount = NULL; if (!gc->wants_to_die) { if (info == NULL) { @@ -100,12 +171,28 @@ g_source_remove(info->timeout); } info->timeout = g_timeout_add(info->delay, do_signon, account); + + if (!listAccount) + accountReconnecting = g_slist_prepend(accountReconnecting, account); } else if (info != NULL) { g_hash_table_remove(hash, account); + + if (listAccount) + accountReconnecting = g_slist_delete_link(accountReconnecting, listAccount); } } static void +reconnected(GaimConnection *gc, void *m) { + GaimAccount *account; + + g_return_if_fail(gc != NULL && accountReconnecting != NULL); + account = gaim_connection_get_account(gc); + + accountReconnecting = g_slist_remove(accountReconnecting, account); +} + +static void free_auto_recon(gpointer data) { GaimAutoRecon *info = data; @@ -135,15 +222,24 @@ old_ops = gaim_connections_get_ui_ops(); new_ops = (GaimConnectionUiOps *) g_memdup(old_ops, sizeof(GaimConnectionUiOps)); + new_ops->connect_progress = connect_progress; + new_ops->connected = connected; + new_ops->disconnected = disconnected; + new_ops->notice = notice; new_ops->report_disconnect = report_disconnect; gaim_connections_set_ui_ops(new_ops); hash = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, free_auto_recon); + + accountReconnecting = NULL; gaim_signal_connect(gaim_connections_get_handle(), "signed-off", plugin, GAIM_CALLBACK(reconnect), NULL); + gaim_signal_connect(gaim_connections_get_handle(), "signed-on", + plugin, GAIM_CALLBACK(reconnected), NULL); + return TRUE; } @@ -154,8 +250,16 @@ gaim_signal_disconnect(gaim_connections_get_handle(), "signed-off", plugin, GAIM_CALLBACK(reconnect)); + gaim_signal_disconnect(gaim_connections_get_handle(), "signed-on", + plugin, GAIM_CALLBACK(reconnected)); + g_hash_table_destroy(hash); hash = NULL; + + if (accountReconnecting) { + g_slist_free(accountReconnecting); + accountReconnecting = NULL; + } gaim_connections_set_ui_ops(old_ops); g_free(new_ops); @@ -180,6 +284,10 @@ _("Hide Login Errors")); gaim_plugin_pref_frame_add(frame, pref); + pref = gaim_plugin_pref_new_with_name_and_label(OPT_HIDE_RECONNECTING_DIALOG, + _("Hide Reconnecting Dialog")); + gaim_plugin_pref_frame_add(frame, pref); + return frame; } @@ -227,6 +335,7 @@ gaim_prefs_add_none(AUTORECON_OPT); gaim_prefs_add_bool(OPT_HIDE_CONNECTED, FALSE); gaim_prefs_add_bool(OPT_HIDE_CONNECTING, FALSE); + gaim_prefs_add_bool(OPT_HIDE_RECONNECTING_DIALOG, FALSE); gaim_prefs_remove(OPT_RESTORE_STATE); }