# HG changeset patch
# Node ID 1923e48a65a5
# Parent  c7ca6a49977a
diff --git a/finch/gntaccount.c b/finch/gntaccount.c
--- a/finch/gntaccount.c
+++ b/finch/gntaccount.c
@@ -73,7 +73,7 @@
 				purple_account_get_protocol_name(account)),
 			NULL, NULL);
 	gnt_tree_set_choice(GNT_TREE(accounts.tree), account,
-			purple_account_get_enabled(account, FINCH_UI));
+			purple_account_get_enabled(account));
 }
 
 static void
@@ -260,7 +260,7 @@
 		saved_status = purple_savedstatus_get_current();
 		if (saved_status != NULL) {
 			purple_savedstatus_activate_for_account(saved_status, account);
-			purple_account_set_enabled(account, FINCH_UI, TRUE);
+			purple_account_set_enabled(account, TRUE);
 		}
 	}
 
@@ -737,7 +737,7 @@
 		purple_savedstatus_activate_for_account(purple_savedstatus_get_current(),
 												account);
 
-	purple_account_set_enabled(account, FINCH_UI, enabled);
+	purple_account_set_enabled(account, enabled);
 }
 
 static gboolean
@@ -918,7 +918,7 @@
 	iter = purple_account_manager_get_all(manager);
 	if (iter) {
 		for (; iter; iter = iter->next) {
-			if (purple_account_get_enabled(iter->data, FINCH_UI))
+			if (purple_account_get_enabled(iter->data))
 				break;
 		}
 		if (!iter)
diff --git a/finch/gntconn.c b/finch/gntconn.c
--- a/finch/gntconn.c
+++ b/finch/gntconn.c
@@ -91,7 +91,7 @@
 static void
 ce_enable_account_cb(PurpleAccount *account)
 {
-	purple_account_set_enabled(account, FINCH_UI, TRUE);
+	purple_account_set_enabled(account, TRUE);
 }
 
 static void
@@ -133,7 +133,7 @@
 		g_free(act);
 		g_free(primary);
 		g_free(secondary);
-		purple_account_set_enabled(account, FINCH_UI, FALSE);
+		purple_account_set_enabled(account, FALSE);
 	}
 }
 
diff --git a/libpurple/account.h b/libpurple/account.h
--- a/libpurple/account.h
+++ b/libpurple/account.h
@@ -387,14 +387,11 @@
 /**
  * purple_account_set_enabled:
  * @account: The account.
- * @ui:      The UI.
  * @value:   %TRUE if it is enabled.
  *
- * Sets whether or not this account is enabled for the specified
- * UI.
+ * Sets whether or not this account is enabled.
  */
-void purple_account_set_enabled(PurpleAccount *account, const char *ui,
-			      gboolean value);
+void purple_account_set_enabled(PurpleAccount *account, gboolean value);
 
 /**
  * purple_account_set_proxy_info:
@@ -709,15 +706,12 @@
 /**
  * purple_account_get_enabled:
  * @account: The account.
- * @ui:      The UI.
  *
- * Returns whether or not this account is enabled for the
- * specified UI.
+ * Returns whether or not this account is enabled.
  *
  * Returns: %TRUE if it enabled on this UI.
  */
-gboolean purple_account_get_enabled(PurpleAccount *account,
-				  const char *ui);
+gboolean purple_account_get_enabled(PurpleAccount *account);
 
 /**
  * purple_account_get_proxy_info:
diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -62,6 +62,7 @@
 
 	char *buddy_icon_path;      /* The buddy icon's non-cached path.      */
 
+	gboolean enabled;
 	gboolean remember_pass;     /* Remember the password.                 */
 
 	/*
@@ -317,7 +318,7 @@
 request_password_cancel_cb(PurpleAccount *account, PurpleRequestFields *fields)
 {
 	/* Disable the account as the user has cancelled connecting */
-	purple_account_set_enabled(account, purple_core_get_ui(), FALSE);
+	purple_account_set_enabled(account, FALSE);
 }
 
 
