Commits

Ivan Vučica committed d967090

Fixes of iq parsers. More changes of console.log() => zxmppConsole.log().

  • Participants
  • Parent commits 7eb4f82

Comments (0)

Files changed (4)

File zxmpp_caps.js

 			return; 
 		}
 		
-		console.log("Asking " + this.ownerJid + " about caps");
+		zxmppConsole.log("Asking " + this.ownerJid + " about caps");
 		this.zxmpp.stream.sendIqQuery("http://jabber.org/protocol/disco#info", "get", this.ownerJid, false, {"node": this.node + "#" + this.ver});
 		
 		
 			}
 			
 
-			console.log("SENDING for EXT: " + ext);
+			zxmppConsole.log("SENDING for EXT: " + ext);
 			return true;
 		}
 		else
 
 	this.toJSON = function zxmppCaps_toJSON(key)
 	{
-		console.log("zxmppCaps_toJSON()");
+		zxmppConsole.log("zxmppCaps_toJSON()");
 		var oldzxmpp = this.zxmpp;
 		var oldtojson = this.toJSON; // firefox4 beta7; when we return cloned, cleaned copy of this object, it attempts to stringify once again using this same function, causing this.zxmpp to be undefined. we need to remove the function too
 		delete this.zxmpp;

File zxmpp_main.js

 			continue;
 		}
 		
-		if(presence.priority > topPresence.priority)
+		if(presence.priority > topPresence.priority && presence.show != "unavailable")
 		{
 			topPresence = presence;
 		}

File zxmpp_packet.js

 		
 		
 		// now find the stanzas in the body, and parse them
+        // FIXME instead of this loop, use .localName and .nodeNamespace when parsing XML!
 		for(var i in this.xml_body.childNodes)
 		{
 			var child = this.xml_body.childNodes[i];

File zxmpp_stanzaiq.js

 
 				default:
 
-				var __parseWithParserId = function zxmpp_stanzaiq_parseWithParserId(parserId)
+				var __parseWithParserId = function zxmpp_stanzaiq_parseWithParserId(ownerStanza, parserId)
 				{
 					var parsedOk = false;
 					try
 					{
-						if(this.zxmpp.iqParsers && this.zxmpp.iqParsers[parserId] && this.zxmpp.iqParsers[parserId].length)
+						if(ownerStanza.zxmpp.iqParsers && ownerStanza.zxmpp.iqParsers[parserId] && ownerStanza.zxmpp.iqParsers[parserId].length)
 						{
-							var parsers = this.zxmpp.iqParsers[parserId];
+							var parsers = ownerStanza.zxmpp.iqParsers[parserId];
 							for(var i in parsers)
 							{
 								var parser = parsers[i];
 								if(parser.func)
-									parsedOk = parsedOk || parser.func(parser.context, this.zxmpp, this, child);
+									parsedOk = parser.func(parser.context, ownerStanza.zxmpp, ownerStanza, child) || parsedOk;
 								else
-									parsedOk = parsedOk || parser(this.zxmpp, this, child);
+									parsedOk = parser(ownerStanza.zxmpp, ownerStanza, child) || parsedOk;
+                                
 								if(parsedOk)
 									break;
 							}
 
 				var parserId = child.localName + "#" + child.namespaceURI;
 				var parsedOk = false;
-				parsedOk = __parseWithParserId(parserId);
+				parsedOk = __parseWithParserId(this, parserId);
 				if(!parsedOk)
 				{
 					parserId = child.localName;
-					parsedOk = __parseWithParserId(parserId);
+					parsedOk = __parseWithParserId(this, parserId);
 				}
 
 				
 				if(!parsedOk)
 				{
-					zxmppConsole.warn("zxmpp::stanzaIq::parseXML(): Unhandled child " + child.nodeName + " (" + child.nodeName + " in " + child.prefix + " / " + child.namespaceURI + ")");
+					zxmppConsole.warn("zxmpp::stanzaIq::parseXML(): Unhandled child " + child.nodeName + " (" + child.nodeName + " in " + child.prefix + " / " + child.namespaceURI + " - parserId " + parserId + ")");
 					this.iqFail();
 				}
 			}
 		// generate an iq in this packet
 		
 		var iq = packet.xml.createElementNS("jabber:client", "iq");
-		
 		if(!forced_id)
 			iq.setAttribute("id", this.id=this.zxmpp.stream.uniqueId(idtype));
 		else