comparison src/gtkconn.c @ 13730:2eea3265dbe6

[gaim-migrate @ 16141] Correctly remove the disconnected button when the account successfully connections. This might have only been a problem when the account wanted_to_die committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 07 May 2006 18:04:24 +0000
parents 6818e4fc3616
children 69e02f13b525
comparison
equal deleted inserted replaced
13729:74033e0831bc 13730:2eea3265dbe6
49 * Contains accounts that are auto-reconnecting. 49 * Contains accounts that are auto-reconnecting.
50 * The key is a pointer to the GaimAccount and the 50 * The key is a pointer to the GaimAccount and the
51 * value is a pointer to a GaimAutoRecon. 51 * value is a pointer to a GaimAutoRecon.
52 */ 52 */
53 static GHashTable *hash = NULL; 53 static GHashTable *hash = NULL;
54 static GHashTable *errored_accounts = NULL;
55 54
56 static void 55 static void
57 gaim_gtk_connection_connect_progress(GaimConnection *gc, 56 gaim_gtk_connection_connect_progress(GaimConnection *gc,
58 const char *text, size_t step, size_t step_count) 57 const char *text, size_t step, size_t step_count)
59 { 58 {
62 return; 61 return;
63 gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox), 62 gtk_gaim_status_box_set_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox),
64 (gaim_connections_get_connecting() != NULL)); 63 (gaim_connections_get_connecting() != NULL));
65 gtk_gaim_status_box_pulse_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox)); 64 gtk_gaim_status_box_pulse_connecting(GTK_GAIM_STATUS_BOX(gtkblist->statusbox));
66 } 65 }
67 66 \
68 static void 67 static void
69 gaim_gtk_connection_connected(GaimConnection *gc) 68 gaim_gtk_connection_connected(GaimConnection *gc)
70 { 69 {
71 GaimAccount *account; 70 GaimAccount *account;
72 GaimGtkBuddyList *gtkblist; 71 GaimGtkBuddyList *gtkblist;
79 (gaim_connections_get_connecting() != NULL)); 78 (gaim_connections_get_connecting() != NULL));
80 79
81 if (hash != NULL) 80 if (hash != NULL)
82 g_hash_table_remove(hash, account); 81 g_hash_table_remove(hash, account);
83 82
84 if (g_hash_table_size(errored_accounts) > 0) 83 gaim_gtk_blist_update_account_error_state(account, NULL);
85 {
86 g_hash_table_remove(errored_accounts, account);
87 gaim_gtk_blist_update_account_error_state(account, NULL);
88 }
89 } 84 }
90 85
91 static void 86 static void
92 gaim_gtk_connection_disconnected(GaimConnection *gc) 87 gaim_gtk_connection_disconnected(GaimConnection *gc)
93 { 88 {
149 static void 144 static void
150 gaim_gtk_connection_report_disconnect(GaimConnection *gc, const char *text) 145 gaim_gtk_connection_report_disconnect(GaimConnection *gc, const char *text)
151 { 146 {
152 GaimAccount *account = NULL; 147 GaimAccount *account = NULL;
153 GaimAutoRecon *info; 148 GaimAutoRecon *info;
154 GSList* errored_account;
155 149
156 account = gaim_connection_get_account(gc); 150 account = gaim_connection_get_account(gc);
157 info = g_hash_table_lookup(hash, account); 151 info = g_hash_table_lookup(hash, account);
158 errored_account = g_hash_table_lookup(errored_accounts, account);
159 152
160 gaim_gtk_blist_update_account_error_state(account, text); 153 gaim_gtk_blist_update_account_error_state(account, text);
161 if (!gc->wants_to_die) { 154 if (!gc->wants_to_die) {
162 if (info == NULL) { 155 if (info == NULL) {
163 info = g_new0(GaimAutoRecon, 1); 156 info = g_new0(GaimAutoRecon, 1);
167 info->delay = MIN(2 * info->delay, MAX_RECON_DELAY); 160 info->delay = MIN(2 * info->delay, MAX_RECON_DELAY);
168 if (info->timeout != 0) 161 if (info->timeout != 0)
169 g_source_remove(info->timeout); 162 g_source_remove(info->timeout);
170 } 163 }
171 info->timeout = g_timeout_add(info->delay, do_signon, account); 164 info->timeout = g_timeout_add(info->delay, do_signon, account);
172
173 g_hash_table_insert(errored_accounts, account, NULL);
174 } else { 165 } else {
175 char *p, *s, *n=NULL ; 166 char *p, *s, *n=NULL ;
176 if (info != NULL) 167 if (info != NULL)
177 g_hash_table_remove(hash, account); 168 g_hash_table_remove(hash, account);
178
179 if (errored_account != NULL)
180 g_hash_table_remove(errored_accounts, errored_account);
181 169
182 if (gaim_account_get_alias(account)) 170 if (gaim_account_get_alias(account))
183 { 171 {
184 n = g_strdup_printf("%s (%s) (%s)", 172 n = g_strdup_printf("%s (%s) (%s)",
185 gaim_account_get_username(account), 173 gaim_account_get_username(account),
229 static void 217 static void
230 account_removed_cb(GaimAccount *account, gpointer user_data) 218 account_removed_cb(GaimAccount *account, gpointer user_data)
231 { 219 {
232 g_hash_table_remove(hash, account); 220 g_hash_table_remove(hash, account);
233 221
234 if (g_hash_table_size(errored_accounts) > 0) 222 gaim_gtk_blist_update_account_error_state(account, NULL);
235 {
236 g_hash_table_remove(errored_accounts, account);
237 gaim_gtk_blist_update_account_error_state(account, NULL);
238 }
239 } 223 }
240 224
241 225
242 /************************************************************************** 226 /**************************************************************************
243 * GTK+ connection glue 227 * GTK+ connection glue
255 gaim_gtk_connection_init(void) 239 gaim_gtk_connection_init(void)
256 { 240 {
257 hash = g_hash_table_new_full( 241 hash = g_hash_table_new_full(
258 g_direct_hash, g_direct_equal, 242 g_direct_hash, g_direct_equal,
259 NULL, free_auto_recon); 243 NULL, free_auto_recon);
260 errored_accounts = g_hash_table_new_full(
261 g_direct_hash, g_direct_equal,
262 NULL, NULL);
263 244
264 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed", 245 gaim_signal_connect(gaim_accounts_get_handle(), "account-removed",
265 gaim_gtk_connection_get_handle(), 246 gaim_gtk_connection_get_handle(),
266 GAIM_CALLBACK(account_removed_cb), NULL); 247 GAIM_CALLBACK(account_removed_cb), NULL);
267 } 248 }
270 gaim_gtk_connection_uninit(void) 251 gaim_gtk_connection_uninit(void)
271 { 252 {
272 gaim_signals_disconnect_by_handle(gaim_gtk_connection_get_handle()); 253 gaim_signals_disconnect_by_handle(gaim_gtk_connection_get_handle());
273 254
274 g_hash_table_destroy(hash); 255 g_hash_table_destroy(hash);
275 g_hash_table_destroy(errored_accounts); 256 }
276 }