changeset 10740:94cc67130789

[gaim-migrate @ 12342] More big changes, yay. I combined gaim_connection_new and gaim_connection_connect. Earlier today I realized that it's dumb to have a GaimConnection that isn't connected. I'm about to combine gaim_connection_disconnect and gaim_connection_destroy, as well. I added a "password" field to GaimConnection. It holds the password used to login a specific GaimConnection. Now, when "remember password" is false, account->password is NEVER set. When the user tries to sign on and Gaim prompts for the password, it goes directly into the GaimConnection. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 26 Mar 2005 23:25:18 +0000
parents 42dbc4ba1325
children 2f5d99f963eb
files plugins/tcl/tcl_cmds.c src/account.c src/account.h src/connection.c src/connection.h src/protocols/gg/gg.c src/protocols/irc/irc.c src/protocols/jabber/auth.c src/protocols/jabber/jabber.c src/protocols/msn/nexus.c src/protocols/msn/notification.c src/protocols/napster/napster.c src/protocols/novell/novell.c src/protocols/oscar/oscar.c src/protocols/silc/ops.c src/protocols/toc/toc.c src/protocols/trepia/trepia.c src/protocols/yahoo/yahoo.c src/server.c src/server.h src/status.h
diffstat 21 files changed, 219 insertions(+), 281 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/tcl/tcl_cmds.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/plugins/tcl/tcl_cmds.c	Sat Mar 26 23:25:18 2005 +0000
@@ -119,10 +119,9 @@
 		error = Tcl_GetIntFromObj(interp, objv[2], (int *)&account);
 		if (error || !tcl_validate_account(account, interp))
 			return TCL_ERROR;
-		if (gaim_account_is_connected(account))
-			Tcl_SetIntObj(result, (int)gaim_account_get_connection(account));
-		else
-			Tcl_SetIntObj(result, (int)gaim_account_connect(account));
+		if (!gaim_account_is_connected(account))
+			gaim_account_connect(account);
+		Tcl_SetIntObj(result, (int)gaim_account_get_connection(account));
 		break;
 	case CMD_ACCOUNT_CONNECTION:
 		if (objc != 3) {
--- a/src/account.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/account.c	Sat Mar 26 23:25:18 2005 +0000
@@ -741,44 +741,83 @@
 	g_free(account);
 }
 
-GaimConnection *
+void
 gaim_account_register(GaimAccount *account)
 {
-	GaimConnection *gc;
+	g_return_if_fail(account != NULL);
 
-	g_return_val_if_fail(account != NULL, NULL);
+	gaim_debug_info("account", "Registering account %s\n",
+					gaim_account_get_username(account));
 
-	if (gaim_account_get_connection(account) != NULL)
-		return NULL;
+	gaim_connection_new(account, TRUE, NULL);
+}
 
-	gc = gaim_connection_new(account);
+static void
+request_password_ok_cb(GaimAccount *account, const char *entry)
+{
+	if (!entry || !*entry)
+	{
+		gaim_notify_error(account, NULL, _("Password is required to sign on."), NULL);
+		return;
+	}
 
-	gaim_debug_info("account", "Registering account %p. gc = %p\n",
-					account, gc);
+	if (gaim_account_get_remember_password(account))
+		gaim_account_set_password(account, entry);
 
-	gaim_connection_register(gc);
-
-	return gc;
+	gaim_connection_new(account, FALSE, entry);
 }
 
-GaimConnection *
+static void
+request_password(GaimAccount *account)
+{
+	gchar *primary;
+	gchar *escaped;
+	const gchar *username;
+
+	username = gaim_account_get_username(account);
+	escaped = g_markup_escape_text(username, strlen(username));
+	primary = g_strdup_printf(_("Enter password for %s (%s)"), escaped,
+								  gaim_account_get_protocol_name(account));
+	gaim_request_input(account, _("Enter Password"), primary, NULL, NULL,
+					   FALSE, TRUE, NULL,
+					   _("OK"), G_CALLBACK(request_password_ok_cb),
+					   _("Cancel"), NULL, account);
+	g_free(primary);
+	g_free(escaped);
+}
+
+void
 gaim_account_connect(GaimAccount *account)
 {
-	GaimConnection *gc;
+	GaimPlugin *prpl;
+	GaimPluginProtocolInfo *prpl_info;
+	const char *password;
+
+	g_return_if_fail(account != NULL);
 
-	g_return_val_if_fail(account != NULL, NULL);
+	gaim_debug_info("account", "Connecting to account %s\n",
+					gaim_account_get_username(account));
 
-	if (gaim_account_get_connection(account) != NULL)
-		return NULL;
+	prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));
+	if (prpl == NULL)
+	{
+		gchar *message;
 
-	gc = gaim_connection_new(account);
+		message = g_strdup_printf(_("Missing protocol plugin for %s"),
+			gaim_account_get_username(account));
+		gaim_notify_error(NULL, _("Connection Error"), message, NULL);
+		g_free(message);
+		return;
+	}
 