@@ -701,6 +702,7 @@
 _purple_account_to_xmlnode(PurpleAccount *account)
 {
 	PurpleXmlNode *node, *child;
+	gchar *data = NULL;
 	const char *tmp;
 	PurpleProxyInfo *proxy_info;
 	PurpleAccountPrivate *priv = purple_account_get_instance_private(account);
@@ -718,6 +720,11 @@
 	child = purple_xmlnode_new_child(node, "name");
 	purple_xmlnode_insert_data(child, purple_account_get_username(account), -1);
 
+	child = purple_xmlnode_new_child(node, "enabled");
+	data = g_strdup_printf("%d", priv->enabled);
+	purple_xmlnode_insert_data(child, data, -1);
+	g_clear_pointer(&data, g_free);
+
 	if ((tmp = purple_account_get_private_alias(account)) != NULL)
 	{
 		child = purple_xmlnode_new_child(node, "alias");
@@ -787,8 +794,7 @@
 			purple_account_set_private_alias(account, g_value_get_string(value));
 			break;
 		case PROP_ENABLED:
-			purple_account_set_enabled(account, purple_core_get_ui(),
-					g_value_get_boolean(value));
+			purple_account_set_enabled(account, g_value_get_boolean(value));
 			break;
 		case PROP_CONNECTION:
 			purple_account_set_connection(account, g_value_get_object(value));
@@ -833,8 +839,7 @@
 			g_value_set_string(value, purple_account_get_private_alias(account));
 			break;
 		case PROP_ENABLED:
-			g_value_set_boolean(value, purple_account_get_enabled(account,
-					purple_core_get_ui()));
+			g_value_set_boolean(value, purple_account_get_enabled(account));
 			break;
 		case PROP_CONNECTION:
 			g_value_set_object(value, purple_account_get_connection(account));
@@ -1092,6 +1097,7 @@
 		PURPLE_TYPE_ACCOUNT,
 		"username", username,
 		"protocol-id", protocol_id,
+		"enabled", FALSE,
 		NULL);
 
 	return account;
@@ -1119,7 +1125,7 @@
 
 	username = purple_account_get_username(account);
 
-	if (!purple_account_get_enabled(account, purple_core_get_ui())) {
+	if (!purple_account_get_enabled(account)) {
 		purple_debug_info("account",
 				  "Account %s not enabled, not connecting.\n",
 				  username);
@@ -1620,21 +1626,19 @@
 }
 
 void
-purple_account_set_enabled(PurpleAccount *account, const char *ui,
-			 gboolean value)
-{
+purple_account_set_enabled(PurpleAccount *account, gboolean value) {
 	PurpleConnection *gc;
 	PurpleAccountPrivate *priv;
 	gboolean was_enabled = FALSE;
 
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
-	g_return_if_fail(ui != NULL);
-
-	was_enabled = purple_account_get_enabled(account, ui);
-
-	purple_account_set_ui_bool(account, ui, "auto-login", value);
+
+	priv = purple_account_get_instance_private(account);
+
+	was_enabled = priv->enabled;
+	priv->enabled = value;
+
 	gc = purple_account_get_connection(account);
-
 	if(was_enabled && !value)
 		purple_signal_emit(purple_accounts_get_handle(), "account-disabled", account);
 	else if(!was_enabled && value)
@@ -1645,12 +1649,12 @@
 	if ((gc != NULL) && (_purple_connection_wants_to_die(gc)))
 		return;
 
-	priv = purple_account_get_instance_private(account);
-
 	if (value && purple_presence_is_online(priv->presence))
 		purple_account_connect(account);
 	else if (!value && !purple_account_is_disconnected(account))
 		purple_account_disconnect(account);
+
+	purple_accounts_schedule_save();
 }
 
 void
@@ -2076,12 +2080,14 @@
 }
 
 gboolean
-purple_account_get_enabled(PurpleAccount *account, const char *ui)
-{
+purple_account_get_enabled(PurpleAccount *account) {
+	PurpleAccountPrivate *priv = NULL;
+
 	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), FALSE);
-	g_return_val_if_fail(ui      != NULL, FALSE);
-
-	return purple_account_get_ui_bool(account, ui, "auto-login", FALSE);
+
+	priv = purple_account_get_instance_private(account);
+
+	return priv->enabled;
 }
 
 PurpleProxyInfo *
diff --git a/libpurple/accounts.c b/libpurple/accounts.c
--- a/libpurple/accounts.c
+++ b/libpurple/accounts.c
@@ -326,6 +326,7 @@
 	char *protocol_id = NULL;
 	char *name = NULL;
 	char *data;
+	gboolean enabled = FALSE;
 
 	child = purple_xmlnode_get_child(node, "id");
 	if(child != NULL) {
@@ -347,6 +348,11 @@
 			name = purple_xmlnode_get_data(child);
 	}
 
+	child = purple_xmlnode_get_child(node, "enabled");
+	if(child != NULL) {
+		enabled = atoi(purple_xmlnode_get_data(child));
+	}
+
 	if ((protocol_id == NULL) || (name == NULL))
 	{
 		g_free(id);
@@ -362,6 +368,7 @@
 		"id", id,
 		"username", name,
 		"protocol-id", protocol_id,
+		"enabled", enabled,
 		NULL);
 
 	g_free(id);
@@ -493,7 +500,7 @@
 	 * account for all UIs rather than the just the current UI,
 	 * but it doesn't really matter.
 	 */
-	purple_account_set_enabled(account, purple_core_get_ui(), FALSE);
+	purple_account_set_enabled(account, FALSE);
 
 	purple_notify_close_with_handle(account);
 	purple_request_close_with_handle(account);
@@ -568,7 +575,7 @@
                                        G_GNUC_UNUSED gpointer data) {
 	gboolean enabled = FALSE, online = FALSE;
 
-	enabled = purple_account_get_enabled(account, purple_core_get_ui());
+	enabled = purple_account_get_enabled(account);
 	online = purple_presence_is_online(purple_account_get_presence(account));
 
 	if(enabled && online) {
diff --git a/libpurple/example/nullclient.c b/libpurple/example/nullclient.c
--- a/libpurple/example/nullclient.c
+++ b/libpurple/example/nullclient.c
@@ -244,7 +244,7 @@
 	                                               NULL, NULL, NULL);
 
 	/* It's necessary to enable the account first. */
-	purple_account_set_enabled(account, UI_ID, TRUE);
+	purple_account_set_enabled(account, TRUE);
 
 	/* Now, to connect the account(s), create a status and activate it. */
 	status = purple_savedstatus_new(NULL, PURPLE_STATUS_AVAILABLE);
diff --git a/libpurple/protocols/jabber/auth.c b/libpurple/protocols/jabber/auth.c
--- a/libpurple/protocols/jabber/auth.c
+++ b/libpurple/protocols/jabber/auth.c
@@ -120,7 +120,7 @@
 	PURPLE_ASSERT_CONNECTION_IS_VALID(gc);
 
 	/* Disable the account as the user has cancelled connecting */
-	purple_account_set_enabled(purple_connection_get_account(gc), purple_core_get_ui(), FALSE);
+	purple_account_set_enabled(purple_connection_get_account(gc), FALSE);
 }
 #endif
 
