/*------------------------------------------------------ Library Name: "datenkueche-jabber-connector" Version: 0.23 This is a pure XML (AJAX) low level library for Javascript to jabber http-binding (jep-0124) 2006 Bernhard Zwischenbrugger bz@datenkueche.com (C) LGPL (http://www.gnu.org/licenses/lgpl.html) If you need a different licence please ask. If you extend this file, please write your name here: Knows Bugs: - It' not really object oriented Change log: ----------------------------------------------------*/ function jabberConnect(loginserver){ this.lastSent="unknown"; this.lastlastSent="unknown"; this.lastReceived="unknown"; this.lastReceiveStatus="unknown"; this.lastReadyState="unknown"; this.ready="yes"; this.timestamp=0; this.timeout=null; this.delay="unknown"; this.debug=0; this.requestCount=0; this.requests=0; this.errorText="success"; this.error=false; this.fifoArray=new Array(); this.rid=Math.round(Math.random()*999999); var xml="
"; this.rid++; xml+=sendThis; xml+="\n\n"; this.lastlastSent=this.lastSent; this.lastSent=xml; xmlhttp.open("POST", jep124server, true); var obj=this; xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { //no idea where the empty string comes form if(xmlhttp.responseText==""){ return; } //alert(xmlhttp.responseText); jabber.lastReadyState=4; jabber.lastReceived=xmlhttp.responseText; //alert("receive: "+obj.requests); jabber.requests--; //this breaks everything !!!!!!!!!!!!!!!!!!!!! //jabber.status(); datenkueche_com_jabbercallback(xmlhttp,obj); //really bad!!!!!!!!!! }else{ //jabber.lastReadyState=xmlhttp.readyState; //jabber.status(); } } this.requestCount++; jabber.status(); xmlhttp.send(xml); //alert(xml); } function datenkueche_com_jabbercallback(xmlhttp,obj) { try{ var status=xmlhttp.status; }catch(e){ if(obj.requests < 1){ obj.send(''); } obj.errorText="empty and no status"; obj.status(); return; } if (status == 200) { obj.lastStatus=status; //alert(xmlhttp.responseText); if(xmlhttp.responseXML!=null){ this.ready="no"; for(var i=0; i < xmlhttp.responseXML.documentElement.childNodes.length; i++){ //call the function provided by the user if((typeof receive == "function")){ receive(xmlhttp.responseXML.documentElement.childNodes.item(i)); }else{ alert("Function 'receive(stanza)' missing, please provide this callback function"); } } this.ready="yes"; if(obj.requests < 1){ obj.debug++; //obj.send(''); obj.send(''); //obj.timeout=setTimeout("obj.send('')",2000); //setTimeout("jabber.send('')",200000); } }else{ obj.error=true; obj.errorText="XML Parse error"; obj.status(); } }else{ obj.error=true; obj.errorText="HTTP Code != 200"; obj.lastStatus=xmlhttp.status; obj.status(); } xmlhttp.abort(); } function sha1(s){ function X(x,y){var l=(x&0xFFFF)+(y&0xFFFF),m=(x>>16)+(y>>16)+(l>>16);return(m<<16)|(l&0xFFFF)} function Y(x,y){return(x<