-	gaim_debug_info("account", "Connecting to account %p. gc = %p\n",
-					account, gc);
-
-	gaim_connection_connect(gc);
-
-	return gc;
+	prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
+	password = gaim_account_get_password(account);
+	if ((password == NULL) &&
+		!(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
+		!(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL))
+		request_password(account);
+	else
+		gaim_connection_new(account, FALSE, password);
 }
 
 void
@@ -940,9 +979,7 @@
 {
 	g_return_if_fail(account != NULL);
 
-	if (account->username != NULL)
-		g_free(account->username);
-
+	g_free(account->username);
 	account->username = (username == NULL ? NULL : g_strdup(username));
 
 	schedule_accounts_save();
@@ -953,8 +990,11 @@
 {
 	g_return_if_fail(account != NULL);
 
-	if (account->password != NULL)
-		g_free(account->password);
+	g_free(account->password);
+	account->password = NULL;
+
+	if (!gaim_account_get_remember_password(account))
+		return;
 
 	account->password = (password == NULL ? NULL : g_strdup(password));
 
@@ -966,9 +1006,7 @@
 {
 	g_return_if_fail(account != NULL);
 
-	if (account->alias != NULL)
-		g_free(account->alias);
-
+	g_free(account->alias);
 	account->alias = (alias == NULL ? NULL : g_strdup(alias));
 
 	schedule_accounts_save();
@@ -979,9 +1017,7 @@
 {
 	g_return_if_fail(account != NULL);
 
-	if (account->user_info != NULL)
-		g_free(account->user_info);
-
+	g_free(account->user_info);
 	account->user_info = (user_info == NULL ? NULL : g_strdup(user_info));
 
 	schedule_accounts_save();
@@ -992,11 +1028,9 @@
 {
 	g_return_if_fail(account != NULL);
 
-	if (account->buddy_icon != NULL)
-		g_free(account->buddy_icon);
-
+	g_free(account->buddy_icon);
 	account->buddy_icon = (icon == NULL ? NULL : g_strdup(icon));
-	if (account->gc)
+	if (gaim_account_is_connected(account))
 		serv_set_buddyicon(account->gc, icon);
 
 	schedule_accounts_save();
@@ -1008,9 +1042,7 @@
 	g_return_if_fail(account     != NULL);
 	g_return_if_fail(protocol_id != NULL);
 
-	if (account->protocol_id != NULL)
-		g_free(account->protocol_id);
-
+	g_free(account->protocol_id);
 	account->protocol_id = g_strdup(protocol_id);
 
 	schedule_accounts_save();
--- a/src/account.h	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/account.h	Sat Mar 26 23:25:18 2005 +0000
@@ -113,20 +113,15 @@
  * Connects to an account.
  *
  * @param account The account to connect to.
- * @param status  The status the account should use when logging in.
- *
- * @return The gaim connection.
  */
-GaimConnection *gaim_account_connect(GaimAccount *account);
+void gaim_account_connect(GaimAccount *account);
 
 /**
  * Registers an account.
  *
  * @param account The account to register.
- *
- * @return The gaim connection.
  */
-GaimConnection *gaim_account_register(GaimAccount *account);
+void gaim_account_register(GaimAccount *account);
 
 /**
  * Disconnects from an account.
--- a/src/connection.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/connection.c	Sat Mar 26 23:25:18 2005 +0000
@@ -23,6 +23,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include "internal.h"
+#include "account.h"
 #include "blist.h"
 #include "connection.h"
 #include "debug.h"
@@ -40,21 +41,73 @@
 
 static int connections_handle;
 
-GaimConnection *
-gaim_connection_new(GaimAccount *account)
+void
+gaim_connection_new(GaimAccount *account, gboolean regist, const char *password)
 {
 	GaimConnection *gc;
+	GaimPlugin *prpl;
+	GaimPluginProtocolInfo *prpl_info;
 
-	g_return_val_if_fail(account != NULL, NULL);
+	g_return_if_fail(account != NULL);
+
+	prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));
+
+	if (prpl != NULL)
+		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
+	else {
+		gchar *message;
+
+		message = g_strdup_printf(_("Missing protocol plugin for %s"),
+			gaim_account_get_username(account));
+		gaim_notify_error(NULL, regist ? _("Registration Error") :
+						  _("Connection Error"), message, NULL);
+		g_free(message);
+		return;
+	}
+
+	if (regist)
+	{
+		if (prpl_info->register_user == NULL)
+			return;
+	}
+	else
+	{
+		if ((password == NULL) &&
+			!(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
+			!(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL))
+		{
+			gaim_debug_error("connection", "Can not connect to account %s without "
+							 "a password.\n", gaim_account_get_username(account));
+			return;
+		}
+	}
 
 	gc = g_new0(GaimConnection, 1);
-
-	gc->prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));
-
+	gc->prpl = prpl;
+	gc->password = g_strdup(password);
 	gaim_connection_set_account(gc, account);
+	gaim_connection_set_state(gc, GAIM_CONNECTING);
+	connections = g_list_append(connections, gc);
 	gaim_account_set_connection(account, gc);
 
-	return gc;
+	gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc);
+
+	if (regist)
+	{
+		gaim_debug_info("connection", "Registering.  gc = %p\n", gc);
+
+		/* set this so we don't auto-reconnect after registering */
+		gc->wants_to_die = TRUE;
+
+		prpl_info->register_user(account);
+	}
+	else
+	{
+		gaim_debug_info("connection", "Connecting. gc = %p\n", gc);
+
+		gaim_signal_emit(gaim_accounts_get_handle(), "account-connecting", account);
+		prpl_info->login(account, gaim_account_get_active_status(account));
+	}
 }
 
 void
@@ -75,6 +128,9 @@
 	account = gaim_connection_get_account(gc);
 	gaim_account_set_connection(account, NULL);
 
+	if (gc->password != NULL)
+		g_free(gc->password);
+
 	if (gc->display_name != NULL)
 		g_free(gc->display_name);
 
@@ -84,126 +140,6 @@
 	g_free(gc);
 }
 
-static void
-request_pass_ok_cb(GaimAccount *account, const char *entry)
-{
-	gaim_account_set_password(account, (*entry != '\0') ? entry : NULL);
-
-	gaim_account_connect(account);
-}
-
-void
-gaim_connection_register(GaimConnection *gc)
-{
-	GaimAccount *account;
-	GaimConnectionUiOps *ops;
-	GaimPluginProtocolInfo *prpl_info = NULL;
-
-	g_return_if_fail(gc != NULL);
-
-	gaim_debug_info("connection", "Registering.  gc = %p\n", gc);
-
-	ops = gaim_connections_get_ui_ops();
-
-	if (gc->prpl != NULL)
-		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
-	else
-	{
-		gchar *message = g_strdup_printf(_("Missing protocol plugin for %s"),
-			gaim_account_get_username(gaim_connection_get_account(gc)));
-
-		gaim_debug_error("connection", "Could not get prpl info for %p\n", gc);
-		gaim_notify_error(NULL, _("Registration Error"),
-				  message, NULL);
-		g_free(message);
-		return;
-	}
-
-	if (prpl_info->register_user == NULL)
-		return;
-
-	account = gaim_connection_get_account(gc);
-
-	if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED)
-		return;
-
-	gaim_connection_set_state(gc, GAIM_CONNECTING);
-
-	connections = g_list_append(connections, gc);
-
-	gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc);
-
-	/* set this so we don't auto-reconnect after registering */
-	gc->wants_to_die = TRUE;
-
-	gaim_debug_info("connection", "Calling register_user\n");
-
-	prpl_info->register_user(account);
-}
-
-
-void
-gaim_connection_connect(GaimConnection *gc)
-{
-	GaimAccount *account;
-	GaimPluginProtocolInfo *prpl_info = NULL;
-	GaimStatus *status;
-
-	g_return_if_fail(gc != NULL);
-
-	gaim_debug_info("connection", "Connecting. gc = %p\n", gc);
-
-	if (gc->prpl != NULL)
-		prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
-	else {
-		gchar *message = g_strdup_printf(_("Missing protocol plugin for %s"),
-			gaim_account_get_username(gaim_connection_get_account(gc)));
-
-		gaim_debug_error("connection", "Could not get prpl info for %p\n", gc);
-		gaim_notify_error(NULL, _("Connection Error"), message, NULL);
-		g_free(message);
-		return;
-	}
-
-	account = gaim_connection_get_account(gc);
-
-	if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED)
-		return;
-
-	if (!(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
-			!(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL) &&
-			gaim_account_get_password(account) == NULL) {
-		gchar *primary;
-		gchar *escaped;
-		const gchar *username = gaim_account_get_username(account);
-
-		gaim_debug_info("connection", "Requesting password\n");
-		gaim_connection_destroy(gc);
-		escaped = g_markup_escape_text(username, strlen(username));
-		primary = g_strdup_printf(_("Enter password for %s (%s)"), escaped,
-								  gaim_account_get_protocol_name(account));
-		gaim_request_input(gc, _("Enter Password"), primary, NULL, NULL,
-						   FALSE, TRUE, NULL,
-						   _("OK"), G_CALLBACK(request_pass_ok_cb),
-						   _("Cancel"), NULL, account);
-		g_free(primary);
-		g_free(escaped);
-
-		return;
-	}
-
-	gaim_connection_set_state(gc, GAIM_CONNECTING);
-
-	connections = g_list_append(connections, gc);
-
-	gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc);
-
-	gaim_debug_info("connection", "Calling serv_login\n");
-
-	status = gaim_account_get_active_status(account);
-	serv_login(account, status);
-}
-
 void
 gaim_connection_disconnect(GaimConnection *gc)
 {
@@ -256,9 +192,6 @@
 		gaim_notify_close_with_handle(gc);
 	}
 
