diff 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
line wrap: on
line diff
--- a/src/connection.c	Sat Mar 26 23:37:39 2005 +0000
+++ b/src/connection.c	Sun Mar 27 00:20:43 2005 +0000
@@ -117,48 +117,14 @@
 
 	g_return_if_fail(gc != NULL);
 
-	if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) {
-		gaim_connection_disconnect(gc);
-
-		return;
-	}
-
-	gaim_debug_info("connection", "Destroying connection %p\n", gc);
-
-	account = gaim_connection_get_account(gc);
-	gaim_account_set_connection(account, NULL);
-
-	if (gc->password != NULL)
-		g_free(gc->password);
-
-	if (gc->display_name != NULL)
-		g_free(gc->display_name);
-
-	if (gc->disconnect_timeout)
-		gaim_timeout_remove(gc->disconnect_timeout);
-
-	g_free(gc);
-}
-
-void
-gaim_connection_disconnect(GaimConnection *gc)
-{
-	GaimAccount *account;
-	GList *wins;
-	GaimPresence *presence = NULL;
-
-	g_return_if_fail(gc != NULL);
-
 	account = gaim_connection_get_account(gc);
 
-	if (!account->disconnecting) {
-		gaim_account_disconnect(account);
-		return;
-	}
+	if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) {
+		GList *wins;
+		GaimPresence *presence = NULL;
 
-	gaim_debug_info("connection", "Disconnecting connection %p\n", gc);
+		gaim_debug_info("connection", "Disconnecting connection %p\n", gc);
 
-	if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) {
 		if (gaim_connection_get_state(gc) != GAIM_CONNECTING)
 			gaim_blist_remove_account(gaim_connection_get_account(gc));
 
@@ -190,19 +156,24 @@
 
 		gaim_request_close_with_handle(gc);
 		gaim_notify_close_with_handle(gc);
+
+		return;
 	}
 
-	gaim_connection_destroy(gc);
-}
+	gaim_debug_info("connection", "Destroying connection %p\n", gc);
+
+	gaim_account_set_connection(account, NULL);
+
+	if (gc->password != NULL)
+		g_free(gc->password);
 
-gboolean
-gaim_connection_disconnect_cb(gpointer data)
-{
-	GaimAccount *account = data;
+	if (gc->display_name != NULL)
+		g_free(gc->display_name);
 
-	gaim_account_disconnect(account);
+	if (gc->disconnect_timeout)
+		gaim_timeout_remove(gc->disconnect_timeout);
 
-	return FALSE;
+	g_free(gc);
 }
 
 /*
@@ -410,6 +381,16 @@
 		ops->notice(gc, text);
 }
 
+gboolean
+gaim_connection_disconnect_cb(gpointer data)
+{
+	GaimAccount *account = data;
+
+	gaim_account_disconnect(account);
+
+	return FALSE;
+}
+
 void
 gaim_connection_error(GaimConnection *gc, const char *text)
 {
@@ -442,7 +423,7 @@
 	while ((l = gaim_connections_get_all()) != NULL) {
 		gc = l->data;
 		gc->wants_to_die = TRUE;
-		gaim_connection_destroy(gc);
+		gaim_account_disconnect(gc->account);
 	}
 }