Kamis, 27 Juni 2013

/* * Copyright 2013 Voxeo Labs, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or * implied. See the License for the specific language governing * permissions and limitations under the License. * * Includes third party software from various sources. Portions of this * software are copyright their respective owners. See * http://phono.com/license for copyright statements from Adobe Systems * Incorporated, Kyle Simpson, Getify Solutions, Inc., Paul Johnston, and * Flowplayer. * */ function FABridge(b,a){this.target=b;this.remoteTypeCache={};this.remoteInstanceCache={};this.remoteFunctionCache={};this.localFunctionCache={};this.bridgeID=FABridge.nextBridgeID++;this.name=a;this.nextLocalFuncID=0;FABridge.instances[this.name]=this;FABridge.idMap[this.bridgeID]=this;return this}FABridge.TYPE_ASINSTANCE=1;FABridge.TYPE_ASFUNCTION=2;FABridge.TYPE_JSFUNCTION=3;FABridge.TYPE_ANONYMOUS=4;FABridge.initCallbacks={};FABridge.userTypes={};FABridge.addToUserTypes=function(){for(var a=0;a=0){FABridge.attachBridge(h,d);g=true;break}}}if(g){break}}}}else{var n=document.getElementsByTagName("embed");if(n.length==1){FABridge.attachBridge(n[0],d)}else{for(var f=0;f=0){FABridge.attachBridge(h,d)}}}}return true}FABridge.nextBridgeID=0;FABridge.instances={};FABridge.idMap={};FABridge.refCount=0;FABridge.extractBridgeFromID=function(b){var a=(b>>16);return FABridge.idMap[a]};FABridge.attachBridge=function(a,c){var b=new FABridge(a,c);FABridge[c]=b;var e=FABridge.initCallbacks[c];if(e==null){return}for(var d=0;d0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;retVal=this.target.getPropFromAS(b,a);retVal=this.handleError(retVal);FABridge.refCount--;return retVal}},setPropertyInAS:function(c,b,a){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;retVal=this.target.setPropInAS(c,b,this.serialize(a));retVal=this.handleError(retVal);FABridge.refCount--;return retVal}},callASFunction:function(b,a){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;retVal=this.target.invokeASFunction(b,this.serialize(a));retVal=this.handleError(retVal);FABridge.refCount--;return retVal}},callASMethod:function(b,c,a){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;a=this.serialize(a);retVal=this.target.invokeASMethod(b,c,a);retVal=this.handleError(retVal);FABridge.refCount--;return retVal}},invokeLocalFunction:function(d,b){var a;var c=this.localFunctionCache[d];if(c!=undefined){a=this.serialize(c.apply(null,this.deserialize(b)))}return a},getUserTypeDescriptor:function(b){var c=b.replace(/^([^:]*)\:\:([^:]*)$/,"$2");var e=((typeof window[c]=="function")&&(typeof FABridge.userTypes[c]!="undefined"));var d=false;if(e){d=FABridge.userTypes[c].enriched}var a={simpleType:c,isUserProto:e,protoEnriched:d};return a},getTypeFromName:function(b){var c=this.getUserTypeDescriptor(b);var a=this.remoteTypeCache[b];if(c.isUserProto){if(!c.protoEnriched){for(i in window[c.simpleType].prototype){a[i]=window[c.simpleType].prototype[i]}window[c.simpleType].prototype=a;this.remoteTypeCache[b]=a;FABridge.userTypes[c.simpleType].enriched=true}}return a},createProxy:function(c,b){var d=this.getUserTypeDescriptor(b);var f=this.getTypeFromName(b);if(d.isUserProto){var e=window[d.simpleType];var a=new e(this.name,c);a.fb_instance_id=c}else{instanceFactory.prototype=f;var a=new instanceFactory(c)}this.remoteInstanceCache[c]=a;return a},getProxy:function(a){return this.remoteInstanceCache[a]},addTypeDataToCache:function(d){newType=new ASProxy(this,d.name);var b=d.accessors;for(var c=0;c="a"&&f<="z"){d="get"+f.toUpperCase()+e.substr(1);b="set"+f.toUpperCase()+e.substr(1)}else{d="get"+e;b="set"+e}a[b]=function(c){this.bridge.setPropertyInAS(this.fb_instance_id,e,c)};a[d]=function(){return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id,e))}},addMethodToType:function(a,b){a[b]=function(){return this.bridge.deserialize(this.bridge.callASMethod(this.fb_instance_id,b,FABridge.argsToArray(arguments)))}},getFunctionProxy:function(a){var b=this;if(this.remoteFunctionCache[a]==null){this.remoteFunctionCache[a]=function(){b.callASFunction(a,FABridge.argsToArray(arguments))}}return this.remoteFunctionCache[a]},getFunctionID:function(a){if(a.__bridge_id__==undefined){a.__bridge_id__=this.makeID(this.nextLocalFuncID++);this.localFunctionCache[a.__bridge_id__]=a}return a.__bridge_id__},serialize:function(d){var a={};var c=typeof(d);if(c=="number"||c=="string"||c=="boolean"||c==null||c==undefined){a=d}else{if(d instanceof Array){a=[];for(var b=0;b0){FABridge.refCount--}throw new Error(a[1]);return b}else{return b}}};ASProxy=function(b,a){this.bridge=b;this.typeName=a;return this};ASProxy.prototype={get:function(a){return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id,a))},set:function(b,a){this.bridge.setPropertyInAS(this.fb_instance_id,b,a)},call:function(b,a){this.bridge.callASMethod(this.fb_instance_id,b,a)},addRef:function(){this.bridge.addRef(this)},release:function(){this.bridge.release(this)}};var flensed;if(typeof phonoFlensedOverride!="undefined"){flensed=phonoFlensedOverride}else{flensed={base_path:"//s.phono.com/deps/flensed/1.0/"}}(function($){var Strophe=null;function Phono(config){Strophe=PhonoStrophe;this.config=Phono.util.extend({gateway:"gw-v6.d.phono.com",connectionUrl:window.location.protocol+"//app.v1-1.phono.com/http-bind"},config);if(this.config.connectionUrl.indexOf("file:")==0){this.config.connectionUrl="https://app.v1-1.phono.com/http-bind"}Phono.events.bind(this,config);Phono.util.loggify("Phono",this);if(!config.apiKey){this.config.apiKey=prompt("Please enter your Phono API Key.\n\nTo get a new one sign up for a free account at: http://www.phono.com");if(!this.config.apiKey){var message="A Phono API Key is required. Please get one at http://www.phono.com";Phono.events.trigger(this,"error",{reason:message});throw message}}this.sessionId=null;this.connTimers=[];Phono.log.debug("[CONFIG] ConnectionUrl: "+this.config.connectionUrl);if(navigator.appName.indexOf("Internet Explorer")>0){xmlSerializer={};xmlSerializer.serializeToString=function(body){return body.xml}}else{xmlSerializer=new XMLSerializer()}if(this.config.connection!=null){Strophe=window.Strophe;Strophe.build=$build;Strophe.msg=$msg;Strophe.iq=$iq;Strophe.pres=$pres;this.connection=this.config.connection}else{var phono=this;var cfunc=function(curl){if(!phono.connected()){Phono.log.debug("trying connection URL "+curl);if(phono.connection!=null){phono.connection.disconnect()}phono.connection=new Strophe.Connection(curl);phono.connection.xmlInput=function(body){Phono.log.debug("[WIRE] (i) "+xmlSerializer.serializeToString(body))};phono.connection.xmlOutput=function(body){Phono.log.debug("[WIRE] (o) "+xmlSerializer.serializeToString(body))};phono.connect()}else{Phono.log.debug("[LB] already connected... not trying URL "+curl)}};Phono.log.debug("[LB] Invoke loadbalancer");var dummy=connection=new PhonoStrophe.Connection(this.config.connectionUrl);var a="",b=function(){},c="";var sr=new PhonoStrophe.Request(a,b,c,0);var srvreq=sr.xhr;var curls=[];var uri=document.createElement("a");var srv="_phono";uri.href=this.config.connectionUrl;Phono.log.debug("[LB] OrigT ="+uri.hostname+" path ="+uri.pathname);if(uri.protocol=="https:"){srv=srv+"s"}var dnsUrl=uri.protocol+"//"+uri.host+"/Phono/srvlookup/"+srv+"._tcp."+uri.hostname;srvreq.open("GET",dnsUrl,false);if(srvreq.overrideMimeType){srvreq.overrideMimeType("application/json")}try{srvreq.onreadystatechange=function(){if(srvreq.readyState==4){Phono.log.debug("[LB] Got reply :"+srvreq.status);if(srvreq.status==200){Phono.log.debug("[LB] Reply was "+srvreq.responseText);var srv=eval("("+srvreq.responseText+")");for(var s in srv.servers){var nexts=srv.servers[s];var curl="";var path=uri.pathname;if(uri.hostname==nexts.target){if(path.indexOf("/")!=0){path="/"+path}}else{path="/http-bind"}curl=uri.protocol+"//"+nexts.target+":"+nexts.port+path;if(typeof nexts.target!="undefined"){Phono.log.debug("[LB] Adding connection URL "+curl);curls.push(curl)}}Phono.log.debug("[LB] Adding default connection URL "+phono.config.connectionUrl);curls.push(phono.config.connectionUrl);Phono.log.debug("[LB] Initial connection URL "+curls[0]);var t=0;for(var c in curls){if(curls[c].substring){setTimeout(function(){if(curls[t].substring){cfunc(curls[t])}t=t+1},20+(c*10000))}}}else{Phono.log.debug("[LB] loadbalancer status was "+srvreq.status);Phono.log.debug("[LB] Using default connection URL "+phono.config.connectionUrl);cfunc(phono.config.connectionUrl)}}};srvreq.send(null)}catch(e){Phono.log.debug("[LB] error - ignoring a loadbalance error "+e);Phono.log.debug("[LB] Using default connection URL "+phono.config.connectionUrl);cfunc(phono.config.connectionUrl)}}}(function(){Phono.util={guid:function(){return MD5.hexdigest(new String((new Date()).getTime()))},escapeXmppNode:function(input){var node=input;node=node.replace(/\\/g,"\\5c");node=node.replace(/ /g,"\\20");node=node.replace(/\"/,"\\22");node=node.replace(/&/g,"\\26");node=node.replace(/\'/,"\\27");node=node.replace(/\//g,"\\2f");node=node.replace(/:/g,"\\3a");node=node.replace(//g,"\\3e");node=node.replace(/@/g,"\\40");return node},each:function(object,callback,args){var name,i=0,length=object.length,isObj=length===undefined||$.isFunction(object);if(args){if(isObj){for(name in object){if(callback.apply(object[name],args)===false){break}}}else{for(;i0){uri.directoryPath=uri.directoryPath.replace(/\/?$/,"/")}return uri},filterWideband:function(offer,wideband){var codecs=new Array();Phono.util.each(offer,function(){if(!wideband){if(this.name.toUpperCase()!="G722"&&this.rate!="16000"){codecs.push(this)}}else{codecs.push(this)}});return codecs},isIOS:function(){var userAgent=window.navigator.userAgent;if(userAgent.match(/iPad/i)||userAgent.match(/iPhone/i)){return true}return false},isAndroid:function(){var userAgent=window.navigator.userAgent;if(userAgent.match(/Android/i)){return true}return false},getIEVersion:function(){var rv=-1;if(navigator.appName=="Microsoft Internet Explorer"){var ua=navigator.userAgent;var re=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");if(re.exec(ua)!=null){rv=parseFloat(RegExp.$1)}}console.log("IE Version = "+rv);return rv},localUri:function(fullUri){var splitUri=fullUri.split(":");return splitUri[0]+":"+splitUri[1]+":"+splitUri[2]},loggify:function(objName,obj){for(prop in obj){if(typeof obj[prop]==="function"){Phono.util.loggyFunction(objName,obj,prop)}}return obj},loggyFunction:function(objName,obj,funcName){var original=obj[funcName];obj[funcName]=function(){try{var sep="";var args="";for(var i=0;i=level.level}};PhonoLogLevel.ALL=new PhonoLogLevel(Number.MIN_VALUE,"ALL");PhonoLogLevel.TRACE=new PhonoLogLevel(10000,"TRACE");PhonoLogLevel.DEBUG=new PhonoLogLevel(20000,"DEBUG");PhonoLogLevel.INFO=new PhonoLogLevel(30000,"INFO");PhonoLogLevel.WARN=new PhonoLogLevel(40000,"WARN");PhonoLogLevel.ERROR=new PhonoLogLevel(50000,"ERROR");PhonoLogLevel.FATAL=new PhonoLogLevel(60000,"FATAL");PhonoLogLevel.OFF=new PhonoLogLevel(Number.MAX_VALUE,"OFF");PhonoLogger.prototype.log=function(level,params){var exception;var finalParamIndex=params.length-1;var lastParam=params[params.length-1];if(params.length>1&&isError(lastParam)){exception=lastParam;finalParamIndex--}var messages=[];for(var i=0;i<=finalParamIndex;i++){messages[i]=params[i]}var loggingEvent=new PhonoLogEvent(new Date(),level,messages,exception);this.eventQueue.push(loggingEvent);this.flushEventQueue()};PhonoLogger.prototype.flushEventQueue=function(){if(this.initialized){var logger=this;Phono.util.each(this.eventQueue,function(idx,event){Phono.events.trigger(logger,"log",event)});this.eventQueue=[]}};PhonoLogger.prototype.debug=function(){this.log(PhonoLogLevel.DEBUG,arguments)};PhonoLogger.prototype.info=function(){this.log(PhonoLogLevel.INFO,arguments)};PhonoLogger.prototype.warn=function(){this.log(PhonoLogLevel.WARN,arguments)};PhonoLogger.prototype.error=function(){this.log(PhonoLogLevel.ERROR,arguments)};function getExceptionMessage(ex){if(ex.message){return ex.message}else{if(ex.description){return ex.description}else{return toStr(ex)}}}function getUrlFileName(url){var lastSlashIndex=Math.max(url.lastIndexOf("/"),url.lastIndexOf("\\"));return url.substr(lastSlashIndex+1)}function getExceptionStringRep(ex){if(ex){var exStr="Exception: "+getExceptionMessage(ex);try{if(ex.lineNumber){exStr+=" on line number "+ex.lineNumber}if(ex.fileName){exStr+=" in file "+getUrlFileName(ex.fileName)}}catch(localEx){}if(showStackTraces&&ex.stack){exStr+=newLine+"Stack trace:"+newLine+ex.stack}return exStr}return null}function isError(err){return(err instanceof Error)}function bool(obj){return Boolean(obj)}})();Phono.version="1.0";Phono.log=new PhonoLogger();Phono.registerPlugin=function(name,config){if(!Phono.plugins){Phono.plugins={}}Phono.plugins[name]=config};Phono.prototype.connect=function(){var phono=this;if(!this.config.connection){if(!this.connection.connected){Phono.log.debug("Connecting....");phono.connection.connect(phono.config.gateway,null,phono.handleStropheStatusChange,50)}}else{new PluginManager(this,this.config,function(plugins){this.handleConnect()}).init()}};Phono.prototype.disconnect=function(){this.connection.disconnect()};Phono.prototype.connected=function(){return(typeof(this.connection)!="undefined"&&this.connection.connected)};Phono.prototype.handleStropheStatusChange=function(status){if(status===Strophe.Status.CONNECTED){if(this.connTimer!=null){Phono.log.debug("Clear timeout");clearTimeout(this.connTimer)}new PluginManager(this,this.config,function(plugins){this.handleConnect()}).init()}else{if(status===Strophe.Status.DISCONNECTED){this.handleDisconnect()}else{if(status===Strophe.Status.ERROR||status===Strophe.Status.CONNFAIL||status===Strophe.Status.CONNFAIL||status===Strophe.Status.AUTHFAIL){this.handleError()}}}};Phono.prototype.handleConnect=function(){var phono=this;phono.sessionId=Strophe.getBareJidFromJid(this.connection.jid);if(!this.config.connection){var apiKeyIQ=Strophe.iq({type:"set"}).c("apikey",{xmlns:"http://phono.com/apikey"}).t(phono.config.apiKey).up().c("caps",{xmlns:"http://phono.com/caps",ver:Phono.version});for(pluginName in Phono.plugins){if(phono[pluginName]&&phono[pluginName].getCaps){apiKeyIQ=phono[pluginName].getCaps(apiKeyIQ.c(pluginName));apiKeyIQ.up()}}apiKeyIQ=apiKeyIQ.c("browser",{version:navigator.appVersion,agent:navigator.userAgent}).up();phono.connection.sendIQ(apiKeyIQ,phono.handleKeySuccess,function(){Phono.events.trigger(phono,"error",{reason:"API key rejected"})});if(phono.config.provisioningUrl){phono.connection.send(Strophe.iq({type:"set"}).c("provisioning",{xmlns:"http://phono.com/provisioning"}).t(phono.config.provisioningUrl))}}else{Phono.events.trigger(this,"ready")}};Phono.prototype.handleKeySuccess=function(){Phono.events.trigger(this,"ready")};Phono.prototype.handleError=function(){Phono.log.debug("connection failed - logging in handleError");Phono.events.trigger(this,"error",{reason:"Error connecting to XMPP server"})};Phono.prototype.handleDisconnect=function(){Phono.events.trigger(this,"unready")};(function(c){var E=c,h=c.document,z="undefined",a=true,L=false,g="",o="object",k="function",N="string",l="div",e="onunload",H=null,y=null,K=null,q=null,x=0,i=[],m=null,r=null,G="flXHR.js",n="flensed.js",P="flXHR.vbs",j="checkplayer.js",A="flXHR.swf",u=c.parseInt,w=c.setTimeout,f=c.clearTimeout,s=c.setInterval,v=c.clearInterval,O="instanceId",J="readyState",D="onreadystatechange",M="ontimeout",C="onerror",d="binaryResponseBody",F="xmlResponseText",I="loadPolicyURL",b="noCacheHeader",p="sendTimeout",B="appendToId",t="swfIdPrefix";if(typeof c.flensed===z){c.flensed={}}if(typeof c.flensed.flXHR!==z){return}y=c.flensed;w(function(){var Q=L,ab=h.getElementsByTagName("script"),V=ab.length;try{y.base_path.toLowerCase();Q=a}catch(T){y.base_path=g}function Z(ai,ah,aj){for(var ag=0;ag=0){break}}}var af=h.createElement("script");af.setAttribute("src",y.base_path+ai);if(typeof ah!==z){af.setAttribute("type",ah)}if(typeof aj!==z){af.setAttribute("language",aj)}h.getElementsByTagName("head")[0].appendChild(af)}if((typeof ab!==z)&&(ab!==null)){if(!Q){var ac=0;for(var U=0;U=0)||((ac=ab[U].src.indexOf(G))>=0)){y.base_path=ab[U].src.substr(0,ac);break}}}}}try{y.checkplayer.module_ready()}catch(aa){Z(j,"text/javascript")}var ad=null;(function ae(){try{y.ua.pv.join(".")}catch(af){ad=w(arguments.callee,25);return}if(y.ua.win&&y.ua.ie){Z(P,"text/vbscript","vbscript")}y.binaryToString=function(aj,ai){ai=(((y.ua.win&&y.ua.ie)&&typeof ai!==z)?(!(!ai)):!(y.ua.win&&y.ua.ie));if(!ai){try{return flXHR_vb_BinaryToString(aj)}catch(al){}}var am=g,ah=[];try{for(var ak=0;ak0)){aH=H}if((typeof aR[D]!==z)&&(aR[D]!==null)){aK=aR[D]}if((typeof aR[C]!==z)&&(aR[C]!==null)){aD=aR[C]}if((typeof aR[M]!==z)&&(aR[M]!==null)){aO=aR[M]}}Y=S+"_"+aW;function a0(){f(af);try{E.detachEvent(e,a0)}catch(a3){}}try{E.attachEvent(e,a0)}catch(a1){}(function a2(){try{y.bindEvent(E,e,aI)}catch(a3){af=w(arguments.callee,25);return}a0();af=w(aT,1)})()}();function aT(){if(V===null){Q=h.getElementsByTagName("body")[0]}else{Q=y.getObjectById(V)}try{Q.nodeName.toLowerCase();y.checkplayer.module_ready();K=y.checkplayer}catch(a1){af=w(aT,25);return}if((q===null)&&(typeof K._ins===z)){try{q=new K(r.MIN_PLAYER_VERSION,aU,L,aq)}catch(a0){aP(r.DEPENDENCY_ERROR,"flXHR: checkplayer Init Failed","The initialization of the 'checkplayer' library failed to complete.");return}}else{q=K._ins;ag()}}function ag(){if(q===null||!q.checkPassed){af=w(ag,25);return}if(m===null&&V===null){y.createCSS("."+ae,"left:-1px;top:0px;width:1px;height:1px;position:absolute;");m=a}var a4=h.createElement(l);a4.id=Y;a4.className=ae;Q.appendChild(a4);Q=null;var a1={},a5={allowScriptAccess:"always"},a2={id:Y,name:Y,styleclass:ae},a3={swfCB:aS,swfEICheck:"reset"};try{q.DoSWF(y.base_path+A,Y,"1","1",a1,a5,a2,a3)}catch(a0){aP(r.DEPENDENCY_ERROR,"flXHR: checkplayer Call Failed","A call to the 'checkplayer' library failed to complete.");return}}function aS(a0){if(a0.status!==K.SWF_EI_READY){return}R();aV=y.getObjectById(Y);aV.setId(Y);if(T!==g){aV.loadPolicy(T)}aV.autoNoCacheHeader(au);aV.returnBinaryResponseBody(aC);aV.doOnReadyStateChange=al;aV.doOnError=aP;aV.sendProcessed=ap;aV.chunkResponse=ay;aM=0;ax();aX();if(typeof aK===k){try{aK(ak)}catch(a1){aP(r.HANDLER_ERROR,"flXHR::onreadystatechange(): Error","An error occurred in the handler function. ("+a1.message+")");return}}at()}function aI(){try{c.flensed.unbindEvent(E,e,aI)}catch(a3){}try{for(var a4=0;a40){aH=H}aK=ak[D];aD=ak[C];aO=ak[M];if(ak[I]!==null){if((ak[I]!==T)&&(aM>=0)){aV.loadPolicy(ak[I])}T=ak[I]}if(ak[b]!==null){if((ak[b]!==au)&&(aM>=0)){aV.autoNoCacheHeader(ak[b])}au=ak[b]}if(ak[d]!==null){if((ak[d]!==aC)&&(aM>=0)){aV.returnBinaryResponseBody(ak[d])}aC=ak[d]}if(aA!==null){aA=!(!ak[F])}}catch(a0){}}function aN(){am();try{aV.reset()}catch(a0){}aE=null;aw=null;ac=null;ao=null;aa=null;aL=null;aB=L;aX();T=g;ax()}function aU(a0){if(a0.checkPassed){ag()}else{if(!aJ){aP(r.PLAYER_VERSION_ERROR,"flXHR: Insufficient Flash Player Version","The Flash Player was either not detected, or the detected version ("+a0.playerVersionDetected+") was not at least the minimum version ("+r.MIN_PLAYER_VERSION+") needed by the 'flXHR' library.")}else{q.UpdatePlayer()}}}function aq(a0){if(a0.updateStatus===K.UPDATE_CANCELED){aP(r.PLAYER_VERSION_ERROR,"flXHR: Flash Player Update Canceled","The Flash Player was not updated.")}else{if(a0.updateStatus===K.UPDATE_FAILED){aP(r.PLAYER_VERSION_ERROR,"flXHR: Flash Player Update Failed","The Flash Player was either not detected or could not be updated.")}}}function ap(){if(aH!==null&&aH>0){X=w(W,aH)}}function am(){R();aQ();ax();aM=0;aF=0;try{aV.abort()}catch(a0){aP(r.CALL_ERROR,"flXHR::abort(): Failed","The abort() call failed to complete.")}aX()}function av(){ax();if(typeof arguments[0]===z||typeof arguments[1]===z){aP(r.CALL_ERROR,"flXHR::open(): Failed","The open() call requires 'method' and 'url' parameters.")}else{if(aM>0||aB){aN()}if(aF===0){al(1)}else{aM=1}var a7=arguments[0],a6=arguments[1],a5=(typeof arguments[2]!==z)?arguments[2]:a,ba=(typeof arguments[3]!==z)?arguments[3]:g,a9=(typeof arguments[4]!==z)?arguments[4]:g;try{aV.autoNoCacheHeader(au);aV.open(a7,a6,a5,ba,a9)}catch(a8){aP(r.CALL_ERROR,"flXHR::open(): Failed","The open() call failed to complete.")}}}function az(){ax();if(aM<=1&&!aB){var a1=(typeof arguments[0]!==z)?arguments[0]:g;if(aF===1){al(2)}else{aM=2}try{aV.autoNoCacheHeader(au);aV.send(a1)}catch(a2){aP(r.CALL_ERROR,"flXHR::send(): Failed","The send() call failed to complete.")}}else{aP(r.CALL_ERROR,"flXHR::send(): Failed","The send() call cannot be made at this time.")}}function aj(){ax();if(typeof arguments[0]===z||typeof arguments[1]===z){aP(r.CALL_ERROR,"flXHR::setRequestHeader(): Failed","The setRequestHeader() call requires 'name' and 'value' parameters.")}else{if(!aB){var a3=(typeof arguments[0]!==z)?arguments[0]:g,a2=(typeof arguments[1]!==z)?arguments[1]:g;try{aV.setRequestHeader(a3,a2)}catch(a4){aP(r.CALL_ERROR,"flXHR::setRequestHeader(): Failed","The setRequestHeader() call failed to complete.")}}}}function an(){ax();return g}function ar(){ax();return[]}ak={readyState:aF,responseBody:aa,responseText:ac,responseXML:ao,status:aE,statusText:aw,timeout:aH,open:function(){ax();if(ak[J]===0){ad(1)}if(!Z||aM<0){aZ(av,"open",arguments);return}av.apply({},arguments)},send:function(){ax();if(ak[J]===1){ad(2)}if(!Z||aM<0){aZ(az,"send",arguments);return}az.apply({},arguments)},abort:am,setRequestHeader:function(){ax();if(!Z||aM<0){aZ(aj,"setRequestHeader",arguments);return}aj.apply({},arguments)},getResponseHeader:an,getAllResponseHeaders:ar,onreadystatechange:aK,ontimeout:aO,instanceId:aY,loadPolicyURL:T,noCacheHeader:au,binaryResponseBody:aC,xmlResponseText:aA,onerror:aD,Configure:function(a0){if(typeof a0===o&&a0!==null){if((typeof a0[O]!==z)&&(a0[O]!==null)&&(a0[O]!==g)){aY=a0[O]}if(typeof a0[b]!==z){au=!(!a0[b]);if(aM>=0){aV.autoNoCacheHeader(au)}}if(typeof a0[d]!==z){aC=!(!a0[d]);if(aM>=0){aV.returnBinaryResponseBody(aC)}}if(typeof a0[F]!==z){aA=!(!a0[F])}if((typeof a0[D]!==z)&&(a0[D]!==null)){aK=a0[D]}if((typeof a0[C]!==z)&&(a0[C]!==null)){aD=a0[C]}if((typeof a0[M]!==z)&&(a0[M]!==null)){aO=a0[M]}if((typeof a0[p]!==z)&&((H=u(a0[p],10))>0)){aH=H}if((typeof a0[I]!==z)&&(a0[I]!==null)&&(a0[I]!==g)&&(a0[I]!==T)){T=a0[I];if(aM>=0){aV.loadPolicy(T)}}aX()}},Reset:aN,Destroy:aI};if(ab){i[i.length]=ak}return ak};r=y.flXHR;r.HANDLER_ERROR=10;r.CALL_ERROR=11;r.TIMEOUT_ERROR=12;r.DEPENDENCY_ERROR=13;r.PLAYER_VERSION_ERROR=14;r.SECURITY_ERROR=15;r.COMMUNICATION_ERROR=16;r.MIN_PLAYER_VERSION="9.0.124";r.module_ready=function(){}})(window);var Base64=(function(){var keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var obj={encode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;do{chr1=input.charCodeAt(i++);chr2=input.charCodeAt(i++);chr3=input.charCodeAt(i++);enc1=chr1>>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64}else{if(isNaN(chr3)){enc4=64}}output=output+keyStr.charAt(enc1)+keyStr.charAt(enc2)+keyStr.charAt(enc3)+keyStr.charAt(enc4)}while(i>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2)}if(enc4!=64){output=output+String.fromCharCode(chr3)}}while(i>16)+(y>>16)+(lsw>>16);return(msw<<16)|(lsw&65535)};var bit_rol=function(num,cnt){return(num<>>(32-cnt))};var str2binl=function(str){var bin=[];var mask=(1<>5]|=(str.charCodeAt(i/chrsz)&mask)<<(i%32)}return bin};var binl2str=function(bin){var str="";var mask=(1<>5]>>>(i%32))&mask)}return str};var binl2hex=function(binarray){var hex_tab=hexcase?"0123456789ABCDEF":"0123456789abcdef";var str="";for(var i=0;i>2]>>((i%4)*8+4))&15)+hex_tab.charAt((binarray[i>>2]>>((i%4)*8))&15)}return str};var binl2b64=function(binarray){var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var str="";var triplet,j;for(var i=0;i>2]>>8*(i%4))&255)<<16)|(((binarray[i+1>>2]>>8*((i+1)%4))&255)<<8)|((binarray[i+2>>2]>>8*((i+2)%4))&255);for(j=0;j<4;j++){if(i*8+j*6>binarray.length*32){str+=b64pad}else{str+=tab.charAt((triplet>>6*(3-j))&63)}}}return str};var md5_cmn=function(q,a,b,x,s,t){return safe_add(bit_rol(safe_add(safe_add(a,q),safe_add(x,t)),s),b)};var md5_ff=function(a,b,c,d,x,s,t){return md5_cmn((b&c)|((~b)&d),a,b,x,s,t)};var md5_gg=function(a,b,c,d,x,s,t){return md5_cmn((b&d)|(c&(~d)),a,b,x,s,t)};var md5_hh=function(a,b,c,d,x,s,t){return md5_cmn(b^c^d,a,b,x,s,t)};var md5_ii=function(a,b,c,d,x,s,t){return md5_cmn(c^(b|(~d)),a,b,x,s,t)};var core_md5=function(x,len){x[len>>5]|=128<<((len)%32);x[(((len+64)>>>9)<<4)+14]=len;var a=1732584193;var b=-271733879;var c=-1732584194;var d=271733878;var olda,oldb,oldc,oldd;for(var i=0;i16){bkey=core_md5(bkey,key.length*chrsz)}var ipad=new Array(16),opad=new Array(16);for(var i=0;i<16;i++){ipad[i]=bkey[i]^909522486;opad[i]=bkey[i]^1549556828}var hash=core_md5(ipad.concat(str2binl(data)),512+data.length*chrsz);return core_md5(opad.concat(hash),512+128)};var obj={hexdigest:function(s){return binl2hex(core_md5(str2binl(s),s.length*chrsz))},b64digest:function(s){return binl2b64(core_md5(str2binl(s),s.length*chrsz))},hash:function(s){return binl2str(core_md5(str2binl(s),s.length*chrsz))},hmac_hexdigest:function(key,data){return binl2hex(core_hmac_md5(key,data))},hmac_b64digest:function(key,data){return binl2b64(core_hmac_md5(key,data))},hmac_hash:function(key,data){return binl2str(core_hmac_md5(key,data))},test:function(){return MD5.hexdigest("abc")==="900150983cd24fb0d6963f7d28e17f72"}};return obj})();if(!Function.prototype.bind){Function.prototype.bind=function(obj){var func=this;return function(){return func.apply(obj,arguments)}}}if(!Function.prototype.prependArg){Function.prototype.prependArg=function(arg){var func=this;return function(){var newargs=[arg];for(var i=0;i/g,">");return text},xmlTextNode:function(text){text=Strophe.xmlescape(text);if(!Strophe._xmlGenerator){Strophe._xmlGenerator=Strophe._makeGenerator()}return Strophe._xmlGenerator.createTextNode(text)},getText:function(elem){if(!elem){return null}var str="";if(elem.childNodes.length===0&&elem.nodeType==Strophe.ElementType.TEXT){str+=elem.nodeValue}for(var i=0;i/g,"\\3e").replace(/@/g,"\\40")},unescapeNode:function(node){return node.replace(/\\20/g," ").replace(/\\22/g,'"').replace(/\\26/g,"&").replace(/\\27/g,"'").replace(/\\2f/g,"/").replace(/\\3a/g,":").replace(/\\3c/g,"<").replace(/\\3e/g,">").replace(/\\40/g,"@").replace(/\\5c/g,"\\")},getNodeFromJid:function(jid){if(jid.indexOf("@")<0){return null}return jid.split("@")[0]},getDomainFromJid:function(jid){var bare=Strophe.getBareJidFromJid(jid);if(bare.indexOf("@")<0){return bare}else{var parts=bare.split("@");parts.splice(0,1);return parts.join("@")}},getResourceFromJid:function(jid){var s=jid.split("/");if(s.length<2){return null}s.splice(0,1);return s.join("/")},getBareJidFromJid:function(jid){return jid.split("/")[0]},log:function(level,msg){return},debug:function(msg){this.log(this.LogLevel.DEBUG,msg)},info:function(msg){this.log(this.LogLevel.INFO,msg)},warn:function(msg){this.log(this.LogLevel.WARN,msg)},error:function(msg){this.log(this.LogLevel.ERROR,msg)},fatal:function(msg){this.log(this.LogLevel.FATAL,msg)},serialize:function(elem){var result;if(!elem){return null}if(typeof(elem.tree)==="function"){elem=elem.tree()}var nodeName=elem.nodeName;var i,child;if(elem.getAttribute("_realname")){nodeName=elem.getAttribute("_realname")}result="<"+nodeName;for(i=0;i0){result+=">";for(i=0;i"}else{result+="/>"}return result},_requestId:0,_connectionPlugins:{},addConnectionPlugin:function(name,ptype){Strophe._connectionPlugins[name]=ptype}};Strophe.Builder=function(name,attrs){if(name=="presence"||name=="message"||name=="iq"){if(attrs&&!attrs.xmlns){attrs.xmlns=Strophe.NS.CLIENT}else{if(!attrs){attrs={xmlns:Strophe.NS.CLIENT}}}}this.nodeTree=Strophe.xmlElement(name,attrs);this.node=this.nodeTree};Strophe.Builder.prototype={tree:function(){return this.nodeTree},toString:function(){return Strophe.serialize(this.nodeTree)},up:function(){this.node=this.node.parentNode;return this},attrs:function(moreattrs){for(var k in moreattrs){if(moreattrs.hasOwnProperty(k)){this.node.setAttribute(k,moreattrs[k])}}return this},c:function(name,attrs){var child=Strophe.xmlElement(name,attrs);this.node.appendChild(child);this.node=child;return this},cnode:function(elem){this.node.appendChild(elem);this.node=elem;return this},t:function(text){var child=Strophe.xmlTextNode(text);this.node.appendChild(child);return this}};Strophe.Handler=function(handler,ns,name,type,id,from,options){this.handler=handler;this.ns=ns;this.name=name;this.type=type;this.id=id;this.options=options||{matchbare:false};if(!this.options.matchBare){this.options.matchBare=false}if(this.options.matchBare){this.from=Strophe.getBareJidFromJid(from)}else{this.from=from}this.user=true};Strophe.Handler.prototype={isMatch:function(elem){var nsMatch;var from=null;if(this.options.matchBare){from=Strophe.getBareJidFromJid(elem.getAttribute("from"))}else{from=elem.getAttribute("from")}nsMatch=false;if(!this.ns){nsMatch=true}else{var that=this;Strophe.forEachChild(elem,null,function(elem){if(elem.getAttribute("xmlns")==that.ns){nsMatch=true}});nsMatch=nsMatch||elem.getAttribute("xmlns")==this.ns}if(nsMatch&&(!this.name||Strophe.isTagEqual(elem,this.name))&&(!this.type||elem.getAttribute("type")===this.type)&&(!this.id||elem.getAttribute("id")===this.id)&&(!this.from||from===this.from)){return true}return false},run:function(elem){var result=null;try{result=this.handler(elem)}catch(e){if(e.sourceURL){Strophe.fatal("error: "+this.handler+" "+e.sourceURL+":"+e.line+" - "+e.name+": "+e.message)}else{if(e.fileName){if(typeof(console)!="undefined"){console.trace();console.error(this.handler," - error - ",e,e.message)}Strophe.fatal("error: "+this.handler+" "+e.fileName+":"+e.lineNumber+" - "+e.name+": "+e.message)}else{Strophe.fatal("error: "+this.handler)}}throw e}return result},toString:function(){return"{Handler: "+this.handler+"("+this.name+","+this.id+","+this.ns+")}"}};Strophe.TimedHandler=function(period,handler){this.period=period;this.handler=handler;this.lastCalled=new Date().getTime();this.user=true};Strophe.TimedHandler.prototype={run:function(){this.lastCalled=new Date().getTime();return this.handler()},reset:function(){this.lastCalled=new Date().getTime()},toString:function(){return"{TimedHandler: "+this.handler+"("+this.period+")}"}};Strophe.Request=function(elem,func,rid,sends){this.id=++Strophe._requestId;this.xmlData=elem;this.data=Strophe.serialize(elem);this.origFunc=func;this.func=func;this.rid=rid;this.date=NaN;this.sends=sends||0;this.abort=false;this.dead=null;this.age=function(){if(!this.date){return 0}var now=new Date();return(now-this.date)/1000};this.timeDead=function(){if(!this.dead){return 0}var now=new Date();return(now-this.dead)/1000};this.xhr=this._newXHR()};Strophe.Request.prototype={getResponse:function(){var node=null;if(this.xhr.responseXML&&this.xhr.responseXML.documentElement){node=this.xhr.responseXML.documentElement;if(node.tagName=="parsererror"){Strophe.error("invalid response received");Strophe.error("responseText: "+this.xhr.responseText);Strophe.error("responseXML: "+Strophe.serialize(this.xhr.responseXML));throw"parsererror"}}else{if(this.xhr.responseText){Strophe.error("invalid response received");Strophe.error("responseText: "+this.xhr.responseText);Strophe.error("responseXML: "+Strophe.serialize(this.xhr.responseXML))}}return node},_newXHR:function(){var xhr=null;if(window.XMLHttpRequest){xhr=new XMLHttpRequest();if(xhr.overrideMimeType){xhr.overrideMimeType("text/xml")}}else{if(window.ActiveXObject){xhr=new ActiveXObject("Microsoft.XMLHTTP")}}xhr.onreadystatechange=this.func.prependArg(this);return xhr}};Strophe.Connection=function(service){this.service=service;this.jid="";this.rid=Math.floor(Math.random()*4294967295);this.sid=null;this.streamId=null;this.do_session=false;this.do_bind=false;this.timedHandlers=[];this.handlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[];this._idleTimeout=null;this._disconnectTimeout=null;this.authenticated=false;this.disconnecting=false;this.connected=false;this.errors=0;this.paused=false;this.hold=1;this.wait=60;this.window=5;this._data=[];this._requests=[];this._uniqueId=Math.round(Math.random()*10000);this._sasl_success_handler=null;this._sasl_failure_handler=null;this._sasl_challenge_handler=null;this._idleTimeout=setTimeout(this._onIdle.bind(this),100);for(var k in Strophe._connectionPlugins){if(Strophe._connectionPlugins.hasOwnProperty(k)){var ptype=Strophe._connectionPlugins[k];var F=function(){};F.prototype=ptype;this[k]=new F();this[k].init(this)}}};Strophe.Connection.prototype={reset:function(){this.rid=Math.floor(Math.random()*4294967295);this.sid=null;this.streamId=null;this.do_session=false;this.do_bind=false;this.timedHandlers=[];this.handlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[];this.authenticated=false;this.disconnecting=false;this.connected=false;this.errors=0;this._requests=[];this._uniqueId=Math.round(Math.random()*10000)},pause:function(){this.paused=true},resume:function(){this.paused=false},getUniqueId:function(suffix){if(typeof(suffix)=="string"||typeof(suffix)=="number"){return ++this._uniqueId+":"+suffix}else{return ++this._uniqueId+""}},connect:function(jid,pass,callback,wait,hold){this.jid=jid;this.pass=pass;this.connect_callback=callback;this.disconnecting=false;this.connected=false;this.authenticated=false;this.errors=0;this.wait=wait||this.wait;this.hold=hold||this.hold;this.domain=Strophe.getDomainFromJid(this.jid);var body=this._buildBody().attrs({to:this.domain,"xml:lang":"en",wait:this.wait,hold:this.hold,content:"text/xml; charset=utf-8",ver:"1.6","xmpp:version":"1.0","xmlns:xmpp":Strophe.NS.BOSH});this._changeConnectStatus(Strophe.Status.CONNECTING,null);this._requests.push(new Strophe.Request(body.tree(),this._onRequestStateChange.bind(this).prependArg(this._connect_cb.bind(this)),body.tree().getAttribute("rid")));this._throttledRequestHandler()},attach:function(jid,sid,rid,callback,wait,hold,wind){this.jid=jid;this.sid=sid;this.rid=rid;this.connect_callback=callback;this.domain=Strophe.getDomainFromJid(this.jid);this.authenticated=true;this.connected=true;this.wait=wait||this.wait;this.hold=hold||this.hold;this.window=wind||this.window;this._changeConnectStatus(Strophe.Status.ATTACHED,null)},xmlInput:function(elem){return},xmlOutput:function(elem){return},rawInput:function(data){return},rawOutput:function(data){return},send:function(elem){if(elem===null){return}if(typeof(elem.sort)==="function"){for(var i=0;i0){for(var i=0;i=0;i--){if(req==this._requests[i]){this._requests.splice(i,1)}}req.xhr.onreadystatechange=function(){};this._throttledRequestHandler()},_restartRequest:function(i){var req=this._requests[i];if(req.dead===null){req.dead=new Date()}this._processRequest(i)},_processRequest:function(i){var req=this._requests[i];var reqStatus=-1;try{if(req.xhr.readyState==4){reqStatus=req.xhr.status}}catch(e){Strophe.error("caught an error in _requests["+i+"], reqStatus: "+reqStatus)}if(typeof(reqStatus)=="undefined"){reqStatus=-1}var time_elapsed=req.age();var primaryTimeout=(!isNaN(time_elapsed)&&time_elapsed>Math.floor(Strophe.TIMEOUT*this.wait));var secondaryTimeout=(req.dead!==null&&req.timeDead()>Math.floor(Strophe.SECONDARY_TIMEOUT*this.wait));var requestCompletedWithServerError=(req.xhr.readyState==4&&(reqStatus<1||reqStatus>=500));if(primaryTimeout||secondaryTimeout||requestCompletedWithServerError){if(secondaryTimeout){Strophe.error("Request "+this._requests[i].id+" timed out (secondary), restarting")}req.abort=true;req.xhr.abort();req.xhr.onreadystatechange=function(){};this._requests[i]=new Strophe.Request(req.xmlData,req.origFunc,req.rid,req.sends);req=this._requests[i]}if(req.xhr.readyState===0){Strophe.debug("request id "+req.id+"."+req.sends+" posting");req.date=new Date();try{req.xhr.open("POST",this.service,true)}catch(e2){Strophe.error("XHR open failed.");if(!this.connected){this._changeConnectStatus(Strophe.Status.CONNFAIL,"bad-service")}this.disconnect();return}var sendFunc=function(){try{req.xhr.send(req.data)}catch(e){Strophe.error("send func caught an error in _requests["+i+"], reqStatus: "+req.xhr.status);Strophe.error("exception was "+e)}};if(req.sends>1){var backoff=Math.pow(req.sends,3)*1000;setTimeout(sendFunc,backoff)}else{sendFunc()}req.sends++;this.xmlOutput(req.xmlData);this.rawOutput(req.data)}else{Strophe.debug("_processRequest: "+(i===0?"first":"second")+" request has readyState of "+req.xhr.readyState)}},_throttledRequestHandler:function(){if(!this._requests){Strophe.debug("_throttledRequestHandler called with undefined requests")}else{Strophe.debug("_throttledRequestHandler called with "+this._requests.length+" requests")}if(!this._requests||this._requests.length===0){return}if(this._requests.length>0){this._processRequest(0)}if(this._requests.length>1&&Math.abs(this._requests[0].rid-this._requests[1].rid)=400){this._hitError(reqStatus);return}}var reqIs0=(this._requests[0]==req);var reqIs1=(this._requests[1]==req);if((reqStatus>0&&reqStatus<500)||req.sends>5){this._removeRequest(req);Strophe.debug("request id "+req.id+" should now be removed")}if(reqStatus==200){if(reqIs1||(reqIs0&&this._requests.length>0&&this._requests[0].age()>Math.floor(Strophe.SECONDARY_TIMEOUT*this.wait))){this._restartRequest(0)}Strophe.debug("request id "+req.id+"."+req.sends+" got 200");func(req);this.errors=0}else{Strophe.error("request id "+req.id+"."+req.sends+" error "+reqStatus+" happened");if(reqStatus===0||(reqStatus>=400&&reqStatus<600)||reqStatus>=12000){this._hitError(reqStatus);if(reqStatus>=400&&reqStatus<500){this._changeConnectStatus(Strophe.Status.DISCONNECTING,null);this._doDisconnect()}}}if(!((reqStatus>0&&reqStatus<10000)||req.sends>5)){this._throttledRequestHandler()}}},_hitError:function(reqStatus){this.errors++;Strophe.warn("request errored, status: "+reqStatus+", number of errors: "+this.errors);if(this.errors>4){this._onDisconnectTimeout()}},_doDisconnect:function(){Strophe.info("_doDisconnect was called");this.authenticated=false;this.disconnecting=false;this.sid=null;this.streamId=null;this.rid=Math.floor(Math.random()*4294967295);if(this.connected){this._changeConnectStatus(Strophe.Status.DISCONNECTED,null);this.connected=false}this.handlers=[];this.timedHandlers=[];this.removeTimeds=[];this.removeHandlers=[];this.addTimeds=[];this.addHandlers=[]},_dataRecv:function(req){try{var elem=req.getResponse()}catch(e){if(e!="parsererror"){throw e}this.disconnect("strophe-parsererror")}if(elem===null){return}this.xmlInput(elem);this.rawInput(Strophe.serialize(elem));var i,hand;while(this.removeHandlers.length>0){hand=this.removeHandlers.pop();i=this.handlers.indexOf(hand);if(i>=0){this.handlers.splice(i,1)}}while(this.addHandlers.length>0){this.handlers.push(this.addHandlers.pop())}if(this.disconnecting&&this._requests.length===0){this.deleteTimedHandler(this._disconnectTimeout);this._disconnectTimeout=null;this._doDisconnect();return}var typ=elem.getAttribute("type");var cond,conflict;if(typ!==null&&typ=="terminate"){cond=elem.getAttribute("condition");conflict=elem.getElementsByTagName("conflict");if(cond!==null){if(cond=="remote-stream-error"&&conflict.length>0){cond="conflict"}this._changeConnectStatus(Strophe.Status.CONNFAIL,cond)}else{this._changeConnectStatus(Strophe.Status.CONNFAIL,"unknown")}this.disconnect();return}var that=this;Strophe.forEachChild(elem,null,function(child){var i,newList;newList=that.handlers;that.handlers=[];for(i=0;i0){cond="conflict"}this._changeConnectStatus(Strophe.Status.CONNFAIL,cond)}else{this._changeConnectStatus(Strophe.Status.CONNFAIL,"unknown")}return}if(!this.sid){this.sid=bodyWrap.getAttribute("sid")}if(!this.stream_id){this.stream_id=bodyWrap.getAttribute("authid")}var wind=bodyWrap.getAttribute("requests");if(wind){this.window=parseInt(wind,10)}var hold=bodyWrap.getAttribute("hold");if(hold){this.hold=parseInt(hold,10)}var wait=bodyWrap.getAttribute("wait");if(wait){this.wait=parseInt(wait,10)}var do_sasl_plain=false;var do_sasl_digest_md5=false;var do_sasl_anonymous=false;var mechanisms=bodyWrap.getElementsByTagName("mechanism");var i,mech,auth_str,hashed_auth_str;if(mechanisms.length>0){for(i=0;i0){jidNode=bind[0].getElementsByTagName("jid");if(jidNode.length>0){this.jid=Strophe.getText(jidNode[0]);if(this.do_session){this._addSysHandler(this._sasl_session_cb.bind(this),null,null,null,"_session_auth_2");this.send($iq({type:"set",id:"_session_auth_2"}).c("session",{xmlns:Strophe.NS.SESSION}).tree())}else{this.authenticated=true;this._changeConnectStatus(Strophe.Status.CONNECTED,null)}}}else{Strophe.info("SASL binding failed.");this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false}},_sasl_session_cb:function(elem){if(elem.getAttribute("type")=="result"){this.authenticated=true;this._changeConnectStatus(Strophe.Status.CONNECTED,null)}else{if(elem.getAttribute("type")=="error"){Strophe.info("Session creation failed.");this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false}}return false},_sasl_failure_cb:function(elem){if(this._sasl_success_handler){this.deleteHandler(this._sasl_success_handler);this._sasl_success_handler=null}if(this._sasl_challenge_handler){this.deleteHandler(this._sasl_challenge_handler);this._sasl_challenge_handler=null}this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);return false},_auth2_cb:function(elem){if(elem.getAttribute("type")=="result"){this.authenticated=true;this._changeConnectStatus(Strophe.Status.CONNECTED,null)}else{if(elem.getAttribute("type")=="error"){this._changeConnectStatus(Strophe.Status.AUTHFAIL,null);this.disconnect()}}return false},_addSysTimedHandler:function(period,handler){var thand=new Strophe.TimedHandler(period,handler);thand.user=false;this.addTimeds.push(thand);return thand},_addSysHandler:function(handler,ns,name,type,id){var hand=new Strophe.Handler(handler,ns,name,type,id);hand.user=false;this.addHandlers.push(hand);return hand},_onDisconnectTimeout:function(){Strophe.info("_onDisconnectTimeout was called");var req;while(this._requests.length>0){req=this._requests.pop();req.abort=true;req.xhr.abort();req.xhr.onreadystatechange=function(){}}this._doDisconnect();return false},_onIdle:function(){var i,thand,since,newList;while(this.removeTimeds.length>0){thand=this.removeTimeds.pop();i=this.timedHandlers.indexOf(thand);if(i>=0){this.timedHandlers.splice(i,1)}}while(this.addTimeds.length>0){this.timedHandlers.push(this.addTimeds.pop())}var now=new Date().getTime();newList=[];for(i=0;i0&&!this.paused){body=this._buildBody();for(i=0;i0){time_elapsed=this._requests[0].age();if(this._requests[0].dead!==null){if(this._requests[0].timeDead()>Math.floor(Strophe.SECONDARY_TIMEOUT*this.wait)){this._throttledRequestHandler()}}if(time_elapsed>Math.floor(Strophe.TIMEOUT*this.wait)){Strophe.warn("Request "+this._requests[0].id+" timed out, over "+Math.floor(Strophe.TIMEOUT*this.wait)+" seconds since last activity");this._throttledRequestHandler()}}clearTimeout(this._idleTimeout);this._idleTimeout=setTimeout(this._onIdle.bind(this),100)}};if(callback){callback(Strophe,$build,$msg,$iq,$pres)}})(function(){window.PhonoStrophe=arguments[0];window.PhonoStrophe.build=arguments[1];window.PhonoStrophe.msg=arguments[2];window.PhonoStrophe.iq=arguments[3];window.PhonoStrophe.pres=arguments[4]});PhonoStrophe.addConnectionPlugin("cors",{init:function(){if(window.XDomainRequest){PhonoStrophe.debug("CORS with IE");PhonoStrophe.Request.prototype._newXHR=function(){var stateChange=function(xhr,state){xhr.status=state;xhr.readyState=4;try{xhr.onreadystatechange()}catch(err){}xhr.readyState=0;try{xhr.onreadystatechange()}catch(err){}};var xhr=new XDomainRequest();xhr.readyState=0;xhr.onreadystatechange=this.func.prependArg(this);xhr.onload=function(){xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async="false";xmlDoc.loadXML(xhr.responseText);xhr.responseXML=xmlDoc;stateChange(xhr,200)};xhr.onerror=function(){stateChange(xhr,500)};xhr.ontimeout=function(){stateChange(xhr,500)};xhr.sendFnc=xhr.send;xhr.send=function(value){xhr.readyState=2;return xhr.sendFnc(value)};return xhr}}else{if(new XMLHttpRequest().withCredentials!==undefined){PhonoStrophe.debug("CORS with Firefox/Safari/Chome")}else{if(flensed&&flensed.flXHR){PhonoStrophe.debug("CORS not supported, using flXHR");var poolingSetting=true;if(navigator.userAgent.indexOf("MSIE")!=-1){poolingSetting=false}PhonoStrophe.Request.prototype._newXHR=function(){var xhr=new flensed.flXHR({autoUpdatePlayer:true,instancePooling:poolingSetting,noCacheHeader:false});xhr.onreadystatechange=this.func.prependArg(this);return xhr}}else{PhonoStrophe.error("No CORS and no flXHR. You may experience cross domain turbulence.")}}}}});Phono.events={handlerCount:1,add:function(target,type,handler){type=type.toLowerCase();if(!handler.$$guid){handler.$$guid=this.handlerCount++}if(!target.events){target.events={}}var handlers=target.events[type];if(!handlers){handlers=target.events[type]={};if(target["on"+type]){handlers[0]=target["on"+type]}}handlers[handler.$$guid]=handler;target["on"+type]=this.handle},bind:function(target,config){var name;for(k in config){if(k.match("^on")){this.add(target,k.substr(2).toLowerCase(),config[k])}}},remove:function(target,type,handler){type=type.toLowerCase();if(target.events&&target.events[type]){delete target.events[type][handler.$$guid]}},trigger:function(target,type,event,data){event=event||{};event.type=type;var handler=target["on"+type.toLowerCase()];if(handler){if("log"!=type.toLowerCase()){Phono.log.info("[EVENT] "+type+"["+data+"]")}handler.call(target,event,data)}},handle:function(event,data){var handlers=this.events[event.type.toLowerCase()];event.source=this;var args=new Array();args.push(event);if(data){var i;for(i=0;iFlash version "+b.version+" or greater is required

"+(g[0]>0?"Your version is "+g:"You have no flash plugin installed")+"

"+(a.tagName=="A"?"

Click here to download latest version

":"

Download latest version from here

");if(a.tagName=="A"){a.onclick=function(){location.href=k}}}if(b.onFail){var d=b.onFail.call(this);if(typeof d=="string"){a.innerHTML=d}}}}if(h){window[b.id]=document.getElementById(b.id)}f(this,{getRoot:function(){return a},getOptions:function(){return b},getConf:function(){return c},getApi:function(){return a.firstChild}})}var h=document.all,k="http://www.adobe.com/go/getflashplayer",n=typeof $=="function",o=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,i={width:"100%",height:"100%",id:"_"+(""+Math.random()).slice(9),allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:[3,0],onFail:null,expressInstall:null,w3c:false,cachebusting:false};window.attachEvent&&window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}});window.flashembed=function(a,b,c){if(typeof a=="string"){a=document.getElementById(a.replace("#",""))}if(a){if(typeof b=="string"){b={src:b}}return new m(a,f(f({},i),b),c)}};var e=f(window.flashembed,{conf:i,getVersion:function(){var a;try{a=navigator.plugins["Shockwave Flash"].description.slice(16)}catch(b){try{var c=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");a=c&&c.GetVariable("$version")}catch(d){}}return(a=o.exec(a))?[a[1],a[3]]:[0,0]},asString:function(a){if(a===null||a===undefined){return null}var b=typeof a;if(b=="object"&&a.push){b="array"}switch(b){case"string":a=a.replace(new RegExp('(["\\\\])',"g"),"\\$1");a=a.replace(/^\s?(\d+\.?\d+)%/,"$1pct");return'"'+a+'"';case"array":return"["+l(a,function(d){return e.asString(d)}).join(",")+"]";case"function":return'"function()"';case"object":b=[];for(var c in a){a.hasOwnProperty(c)&&b.push('"'+c+'":'+e.asString(a[c]))}return"{"+b.join(",")+"}"}return String(a).replace(/\s/g," ").replace(/\'/g,'"')},getHTML:function(a,b){a=f({},a);var c=''}a.width=a.height=a.id=a.w3c=a.src=null;a.onFail=a.version=a.expressInstall=null;for(var d in a){if(a[d]){c+=''}}a="";if(b){for(var j in b){if(b[j]){d=b[j];a+=j+"="+(/function|object/.test(typeof d)?e.asString(d):d)+"&"}}a=a.slice(0,-1);c+='"}c+="";return c},isSupported:function(a){return g[0]>a[0]||g[0]==a[0]&&g[1]>=a[1]}}),g=e.getVersion();if(n){$.tools=$.tools||{version:"1.2.2"};$.tools.flashembed={conf:i};$.fn.flashembed=function(a,b){return this.each(function(){$(this).data("flashembed",flashembed(this,a,b))})}}})();(function(){function FlashAudio(phono,config,callback){this.type="flash";this.config=Phono.util.extend({protocol:"rtmfp",swf:"//"+MD5.hexdigest(window.location.host+phono.config.apiKey)+".u.phono.com/releases/"+Phono.version+"/plugins/audio/phono.audio.swf",cirrus:"rtmfp://phono-fms1-ext.voxeolabs.net/phono",bridged:false,reliable:false,media:{audio:true,video:true},watchdog:25000},config);Phono.events.bind(this,config);var containerId=this.config.containerId;if(!containerId){this.config.containerId=containerId=this.createContainer()}Phono.events.bind(this,{onPermissionBoxShow:function(){var p=$("#"+containerId).position();$("#"+containerId).css("left",parseInt(p.left));$("#"+containerId).css("top",parseInt(p.top))}});var plugin=this;FABridge.addInitializationCallback(containerId,function(){Phono.log.info("FlashAudio Ready");plugin.$flash=this.create("Wrapper").getAudio();plugin.$flash.addEventListener(null,function(event){var eventName=(event.getType()+"");Phono.events.trigger(plugin,eventName,{reason:event.getReason()});if(eventName=="mediaError"){Phono.events.trigger(phono,"error",{reason:event.getReason()})}});plugin.$flash.setVersion(Phono.version);callback(plugin)});wmodeSetting="opaque";if((navigator.appVersion.indexOf("X11")!=-1)||(navigator.appVersion.indexOf("Linux")!=-1)||($.browser.opera)){wmodeSetting="window"}window.setInterval(function(){if(!plugin.$flash){Phono.events.trigger(phono,"error",{reason:"Timeout waiting for flash to load."});Phono.log.error("Timeout waiting for flash to load.")}},plugin.config.watchdog);flashembed(containerId,{id:containerId+"id",src:this.config.swf+"?rnd="+new Date().getTime(),wmode:wmodeSetting},{bridgeName:containerId})}FlashAudio.count=0;FlashAudio.prototype.getCaps=function(c){return c.c(this.type,{protocol:this.config.protocol,bridged:this.config.bridged}).up()};FlashAudio.prototype.showPermissionBox=function(){this.$flash.showPermissionBox()};FlashAudio.prototype.permission=function(){return this.$flash.getHasPermission()};FlashAudio.prototype.play=function(transport,autoPlay){url=transport.uri.replace("protocol",this.config.protocol);var luri=url;var uri=Phono.util.parseUri(url);var location=Phono.util.parseUri(document.location);if(uri.protocol=="rtp"){return null}if(url.indexOf("//")==0){luri=location.protocol+":"+url}else{if(uri.protocol.length<2){luri=location.protocol+"://"+location.authority+location.directoryPath+url}}var player;if(this.config.bridged==false&&transport.peerID!=undefined&&this.config.cirrus!=undefined){Phono.log.info("Direct media play with peer "+transport.peerID);player=this.$flash.play(luri,autoPlay,transport.peerID,this.config.video)}else{player=this.$flash.play(luri,autoPlay)}return{url:function(){return player.getUrl()},start:function(){player.start()},stop:function(){player.stop();player.release()},volume:function(value){if(arguments.length===0){return player.getVolume()}else{player.setVolume(value)}}}};FlashAudio.prototype.share=function(transport,autoPlay,codec){var url=transport.uri.replace("protocol",this.config.protocol);var peerID="";if(this.config.bridged==false&&transport.peerID!=undefined&&this.config.cirrus!=undefined){peerID=transport.peerID;Phono.log.info("Direct media share with peer "+transport.peerID)}var isSecure=false;var share=this.$flash.share(url,autoPlay,codec.id,codec.name,codec.rate,true,peerID,this.config.video,this.config.reliable);if(url.indexOf("rtmfp://")==0){isSecure=true}var s={url:function(){return share.getUrl()},codec:function(){var codec=share.getCodec();return{id:codec.getId(),name:codec.getName(),rate:codec.getRate()}},start:function(){share.start()},stop:function(){share.stop();share.release()},digit:function(value,duration,audible){share.digit(value,duration,audible)},gain:function(value){if(arguments.length===0){return share.getGain()}else{share.setGain(value)}},mute:function(value){if(arguments.length===0){return share.getMute()}else{share.setMute(value)}},suppress:function(value){if(arguments.length===0){return share.getSuppress()}else{share.setSuppress(value)}},energy:function(){return{mic:0,spk:0}},secure:function(){return isSecure}};share.addEventListener(null,function(event){var eventName=(event.getType()+"");Phono.events.trigger(s,eventName,{reason:event.getReason()})});return s};FlashAudio.prototype.transport=function(){var $flash=this.$flash;var config=this.config;var cirrus=this.config.cirrus;var plugin=this;var name=this.$flash.getTransport();var description=this.$flash.getDescription();return{name:name,description:description,buildTransport:function(direction,j,callback){var nearID="";if(!config.bridged){var onConnected=function(){if(nearID==""){nearID=$flash.nearID(cirrus);Phono.log.info("Got nearID = "+nearID);if(nearID!=""){j.c("transport",{xmlns:name,peerID:nearID})}else{j.c("transport",{xmlns:name})}callback()}};var connected=$flash.doCirrusConnect(cirrus);Phono.log.info("doCirrusConnect");if(connected){Phono.log.info("doCirrusConnect - already connected");onConnected()}else{Phono.events.add(plugin,"flashConnected",onConnected)}}else{j.c("transport",{xmlns:this.name});callback()}},processTransport:function(t){var pID=t.attr("peerid");var transport;if(pID!=undefined){transport={input:{uri:"rtmfp://invalid/invalid",peerID:pID},output:{uri:"rtmfp://invalid/invalid",peerID:pID}}}t.find("candidate").each(function(){transport={input:{uri:$(this).attr("rtmpUri")+"/"+$(this).attr("playName"),peerID:pID},output:{uri:$(this).attr("rtmpUri")+"/"+$(this).attr("publishName"),peerID:pID}}});return transport},destroyTransport:function(){if(!config.bridged){Phono.log.info("Disconnecting from cirrus server");$flash.doCirrusDisconnect(cirrus)}}}};FlashAudio.prototype.codecs=function(){var result=new Array();var codecs=this.$flash.getCodecs();Phono.util.each(codecs,function(){result.push({id:this.getId(),name:this.getName(),rate:this.getRate()})});return result};FlashAudio.prototype.createContainer=function(phono){var flashDiv=$("
").attr("id","_phono-audio-flash"+(FlashAudio.count++)).addClass("phono_FlashHolder").appendTo("body");flashDiv.css({width:"1px",height:"1px",position:"absolute",top:"50%",left:"50%","margin-top":"-69px","margin-left":"-107px","z-index":"10001",visibility:"visible"});var containerId=$(flashDiv).attr("id");Phono.events.bind(this,{onPermissionBoxShow:function(){$("#"+containerId).css({width:"240px",height:"160px"})},onPermissionBoxHide:function(){$("#"+containerId).css({width:"1px",height:"1px"})}});return containerId};function JavaAudio(phono,config,callback){this.type="java";if(JavaAudio.exists()){this.config=Phono.util.extend({jar:"//s.phono.com/releases/"+Phono.version+"/plugins/audio/phono.audio.jar"},config);Phono.events.bind(this,config);var containerId=this.config.containerId;if(!containerId){this.config.containerId=containerId=_createContainer()}var plugin=this;plugin.$applet=_loadApplet(containerId,this.config.jar,callback,plugin);window.setInterval(function(){var str="Loading...";try{var json=plugin.$applet[0].getJSONStatus();if(json){var statusO=eval("("+json+")");if(!statusO.userTrust){Phono.events.trigger(phono,"error",{reason:"Java Applet not trusted by user - cannot continue"})}else{eps=statusO.endpoints;if(eps.length>0){if((eps[0].sent>50)&&(eps[0].rcvd==0)){Phono.events.trigger(phono,"error",{reason:"Java Applet detected firewall."})}str="share: "+eps[0].uri;str+=" sent "+eps[0].sent;str+=" rcvd "+eps[0].rcvd;str+=" error "+eps[0].error;Phono.log.debug("[JAVA RTP] "+str)}}}else{Phono.events.trigger(phono,"error",{reason:"Java applet did not load."});Phono.log.debug("[JAVA Load errror] no status returned.")}}catch(e){Phono.events.trigger(phono,"error",{reason:"Can not communicate with Java Applet - perhaps it did not load."});Phono.log.debug("[JAVA Load error] "+e)}},25000)}else{Phono.events.trigger(phono,"error",{reason:"Java not available in this browser."})}}JavaAudio.exists=function(){return(navigator.javaEnabled())};JavaAudio.count=0;JavaAudio.prototype.play=function(transport,autoPlay){var url=transport.uri;var applet=this.$applet[0];var player;var luri=url;var uri=Phono.util.parseUri(url);var location=Phono.util.parseUri(document.location);if(uri.protocol=="rtp"){return null}if(url.indexOf("//")==0){luri=location.protocol+":"+url}else{if(uri.protocol.length<2){luri=location.protocol+"://"+location.authority+location.directoryPath+url}}if(autoPlay===undefined){autoPlay=false}player=applet.play(luri,autoPlay);return{url:function(){return player.getUrl()},start:function(){player.start()},stop:function(){player.stop()},volume:function(){if(arguments.length===0){return player.volume()}else{player.volume(value)}}}};JavaAudio.prototype.share=function(transport,autoPlay,codec,srtpPropsl,srtpPropsr){var url=transport.uri;var applet=this.$applet[0];Phono.log.debug("[JAVA share codec ] "+codec.p.pt+" id = "+codec.id);var acodec=applet.mkCodec(codec.p,codec.id);var share;var isSecure=false;if(srtpPropsl!=undefined&&srtpPropsr!=undefined){share=applet.share(url,acodec,autoPlay,srtpPropsl,srtpPropsr);isSecure=true}else{share=applet.share(url,acodec,autoPlay)}return{url:function(){return share.getUrl()},codec:function(){var codec=share.getCodec();return{id:codec.getId(),name:codec.getName(),rate:codec.getRate()}},start:function(){share.start()},stop:function(){share.stop()},digit:function(value,duration,audible){share.digit(value,duration,audible)},gain:function(value){if(arguments.length===0){return share.gain()}else{share.gain(value)}},mute:function(value){if(arguments.length===0){return share.mute()}else{share.mute(value)}},suppress:function(value){if(arguments.length===0){return share.doES()}else{share.doES(value)}},energy:function(){var en=share.energy();return{mic:Math.floor(Math.max((Math.LOG2E*Math.log(en[0])-4),0)),spk:Math.floor(Math.max((Math.LOG2E*Math.log(en[1])-4),0))}},secure:function(){return isSecure}}};JavaAudio.prototype.permission=function(){return true};JavaAudio.prototype.transport=function(){var applet=this.$applet[0];var endpoint=applet.allocateEndpoint();return{name:"urn:xmpp:jingle:transports:raw-udp:1",description:"urn:xmpp:jingle:apps:rtp:1",supportsSRTP:true,buildTransport:function(direction,j,callback){var uri=Phono.util.parseUri(endpoint);j.c("transport",{xmlns:"urn:xmpp:jingle:transports:raw-udp:1"}).c("candidate",{ip:uri.domain,port:uri.port,generation:"1"});callback()},processTransport:function(t){var fullUri;t.find("candidate").each(function(){fullUri=endpoint+":"+$(this).attr("ip")+":"+$(this).attr("port")});return{input:{uri:fullUri},output:{uri:fullUri}}}}};String.prototype.startsWith=function(str){return(this.match("^"+str)==str)};JavaAudio.prototype.codecs=function(){var result=new Array();var applet=this.$applet[0];var codecs=applet.codecs();for(l=0;l0){result.push(mixers[l].name)}}return result};_createContainer=function(){var appletDiv=$("
").attr("id","_phono-appletHolder"+(JavaAudio.count++)).addClass("phono_AppletHolder").appendTo("body");appletDiv.css({width:"1px",height:"1px",position:"absolute",top:"50%",left:"50%","margin-top":"-69px","margin-left":"-107px","z-index":"10001",visibility:"visible"});var containerId=$(appletDiv).attr("id");return containerId};_loadApplet=function(containerId,jar,callback,plugin){var id="_phonoAudio"+(JavaAudio.count++);var callbackName=id+"Callback";window[callbackName]=function(devJson){plugin.audioDeviceList=devJson;t=window.setTimeout(function(){callback(plugin)},10)};var applet=$("").attr("id",id).attr("name",id).attr("code","com.phono.applet.rtp.RTPApplet").attr("archive",jar).attr("width","1px").attr("height","1px").attr("mayscript","true").append($("").attr("name","doEC").attr("value","true")).append($("").attr("name","callback").attr("value",callbackName)).appendTo("#"+containerId);return applet};function PhonegapIOSAudio(phono,config,callback){this.type="phonegap-ios";Phono.events.bind(this,config);var plugin=this;this.initState(callback,plugin)}PhonegapIOSAudio.exists=function(){return((typeof PhoneGap!="undefined")&&Phono.util.isIOS())};PhonegapIOSAudio.codecs=new Array();PhonegapIOSAudio.endpoint="rtp://0.0.0.0";PhonegapIOSAudio.prototype.allocateEndpoint=function(){PhonegapIOSAudio.endpoint="rtp://0.0.0.0";PhoneGap.exec(function(result){console.log("endpoint success: "+result);PhonegapIOSAudio.endpoint=result},function(result){console.log("endpoint fail:"+result)},"Phono","allocateEndpoint",[])};PhonegapIOSAudio.prototype.initState=function(callback,plugin){this.allocateEndpoint();PhoneGap.exec(function(result){console.log("codec success: "+result);var codecs=$.parseJSON(result);for(l=0;l="4"),buildTransport:function(direction,j,callback){console.log("buildTransport: "+endpoint);var uri=Phono.util.parseUri(endpoint);j.c("transport",{xmlns:"urn:xmpp:jingle:transports:raw-udp:1"}).c("candidate",{ip:uri.domain,port:uri.port,generation:"1"});callback()},processTransport:function(t){var fullUri;t.find("candidate").each(function(){fullUri=endpoint+":"+$(this).attr("ip")+":"+$(this).attr("port")});return{input:{uri:fullUri},output:{uri:fullUri}}}}};String.prototype.startsWith=function(str){return(this.match("^"+str)==str)};PhonegapAndroidAudio.prototype.codecs=function(){return PhonegapAndroidAudio.codecs};function JSEPAudio(phono,config,callback){this.type="jsep";Phono.log.info("Initialize JSEP");if(typeof(webkitAudioContext)!=="undefined"){Phono.log.info("Have webkitAudio def");JSEPAudio.webAudioContext=new webkitAudioContext()}else{if(typeof(AudioContext)!=="undefined"){Phono.log.info("Have AudioContext def");JSEPAudio.webAudioContext=new AudioContext()}else{if(typeof(mozAudioContext)!=="undefined"){Phono.log.info("Have mozAudio def");JSEPAudio.webAudioContext=new mozAudioContext()}else{Phono.log.info("No webAudio available - so no freep")}}}if(typeof webkitRTCPeerConnection=="function"){JSEPAudio.GUM=function(p,s,f){navigator.webkitGetUserMedia(p,s,f)};JSEPAudio.mkPeerConnection=function(a,b){return new webkitRTCPeerConnection(a,b)};JSEPAudio.mkSessionDescription=function(a){return new RTCSessionDescription(a)};JSEPAudio.createObjectURL=function(s){return webkitURL.createObjectURL(s)};JSEPAudio.stun="stun:stun.l.google.com:19302";JSEPAudio.attachMediaStream=function(element,stream){element.src=webkitURL.createObjectURL(stream)};JSEPAudio.stripCrypto=function(sdpObj){return sdpObj};JSEPAudio.AudioUrl=function(url){return url};JSEPAudio.addCreateConstraint=function(constraint){return constraint}}else{if(typeof mozRTCPeerConnection=="function"){JSEPAudio.GUM=function(p,s,f){navigator.mozGetUserMedia(p,s,f)};JSEPAudio.mkPeerConnection=function(a,b){return new mozRTCPeerConnection(a,b)};JSEPAudio.mkSessionDescription=function(a){return new mozRTCSessionDescription(a)};JSEPAudio.createObjectURL=function(s){return URL.createObjectURL(s)};JSEPAudio.stun="stun:23.21.150.121";JSEPAudio.attachMediaStream=function(element,stream){element.mozSrcObject=stream;element.play()};JSEPAudio.stripCrypto=function(sdpObj){Phono.util.each(sdpObj.contents,function(){if(this.crypto){delete this.crypto}});return sdpObj};JSEPAudio.AudioUrl=function(url){return url.replace(".mp3",".ogg")};JSEPAudio.addCreateConstraint=function(constraint){constraint.mandatory.MozDontOfferDataChannel=true;return constraint}}}JSEPAudio.spk=0;JSEPAudio.mic=0;this.config=Phono.util.extend({media:{audio:true,video:false}},config);var plugin=this;var localContainerId=this.config.localContainerId;if(!localContainerId){this.config.localContainerId=this.createContainer()}JSEPAudio.localVideo=document.getElementById(this.config.localContainerId);callback(plugin)}JSEPAudio.exists=function(){if(typeof webkitRTCPeerConnection=="function"){return true}if(typeof mozRTCPeerConnection=="function"){try{mozRTCPeerConnection()}catch(err){return false}return true}};JSEPAudio.prototype.getCaps=function(c){return c.c(this.type).up()};JSEPAudio.count=0;JSEPAudio.toneMap={"0":[1336,941],"1":[1209,697],"2":[1336,697],"3":[1477,696],"4":[1209,770],"5":[1336,770],"6":[1477,770],"7":[1209,852],"8":[1336,852],"9":[1447,852],"*":[1209,941],"#":[1477,941]};JSEPAudio.prototype.play=function(transport,autoPlay){var url=null;var audioPlayer=null;if(transport.uri){url=JSEPAudio.AudioUrl(transport.uri)}return{url:function(){return url},start:function(){if(url){audioPlayer=new Audio(url);var loop=function(){audioPlayer=new Audio(url);audioPlayer.play();audioPlayer.addEventListener("ended",loop)};loop()}},stop:function(){if(audioPlayer){audioPlayer.pause()}audioPlayer=null},volume:function(value){if(arguments.length===0){return transport.volume*100}else{transport.volume=(value/100)}}}};JSEPAudio.prototype.share=function(transport,autoPlay,codec){var share;return{url:function(){return null},codec:function(){return codec},start:function(){return null},stop:function(){if(JSEPAudio.localStream){JSEPAudio.localStream.stop()}},gain:function(value){return null},mute:function(value){var tracks=[];if(JSEPAudio.localStream.getAudioTracks){tracks=JSEPAudio.localStream.getAudioTracks()}if(arguments.length===0){var muted=true;Phono.util.each(tracks,function(){if(this.enabled==true){muted=false}});return muted}if(value==true){Phono.util.each(tracks,function(){this.enabled=false})}else{Phono.util.each(tracks,function(){this.enabled=true})}},suppress:function(value){return null},energy:function(){if((JSEPAudio.pc)&&(JSEPAudio.pc.getStats)){JSEPAudio.pc.getStats(function(stats){var sr=stats.result();for(var i=0;i0){JSEPAudio.mic=Math.floor(Math.max((Math.LOG2E*Math.log(nmic)-4),0))}if(obj.stat("audioOutputLevel")){nspk=obj.stat("audioOutputLevel")}if(nspk>0){JSEPAudio.spk=Math.floor(Math.max((Math.LOG2E*Math.log(nspk)-4),0))}}}})}return{mic:JSEPAudio.mic,spk:JSEPAudio.spk}},secure:function(){return true},freep:function(value,duration,audible){if(audible){var context=JSEPAudio.webAudioContext;if(context){var note1;var note2;if(duration<100){duration=100}note1=context.createOscillator();note2=context.createOscillator();note1.connect(context.destination);note2.connect(context.destination);var twoTone=JSEPAudio.toneMap[value];note1.frequency.value=twoTone[0];note2.frequency.value=twoTone[1];note1.noteOn(0);note2.noteOn(0);window.setTimeout(function(){note1.noteOff(0);note2.noteOff(0)},duration)}}}}};JSEPAudio.prototype.showPermissionBox=function(callback){Phono.log.info("Requesting access to local media");JSEPAudio.GUM({audio:this.config.media.audio,video:this.config.media.video},function(stream){JSEPAudio.localStream=stream;JSEPAudio.localVideo.style.opacity=1;JSEPAudio.attachMediaStream(JSEPAudio.localVideo,stream);JSEPAudio.localVideo.muted="muted";if(typeof callback=="function"){callback(true)}},function(error){Phono.log.info("Failed to get access to local media. Error code was "+error.code);alert("Failed to get access to local media. Error code was "+error.code+".");if(typeof callback=="function"){callback(false)}})};JSEPAudio.prototype.permission=function(){return(JSEPAudio.localStream!=undefined)};JSEPAudio.prototype.transport=function(config){var pc;var inboundOffer;var configuration={iceServers:[{url:JSEPAudio.stun}]};var offerconstraints;var peerconstraints;var remoteContainerId;var complete=false;var audio=this;var candidateCount=0;offerconstraints={mandatory:{OfferToReceiveAudio:this.config.media.audio,OfferToReceiveVideo:this.config.media.video}};offerconstraints=JSEPAudio.addCreateConstraint(offerconstraints);peerconstraints={optional:[{DtlsSrtpKeyAgreement:"true"}]};if(!config||!config.remoteContainerId){if(this.config.remoteContainerId){remoteContainerId=this.config.remoteContainerId}else{remoteContainerId=this.createContainer()}}else{remoteContainerId=config.remoteContainerId}var remoteVideo=document.getElementById(remoteContainerId);return{name:"urn:xmpp:jingle:transports:ice-udp:1",buildTransport:function(direction,j,callback,u,updateCallback){pc=JSEPAudio.mkPeerConnection(configuration,peerconstraints);JSEPAudio.pc=pc;var oic=function(evt){if(!complete){if((evt.candidate==null)||(candidateCount>=1&&!audio.config.media.video&&direction=="answer")){Phono.log.info("All Ice candidates in ");complete=true;var sdp=pc.localDescription.sdp;Phono.log.info("SDP "+JSON.stringify(sdp));var sdpObj=Phono.sdp.parseSDP(sdp);Phono.log.info("SdpObj "+JSON.stringify(sdpObj));Phono.sdp.buildJingle(j,sdpObj);var codecId=0;if(sdpObj.contents[0].codecs[0].name=="telephone-event"){codecId=1}var codec={id:sdpObj.contents[0].codecs[codecId].id,name:sdpObj.contents[0].codecs[codecId].name,rate:sdpObj.contents[0].codecs[codecId].clockrate};callback(codec)}else{Phono.log.info("An Ice candidate ");candidateCount+=1}}};pc.onicecandidate=oic;pc.onaddstream=function(event){Phono.log.info("onAddStream. Attaching");JSEPAudio.attachMediaStream(remoteVideo,event.stream);remoteVideo.style.opacity=1};Phono.log.debug("Adding localStream");var cb2=function(){pc.addStream(JSEPAudio.localStream);var setlfail=function(er){Phono.log.error("failed to setlocal "+er)};var setlok=function(){Phono.log.info("setlocal ok")};var cb=function(localDesc){var sd=JSEPAudio.mkSessionDescription(localDesc);pc.setLocalDescription(sd,setlok,setlfail);window.setTimeout(function(){oic({})},1000);Phono.log.info("Set local description "+JSON.stringify(localDesc))};var offerfail=function(){Phono.log.error("failed to create offer")};var ansfail=function(){Phono.log.error("failed to create answer")};if(direction=="answer"){Phono.log.info("Set remote description "+JSON.stringify(inboundOffer));pc.setRemoteDescription(inboundOffer,function(){Phono.log.debug("remoteDescription happy");pc.createAnswer(cb,ansfail)},function(){Phono.log.error("remoteDescription error")})}else{Phono.log.info("create offer with "+JSON.stringify(offerconstraints));pc.createOffer(cb,offerfail,offerconstraints)}};if(audio.permission()){cb2()}else{audio.showPermissionBox(cb2)}},processTransport:function(t,update,iq){var sdpObj=Phono.sdp.parseJingle(iq);Phono.log.info("Made remote sdp Obj"+JSON.stringify(sdpObj));sdpObj=JSEPAudio.stripCrypto(sdpObj);var sdp=Phono.sdp.buildSDP(sdpObj);Phono.log.info("constructed remote sdp "+JSON.stringify(sdp));var codecId=0;if(sdpObj.contents[0].codecs[0].name=="telephone-event"){codecId=1}var codec={id:sdpObj.contents[0].codecs[codecId].id,name:sdpObj.contents[0].codecs[codecId].name,rate:sdpObj.contents[0].codecs[codecId].clockrate};if(pc){Phono.log.info("Got remote sdp "+JSON.stringify(sdp));var sd=JSEPAudio.mkSessionDescription({sdp:sdp,type:"answer"});Phono.log.info("Set remote description "+JSON.stringify(sd));pc.setRemoteDescription(sd,function(){Phono.log.debug("remoteDescription happy")},function(){Phono.log.error("remoteDescription sad")})}else{Phono.log.info("Got remote description "+JSON.stringify(sdp));var sd=JSEPAudio.mkSessionDescription({sdp:sdp,type:"offer"});inboundOffer=sd}return{codec:codec,input:remoteVideo}},destroyTransport:function(){if(pc){pc.close();if(($(remoteVideo).attr("id")).indexOf("_phono-audio-webrtc")==0){remoteVideo.parentNode.removeChild(remoteVideo)}}if(JSEPAudio.localStream){JSEPAudio.localStream.stop();JSEPAudio.localStream=null}}}};JSEPAudio.prototype.codecs=function(){return{}};JSEPAudio.prototype.audioInDevices=function(){var result=new Array();return result};JSEPAudio.prototype.createContainer=function(){var webRTC=$("