# HG changeset patch
# Node ID 5e23dfe98f10
# Parent  f4ac61968453
diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -416,11 +416,13 @@
 {
 	PurpleConnection *gc;
 
-	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), PURPLE_CONNECTION_DISCONNECTED);
+	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account),
+	                     PURPLE_CONNECTION_STATE_DISCONNECTED);
 
 	gc = purple_account_get_connection(account);
-	if (!gc)
-		return PURPLE_CONNECTION_DISCONNECTED;
+	if(!gc) {
+		return PURPLE_CONNECTION_STATE_DISCONNECTED;
+	}
 
 	return purple_connection_get_state(gc);
 }
@@ -1645,19 +1647,19 @@
 gboolean
 purple_account_is_connected(PurpleAccount *account)
 {
-	return (purple_account_get_state(account) == PURPLE_CONNECTION_CONNECTED);
+	return (purple_account_get_state(account) == PURPLE_CONNECTION_STATE_CONNECTED);
 }
 
 gboolean
 purple_account_is_connecting(PurpleAccount *account)
 {
-	return (purple_account_get_state(account) == PURPLE_CONNECTION_CONNECTING);
+	return (purple_account_get_state(account) == PURPLE_CONNECTION_STATE_CONNECTING);
 }
 
 gboolean
 purple_account_is_disconnected(PurpleAccount *account)
 {
-	return (purple_account_get_state(account) == PURPLE_CONNECTION_DISCONNECTED);
+	return (purple_account_get_state(account) == PURPLE_CONNECTION_STATE_DISCONNECTED);
 }
 
 const char *
diff --git a/libpurple/buddylist.c b/libpurple/buddylist.c
--- a/libpurple/buddylist.c
+++ b/libpurple/buddylist.c
@@ -1627,8 +1627,9 @@
 	{
 		PurpleConnection *gc = (PurpleConnection *)l->data;
 
-		if (purple_connection_get_state(gc) == PURPLE_CONNECTION_CONNECTED)
+		if(purple_connection_get_state(gc) == PURPLE_CONNECTION_STATE_CONNECTED) {
 			purple_account_remove_group(purple_connection_get_account(gc), group);
+		}
 	}
 
 	/* Delete the node */
diff --git a/libpurple/connection.h b/libpurple/connection.h
--- a/libpurple/connection.h
+++ b/libpurple/connection.h
@@ -82,15 +82,18 @@
 
 /**
  * PurpleConnectionState:
- * @PURPLE_CONNECTION_DISCONNECTED: Disconnected.
- * @PURPLE_CONNECTION_CONNECTED:    Connected.
- * @PURPLE_CONNECTION_CONNECTING:   Connecting.
+ * @PURPLE_CONNECTION_STATE_DISCONNECTED: Disconnected
+ * @PURPLE_CONNECTION_STATE_DISCONNECTING: Disconnecting
+ * @PURPLE_CONNECTION_STATE_CONNECTED: Connected
+ * @PURPLE_CONNECTION_STATE_CONNECTING: Connecting
+ *
+ * A representation of the state of a [class@Purple.Connection].
  */
