changeset 11348:efb358543b1d

[gaim-migrate @ 13565] Two changes: 1. Fix the "enabled" button in the accounts editor so that unchecking it will sign off an account. I broke this in one of my commits on August 17th 2. Some changes from Thomas Butter to finishing initializing Gaim, and THEN attempt to sign on accounts. This fixes problems with the crypto API not yet being initialized. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 26 Aug 2005 04:38:36 +0000
parents 6c1ad49fcb4b
children 2de0bf90a474
files src/account.c src/account.h src/gtkmain.c
diffstat 3 files changed, 33 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/account.c	Fri Aug 26 03:21:03 2005 +0000
+++ b/src/account.c	Fri Aug 26 04:38:36 2005 +0000
@@ -781,12 +781,6 @@
 		GaimAccount *new_acct;
 		new_acct = parse_account(child);
 		gaim_accounts_add(new_acct);
-
-		if (gaim_account_get_enabled(new_acct, gaim_core_get_ui()) &&
-			(gaim_presence_is_online(new_acct->presence)))
-		{
-			gaim_account_connect(new_acct);
-		}
 	}
 }
 
@@ -1295,6 +1289,8 @@
 	gaim_account_set_ui_bool(account, ui, "auto-login", value);
 	if (value && gaim_presence_is_online(account->presence))
 		gaim_account_connect(account);
+	else if (!value && !gaim_account_is_disconnected(account))
+		gaim_account_disconnect(account);
 }
 
 void
@@ -2060,6 +2056,23 @@
 }
 
 void
+gaim_accounts_restore_previous_statuses()
+{
+	GList *l;
+	GaimAccount *account;
+
+	for (l = gaim_accounts_get_all(); l != NULL; l = l->next)
+	{
+		account = (GaimAccount *)l->data;
+		if (gaim_account_get_enabled(account, gaim_core_get_ui()) &&
+			(gaim_presence_is_online(account->presence)))
+		{
+			gaim_account_connect(account);
+		}
+	}
+}
+
+void
 gaim_accounts_set_ui_ops(GaimAccountUiOps *ops)
 {
 	account_ui_ops = ops;
--- a/src/account.h	Fri Aug 26 03:21:03 2005 +0000
+++ b/src/account.h	Fri Aug 26 04:38:36 2005 +0000
@@ -746,6 +746,17 @@
  */
 GaimAccount *gaim_accounts_find(const char *name, const char *protocol);
 
+/**
+ * This is called by the core after all subsystems and what
+ * not have been initialized.  It sets all enabled accounts
+ * to their previous status by signing them on, setting them
+ * away, etc.
+ *
+ * You probably shouldn't call this unless you really know
+ * what you're doing.
+ */
+void gaim_accounts_restore_previous_statuses();
+
 /*@}*/
 
 
--- a/src/gtkmain.c	Fri Aug 26 03:21:03 2005 +0000
+++ b/src/gtkmain.c	Fri Aug 26 04:38:36 2005 +0000
@@ -672,9 +672,10 @@
 		}
 	}
 
-	if (!opt_acct && opt_nologin)
+	if (!opt_acct && !opt_nologin)
 	{
-		/* TODO: Need to disable all accounts or set them all to offline */
+		/* Everything is good to go--sign on already */
+		gaim_accounts_restore_previous_statuses();
 	}
 
 	if (opt_acct || (gaim_accounts_get_all() == NULL)) {