Mercurial > pidgin
comparison src/connection.c @ 10754:8a97b59f0071
[gaim-migrate @ 12357]
Some fairly clutch changes to how accounts set their statuses. This
gets rid of a lot of those g_assertion warnings.
My Girlfriend: Dad, why do we have so many forks?
Her Dad: Well, it's like the lord said, "Go fork and multiply."
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Sun, 27 Mar 2005 19:12:52 +0000 |
| parents | bf5e48215158 |
| children | fffc664d5294 |
comparison
equal
deleted
inserted
replaced
| 10753:b40a67d45dbb | 10754:8a97b59f0071 |
|---|---|
| 145 | 145 |
| 146 void | 146 void |
| 147 gaim_connection_destroy(GaimConnection *gc) | 147 gaim_connection_destroy(GaimConnection *gc) |
| 148 { | 148 { |
| 149 GaimAccount *account; | 149 GaimAccount *account; |
| 150 GList *wins; | |
| 151 GaimPresence *presence = NULL; | |
| 152 GaimPluginProtocolInfo *prpl_info = NULL; | |
| 150 | 153 |
| 151 g_return_if_fail(gc != NULL); | 154 g_return_if_fail(gc != NULL); |
| 152 | 155 |
| 153 account = gaim_connection_get_account(gc); | 156 account = gaim_connection_get_account(gc); |
| 154 | 157 |
| 155 if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) | 158 gaim_debug_info("connection", "Disconnecting connection %p\n", gc); |
| 156 { | 159 |
| 157 GList *wins; | 160 if (gaim_connection_get_state(gc) != GAIM_CONNECTING) |
| 158 GaimPresence *presence = NULL; | 161 gaim_blist_remove_account(account); |
| 159 GaimPluginProtocolInfo *prpl_info = NULL; | 162 |
| 160 | 163 gaim_signal_emit(gaim_connections_get_handle(), "signing-off", gc); |
| 161 gaim_debug_info("connection", "Disconnecting connection %p\n", gc); | 164 |
| 162 | 165 while (gc->buddy_chats) |
| 163 if (gaim_connection_get_state(gc) != GAIM_CONNECTING) | 166 { |
| 164 gaim_blist_remove_account(account); | 167 GaimConversation *b = gc->buddy_chats->data; |
| 165 | 168 |
| 166 gaim_signal_emit(gaim_connections_get_handle(), "signing-off", gc); | 169 gc->buddy_chats = g_slist_remove(gc->buddy_chats, b); |
| 167 | 170 gaim_conv_chat_left(GAIM_CONV_CHAT(b)); |
| 168 while (gc->buddy_chats) | 171 } |
| 169 { | 172 |
| 170 GaimConversation *b = gc->buddy_chats->data; | 173 if (gc->idle_timer > 0) |
| 171 | 174 gaim_timeout_remove(gc->idle_timer); |
| 172 gc->buddy_chats = g_slist_remove(gc->buddy_chats, b); | 175 gc->idle_timer = 0; |
| 173 gaim_conv_chat_left(GAIM_CONV_CHAT(b)); | 176 |
| 174 } | 177 update_keepalive(gc, FALSE); |
| 175 | 178 |
| 176 if (gc->idle_timer > 0) | 179 if (gc->prpl != NULL) |
| 177 gaim_timeout_remove(gc->idle_timer); | 180 { |
| 178 gc->idle_timer = 0; | 181 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
| 179 | 182 |
| 180 update_keepalive(gc, FALSE); | 183 if (prpl_info->close) |
| 181 | 184 (prpl_info->close)(gc); |
| 182 if (gc->prpl != NULL) | 185 } |
| 183 { | 186 |
| 184 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | 187 connections = g_list_remove(connections, gc); |
| 185 | 188 |
| 186 if (prpl_info->close) | 189 gaim_connection_set_state(gc, GAIM_DISCONNECTED); |
| 187 (prpl_info->close)(gc); | 190 |
| 188 } | 191 /* LOG system_log(log_signoff, gc, NULL, |
| 189 | 192 OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); */ |
| 190 connections = g_list_remove(connections, gc); | 193 gaim_signal_emit(gaim_connections_get_handle(), "signed-off", gc); |
| 191 | 194 |
| 192 gaim_connection_set_state(gc, GAIM_DISCONNECTED); | 195 presence = gaim_account_get_presence(account); |
| 193 | 196 if (gaim_presence_is_online(presence) == TRUE) |
| 194 /* LOG system_log(log_signoff, gc, NULL, | 197 gaim_presence_set_status_active(presence, "offline", TRUE); |
| 195 OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); */ | 198 |
| 196 gaim_signal_emit(gaim_connections_get_handle(), "signed-off", gc); | 199 /* |
| 197 | 200 * XXX This is a hack! Remove this and replace it with a better event |
| 198 presence = gaim_account_get_presence(account); | 201 * notification system. |
| 199 if (gaim_presence_is_online(presence) == TRUE) | 202 */ |
| 200 gaim_presence_set_status_active(presence, "offline", TRUE); | 203 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { |
| 201 | 204 GaimConvWindow *win = (GaimConvWindow *)wins->data; |
| 202 /* | 205 gaim_conversation_update(gaim_conv_window_get_conversation_at(win, 0), |
| 203 * XXX This is a hack! Remove this and replace it with a better event | 206 GAIM_CONV_ACCOUNT_OFFLINE); |
| 204 * notification system. | 207 } |
| 205 */ | 208 |
| 206 for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { | 209 gaim_request_close_with_handle(gc); |
| 207 GaimConvWindow *win = (GaimConvWindow *)wins->data; | 210 gaim_notify_close_with_handle(gc); |
| 208 gaim_conversation_update(gaim_conv_window_get_conversation_at(win, 0), | |
| 209 GAIM_CONV_ACCOUNT_OFFLINE); | |
| 210 } | |
| 211 | |
| 212 gaim_request_close_with_handle(gc); | |
| 213 gaim_notify_close_with_handle(gc); | |
| 214 | |
| 215 return; | |
| 216 } | |
| 217 | 211 |
| 218 gaim_debug_info("connection", "Destroying connection %p\n", gc); | 212 gaim_debug_info("connection", "Destroying connection %p\n", gc); |
| 219 | 213 |
| 220 gaim_account_set_connection(account, NULL); | 214 gaim_account_set_connection(account, NULL); |
| 221 | 215 |
