changeset 10720:0e017707532f

[gaim-migrate @ 12318] We can now sign on and off and on and off accounts all the live long day using the "enabled" button in the accounts window committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 24 Mar 2005 04:36:09 +0000
parents 1da76f22c750
children fbd50c34a27f
files src/account.c src/gtkaccount.c
diffstat 2 files changed, 18 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/account.c	Thu Mar 24 04:35:06 2005 +0000
+++ b/src/account.c	Thu Mar 24 04:36:09 2005 +0000
@@ -584,7 +584,7 @@
 	account->ui_settings = g_hash_table_new_full(g_str_hash, g_str_equal,
 				g_free, (GDestroyNotify)g_hash_table_destroy);
 	account->system_log = NULL;
-	
+
 	account->presence = gaim_presence_new_for_account(account);
 
 	prpl = gaim_find_prpl(protocol_id);
@@ -998,7 +998,6 @@
 	g_return_if_fail(status_id != NULL);
 
 	status = gaim_account_get_status(account, status_id);
-
 	if (status == NULL)
 	{
 		gaim_debug_error("accounts",
@@ -1007,6 +1006,22 @@
 				   gaim_account_get_protocol_id(account));
 		return;
 	}
+	status_type = gaim_status_get_type(status);
+
+	/*
+	 * If this account should be disconnected, but is online, then disconnect.
+	 */
+	if (active &&
+		(gaim_status_type_get_primitive(status_type) == GAIM_STATUS_OFFLINE) &&
+		gaim_account_is_connected(account))
+	{
+		gaim_account_disconnect(account);
+
+		/* No need to actually set the status, so we just exit */
+		return;
+	}
+
+	/* TODO: Record the status in accounts.xml? */
 
 	va_start(args, active);
 	gaim_status_set_active_with_attrs(status, active, args);
@@ -1015,7 +1030,6 @@
 	/*
 	 * If this account should be connected, but is not, then connect.
 	 */
-	status_type = gaim_status_get_type(status);
 	if (active &&
 		(gaim_status_type_get_primitive(status_type) != GAIM_STATUS_OFFLINE) &&
 		!gaim_account_is_connected(account))
--- a/src/gtkaccount.c	Thu Mar 24 04:35:06 2005 +0000
+++ b/src/gtkaccount.c	Thu Mar 24 04:36:09 2005 +0000
@@ -1357,7 +1357,6 @@
 
 		dialog->account = gaim_account_new(screenname, dialog->protocol_id);
 		gaim_account_set_enabled(dialog->account, GAIM_GTK_UI, TRUE);
-			
 	}
 	else
 	{
@@ -2042,7 +2041,7 @@
 					   COLUMN_ENABLED, &enabled,
 					   -1);
 	if (enabled) {
-		gaim_account_disconnect(account);
+		gaim_account_set_status(account, "offline", TRUE, NULL);
 	} else {
 		GaimGtkBuddyList *gtkblist;
 		const char *type;