diff --git a/libpurple/protocols/jabber/auth_cyrus.c b/libpurple/protocols/jabber/auth_cyrus.c
--- a/libpurple/protocols/jabber/auth_cyrus.c
+++ b/libpurple/protocols/jabber/auth_cyrus.c
@@ -179,7 +179,7 @@
 	account = purple_connection_get_account(gc);
 
 	/* Disable the account as the user has cancelled connecting */
-	purple_account_set_enabled(account, purple_core_get_ui(), FALSE);
+	purple_account_set_enabled(account, FALSE);
 }
 
 static gboolean remove_current_mech(JabberStream *js) {
diff --git a/libpurple/purpleaccountmanager.c b/libpurple/purpleaccountmanager.c
--- a/libpurple/purpleaccountmanager.c
+++ b/libpurple/purpleaccountmanager.c
@@ -197,7 +197,7 @@
 	for(l = manager->accounts; l != NULL; l = l->next) {
 		PurpleAccount *account = PURPLE_ACCOUNT(l->data);
 
-		if(purple_account_get_enabled(account, purple_core_get_ui())) {
+		if(purple_account_get_enabled(account)) {
 			active = g_list_append(active, account);
 		}
 	}
@@ -214,7 +214,7 @@
 	for(l = manager->accounts; l != NULL; l = l->next) {
 		PurpleAccount *account = l->data;
 
-		if(!purple_account_get_enabled(account, purple_core_get_ui())) {
+		if(!purple_account_get_enabled(account)) {
 			inactive = g_list_append(inactive, account);
 		}
 	}
diff --git a/libpurple/status.c b/libpurple/status.c
--- a/libpurple/status.c
+++ b/libpurple/status.c
@@ -512,7 +512,7 @@
 				PURPLE_ACCOUNT_PRESENCE(presence));
 		PurpleAccountUiOps *ops = purple_accounts_get_ui_ops();
 
-		if (purple_account_get_enabled(account, purple_core_get_ui()))
+		if (purple_account_get_enabled(account))
 			purple_protocol_change_account_status(account, old_status, new_status);
 
 		if (ops != NULL && ops->status_changed != NULL)
diff --git a/libpurple/util.c b/libpurple/util.c
--- a/libpurple/util.c
+++ b/libpurple/util.c
@@ -1147,7 +1147,7 @@
 		PurplePresence *presence;
 		PurpleStatus *tune;
 		PurpleAccount *account = list->data;
-		if (!purple_account_get_enabled(account, purple_core_get_ui()))
+		if (!purple_account_get_enabled(account))
 			continue;
 
 		presence = purple_account_get_presence(account);
diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -944,7 +944,7 @@
 
 		if (saved_status != NULL && purple_account_get_remember_password(account)) {
 			purple_savedstatus_activate_for_account(saved_status, account);
-			purple_account_set_enabled(account, PIDGIN_UI, TRUE);
+			purple_account_set_enabled(account, TRUE);
 		}
 	}
 	else
@@ -1149,7 +1149,7 @@
 		saved_status = purple_savedstatus_get_current();
 		if (saved_status != NULL) {
 			purple_savedstatus_activate_for_account(saved_status, account);
-			purple_account_set_enabled(account, PIDGIN_UI, TRUE);
+			purple_account_set_enabled(account, TRUE);
 		}
 	}
 
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -3323,7 +3323,7 @@
 {
 	PurpleAccount *account = user_data;
 	purple_account_clear_current_error(account);
-	purple_account_set_enabled(account, purple_core_get_ui(), TRUE);
+	purple_account_set_enabled(account, TRUE);
 }
 
 static void