-	if (!gaim_account_get_remember_password(account))
-		gaim_account_set_password(account, NULL);
-
 	gaim_connection_destroy(gc);
 }
 
@@ -431,6 +364,14 @@
 }
 
 const char *
+gaim_connection_get_password(const GaimConnection *gc)
+{
+	g_return_val_if_fail(gc != NULL, NULL);
+
+	return gc->password;
+}
+
+const char *
 gaim_connection_get_display_name(const GaimConnection *gc)
 {
 	g_return_val_if_fail(gc != NULL, NULL);
--- a/src/connection.h	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/connection.h	Sat Mar 26 23:25:18 2005 +0000
@@ -79,6 +79,7 @@
 	GaimConnectionState state;   /**< The connection state.              */
 
 	GaimAccount *account;        /**< The account being connected to.    */
+	char *password;              /**< The password used.                 */
 	int inpa;                    /**< The input watcher.                 */
 
 	GSList *buddy_chats;         /**< A list of active chats.            */
@@ -113,44 +114,35 @@
 /*@{*/
 
 /**
- * Creates a connection to the specified account.
+ * This function should only be called by gaim_connection_connect()
+ * in account.c.  If you're trying to sign on an account, use that
+ * function instead.
+ *
+ * Creates a connection to the specified account and either connects
+ * or attempts to register a new account.  If you are logging in,
+ * the connection uses the current active status for this account.
+ * So if you want to sign on as "away," for example, you need to
+ * have called gaim_account_set_status(account, "away").
+ * (And this will call gaim_account_connect() automatically).
  *
  * @param account The account the connection should be connecting to.
- *
- * @return The gaim connection.
+ * @param register Whether we are registering a new account or just
+ *        trying to do a normal signon.
+ * @param password The password to use.
  */
-GaimConnection *gaim_connection_new(GaimAccount *account);
-
-/**
- * Destroys and closes a gaim connection.
- *
- * @param gc The gaim connection to destroy.
- */
-void gaim_connection_destroy(GaimConnection *gc);
+void gaim_connection_new(GaimAccount *account, gboolean regist,
+									const char *password);
 
 /**
  * This function should only be called by gaim_connection_connect()
  * in account.c.  If you're trying to sign on an account, use that
  * function instead.
  *
- * Logs in to this connection.  The connection uses the current
- * active status in the account as the initial status.  So if
- * you want to sign on as "away," for example, you need to
- * have called gaim_account_set_status(account, "away").
- * (And generally this has the effect of also signin on).
- *
- * @param gc The connection to log in.
+ * Disconnects and destroys a GaimConnection.
  *
- * @see gaim_connection_disconnect()
+ * @param gc The gaim connection to destroy.
  */
-void gaim_connection_connect(GaimConnection *gc);
-
-/**
- * Registers a connection.
- *
- * @param gc The connection to register.
- */
-void gaim_connection_register(GaimConnection *gc);
+void gaim_connection_destroy(GaimConnection *gc);
 
 /**
  * This function should only be called by gaim_connection_disconnect()
@@ -216,6 +208,15 @@
 GaimAccount *gaim_connection_get_account(const GaimConnection *gc);
 
 /**
+ * Returns the connection's password.
+ *
+ * @param gc The connection.
+ *
+ * @return The connection's password.
+ */
+const char *gaim_connection_get_password(const GaimConnection *gc);
+
+/**
  * Returns the connection's displayed name.
  *
  * @param gc The connection.
--- a/src/protocols/gg/gg.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/protocols/gg/gg.c	Sat Mar 26 23:25:18 2005 +0000
@@ -1,6 +1,6 @@
 /*
  * gaim - Gadu-Gadu Protocol Plugin
- * $Id: gg.c 12334 2005-03-26 02:43:49Z lschiere $
+ * $Id: gg.c 12342 2005-03-26 23:25:18Z thekingant $
  *
  * Copyright (C) 2001 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
  *
@@ -27,6 +27,7 @@
 #include "account.h"
 #include "accountopt.h"
 #include "blist.h"
+#include "connection.h"
 #include "debug.h"
 #include "notify.h"
 #include "proxy.h"
@@ -1353,7 +1354,7 @@
 {
 	struct agg_http *hi = g_new0(struct agg_http, 1);
 	gchar *u = gg_urlencode(gaim_account_get_username(gc->account));
-	gchar *p = gg_urlencode(gaim_account_get_password(gc->account));
+	gchar *p = gg_urlencode(gaim_connection_get_password(gc));
 
 	hi->gc = gc;
 	hi->type = AGG_HTTP_USERLIST_IMPORT;
@@ -1380,7 +1381,7 @@
 	struct agg_http *he = g_new0(struct agg_http, 1);
 	gchar *ptr;
 	gchar *u = gg_urlencode(gaim_account_get_username(gc->account));
-	gchar *p = gg_urlencode(gaim_account_get_password(gc->account));
+	gchar *p = gg_urlencode(gaim_connection_get_password(gc));
 
 	GaimBlistNode *gnode, *cnode, *bnode;
 
@@ -1453,7 +1454,7 @@
 {
 	struct agg_http *he = g_new0(struct agg_http, 1);
 	gchar *u = gg_urlencode(gaim_account_get_username(gc->account));
-	gchar *p = gg_urlencode(gaim_account_get_password(gc->account));
+	gchar *p = gg_urlencode(gaim_connection_get_password(gc));
 
 	he->gc = gc;
 	he->type = AGG_HTTP_USERLIST_DELETE;
@@ -1529,7 +1530,7 @@
 {
 	struct agg_http *hpass = g_new0(struct agg_http, 1);
 	gchar *u = gg_urlencode(gaim_account_get_username(gc->account));
-	gchar *p = gg_urlencode(gaim_account_get_password(gc->account));
+	gchar *p = gg_urlencode(gaim_connection_get_password(gc));
 	gchar *enew = gg_urlencode(new);
 	gchar *eold = gg_urlencode(old);
 
--- a/src/protocols/irc/irc.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/protocols/irc/irc.c	Sat Mar 26 23:25:18 2005 +0000
@@ -286,7 +286,7 @@
 	char hostname[256];
 	const char *username, *realname;
 	struct irc_conn *irc = gc->proto_data;
-	const char *pass = gaim_account_get_password(gc->account);
+	const char *pass = gaim_connection_get_password(gc);
 
 	if (pass && *pass) {
 		buf = irc_format(irc, "vv", "PASS", pass);
--- a/src/protocols/jabber/auth.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/protocols/jabber/auth.c	Sat Mar 26 23:25:18 2005 +0000
@@ -74,7 +74,7 @@
 		response = g_string_append(response, js->user->node);
 		response = g_string_append_len(response, "\0", 1);
 		response = g_string_append(response,
-				gaim_account_get_password(js->gc->account));
+				gaim_connection_get_password(js->gc));
 
 		enc_out = gaim_base64_encode(response->str, response->len);
 
@@ -96,7 +96,7 @@
 		x = xmlnode_new_child(query, "resource");
 		xmlnode_insert_data(x, js->user->resource, -1);
 		x = xmlnode_new_child(query, "password");
-		xmlnode_insert_data(x, gaim_account_get_password(js->gc->account), -1);
+		xmlnode_insert_data(x, gaim_connection_get_password(js->gc), -1);
 		jabber_iq_set_callback(iq, auth_old_result_cb, NULL);
 		jabber_iq_send(iq);
 	}
@@ -201,7 +201,7 @@
 	JabberIq *iq;
 	xmlnode *query, *x;
 	const char *type = xmlnode_get_attrib(packet, "type");
-	const char *pw = gaim_account_get_password(js->gc->account);
+	const char *pw = gaim_connection_get_password(js->gc);
 
 	if(!type) {
 		gaim_connection_error(js->gc, _("Invalid response from server."));
@@ -422,12 +422,12 @@
 
 			a2 = g_strdup_printf("AUTHENTICATE:xmpp/%s", realm);
 			auth_resp = generate_response_value(js->user,
-					gaim_account_get_password(js->gc->account), nonce, cnonce, a2, realm);
+					gaim_connection_get_password(js->gc), nonce, cnonce, a2, realm);
 			g_free(a2);
 
 			a2 = g_strdup_printf(":xmpp/%s", realm);
 			js->expected_rspauth = generate_response_value(js->user,
-					gaim_account_get_password(js->gc->account), nonce, cnonce, a2, realm);
+					gaim_connection_get_password(js->gc), nonce, cnonce, a2, realm);
 			g_free(a2);
 
 
--- a/src/protocols/jabber/jabber.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/protocols/jabber/jabber.c	Sat Mar 26 23:25:18 2005 +0000
@@ -24,6 +24,7 @@
 #include "accountopt.h"
 #include "blist.h"
 #include "cmds.h"
+#include "connection.h"
 #include "debug.h"
 #include "message.h"
 #include "notify.h"
@@ -422,7 +423,10 @@
 conn_close_cb(gpointer data)
 {
 	JabberStream *js = data;
-	gaim_connection_destroy(js->gc);
+	GaimAccount *account = gaim_connection_get_account(js->gc);
+
+	gaim_account_disconnect(account);
+
 	return FALSE;
 }
 
@@ -599,7 +603,7 @@
 		gaim_request_field_group_add_field(group, field);
 
 		field = gaim_request_field_string_new("password", _("Password"),
-				gaim_account_get_password(js->gc->account), FALSE);
+				gaim_connection_get_password(js->gc), FALSE);
 		gaim_request_field_string_set_masked(field, TRUE);
 		gaim_request_field_group_add_field(group, field);
 
--- a/src/protocols/msn/nexus.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/protocols/msn/nexus.c	Sat Mar 26 23:25:18 2005 +0000
@@ -129,7 +129,7 @@
 		g_strdup(gaim_url_encode(gaim_account_get_username(session->account)));
 
 	password =
-		g_strdup(gaim_url_encode(gaim_account_get_password(session->account)));
+		g_strdup(gaim_url_encode(gaim_connection_get_password(session->account->gc)));
 
 	ctint = strtoul((char *)g_hash_table_lookup(nexus->challenge_data, "ct"), NULL, 10) + 200;
 
--- a/src/protocols/msn/notification.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/protocols/msn/notification.c	Sat Mar 26 23:25:18 2005 +0000
@@ -904,7 +904,7 @@
 	g_snprintf(buf, sizeof(buf), "%s%lu%s",
 			   session->passport_info.mspauth,
 			   time(NULL) - session->passport_info.sl,
-			   gaim_account_get_password(account));
+			   gaim_connection_get_password(account->gc));
 
 	cipher = gaim_ciphers_find_cipher("md5");
 	context = gaim_cipher_context_new(cipher, NULL);
--- a/src/protocols/napster/napster.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/protocols/napster/napster.c	Sat Mar 26 23:25:18 2005 +0000
@@ -243,7 +243,7 @@
 	}
 
 	len = header[0];
-	command = header[1];	
+	command = header[1];
 	buf = (gchar *)g_malloc((len + 1) * sizeof(gchar));
 	buf[len] = '\0';
 
@@ -268,7 +268,7 @@
 		gaim_input_remove(gc->inpa);
 		gc->inpa = 0;
 		close(source);
-		gaim_connection_destroy(gc);
+		gaim_connection_error(gc, _("Unknown server error."));
 		break;
 
 	case 003: /* MSG_SERVER_EMAIL */
@@ -333,9 +333,7 @@
 
 	case 316: /* MSG_SERVER_DISCONNECTING */
 		/* we have been kicked off =^( */
-		gaim_notify_error(gc, NULL,
-						  _("You were disconnected from the server."), NULL);
-                gaim_connection_destroy(gc);
+		gaim_connection_error(gc, _("You were disconnected from the server."));
 		break;
 
 	case 401: /* MSG_CLIENT_PART */
@@ -429,10 +427,7 @@
 
 	case 748: /* MSG_SERVER_GHOST */
 		/* Looks like someone logged in as us! =-O */
-		gaim_notify_error(gc, NULL,
-						  _("You were disconnected from the server, because "
-							"you logged on from a different location"), NULL);
-		gaim_connection_destroy(gc);
+		gaim_connection_error(gc, _("You have signed on from another location."));
 		break;
 
 	case 751: /* MSG_CLIENT_PING */
@@ -497,7 +492,7 @@
 	/* Write our signon data */
 	nap_write_packet(gc, 2, "%s %s 0 \"gaim %s\" 0",
 			gaim_account_get_username(gc->account),
-			gaim_account_get_password(gc->account), VERSION);
+			gaim_connection_get_password(gc), VERSION);
 
 	/* And set up the input watcher */
 	gc->inpa = gaim_input_add(ndata->fd, GAIM_INPUT_READ, nap_callback, gc);
