changeset 10755:fffc664d5294

[gaim-migrate @ 12358] Some TLC for Jabber and Yahoo!. Jabber no longer crashes at signoff. Is Left Eye Lopez the one that burned down that guy's house? committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 27 Mar 2005 19:29:18 +0000
parents 8a97b59f0071
children 897f98b4ca85
files src/connection.c src/protocols/jabber/presence.c src/protocols/yahoo/yahoo.c
diffstat 3 files changed, 25 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/connection.c	Sun Mar 27 19:12:52 2005 +0000
+++ b/src/connection.c	Sun Mar 27 19:29:18 2005 +0000
@@ -82,6 +82,9 @@
 
 	g_return_if_fail(account != NULL);
 
+	if (gaim_account_is_connected(account))
+		return;
+
 	prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));
 
 	if (prpl != NULL)
--- a/src/protocols/jabber/presence.c	Sun Mar 27 19:12:52 2005 +0000
+++ b/src/protocols/jabber/presence.c	Sun Mar 27 19:29:18 2005 +0000
@@ -91,6 +91,8 @@
 {
 	GaimConnection *gc = NULL;
 	JabberStream *js = NULL;
+	gboolean connected;
+	int primitive;
 	xmlnode *presence, *x, *photo;
 	char *stripped = NULL;
 	const char *msg;
@@ -100,15 +102,21 @@
 	if(!gaim_status_is_active(status))
 		return;
 
-	if(!account) return ;
-	gc = account->gc;
-	
-	if (!gc && strcmp(gaim_status_get_id(status), "offline"))
+	connected = gaim_account_is_connected(account);
+	primitive = gaim_status_type_get_primitive(gaim_status_get_type(status));
+
+	if(primitive != GAIM_STATUS_OFFLINE && !connected) {
 		gaim_account_connect(account);
-	
-	if(!gc) return;
-	js= gc->proto_data;
-	
+	} else if(primitive == GAIM_STATUS_OFFLINE && connected) {
+		gaim_account_disconnect(account);
+	}
+
+	if(!connected)
+		return;
+
+	gc = gaim_account_get_connection(account);
+	js = gc->proto_data;
+
 	gaim_status_to_jabber(status, &state, &msg, &priority);
 
 	if(msg)
--- a/src/protocols/yahoo/yahoo.c	Sun Mar 27 19:12:52 2005 +0000
+++ b/src/protocols/yahoo/yahoo.c	Sun Mar 27 19:29:18 2005 +0000
@@ -2760,6 +2760,7 @@
 static void yahoo_set_status(GaimAccount *account, GaimStatus *status)
 {
 	GaimConnection *gc = gaim_account_get_connection(account);
+	gboolean connected = gaim_account_is_connected(account);
 	struct yahoo_data *yd;
 	struct yahoo_packet *pkt;
 	int old_status;
@@ -2770,14 +2771,17 @@
 	id = gaim_status_get_id(status);
 	if (!gaim_status_is_active(status))
 		return;
-	if (strcmp(id, YAHOO_STATUS_TYPE_OFFLINE) && !gc) {
+	if (strcmp(id, YAHOO_STATUS_TYPE_OFFLINE) && !connected) {
 		gaim_account_connect(account);
 		return;
-	} else if (!strcmp(id, YAHOO_STATUS_TYPE_OFFLINE) && gc) {
+	} else if (!strcmp(id, YAHOO_STATUS_TYPE_OFFLINE) && connected) {
 		gaim_account_disconnect(account);
 		return;
 	}
 
+	if (!connected)
+		return;
+
 	yd = (struct yahoo_data *)gc->proto_data;
 	old_status = yd->current_status;