-typedef enum
-{
-	PURPLE_CONNECTION_DISCONNECTED = 0,
-	PURPLE_CONNECTION_CONNECTED,
-	PURPLE_CONNECTION_CONNECTING
+typedef enum {
+	PURPLE_CONNECTION_STATE_DISCONNECTED = 0,
+	PURPLE_CONNECTION_STATE_DISCONNECTING,
+	PURPLE_CONNECTION_STATE_CONNECTED,
+	PURPLE_CONNECTION_STATE_CONNECTING
 } PurpleConnectionState;
 
 /**
@@ -250,7 +253,7 @@
  * Returns: TRUE if the account is connected, otherwise returns FALSE.
  */
 #define PURPLE_CONNECTION_IS_CONNECTED(gc) \
-	(purple_connection_get_state(gc) == PURPLE_CONNECTION_CONNECTED)
+	(purple_connection_get_state(gc) == PURPLE_CONNECTION_STATE_CONNECTED)
 
 /**
  * purple_connection_new:
@@ -267,17 +270,6 @@
 PurpleConnection *purple_connection_new(PurpleProtocol *protocol, PurpleAccount *account, const char *password);
 
 /**
- * purple_connection_is_disconnecting:
- * @gc: The connection.
- *
- * Checks, if connection is in disconnecting state.
- *
- * Returns: %TRUE, if the account is disconnecting.
- */
-gboolean
-purple_connection_is_disconnecting(PurpleConnection *gc);
-
-/**
  * purple_connection_get_id:
  * @connection: The connection.
  *
diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -179,7 +179,7 @@
 
 	ops = purple_connections_get_ui_ops();
 
-	if(priv->state == PURPLE_CONNECTION_CONNECTED) {
+	if(priv->state == PURPLE_CONNECTION_STATE_CONNECTED) {
 		PurplePresence *presence;
 		gboolean emit_online = FALSE;
 		gpointer handle = NULL;
@@ -221,7 +221,7 @@
 		if(emit_online) {
 			purple_signal_emit(handle, "online");
 		}
-	} else if(priv->state == PURPLE_CONNECTION_DISCONNECTED) {
+	} else if(priv->state == PURPLE_CONNECTION_STATE_DISCONNECTED) {
 		if(ops != NULL && ops->disconnected != NULL) {
 			ops->disconnected(connection);
 		}
@@ -280,7 +280,7 @@
 	PurpleConnectionPrivate *priv = NULL;
 
 	g_return_val_if_fail(PURPLE_IS_CONNECTION(connection),
-	                     PURPLE_CONNECTION_DISCONNECTED);
+	                     PURPLE_CONNECTION_STATE_DISCONNECTED);
 
 	priv = purple_connection_get_instance_private(connection);
 
@@ -298,17 +298,6 @@
 	return priv->flags;
 }
 
-gboolean
-purple_connection_is_disconnecting(PurpleConnection *connection) {
-	PurpleConnectionPrivate *priv = NULL;
-
-	g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), TRUE);
-
-	priv = purple_connection_get_instance_private(connection);
-
-	return priv->is_finalizing;
-}
-
 PurpleAccount *
 purple_connection_get_account(PurpleConnection *connection) {
 	PurpleConnectionPrivate *priv = NULL;
@@ -737,7 +726,7 @@
 
 static void
 purple_connection_init(PurpleConnection *connection) {
-	purple_connection_set_state(connection, PURPLE_CONNECTION_CONNECTING);
+	purple_connection_set_state(connection, PURPLE_CONNECTION_STATE_CONNECTING);
 	connections = g_list_append(connections, connection);
 }
 
@@ -780,7 +769,7 @@
 
 	purple_debug_info("connection", "Disconnecting connection %p", connection);
 
-	if(priv->state != PURPLE_CONNECTION_CONNECTING) {
+	if(priv->state != PURPLE_CONNECTION_STATE_CONNECTING) {
 		remove = TRUE;
 	}
 
@@ -803,7 +792,7 @@
 
 	connections = g_list_remove(connections, connection);
 
-	purple_connection_set_state(connection, PURPLE_CONNECTION_DISCONNECTED);
+	purple_connection_set_state(connection, PURPLE_CONNECTION_STATE_DISCONNECTED);
 
 	if(remove) {
 		purple_blist_remove_account(priv->account);
@@ -867,7 +856,7 @@
 	properties[PROP_STATE] = g_param_spec_enum(
 		"state", "Connection state",
 		"The current state of the connection.",
-		PURPLE_TYPE_CONNECTION_STATE, PURPLE_CONNECTION_DISCONNECTED,
+		PURPLE_TYPE_CONNECTION_STATE, PURPLE_CONNECTION_STATE_DISCONNECTED,
 		G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
 
 	properties[PROP_ACCOUNT] = g_param_spec_object(
diff --git a/libpurple/protocols/bonjour/bonjour.c b/libpurple/protocols/bonjour/bonjour.c
--- a/libpurple/protocols/bonjour/bonjour.c
+++ b/libpurple/protocols/bonjour/bonjour.c
@@ -161,7 +161,7 @@
 	bonjour_dns_sd_update_buddy_icon(bd->dns_sd_data);
 
 	/* Show the buddy list by telling Purple we have already connected */
-	purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED);
+	purple_connection_set_state(gc, PURPLE_CONNECTION_STATE_CONNECTED);
 
 	return gc;
 }
