# HG changeset patch # User Stu Tomlinson # Date 1181701211 0 # Node ID 1f060ef64f7728bbc9ab4bbc9bd536a08dcffb9c # Parent 662710d7ecf0a68edf771b91420fe6caa622e4e8 Make -l do something slightly more sane than it does now, even though it doesn't really fit in with our normal utilization of multiple accounts. This will now disable all accounts and then only enable those requested on the command line. Fixes #1257. diff -r 662710d7ecf0 -r 1f060ef64f77 pidgin/gtkmain.c --- a/pidgin/gtkmain.c Wed Jun 13 00:52:35 2007 +0000 +++ b/pidgin/gtkmain.c Wed Jun 13 02:20:11 2007 +0000 @@ -108,21 +108,19 @@ }; #endif -static int +static void dologin_named(const char *name) { PurpleAccount *account; char **names; int i; - int ret = -1; if (name != NULL) { /* list of names given */ names = g_strsplit(name, ",", 64); for (i = 0; names[i] != NULL; i++) { account = purple_accounts_find(names[i], NULL); if (account != NULL) { /* found a user */ - ret = 0; - purple_account_connect(account); + purple_account_set_enabled(account, PIDGIN_UI, TRUE); } } g_strfreev(names); @@ -133,12 +131,9 @@ if (accounts != NULL) { account = (PurpleAccount *)accounts->data; - ret = 0; - purple_account_connect(account); + purple_account_set_enabled(account, PIDGIN_UI, TRUE); } } - - return ret; } #ifdef HAVE_SIGNAL_H @@ -439,7 +434,6 @@ char *opt_config_dir_arg = NULL; char *opt_login_arg = NULL; char *opt_session_arg = NULL; - int dologin_ret = -1; char *search_path; GList *accounts; #ifdef HAVE_SIGNAL_H @@ -788,14 +782,23 @@ pidgin_debug_window_show(); if (opt_login) { - dologin_ret = dologin_named(opt_login_arg); + /* disable all accounts */ + for (accounts = purple_accounts_get_all(); accounts != NULL; accounts = accounts->next) { + PurpleAccount *account = accounts->data; + purple_account_set_enabled(account, PIDGIN_UI, FALSE); + } + /* honor the startup status preference */ + if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status")) + purple_savedstatus_activate(purple_savedstatus_get_startup()); + /* now enable the requested ones */ + dologin_named(opt_login_arg); if (opt_login_arg != NULL) { g_free(opt_login_arg); opt_login_arg = NULL; } } - if (opt_nologin) + if (opt_nologin && !opt_login) { /* Set all accounts to "offline" */ PurpleSavedStatus *saved_status; @@ -811,7 +814,7 @@ /* Set the status for each account */ purple_savedstatus_activate(saved_status); } - else + else if (!opt_login) { /* Everything is good to go--sign on already */ if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status"))