diff src/protocols/jabber/presence.c @ 7395:b250288fa948

[gaim-migrate @ 7990] this would be the non-working start of file transfer (the real way) for jabber also approximately eleventy billion jabber tweaks committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Fri, 31 Oct 2003 02:43:58 +0000
parents ab828b8c3f22
children 85cd2e71bff7
line wrap: on
line diff
--- a/src/protocols/jabber/presence.c	Fri Oct 31 01:38:46 2003 +0000
+++ b/src/protocols/jabber/presence.c	Fri Oct 31 02:43:58 2003 +0000
@@ -145,7 +145,7 @@
 	JabberID *jid;
 	JabberChat *chat;
 	JabberBuddy *jb;
-	JabberBuddyResource *jbr;
+	JabberBuddyResource *jbr = FALSE;
 	GaimBuddy *b;
 	char *buddy_name;
 	int state = 0;
@@ -298,6 +298,7 @@
 		}
 		g_free(room_jid);
 	} else {
+		gboolean newly_online = FALSE;
 		if(state != JABBER_STATE_ERROR && !(jb->subscription & JABBER_SUB_TO)) {
 			gaim_debug(GAIM_DEBUG_INFO, "jabber",
 					"got unexpected presence from %s, ignoring\n", from);
@@ -314,13 +315,17 @@
 		}
 
 		if(state == JABBER_STATE_ERROR ||
-				(type && !strcasecmp(type, "unavailable")))
+				(type && !strcasecmp(type, "unavailable"))) {
 			jabber_buddy_remove_resource(jb, jid->resource);
-		else
+		} else {
+			if(!(jbr = jabber_buddy_find_resource(jb, jid->resource)))
+				newly_online = TRUE;
 			jabber_buddy_track_resource(jb, jid->resource, priority, state,
 					status);
+		}
 
-		jbr = jabber_buddy_find_resource(jb, jid->resource);
+		if(!jbr)
+			jbr = jabber_buddy_find_resource(jb, jid->resource);
 
 		if(jbr)
 			serv_got_update(js->gc, buddy_name, 1, 0, b->signon, b->idle,
@@ -328,6 +333,13 @@
 		else
 			serv_got_update(js->gc, buddy_name, 0, 0, 0, 0, 0);
 
+		if(newly_online) {
+			JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_GET,
+					"http://jabber.org/protocol/disco#info");
+			xmlnode_set_attrib(iq->node, "to", from);
+			jabber_iq_send(iq);
+		}
+
 		g_free(buddy_name);
 	}
 	g_free(status);