diff --git a/libpurple/protocols/demo/purpledemoprotocol.c b/libpurple/protocols/demo/purpledemoprotocol.c
--- a/libpurple/protocols/demo/purpledemoprotocol.c
+++ b/libpurple/protocols/demo/purpledemoprotocol.c
@@ -43,7 +43,7 @@
 
 	connection = purple_connection_new(protocol, account, password);
 
-	purple_connection_set_state(connection, PURPLE_CONNECTION_CONNECTED);
+	purple_connection_set_state(connection, PURPLE_CONNECTION_STATE_CONNECTED);
 
 	purple_demo_contacts_load(account);
 
diff --git a/libpurple/protocols/facebook/facebook.c b/libpurple/protocols/facebook/facebook.c
--- a/libpurple/protocols/facebook/facebook.c
+++ b/libpurple/protocols/facebook/facebook.c
@@ -116,7 +116,7 @@
 	acct = purple_connection_get_account(gc);
 
 	fb_data_save(fata);
-	purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED);
+	purple_connection_set_state(gc, PURPLE_CONNECTION_STATE_CONNECTED);
 
 	if (purple_account_get_bool(acct, "show-unread", TRUE)) {
 		fb_api_unread(api);
@@ -286,7 +286,7 @@
 		return;
 	}
 
-	if (state != PURPLE_CONNECTION_CONNECTED) {
+	if (state != PURPLE_CONNECTION_STATE_CONNECTED) {
 		status = purple_account_get_active_status(acct);
 		type = purple_status_get_status_type(status);
 		pstat = purple_status_type_get_primitive(type);
diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -531,7 +531,7 @@
 					PURPLE_INPUT_READ,
 					ggp_callback_recv, gc);
 
-				purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED);
+				purple_connection_set_state(gc, PURPLE_CONNECTION_STATE_CONNECTED);
 
 				ggp_buddylist_send(gc);
 				ggp_roster_request_update(gc);
diff --git a/libpurple/protocols/gg/tcpsocket.c b/libpurple/protocols/gg/tcpsocket.c
--- a/libpurple/protocols/gg/tcpsocket.c
+++ b/libpurple/protocols/gg/tcpsocket.c
@@ -139,7 +139,6 @@
 	GError *error = NULL;
 
 	PURPLE_ASSERT_CONNECTION_IS_VALID(gc);
-	g_return_val_if_fail(!purple_connection_is_disconnecting(gc), NULL);
 
 	g_return_val_if_fail(host != NULL, NULL);
 	g_return_val_if_fail(is_async, NULL);
diff --git a/libpurple/protocols/irc/msgs.c b/libpurple/protocols/irc/msgs.c
--- a/libpurple/protocols/irc/msgs.c
+++ b/libpurple/protocols/irc/msgs.c
@@ -93,7 +93,7 @@
 		return;
 
 	purple_connection_set_display_name(gc, nick);
-	purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED);
+	purple_connection_set_state(gc, PURPLE_CONNECTION_STATE_CONNECTED);
 	account = purple_connection_get_account(gc);
 
 	/* If we're away then set our away message */