--- a/src/protocols/novell/novell.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/protocols/novell/novell.c	Sat Mar 26 23:25:18 2005 +0000
@@ -1709,7 +1709,7 @@
 									2, NOVELL_CONNECT_STEPS);
 
 	my_addr = gaim_network_get_my_ip(gsc->fd);
-	pwd = gaim_account_get_password(user->client_data);
+	pwd = gaim_connection_get_password(gc);
 	ua = _user_agent_string();
 
 	rc = nm_send_login(user, pwd, my_addr, ua, _login_resp_cb, NULL);
--- a/src/protocols/oscar/oscar.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/protocols/oscar/oscar.c	Sat Mar 26 23:25:18 2005 +0000
@@ -2566,7 +2566,6 @@
 	GaimConnection *gc = sess->aux_data;
 	OscarData *od = gc->proto_data;
 	GaimAccount *account = gaim_connection_get_account(gc);
-	GaimAccount *ac = gaim_connection_get_account(gc);
 #if 0
 	struct client_info_s info = {"gaim", 7, 3, 2003, "us", "en", 0x0004, 0x0000, 0x04b};
 #endif
@@ -2579,12 +2578,12 @@
 
 	if (od->icq) {
 		struct client_info_s info = CLIENTINFO_ICQ_KNOWNGOOD;
-		aim_send_login(sess, fr->conn, gaim_account_get_username(ac),
-					   gaim_account_get_password(account), &info, key);
+		aim_send_login(sess, fr->conn, gaim_account_get_username(account),
+					   gaim_connection_get_password(gc), &info, key);
 	} else {
 		struct client_info_s info = CLIENTINFO_AIM_KNOWNGOOD;
-		aim_send_login(sess, fr->conn, gaim_account_get_username(ac),
-					   gaim_account_get_password(account), &info, key);
+		aim_send_login(sess, fr->conn, gaim_account_get_username(account),
+					   gaim_connection_get_password(gc), &info, key);
 	}
 
 	gaim_connection_update_progress(gc, _("Password sent"), 2, OSCAR_CONNECT_STEPS);