@@ -3354,8 +3354,7 @@
 {
 	GtkWidget *mini_dialog;
 	const char *username = purple_account_get_username(account);
-	gboolean enabled =
-		purple_account_get_enabled(account, purple_core_get_ui());
+	gboolean enabled = purple_account_get_enabled(account);
 	char *primary;
 
 	if (enabled)
@@ -3438,7 +3437,7 @@
 static void
 enable_account(PurpleAccount *account)
 {
-	purple_account_set_enabled(account, purple_core_get_ui(), TRUE);
+	purple_account_set_enabled(account, TRUE);
 }
 
 static void
diff --git a/pidgin/gtkconn.c b/pidgin/gtkconn.c
--- a/pidgin/gtkconn.c
+++ b/pidgin/gtkconn.c
@@ -126,7 +126,7 @@
 		if (info != NULL)
 			g_hash_table_remove(auto_reconns, account);
 
-		purple_account_set_enabled(account, PIDGIN_UI, FALSE);
+		purple_account_set_enabled(account, FALSE);
 	}
 }
 
diff --git a/pidgin/pidginaccountactionsmenu.c b/pidgin/pidginaccountactionsmenu.c
--- a/pidgin/pidginaccountactionsmenu.c
+++ b/pidgin/pidginaccountactionsmenu.c
@@ -58,7 +58,7 @@
 pidgin_account_actions_menu_disable_cb(GtkMenuItem *item, gpointer data) {
 	PidginAccountActionsMenu *menu = PIDGIN_ACCOUNT_ACTIONS_MENU(data);
 
-	purple_account_set_enabled(menu->account, PIDGIN_UI, FALSE);
+	purple_account_set_enabled(menu->account, FALSE);
 }
 
 static void
