comparison pidgin/gtkconn.c @ 20089:c43f96170910

Rename Pidgin's hash table of ongoing autoreconnections to 'auto_reconns' from the highly descriptive 'hash'.
author Will Thompson <will.thompson@collabora.co.uk>
date Sun, 16 Sep 2007 16:48:46 +0000
parents 6bf32c9e15a7
children d3bd5414eb0f b7460582a135
comparison
equal deleted inserted replaced
20086:2a4550082d66 20089:c43f96170910
51 /** 51 /**
52 * Contains accounts that are auto-reconnecting. 52 * Contains accounts that are auto-reconnecting.
53 * The key is a pointer to the PurpleAccount and the 53 * The key is a pointer to the PurpleAccount and the
54 * value is a pointer to a PidginAutoRecon. 54 * value is a pointer to a PidginAutoRecon.
55 */ 55 */
56 static GHashTable *hash = NULL; 56 static GHashTable *auto_reconns = NULL;
57 57
58 static void 58 static void
59 pidgin_connection_connect_progress(PurpleConnection *gc, 59 pidgin_connection_connect_progress(PurpleConnection *gc,
60 const char *text, size_t step, size_t step_count) 60 const char *text, size_t step, size_t step_count)
61 { 61 {
78 78
79 if (gtkblist != NULL) 79 if (gtkblist != NULL)
80 pidgin_status_box_set_connecting(PIDGIN_STATUS_BOX(gtkblist->statusbox), 80 pidgin_status_box_set_connecting(PIDGIN_STATUS_BOX(gtkblist->statusbox),
81 (purple_connections_get_connecting() != NULL)); 81 (purple_connections_get_connecting() != NULL));
82 82
83 g_hash_table_remove(hash, account); 83 g_hash_table_remove(auto_reconns, account);
84 84
85 pidgin_blist_update_account_error_state(account, NULL); 85 pidgin_blist_update_account_error_state(account, NULL);
86 } 86 }
87 87
88 static void 88 static void
118 PidginAutoRecon *info; 118 PidginAutoRecon *info;
119 PurpleStatus *status; 119 PurpleStatus *status;
120 120
121 purple_debug_info("autorecon", "do_signon called\n"); 121 purple_debug_info("autorecon", "do_signon called\n");
122 g_return_val_if_fail(account != NULL, FALSE); 122 g_return_val_if_fail(account != NULL, FALSE);
123 info = g_hash_table_lookup(hash, account); 123 info = g_hash_table_lookup(auto_reconns, account);
124 124
125 if (info) 125 if (info)
126 info->timeout = 0; 126 info->timeout = 0;
127 127
128 status = purple_account_get_active_status(account); 128 status = purple_account_get_active_status(account);
141 { 141 {
142 PurpleAccount *account = NULL; 142 PurpleAccount *account = NULL;
143 PidginAutoRecon *info; 143 PidginAutoRecon *info;
144 144
145 account = purple_connection_get_account(gc); 145 account = purple_connection_get_account(gc);
146 info = g_hash_table_lookup(hash, account); 146 info = g_hash_table_lookup(auto_reconns, account);
147 147
148 pidgin_blist_update_account_error_state(account, text); 148 pidgin_blist_update_account_error_state(account, text);
149 if (!gc->wants_to_die) { 149 if (!gc->wants_to_die) {
150 if (info == NULL) { 150 if (info == NULL) {
151 info = g_new0(PidginAutoRecon, 1); 151 info = g_new0(PidginAutoRecon, 1);
152 g_hash_table_insert(hash, account, info); 152 g_hash_table_insert(auto_reconns, account, info);
153 info->delay = g_random_int_range(INITIAL_RECON_DELAY_MIN, INITIAL_RECON_DELAY_MAX); 153 info->delay = g_random_int_range(INITIAL_RECON_DELAY_MIN, INITIAL_RECON_DELAY_MAX);
154 } else { 154 } else {
155 info->delay = MIN(2 * info->delay, MAX_RECON_DELAY); 155 info->delay = MIN(2 * info->delay, MAX_RECON_DELAY);
156 if (info->timeout != 0) 156 if (info->timeout != 0)
157 g_source_remove(info->timeout); 157 g_source_remove(info->timeout);
158 } 158 }
159 info->timeout = g_timeout_add(info->delay, do_signon, account); 159 info->timeout = g_timeout_add(info->delay, do_signon, account);
160 } else { 160 } else {
161 char *p, *s, *n=NULL ; 161 char *p, *s, *n=NULL ;
162 if (info != NULL) 162 if (info != NULL)
163 g_hash_table_remove(hash, account); 163 g_hash_table_remove(auto_reconns, account);
164 164
165 if (purple_account_get_alias(account)) 165 if (purple_account_get_alias(account))
166 { 166 {
167 n = g_strdup_printf("%s (%s) (%s)", 167 n = g_strdup_printf("%s (%s) (%s)",
168 purple_account_get_username(account), 168 purple_account_get_username(account),
202 if(gtkblist) 202 if(gtkblist)
203 pidgin_status_box_set_network_available(PIDGIN_STATUS_BOX(gtkblist->statusbox), TRUE); 203 pidgin_status_box_set_network_available(PIDGIN_STATUS_BOX(gtkblist->statusbox), TRUE);
204 204
205 while (list) { 205 while (list) {
206 PurpleAccount *account = (PurpleAccount*)list->data; 206 PurpleAccount *account = (PurpleAccount*)list->data;
207 g_hash_table_remove(hash, account); 207 g_hash_table_remove(auto_reconns, account);
208 if (purple_account_is_disconnected(account)) 208 if (purple_account_is_disconnected(account))
209 do_signon(account); 209 do_signon(account);
210 list = list->next; 210 list = list->next;
211 } 211 }
212 } 212 }
263 } 263 }
264 264
265 static void 265 static void
266 account_removed_cb(PurpleAccount *account, gpointer user_data) 266 account_removed_cb(PurpleAccount *account, gpointer user_data)
267 { 267 {
268 g_hash_table_remove(hash, account); 268 g_hash_table_remove(auto_reconns, account);
269 269
270 pidgin_blist_update_account_error_state(account, NULL); 270 pidgin_blist_update_account_error_state(account, NULL);
271 } 271 }
272 272
273 273
284 } 284 }
285 285
286 void 286 void
287 pidgin_connection_init(void) 287 pidgin_connection_init(void)
288 { 288 {
289 hash = g_hash_table_new_full( 289 auto_reconns = g_hash_table_new_full(
290 g_direct_hash, g_direct_equal, 290 g_direct_hash, g_direct_equal,
291 NULL, free_auto_recon); 291 NULL, free_auto_recon);
292 292
293 purple_signal_connect(purple_accounts_get_handle(), "account-removed", 293 purple_signal_connect(purple_accounts_get_handle(), "account-removed",
294 pidgin_connection_get_handle(), 294 pidgin_connection_get_handle(),
298 void 298 void
299 pidgin_connection_uninit(void) 299 pidgin_connection_uninit(void)
300 { 300 {
301 purple_signals_disconnect_by_handle(pidgin_connection_get_handle()); 301 purple_signals_disconnect_by_handle(pidgin_connection_get_handle());
302 302
303 g_hash_table_destroy(hash); 303 g_hash_table_destroy(auto_reconns);
304 } 304 }