--- a/src/protocols/silc/ops.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/protocols/silc/ops.c	Sat Mar 26 23:25:18 2005 +0000
@@ -1537,7 +1537,8 @@
 	if (!sg->detaching)
 		gaim_connection_error(gc, _("Disconnected by server"));
 	else
-		gaim_connection_destroy(gc);
+		/* TODO: Does this work correctly? Maybe we need to set wants_to_die? */
+		gaim_account_disconnect(gaim_connection_get_account(gc));
 }
 
 
--- a/src/protocols/toc/toc.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/protocols/toc/toc.c	Sat Mar 26 23:25:18 2005 +0000
@@ -602,9 +602,9 @@
 				   "Client sends TOC \"toc_signon\" message\n");
 		/* i hate icq. */
 		if (username[0] >= '0' && username[0] <= '9')
-			password = g_strndup(gaim_account_get_password(account), 8);
+			password = g_strndup(gaim_connection_get_password(connection), 8);
 		else
-			password = g_strdup(gaim_account_get_password(account));
+			password = g_strdup(gaim_connection_get_password(connection));
 		g_snprintf(snd, sizeof snd, "toc_signon %s %d  %s %s %s \"%s\"",
 			   AUTH_HOST, AUTH_PORT, gaim_normalize(account, username),
 			   roast_password(password), LANGUAGE, REVISION);
