src/protocols/jabber/presence.c

changeset 10755
a336a5d3102d
parent 10738
63ca8277c234
child 10941
7a67db0a7f43
--- 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)

mercurial