# HG changeset patch
# Node ID f8b085bd54e9
# Parent  39e595f7d056
diff --git a/ChangeLog.API b/ChangeLog.API
--- a/ChangeLog.API
+++ b/ChangeLog.API
@@ -326,8 +326,9 @@
 		* _PurpleSoundEventID
 		* _PurpleSslConnection
 		* _XMLNodeType
-		* account-added signal. Use PurpleAccountManager::added
-		  instead.
+		* account-added signal. Use PurpleAccountManager::added instead.
+		* account-created signal. Use PurpleAccountManager::added instead.
+		* account-destroying signal. Use PurpleAccountManager::removed instead.
 		* account-disabled signal. Use
 		  PurpleAccountManager::account-changed::enabled instead.
 		* account-enabled signal. Use
diff --git a/doc/reference/libpurple/signals_account.md b/doc/reference/libpurple/signals_account.md
--- a/doc/reference/libpurple/signals_account.md
+++ b/doc/reference/libpurple/signals_account.md
@@ -5,8 +5,6 @@
 
 ### Signal List
 
-* [account-created](#account-created)
-* [account-destroying](#account-destroying)
 * [account-status-changed](#account-status-changed)
 * [account-actions-changed](#account-actions-changed)
 * [account-error-changed](#account-error-changed)
diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -870,9 +870,6 @@
 			"protocol-id", &protocol_id,
 			NULL);
 
-	purple_signal_emit(purple_accounts_get_handle(), "account-created",
-			account);
-
 	manager = purple_protocol_manager_get_default();
 	protocol = purple_protocol_manager_find(manager, protocol_id);
 	if (protocol == NULL) {
@@ -924,8 +921,6 @@
 	PurpleConversationManager *manager = NULL;
 
 	purple_debug_info("account", "Destroying account %p", account);
-	purple_signal_emit(purple_accounts_get_handle(), "account-destroying",
-	                   account);
 
 	manager = purple_conversation_manager_get_default();
 	l = purple_conversation_manager_get_all(manager);
diff --git a/libpurple/accounts.c b/libpurple/accounts.c
--- a/libpurple/accounts.c
+++ b/libpurple/accounts.c
@@ -680,14 +680,6 @@
 	void *handle = purple_accounts_get_handle();
 	void *conn_handle = purple_connections_get_handle();
 
-	purple_signal_register(handle, "account-created",
-						 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
-						 PURPLE_TYPE_ACCOUNT);
-
-	purple_signal_register(handle, "account-destroying",
-						 purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
-						 PURPLE_TYPE_ACCOUNT);
-
 	purple_signal_register(handle, "account-status-changing",
 						 purple_marshal_VOID__POINTER_POINTER_POINTER,
 						 G_TYPE_NONE, 3, PURPLE_TYPE_ACCOUNT,
diff --git a/libpurple/buddylist.c b/libpurple/buddylist.c
--- a/libpurple/buddylist.c
+++ b/libpurple/buddylist.c
@@ -144,11 +144,27 @@
 }
 
 static void
+purple_buddy_list_account_added_cb(G_GNUC_UNUSED PurpleAccountManager *manager,
+                                   PurpleAccount *account,
+                                   G_GNUC_UNUSED gpointer data)
+{
+	purple_blist_buddies_cache_add_account(account);
+}
+
+static void
 purple_blist_buddies_cache_remove_account(const PurpleAccount *account)
 {
 	g_hash_table_remove(buddies_cache, account);
 }
 
+static void
+purple_buddy_list_account_removed_cb(G_GNUC_UNUSED PurpleAccountManager *manager,
+                                     PurpleAccount *account,
+                                     G_GNUC_UNUSED gpointer data)
+{
+	purple_blist_buddies_cache_remove_account(account);
+}
+
 /*********************************************************************
  * Writing to disk                                                   *
  *********************************************************************/
@@ -2202,16 +2218,6 @@
 	purple_signal_register(handle, "buddy-caps-changed",
 			purple_marshal_VOID__POINTER_INT_INT, G_TYPE_NONE,
 			3, PURPLE_TYPE_BUDDY, G_TYPE_INT, G_TYPE_INT);
-
-	purple_signal_connect(purple_accounts_get_handle(), "account-created",
-			handle,
-			G_CALLBACK(purple_blist_buddies_cache_add_account),
-			NULL);
-
-	purple_signal_connect(purple_accounts_get_handle(), "account-destroying",
-			handle,
-			G_CALLBACK(purple_blist_buddies_cache_remove_account),
-			NULL);
 }
 
 static void
@@ -2277,13 +2283,23 @@
 static void
 purple_buddy_list_init(PurpleBuddyList *blist)
 {
-	PurpleBuddyListPrivate *priv =
-			purple_buddy_list_get_instance_private(blist);
+	PurpleBuddyListPrivate *priv = NULL;
+	PurpleAccountManager *manager = NULL;
+
+	priv = purple_buddy_list_get_instance_private(blist);
 
 	priv->buddies = g_hash_table_new_full(
 					 (GHashFunc)_purple_blist_hbuddy_hash,
 					 (GEqualFunc)_purple_blist_hbuddy_equal,
 					 (GDestroyNotify)_purple_blist_hbuddy_free_key, NULL);
+
+	manager = purple_account_manager_get_default();
+	g_signal_connect_object(manager, "added",
+	                        G_CALLBACK(purple_buddy_list_account_added_cb),
+	                        blist, 0);
+	g_signal_connect_object(manager, "removed",
+	                        G_CALLBACK(purple_buddy_list_account_removed_cb),
+	                        blist, 0);
 }
 
 /* GObject finalize function */
