void purple_connection_set_state(PurpleConnection *gc, PurpleConnectionState state) { PurpleConnectionUiOps *ops; g_return_if_fail(gc != NULL); if (gc->state == state) return; gc->state = state; ops = purple_connections_get_ui_ops(); if (gc->state == PURPLE_CONNECTING) { connections_connecting = g_list_append(connections_connecting, gc); } else { connections_connecting = g_list_remove(connections_connecting, gc); } if (gc->state == PURPLE_CONNECTED) { PurpleAccount *account; PurplePresence *presence; account = purple_connection_get_account(gc); presence = purple_account_get_presence(account); /* Set the time the account came online */ purple_presence_set_login_time(presence, time(NULL)); #if 0 if (purple_prefs_get_bool("/purple/logging/log_system")) { PurpleLog *log = purple_account_get_log(account, TRUE); if (log != NULL) { char *msg = g_strdup_printf(_("+++ %s signed on"), purple_account_get_username(account)); purple_log_write(log, PURPLE_MESSAGE_SYSTEM, purple_account_get_username(account), purple_presence_get_login_time(presence), msg); g_free(msg); } } #endif if (ops != NULL && ops->connected != NULL) ops->connected(gc); purple_blist_add_account(account); purple_signal_emit(purple_connections_get_handle(), "signed-on", gc); purple_signal_emit_return_1(purple_connections_get_handle(), "autojoin", gc); serv_set_permit_deny(gc); update_keepalive(gc, TRUE); } else if (gc->state == PURPLE_DISCONNECTED) { PurpleAccount *account = purple_connection_get_account(gc); #if 0 if (purple_prefs_get_bool("/purple/logging/log_system")) { PurpleLog *log = purple_account_get_log(account, FALSE); if (log != NULL) { char *msg = g_strdup_printf(_("+++ %s signed off"), purple_account_get_username(account)); purple_log_write(log, PURPLE_MESSAGE_SYSTEM, purple_account_get_username(account), time(NULL), msg); g_free(msg); } } purple_account_destroy_log(account); #endif if (ops != NULL && ops->disconnected != NULL) ops->disconnected(gc); } }
void gaim_connection_set_state(GaimConnection *gc, GaimConnectionState state) { GaimConnectionUiOps *ops; g_return_if_fail(gc != NULL); if (gc->state == state) return; gc->state = state; ops = gaim_connections_get_ui_ops(); if (gc->state == GAIM_CONNECTING) { connections_connecting = g_list_append(connections_connecting, gc); } else { connections_connecting = g_list_remove(connections_connecting, gc); } if (gc->state == GAIM_CONNECTED) { GaimAccount *account; GaimPresence *presence; account = gaim_connection_get_account(gc); presence = gaim_account_get_presence(account); /* Set the time the account came online */ gaim_presence_set_login_time(presence, time(NULL)); if (gaim_prefs_get_bool("/core/logging/log_system")) { GaimLog *log = gaim_account_get_log(account, TRUE); if (log != NULL) { char *msg = g_strdup_printf(_("+++ %s signed on"), gaim_account_get_username(account)); gaim_log_write(log, GAIM_MESSAGE_SYSTEM, gaim_account_get_username(account), gaim_presence_get_login_time(presence), msg); g_free(msg); } } if (ops != NULL && ops->connected != NULL) ops->connected(gc); gaim_blist_add_account(account); gaim_signal_emit(gaim_connections_get_handle(), "signed-on", gc); serv_set_permit_deny(gc); update_keepalive(gc, TRUE); } else if (gc->state == GAIM_DISCONNECTED) { GaimAccount *account = gaim_connection_get_account(gc); if (gaim_prefs_get_bool("/core/logging/log_system")) { GaimLog *log = gaim_account_get_log(account, FALSE); if (log != NULL) { char *msg = g_strdup_printf(_("+++ %s signed off"), gaim_account_get_username(account)); gaim_log_write(log, GAIM_MESSAGE_SYSTEM, gaim_account_get_username(account), time(NULL), msg); g_free(msg); } } gaim_account_destroy_log(account); if (ops != NULL && ops->disconnected != NULL) ops->disconnected(gc); } }
void _purple_connection_destroy(PurpleConnection *gc) { PurpleAccount *account; GSList *buddies; PurplePluginProtocolInfo *prpl_info = NULL; gboolean remove = FALSE; g_return_if_fail(gc != NULL); account = purple_connection_get_account(gc); purple_debug_info("connection", "Disconnecting connection %p\n", gc); if (purple_connection_get_state(gc) != PURPLE_CONNECTING) remove = TRUE; purple_signal_emit(purple_connections_get_handle(), "signing-off", gc); while (gc->buddy_chats) { PurpleConversation *b = gc->buddy_chats->data; gc->buddy_chats = g_slist_remove(gc->buddy_chats, b); purple_conv_chat_left(PURPLE_CONV_CHAT(b)); } update_keepalive(gc, FALSE); purple_proxy_connect_cancel_with_handle(gc); prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); if (prpl_info->close) (prpl_info->close)(gc); /* Clear out the proto data that was freed in the prpl close method*/ buddies = purple_find_buddies(account, NULL); while (buddies != NULL) { PurpleBuddy *buddy = buddies->data; purple_buddy_set_protocol_data(buddy, NULL); buddies = g_slist_delete_link(buddies, buddies); } connections = g_list_remove(connections, gc); purple_connection_set_state(gc, PURPLE_DISCONNECTED); if (remove) purple_blist_remove_account(account); purple_signal_emit(purple_connections_get_handle(), "signed-off", gc); purple_account_request_close_with_account(account); purple_request_close_with_handle(gc); purple_notify_close_with_handle(gc); purple_debug_info("connection", "Destroying connection %p\n", gc); purple_account_set_connection(account, NULL); g_free(gc->password); g_free(gc->display_name); if (gc->disconnect_timeout > 0) purple_timeout_remove(gc->disconnect_timeout); PURPLE_DBUS_UNREGISTER_POINTER(gc); g_free(gc); }
void gaim_connection_destroy(GaimConnection *gc) { GaimAccount *account; GSList *buddies, *tmp; #if 0 GList *wins; #endif GaimPluginProtocolInfo *prpl_info = NULL; gboolean remove = FALSE; g_return_if_fail(gc != NULL); account = gaim_connection_get_account(gc); gaim_debug_info("connection", "Disconnecting connection %p\n", gc); if (gaim_connection_get_state(gc) != GAIM_CONNECTING) remove = TRUE; gaim_signal_emit(gaim_connections_get_handle(), "signing-off", gc); while (gc->buddy_chats) { GaimConversation *b = gc->buddy_chats->data; gc->buddy_chats = g_slist_remove(gc->buddy_chats, b); gaim_conv_chat_left(GAIM_CONV_CHAT(b)); } update_keepalive(gc, FALSE); gaim_proxy_connect_cancel_with_handle(gc); prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); if (prpl_info->close) (prpl_info->close)(gc); /* Clear out the proto data that was freed in the prpl close method*/ buddies = gaim_find_buddies(account, NULL); for (tmp = buddies; tmp; tmp = tmp->next) { GaimBuddy *buddy = tmp->data; buddy->proto_data = NULL; } g_slist_free(buddies); connections = g_list_remove(connections, gc); gaim_connection_set_state(gc, GAIM_DISCONNECTED); if (remove) gaim_blist_remove_account(account); gaim_signal_emit(gaim_connections_get_handle(), "signed-off", gc); #if 0 /* see comment later in file on if 0'd same code */ /* * XXX This is a hack! Remove this and replace it with a better event * notification system. */ for (wins = gaim_get_windows(); wins != NULL; wins = wins->next) { GaimConvWindow *win = (GaimConvWindow *)wins->data; gaim_conversation_update(gaim_conv_window_get_conversation_at(win, 0), GAIM_CONV_ACCOUNT_OFFLINE); } #endif gaim_request_close_with_handle(gc); gaim_notify_close_with_handle(gc); gaim_debug_info("connection", "Destroying connection %p\n", gc); gaim_account_set_connection(account, NULL); g_free(gc->password); g_free(gc->display_name); if (gc->disconnect_timeout) gaim_timeout_remove(gc->disconnect_timeout); GAIM_DBUS_UNREGISTER_POINTER(gc); g_free(gc); }