diff --git a/pidgin/pidginaccountmanager.c b/pidgin/pidginaccountmanager.c
--- a/pidgin/pidginaccountmanager.c
+++ b/pidgin/pidginaccountmanager.c
@@ -140,7 +140,7 @@
 	}
 
 	gtk_list_store_set(manager->model, iter,
-	                   COLUMN_ENABLED, purple_account_get_enabled(account, PIDGIN_UI),
+	                   COLUMN_ENABLED, purple_account_get_enabled(account),
 	                   COLUMN_AVATAR, avatar,
 	                   COLUMN_USERNAME, purple_account_get_username(account),
 	                   COLUMN_PROTOCOL_ICON, protocol_icon,
@@ -302,7 +302,7 @@
 			purple_savedstatus_activate_for_account(status, account);
 		}
 
-		purple_account_set_enabled(account, PIDGIN_UI, !enabled);
+		purple_account_set_enabled(account, !enabled);
 
 		/* We don't update the model here, as it's updated via the notify
 		 * signal.
diff --git a/pidgin/pidginaccountsenabledmenu.c b/pidgin/pidginaccountsenabledmenu.c
--- a/pidgin/pidginaccountsenabledmenu.c
+++ b/pidgin/pidginaccountsenabledmenu.c
@@ -63,7 +63,7 @@
 {
 	GMenu *menu = data;
 
-	if(purple_account_get_enabled(account, PIDGIN_UI)) {
+	if(purple_account_get_enabled(account)) {
 		GMenu *submenu = NULL;
 		gchar *label = NULL;
 		const gchar *account_name = purple_account_get_username(account);
diff --git a/pidgin/pidginaccountsmenu.c b/pidgin/pidginaccountsmenu.c
--- a/pidgin/pidginaccountsmenu.c
+++ b/pidgin/pidginaccountsmenu.c
@@ -46,7 +46,7 @@
 pidgin_accounts_menu_enable_account(GtkMenuItem *item, gpointer data) {
 	PurpleAccount *account = PURPLE_ACCOUNT(data);
 
-	purple_account_set_enabled(account, PIDGIN_UI, TRUE);
+	purple_account_set_enabled(account, TRUE);
 }
 
 /******************************************************************************
@@ -136,7 +136,7 @@
 pidgin_accounts_menu_foreach_cb(PurpleAccount *account, gpointer data) {
 	PidginAccountsMenu *menu = PIDGIN_ACCOUNTS_MENU(data);
 
-	if(purple_account_get_enabled(account, PIDGIN_UI)) {
+	if(purple_account_get_enabled(account)) {
 		pidgin_accounts_menu_add_enabled_account(menu, account);
 	} else {
 		pidgin_accounts_menu_add_disabled_account(menu, account);
diff --git a/pidgin/pidginapplication.c b/pidgin/pidginapplication.c
--- a/pidgin/pidginapplication.c
+++ b/pidgin/pidginapplication.c
@@ -277,8 +277,8 @@
 
 	account = purple_account_manager_find_by_id(manager, id);
 	if(PURPLE_IS_ACCOUNT(account)) {
-		if(purple_account_get_enabled(account, PIDGIN_UI)) {
-			purple_account_set_enabled(account, PIDGIN_UI, FALSE);
+		if(purple_account_get_enabled(account)) {
+			purple_account_set_enabled(account, FALSE);
 		}
 	}
 }
@@ -315,8 +315,8 @@
 
 	account = purple_account_manager_find_by_id(manager, id);
 	if(PURPLE_IS_ACCOUNT(account)) {
-		if(!purple_account_get_enabled(account, PIDGIN_UI)) {
-			purple_account_set_enabled(account, PIDGIN_UI, TRUE);
+		if(!purple_account_get_enabled(account)) {
+			purple_account_set_enabled(account, TRUE);
 		}
 	}
 }