@@ -684,7 +684,7 @@
 			g_snprintf(snd, sizeof snd, "toc_signon %s %d %s %s %s \"%s\"",
 				   AUTH_HOST, AUTH_PORT,
 				   gaim_normalize(account, gaim_account_get_username(account)),
-				   roast_password(gaim_account_get_password(account)),
+				   roast_password(gaim_connection_get_password(connection)),
 				   LANGUAGE, REVISION);
 			if (sflap_send(gc, snd, -1, TYPE_DATA) < 0) {
 				gaim_connection_error(gc, _("Disconnected."));
--- a/src/protocols/trepia/trepia.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/protocols/trepia/trepia.c	Sat Mar 26 23:25:18 2005 +0000
@@ -1000,7 +1000,7 @@
 
 	account = gaim_connection_get_account(session->gc);
 
-	password = gaim_account_get_password(account);
+	password = gaim_connection_get_password(session->gc);
 
 	md5_init(&st);
 	md5_append(&st, (const md5_byte_t *)password, strlen(password));
@@ -1195,7 +1195,7 @@
 		"<f></f><g></g><h></h><i></i><j></j><k></k><l></l>"
 		"<m></m></J>",
 		mac, "", TREPIA_VERSION, gaim_account_get_username(account),
-		gaim_account_get_password(account));
+		gaim_connection_get_password(gc->account));
 }
 
 static GaimPluginProtocolInfo prpl_info =