@@ -1186,7 +1186,7 @@
 void irc_msg_badnick(struct irc_conn *irc, const char *name, const char *from, char **args)
 {
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
-	if (purple_connection_get_state(gc) == PURPLE_CONNECTION_CONNECTED) {
+	if (purple_connection_get_state(gc) == PURPLE_CONNECTION_STATE_CONNECTED) {
 		purple_notify_error(gc, _("Invalid nickname"), _("Invalid "
 			"nickname"), _("Your selected nickname was rejected by "
 			"the server.  It probably contains invalid characters."),
@@ -1205,7 +1205,7 @@
 	char *newnick, *buf, *end;
 	PurpleConnection *gc = purple_account_get_connection(irc->account);
 
-	if (gc && purple_connection_get_state(gc) == PURPLE_CONNECTION_CONNECTED) {
+	if (gc && purple_connection_get_state(gc) == PURPLE_CONNECTION_STATE_CONNECTED) {
 		/* We only want to do the following dance if the connection
 		   has not been successfully completed.  If it has, just
 		   notify the user that their /nick command didn't go. */
diff --git a/libpurple/protocols/ircv3/purpleircv3connection.c b/libpurple/protocols/ircv3/purpleircv3connection.c
--- a/libpurple/protocols/ircv3/purpleircv3connection.c
+++ b/libpurple/protocols/ircv3/purpleircv3connection.c
@@ -180,7 +180,7 @@
 	}
 
 	purple_connection_set_state(PURPLE_CONNECTION(connection),
-	                            PURPLE_CONNECTION_CONNECTED);
+	                            PURPLE_CONNECTION_STATE_CONNECTED);
 
 	g_message("Successfully connected to %s", connection->server_name);
 
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -1293,7 +1293,7 @@
 
 	if(js->registration) {
 		/* get rid of the login thingy */
-		purple_connection_set_state(js->gc, PURPLE_CONNECTION_CONNECTED);
+		purple_connection_set_state(js->gc, PURPLE_CONNECTION_STATE_CONNECTED);
 	}
 
 	if(purple_xmlnode_get_child(query, "registered")) {
@@ -1498,7 +1498,7 @@
 	PurpleConnection *gc = purple_account_get_connection(account);
 	JabberStream *js;
 
-	if (purple_connection_get_state(gc) != PURPLE_CONNECTION_CONNECTED) {
+	if (purple_connection_get_state(gc) != PURPLE_CONNECTION_STATE_CONNECTED) {
 		#warning fix registration and unregistration
 		#if 0
 		if (purple_connection_get_state(gc) != PURPLE_CONNECTION_CONNECTING) {
@@ -1646,7 +1646,7 @@
 		/* Start up the inactivity timer */
 		jabber_stream_restart_inactivity_timer(js);
 
-		purple_connection_set_state(js->gc, PURPLE_CONNECTION_CONNECTED);
+		purple_connection_set_state(js->gc, PURPLE_CONNECTION_STATE_CONNECTED);
 	}
 }
 
diff --git a/libpurple/protocols/novell/novell.c b/libpurple/protocols/novell/novell.c
--- a/libpurple/protocols/novell/novell.c
+++ b/libpurple/protocols/novell/novell.c
@@ -114,7 +114,7 @@
 		}
 
 		/* Tell Purple that we are connected */
-		purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED);
+		purple_connection_set_state(gc, PURPLE_CONNECTION_STATE_CONNECTED);
 
 		_sync_contact_list(user);
 
diff --git a/libpurple/protocols/sametime/sametime.c b/libpurple/protocols/sametime/sametime.c
--- a/libpurple/protocols/sametime/sametime.c
+++ b/libpurple/protocols/sametime/sametime.c
@@ -1480,7 +1480,7 @@
   case mwSession_STARTED:
     session_started(pd);
 
-    purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED);
+    purple_connection_set_state(gc, PURPLE_CONNECTION_STATE_CONNECTED);
     break;
 
   case mwSession_STOPPING:
diff --git a/libpurple/protocols/silc/silc.c b/libpurple/protocols/silc/silc.c
--- a/libpurple/protocols/silc/silc.c
+++ b/libpurple/protocols/silc/silc.c
@@ -272,7 +272,7 @@
 		sg->conn = conn;
 
 		/* Connection created successfully */
-		purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED);
+		purple_connection_set_state(gc, PURPLE_CONNECTION_STATE_CONNECTED);
 
 		/* Send the server our buddy list */
 		silcpurple_send_buddylist(gc);
diff --git a/libpurple/protocols/zephyr/zephyr.c b/libpurple/protocols/zephyr/zephyr.c
--- a/libpurple/protocols/zephyr/zephyr.c
+++ b/libpurple/protocols/zephyr/zephyr.c
@@ -744,7 +744,7 @@
 		return gc;
 	}
 
-	purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED);
+	purple_connection_set_state(gc, PURPLE_CONNECTION_STATE_CONNECTED);
 
 	if (purple_account_get_bool(account, "read_anyone", TRUE)) {
 		process_anyone(zephyr);
