Mercurial > pidgin
comparison src/connection.c @ 10742:4228b6d78506
[gaim-migrate @ 12344]
Combine gaim_connection_destroy and gaim_connection_disconnect
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 27 Mar 2005 00:20:43 +0000 |
parents | 94cc67130789 |
children | ca69d597a5e2 |
comparison
equal
deleted
inserted
replaced
10741:2f5d99f963eb | 10742:4228b6d78506 |
---|---|
115 { | 115 { |
116 GaimAccount *account; | 116 GaimAccount *account; |
117 | 117 |
118 g_return_if_fail(gc != NULL); | 118 g_return_if_fail(gc != NULL); |
119 | 119 |
120 account = gaim_connection_get_account(gc); | |
121 | |
120 if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) { | 122 if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) { |
121 gaim_connection_disconnect(gc); | 123 GList *wins; |
122 | 124 GaimPresence *presence = NULL; |
123 return; | 125 |
124 } | 126 gaim_debug_info("connection", "Disconnecting connection %p\n", gc); |
125 | 127 |
126 gaim_debug_info("connection", "Destroying connection %p\n", gc); | |
127 | |
128 account = gaim_connection_get_account(gc); | |
129 gaim_account_set_connection(account, NULL); | |
130 | |
131 if (gc->password != NULL) | |
132 g_free(gc->password); | |
133 | |
134 if (gc->display_name != NULL) | |
135 g_free(gc->display_name); | |
136 | |
137 if (gc->disconnect_timeout) | |
138 gaim_timeout_remove(gc->disconnect_timeout); | |
139 | |
140 g_free(gc); | |
141 } | |
142 | |
143 void | |
144 gaim_connection_disconnect(GaimConnection *gc) | |
145 { | |
146 GaimAccount *account; | |
147 GList *wins; | |
148 GaimPresence *presence = NULL; | |
149 | |
150 g_return_if_fail(gc != NULL); | |
151 | |
152 account = gaim_connection_get_account(gc); | |
153 | |
154 if (!account->disconnecting) { | |
155 gaim_account_disconnect(account); | |
156 return; | |
157 } | |
158 | |
159 gaim_debug_info("connection", "Disconnecting connection %p\n", gc); | |
160 | |
161 if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) { | |
162 if (gaim_connection_get_state(gc) != GAIM_CONNECTING) | 128 if (gaim_connection_get_state(gc) != GAIM_CONNECTING) |
163 gaim_blist_remove_account(gaim_connection_get_account(gc)); | 129 gaim_blist_remove_account(gaim_connection_get_account(gc)); |
164 | 130 |
165 gaim_signal_emit(gaim_connections_get_handle(), "signing-off", gc); | 131 gaim_signal_emit(gaim_connections_get_handle(), "signing-off", gc); |
166 | 132 |
188 GAIM_CONV_ACCOUNT_OFFLINE); | 154 GAIM_CONV_ACCOUNT_OFFLINE); |
189 } | 155 } |
190 | 156 |
191 gaim_request_close_with_handle(gc); | 157 gaim_request_close_with_handle(gc); |
192 gaim_notify_close_with_handle(gc); | 158 gaim_notify_close_with_handle(gc); |
193 } | 159 |
194 | 160 return; |
195 gaim_connection_destroy(gc); | 161 } |
196 } | 162 |
197 | 163 gaim_debug_info("connection", "Destroying connection %p\n", gc); |
198 gboolean | 164 |
199 gaim_connection_disconnect_cb(gpointer data) | 165 gaim_account_set_connection(account, NULL); |
200 { | 166 |
201 GaimAccount *account = data; | 167 if (gc->password != NULL) |
202 | 168 g_free(gc->password); |
203 gaim_account_disconnect(account); | 169 |
204 | 170 if (gc->display_name != NULL) |
205 return FALSE; | 171 g_free(gc->display_name); |
172 | |
173 if (gc->disconnect_timeout) | |
174 gaim_timeout_remove(gc->disconnect_timeout); | |
175 | |
176 g_free(gc); | |
206 } | 177 } |
207 | 178 |
208 /* | 179 /* |
209 * d:)->-< | 180 * d:)->-< |
210 * | 181 * |
408 | 379 |
409 if (ops != NULL && ops->notice != NULL) | 380 if (ops != NULL && ops->notice != NULL) |
410 ops->notice(gc, text); | 381 ops->notice(gc, text); |
411 } | 382 } |
412 | 383 |
384 gboolean | |
385 gaim_connection_disconnect_cb(gpointer data) | |
386 { | |
387 GaimAccount *account = data; | |
388 | |
389 gaim_account_disconnect(account); | |
390 | |
391 return FALSE; | |
392 } | |
393 | |
413 void | 394 void |
414 gaim_connection_error(GaimConnection *gc, const char *text) | 395 gaim_connection_error(GaimConnection *gc, const char *text) |
415 { | 396 { |
416 GaimConnectionUiOps *ops; | 397 GaimConnectionUiOps *ops; |
417 | 398 |
440 GaimConnection *gc; | 421 GaimConnection *gc; |
441 | 422 |
442 while ((l = gaim_connections_get_all()) != NULL) { | 423 while ((l = gaim_connections_get_all()) != NULL) { |
443 gc = l->data; | 424 gc = l->data; |
444 gc->wants_to_die = TRUE; | 425 gc->wants_to_die = TRUE; |
445 gaim_connection_destroy(gc); | 426 gaim_account_disconnect(gc->account); |
446 } | 427 } |
447 } | 428 } |
448 | 429 |
449 GList * | 430 GList * |
450 gaim_connections_get_all(void) | 431 gaim_connections_get_all(void) |