--- a/src/protocols/yahoo/yahoo.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/protocols/yahoo/yahoo.c	Sat Mar 26 23:25:18 2005 +0000
@@ -920,7 +920,7 @@
 	struct yahoo_packet *pack;
 	GaimAccount *account = gaim_connection_get_account(gc);
 	const char *name = gaim_normalize(account, gaim_account_get_username(account));
-	const char *pass = gaim_account_get_password(account);
+	const char *pass = gaim_connection_get_password(gc);
 	struct yahoo_data *yd = gc->proto_data;
 
 	/* So, Yahoo has stopped supporting its older clients in India, and undoubtedly
@@ -1037,7 +1037,7 @@
 	struct yahoo_packet *pack = NULL;
 	GaimAccount *account = gaim_connection_get_account(gc);
 	const char *name = gaim_normalize(account, gaim_account_get_username(account));
-	const char *pass = gaim_account_get_password(account);
+	const char *pass = gaim_connection_get_password(gc);
 	struct yahoo_data *yd = gc->proto_data;
 
 	GaimCipher 			*md5_cipher;
@@ -2172,7 +2172,7 @@
 	GaimAccount *account = gaim_connection_get_account(gc);
 	struct yahoo_data *yd = gc->proto_data;
 	const char *sn = gaim_account_get_username(account);
-	const char *pass = gaim_account_get_password(account);
+	const char *pass = gaim_connection_get_password(gc);
 	GHashTable *hash = yahoo_login_page_hash(buf, len);
 	GString *url = g_string_new("GET http://login.yahoo.com/config/login?login=");
 	char md5[33], *hashp = md5, *chal;
--- a/src/server.c	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/server.c	Sat Mar 26 23:25:18 2005 +0000
@@ -44,36 +44,6 @@
 #define SECS_BEFORE_RESENDING_AUTORESPONSE 600
 #define SEX_BEFORE_RESENDING_AUTORESPONSE "Only after you're married"
 
-void serv_login(GaimAccount *account, GaimStatus *status)
-{
-	GaimPlugin *p = gaim_find_prpl(gaim_account_get_protocol_id(account));
-	GaimPluginProtocolInfo *prpl_info = NULL;
-
-	if (account->gc == NULL || p == NULL)
-		return;
-
-	prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(p);
-
-	if (prpl_info->login) {
-		if (gaim_account_get_password(account) == NULL &&
-			!(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
-			!(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) {
-			gaim_notify_error(NULL, NULL,
-							  _("Please enter your password"), NULL);
-			return;
-		}
-
-		gaim_debug_info("server", PACKAGE " " VERSION
-						" logging in %s using %s\n",
-						gaim_account_get_username(account),
-						gaim_account_get_protocol_name(account));
-
-		gaim_signal_emit(gaim_accounts_get_handle(),
-						 "account-connecting", account);
-		prpl_info->login(account, status);
-	}
-}
-
 static gboolean send_keepalive(gpointer d)
 {
 	GaimConnection *gc = d;
--- a/src/server.h	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/server.h	Sat Mar 26 23:25:18 2005 +0000
@@ -33,7 +33,6 @@
 extern "C" {
 #endif
 
-void serv_login(GaimAccount *, GaimStatus *);
 void serv_close(GaimConnection *);
 void serv_touch_idle(GaimConnection *);
 int  serv_send_im(GaimConnection *, const char *, const char *, GaimConvImFlags);
--- a/src/status.h	Sat Mar 26 21:22:53 2005 +0000
+++ b/src/status.h	Sat Mar 26 23:25:18 2005 +0000
@@ -53,7 +53,8 @@
  * your accounts is saved so that the next time you start Gaim,
  * your accounts will be set to their last know statuses.  There
  * is also a list of saved statuses that are written to the
- * status.xml file.
+ * status.xml file.  Also, each GaimStatus has a "savable" boolean.
+ * If "savable" is set to FALSE then the status is NEVER saved.
  *
  * A GaimPresence is like a collection of GaimStatuses (plus some
  * other random info).  For any buddy, or for any one of your accounts,