webphone_api.platformClass=function(){"use strict";function e(e){return e=String(e),e.charAt(0).toUpperCase()+e.slice(1)}function n(e,n,t){var i={"11.0":"11","10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return n&&t&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(i=i[/[\d.]+$/.exec(e)])&&(e="Windows "+i),e=String(e),n&&t&&(e=e.replace(RegExp(n,"i"),t)),e=o(e.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}function t(e,n){var t=-1,o=e?e.length:0;if("number"==typeof o&&o>-1&&o<=b)for(;++t3&&"WebKit"||/\bOpera\b/.test(M)&&(/\bOPR\b/.test(e)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(e)&&!/^(?:Trident|EdgeHTML)$/.test(F)&&"WebKit"||!F&&/\bMSIE\b/i.test(e)&&("Mac OS"==j?"Tasman":"Trident")||"WebKit"==F&&/\bPlayStation\b(?! Vita\b)/i.test(M)&&"NetFront")&&(F=[O]),"IE"==M&&(O=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(e)||0)[1])?(M+=" Mobile",j="Windows Phone "+(/\+$/.test(O)?O:O+".x"),k.unshift("desktop mode")):/\bWPDesktop\b/i.test(e)?(M="IE Mobile",j="Windows Phone 8.x",k.unshift("desktop mode"),W||(W=(/\brv:([\d.]+)/.exec(e)||0)[1])):"IE"!=M&&"Trident"==F&&(O=/\brv:([\d.]+)/.exec(e))&&(M&&k.push("identifying as "+M+(W?" "+W:"")),M="IE",W=O[1]),V){if(r(m,"global"))if(C&&(O=C.lang.System,A=O.getProperty("os.arch"),j=j||O.getProperty("os.name")+" "+O.getProperty("os.version")),G){try{W=m.require("ringo/engine").version.join("."),M="RingoJS"}catch(z){(O=m.system)&&O.global.system==m.system&&(M="Narwhal",j||(j=O[0].os||null))}M||(M="Rhino")}else"object"==typeof m.process&&!m.process.browser&&(O=m.process)&&("object"==typeof O.versions&&("string"==typeof O.versions.electron?(k.push("Node "+O.versions.node),M="Electron",W=O.versions.electron):"string"==typeof O.versions.nw&&(k.push("Chromium "+W,"Node "+O.versions.node),M="NW.js",W=O.versions.nw)),M||(M="Node.js",A=O.arch,j=O.platform,W=/[\d.]+/.exec(O.version),W=W?W[0]:null));else a(O=m.runtime)==T?(M="Adobe AIR",j=O.flash.system.Capabilities.os):a(O=m.phantom)==I?(M="PhantomJS",W=(O=O.version||null)&&O.major+"."+O.minor+"."+O.patch):"number"==typeof y.documentMode&&(O=/\bTrident\/(\d+)/i.exec(e))?(W=[W,y.documentMode],(O=+O[1]+4)!=W[1]&&(k.push("IE "+W[1]+" mode"),F&&(F[1]=""),W[1]=O),W="IE"==M?String(W[1].toFixed(1)):W[0]):"number"==typeof y.documentMode&&/^(?:Chrome|Firefox)\b/.test(M)&&(k.push("masking as "+M+" "+W),M="IE",W="11.0",F=["Trident"],j="Windows");j=j&&o(j)}if(W&&(O=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(W)||/(?:alpha|beta)(?: ?\d)?/i.exec(e+";"+(V&&b.appMinorVersion))||/\bMinefield\b/i.test(e)&&"a")&&(U=/b/i.test(O)?"beta":"alpha",W=W.replace(RegExp(O+"\\+?$"),"")+("beta"==U?R:L)+(/\d+\+?/.exec(O)||"")),"Fennec"==M||"Firefox"==M&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(j))M="Firefox Mobile";else if("Maxthon"==M&&W)W=W.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(H))"Xbox 360"==H&&(j=null),"Xbox 360"==H&&/\bIEMobile\b/.test(e)&&k.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(M)&&(!M||H||/Browser|Mobi/.test(M))||"Windows CE"!=j&&!/Mobi/i.test(e))if("IE"==M&&V)try{null===m.external&&k.unshift("platform preview")}catch(z){k.unshift("embedded")}else(/\bBlackBerry\b/.test(H)||/\bBB10\b/.test(e))&&(O=(RegExp(H.replace(/ +/g," *")+"/([.\\d]+)","i").exec(e)||0)[1]||W)?(O=[O,/BB10/.test(e)],j=(O[1]?(H=null,B="BlackBerry"):"Device Software")+" "+O[0],W=null):this!=i&&"Wii"!=H&&(V&&D||/Opera/.test(M)&&/\b(?:MSIE|Firefox)\b/i.test(e)||"Firefox"==M&&/\bOS X (?:\d+\.){2,}/.test(j)||"IE"==M&&(j&&!/^Win/.test(j)&&W>5.5||/\bWindows XP\b/.test(j)&&W>8||8==W&&!/\bTrident\b/.test(e)))&&!_.test(O=c.call(i,e.replace(_,"")+";"))&&O.name&&(O="ing as "+O.name+((O=O.version)?" "+O:""),_.test(M)?(/\bIE\b/.test(O)&&"Mac OS"==j&&(j=null),O="identify"+O):(O="mask"+O,M=E?o(E.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(O)&&(j=null),V||(W=null)),F=["Presto"],k.push(O));else M+=" Mobile";(O=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(e)||0)[1])&&(O=[parseFloat(O.replace(/\.(\d)$/,".0$1")),O],"Safari"==M&&"+"==O[1].slice(-1)?(M="WebKit Nightly",U="alpha",W=O[1].slice(0,-1)):W!=O[1]&&W!=(O[2]=(/\bSafari\/([\d.]+\+?)/i.exec(e)||0)[1])||(W=null),O[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(e)||0)[1],537.36==O[0]&&537.36==O[2]&&parseFloat(O[1])>=28&&"WebKit"==F&&(F=["Blink"]),V&&(P||O[1])?(F&&(F[1]="like Chrome"),O=O[1]||(O=O[0],O<530?1:O<532?2:O<532.05?3:O<533?4:O<534.03?5:O<534.07?6:O<534.1?7:O<534.13?8:O<534.16?9:O<534.24?10:O<534.3?11:O<535.01?12:O<535.02?"13+":O<535.07?15:O<535.11?16:O<535.19?17:O<536.05?18:O<536.1?19:O<537.01?20:O<537.11?"21+":O<537.13?23:O<537.18?24:O<537.24?25:O<537.36?26:"Blink"!=F?"27":"28")):(F&&(F[1]="like Safari"),O=O[0],O=O<400?1:O<500?2:O<526?3:O<533?4:O<534?"4+":O<535?5:O<537?6:O<538?7:O<601?8:O<602?9:O<604?10:O<606?11:O<608?12:"12"),F&&(F[1]+=" "+(O+="number"==typeof O?".x":/[.+]/.test(O)?"":"+")),"Safari"==M&&(!W||parseInt(W)>45)?W=O:"Chrome"==M&&/\bHeadlessChrome/i.test(e)&&k.unshift("headless")),"Opera"==M&&(O=/\bzbov|zvav$/.exec(j))?(M+=" ",k.unshift("desktop mode"),"zvav"==O?(M+="Mini",W=null):M+="Mobile",j=j.replace(RegExp(" *"+O+"$"),"")):"Safari"==M&&/\bChrome\b/.exec(F&&F[1])?(k.unshift("desktop mode"),M="Chrome Mobile",W=null,/\bOS X\b/.test(j)?(B="Apple",j="iOS 4.3+"):j=null):/\bSRWare Iron\b/.test(M)&&!W&&(W=u("Chrome")),W&&0==W.indexOf(O=/[\d.]+$/.exec(j))&&e.indexOf("/"+O+"-")>-1&&(j=p(j.replace(O,""))),j&&-1!=j.indexOf(M)&&!RegExp(M+" OS").test(j)&&(j=j.replace(RegExp(" *"+l(M)+" *"),"")),F&&!/\b(?:Avant|Nook)\b/.test(M)&&(/Browser|Lunascape|Maxthon/.test(M)||"Safari"!=M&&/^iOS/.test(j)&&/\bSafari\b/.test(F[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(M)&&F[1])&&(O=F[F.length-1])&&k.push(O),(void 0===j||null==j||j.length<1)&&(e.toLowerCase().indexOf("windows")>=0||w.toLowerCase().indexOf("win32")>=0?j="Windows":e.toLowerCase().indexOf("android")>=0||w.toLowerCase().indexOf("android")>=0?j="Android":e.toLowerCase().indexOf("ios")>=0||w.toLowerCase().indexOf("ios")>=0?j="iOS":e.toLowerCase().indexOf("mac")>=0||w.toLowerCase().indexOf("mac")>=0?j="Android":(e.toLowerCase().indexOf("linux")>=0||e.toLowerCase().indexOf("debian")>=0||e.toLowerCase().indexOf("gentoo")>=0||e.toLowerCase().indexOf("ubuntu")>=0||e.toLowerCase().indexOf("centos")>=0||e.toLowerCase().indexOf("red hat")>=0||e.toLowerCase().indexOf("suse")>=0||w.toLowerCase().indexOf("linux")>=0||w.toLowerCase().indexOf("debian")>=0||w.toLowerCase().indexOf("gentoo")>=0||w.toLowerCase().indexOf("ubuntu")>=0||w.toLowerCase().indexOf("centos")>=0||w.toLowerCase().indexOf("red hat")>=0||w.toLowerCase().indexOf("suse")>=0)&&(j="Linux")),k.length&&(k=["("+k.join("; ")+")"]),B&&H&&H.indexOf(B)<0&&k.push("on "+B),H&&k.push((/^on /.test(k[k.length-1])?"":"on ")+H),j&&(O=/ ([\d.+]+)$/.exec(j),x=O&&"/"==j.charAt(j.length-O[0].length-1),j={architecture:32,family:O&&!x?j.replace(O[0],""):j,version:O?O[1]:null,toString:function(){var e=this.version;return this.family+(e&&!x?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(O=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(A))&&!/\bi686\b/i.test(A)?(j&&(j.architecture=64,j.family=j.family.replace(RegExp(" *"+O),"")),M&&(/\bWOW64\b/i.test(e)||V&&/\w(?:86|32)$/.test(b.cpuClass||b.platform)&&!/\bWin64; x64\b/i.test(e))&&k.unshift("32-bit")):j&&/^OS X/.test(j.family)&&"Chrome"==M&&parseFloat(W)>=39&&(j.architecture=64),e||(e=null);var $={};return $.description=e,$.layout=F&&F[0],$.manufacturer=B,$.name=M,$.prerelease=U,$.product=H,$.ua=e,$.version=M&&W,$.os=j||{architecture:null,family:null,version:null,toString:function(){return"null"}},$.parse=c,$.toString=h,$.version&&k.unshift(W),$.name&&k.unshift(M),j&&M&&(j!=String(j).split(" ")[0]||j!=M.split(" ")[0]&&!H)&&k.push(H?"("+j+")":"on "+j),k.length&&($.description=k.join(" ")),$}var u={"function":!0,object:!0},g=u[typeof window]&&window||this,h=u[typeof exports]&&exports,m=u[typeof module]&&module&&!module.nodeType&&module,d=h&&m&&"object"==typeof global&&global;!d||d.global!==d&&d.window!==d&&d.self!==d||(g=d);var b=Math.pow(2,53)-1,_=/\bOpera/,f=Object.prototype,w=f.hasOwnProperty,v=f.toString;webphone_api.platform=c()}(),function(e,n){"use strict";e.webphone_api.picoModal=function(){"use strict";function e(e){return"object"==typeof Node?e instanceof Node:e&&"object"==typeof e&&"number"==typeof e.nodeType}function n(e){return"string"==typeof e}function t(){var e=[];return{watch:e.push.bind(e),trigger:function(n){for(var t=!0,o={preventDefault:function(){t=!1}},i=0;i0)for(var n=0;n0){var a=d(t);if(a)if(!f(U[n].swfVersion)||B.wk&&B.wk<312)if(U[n].expressInstall&&l()){var c={};c.data=U[n].expressInstall,c.width=a.getAttribute("width")||"0",c.height=a.getAttribute("height")||"0",a.getAttribute("class")&&(c.styleclass=a.getAttribute("class")),a.getAttribute("align")&&(c.align=a.getAttribute("align"));for(var u={},g=a.getElementsByTagName("param"),h=g.length,m=0;m');i.outerHTML='"+l+"",V[V.length]=e.id,o=d(e.id)}else{var p=b(L);p.setAttribute("type",R);for(var c in e)e[c]!=Object.prototype[c]&&("styleclass"==c.toLowerCase()?p.setAttribute("class",e[c]):"classid"!=c.toLowerCase()&&p.setAttribute(c,e[c]));for(var u in n)n[u]!=Object.prototype[u]&&"movie"!=u.toLowerCase()&&g(p,u,n[u]);i.parentNode.replaceChild(p,i),o=p}return o}function g(e,n,t){var o=b("param");o.setAttribute("name",n),o.setAttribute("value",t),e.appendChild(o)}function h(e){var n=d(e);n&&"OBJECT"==n.nodeName&&(B.ie&&B.win?(n.style.display="none",function(){4==n.readyState?m(e):setTimeout(arguments.callee,10)}()):n.parentNode.removeChild(n))}function m(e){var n=d(e);if(n){for(var t in n)"function"==typeof n[t]&&(n[t]=null);n.parentNode.removeChild(n)}}function d(e){var n=null;try{n=O.getElementById(e)}catch(t){}return n}function b(e){return O.createElement(e)}function _(e,n,t){e.attachEvent(n,t),W[W.length]=[e,n,t]}function f(e){var n=B.pv,t=e.split(".");return t[0]=parseInt(t[0],10),t[1]=parseInt(t[1],10)||0,t[2]=parseInt(t[2],10)||0,n[0]>t[0]||n[0]==t[0]&&n[1]>t[1]||n[0]==t[0]&&n[1]==t[1]&&n[2]>=t[2]}function w(e,n,t,o){if(!B.ie||!B.mac){var i=O.getElementsByTagName("head")[0];if(i){var a=t&&"string"==typeof t?t:"screen";if(o&&(I=null,C=null),!I||C!=a){var r=b("style");r.setAttribute("type","text/css"),r.setAttribute("media",a),I=i.appendChild(r),B.ie&&B.win&&typeof O.styleSheets!=G&&O.styleSheets.length>0&&(I=O.styleSheets[O.styleSheets.length-1]),C=a}B.ie&&B.win?I&&typeof I.addRule==L&&I.addRule(e,n):I&&typeof O.createTextNode!=G&&I.appendChild(O.createTextNode(e+" {"+n+"}"))}}}function v(e,n){if(H){var t=n?"visible":"hidden";F&&d(e)?d(e).style.visibility=t:w("#"+e,"visibility:"+t)}}function E(e){return null!=/[\\\"<>\.;]/.exec(e)&&typeof encodeURIComponent!=G?encodeURIComponent(e):e}var P,T,S,N,I,C,G="undefined",L="object",R="application/x-shockwave-flash",y="SWFObjectExprInst",D=window,O=document,x=navigator,A=!1,k=[o],U=[],V=[],W=[],F=!1,M=!1,H=!0,B=function(){var e=typeof O.getElementById!=G&&typeof O.getElementsByTagName!=G&&typeof O.createElement!=G,n=x.userAgent.toLowerCase(),t=x.platform.toLowerCase(),o=/win/.test(t?t:n),i=/mac/.test(t?t:n),a=!!/webkit/.test(n)&&parseFloat(n.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")),r=!1,l=[0,0,0],s=null;if(typeof x.plugins!=G&&typeof x.plugins["Shockwave Flash"]==L)!(s=x.plugins["Shockwave Flash"].description)||typeof x.mimeTypes!=G&&x.mimeTypes[R]&&!x.mimeTypes[R].enabledPlugin||(A=!0,r=!1,s=s.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),l[0]=parseInt(s.replace(/^(.*)\..*$/,"$1"),10),l[1]=parseInt(s.replace(/^.*\.(.*)\s.*$/,"$1"),10),l[2]=/[a-zA-Z]/.test(s)?parseInt(s.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0);else if(typeof D.ActiveXObject!=G)try{var p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");p&&(s=p.GetVariable("$version"))&&(r=!0,s=s.split(" ")[1].split(","),l=[parseInt(s[0],10),parseInt(s[1],10),parseInt(s[2],10)])}catch(c){}return{w3:e,pv:l,wk:a,ie:r,win:o,mac:i}}();(function(){B.w3&&((typeof O.readyState!=G&&"complete"==O.readyState||typeof O.readyState==G&&(O.getElementsByTagName("body")[0]||O.body))&&e(),F||(typeof O.addEventListener!=G&&O.addEventListener("DOMContentLoaded",e,!1),B.ie&&B.win&&(O.attachEvent("onreadystatechange",function(){"complete"==O.readyState&&(O.detachEvent("onreadystatechange",arguments.callee),e())}),D==top&&function(){if(!F){try{O.documentElement.doScroll("left")}catch(n){return void setTimeout(arguments.callee,0)}e()}}()),B.wk&&function(){if(!F)/loaded|complete/.test(O.readyState)?e():setTimeout(arguments.callee,0)}(),t(e)))})(),function(){B.ie&&B.win&&window.attachEvent("onunload",function(){for(var e=W.length,n=0;n=43)}})["catch"](function(){return!1})}function u(e){return"boolean"==typeof we?_e.resolve(we):c(e).then(function(e){return we=e})}function g(e){var n=ve[e.name],t={};t.promise=new _e(function(e,n){t.resolve=e,t.reject=n}),n.deferredOperations.push(t),n.dbReady?n.dbReady=n.dbReady.then(function(){return t.promise}):n.dbReady=t.promise}function h(e){var n=ve[e.name],t=n.deferredOperations.pop();if(t)return t.resolve(),t.promise}function m(e,n){var t=ve[e.name],o=t.deferredOperations.pop();if(o)return o.reject(n),o.promise}function d(e,n){return new _e(function(t,o){if(ve[e.name]=ve[e.name]||N(),e.db){if(!n)return t(e.db);g(e),e.db.close()}var i=[e.name];n&&i.push(e.version);var a=be.open.apply(be,i);n&&(a.onupgradeneeded=function(n){var t=a.result;try{t.createObjectStore(e.storeName),n.oldVersion<=1&&t.createObjectStore(fe)}catch(o){if("ConstraintError"!==o.name)throw o;console.warn('The database "'+e.name+'" has been upgraded from version '+n.oldVersion+" to version "+n.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),a.onerror=function(e){e.preventDefault(),o(a.error)},a.onsuccess=function(){var n=a.result;n.onversionchange=function(e){e.target.close()},t(n),h(e)}})}function b(e){return d(e,!1)}function _(e){return d(e,!0)}function f(e,n){if(!e.db)return!0;var t=!e.db.objectStoreNames.contains(e.storeName),o=e.versione.db.version;if(o&&(e.version!==n&&console.warn('The database "'+e.name+"\" can't be downgraded from version "+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||t){if(t){var a=e.db.version+1;a>e.version&&(e.version=a)}return!0}return!1}function w(e){return new _e(function(n,t){var o=new FileReader;o.onerror=t,o.onloadend=function(t){var o=btoa(t.target.result||"");n({__local_forage_encoded_blob:!0,data:o,type:e.type})},o.readAsBinaryString(e)})}function v(e){return i([p(atob(e.data))],{type:e.type})}function E(e){return e&&e.__local_forage_encoded_blob}function P(e){var n=this,t=n._initReady().then(function(){var e=ve[n._dbInfo.name];if(e&&e.dbReady)return e.dbReady});return r(t,e,e),t}function T(e){g(e);for(var n=ve[e.name],t=n.forages,o=0;o0&&(!e.db||"InvalidStateError"===a.name||"NotFoundError"===a.name))return _e.resolve().then(function(){if(!e.db||"NotFoundError"===a.name&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),_(e)}).then(function(){return T(e).then(function(){S(e,n,t,o-1)})})["catch"](t);t(a)}}function N(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function I(e){function n(){return _e.resolve()}var t=this,o={db:null};if(e)for(var i in e)o[i]=e[i];var a=ve[o.name];a||(a=N(),ve[o.name]=a),a.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=P);for(var r=[],l=0;l>4,c[s++]=(15&o)<<4|i>>2,c[s++]=(3&i)<<6|63&a;return p}function U(e){var n,t=new Uint8Array(e),o="";for(n=0;n>2],o+=Ne[(3&t[n])<<4|t[n+1]>>4],o+=Ne[(15&t[n+1])<<2|t[n+2]>>6],o+=Ne[63&t[n+2]];return t.length%3==2?o=o.substring(0,o.length-1)+"=":t.length%3==1&&(o=o.substring(0,o.length-2)+"=="),o}function V(e,n){var t="";if(e&&(t=He.call(e)),e&&("[object ArrayBuffer]"===t||e.buffer&&"[object ArrayBuffer]"===He.call(e.buffer))){var o,i=Ge;e instanceof ArrayBuffer?(o=e,i+=Re):(o=e.buffer,"[object Int8Array]"===t?i+=De:"[object Uint8Array]"===t?i+=Oe:"[object Uint8ClampedArray]"===t?i+=xe:"[object Int16Array]"===t?i+=Ae:"[object Uint16Array]"===t?i+=Ue:"[object Int32Array]"===t?i+=ke:"[object Uint32Array]"===t?i+=Ve:"[object Float32Array]"===t?i+=We:"[object Float64Array]"===t?i+=Fe:n(new Error("Failed to get type for BinaryArray"))),n(i+U(o))}else if("[object Blob]"===t){var a=new FileReader;a.onload=function(){var t=Ie+e.type+"~"+U(this.result);n(Ge+ye+t)},a.readAsArrayBuffer(e)}else try{n(JSON.stringify(e))}catch(r){console.error("Couldn't convert value into a JSON string: ",e),n(null,r)}}function W(e){if(e.substring(0,Le)!==Ge)return JSON.parse(e);var n,t=e.substring(Me),o=e.substring(Le,Me);if(o===ye&&Ce.test(t)){var a=t.match(Ce);n=a[1],t=t.substring(a[0].length)}var r=k(t);switch(o){case Re:return r;case ye:return i([r],{type:n});case De:return new Int8Array(r);case Oe:return new Uint8Array(r);case xe:return new Uint8ClampedArray(r);case Ae:return new Int16Array(r);case Ue:return new Uint16Array(r);case ke:return new Int32Array(r);case Ve:return new Uint32Array(r);case We:return new Float32Array(r);case Fe:return new Float64Array(r);default:throw new Error("Unkown type: "+o)}}function F(e,n,t,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+n.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],t,o)}function M(e){var n=this,t={db:null};if(e)for(var o in e)t[o]="string"!=typeof e[o]?e[o].toString():e[o];var i=new _e(function(e,o){try{t.db=openDatabase(t.name,String(t.version),t.description,t.size)}catch(i){return o(i)}t.db.transaction(function(i){F(i,t,function(){n._dbInfo=t,e()},function(e,n){o(n)})},o)});return t.serializer=Be,i}function H(e,n,t,o,i,a){e.executeSql(t,o,i,function(e,r){r.code===r.SYNTAX_ERR?e.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[n.storeName],function(e,l){l.rows.length?a(e,r):F(e,n,function(){e.executeSql(t,o,i,a)},a)},a):a(e,r)},a)}function B(e,n){var t=this;e=l(e);var o=new _e(function(n,o){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(t){H(t,i,"SELECT * FROM "+i.storeName+" WHERE key = ? LIMIT 1",[e],function(e,t){var o=t.rows.length?t.rows.item(0).value:null;o&&(o=i.serializer.deserialize(o)),n(o)},function(e,n){o(n)})})})["catch"](o)});return a(o,n),o}function j(e,n){var t=this,o=new _e(function(n,o){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(t){H(t,i,"SELECT * FROM "+i.storeName,[],function(t,o){for(var a=o.rows,r=a.length,l=0;l0)return void a($.apply(i,[e,l,t,o-1]));r(n)}})})})["catch"](r)});return a(r,t),r}function q(e,n,t){return $.apply(this,[e,n,t,1])}function z(e,n){var t=this;e=l(e);var o=new _e(function(n,o){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(t){H(t,i,"DELETE FROM "+i.storeName+" WHERE key = ?",[e],function(){n()},function(e,n){o(n)})})})["catch"](o)});return a(o,n),o}function K(e){var n=this,t=new _e(function(e,t){n.ready().then(function(){var o=n._dbInfo;o.db.transaction(function(n){H(n,o,"DELETE FROM "+o.storeName,[],function(){e()},function(e,n){t(n)})})})["catch"](t)});return a(t,e),t}function X(e){var n=this,t=new _e(function(e,t){n.ready().then(function(){var o=n._dbInfo;o.db.transaction(function(n){H(n,o,"SELECT COUNT(key) as c FROM "+o.storeName,[],function(n,t){var o=t.rows.item(0).c;e(o)},function(e,n){t(n)})})})["catch"](t)});return a(t,e),t}function J(e,n){var t=this,o=new _e(function(n,o){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(t){H(t,i,"SELECT key FROM "+i.storeName+" WHERE id = ? LIMIT 1",[e+1],function(e,t){var o=t.rows.length?t.rows.item(0).key:null;n(o)},function(e,n){o(n)})})})["catch"](o)});return a(o,n),o}function Y(e){var n=this,t=new _e(function(e,t){n.ready().then(function(){var o=n._dbInfo;o.db.transaction(function(n){H(n,o,"SELECT key FROM "+o.storeName,[],function(n,t){for(var o=[],i=0;i '__WebKitDatabaseInfoTable__'",[],function(t,o){for(var i=[],a=0;a0}function oe(e){var n=this,t={};if(e)for(var o in e)t[o]=e[o];return t.keyPrefix=ee(e,n._defaultConfig),te()?(n._dbInfo=t,t.serializer=Be,_e.resolve()):_e.reject()}function ie(e){var n=this,t=n.ready().then(function(){for(var e=n._dbInfo.keyPrefix,t=localStorage.length-1;t>=0;t--){var o=localStorage.key(t);0===o.indexOf(e)&&localStorage.removeItem(o)}});return a(t,e),t}function ae(e,n){var t=this;e=l(e);var o=t.ready().then(function(){var n=t._dbInfo,o=localStorage.getItem(n.keyPrefix+e);return o&&(o=n.serializer.deserialize(o)),o});return a(o,n),o}function re(e,n){var t=this,o=t.ready().then(function(){for(var n=t._dbInfo,o=n.keyPrefix,i=o.length,a=localStorage.length,r=1,l=0;l=0;n--){var t=localStorage.key(n);0===t.indexOf(e)&&localStorage.removeItem(t)}}):_e.reject("Invalid arguments"),a(o,n),o}function he(e,n){e[n]=function(){var t=arguments;return arguments.length&&"function"==typeof arguments[arguments.length-1]&&(webphone_api.global.localforage_last_cb=arguments[arguments.length-1]),e.ready().then(function(){return e[n].apply(e,t)})}}function me(){for(var e=1;e0&&n-1 in e)))}function o(e){var n=_e[e]={};return se.each(e.match(ce)||[],function(e,t){n[t]=!0}),n}function i(e,t,o,i){if(se.acceptData(e)){var a,r,l=se.expando,s="string"==typeof t,p=e.nodeType,c=p?se.cache:e,u=p?e[l]:e[l]&&l;if(u&&c[u]&&(i||c[u].data)||!s||o!==n)return u||(p?e[l]=u=Z.pop()||se.guid++:u=l),c[u]||(c[u]={},p||(c[u].toJSON=se.noop)),("object"==typeof t||"function"==typeof t)&&(i?c[u]=se.extend(c[u],t):c[u].data=se.extend(c[u].data,t)),a=c[u],i||(a.data||(a.data={}),a=a.data),o!==n&&(a[se.camelCase(t)]=o),s?null==(r=a[t])&&(r=a[se.camelCase(t)]):r=a,r}}function a(e,n,t){if(se.acceptData(e)){var o,i,a,r=e.nodeType,s=r?se.cache:e,p=r?e[se.expando]:se.expando;if(s[p]){if(n&&(a=t?s[p]:s[p].data)){se.isArray(n)?n=n.concat(se.map(n,se.camelCase)):n in a?n=[n]:(n=se.camelCase(n),n=n in a?[n]:n.split(" "));for(o=0,i=n.length;i>o;o++)delete a[n[o]];if(!(t?l:se.isEmptyObject)(a))return}(t||(delete s[p].data,l(s[p])))&&(r?se.cleanData([e],!0):se.support.deleteExpando||s!=s.window?delete s[p]:s[p]=null)}}}function r(e,t,o){if(o===n&&1===e.nodeType){var i="data-"+t.replace(we,"-$1").toLowerCase();if("string"==typeof(o=e.getAttribute(i))){try{o="true"===o||"false"!==o&&("null"===o?null:+o+""===o?+o:fe.test(o)?se.parseJSON(o):o)}catch(K){}se.data(e,t,o)}else o=n}return o}function l(e){var n;for(n in e)if(("data"!==n||!se.isEmptyObject(e[n]))&&"toJSON"!==n)return!1;return!0}function s(){return!0}function p(){return!1}function c(e,n){do{e=e[n]}while(e&&1!==e.nodeType);return e}function u(e,n,t){if(n=n||0,se.isFunction(n))return se.grep(e,function(e,o){return!!n.call(e,o,e)===t});if(n.nodeType)return se.grep(e,function(e){return e===n===t});if("string"==typeof n){var o=se.grep(e,function(e){return 1===e.nodeType});if(ke.test(n))return se.filter(n,o,!t);n=se.filter(n,o)}return se.grep(e,function(e){return se.inArray(e,n)>=0===t})}function g(e){var n=We.split("|"),t=e.createDocumentFragment();if(t.createElement)for(;n.length;)t.createElement(n.pop());return t}function h(e,n){return e.getElementsByTagName(n)[0]||e.appendChild(e.ownerDocument.createElement(n))}function m(e){var n=e.getAttributeNode("type");return e.type=(n&&n.specified)+"/"+e.type,e}function d(e){var n=Je.exec(e.type);return n?e.type=n[1]:e.removeAttribute("type"),e}function b(e,n){for(var t,o=0;null!=(t=e[o]);o++)se._data(t,"globalEval",!n||se._data(n[o],"globalEval"))}function _(e,n){if(1===n.nodeType&&se.hasData(e)){var t,o,i,a=se._data(e),r=se._data(n,a),l=a.events;if(l){delete r.handle,r.events={};for(t in l)for(o=0,i=l[t].length;i>o;o++)se.event.add(n,t,l[t][o])}r.data&&(r.data=se.extend({},r.data))}}function f(e,n){var t,o,i;if(1===n.nodeType){if(t=n.nodeName.toLowerCase(),!se.support.noCloneEvent&&n[se.expando]){i=se._data(n);for(o in i.events)se.removeEvent(n,o,i.handle);n.removeAttribute(se.expando)}"script"===t&&n.text!==e.text?(m(n).text=e.text,d(n)):"object"===t?(n.parentNode&&(n.outerHTML=e.outerHTML),se.support.html5Clone&&e.innerHTML&&!se.trim(n.innerHTML)&&(n.innerHTML=e.innerHTML)):"input"===t&&ze.test(e.type)?(n.defaultChecked=n.checked=e.checked,n.value!==e.value&&(n.value=e.value)):"option"===t?n.defaultSelected=n.selected=e.defaultSelected:("input"===t||"textarea"===t)&&(n.defaultValue=e.defaultValue)}}function w(e,t){var o,i,a=0,r=typeof e.getElementsByTagName!==z?e.getElementsByTagName(t||"*"):typeof e.querySelectorAll!==z?e.querySelectorAll(t||"*"):n;if(!r)for(r=[],o=e.childNodes||e;null!=(i=o[a]);a++)!t||se.nodeName(i,t)?r.push(i):se.merge(r,w(i,t)) ;return t===n||t&&se.nodeName(e,t)?se.merge([e],r):r}function v(e){ze.test(e.type)&&(e.defaultChecked=e.checked)}function E(e,n){if(n in e)return n;for(var t=n.charAt(0).toUpperCase()+n.slice(1),o=n,i=bn.length;i--;)if((n=bn[i]+t)in e)return n;return o}function P(e,n){return e=n||e,"none"===se.css(e,"display")||!se.contains(e.ownerDocument,e)}function T(e,n){for(var t,o,i,a=[],r=0,l=e.length;l>r;r++)o=e[r],o.style&&(a[r]=se._data(o,"olddisplay"),t=o.style.display,n?(a[r]||"none"!==t||(o.style.display=""),""===o.style.display&&P(o)&&(a[r]=se._data(o,"olddisplay",C(o.nodeName)))):a[r]||(i=P(o),(t&&"none"!==t||!i)&&se._data(o,"olddisplay",i?t:se.css(o,"display"))));for(r=0;l>r;r++)o=e[r],o.style&&(n&&"none"!==o.style.display&&""!==o.style.display||(o.style.display=n?a[r]||"":"none"));return e}function S(e,n,t){var o=pn.exec(n);return o?Math.max(0,o[1]-(t||0))+(o[2]||"px"):n}function N(e,n,t,o,i){for(var a=t===(o?"border":"content")?4:"width"===n?1:0,r=0;4>a;a+=2)"margin"===t&&(r+=se.css(e,t+dn[a],!0,i)),o?("content"===t&&(r-=se.css(e,"padding"+dn[a],!0,i)),"margin"!==t&&(r-=se.css(e,"border"+dn[a]+"Width",!0,i))):(r+=se.css(e,"padding"+dn[a],!0,i),"padding"!==t&&(r+=se.css(e,"border"+dn[a]+"Width",!0,i)));return r}function I(e,n,t){var o=!0,i="width"===n?e.offsetWidth:e.offsetHeight,a=nn(e),r=se.support.boxSizing&&"border-box"===se.css(e,"boxSizing",!1,a);if(0>=i||null==i){if(i=tn(e,n,a),(0>i||null==i)&&(i=e.style[n]),cn.test(i))return i;o=r&&(se.support.boxSizingReliable||i===e.style[n]),i=parseFloat(i)||0}return i+N(e,n,t||(r?"border":"content"),o,a)+"px"}function C(e){var n=K,t=gn[e];return t||(t=G(e,n),"none"!==t&&t||(en=(en||se("
";videocontainer=document.getElementById("video_container"),webphone_api.common.isNull(videocontainer)?!0===e?PutToDebugLog(2,"EVENT, (warn) AddVideoElemnts cannot find video_container DIV"):PutToDebugLog(2,"EVENT, AddVideoElemnts cannot find video_container DIV"):webphone_api.common.isNull(divVideo)&&(PutToDebugLog(2,"EVENT, AddVideoElemnts video elements added"),videocontainer.innerHTML=n),divVideo=document.getElementById("div_video"),videoLocal=document.getElementById("video_local"),videoRemote=document.getElementById("video_remote"),audioRemote=document.getElementById("audio_remote"),webphone_api.common.isNull(webphone_api.$("#btn_video_fullscreen"))?PutToDebugLog(4,"EVENT, (warn) btn_video_fullscreen button doesn not exists"):"function"==typeof webphone_api.$("#btn_video_fullscreen").off?(webphone_api.$("#btn_video_fullscreen").off("click"),webphone_api.$("#btn_video_fullscreen").on("click",function(){toggleFullScreen()})):(webphone_api.$("#btn_video_fullscreen").unbind("click"),webphone_api.$("#btn_video_fullscreen").bind("click",function(){toggleFullScreen()}))}catch(t){PutToDebugLogException(2,"webrtcapi: AddVideoElemnts",t)}}function GetVideoSizeObj(){var e=undefined;try{var n=webphone_api.common.GetParameter2("video_min_width"),t=webphone_api.common.GetParameter2("video_min_height"),o=webphone_api.common.GetParameter2("video_max_width"),i=webphone_api.common.GetParameter2("video_max_height"),a=webphone_api.common.GetParameter2("video_width"),r=webphone_api.common.GetParameter2("video_height"),l=0,s=0,p=0,c=0,u=0,g=0,h=!1;!webphone_api.common.isNull(n)&&n.length>0&&webphone_api.common.IsNumber(n)?(h=!0,l=webphone_api.common.StrToInt(n)):l=100,!webphone_api.common.isNull(t)&&t.length>0&&webphone_api.common.IsNumber(t)?(h=!0,s=webphone_api.common.StrToInt(t)):s=80,!webphone_api.common.isNull(o)&&o.length>0&&webphone_api.common.IsNumber(o)?(h=!0,p=webphone_api.common.StrToInt(o)):p=1920,!webphone_api.common.isNull(i)&&i.length>0&&webphone_api.common.IsNumber(i)?(h=!0,c=webphone_api.common.StrToInt(i)):c=1080,!webphone_api.common.isNull(a)&&a.length>0&&webphone_api.common.IsNumber(a)?(h=!0,u=webphone_api.common.StrToInt(a)):u=960,!webphone_api.common.isNull(r)&&r.length>0&&webphone_api.common.IsNumber(r)?(h=!0,g=webphone_api.common.StrToInt(r)):g=540,71===webphone_api.common.GetConfigInt("brandid",-1)&&(u>0&&(l=u),g>0&&(s=g)),h&&l>0&&s>0&&p>0&&c>0&&(PutToDebugLog(2,"EVENT, webrtcapi: video minw: "+l+"; minh: "+s+"; maxw: "+p+"; maxh: "+c),e={minWidth:l,minHeight:s,maxWidth:p,maxHeight:c,width:u,height:g})}catch(m){PutToDebugLogException(2,"webrtcapi: GetVideoSizeObj",m)}return e}function GetRegFailReason(){return webphone_api.common.isNull(lastregfailreason)&&(lastregfailreason=""),lastregfailreason}function SetPushNotifications(e,n,t,o){try{if(webphone_api.common.isNull(n)||n.length<3)return void PutToDebugLog(2,"ERROR, webrtcapi SetPushNotifications invalid TOKEN: "+n);webphone_api.common.isNull(t)&&(t=""),webphone_api.common.isNull(o)&&(o=""),webphone_api.global.fcmtoken=n;var i="X-MPUSH: w:"+webphone_api.common.GetFCMPackageName()+":"+n,a=webphone_api.common.GetSipusername(!0)+":"+webphone_api.global.mRealm+":"+webphone_api.common.GetParameter("password"),r="X-PIID: "+webphone_api.common.Md5Hash(a);SetSipHeader(0,i),SetSipHeader(0,r),webphone_api.global.phonestarted>2&&ResendRegister()}catch(l){PutToDebugLogException(2,"webrtcapi: SetPushNotifications",l)}}function PlaySound(e,n,t,o){var i=0;try{if(i=1,e>=1&&(webphone_api.common.isNull(n)||n.length<1))return PutToDebugLog(2,"ERROR, playsound: missing file"),!1;if(e<=0&&(webphone_api.common.isNull(o)||!1!==o)){if(!webphone_api.common.isNull(oldtrack))try{i=71,PutToDebugLog(5,"EVENT, playsound stop: restore old track");const a=webphone_api.getrtcpeerconnection();if(!webphone_api.common.isNull(a)){i=72;const r=a.getSenders();if(!webphone_api.common.isNull(r)){i=73;for(var l=!1,s=0;s0&&!webphone_api.common.isNull(ps_audio.loop)&&(ps_audio.loop=!0),i=13;const p=new AudioContext;if(webphone_api.common.isNull(p))return PutToDebugLog(2,"ERROR, playsound: cannot play to remote peer, no audioContext"),!1;i=7;const c=p.createMediaElementSource(ps_audio);if(webphone_api.common.isNull(c))return PutToDebugLog(2,"ERROR, playsound: cannot play to remote peer, no audioSource"),!1;i=8;const u=p.createMediaStreamDestination();if(webphone_api.common.isNull(u))return PutToDebugLog(2,"ERROR, playsound: cannot play to remote peer, no audioDestination"),!1;i=9,c.connect(u),i=10;const g=u.stream.getAudioTracks()[0];if(webphone_api.common.isNull(g))return PutToDebugLog(2,"ERROR, playsound: cannot play to remote peer, no track"),!1;i=11;const a=webphone_api.getrtcpeerconnection();if(webphone_api.common.isNull(a))return PutToDebugLog(2,"ERROR, playsound: cannot play to remote peer, no RTCPeerConnection"),!1;i=20;const r=a.getSenders();if(webphone_api.common.isNull(r))return PutToDebugLog(2,"ERROR, playsound: cannot play to remote peer, no RTCRtpSender senderList"),!1;i=21;for(var l=!1,s=0;s0&&!webphone_api.common.isNull(ps_audio.loop)&&(ps_audio.loop=!0),i=54,ps_audio.play();return!0}catch(m){PutToDebugLogException(2,"webrtcapi: PlaySound ("+i.toString()+")",m)}return!1}function LineToCallID(e){try{var n=webphone_api.common.StrToIntDef(e,-1);n<1&&(n=webphone_api.common.GetBestLine());var t="";if(!webphone_api.common.isNull(webphone_api.global.ep)&&webphone_api.global.ep.length>0){var o=webphone_api.common.GetCallEpIdx(4673,!1,e,"","",null,null,null,!1);if(o>=0&&!webphone_api.common.isNull(webphone_api.global.ep[o])&&webphone_api.global.ep[o].length>=9&&(t=webphone_api.global.ep[o][webphone_api.common.EP_CALLID],!webphone_api.common.isNull(t)&&t.length>0))return t;for(var i,a=0;a0))return t}if(!webphone_api.common.isNull(webphone_api.common.eplinecallid)&&webphone_api.common.eplinecallid.length>e&&(t=webphone_api.common.eplinecallid[e]),!webphone_api.common.isNull(t)&&t.length>0)return t}catch(r){PutToDebugLogException(2,"webrtcapi: LineToCallID",r)}return""}function CallIDToLine(e){try{if(webphone_api.common.isNull(e))return-5;if(e=e.toString(),e.length<1)return-6;var n=-1;if(!webphone_api.common.isNull(webphone_api.global.ep)&&webphone_api.global.ep.length>0){var t=webphone_api.common.GetCallEpIdx(4674,!1,-1,"",e,null,null,null,!1);if(t>=0&&!webphone_api.common.isNull(webphone_api.global.ep[t])&&webphone_api.global.ep[t].length>=2&&(n=webphone_api.global.ep[t][webphone_api.common.EP_LINE],webphone_api.common.IsNumber(n)&&n>0))return n;for(var o,i=0;i0))return n}if(!webphone_api.common.isNull(webphone_api.common.eplinecallid)&&webphone_api.common.eplinecallid.length>0)for(var i=1;i0)try{for(var t=0;t0)try{for(var e=0;e0&&r<250)return webphone_api.common.PutToDebugLog(3,"EVENT, plhandler start already called"),!1;webphone_api.global.loglevel=webphone_api.common.GetLogLevel(),webphone_api.common.HandleCallerID(),webphone_api.global.laststarttick=a,webphone_api.global.pres_set_at_start=!1,webphone_api.global.pingpong=0,webphone_api.global.ever_received_pong=!1,webphone_api.common.GetCustomMenus(),webphone_api.global.nuiswebpage=null,0==webphone_api.global.phonestarttick&&(webphone_api.global.phonestarttick=webphone_api.common.GetTickCount());var l=webphone_api.common.GetAutostart();if(!1===t&&0===l)return webphone_api.common.PutToDebugLog(3,"EVENT, plhandler autologin disabled because autostart is FALSE"),!1;webphone_api.global.colorizelog=webphone_api.common.GetParameterInt("colorizelog",0),webphone_api.global.authenticated_displayed=!1,webphone_api.global.applet_started=!1,ut=e,webphone_api.global.lastengine_working_ok="",webphone_api.common.CanLog(3)&&webphone_api.common.PutToDebugLog(3,"EVENT, plhandler onstart"),webphone_api.common.PutToDebugLog(1,"STATUS,-1,"+webphone_api.stringres.get("initializing"));var s=webphone_api.common.GetParameter("serveraddress_user");(webphone_api.common.isNull(s)||s.length<2)&&(s=webphone_api.common.GetParameter("serveraddress")),(webphone_api.common.isNull(s)||s.length<2)&&webphone_api.common.PutToDebugLog(2,"EVENT, plhandler start serveraddress not set");var p=!0,c="",u=[];if(u.push("a"),!1===webphone_api.global.usestorage&&!webphone_api.common.CheckDID(s,!1))if(u.push("b"),webphone_api.common.AddressHasPort(s)&&(s=webphone_api.common.GetIPFromAddressSimple(s)),!webphone_api.common.IsIPAddrress(s)&&s.indexOf(".")>0){u.push("c");var g=webphone_api.common.DomainToIp(s,function(){});if(!(!webphone_api.common.isNull(g)&&g.length>0&&!0===webphone_api.common.IsIPAddrress(g)||""===g))return u.push("f"),mt=e,dt=t,void webphone_api.common.DomainToIp(s,function(e){if(u.push("g"),c=e,p=!1,!webphone_api.common.isNull(e)&&e.length>0&&!0===webphone_api.common.IsIPAddrress(e)&&(u.push("h"),webphone_api.common.CheckDID(e,!1)?p=!0:(u.push("i"),p=!1)),p)webphone_api.global.laststarttick=0,n(mt,dt);else{var t=[];t.push("E"),t.push("R"),t.push("R"),t.push("O"),t.push("R"),t.push(","),t.push("S"),t.push("e"),t.push("r"),t.push("v"),t.push("e"),t.push("r"),t.push(" "),t.push("n"),t.push("o"),t.push("t"),t.push(" "),t.push("a"),t.push("l"),t.push("l"),t.push("o"),t.push("w"),t.push("e"),t.push("d"),t.push("_"),t.push("7");var o=t.join(""),i=u.join("");setTimeout(function(){webphone_api.common.PutToDebugLog(1,o+" "+s+" / "+e+" ("+i+")"),webphone_api.common.ShowToast(o+" "+s)},853)}});u.push("d"),c=g,webphone_api.common.CheckDID(g,!0)||(u.push("e"),p=!1)}else u.push("j"),p=!1;if(!1===p){var h=[];h.push("E"),h.push("R"),h.push("R"),h.push("O"),h.push("R"),h.push(","),h.push("S"),h.push("e"),h.push("r"),h.push("v"),h.push("e"),h.push("r"),h.push(" "),h.push("n"),h.push("o"),h.push("t"),h.push(" "),h.push("a"),h.push("l"),h.push("l"),h.push("o"),h.push("w"),h.push("e"),h.push("d"),h.push("_"),h.push("8");var m=h.join(""),d=u.join("");return setTimeout(function(){webphone_api.common.PutToDebugLog(1,m+" "+s+" / "+c+" ("+d+")"),webphone_api.common.ShowToast(m+" "+s)},851),!1}st=!0,webphone_api.common.isNull(lt)||clearTimeout(lt),lt=setTimeout(function(){st=!1},2e3),webphone_api.common.PutToDebugLog(2,"EVENT, plhandler onstart reset useengine"),webphone_api.global.useengine="",webphone_api.global.readcallhistoryforrecents=!0,webphone_api.common.IsWindowsSoftphone()?webphone_api.common.SaveParameter("devicetype",webphone_api.common.DEVICE_WIN_SOFTPHONE()):webphone_api.common.SaveParameter("devicetype",webphone_api.common.DEVICE_WEBPHONE());var b=window.location.href;webphone_api.common.isNull(b)&&(b=""),b.length>0&&webphone_api.common.SaveParameter("wphoneappurl",b);var _=webphone_api.getbasedir2();if(webphone_api.common.isNull(_)&&(_=""),_.length>0&&_!==b&&webphone_api.common.SaveParameter("wphoneappurl2",_),!webphone_api.common.Glsp()){gt--;var h=[];h.push("E"),h.push("R"),h.push("R"),h.push("O"),h.push("R"),h.push(","),h.push(" "),h.push("U"),h.push("s"),h.push("a"),h.push("g"),h.push("e"),h.push(" "),h.push("o"),h.push("n"),h.push(" "),h.push("t"),h.push("h"),h.push("i"),h.push("s"),h.push(" "),h.push("o"),h.push("p"),h.push("e"),h.push("r"),h.push("a"),h.push("t"),h.push("i"),h.push("n"),h.push("g"),h.push(" "),h.push("s"),h.push("y"),h.push("s"),h.push("t"),h.push("e"),h.push("m"),h.push(" "),h.push("i"),h.push("s"),h.push(" "),h.push("n"),h.push("o"),h.push("t"),h.push(" "),h.push("p"),h.push("e"),h.push("r"),h.push("m"),h.push("i"),h.push("t"),h.push("t"),h.push("e"),h.push("d"),h.push(" "),h.push("b"),h.push("y"),h.push(" "),h.push("t"),h.push("h"),h.push("i"),h.push("s"),h.push(" "),h.push("l"),h.push("i"),h.push("c"),h.push("e"),h.push("n"),h.push("s"),h.push("e"),h.push("."),h.push(" "),h.push("U"),h.push("p"),h.push("g"),h.push("r"),h.push("a"),h.push("d"),h.push("e"),h.push(" "),h.push("t"),h.push("o"),h.push(" "),h.push("t"),h.push("h"),h.push("e"),h.push(" "),h.push("A"),h.push("d"),h.push("v"),h.push("a"),h.push("n"),h.push("c"),h.push("e"),h.push("d"),h.push(" "),h.push("v"),h.push("e"),h.push("r"),h.push("s"),h.push("i"),h.push("o"),h.push("n"),h.push(" "),h.push("t"),h.push("o"),h.push(" "),h.push("e"),h.push("n"),h.push("a"),h.push("b"),h.push("l"),h.push("e"),h.push(" "),h.push("t"),h.push("h"),h.push("e"),h.push(" "),h.push("w"),h.push("e"),h.push("b"),h.push("p"),h.push("h"),h.push("o"),h.push("n"),h.push("e"),h.push(" "),h.push("o"),h.push("n"),h.push(" "),h.push("s"),h.push("m"),h.push("a"),h.push("r"),h.push("t"),h.push("p"),h.push("h"),h.push("o"),h.push("n"),h.push("e"),h.push("s"),h.push(" "),h.push("a"),h.push("n"),h.push("d"),h.push(" "),h.push("t"),h.push("a"),h.push("b"),h.push("l"),h.push("e"),h.push("t"),h.push("s"),h.push(".");var f=[];f.push("E"),f.push("R"),f.push("R"),f.push("O"),f.push("R");var w=f.join(""),m=h.join("");webphone_api.global.dontclosecurrpopup=!0,setTimeout(function(){webphone_api.global.dontclosecurrpopup=!1},3e4),setTimeout(function(){webphone_api.common.PutToDebugLog(1,m)},2e3),setTimeout(function(){webphone_api.common.AlertDialog(w,m,function(){webphone_api.global.dontclosecurrpopup=!1})},759),ht+=10}if(gt<10)return;if(webphone_api.global.sipstackstarted=!0,!0===webphone_api.common.CanUseIncomingCallNot()){var v=webphone_api.common.GetParameterInt("askfornotifpermission",-1);v=webphone_api.common.GetParameterInt("asknotifpermission",v),v>=3&&webphone_api.common.RequestBrowserNotificationPermission(function(){},"","","",3)}return webphone_api.common.IsWindowsSoftphone()?(webphone_api.common.PutToDebugLog(3,"EVENT, plhandler start softphone"),i()):(!0===webphone_api.common.IsSDK()?webphone_api.common.PutToDebugLog(3,"EVENT, plhandler start webphone sdk"):webphone_api.common.PutToDebugLog(3,"EVENT, plhandler start webphone app"),o(1),webphone_api.common.PutToDebugLog(3,"EVENT, plhandler after wait for engine select")),!0}catch(E){webphone_api.common.PutToDebugLogException(2,"plhandler: Start",E)}return!1}function t(e,n,o,i){try{if(!webphone_api.common.IsMizuServerOrGateway())return void(webphone_api.global.isfirstwsu=!1);if(webphone_api.common.IsLocalServer()){var a=webphone_api.common.GetWebrtcSrvAddr();webphone_api.common.isNull(a)&&(a=""),a=a.toLowerCase(),a=a.replace("ws://",""),a=a.replace("wss://","");var r=a.indexOf("/");if(r>0&&(a=a.substring(0,r)),a.length>0&&0==webphone_api.common.IsLanIPEx(a))return webphone_api.common.PutToDebugLog(2,"ERROR, "+webphone_api.stringres.get("webrtc_local_sipserver")+" (4) "+a),void((!0===webphone_api.global.usestorage||webphone_api.common.Strl(60))&&console.log("ERROR, "+webphone_api.stringres.get("webrtc_local_sipserver")+"\n\n"+webphone_api.stringres.get("all_demo_msg")+" (5)"))}if(!webphone_api.common.IsMizuServerOrGateway())return;webphone_api.common.isNull(n)&&(n=webphone_api.common.GetSipusername(!0)),o=webphone_api.common.isNull(o)?webphone_api.common.GetParameter("password"):webphone_api.common.B64Dec(o);var l=webphone_api.common.GetParameter("serveraddress_user");(webphone_api.common.isNull(l)||l.length<2)&&(l=webphone_api.common.GetParameter("serveraddress"));var s=webphone_api.common.GetParameter("mainconfigs"),p=n+":"+o+":"+l+":"+webphone_api.common.GetWebrtcSrvAddr();if((webphone_api.common.isNull(s)||s.length<1||s!==p)&&(bt=!0),n.length<1&&o.length<1&&_t<25)return _t++,void setTimeout(function(){t()},80);if((webphone_api.common.isNull(n)||n.length<1)&&webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"ERROR, will NOT send wsuser, because username is not set: "+n),(webphone_api.common.isNull(o)||o.length<1)&&webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, CallWsuser password is not set: "+o),ft=webphone_api.common.GetWsuserUrl(n,o,i),ft.length<3)return webphone_api.common.CanLog(3)&&webphone_api.common.PutToDebugLog(3,"EVENT, plhandler CallWsuser wsuser not needed"),webphone_api.global.isfirstwsu=!1,bt=!1,void(webphone_api.global.wsuser_succeded=!0);if(webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, plhandler push wsuser "+webphone_api.global.isfirstwsu.toString()+" "+webphone_api.global.wsuser_succeded.toString()),webphone_api.global.isfirstwsu)if(webphone_api.common.isNull(s)||s.length<1||s!==p)wt=!0;else{var c=webphone_api.common.GetParameter("wsusers"),u=c.split(",");if(!webphone_api.common.isNull(u)&&u.length>0&&n.length>0)for(var g=0;g0&&!1===webphone_api.global.wsuser_succeded&&(webphone_api.common.isNull(e)||1!=e)&&(n=webphone_api.common.GetSipusername(!0),o=webphone_api.common.GetParameter("password"),ft=webphone_api.common.GetWsuserUrl(n,o,i),webphone_api.common.UriParser(ft,"","","","","webrtccreateuser"))},4500)}catch(h){webphone_api.common.PutToDebugLogException(2,"plhandler: CallWsuser",h)}}function o(e){try{webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, wait for engine select from: "+e.toString()),webphone_api.common.isNull(vt)||clearInterval(vt);var n=Tt;Tt=!1,vt=null;var t=80;vt=setInterval(function(){++Et>80&&(webphone_api.common.PutToDebugLog(2,"WARNING, EngineSelect timeout"),clearInterval(vt),webphone_api.common.PutToDebugLog(2,"WARNING, WaitForEngineSelect not ready, but start anyway"),webphone_api.common.ChooseEngineLogic(function(){i()},!0,1));var e=webphone_api.common.GetSipusername(!0),o=!1,a=webphone_api.common.CanIUseWebRTC();if(webphone_api.global.isfirstwsu&&a&&bt){if(Pt<10){var r=webphone_api.common.GetParameter("wsusers"),l=r.split(",");if(1==Et&&webphone_api.common.CanLog(4)&&webphone_api.common.PutToDebugLog(4,"EVENT, wsusers: "+r),!webphone_api.common.isNull(l)&&l.length>0)for(var s=0;s0&&l[s]===e){Pt=webphone_api.common.GetTickCount();break}}Pt>10&&webphone_api.common.GetTickCount()-Pt>2500&&(webphone_api.common.CanLog(4)&&webphone_api.common.PutToDebugLog(4,"EVENT, wsuser can be sent (first time)"),o=!0)}else webphone_api.common.CanLog(4)&&(a?webphone_api.common.PutToDebugLog(4,"EVENT, wsuser can be sent"):webphone_api.common.PutToDebugLog(4,"EVENT, wsuser not neded")),o=!0;if(!1===o&&a)return n||(t=10),void(1==Et&&webphone_api.common.CanLog(4)&&webphone_api.common.PutToDebugLog(4,"EVENT, wait for wsuready"));var p=webphone_api.common.EngineSelect(1,28);p<1?webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, waiting for EngineSelect ("+Et+")"):webphone_api.global.webrtcavailable<0&&(webphone_api.common.isNull(webphone_api.common.GetSelectedEngine())||webphone_api.common.GetSelectedEngine()==webphone_api.common.GetEngine(webphone_api.global.ENGINE_WEBRTC))?webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, waiting for WebRTC to load ("+Et+")"):(clearInterval(vt),webphone_api.common.CanLog(2)&&(webphone_api.common.PutToDebugLog(2,"EVENT, selected engine("+webphone_api.global.engineselectstage+"): "+webphone_api.common.TestEngineToString(webphone_api.common.GetSelectedEngine(),!1)),webphone_api.common.PutToDebugLog(2,"EVENT, recommended engine("+webphone_api.global.engineselectstage+"): "+webphone_api.common.TestEngineToString(webphone_api.common.GetRecommendedEngine(),!1)),webphone_api.common.PutToDebugLog(5,"EVENT, will choose engine logic. ret: "+p.toString()+" wsuready: "+o.toString()+" caniusewebrtc: "+a.toString()+" webrtcavailable: "+webphone_api.global.webrtcavailable.toString())),setTimeout(function(){webphone_api.common.ChooseEngineLogic(function(){i()},!0,2)},1e3))},200)}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: WaitForEngineSelect",o)}}function i(){try{webphone_api.common.IsCurrentEngineWorking(ut),webphone_api.common.CheckEngineFirstStart(ut),webphone_api.common.GatewayFailower(-1,"startUp"),1==webphone_api.common.IsSDK()?(webphone_api.common.PutToDebugLogSpecial(1,"EVENT, plhandler StartUp call HandleSettingsSDK",!1,""),a(function(e){webphone_api.common.PutToDebugLogSpecial(1,"EVENT, plhandler StartUp HandleSettingsSDK FINISHED: "+e,!1,"")})):(webphone_api.common.CanLog(3)&&webphone_api.common.PutToDebugLog(3,"EVENT, plhandler StartUp call StartEngine"),r("x1"))}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: StartUp",e)}return!1}function a(e){try{if(at)return webphone_api.common.PutToDebugLog(3,"EVENT, HandleSettingsSDK call StartEngine"),webphone_api.common.PutToDebugLogSpecial(1,"EVENT, HandleSettingsSDK call StartEngine",!1,""),r("x2"),void e("Already called");if(!e||"function"!=typeof e)return void webphone_api.common.PutToDebugLogSpecial(1,"ERROR, HandleSettingsSDK call StartEngine",!0,"");webphone_api.common.PutToDebugLogSpecial(1,"EVENT, plhandler HandleSettingsSDK called",!1,""),webphone_api.common.PutToDebugLog(3,"EVENT, HandleSettingsSDK called");var n=webphone_api.parameters.serveraddress;!webphone_api.common.isNull(n)&&n.length>1&&(webphone_api.common.SaveParameter("serveraddress",n,!0),webphone_api.common.SaveParameter("serveraddress_user",n,!0),webphone_api.common.SaveParameter("serveraddress_orig",n,!0),webphone_api.common.SaveParameter("iswebrtcuppersrvfromuser","true")),it.length<1&&(it=webphone_api.common.GetSettFilenameSDK()),webphone_api.common.PutToDebugLogSpecial(1,"EVENT, HandleSettingsSDK settfilename: "+it,!1,""),webphone_api.common.PutToDebugLog(3,"EVENT, HandleSettingsSDK settfilename: "+it),webphone_api.common.ReadSettingsFile(it,function(n){webphone_api.common.PutToDebugLog(5,"EVENT, plhandler GetSettings callback"),n||webphone_api.common.PutToDebugLog(5,"EVENT, plhandler GetSettings ReadSettings no content");var t=webphone_api.parameters.serveraddress;!webphone_api.common.isNull(t)&&t.length>1&&(webphone_api.common.SaveParameter("serveraddress",t,!0),webphone_api.common.SaveParameter("serveraddress_user",t,!0),webphone_api.common.SaveParameter("serveraddress_orig",t,!0)),webphone_api.common.isNull(rt)||(clearTimeout(rt),rt=null),webphone_api.common.SaveSettingsFile(3,it,function(n){if(webphone_api.global.loglevel=webphone_api.common.GetLogLevel(),webphone_api.common.PutToDebugLog(3,"EVENT, plhandler: HandleSettingsSDK settings SAVED"),!at){at=!0;var t=webphone_api.common.GetParameter2("register");(webphone_api.common.isNull(t)||t.length<1)&&(t="0");var i=webphone_api.common.StrToInt(t);if(0===webphone_api.common.GetAutostart())return webphone_api.common.PutToDebugLog(2,"EVENT, autostart is disabled, Start must be called manually"),void e("autostart is disabled");i<1?o(2):webphone_api.common.GetSipusername(!0).length>0&&webphone_api.common.GetParameter("password").length>0&&o(3),webphone_api.common.HandleScurlSetparameters(),webphone_api.common.ParseSipAccounts(),e("finished normally")}at=!0})})}catch(t){webphone_api.common.PutToDebugLogSpecial(1,"ERROR, plhandler HandleSettingsSDK",!0,t),webphone_api.common.PutToDebugLogException(2,"plhandler: HandleSettingsSDK",t),e("ERROR,exception")}}function r(e){try{if(St)return;if((webphone_api.common.isNull(e)||e.length<1)&&(e="x"),webphone_api.global.loglevel=webphone_api.common.GetLogLevel(),setTimeout(function(){webphone_api.common.IsLastUsedEngineSaved()||(webphone_api.common.PutToDebugLog(4,"EVENT, reset last used engine"),webphone_api.common.GetParameter("lastusedengine").length>0&&webphone_api.common.SaveParameter("prevusedengine",webphone_api.common.GetParameter("lastusedengine")),webphone_api.common.SaveParameter("lastusedengine",""),webphone_api.global.last_used_engine_cache="")},4e3),!1===Nt&&!0===webphone_api.common.IsSDK()&&webphone_api.common.ReadCallhistoryFile(function(e){e||webphone_api.common.PutToDebugLog(2,"EVENT, plhandler: Load call history failed")}),ht>190)return;!1===webphone_api.common.IsWindowsSoftphone()&&webphone_api.common.CanLog(2)&&(webphone_api.common.PutToDebugLog(4,"EVENT, plhandler StartEngine called"),webphone_api.common.PutToDebugLog(2,"EVENT, starting engine...")),webphone_api.common.HideSettings("voicemail","","voicemail",!0)&&webphone_api.common.SaveParameter("voicemail","0"),(webphone_api.common.HideSettings("chat","","chat",!0)||3==webphone_api.common.GetParameterInt("chatsms",0)||0==webphone_api.common.GetParameterInt("textmessaging",-1))&&(webphone_api.global.textmessaging=0);var n=webphone_api.common.GetParameter("serveraddress_user"),t=webphone_api.common.GetSipusername();(webphone_api.common.isNull(t)||t.length<1)&&(t=webphone_api.common.GetSipusername());var i=webphone_api.common.GetParameter("password"),a=webphone_api.common.GetParameter("registerinterval");if(!webphone_api.common.isNull(t)&&t.length>0&&!webphone_api.common.isNull(i)&&i.length>0){webphone_api.common.isNull(n)&&(n=""),(webphone_api.common.isNull(a)||0==webphone_api.common.IsNumber(a))&&(a="3600");var r=webphone_api.common.StrToInt(a),l=!1;if(webphone_api.global.sipaccounts.length<1)l=!0;else for(var p=0;p1&&setTimeout(function(){(!0===webphone_api.common.IsSDK()||webphone_api.$(".ui-page-active .ui-popup-active").length<1)&&(webphone_api.common.ShowToast(d),webphone_api.common.SaveParameter("messagepopup",""))},4500),webphone_api.common.IsWindowsSoftphone())return webphone_api.common.PutToDebugLog(2,"EVENT, start engine: windows softphone - NS engine"),webphone_api.webphone.StartWin(),!0;var b=webphone_api.common.GetSelectedEngineName(),_=webphone_api.common.GetRecommendedEngineName();if(webphone_api.common.isNull(b)||b.length<1)return webphone_api.common.PutToDebugLog(2,"ERROR, plhandler StartUp no selected engine available"),!1;if(!0===webphone_api.global.isfirststart||webphone_api.common.isNull(webphone_api.global.useengine)||webphone_api.global.useengine.length<2)webphone_api.common.PutToDebugLog(2,"EVENT, StartEngine set useengine: "+b),webphone_api.global.useengine=b,webphone_api.global.last_useengine=b,webphone_api.global.last_last_useengine=b,webphone_api.global.isfirststart=!1;else{if(webphone_api.common.isNull(_)||_.length<1){var f=webphone_api.common.GetEngine(b);return f.failed=1,webphone_api.common.SetEngine(b,f),webphone_api.common.PutToDebugLog(4,"EVENT, WaitForEngineSelect called_3"),webphone_api.common.EngineSelect(1,29),o(4),!1}webphone_api.common.PutToDebugLog(2,"EVENT, StartEngine recommended set useengine: "+_),webphone_api.global.useengine=_,webphone_api.global.last_useengine=_,webphone_api.global.last_last_useengine=_}if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE()&&"flash"===webphone_api.common.getuseengine()){var w=window.location.protocol;!webphone_api.common.isNull(w)&&w.length>0&&w.toLowerCase().indexOf("file")>=0&&("0"===webphone_api.common.GetParameter2("enginepriority_java")&&"0"===webphone_api.common.GetParameter2("enginepriority_webrtc")&&"0"===webphone_api.common.GetParameter2("enginepriority_ns")||"flash"===webphone_api.common.getuseengine())&&(webphone_api.common.PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_flash_local")),console.log(webphone_api.stringres.get("err_flash_local")))}try{webphone_api.onAppStateChangeCb("started")}catch(P){webphone_api.common.PutToDebugLogException(2,"plhandler: There is an error in onAppStateChange(started) callback",P)}try{webphone_api.onStartCb()}catch(P){webphone_api.common.PutToDebugLogException(2,"There is an error in onStart() callback",P)}if(webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onstart,"onStart","","","",""),!0===webphone_api.common.UseCustomAutoprov(!1)&&webphone_api.common.GetCustomAutoprov(function(e){webphone_api.common.RecAutoprovCustom(e)}),!1===webphone_api.common.Loa()){var v=[];v.push("E"),v.push("R"),v.push("R"),v.push("O"),v.push("R"),v.push(","),v.push(" "),v.push("o"),v.push("n"),v.push("l"),v.push("y"),v.push(" "),v.push("a"),v.push("n"),v.push("d"),v.push("r"),v.push("o"),v.push("i"),v.push("d");var E=v.join("");setTimeout(function(){webphone_api.common.PutToDebugLog(2,E)},1214),setTimeout(function(){s(!1,e+" a")},6e4)}else s(!1,e+" b");yn()}catch(P){webphone_api.common.PutToDebugLogException(2,"plhandler: StartEngine",P)}}function l(e){try{(webphone_api.common.isNull(e)||e.length<1)&&(webphone_api.common.PutToDebugLog(2,"ERROR, ParseReceivedParameters invalid parameters: "+e),s(!0,"c")),e=webphone_api.common.Trim(e),e.indexOf("error")>=0&&(webphone_api.common.PutToDebugLog(2,"ERROR, ParseReceivedParameters error received: "+e),s(!0,"d"));var n=e.split(",");if(!webphone_api.common.isNull(n)&&n.length>0)for(var t=0;t0&&!webphone_api.common.isNull(i)&&(o=o.toLowerCase(),webphone_api.common.SaveParameter(o,i))}}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: ParseReceivedParameters",a)}webphone_api.common.PutToDebugLog(2,"EVENT, scurl_setparameters STOP"),Me(!1,1),setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Start scurl_setparameters START"),webphone_api.start()},1500)}function s(e,n){p(e,n)}function p(e,n){var t=0;try{if(t=1,webphone_api.common.PutToDebugLog(4,"EVENT, start engine delayed "+n+" "+webphone_api.global.useengine),t=2,webphone_api.global.startendelayed_wascalled=!0,e&&(webphone_api.global.flagnsreconnect=!0),t=3,webphone_api.global.phonestarted>1&&!1===webphone_api.global.enstarteddisplayed){t=4,webphone_api.global.enstarteddisplayed=!0;var o="",i=webphone_api.common.getuseengine();o=i===webphone_api.global.ENGINE_JAVA?"jv":i===webphone_api.global.ENGINE_SERVICE?"ns":i===webphone_api.global.ENGINE_WEBRTC?"rtc":i,t=5,!1===webphone_api.common.IsWindowsSoftphone()&&webphone_api.common.PutToDebugLog(1,"EVENT,"+webphone_api.stringres.get("status_enginestarted")+" ("+o+")")}if(t=6,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE||(webphone_api.common.getuseengine(),webphone_api.global.ENGINE_JAVA),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){t=7;var a=1e3;1!==webphone_api.common.GetParameterInt("autoaction",0)&&3!==webphone_api.common.GetParameterInt("autoaction",0)||(a=1e4),h(a)}t=8,webphone_api.common.CanLog(5)&&(webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_java: "+webphone_api.common.GetCfgPriority("java")+" "+webphone_api.common.GetParameter2("enginepriority_java")),webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_webrtc: "+webphone_api.common.GetCfgPriority("webrtc")+" "+webphone_api.common.GetParameter2("enginepriority_webrtc")),webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_ns: "+webphone_api.common.GetCfgPriority("ns")+" "+webphone_api.common.GetParameter2("enginepriority_ns")),webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_flash: "+webphone_api.common.GetCfgPriority("flash")+" "+webphone_api.common.GetParameter2("enginepriority_flash")),webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_app: "+webphone_api.common.GetCfgPriority("app")+" "+webphone_api.common.GetParameter2("enginepriority_app")),webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_p2p: "+webphone_api.common.GetCfgPriority("p2p")+" "+webphone_api.common.GetParameter2("enginepriority_p2p")),webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_accessnum: "+webphone_api.common.GetCfgPriority("accessnum")+" "+webphone_api.common.GetParameter2("enginepriority_accessnum")),webphone_api.common.PutToDebugLog(5,"EVENT, enginepriority_nativedial: "+webphone_api.common.GetCfgPriority("nativedial")+" "+webphone_api.common.GetParameter2("enginepriority_nativedial"))),t=9,webphone_api.common.SaveParameter("lastsessionsuccess","1"),t=10;var o="",i=webphone_api.common.getuseengine();o=i===webphone_api.global.ENGINE_JAVA?"jv":i===webphone_api.global.ENGINE_SERVICE?"ns":i===webphone_api.global.ENGINE_WEBRTC?"rtc":i,!1===webphone_api.common.IsWindowsSoftphone()&&(webphone_api.common.PutToDebugLog(1,"STATUS,-1,"+webphone_api.stringres.get("status_startingengine")+" ("+o+")"),webphone_api.common.PutToDebugLog(3,"EVENT, starting useengine: "+webphone_api.common.getuseengine())),t=11;var r=[];if(r.push("E"),r.push("R"),r.push("R"),r.push("O"),r.push("R"),r.push(","),r.push(" "),r.push("T"),r.push("h"),r.push("e"),r.push(" "),r.push("B"),r.push("a"),r.push("s"),r.push("i"),r.push("c"),r.push(" "),r.push("v"),r.push("e"),r.push("r"),r.push("s"),r.push("i"),r.push("o"),r.push("n"),r.push(" "),r.push("o"),r.push("f"),r.push(" "),r.push("W"),r.push("e"),r.push("b"),r.push("p"),r.push("h"),r.push("o"),r.push("n"),r.push("e"),r.push(" "),r.push("d"),r.push("o"),r.push("e"),r.push("s"),r.push(" "),r.push("n"),r.push("o"),r.push("t"),r.push(" "),r.push("s"),r.push("u"),r.push("p"),r.push("p"),r.push("o"),r.push("r"),r.push("t"),r.push(" "),r.push("["),r.push("B"),r.push("R"),r.push("S"),r.push("]"),r.push(" "),r.push("b"),r.push("r"),r.push("o"),r.push("w"),r.push("s"),r.push("e"),r.push("r"),t=12,webphone_api.common.Glv()<=0&&"Chrome"===webphone_api.common.GetBrowser()){t=13;var l=r.join("");return l=l.replace("[BRS]",webphone_api.common.GetBrowser()),setTimeout(function(){webphone_api.common.PutToDebugLog(1,l)},1500),setTimeout(function(){webphone_api.common.PutToDebugLog(1,l.replace("ERROR","STATUS"))},2500),void setTimeout(function(){webphone_api.common.AlertDialog("",l)},2500)}if(webphone_api.common.Glv()<=0&&!1===webphone_api.common.CanIUseApplet()){t=14;var l=r.join("") ;return l=l.replace("[BRS]",webphone_api.common.GetBrowser()),setTimeout(function(){webphone_api.common.PutToDebugLog(1,l)},1450),setTimeout(function(){webphone_api.common.PutToDebugLog(1,l.replace("ERROR","STATUS"))},2450),void setTimeout(function(){webphone_api.common.AlertDialog("",l)},2450)}t=15;var s=webphone_api.common.GetEngine(webphone_api.global.useengine);t=16,webphone_api.common.isNull(s)||(t=17,webphone_api.global.useengineclicked_cache=s.clicked,t=18,s.clicked=1,t=19,webphone_api.common.SetEngine(webphone_api.global.useengine,s),t=20),t=21,webphone_api.common.AutodetectDirectWebrtc(),t=22,webphone_api.global.lastconfroom="";var p=webphone_api.common.GetParameterInt("handleusernameuri",3);if(4==p||5==p){var m=webphone_api.common.GetParameter("serveraddress");if(m=webphone_api.common.GetParameter("serveraddress_user",m),5==p||webphone_api.common.isNull(m)||m.length<1||"YOURSIPDOMAIN.COM"===m&&"YOURSIPSERVER.COM"===m&&"SIPSERVER"===m&&"VOIPSERVER"===m&&"SERVERADDRESS"===m){var d="",b=webphone_api.common.GetParameter("username"),_=webphone_api.common.GetParameter("sipusername");b.indexOf("@")>0?d=b:_.indexOf("@")>0&&(d=_),d.length>0&&(d=webphone_api.common.StripServeraddress(d),d.length>0&&"YOURSIPDOMAIN.COM"!==d&&"YOURSIPSERVER.COM"!==d&&"SIPSERVER"!==d&&"VOIPSERVER"!==d&&"SERVERADDRESS"!==d&&(webphone_api.common.SaveParameter("serveraddress",d),webphone_api.common.SaveParameter("serveraddress_user",d)))}}t=25;var f=webphone_api.common.GetParameter2("serveraddress");if((webphone_api.common.isNull(f)||f.length<2||"YOURSIPDOMAIN.COM"===f||"YOURSIPSERVER.COM"===f||"SIPSERVER"===f||"VOIPSERVER"===f||"SERVERADDRESS"===f)&&(t=26,webphone_api.common.SaveParameter("serveraddress",""),f=webphone_api.common.GetParameter2("serveraddress_user"),webphone_api.common.isNull(f)||f.length<2||"YOURSIPDOMAIN.COM"===f||"YOURSIPSERVER.COM"===f||"SIPSERVER"===f||"VOIPSERVER"===f||"SERVERADDRESS"===f))return t=27,webphone_api.common.PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("error_noserver")),webphone_api.common.PutToDebugLog(2,"ERROR,"+webphone_api.stringres.get("error_noserver")+"; srv: "+webphone_api.common.GetParameter("serveraddress")+"; srv_user: "+webphone_api.common.GetParameter("serveraddress_user")),webphone_api.common.AlertDialog("ERROR","ERROR,"+webphone_api.stringres.get("error_noserver")),"undefined"!=typeof webphone_api.global.worktimer&&null!==webphone_api.global.worktimer&&clearTimeout(webphone_api.global.worktimer),webphone_api.global.worktimer=null,webphone_api.common.SaveParameter("upperserverfromuser",3),void $e();t=28;var w=webphone_api.common.GetSipusername(!0),v=webphone_api.common.GetParameter2("password");t=29,"USERNAME"===w&&"PASSWORD"===v&&(t=30,"USERNAME"===webphone_api.common.GetParameter("username")&&webphone_api.common.SaveParameter("username",""),"USERNAME"===webphone_api.common.GetParameter("sipusername")&&webphone_api.common.SaveParameter("sipusername",""),webphone_api.common.SaveParameter("password",""));var E=webphone_api.common.GetParameter("username");if(E.length>0){var P=webphone_api.common.StripUsername(E,!0);P!==E&&webphone_api.common.SaveParameter("username",P)}var T=webphone_api.common.GetParameter("sipusername");if(T.length>0){var S=webphone_api.common.GetParameterInt("handlesipusernameuri",-2);S<-1&&0===webphone_api.common.GetParameterInt("allowsipuriasusername",1)&&(S=1);var N="";N=S>0?webphone_api.common.StripUsername(T,!0):webphone_api.common.StripUsername(T,!1),N!==T&&webphone_api.common.SaveParameter("sipusername",N)}if(t=31,webphone_api.common.StartFCM(webphone_api.common.getuseengine()),t=32,"java"===webphone_api.common.getuseengine()){t=33,webphone_api.common.ResetWsapisocket("plhandler start java"),t=34;var I=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_java")),C=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_webrtc")),G=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_ns")),L=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_flash")),R=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_app")),y=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_p2p")),D=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_accessnum")),O=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_nativedial"));return t=35,(5===I||I>0&&C<1&&G<1&&L<1&&R<1&&y<1&&D<1&&O<1)&&0===webphone_api.common.IsJavaInstalled()&&webphone_api.common.EngineForcedInstall("java"),t=36,webphone_api.common.IsCurrentEngineWorking(ut),webphone_api.common.PutToDebugLog(2,"EVENT, start engine: java"),webphone_api.global.dispregfailed<1&&(webphone_api.global.dispregfailed=1),t=37,g(),t=38,webphone_api.webphone.Start()}if("ns"===webphone_api.common.getuseengine())return t=39,5===webphone_api.common.GetParameterInt("enginepriority_ns",2)&&(t=40,webphone_api.common.IsServiceInstalled(function(e){!1===e&&(webphone_api.common.PutToDebugLog(2,"EVENT, plhandler: StartEngineDelayed, service upgrade: "+webphone_api.common.GetMinServiceVersion().toString()),webphone_api.common.EngineForcedInstall("ns"))},!0)),t=41,void webphone_api.common.IsServiceInstalled(function(e){if(t=42,!0===e){t=43,webphone_api.common.PutToDebugLog(2,"EVENT, start engine: service");var n=!1,o=webphone_api.common.GetParameterInt("lnsengine",-1);!1===webphone_api.global.usestorage&&!1===webphone_api.common.Strl(60)&&0===o&&(t=44,n=!0,webphone_api.common.SaveParameter("lnsengine","1")),t=45;var i=6e3;n&&(t=46,webphone_api.common.PutToDebugLog(2,"EVENT, Force NS engine upgrade because release version changed"),webphone_api.common.EngineForcedInstall("ns",webphone_api.stringres.get("service_update")),webphone_api.global.nsupdatepending=!0,i=18e4),t=47,setTimeout(function(){webphone_api.common.IsServiceUpToDate()},i),webphone_api.global.dispregfailed<1&&(webphone_api.global.dispregfailed=1),t=48,g(),t=49,webphone_api.webphone.StartService()}else t=50,webphone_api.common.isNull(webphone_api.global.worktimer)||clearTimeout(webphone_api.global.worktimer),t=51,webphone_api.common.PutToDebugLog(2,"EVENT, start engine: service; NOT starting because it is not installed")},!0);if("webrtc"===webphone_api.common.getuseengine()){t=52;var x=0;x=webphone_api.common.GetParameterInt("autoprovisioning",1);var A=Ee("serveraddress_user");if(webphone_api.common.isNull(A)&&(A=""),t=53,0===x||A.length<1||1===x&&A.indexOf(".")>0)t=54,c();else{t=55;var k=webphone_api.common.GetParameterInt("lastautoprov",0);k<1?(t=56,webphone_api.common.GetAutoprovisioning("",function(e){t=57,webphone_api.common.ParseAutoprovisioning(e),t=58,c()})):(t=59,c(),t=60,webphone_api.common.GetAutoprovisioning("",function(e){t=61,webphone_api.common.ParseAutoprovisioning(e)}))}return}if("flash"===webphone_api.common.getuseengine()){t=62;var x=0;x=webphone_api.common.GetParameterInt("autoprovisioning",1);var A=Ee("serveraddress_user");if(webphone_api.common.isNull(A)&&(A=""),t=63,0===x||A.length<1||1===x&&A.indexOf(".")>0)t=64,u();else{t=65;var k=webphone_api.common.GetParameterInt("lastautoprov",0);k<1?webphone_api.common.GetAutoprovisioning("",function(e){t=66,webphone_api.common.ParseAutoprovisioning(e),u()}):(t=67,u(),webphone_api.common.GetAutoprovisioning("",function(e){webphone_api.common.ParseAutoprovisioning(e)}))}return}if("app"===webphone_api.common.getuseengine()){t=68,t=69;var U=webphone_api.common.GetParameterInt("appengine_startat",2);1===U||2===U&&!1===webphone_api.common.IsSDK()?webphone_api.common.StartAppEngine(!0,"EVENT, start engine: app HandleProtocol, open native app"):(webphone_api.common.PutToDebugLog(2,"EVENT, start engine: skip APP engine start, appengine_startat: "+U+"; isSDK: "+webphone_api.common.IsSDK()),webphone_api.common.PutToDebugLog(1,"EVENT, Ready."))}else webphone_api.common.PutToDebugLog(2,"ERROR, start engine: invalid engine: "+webphone_api.common.getuseengine());t=70,setTimeout(function(){t=71,webphone_api.global.startendelayed_wascalled=!1},12e3)}catch(V){webphone_api.common.PutToDebugLogException(2,"plhandler: StartEngineDelayedEx ("+t.toString()+")",V)}}function c(){try{if(Ct<0&&(Ct=webphone_api.common.GetTickCount()),!1===webphone_api.global.pgw_decide_finished&&(webphone_api.common.isNull(It)||clearTimeout(It),It=null,It=setTimeout(function(){c()},150)),webphone_api.common.isNull(It)||clearTimeout(It),It=null,Ct>0&&webphone_api.common.GetTickCount()-Ct>6500&&!0===webphone_api.common.GetParameterBool("firststart_webrtc",!0)&&!0===webphone_api.common.CanIUseService()){webphone_api.common.PutToDebugLog(2,"WARNING, StartEngineWebRTC Failover to NS engine, because no response received from Websocket wsload"),webphone_api.common.SaveParameter("prevusedengine","webrtc"),webphone_api.common.SaveParameter("lastusedengine","ns"),webphone_api.flagrestartwebrtc=!1,webphone_api.common.ResetEngineClicked();var e=webphone_api.common.GetEngine("ns");e.clicked=2,webphone_api.common.SetEngine("ns",e),webphone_api.common.EngineSelect(1,30),webphone_api.common.PutToDebugLog(2,"WARNING, plhandler: offer ns engine because webrtc not received"),webphone_api.common.IsServiceInstalled(function(e){!1===e?webphone_api.common.EngineForcedInstall("ns",webphone_api.stringres.get("serviceengine_msg"),null,function(){webphone_api.startInner()}):webphone_api.startInner()},!0)}Ct=-1,webphone_api.common.ResetWsapisocket("plhandler start webrtc");var n=webphone_api.common.GetParameter("password");(webphone_api.common.isNull(n)||n.length<1)&&!1===webphone_api.common.NeedRegister()||t(),!0===webphone_api.common.UseTLSReload()&&webphone_api.common.TLSReload(),webphone_api.common.Ch(),webphone_api.common.PutToDebugLog(2,"EVENT, start engine: webrtc"),webphone_api.common.CheckEngineFirstStart(ut),webphone_api.common.GatewayFailower(-1,"starten");var o=webphone_api.common.GetWebrtcSrvAddr();if(2===webphone_api.common.GetConfigInt("usemizuwebrtcgateway",1)&&(o=""),(webphone_api.common.isNull(o)||o.length<2)&&(o=webphone_api.common.GetWp()),o.indexOf("mfstwebsock")<0){var i=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_java")),a=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_webrtc")),r=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_ns")),l=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_flash")),s=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_app")),p=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_p2p")),u=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_accessnum")),h=webphone_api.common.StrToInt(webphone_api.common.GetParameter2("enginepriority_nativedial"));i<3&&a<3&&r<3&&l<3&&s<3&&p<3&&u<3&&h<3&&(a=3,webphone_api.common.SaveParameter("enginepriority_webrtc",a),webphone_api.common.PutToDebugLog(2,"EVENT,WebRtc engine priority set to higher, because not Mgateway: "+a))}return"Android"===webphone_api.common.GetOs()&&3===webphone_api.common.GetParameterInt("androidspeaker",1)&&setTimeout(function(){webphone_api.webrtcapi.SwitchOffAndroidSpeaker()},500),webphone_api.global.dispregfailed<1&&(webphone_api.global.dispregfailed=1),g(),webphone_api.webrtcapi.Start()}catch(m){webphone_api.common.PutToDebugLogException(2,"plhandler: StartEngineWebRTC",m)}}function u(){try{return webphone_api.common.PutToDebugLog(2,"EVENT, start engine: flash"),webphone_api.global.dispregfailed<1&&(webphone_api.global.dispregfailed=1),g(),webphone_api.flashapi.Start()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: StartEngineFlash",e)}}function g(){try{var e=webphone_api.common.GetAutostart();if(!0===webphone_api.common.IsSDK()||0!==e)return!1;setTimeout(function(){if("page_settings"===webphone_api.$.mobile.activePage.attr("id")){webphone_api.common.PutToDebugLog(2,"EVENT, plhandler LoginSkin exec");var e=webphone_api.common.GetSipusername(!0),n=webphone_api.common.GetParameter("password");return!webphone_api.common.isNull(e)&&e.length>0&&!webphone_api.common.isNull(n)&&n.length>0?(webphone_api.global.laststarttick=webphone_api.common.GetTickCount()+100,void(webphone_api.common.isNull(webphone_api._settings)||webphone_api._settings.SaveSettings())):void 0}},600)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: LoginSkin",n)}}function h(e,n){try{if(0!=Gt&&webphone_api.common.GetTickCount()-Gt<3e3&&webphone_api.common.GetTickCount()-Gt>=0)return;Gt=webphone_api.common.GetTickCount(),(webphone_api.common.isNull(e)||!1===webphone_api.common.IsNumber(e)||e<0)&&(e=2e3);var t=200;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(t=150),webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu called delay: "+e+"; delayaddition: "+t),!0===n)return setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist 0"),webphone_api.getdevicelist(0,function(e){}),webphone_api.getdevice(0,function(e){})},e),setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist 1"),webphone_api.getdevicelist(1,function(e){}),webphone_api.getdevice(1,function(e){})},e+150),webphone_api.common.CanIUseVideo()&&setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist 2"),webphone_api.getdevicelist(2,function(e){}),webphone_api.getdevice(2,function(e){})},e+300),void webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu return forced");(webphone_api.common.isNull(webphone_api.global.audio_rec_device_list)||webphone_api.global.audio_rec_device_list.length<1)&&setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist mic"),webphone_api.getdevicelist(0,function(e){webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu rec mic 1")}),webphone_api.getdevice(0,function(e){webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu rec mic 2")})},e+t),(webphone_api.common.isNull(webphone_api.global.audio_play_device_list)||webphone_api.global.audio_play_device_list.length<1)&&setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist play"),webphone_api.getdevicelist(1,function(e){webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu rec play 1")}),webphone_api.getdevice(1,function(e){webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu rec play 2")})},e+2*t),(webphone_api.common.isNull(webphone_api.global.audio_ring_device_list)||webphone_api.global.audio_ring_device_list.length<1)&&setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist ring"),webphone_api.getdevicelist(2,function(e){webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu rec ring 1")}),webphone_api.getdevice(2,function(e){webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu rec ring 2")})},e+3*t),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.common.CanIUseVideo()&&(webphone_api.common.isNull(webphone_api.global.video_rec_device_list)||webphone_api.global.video_rec_device_list.length<1)&&setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist video"),webphone_api.getdevicelist(3,function(e){}),webphone_api.getdevice(3,function(e){})},e+4*t),setTimeout(function(){if(webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu START checking audio_rec_device_list: "+webphone_api.global.audio_rec_device_list+"; audio_play_device_list: "+webphone_api.global.audio_play_device_list),!webphone_api.common.isNull(webphone_api.global.audio_rec_device_list)&&webphone_api.global.audio_rec_device_list.length>0&&!webphone_api.common.isNull(webphone_api.global.audio_play_device_list)&&webphone_api.global.audio_play_device_list.length>0){var n=webphone_api.common.GetTickCount()-Gt;webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu READY on first try after delay: "+n),webphone_api.global.audio_devices_loaded=!0}else setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist delayed 0"),webphone_api.getdevicelist(0,function(e){}),webphone_api.getdevice(0,function(e){})},e+2e4+t),setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist delayed 1"),webphone_api.getdevicelist(1,function(e){}),webphone_api.getdevice(1,function(e){})},e+2e4+2*t),setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist delayed 2"),webphone_api.getdevicelist(2,function(e){}),webphone_api.getdevice(2,function(e){})},e+2e4+3*t),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.common.CanIUseVideo()&&setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Getdevice and API_GetDevicelist delayed 3"),webphone_api.getdevicelist(3,function(e){}),webphone_api.getdevice(3,function(e){})},e+2e4+4*t),setTimeout(function(){if(!webphone_api.common.isNull(webphone_api.global.audio_rec_device_list)&&webphone_api.global.audio_rec_device_list.length>0&&!webphone_api.common.isNull(webphone_api.global.audio_play_device_list)&&webphone_api.global.audio_play_device_list.length>0){var e=webphone_api.common.GetTickCount()-Gt;webphone_api.common.PutToDebugLog(5,"EVENT, GetAudioDevicesForMenu READY on second try after delay: "+e),webphone_api.global.audio_devices_loaded=!0}},e+4*t)},e+3*t+500)}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: GetAudioDevicesForMenu",o)}}function m(e){try{Jn("Register");var t=webphone_api.common.GetParameterInt("register",1);if(webphone_api.parameters.register=2,webphone_api.common.SaveParameter("register","2"),webphone_api.common.PutToDebugLog(2,"EVENT, user, register (API_Register) called"),st)return void webphone_api.common.PutToDebugLog(3,"EVENT, plhandler register, Start already called");ct=!0,webphone_api.common.isNull(pt)||clearTimeout(pt),pt=setTimeout(function(){ct=!1},6e3);var o=webphone_api.common.IsConfigChanged();!0===o&&!0===webphone_api.isregistered()||!0===webphone_api.global.pres_unreg_called||0===t||0!=Lt&&webphone_api.common.GetTickCount()-Lt>12e3&&!webphone_api.isregistered()?(!0===o&&!0===webphone_api.isregistered()?webphone_api.common.PutToDebugLog(5,"EVENT, rst on config changhe"):!0===webphone_api.global.pres_unreg_called?webphone_api.common.PutToDebugLog(5,"EVENT, rst on after unreg"):0===t?webphone_api.common.PutToDebugLog(5,"EVENT, rst on no orig reg"):0!=Lt&&webphone_api.common.GetTickCount()-Lt>12e3&&!webphone_api.isregistered()?webphone_api.common.PutToDebugLog(5,"EVENT, rst on not registered"):webphone_api.common.PutToDebugLog(5,"EVENT, rst on unknown"),Lt=webphone_api.common.GetTickCount(),n(e)):0==Lt||ct||d()}catch(i){webphone_api.common.PutToDebugLogException(2,"plhandler: Register",i)}}function d(){try{if(webphone_api.common.PutToDebugLog(3,"EVENT, Reregister ..."),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void(webphone_api.webrtcapi&&webphone_api.webrtcapi.ResendRegister());if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_RegisterNoParam",null,-1);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE()&&webphone_api.webphone&&webphone_api.webphone.applethandle)return webphone_api.webphone.ReRegister()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: ReRegister",e)}}function b(e){try{Jn("RegisterEx");var n=25;if(webphone_api.common.Glv()<2&&(n=13),webphone_api.common.isNull(e)||e.length<4)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler RegisterEx no acocunts passed: "+e);if(e=e.toString(),e=webphone_api.common.ReplaceAll(e," ",""),webphone_api.common.isNull(e)||e.length<4)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler RegisterEx no acocunts passed: "+e);if(n<21){var t=[];t.push("E"),t.push("R"),t.push("R"),t.push("O"),t.push("R"),t.push(","),t.push("R"),t.push("e"),t.push("g"),t.push("i"),t.push("s"),t.push("t"),t.push("e"),t.push("r"),t.push("E"),t.push("x"),t.push(" "),t.push("n"),t.push("o"),t.push("t"),t.push(" "),t.push("a"),t.push("l"),t.push("l"),t.push("o"),t.push("w"),t.push("e"),t.push("d"),t.push(" "),t.push("b"),t.push("y"),t.push(" "),t.push("l"),t.push("i"),t.push("c"),t.push("e"),t.push("n"),t.push("s"),t.push("e");var o=t.join("");return void setTimeout(function(){webphone_api.common.PutToDebugLog(1,o)},851)}if("null"==e&&(e=""),webphone_api.common.SaveParameter("extraregisteraccounts",e),webphone_api.common.PutToDebugLog(2,"EVENT, plhandler RegisterEx: "+e),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){if(e.length<1)return;webphone_api.webrtcapi.RegisterEx(e)}if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH){if(e.length<1)return;webphone_api.common.PutToDebugLog(2,"ERROR, RegisterEx is not supported by flash engine")}webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE||webphone_api.common.WinAPI("API_RegisterEx",null,e),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&webphone_api.webphone.RegisterEx(e)}catch(i){webphone_api.common.PutToDebugLogException(2,"plhandler: RegisterEx",i)}}function _(e,n){try{if(Jn("CheckPresence"),webphone_api.common.isNull(e)||e.length<1)return"";if(webphone_api.global.phonestarted<2)return void Yn("CheckPresence",[e,n]);if(webphone_api.common.PutToDebugLog(2,"EVENT, user, checkpresence (API_CheckPresence), userlist: "+e),n&&"function"==typeof n&&(webphone_api.common.isNull(webphone_api.global.checkpres_callback)&&(webphone_api.global.checkpres_callback=[]),webphone_api.global.checkpres_callback.push(n)),webphone_api.common.PresenceGet2(e),!webphone_api.common.isNull(webphone_api.global.presenceHM)){var t={5:"online",4:"DND",3:"pending",2:"idle",1:"invisible",0:"offline","-1":"not exists"},o="";for(var i in webphone_api.global.presenceHM)webphone_api.common.isNull(i)||i.length<1||webphone_api.common.isNull(webphone_api.global.presenceHM.num)||(o.length>1&&(o+=";"),o=o+i+","+t[o.num[webphone_api.common.PRES_STATUS]]);return webphone_api.common.isNull(o)&&(o=""),o}}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: CheckPresence",a)}return""}function f(e){if(Jn("SetPresenceStatus"),webphone_api.global.phonestarted<2)return void Yn("SetPresenceStatus",[e]);webphone_api.common.PutToDebugLog(2,"EVENT, user, setpresencestatus (API_SetPresenceStatus), status: "+e),webphone_api.common.PresenceSet2(e)}function w(e){Jn("CheckBLF");try{if(webphone_api.common.isNull(e)||e.length<1)return webphone_api.common.PutToDebugLog(2,"ERROR, plhandler checkblf empty userkist"),!1;if(webphone_api.global.phonestarted<2)return Yn("CheckBLF",[e]),!0;if(webphone_api.common.PutToDebugLog(2,"EVENT, plhandler API_CheckBLF: "+e),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.common.PutToDebugLog(2,"WARNING, BLF is not yet supported on WebRTC"),!1;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"WARNING, BLF is not yet supported on flash"),!1;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_CheckBLF",null,e),!0;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return webphone_api.webphone.CheckBLF(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: CheckBLF",n)}return!1}function v(e){Jn("GetVersionNS");try{if(!e||"function"!=typeof e)return webphone_api.common.PutToDebugLog(2,"ERROR, plhandler GetVersionNS: no callback function specified"),"ERROR, no callback function specified";if(webphone_api.common.PutToDebugLog(2,"EVENT, plhandler getversionns"),webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE||webphone_api.common.WinAPI("API_GetExeVersion",function(n){webphone_api.common.isNull(n)&&(n=""),n=n.toString(),n=n.replace("OK:",""),n=webphone_api.common.Trim(n),e(n)}),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA){var n=webphone_api.webphone.GetVersionNS();n=n.toString(),n=n.replace("OK:",""),n=webphone_api.common.Trim(n),e(n)}}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: GetVersionNS",t)}}function E(e){Jn("GetVersionNSNum");try{if(!e||"function"!=typeof e)return webphone_api.common.PutToDebugLog(2,"ERROR, plhandler GetVersionNSNum: no callback function specified"),"ERROR, no callback function specified";if(webphone_api.common.PutToDebugLog(2,"EVENT, plhandler getversionnsnum"),webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE||webphone_api.common.WinAPI("API_GetExeVersionNumber",function(n){webphone_api.common.isNull(n)&&(n=""),n=n.toString(),n=n.replace("OK:",""),n=webphone_api.common.Trim(n),e(n)}),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA){var n=webphone_api.webphone.GetVersionNSNum();webphone_api.common.isNull(n)&&(n=""),n=n.toString(),n=n.replace("OK:",""),n=webphone_api.common.Trim(n),e(n)}}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: GetVersionNS",t)}}function P(e){Jn("GetVersionJava");try{if(!e||"function"!=typeof e)return webphone_api.common.PutToDebugLog(2,"ERROR, plhandler GetVersionJava: no callback function specified"),"ERROR, no callback function specified";if(webphone_api.common.PutToDebugLog(2,"EVENT, plhandler getversionjava"),webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE||webphone_api.common.WinAPI("API_GetExeVersion",function(n){webphone_api.common.isNull(n)&&(n=""),e(n)}),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return void e(webphone_api.webphone.GetVersionJava())}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: GetVersionJava",n)}}function T(){try{if(Jn("IsEncrypted"),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return 3;if(webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.global.useengine!==webphone_api.global.ENGINE_SERVICE&&webphone_api.global.useengine!==webphone_api.global.ENGINE_JAVA)return 0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_IsEncrypted",function(e){!webphone_api.common.isNull(e)&&webphone_api.common.IsNumber(e)&&(webphone_api.global.isencrypted=e)}),0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.IsEncrypted()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: IsEncrypted",e)}return 0}function S(e,n){try{if(Jn("SetSipHeader"),webphone_api.common.isNull(e))return void webphone_api.common.PutToDebugLog(2,"ERROR, SetSipHeader invalid header. A valid SIP header consists of a name/value pair separated by a colon, ex. Headername: Value");if(webphone_api.global.phonestarted<2)return void Yn("SetSipHeader",[e]);webphone_api.common.PutToDebugLog(2,"EVENT, setsipheader: "+e);var t=webphone_api.global.aline;if(!webphone_api.common.isNull(n)&&webphone_api.common.IsNumber(n)&&(t=n),(webphone_api.common.isNull(t)||-3===t)&&(t=-1),e=webphone_api.common.Trim(e),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.webrtcapi.SetSipHeader(t,e);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return void webphone_api.common.PutToDebugLog(2,"ERROR, setsipheader is not supported by flash engine");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_SetSIPHeader",null,webphone_api.common.GetLineForJavaAPI(n),e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.SetSipHeader(webphone_api.common.GetLineForJavaAPI(n),e)}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: SetSipHeader",o)}}function N(e,n){try{if(Jn("GetSipHeaderInternal"),!n||"function"!=typeof n)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetSipHeaderInternal callback is not defined");var t=webphone_api.global.aline;if((webphone_api.common.isNull(t)||-3===t)&&(t=-1),webphone_api.common.isNull(e)||e.length<1)return webphone_api.common.PutToDebugLog(2,"ERROR, Invalid header: "+e),void n("ERROR, Invalid header: "+e);if(e=e.toString(),e=e.replace(":",""),webphone_api.global.phonestarted<2)return void Yn("GetSipHeaderInternal",[e,n]);if(webphone_api.common.PutToDebugLog(2,"EVENT, plhandler: GetSipHeaderInternal: "+e+"; ("+webphone_api.common.getuseengine()+")"),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void n(webphone_api.common.GetSipHeaderInternal(e));if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"ERROR, GetSipHeaderInternal is not supported by flash engine"),void n("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetSipHeaderInternal",function(e){n(e)},webphone_api.common.GetLineForJavaAPI(t,1),e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void n(webphone_api.webphone.GetSipHeaderInternal(webphone_api.common.GetLineForJavaAPI(t,1),e,n))}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: GetSipHeaderInternal",o)}}function I(e,n,t){var o=0;try{if(o=1,Jn("GetSipHeader"),!n||"function"!=typeof n)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetSipHeader callback is not defined");o=2;var i=webphone_api.global.aline;if((webphone_api.common.isNull(i)||-3===i)&&(i=-1),webphone_api.common.isNull(e)||e.length<1)return webphone_api.common.PutToDebugLog(2,"ERROR, Invalid header: "+e),void n("ERROR, Invalid header: "+e);if(o=3,e=e.toString(),e=e.replace(":",""),o=4,webphone_api.global.phonestarted<2)return o=5,void Yn("GetSipHeader",[e,n]);if(webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, plhandler: getsipheader: "+e+"; ("+webphone_api.common.getuseengine()+")"),o=6,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return o=7,void n(webphone_api.common.GetSipHeader(e,!1,-1,t));if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return o=8,webphone_api.common.PutToDebugLog(2,"ERROR, getsipheader is not supported by flash engine"),void n("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return o=9,void webphone_api.common.WinAPI("API_GetSIPHeader",function(e){n(e)},webphone_api.common.GetLineForJavaAPI(),e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return o=10, void n(webphone_api.webphone.GetSipHeader(webphone_api.common.GetLineForJavaAPI(),e,n))}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: GetSipHeader ("+o.toString()+")",a)}}function C(e,n,t,o){try{if(Jn("GetSipMessage"),!t||"function"!=typeof t)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetSipMessage callback is not defined");var i=webphone_api.global.aline;if((webphone_api.common.isNull(i)||-3===i)&&(i=-1),webphone_api.global.phonestarted<2)return void Yn("GetSipMessage",[e,n,t,o]);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void t(webphone_api.common.GetSipMessage(i,e,n,o));if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"ERROR, GetSipMessage is not supported by flash engine"),void t("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetSIPMessage",function(e){t(e)},webphone_api.common.GetLineForJavaAPI(),e,n);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void t(webphone_api.webphone.GetSipMessage(webphone_api.common.GetLineForJavaAPI(),e,n))}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: GetSipMessage",a)}}function G(e){try{if(Jn("GetSipMessage"),webphone_api.common.isNull(e)||!webphone_api.common.IsNumber(e))return!1;var n=webphone_api.common.StrToInt(e);if(n<0||n>45)return!1;if(webphone_api.common.PutToDebugLog(2,"EVENT, plhandler changetheme to: "+n.toString()),webphone_api.common.SaveParameter("theme",n.toString()),webphone_api.common.SetCurrTheme(),webphone_api.common.IsWindowsSoftphone()){var t=webphone_api.common.AddJscommport(webphone_api.global.WIN_SOFTPHONE_URL)+"?extcmd_theme="+e;webphone_api.common.WinSoftphoneHttpReq(t,"GET","","",function(e){webphone_api.common.PutToDebugLog(2,"EVENT, plhandler, send theme to softphone response: "+e)})}return!0}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: ChangeTheme",o)}return!1}function L(e){try{if(Jn("GetWorkDir"),!e||"function"!=typeof e)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetWorkDir callback is not definaed");if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.common.PutToDebugLog(2,"ERROR, getworkdir: only for ns and java"),void e("ERROR, etworkdir: only for ns and java");if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"ERROR, getworkdir: only for ns and java"),void e("ERROR, etworkdir: only for ns and java");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetWorkdir",function(n){e(n)});if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void e(webphone_api.webphone.GetWorkDir())}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: GetWorkDir",n)}}function R(e){Jn("VideoCall"),!1!==webphone_api.common.Glvd()&&x(e,1)}function y(e,n){try{return Jn("MuteVideo"),!1===webphone_api.global.checkIfCallActive?(webphone_api.common.PutToDebugLog(2,"WARNING, MuteVideo there is no active call at the moment."),!1):!1===webphone_api.global.isvideocall?(webphone_api.common.PutToDebugLog(2,"WARNING, MuteVideo this is not a video call."),!1):webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_WEBRTC?(webphone_api.common.PutToDebugLog(2,"ERROR, MuteVideo this is not WebRTC engine."),!1):(e?webphone_api.common.PutToDebugLog(1,"STATUS, "+webphone_api.stringres.get("muted_video")):webphone_api.common.PutToDebugLog(1,"STATUS, "+webphone_api.stringres.get("unmuted_video")),webphone_api.common.PutToDebugLog(2,"EVENT, USER, mutevideo (API_MuteVideo), "+e+", "+n),webphone_api.webrtcapi.SipMuteVideo(e,n))}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: MuteVideo",t)}return!1}function D(e,n){function t(){x(e,2)}try{if(Jn("ScreenShare"),!1===webphone_api.common.Glss())return;webphone_api.common.IsWindowsSoftphone(),t()}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: ScreenShare",o)}}function O(){try{if(!webphone_api.global.usestorage)return;webphone_api.common.isNull(Rt)||(clearTimeout(Rt),Rt=null)}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: Cfin",e)}}function x(e,n){try{Jn("Call"),webphone_api.global.ringstart_time=0,webphone_api.global.callstart_time=0,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_APP&&!1===webphone_api.global.isappenginestarted&&webphone_api.common.StartAppEngine(!0,"EVENT, start engine: because initiating call",!0,e),Dt=!1;var t=115e3;if((webphone_api.common.isNull(n)||!1===webphone_api.common.IsNumber(n))&&(n=0),webphone_api.common.SvCont()&&(t=23e4),webphone_api.global.usestorage&&(Rt=setTimeout(function(){clearTimeout(Rt),Rt=null;var e=[];e.push("L"),e.push("i"),e.push("c"),e.push("e"),e.push("n"),e.push("s"),e.push("e"),e.push(" "),e.push("o"),e.push("r"),e.push(" "),e.push("d"),e.push("e"),e.push("m"),e.push("o "),e.push("l"),e.push("i"),e.push("m"),e.push("i"),e.push("t"),e.push(". "),e.push("R"),e.push("e"),e.push("s"),e.push("t"),e.push("a"),e.push("r"),e.push("t "),e.push("r"),e.push("e"),e.push("q"),e.push("u"),e.push("i"),e.push("r"),e.push("e"),e.push("d"),e.push(" "),e.push("h"),e.push("a"),e.push("n"),e.push("g"),e.push("u"),e.push("p"),e.push(" "),e.push("9");var n=e.join("");V(null,!0),setTimeout(function(){webphone_api.common.PutToDebugLog(1,"ERROR,"+n)},100),setTimeout(function(){webphone_api.common.PutToDebugLog(1,"ERROR,"+n),webphone_api.common.ShowToast("ERROR,"+n,15e3)},250)},t)),!webphone_api.common.onc())return!1;webphone_api.common.GetNrOfActiveCalls()<1&&webphone_api.notifications.SetCallStartTime(webphone_api.common.GetTickCount());var o=webphone_api.global.aline;if((webphone_api.common.isNull(o)||-3===o)&&(o=-1),webphone_api.common.IsLineFree(o)||(o=webphone_api.common.GetFreeLine(),Pe(o,!1,500)),webphone_api.common.isNull(e)||webphone_api.common.Trim(e).length<1)return webphone_api.common.PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_msg_4")+": "+e),!1;if(e=webphone_api.common.Trim(e),webphone_api.common.PutToDebugLog(2,"EVENT, plhandler initiate Call with engine: "+webphone_api.global.useengine+", to number: "+e),webphone_api.global.sipstackstarted=!0,!0===webphone_api.common.CanUseIncomingCallNot()){var i=webphone_api.common.GetParameterInt("askfornotifpermission",-1);i=webphone_api.common.GetParameterInt("asknotifpermission",i),i>=3&&webphone_api.common.RequestBrowserNotificationPermission(function(){},"","","",3)}if(webphone_api.common.RemoveSipHeadreFromCache("X-reason"),webphone_api.common.RemoveSipHeadreFromCache("Reason"),webphone_api.common.RemoveSipHeadreFromCache("Warning"),"p2p"===webphone_api.common.getuseengine())return void webphone_api.common.Phone2Phone("",e);if("accessnum"===webphone_api.common.getuseengine())var a=webphone_api.common.GetParameter("accessnumber"),r="tel://"+a;else if("nativedial"===webphone_api.common.getuseengine()||"app"===webphone_api.common.getuseengine()){var r="tel://"+encodeURIComponent(e),l='';return webphone_api.$("body").append(l),webphone_api.$("#make_native_call").on("click",function(){var e=webphone_api.$("#make_native_call").attr("href");webphone_api.$("#make_native_call").remove(),window.location=e}),webphone_api.$("#make_native_call").click(),void webphone_api.common.ShowToast(webphone_api.stringres.get("native_call"))}var s=!1,p=webphone_api.common.GetParameterInt("multilineoop",2),c=webphone_api.common.GetNrOfActiveCalls();if(c<1&&webphone_api.notifications.SetCallStartTime(webphone_api.common.GetTickCount()),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(-1==p||c>0&&(p<2||p<3&&"Firefox"===webphone_api.common.GetBrowser()))&&!webphone_api.common.isNull(webphone_api.global.ep)&&webphone_api.global.ep.length>0)for(var u=0;u0||-1==p){if(webphone_api.common.PutToDebugLog(5,"EVENT, mute after reload timeout"),-1!=p){Te()!=g&&Pe(g,!0,502)}return J(!0,null,!0)}(g<1||-1==p)&&webphone_api.global.callaftermute_number.length>0&&(webphone_api.common.PutToDebugLog(5,"EVENT, call after reload timeout"),Pe(o,!0,505),A(o,e,n))},h)}c<1&&webphone_api.notifications.SetCallStartTime(webphone_api.common.GetTickCount()),s||A(o,e,n)}catch(m){webphone_api.common.PutToDebugLogException(2,"plhandler: Call",m)}return!1}function A(e,t,o){try{webphone_api.common.isNull(yt)||clearTimeout(yt),yt=null,webphone_api.global.sipstackstarted=!0,webphone_api.global.phonestarted<1&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_APP&&(webphone_api.global.phonestarted=1,n(webphone_api.parameters));var i=webphone_api.common.NeedRegister(),a=webphone_api.common.GetTickCount();if(0==Ot&&(Ot=a),!0===webphone_api.common.GetParameterBool("mustconnect",!1)&&webphone_api.global.phonestarted<3)return webphone_api.common.PutToDebugLog(1,"ERROR, "+webphone_api.stringres.get("warning_notreg")),void webphone_api.common.ShowToast(webphone_api.stringres.get("warning_notreg"));if(i&&webphone_api.global.phonestarted<3&&a-Ot<4e3||webphone_api.global.phonestarted<2){var r=webphone_api.common.GetParameterInt("register",1);return r>1&&!1===Dt&&a-Ot>3500&&(Dt=!0,!1===i?(webphone_api.common.PutToDebugLog(2,"WARNING, Cannot initiate call because SipStack is not started ("+r.toString()+" "+(a-Ot).toString()+" "+Ot.toString()+")"),webphone_api.common.ShowToast(webphone_api.stringres.get("warning_notstarted"))):(webphone_api.common.PutToDebugLog(2,"WARNING, "+webphone_api.stringres.get("warning_notreg")+" ("+r.toString()+" "+(a-Ot).toString()+" "+Ot.toString()+")"),2===r&&webphone_api.common.ShowToast(webphone_api.stringres.get("warning_notreg")))),void(yt=setTimeout(function(){A(e,t,o)},250))}var l="audio";1===o&&(l="video"),2===o&&(l="screenshare"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, API_Call ("+webphone_api.global.useengine+"), to: "+t+", on line: "+e.toString()+", type: "+l+", engine: "+webphone_api.common.getuseengine()+" / "+webphone_api.common.GetParameter("devicetype")),Dt=!1,Ot=0,0==webphone_api.common.IsSDK()&&(webphone_api.global.intentcall[0]="number="+t,webphone_api.global.intentcall[1]="calltype=outgoing",webphone_api.global.intentcall[2]="name=",webphone_api.global.intentcall[3]="callmode="+o,setTimeout(function(){webphone_api.$.mobile.changePage("#page_call",{transition:"pop",role:"page"})},10));var s=webphone_api.common.GetParameterInt("androidspeaker",-1);-1==s&&(s=webphone_api.global.isvideocall?0:1),!0===webphone_api.global.isfirstcall&&"Android"===webphone_api.common.GetOs()&&1===s&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC?(webphone_api.common.PutToDebugLog(2,"EVENT, call handle SwitchOffAndroidSpeaker"),webphone_api.webrtcapi.SwitchOffAndroidSpeaker(function(){webphone_api.common.PutToDebugLog(2,"EVENT, call SwitchOffAndroidSpeaker handled"),k(e,t,o)})):k(e,t,o)}catch(p){webphone_api.common.PutToDebugLogException(2,"plhandler: CallDelayed",p)}}function k(e,n,t){try{if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.global.stacknotstarted_retry=!0,0===t?webphone_api.webrtcapi.SipCall("call-audio",e,n):1===t?(webphone_api.global.isvideocall=!0,webphone_api.webrtcapi.SipCall("call-audiovideo",e,n)):2===t?(webphone_api.isscreensharecall=!0,webphone_api.webrtcapi.SipCall("call-screenshare",e,n)):webphone_api.webrtcapi.SipCall("call-audio",e,n);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.flashapi.Call(n);if(!0===webphone_api.common.IsWindowsSoftphone())return 0===t?void webphone_api.common.WinAPI("API_Call",null,webphone_api.common.GetLineForJavaAPI(e),n):1===t?(webphone_api.global.isvideocall=!0,void webphone_api.common.WinAPI("API_SoftphoneVideoCall",null,n)):2===t?(webphone_api.isscreensharecall=!0,void webphone_api.common.WinAPI("API_SoftphoneScreenshare",null,n)):void webphone_api.common.WinAPI("API_Call",null,webphone_api.common.GetLineForJavaAPI(e),n);if(t>0&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE&&!0===webphone_api.common.CanIUseWebRTC())return webphone_api.common.SwitchToEngine(webphone_api.global.ENGINE_WEBRTC),void setTimeout(function(){A(e,n,t)},3e3);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_Call",null,webphone_api.common.GetLineForJavaAPI(e),n);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.Call(webphone_api.common.GetLineForJavaAPI(e),n)}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: CallDelayedSecond",o)}}function U(){try{Jn("StopScreenShare");var e=webphone_api.global.aline;(webphone_api.common.isNull(e)||-3===e)&&(e=-1),webphone_api.common.PutToDebugLog(2,"EVENT, USER, stopscreenshare (API_StopScreenShare) ("+webphone_api.global.useengine+") on line: "+e.toString());var n=webphone_api.common.GetCallSession(21,!0,e,"");if(webphone_api.common.isNull(n)&&(webphone_api.global.checkIfInCall=!1,webphone_api.global.checkIfCallActive=!1,webphone_api.global.active_incoming_call=!1,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.webrtcapi.ClearPendingStartMedia()),webphone_api.global.hadStartMediaPending=!1,setTimeout(function(){webphone_api.common.GetEndpoint(1017,e,"","","",!0)},400),setTimeout(function(){if(webphone_api.common.GetNrOfActiveCalls()>0){Pe(webphone_api.common.GetBestLine(),!1,506),!1!==webphone_api.common.IsSDK()||!0!==webphone_api.global.isCallStarted||webphone_api.common.isNull(webphone_api._call)||webphone_api._call.UpdateLineButtons(16)}},350),-2===e&&!webphone_api.common.isNull(webphone_api.global.ep)&&webphone_api.global.ep.length>0){for(var t=0;t1||webphone_api.common.GetNrOfActiveCalls()>0){var e=webphone_api.common.GetBestLine();webphone_api.global.aline==t?Pe(e,!1,507):Pe(e,!0,508),!1!==webphone_api.common.IsSDK()||!0!==webphone_api.global.isCallStarted||webphone_api.common.isNull(webphone_api._call)||webphone_api._call.UpdateLineButtons(17)}},350),-2===t&&!webphone_api.common.isNull(webphone_api.global.ep)&&webphone_api.global.ep.length>0){if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE||webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())W(-2,-2);else for(var a=0;a0&&(1===o?(webphone_api.common.PutToDebugLog(5,"EVENT, USER SetVideoSize remote width: "+n+"; height: "+t),webphone_api.$("#div_video_remote").width(i),a>0&&webphone_api.$("#div_video_remote").height(a)):2===o&&(webphone_api.common.PutToDebugLog(5,"EVENT, USER SetVideoSize local width: "+n+"; height: "+t),webphone_api.$("#div_video_remote").width(i),a>0&&webphone_api.$(".previewvideo").height(a)))}catch(r){webphone_api.common.PutToDebugLogException(2,"plhandler: SetVideoSize",r)}}function j(){try{Jn("GetAvailableCallfunc");var e="conference,transfer,mute,hold,chat";return webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC?e="transfer,chat":webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH&&(e="transfer,chat"),e}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: GetAvailableCallfunc",n)}return""}function $(e){try{if(Jn("Forward"),!1===webphone_api.common.Glt())return;var n=webphone_api.global.aline;if((webphone_api.common.isNull(n)||-3===n)&&(n=-1),webphone_api.common.PutToDebugLog(2,"EVENT, USER, forward (API_Forward), "+e+" on line: "+n.toString()),webphone_api.common.isNull(e))return webphone_api.common.PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_msg_4")),!1;if(e=webphone_api.common.Trim(e),!0===webphone_api.common.GetParameterBool("isfirstcallfwd",!0)&&(webphone_api.common.SaveParameter("isfirstcallfwd","false"),(!0===webphone_api.global.usestorage||webphone_api.common.Strl(60))&&webphone_api.common.ShowToast("Call forward will work only if the remote peer has support for it.",6e3)),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.webrtcapi.Forward(e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_Forward",null,webphone_api.common.GetLineForJavaAPI(),e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.Forward(webphone_api.common.GetLineForJavaAPI(),e)}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: Forward",t)}return!1}function q(){webphone_api.common.isNull(xt)||clearInterval(xt),xt=null,At=0}function z(e,n){try{if(Jn("Conference"),!1===webphone_api.common.Glcf())return!1;if(webphone_api.common.isNull(e)&&(e=""),e.length>0&&(webphone_api.global.lastcontarget=e),!webphone_api.global.checkIfInCall&&e.length>0)return x(e);var t=webphone_api.common.GetParameterInt("conferencetype",1);if(0===t)return webphone_api.common.PutToDebugLog(1,"ERROR, conference is disabled"),!1;if(webphone_api.common.PutToDebugLog(2,"EVENT, USER, conference (API_Conf) ("+webphone_api.global.useengine+"), "+e),webphone_api.common.isNull(e))return webphone_api.common.PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_msg_4")),!1;if(webphone_api.common.isNull(n)&&(n=!0,webphone_api.common.PutToDebugLog(2,"EVENT, plhandler Conference add is NULL, used as true")),e=webphone_api.common.Trim(e),!0===webphone_api.global.active_incoming_call&&(webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Accept Conf"),webphone_api.accept()),!0===n&&webphone_api.common.GetParameterInt("multilinegui",0)<1){if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.global.isconfcall=!0,webphone_api.common.WinAPI("API_Conf",null,e),!1;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return webphone_api.global.isconfcall=!0,webphone_api.webphone.Conference(e)}else{if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.global.isconfcall=!0,webphone_api.common.WinAPI("API_ConfEx",null,webphone_api.common.GetLineForJavaAPI(),e,n);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return webphone_api.global.isconfcall=!0,webphone_api.webphone.ConferenceEx(webphone_api.common.GetLineForJavaAPI(),e,n)}var o=webphone_api.common.GetSipHeaderInternal("X-UT",!0);if(webphone_api.common.isNull(o)&&(o=""),o=webphone_api.common.Trim(o),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(webphone_api.common.isNull(e)||e.length<1)&&(e=webphone_api.common.CanAcceptEmptyNumber()),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&e.length>0){var i=!1,a=!1;if(2!=t&&4!=t&&("g"===o||"s"===o||"b"===o||webphone_api.common.IsMizuServerOrGateway())){for(var r=!0,l=0;l="0"&&e.charAt(l)<="9"||e.charAt(l)>="A"&&e.charAt(l)<="D"||"*"==e.charAt(l)||"#"==e.charAt(l))){r=!1;break}if(n&&(1===t||t>=5)){a=!0,!r||"g"!==o&&"b"!==o||(webphone_api.global.confcanfailover=!0);var s=webphone_api.common.CreateConferenceRoom(!1,e);webphone_api.common.isNull(s)||s.length<3?webphone_api.common.PutToDebugLog(2,"WARNING, plhandler Conference webrtc invalid URL: "+s):(webphone_api.common.UriParser(s,"","","","","getconferenceroom"),webphone_api.common.PutToDebugLog(1,"EVENT,conference created"),webphone_api.common.isNull(webphone_api.global.waiting_conf_numbers)&&(webphone_api.global.waiting_conf_numbers=""),webphone_api.global.waiting_conf_numbers.length>0&&(webphone_api.global.waiting_conf_numbers=webphone_api.global.waiting_conf_numbers+","),webphone_api.global.waiting_conf_numbers=webphone_api.global.waiting_conf_numbers+e,i=!0)}if(!i&&t<5&&("g"===o||"s"===o||"b"===o)&&r&&(!0===n?!1===webphone_api.global.checkIfInCall||(webphone_api.common.PutToDebugLog(2,"EVENT, Add to DTMF conference: "+e),webphone_api.dtmf("*1*"+e+"#")):webphone_api.dtmf("*6*"+e+"#"),i=!0),!i&&!a&&n){!r||"g"!==o&&"b"!==o||(webphone_api.global.confcanfailover=!0);var s=webphone_api.common.CreateConferenceRoom(!1,e);webphone_api.common.isNull(s)||s.length<3?webphone_api.common.PutToDebugLog(2,"WARNING, plhandler Conference webrtc invalid URL: "+s):(webphone_api.common.UriParser(s,"","","","","getconferenceroom"),webphone_api.common.PutToDebugLog(1,"EVENT,conference created"),webphone_api.common.isNull(webphone_api.global.waiting_conf_numbers)&&(webphone_api.global.waiting_conf_numbers=""),webphone_api.global.waiting_conf_numbers.length>0&&(webphone_api.global.waiting_conf_numbers=webphone_api.global.waiting_conf_numbers+","),webphone_api.global.waiting_conf_numbers=webphone_api.global.waiting_conf_numbers+e,i=!0)}}if(!i&&n&&e.length>0&&!0===webphone_api.common.CanIUseApplet()&&(r&&(webphone_api.global.confcanfailover=!1),webphone_api.common.SwitchToEngine(webphone_api.global.ENGINE_JAVA),i=!0),!i&&n&&!0===webphone_api.common.CanIUseService()&&(r&&(webphone_api.global.confcanfailover=!1),webphone_api.common.IsServiceInstalled(function(n){try{i=!0,!0===n?(webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Hangup because Conference engine switch to NS(1)"),V(null,!0),!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api.common.PutToDebugLog(4,"EVENT, Close call page because Conference engine switch to NS(1)"),webphone_api._call.CloseCall()),webphone_api.common.SwitchToEngine(webphone_api.global.ENGINE_SERVICE),webphone_api.common.PutToDebugLog(1,"EVENT, "+webphone_api.stringres.get("switch_conf")),webphone_api.common.ShowToast(webphone_api.stringres.get("switch_conf")),setTimeout(function(){if(!webphone_api.common.isNull(xt))return q(),!0;var n=!1,t=0;xt=setInterval(function(){return++At>50?(q(),!0):(t<1&&!1===n&&!0===webphone_api.isregistered()&&(t=webphone_api.common.GetTickCount()),t>0&&webphone_api.common.GetTickCount()-t>1e3&&!1===n&&(n=!0,webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Call Conf switch: "+webphone_api.global.currcallnumber),webphone_api.call(webphone_api.global.currcallnumber)),!0===webphone_api.global.checkIfInCall?(webphone_api.global.isconfcall=!0, webphone_api.common.WinAPI("API_Conf",null,e),q(),!0):void 0)},500)},4e3)):(webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Hangup because Conference engine switch to NS(2)"),V(null,!0),!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api.common.PutToDebugLog(4,"EVENT, Close call page because Conference engine switch to NS(2)"),webphone_api._call.CloseCall()),setTimeout(function(){webphone_api.common.AlertDialog(webphone_api.stringres.get("switch_conf_title"),webphone_api.stringres.get("switch_confmessage"),function(e){if(!0===e){var n=webphone_api.common.GetNPLocation();!webphone_api.common.isNull(n)&&n.length>0&&window.open(n),setTimeout(function(){return webphone_api.common.SwitchToEngine(webphone_api.global.ENGINE_SERVICE),!0},1e3)}},webphone_api.stringres.get("btn_ok"))},500))}catch(t){i=!1,webphone_api.common.PutToDebugLogException(2,"plhandler: Conference InnerService",t)}},!0)),!i&&!a&&n&&("g"===o||"s"===o||"b"===o||webphone_api.common.IsMizuServerOrGateway())){r&&(webphone_api.global.confcanfailover=!1);var s=webphone_api.common.CreateConferenceRoom(!1,e);webphone_api.common.isNull(s)||s.length<3?webphone_api.common.PutToDebugLog(2,"WARNING, plhandler Conference webrtc invalid URL: "+s):(webphone_api.common.UriParser(s,"","","","","getconferenceroom"),webphone_api.common.PutToDebugLog(1,"EVENT,conference created"),webphone_api.common.isNull(webphone_api.global.waiting_conf_numbers)&&(webphone_api.global.waiting_conf_numbers=""),webphone_api.global.waiting_conf_numbers.length>0&&(webphone_api.global.waiting_conf_numbers=webphone_api.global.waiting_conf_numbers+","),webphone_api.global.waiting_conf_numbers=webphone_api.global.waiting_conf_numbers+e,i=!0)}return i||(r&&(webphone_api.global.confcanfailover=!1),n?e.length>0?webphone_api.common.PutToDebugLog(1,"ERROR, Conference not available in this environment"):webphone_api.common.PutToDebugLog(1,"ERROR, No target number for conference"):webphone_api.common.PutToDebugLog(1,"EVENT, conference stop skipped")),i}}catch(p){webphone_api.common.PutToDebugLogException(2,"plhandler: Conference",p)}return!1}function K(e){var n=0;try{if(n=1,Jn("Transfer"),!1===webphone_api.common.Glt())return!1;var t=webphone_api.global.aline;webphone_api.global.attendedtransfer_origline>0&&(t=webphone_api.global.attendedtransfer_origline),(webphone_api.common.isNull(t)||-3===t)&&(t=2),n=2,e=webphone_api.common.isNull(e)?"":webphone_api.common.Trim(e),webphone_api.common.PutToDebugLog(2,"EVENT, USER, transfer (API_Transfer) to "+e+" on line: "+t.toString()+" ("+webphone_api.global.aline.toString()+"/"+webphone_api.global.attendedtransfer_origline.toString()+")"),webphone_api.global.attendedtransfer_origline=-1,webphone_api.common.CanLog(5)&&webphone_api.common.LogLines();var o=webphone_api.common.getuseengine();if(n=3,e.length<1&&(o===webphone_api.global.ENGINE_WEBRTC||o===webphone_api.global.ENGINE_FLASH)){n=4;var i=t;i<1&&(i=webphone_api.common.GetBestLine());var a=webphone_api.common.GetEndpoint(2219,i,"","","",!1),r=-1;if(!webphone_api.common.isNull(a)&&i>0){n=5;for(var l,s=webphone_api.global.ep.length-1;s>=0;s--)if(l=webphone_api.global.ep[s],!(webphone_api.common.isNull(l)||l.length<5)&&a!==l&&a[webphone_api.common.EP_LINE]!=l[webphone_api.common.EP_LINE]&&!(webphone_api.common.isNull(l[webphone_api.common.EP_DESTNR])||l[webphone_api.common.EP_DESTNR].length<1)&&l[webphone_api.common.EP_DESTNR]!=a[webphone_api.common.EP_DESTNR]&&webphone_api.common.EpIsInCallEx(l)){e=l[webphone_api.common.EP_DESTNR],r=s;break}}if(n=6,webphone_api.common.isNull(e)||e.length<1)return webphone_api.common.PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_msg_4")),!1;webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, transfer target guessed as "+e+" on ep "+webphone_api.common.EpToString(r))}if(n=7,o===webphone_api.global.ENGINE_WEBRTC||o===webphone_api.global.ENGINE_FLASH){n=71;var i=t;i<1&&(i=webphone_api.common.GetBestLine());var a=webphone_api.common.GetEndpoint(2219,i,"","","",!1);if(a&&a[webphone_api.common.EP_DESTNR]==e){n=72;for(var l,s=webphone_api.global.ep.length-1;s>=0;s--)if(l=webphone_api.global.ep[s],!(webphone_api.common.isNull(l)||l.length<5)&&l[webphone_api.common.EP_DESTNR]!=e&&webphone_api.common.EpIsInCallEx(l)){var p=webphone_api.common.StrToIntDef(l[webphone_api.common.EP_LINE],0);if(!(p<1)){webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, transfer change source (current line) from "+t.toString()+" to "+p.toString()+"/"+l[webphone_api.common.EP_DESTNR]),t=p,webphone_api.global.aline=p;break}}}}if(webphone_api.global.last_transfer_tick=webphone_api.common.GetTickCount(),o===webphone_api.global.ENGINE_WEBRTC)return n=8,webphone_api.webrtcapi.SipTransferEx(e,t);if(o===webphone_api.global.ENGINE_FLASH)return n=9,webphone_api.flashapi.Transfer(e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||o===webphone_api.global.ENGINE_SERVICE)return n=10,webphone_api.common.WinAPI("API_Transfer",null,webphone_api.common.GetLineForJavaAPI(),e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return n=11,webphone_api.webphone.Transfer(webphone_api.common.GetLineForJavaAPI(),e)}catch(c){webphone_api.common.PutToDebugLogException(2,"plhandler: Transfer ("+n.toString()+")",c)}return!1}function X(e){try{Jn("Dtmf");var n=webphone_api.global.aline;if((webphone_api.common.isNull(n)||-3===n)&&(n=-1),webphone_api.common.PutToDebugLog(2,"EVENT, USER, dtmf (API_Dtmf), "+e+" on line: "+n.toString()),webphone_api.common.isNull(e))return webphone_api.common.PutToDebugLog(1,"ERROR,"+webphone_api.stringres.get("err_msg_4")),!1;if(e=webphone_api.common.Trim(e),webphone_api.common.PlayDtmfSound(e),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.common.PutToDebugLog(1,"EVENT,Send DTMF "+e),webphone_api.webrtcapi.SipSendDTMF(e);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(1,"EVENT,Send DTMF "+e),webphone_api.flashapi.SendDTMF(e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_Dtmf",null,webphone_api.common.GetLineForJavaAPI(),e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.Dtmf(n,e)}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: Dtmf",t)}return!1}function J(e,n,t){try{Jn("MuteEx");var o=[];o.push("h"),o.push("a"),o.push("s"),o.push("m"),o.push("u"),o.push("t"),o.push("e");var i=o.join("");if(!1===webphone_api.common.GetParameterBool(i,!0)){var a="N";return a+="o",a+=" ",webphone_api.common.PutToDebugLog(2,"WARNING, "+a+i),!1}var r=webphone_api.global.aline;(webphone_api.common.isNull(r)||-3===r)&&(r=-1);var l=webphone_api.common.ParamAsBool(e),s=webphone_api.common.GetParameterInt("muteholdalllines",0);!0===webphone_api.global.isconfcall&&s>1&&(r=-2,webphone_api.common.SetALineInternal(-2,10),webphone_api.global.lastalineset=-2,webphone_api.global.lastalinesettick=webphone_api.common.GetTickCount()),webphone_api.common.isNull(t)&&(t=!1);var p="USER";if(!0!==t&&"true"!==t||(p="INTERNAL"),(webphone_api.common.isNull(n)||n.length<1)&&(n=webphone_api.common.GetParameterInt("defmute",2)),n=webphone_api.common.StrToIntDef(n,0),-1==n&&(n=0),5===n)return webphone_api.common.PutToDebugLog(2,"WARNING, "+p+", mute (API_MutEx), "+l+", "+n+" on line: "+r.toString()+" Mute is disabled!"),!1;if(3!==n&&4!==n||(n=0),l?webphone_api.common.PutToDebugLog(1,"STATUS,"+r.toString()+","+webphone_api.stringres.get("muted")):webphone_api.common.PutToDebugLog(1,"STATUS,"+r.toString()+","+webphone_api.stringres.get("unmuted")),webphone_api.common.PutToDebugLog(2,"EVENT, "+p+", API_MutEx, "+l+", "+n+" on line: "+r.toString()),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return!!webphone_api.webrtcapi.SipToggleMute(l,n)&&(webphone_api.common.SetMuteState(r,l),!0);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_MuteEx",null,webphone_api.common.GetLineForJavaAPI(),l,n),webphone_api.common.SetMuteState(r,l),!0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return!!webphone_api.webphone.MuteEx(webphone_api.common.GetLineForJavaAPI(),l,n)&&(webphone_api.common.SetMuteState(r,l),!0)}catch(c){webphone_api.common.PutToDebugLogException(2,"plhandler: MuteEx",c)}return!1}function Y(){try{Jn("IsMuted");var e=webphone_api.global.aline;return(webphone_api.common.isNull(e)||-3===e)&&(e=-1),webphone_api.common.PutToDebugLog(2,"EVENT, USER, ismuted (API_IsMuted) on line: "+e.toString()),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA?webphone_api.webphone.IsMuted(e):webphone_api.common.GetMuteState(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: IsMuted",n)}return!1}function Q(e,n,t){try{Jn("Hold");var o=[];o.push("h"),o.push("a"),o.push("s"),o.push("h"),o.push("o"),o.push("l"),o.push("d");var i=o.join("");if(!1===webphone_api.common.GetParameterBool(i,!0)){var a="N";return a+="o",a+=" ",webphone_api.common.PutToDebugLog(2,"WARNING, "+a+i),webphone_api.global.wasmuteinsteadhold=3,!1}var r=-10;r=!webphone_api.common.isNull(n)&&webphone_api.common.IsNumber(n)?webphone_api.common.StrToInt(n):webphone_api.global.aline,(webphone_api.common.isNull(r)||-3===r)&&(r=-1);var l=webphone_api.common.ParamAsBool(e);webphone_api.common.isNull(t)&&(t=!1),webphone_api.common.PutToDebugLog(5,"EVENT, toggle hold api. hold: "+l.toString()+", line: "+r.toString()+", from: "+t.toString());var s=webphone_api.common.GetParameterInt("muteholdalllines",0);!0===webphone_api.global.isconfcall&&s>1&&(r=-2,webphone_api.common.SetALineInternal(-2,11),webphone_api.global.lastalineset=-2,webphone_api.global.lastalinesettick=webphone_api.common.GetTickCount());var p=webphone_api.common.ParamAsInt(webphone_api.common.GetParameter2("fasthold"),-1);if(1===p)return webphone_api.global.wasmuteinsteadhold=2,webphone_api.global.wasmultilineoop=1,webphone_api.common.PutToDebugLog(2,"EVENT, fasthold: "+l),J(l,0,!0);if(-1===p&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&"Firefox"===webphone_api.common.GetBrowser())return webphone_api.common.PutToDebugLog(2,"EVENT, fasthold firefox: "+l),webphone_api.global.wasmuteinsteadhold=2,webphone_api.global.wasmultilineoop=1,J(l,0,!0);var c=webphone_api.common.GetHoldState(r),u="USER";if(!0!==t&&"true"!==t||(u="INTERNAL"),webphone_api.common.PutToDebugLog(2,"EVENT, "+u+", hold (API_Hold), "+l+" on line: "+r.toString()+" holdstate: "+c.toString()),!webphone_api.common.CheckStrictLine(r))return!1;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){if(l===c&&webphone_api.common.GetParameterInt("ignoreprevholdstate",0)<1)return webphone_api.global.wasmultilineoop>0&&!l&&webphone_api.common.GetMuteState(r)?(webphone_api.global.wasmuteinsteadhold=2,webphone_api.common.PutToDebugLog(2,"EVENT, unmute instead of unhold on multilineoop"),J(!1,0,!0)):(webphone_api.global.wasmuteinsteadhold=3,!0===l?webphone_api.common.PutToDebugLog(2,"WARNING, hold (API_Hold), skip putting call on hold, because it is already on hold"):webphone_api.common.PutToDebugLog(2,"WARNING, hold (API_Hold), skip reloading call , because it is not on hold"),!1);var g=webphone_api.common.GetParameterInt("holdtype",-1);if(-2===g||0===g)return webphone_api.global.wasmuteinsteadhold=3,webphone_api.common.PutToDebugLog(2,"EVENT, API_Hold ignored because holdtype is: "+g.toString()),!1;var h=webphone_api.common.GetParameterInt("multilineoop",2);l&&(-1==h||webphone_api.common.GetNrOfActiveCalls()>1&&(h<2||h<3&&"Firefox"===webphone_api.common.GetBrowser()))&&(webphone_api.global.usemutemutiline=!0);var m=!1;if((-1==h||webphone_api.common.GetNrOfActiveCalls()>1&&h<1)&&(m=!0),!l&&m&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){var d=webphone_api.common.GetCallSession(51,!1,r,"");!webphone_api.common.isNull(d)&&d.getHolded()>0&&(m=!1)}if(m){webphone_api.common.PutToDebugLog(2,"EVENT, API_Hold mute instead because multiline call ("+webphone_api.common.GetNrOfActiveCalls()+")"),webphone_api.global.wasmuteinsteadhold=2,webphone_api.global.wasmultilineoop=1;return J(l,webphone_api.common.GetParameterInt("defmute",0),!0)}return webphone_api.global.wasmuteinsteadhold=1,Z(l,r,30)?(webphone_api.common.SetHoldState(r,l),!0):(webphone_api.global.wasmuteinsteadhold=4,!1)}if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.global.wasmuteinsteadhold=1,webphone_api.common.WinAPI("API_Hold",null,webphone_api.common.GetLineForJavaAPI(),l),webphone_api.common.SetHoldState(r,l),!0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.global.wasmuteinsteadhold=1,webphone_api.webphone.Hold(webphone_api.common.GetLineForJavaAPI(),l)?(webphone_api.common.SetHoldState(r,l),!0):(webphone_api.global.wasmuteinsteadhold=4,!1)}catch(b){webphone_api.common.PutToDebugLogException(2,"plhandler: Hold",b)}return webphone_api.global.wasmuteinsteadhold<1&&(webphone_api.global.wasmuteinsteadhold=4),!1}function Z(e,n,t){function o(){webphone_api.common.isNull(Ut)||(clearInterval(Ut),Ut=null)}var i=!1;try{webphone_api.common.isNull(e)&&(e=!0),webphone_api.common.isNull(n)&&(n=-1),webphone_api.common.isNull(t)&&(t=50),webphone_api.common.PutToDebugLog(5,"EVENT, toggle hold delayed. hold: "+e.toString()+", line: "+n.toString()+", from: "+t.toString());var a=webphone_api.common.GetTickCount();if(kt>0&&a-kt<1e3||!webphone_api.common.isNull(Wt)&&Wt.length>0){webphone_api.common.isNull(Vt)&&(Vt=[]),webphone_api.common.isNull(Wt)&&(Wt=[]),Wt.length>15&&(Vt=[],Wt=[],webphone_api.common.PutToDebugLog(5,"WARNING, too many hold operation queued"));for(var r=Wt.length-1;r>=0;r--)if(Wt[r]==n&&Vt[r]==e)return webphone_api.common.PutToDebugLog(5,"EVENT, hold operation already queued: "+n.toString()+"; state: "+e.toString()),!0;Vt.push(e),Wt.push(n),o(),Ut=setInterval(function(){if(webphone_api.common.isNull(Vt)&&(Vt=[]),webphone_api.common.isNull(Wt)&&(Wt=[]),Vt.length<1)o();else if(webphone_api.common.GetTickCount()-kt>950){kt=webphone_api.common.GetTickCount();var e=Vt.shift(),n=Wt.shift();webphone_api.common.PutToDebugLog(2,"EVENT, execute API_Hold delayed on line: "+n.toString()+"; state: "+e.toString()),webphone_api.webrtcapi.SipToggleHoldResume(e,n,t),Vt.length<1&&o()}},100),i=!0}else webphone_api.common.isNull(Ut)||(clearInterval(Ut),Ut=null),i=webphone_api.webrtcapi.SipToggleHoldResume(e,n,t);kt=a}catch(l){webphone_api.common.PutToDebugLogException(2,"plhandler: HoldDelayedWebrtc",l)}return i}function ee(){try{Jn("IsOnHold");var e=webphone_api.global.aline;(webphone_api.common.isNull(e)||-3===e)&&(e=-1),webphone_api.common.PutToDebugLog(2,"EVENT, USER, isonhold (API_IsOnHold) on line: "+e.toString());return webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA?webphone_api.webphone.IsOnHold(e):webphone_api.common.GetHoldState(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: IsOnHold",n)}return!1}function ne(e,n,t,o){try{if(Jn("SendChat"),!webphone_api.common.isNull(e)&&e.indexOf(",")>0){webphone_api.common.isNull(t)&&(t="");var i=e.split(","),a=t.split("|");if(webphone_api.common.isNull(t)||t.length<1||webphone_api.common.isNull(a)||a.length0&&(t+="|"),t+=webphone_api.common.Trim(i[r]))}for(var r=0;r2?((webphone_api.common.isNull(t)||t.length<1)&&(t=webphone_api.common.GetSipusername(!0)),webphone_api.common.UriParser(o,"",t,e,n,"sendsms")):ne(e,n,"",!0)}catch(i){webphone_api.common.PutToDebugLogException(2,"plhandler: SendSms",i)}return!1}function ie(e,n){try{if(Jn("Voicerecord"),!1===webphone_api.common.Glcr())return;if(webphone_api.global.phonestarted<2)return void Yn("Voicerecord",[e,n]);if(webphone_api.common.isNull(n)&&(n=""),!1===e&&(n="null"),!0===e&&(n.length<1||"null"===n||"NULL"===n))return void webphone_api.common.PutToDebugLog(2,"WARNING, voicerecord (API_Voicerecord) skipped start with no url, "+e+", "+n);webphone_api.common.PutToDebugLog(2,"EVENT, voicerecord (API_Voicerecord), "+e+", "+n);var t=!1;if((!1===e||webphone_api.common.isNull(n)||n.length<1||"null"===n||"NULL"===n)&&(n="null",t=!0),webphone_api.common.SaveParameter("voicerecupload",n),webphone_api.common.isNull(webphone_api.parameters.voicerecupload)||(webphone_api.parameters.voicerecupload=n),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.common.IsMizuServerOrGateway()||webphone_api.common.PutToDebugLog(3,"WARNING, voicerecord (API_Voicerecord), unknown WebRTC server. Voice recording should be implemented on your server instead. See the How to activate voice recording FAQ point in the documentation"),void webphone_api.common.CallWsuserKeepAlive(!0);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void(!1===t?webphone_api.common.WinAPI("API_VoiceRecord",null,4,2,n,webphone_api.common.GetLineForJavaAPI()):webphone_api.common.WinAPI("API_VoiceRecord",null,0,2,n,webphone_api.common.GetLineForJavaAPI()));if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return void(!1===t?webphone_api.webphone.VoiceRecord(4,2,n,webphone_api.common.GetLineForJavaAPI()):webphone_api.webphone.VoiceRecord(0,2,n,webphone_api.common.GetLineForJavaAPI()))}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: Voicerecord",o)}}function ae(){try{if("undefined"!=typeof webphone_api.notifications&&null!==webphone_api.notifications)return webphone_api.notifications.GetStatus();console&&console.log&&console.log("ERROR, plhandler GetStatus webphone_api.notifications is not defined")}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: GetStatus",e)}return""}function re(e,n){try{if(Jn("GetRegFailReason"),!e||"function"!=typeof e)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetRegFailReason callback is not definaed");var t=!0;if((webphone_api.common.isNull(n)||"true"!=n&&"false"!=n||"false"==n||0==n)&&(t=!1),webphone_api.global.phonestarted<2)return void Yn("GetRegFailReason",[e,n]);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void e(webphone_api.webrtcapi.GetRegFailReason());if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"ERROR, GetRegFailReason is not supported by flash engine"),void e("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetRegFailReason",function(n){e(n)},t);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return webphone_api.webphone.GetRegFailReason(e,t)}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: GetRegFailReason",o)}return""}function le(){try{if(Jn("DevicePopup"),webphone_api.common.isNull(Mt)||clearTimeout(Mt),Mt=null,webphone_api.global.phonestarted<1&&(webphone_api.global.phonestarted=1,n(webphone_api.parameters)),webphone_api.global.phonestarted<2)return void(Mt=setTimeout(function(){le()},250));if(webphone_api.common.PutToDebugLog(2,"EVENT, USER, devicepopup (API_DevicePopup)"),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return webphone_api.webphone.AudioDevice();webphone_api.common.AudioDevicePopup()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: DevicePopup",e)}return!1}function se(e,n){try{if(Jn("SetVolume"),webphone_api.common.isNull(e)||e.length<1||webphone_api.common.isNull(n)||n.length<1||!webphone_api.common.IsNumber(e)||!webphone_api.common.IsNumber(n))return webphone_api.common.PutToDebugLog(3,"ERROR, wphone: setvolume device or volume is NULL"),!1;if(webphone_api.global.phonestarted<2)return void Yn("SetVolume",[e,n]);webphone_api.common.PutToDebugLog(2,"EVENT, plhandler setvolume engine: "+webphone_api.common.getuseengine()+" / "+webphone_api.common.GetParameter("devicetype")+"; dev: "+e+"; volume: "+n);var t=webphone_api.common.StrToInt(e),o=webphone_api.common.StrToInt(n);if(t<0||t>2)return webphone_api.common.PutToDebugLog(3,"ERROR, wphone: setvolume invalid device"),!1;if(o<0||o>100)return webphone_api.common.PutToDebugLog(3,"ERROR, wphone: setvolume invalid valume value"),!1;if(webphone_api.common.PutToDebugLog(2,"EVENT, USER, API_SetVolume, "+e+", "+n),0==e?webphone_api.common.SaveParameter("volumein",n):webphone_api.common.SaveParameter("volumeout",n),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return void webphone_api.common.PutToDebugLog(2,"EVENT, setvolume is not supported by flash engine");if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void webphone_api.webrtcapi.SetVolume(e,n);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_SetVolume",null,e,n);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.SetVolume(e,n)}catch(i){webphone_api.common.PutToDebugLogException(2,"plhandler: SetVolume",i)}return!1}function pe(e,n){try{if(Jn("GetVolume"),!n||"function"!=typeof n)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetVolume callback is not defined");if(webphone_api.common.isNull(e)||e.length<1||!webphone_api.common.IsNumber(e))return webphone_api.common.PutToDebugLog(3,"ERROR, wphone: getvolume device is NULL"),n(-1),!1;var t=webphone_api.common.StrToInt(e);if(t<0||t>2)return webphone_api.common.PutToDebugLog(3,"ERROR, wphone: getvolume invalid device"),!1;if(webphone_api.global.phonestarted<2)return void Yn("GetVolume",[e,n]);if(webphone_api.common.PutToDebugLog(2,"EVENT, USER, getvolume (API_GetVolume), "+e),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return void webphone_api.common.PutToDebugLog(2,"EVENT, getvolume is not supported by flash engine");if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void n(webphone_api.webrtcapi.GetVolume(e));if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetVolume",function(e){var t=50;webphone_api.common.isNull(e)||e.length<1||!1===webphone_api.common.IsNumber(e)?webphone_api.common.PutToDebugLog(2,"ERROR, plhandler GetVolume invalid return value: "+e):t=webphone_api.common.StrToInt(e),webphone_api.common.PutToDebugLog(2,"plhandler: GetVolume NS returned: "+t.toString()),n(t)},e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void n(webphone_api.webphone.GetVolume(e))}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: GetVolume",o)}return!1}function ce(e){try{if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void(!0===e||"true"===e?webphone_api.common.SaveParameter("androidspeaker","0"):webphone_api.common.SaveParameter("androidspeaker","1"));webphone_api.common.PutToDebugLog(2,"WARNING, setloudspeaker not iplemented for this engine: "+webphone_api.common.getuseengine())}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: SetLoudspeaker",n)}return!1}function ue(e,n,t,o){try{if(Jn("PlaySound"),webphone_api.global.phonestarted<2)return void Yn("PlaySound",[e,n,t,o]);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.webrtcapi.PlaySound(e,n,t,o);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_PlaySound",null,e,n,t,!1,!1,o,webphone_api.common.GetLineForJavaAPI()),!0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.PlaySound(e,n,t,!1,!1,o,webphone_api.common.GetLineForJavaAPI());webphone_api.common.PutToDebugLog(2,"ERROR, plhandler API_PlaySuond is not supported by "+webphone_api.common.getuseengine()+" engine")}catch(i){webphone_api.common.PutToDebugLogException(2,"plhandler: PlaySound",i)}return!1}function ge(e,n,t,o,i,a,r,l){try{if(Jn("AddContact"),webphone_api.common.isNull(n)||webphone_api.common.Trim(n).length<1)return webphone_api.common.PutToDebugLog(3,"ERROR, plhandler AddContact invalid number: "+n),!1;n=webphone_api.common.Trim(n),webphone_api.common.isNull(e)&&(e=""),e=webphone_api.common.Trim(e);var s=webphone_api.common.GetParameterInt("normalize_contact",1);s>0&&n.indexOf("|")<0&&(n=webphone_api.common.NormalizeInput2(n,3)),s>0&&(e=webphone_api.common.NormalizeInput2(e,2)),webphone_api.common.isNull(t)&&(t=""),s>0&&(t=webphone_api.common.NormalizeInput2(t,3),t=webphone_api.common.Trim(t)),webphone_api.common.isNull(o)&&(o=""),s>0&&(o=webphone_api.common.NormalizeInput2(o,3),o=webphone_api.common.Trim(o)),webphone_api.common.isNull(i)&&(i=""),s>0&&(i=webphone_api.common.NormalizeInput2(i,3),i=webphone_api.common.Trim(i)),webphone_api.common.isNull(a)&&(a=""),s>0&&(a=webphone_api.common.NormalizeInput2(a,2),a=webphone_api.common.Trim(a));return webphone_api.common.PutToDebugLog(2,"EVENT, AddContact name: "+e+"; number: "+n+"; email: "+t+"; address: "+o+"; notes: "+i+"; website: "+a+"; isfromsync: 0"),he(e,n,l,r,webphone_api.common.GetTickCount(),t,o,i,a,"0"),!0}catch(p){webphone_api.common.PutToDebugLogException(2,"plhandler: AddContact",p)}return!1}function he(e,n,t,o,i,a,r,l,s,p){try{if(webphone_api.common.isNull(webphone_api.global.ctlist)&&(webphone_api.global.ctlist=[]),n=n.indexOf("|")>=0?n.split("|"):[n],o=webphone_api.common.isNull(o)||o.length<1?webphone_api.common.IsNumber(n)?["phone"]:["sip"]:o.indexOf("|")>=0?o.split("|"):[o],o.length==n.length);else if(o.length>n.length)o.splice(n.length);else for(var c=o.length;c0&&n.length>0)for(var t=0;t0)for(var t=0;t0)for(var t=0;t0)for(var o=0;o0)for(var o=0;o0&&(n+="\r\n");for(var i="",a=0;a0&&(i+="|"),i+=o[webphone_api.common.CT_NUMBER][a]);for(var r="",a=0;a0&&(r+="|"),r+=o[webphone_api.common.CT_PTYPE][a]);n+=o[webphone_api.common.CT_NAME]+"\t"+i+"\t"+o[webphone_api.common.CT_FAV]+"\t"+o[webphone_api.common.CT_EMAIL]+"\t"+o[webphone_api.common.CT_ADDRESS]+"\t"+o[webphone_api.common.CT_NOTES]+"\t"+o[webphone_api.common.CT_WEBSITE]+"\t"+r}}if(!webphone_api.common.isNull(n)&&n.length>0)return n}catch(l){webphone_api.common.PutToDebugLogException(2,"plhandler: BuildCtList",l)}return null}(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: ListContacts",n)}return null}function we(){try{Jn("ListCallhistory"),webphone_api.common.isNull(webphone_api.global.chlist)&&(webphone_api.global.chlist=[]),webphone_api.common.PutToDebugLog(4,"EVENT, plhandler listcallhistory called");for(var e="",n=0;n0&&(e+="\r\n");e+=t[webphone_api.common.CH_TYPE]+"\t"+t[webphone_api.common.CH_NAME]+"\t"+t[webphone_api.common.CH_NUMBER]+"\t"+t[webphone_api.common.CH_DATE]+"\t"+t[webphone_api.common.CH_DURATION]+"\t"+t[webphone_api.common.CH_REASON]}if(!webphone_api.common.isNull(e)&&e.length>0)return e}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: ListCallhistory",o)}return null}function ve(e,n){try{var t=n;if("password"!==e&&"sippassword"!==e||webphone_api.common.CanLog(5)||(t="*****"),webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLogSpecial(2,"EVENT, SetParameter user, "+e+": "+t,!1,""),Jn("SetParameter: "+e+": "+t),webphone_api.common.isNull(e)||e.length<1)return!1;if(e=e.toLowerCase(),webphone_api.common.isNull(n)&&(n="null"),n=webphone_api.common.Trim(n),0===n.indexOf("encrypted__")&&(n=webphone_api.common.StrDc(n)),e.indexOf("server")>=0){if("YOURSIPDOMAIN.COM"===n||"YOURSIPSERVER.COM"===n||"SIPSERVER"===n||"VOIPSERVER"===n||"SERVERADDRESS"===n||"yoursipdomain.com"===n||"SERVER_ADDRESS"===n||"serveraddress"===n||"YOURSIPDOMAIN"===n)return!1}else if(e.indexOf("username")>=0){if("USERNAME"===n||"SIPUSERNAME"===n)return!1}else if(e.indexOf("password")>=0){if("PASSWORD"===n||"SIPPASSWORD"===n||"SIPASSWORD"===n)return!1}else if(e.indexOf("callto")>=0&&("DESTINATION"===n||"CALLTO"===n))return!1;"webrtcserver"!==e&&"webrtcaddress"!==e&&"rtcserver"!==e&&"rtcaddress"!==e||(e="webrtcserveraddress");try{window.location.href.indexOf("isdemopage=true")>0&&!webphone_api.common.isNull(n)&&n.toString().length>0&&("sipusername"===e||"username"===e||"password"===e||"sippassword"===e||"serveraddress_user"===e||"serveraddress_orig"===e||"serveraddress"===e||"upperserver"===e||"callto"===e||"destination"===e)&&webphone_api.SetCookie("wpdemosett_"+e,n,365)}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: SetParameter inner",a)}t=n,"password"!==e&&"sippassword"!==e||webphone_api.common.CanLog(5)||(t="*****"),webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLogSpecial(2,"EVENT, SetParameter "+e+": "+t,!1,""),"serveraddress"===e&&n.length>0?webphone_api.common.SaveParameter("serveraddress_user",n):"theme"===e&&n.length>0?webphone_api.common.SaveParameter("colortheme",n):"colortheme"===e&&n.length>0&&webphone_api.common.SaveParameter("theme",n),webphone_api.common.SaveParameter(e,n),webphone_api.common.isNull(webphone_api.parameters)||webphone_api.common.isNull(webphone_api.parameters[e])||(webphone_api.parameters[e]=n),"loglevel"==e&&(webphone_api.global.loglevel=webphone_api.common.StrToIntDef(n,webphone_api.global.loglevel));var o=webphone_api.common.GetParameter("devicetype");if(o===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_SetParameter",null,e,n);if(o===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.SetParameter(e,n)}catch(r){var i=e;i=webphone_api.common.isNull(i)?"":": "+i,webphone_api.common.PutToDebugLogException(2,"plhandler: SetParameter"+i,r)}return!1}function Ee(e){try{if(webphone_api.common.isNull(e)||e.length<1)return null;e=e.toLowerCase();var n=webphone_api.common.GetParameter(e);try{if(window.location.href.indexOf("isdemopage=true")>0&&("sipusername"===e||"username"===e||"password"===e||"sippassword"===e||"serveraddress_user"===e||"serveraddress_orig"===e||"serveraddress"===e||"upperserver"===e||"callto"===e||"destination"===e)){var t=webphone_api.GetCookie("wpdemosett_"+e);if(!webphone_api.common.isNull(t)&&t.length>0&&(webphone_api.common.isNull(n)||n.length<1))return t}}catch(o){webphone_api.common.PutToDebugLogException(2,"plhandler: GetParameter inner",o)}return n}catch(i){webphone_api.common.PutToDebugLogException(2,"plhandler: GetParameter",i)}return null}function Pe(e,n,t){try{if(Jn("SetLine"),webphone_api.common.isNull(e)||e.toString().length<1)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: SetLine invalid line (A)");webphone_api.common.PutToDebugLog(2,"EVENT, USER, setline (API_SetLine), "+e.toString());var o=!1,i=-10;if(webphone_api.common.IsNumber(e)&&e.toString().length<3){var a=webphone_api.common.StrToInt(webphone_api.common.Trim(e));a<-2||a>99||(i=a)}if(e=e.toString(),i<-5){o=!0;for(var r=0;r1&&e===l&&(i=webphone_api.common.StrToInt(webphone_api.global.ep[r][webphone_api.common.EP_LINE]))}}if(i<-5)for(var r=0;r1&&e===s&&(i=webphone_api.common.StrToInt(webphone_api.global.ep[r][webphone_api.common.EP_LINE]))}if(0===webphone_api.common.IsMultiline())return void setTimeout(function(){var e=[];e.push("E"),e.push("R"),e.push("R"),e.push("O"),e.push("R"),e.push(","),e.push("M"),e.push("u"),e.push("l"),e.push("t"),e.push("i"),e.push("l"),e.push("i"),e.push("n"),e.push("e"),e.push(" "),e.push("f"),e.push("e"),e.push("a"),e.push("t"),e.push("u"),e.push("r"),e.push("e"),e.push(" "),e.push("i"),e.push("s"),e.push("d"),e.push("i"),e.push("s"),e.push("a"),e.push("b"),e.push("l"),e.push("e"),e.push("d");var n=e.join("");webphone_api.common.PutToDebugLog(1,n)},550);if(a>=-2&&a<=99){var p=i;-1===i&&(i=webphone_api.common.GetBestLine()),webphone_api.global.lastalineset=p,webphone_api.global.lastalinesettick=webphone_api.common.GetTickCount(),(webphone_api.common.isNull(n)||!0!==n)&&(webphone_api.global.lastalinesetreal=p,webphone_api.global.lastalinesetrealtick=webphone_api.common.GetTickCount())}if(webphone_api.common.isNull(t)&&(t=14),webphone_api.common.SetALineInternal(i,t),!1===Ht&&webphone_api.common.IsNumber(e)&&e>0&&(webphone_api.common.SaveParameter("multilinegui","1"),Ht=!0),webphone_api.common.RefreshInfo(8),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return void webphone_api.common.PutToDebugLog(2,"WARNING, SetLine method not available for engine: "+webphone_api.common.GetEngineDisplayName(webphone_api.global.useengine));if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return!0===o?webphone_api.common.WinAPI("API_SetLine",null,e):webphone_api.common.WinAPI("API_SetLine",null,i),void webphone_api.common.SaveParameter("line",i.toString());if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return!0===o?webphone_api.webphone.SetLineEx(e):webphone_api.webphone.SetLine(i),void webphone_api.common.SaveParameter("line",i.toString())}catch(c){webphone_api.common.PutToDebugLogException(2,"plhandler: SetLine",c)}return null}function Te(){var e=webphone_api.global.aline;try{if(Jn("GetLine"),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.common.PutToDebugLog(2,"EVENT, USER, getline (API_getLine) a "+e),e;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"WARNING, GetLine method not available for engine: "+webphone_api.common.GetEngineDisplayName(webphone_api.global.useengine)),webphone_api.common.PutToDebugLog(2,"EVENT, USER, getline (API_getLine) b "+e),e;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.PutToDebugLog(2,"EVENT, USER, getline (API_getLine) c "+e),e;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.common.SetALineInternal(webphone_api.webphone.GetLine(),15,!1),webphone_api.common.PutToDebugLog(2,"EVENT, USER, getline (API_getLine) d "+webphone_api.global.aline),webphone_api.global.aline;webphone_api.common.PutToDebugLog(2,"EVENT, USER, getline (API_getLine) e "+e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: GetLine",n)}return e}function Se(e,n){try{if(Jn("LineToCallID"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, linetocallid (API_LineToCallID)"),webphone_api.common.isNull(e)||!webphone_api.common.IsNumber(e))return void n("ERROR, linetocallid: Invalid line");if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void n(webphone_api.webrtcapi.LineToCallID(e));if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return void webphone_api.common.PutToDebugLog(2,"WARNING, LineToCallID method not available for engine: "+webphone_api.common.GetEngineDisplayName(webphone_api.global.useengine));if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_LineToCallID",function(e){n(e)},e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void n(webphone_api.webphone.LineToCallID(e))}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: LineToCallID",t)}}function Ne(e,n){try{if(Jn("CallIDToLine"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, callidtoline (API_CallIDToLine)"),webphone_api.common.isNull(e)||e.length<1)return void n("ERROR, CallIDToLine: Invalid callid");if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void n(webphone_api.webrtcapi.CallIDToLine(e));if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"WARNING, CallIDToLine method not available for engine: "+webphone_api.common.GetEngineDisplayName(webphone_api.global.useengine)),"";if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_CallIDToLine",function(e){n(e)},e);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void n(webphone_api.webphone.CallIDToLine(e))}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: CallIDToLine",t)}}function Ie(e){for(var n=1;n0){var o=t.split(",");if(!webphone_api.common.isNull(o)&&o.length>0){t="";for(var i=0;i0&&(t+=","),t+=o[i]}}return t}var a=n.toString(),r="Unused line",l="",s="",p="",c="-1",u=webphone_api.common.GetParameter("serveraddress_user"),g="",h="false",m="false",d="",b=webphone_api.common.GetTickCount(),_=webphone_api.global.lnstat[n];if(!webphone_api.common.isNull(_)&&_.length>1){var f=webphone_api.common.GetConfigInt("registerinterval",0);f<1&&(f=90),f*=6e4,!webphone_api.common.isNull(_[0])&&webphone_api.common.IsNumber(_[0])&&b-_[0]<=f&&!webphone_api.common.isNull(_[1]&&_[1].length)&&(r=_[1])}var w=webphone_api.common.GetEndpoint(1019,n,"","","",!1);!webphone_api.common.isNull(w)&&w.length>2&&(l=w[webphone_api.common.EP_CALLID],s=w[webphone_api.common.EP_DESTNR],p=webphone_api.common.GetSipusername(!0),c=w[webphone_api.common.EP_INCOMING],u=webphone_api.common.GetParameter("serveraddress_user"),g="",h=w[webphone_api.common.EP_MUTESTATE],m=w[webphone_api.common.EP_HOLDSTATE],d="");var v="LINEDETAILS,"+a+","+r+","+l+","+s+","+p+","+c+","+u+","+g+","+h+","+m+","+d;return webphone_api.common.PutToDebugLog(4,"EVENT, GetLineDetails user: "+v),v}catch(E){webphone_api.common.PutToDebugLogException(2,"plhandler: GetLineDetails",E)}return""}function Re(){try{Jn("GetLastCallDetails");var e=webphone_api.global.lastcalldetails;if(webphone_api.common.isNull(e)&&(e=""),e=webphone_api.common.Trim(e),webphone_api.global.phonestarted<2)return void Yn("GetLastCallDetails",[]);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return e;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return e;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return e;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.GetLastCallDetails()}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: GetLastCallDetails",n)}return""}function ye(e){try{if(Jn("GetIcomingDisplay"),!e||"function"!=typeof e)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetIncomingDisplay callback is not definaed");if(webphone_api.global.phonestarted<2)return void Yn("GetIncomingDisplay",[e]);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void e(webphone_api.common.GetWebrtcDisplayName());if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return void e("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetIncomingDisplay",function(n){webphone_api.common.isNull(n)&&(n=""),n=webphone_api.common.Trim(n),0===n.indexOf("_BASE64_")&&(n=webphone_api.common.B64Dec(n),webphone_api.common.isNull(n)&&(n=""),n=webphone_api.common.Trim(n)),e(n)},webphone_api.common.GetLineForJavaAPI());if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE()){var n=webphone_api.webphone.GetIncomingDisplay();return webphone_api.common.isNull(n)&&(n=""),n=webphone_api.common.Trim(n),0===n.indexOf("_BASE64_")&&(n=webphone_api.common.B64Dec(n),webphone_api.common.isNull(n)&&(n=""),n=webphone_api.common.Trim(n)),void e(n)}}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: GetIncomingDisplay",t)}return""}function De(){try{webphone_api.global.printwad_called=!1,webphone_api.common.PutToDebugLog(2,"EVENT, USER, API_Unregister"),webphone_api.global.authenticated_displayed=!1,webphone_api.global.sipstackstarted=!1,webphone_api.global.dispSaveSettMsg=0,webphone_api.global.unregisteredfromidle=0,webphone_api.global.pres_unreg_called=!0,webphone_api.global.last_presence_enabled=webphone_api.common.UsePresence2(),webphone_api.global.onregisteredcalled=!1;var e=webphone_api.global.dispregfailed;if(webphone_api.global.dispregfailed=2,setTimeout(function(){webphone_api.global.dispregfailed=e},500),!1===webphone_api.global.onunregistered_flag){webphone_api.global.onunregistered_flag=!0,setTimeout(function(){webphone_api.global.onunregistered_flag=!1},2e3);try{webphone_api.onRegStateChangeCb("unregistered",null)}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: There is an error in onUnRegistered(unregistered) callback",t)}try{webphone_api.onUnRegisteredCb()}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: There is an error in onUnRegistered() callback",t)}}var n=webphone_api.common.getuseengine();if((webphone_api.common.isNull(n)||n.length<1)&&(n=webphone_api.global.last_last_useengine),n===webphone_api.global.ENGINE_WEBRTC)return webphone_api.flagrestartwebrtc=!1,webphone_api.webrtcapi.SipUnRegister(),webphone_api.common.Wsunreg(),webphone_api.global.phonestarted>2&&(webphone_api.global.phonestarted=2),void(webphone_api.global.webrtcsipsignalingreceived=0);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||n===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_Unregister",null),void(webphone_api.global.phonestarted>2&&(webphone_api.global.phonestarted=2));if(n===webphone_api.global.ENGINE_FLASH)return webphone_api.flashapi.Logout(null),void(webphone_api.global.phonestarted>2&&(webphone_api.global.phonestarted=2));if(n===webphone_api.global.ENGINE_JAVA)return webphone_api.webphone.Unregister(),void(webphone_api.global.phonestarted>2&&(webphone_api.global.phonestarted=2))}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: Unregister",t)}}function Oe(e){try{return webphone_api.global.onregisteredcalled=!1,(webphone_api.global.sipstackstarted=!1,webphone_api.common.isNull(e)&&(e=webphone_api.common.getuseengine()),webphone_api.common.isNull(e)&&(e=webphone_api.common.GetSelectedEngineName()),e===webphone_api.global.ENGINE_WEBRTC)?(!0===webphone_api.global.checkIfInCall&&(webphone_api.common.PutToDebugLog(3,"EVENT, Window.OnUnload close or refresh: hangup active call_1: "+e),webphone_api.webrtcapi.SipHangup(!1,-2)),webphone_api.flagrestartwebrtc=!1,webphone_api.webrtcapi.SipStop(1),webphone_api.common.Wsunreg(),void(webphone_api.global.phonestarted=2)):e===webphone_api.global.ENGINE_FLASH?(!0===webphone_api.global.checkIfInCall&&(webphone_api.common.PutToDebugLog(3,"EVENT, Window.OnUnload close or refresh: hangup active call_2: "+e),webphone_api.flashapi.Hangup()),webphone_api.flashapi.Logout(null),void(webphone_api.global.phonestarted=2)):e===webphone_api.global.ENGINE_JAVA?(!0===webphone_api.global.checkIfInCall&&(webphone_api.common.PutToDebugLog(3,"EVENT, Window.OnUnload close or refresh: hangup active call_3: "+e),webphone_api.webphone.Hangup(-2)),webphone_api.webphone.Unregister(),void(webphone_api.global.phonestarted=2)):(!0===webphone_api.global.checkIfInCall||webphone_api.common.WinAPI("API_Unregister",null),void(webphone_api.global.phonestarted=2))}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: UnregisterEngine",n)}}function xe(){try{if(Jn("HTTPKeepAlive"),webphone_api.common.PutToDebugLog(5,"EVENT, httpkeepalive (API_HTTPKeepAlive)"),webphone_api.global.useengine!==webphone_api.global.ENGINE_JAVA)return;return webphone_api.webphone.HTTPKeepAlive()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: HTTPKeepAlive",e)}}function Ae(){Jn("IsRegistered");try{if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA){var e=webphone_api.webphone.IsRegistered();return webphone_api.common.PutToDebugLog(2,"EVENT, USER, API_IsRegistered: wp "+e.toString()),e}if(webphone_api.global.phonestarted>2)return webphone_api.common.PutToDebugLog(2,"EVENT, USER, API_IsRegistered: true"),!0;webphone_api.common.PutToDebugLog(2,"EVENT, USER, isregistered (API_IsRegistered)")}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: IsRegistered",n)}return!1}function ke(){Jn("IsInCall");try{webphone_api.common.PutToDebugLog(4,"EVENT, isincall: "+webphone_api.global.checkIfInCall.toString())}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: IsInCall",e)}return webphone_api.global.checkIfInCall}function Ue(e,n,t){var o=0;try{if(webphone_api.common.isNull(e)||e<-2)return void webphone_api.common.PutToDebugLog(2,"WARNING, plhandler: GetDeviceList dev is null "+e);if(!n||"function"!=typeof n)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetDeviceList callback is not defined");if(!0!==t){Jn("GetDeviceList");for(var i=!1,a=Bt.length-1;a>=0;a--)if(Bt[a]===e&&jt[a]===n){i=!0;break}i||(Bt.push(e),jt.push(n))}if(Bt.length<1&&(Bt.push(e),jt.push(n)),Bt.length<1)return void webphone_api.common.PutToDebugLog(2,"WARNING, plhandler: GetDeviceList no request is waiting a");if(jt.length<1)return void webphone_api.common.PutToDebugLog(2,"WARNING, plhandler: GetDeviceList no request is waiting b");if(!jt[0]||"function"!=typeof jt[0])return void webphone_api.common.PutToDebugLog(2,"WARNING, plhandler: GetDeviceList no request is waiting c");if(webphone_api.common.getuseengine().length<1&&webphone_api.global.phonestarted<2){webphone_api.common.isNull($t)||clearTimeout($t),$t=null;var r=Bt[0],l=jt[0];return void($t=setTimeout(function(){webphone_api.common.isNull(r)&&(r="-41"),Ue(r,l,!0)},300))}if(webphone_api.common.isNull($t)||clearTimeout($t),$t=null,webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetAudioDeviceList",function(e){try{if(o=1,webphone_api.common.isNull(e)&&(e=""),e=webphone_api.common.Trim(e),webphone_api.common.CanLog(7)&&webphone_api.common.PutToDebugLog(7,"PROCESSING_AUDIOLIST ("+e.length.toString()+") : "+e),Bt.length<1)null!=e&&e.length>0&&webphone_api.common.PutToDebugLog(3,"WARNING, audidevicelist unexpected answer: "+e);else{o=2;var n=jt.shift();o=3;var t=Bt.shift();if(o=4,0===e.indexOf("_BASE64_")&&(e=webphone_api.common.B64Dec(e),webphone_api.common.isNull(e)&&(e=""),e=webphone_api.common.Trim(e)),e=e.replace("EOFLINE","\r\n"),o=5,0==e.indexOf("ERROR")||0==e.indexOf("APIREQUEST")?webphone_api.common.PutToDebugLog(3,"WARNING, audidevicelist invaid answer: "+e+" (for "+t+")"):0==t?(o=6,webphone_api.global.audio_rec_device_list=e,webphone_api.common.SaveParameter("cache_audio_rec_device_list",e),o=7,n(e)):1==t?(o=8,webphone_api.global.audio_play_device_list=e,webphone_api.common.SaveParameter("cache_audio_play_device_list",e),webphone_api.global.audio_ring_device_list.length<1&&!webphone_api.common.isNull(e)&&e.length>0&&(!webphone_api.common.isNull(e)&&e.length>0&&e.indexOf("\r\nAll")<1&&(e+="\r\nAll"),webphone_api.global.audio_ring_device_list=e,webphone_api.common.SaveParameter("cache_audio_ring_device_list",e)),o=9,n(e)):2==t?(o=10,webphone_api.global.audio_play_device_list.length<1&&!webphone_api.common.isNull(e)&&e.length>0&&(webphone_api.global.audio_play_device_list=e,webphone_api.common.SaveParameter("cache_audio_play_device_list",e)),!webphone_api.common.isNull(e)&&e.length>0&&e.indexOf("\r\nAll")<1&&(e+="\r\nAll"),webphone_api.global.audio_ring_device_list=e,webphone_api.common.SaveParameter("cache_audio_ring_device_list",e),o=11,n(e)):3==t?(o=12,webphone_api.global.video_rec_device_list=e,webphone_api.common.SaveParameter("cache_video_rec_device_list",e),n(e)):webphone_api.common.PutToDebugLog(3,"WARNING, audidevicelist answer with unknow dev: "+e),o=13,!webphone_api.common.isNull(jt)&&jt.length>0){o=14;var i=Bt[0];o=15;var a=jt[0];o=16,setTimeout(function(){o=17,webphone_api.common.isNull(i)&&(i="-42"),Ue(i,a,!0)},8)}}}catch(r){webphone_api.common.PutToDebugLogException(2,"plhandler: GetDeviceListInner "+o,r)}},Bt[0]);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA){var s="",p=Bt.shift(),c=jt.shift();if(s=webphone_api.webphone.GetAudioDeviceList(p),webphone_api.common.isNull(s)&&(s=""),s=webphone_api.common.Trim(s),0===s.indexOf("_BASE64_")&&(s=webphone_api.common.B64Dec(s),webphone_api.common.isNull(s)&&(s=""),s=webphone_api.common.Trim(s)),0==s.indexOf("ERROR")||0==s.indexOf("APIREQUEST")?webphone_api.common.PutToDebugLog(3,"WARNING, audidevicelist invaid answer: "+s+" (for "+p+")"):0==p?(webphone_api.global.audio_rec_device_list=s,webphone_api.common.SaveParameter("cache_audio_rec_device_list",s)):1==p?(webphone_api.global.audio_play_device_list=s,webphone_api.common.SaveParameter("cache_audio_play_device_list",s)):2==p?(!webphone_api.common.isNull(s)&&s.length>0&&s.indexOf("\r\nAll")<1&&(s+="\r\nAll"),webphone_api.global.audio_ring_device_list=s,webphone_api.common.SaveParameter("cache_audio_ring_device_list",s)):(webphone_api.global.video_rec_device_list=s,webphone_api.common.SaveParameter("cache_video_rec_device_list",s)),c(s),!webphone_api.common.isNull(jt)&&jt.length>0){var r=Bt[0],l=jt[0];setTimeout(function(){webphone_api.common.isNull(r)&&(r="-43"),Ue(r,l,!0)},8)}return}if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){var s="",p=Bt.shift(),c=jt.shift();if(0==p?(s=webphone_api.webrtcapi.GetAudioDeviceList(p),webphone_api.global.audio_rec_device_list=s,webphone_api.common.SaveParameter("cache_audio_rec_device_list",s)):1==p?(s=webphone_api.webrtcapi.GetAudioDeviceList(p),webphone_api.global.audio_play_device_list=s,webphone_api.common.SaveParameter("cache_audio_play_device_list",s),(webphone_api.common.isNull(webphone_api.global.audio_ring_device_list)||webphone_api.global.audio_ring_device_list.length<1)&&!webphone_api.common.isNull(s)&&s.length>0&&(webphone_api.global.audio_ring_device_list=s,webphone_api.common.SaveParameter("cache_audio_ring_device_list",s))):2==p?(s=webphone_api.webrtcapi.GetAudioDeviceList(p), webphone_api.global.audio_ring_device_list=s,webphone_api.common.SaveParameter("cache_audio_ring_device_list",s),(webphone_api.common.isNull(webphone_api.global.audio_play_device_list)||webphone_api.global.audio_play_device_list.length<1)&&!webphone_api.common.isNull(s)&&s.length>0&&(webphone_api.global.audio_play_device_list=s,webphone_api.common.SaveParameter("cache_audio_play_device_list",s))):(s=webphone_api.webrtcapi.GetAudioDeviceList(p),webphone_api.global.video_rec_device_list=s,webphone_api.common.SaveParameter("cache_video_rec_device_list",s)),c(s),!webphone_api.common.isNull(jt)&&jt.length>0){var r=Bt[0],l=jt[0];setTimeout(function(){webphone_api.common.isNull(r)&&(r="-44"),Ue(r,l,!0)},8)}return}var c=jt.shift();Bt.shift(),c("ERROR, Cannot get device list because no engine is started at the moment")}catch(u){webphone_api.common.PutToDebugLogException(2,"plhandler: GetDeviceList",u)}}function Ve(e,n,t){var o=0;try{if(o=1,!0!==t||zt.length<1){if(o=2,Jn("GetDevice"),!n||"function"!=typeof n)return void webphone_api.common.PutToDebugLog(4,"WARNING, plhandler: GetDevice callback is not defined");o=3,qt.push(e),o=3001,zt.push(n)}if(o=4,webphone_api.common.getuseengine().length<1||webphone_api.global.phonestarted<2){o=5,webphone_api.common.isNull(Kt)||clearTimeout(Kt),Kt=null;var i=qt[0];return o=6,void(Kt=setTimeout(function(){o=7,Ve(i,null,!0)},250))}if(o=8,webphone_api.common.isNull(Kt)||clearTimeout(Kt),Kt=null,o=9,webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return o=10,void webphone_api.common.WinAPI("API_GetAudioDevice",function(e){if(o=11,webphone_api.common.isNull(e)&&(e=""),e=webphone_api.common.Trim(e),webphone_api.common.CanLog(7)&&webphone_api.common.PutToDebugLog(7,"PROCESSING_AUDIODEV ("+e.length.toString()+") : "+e),o=12,qt.length<1)o=13,null!=e&&e.length>0&&webphone_api.common.PutToDebugLog(3,"WARNING, audidevice unexpected answer: "+e);else{o=14;var n=qt.shift();0===e.indexOf("_BASE64_")&&(o=15,e=webphone_api.common.B64Dec(e),webphone_api.common.isNull(e)&&(e=""),e=webphone_api.common.Trim(e)),o=16,0==e.indexOf("ERROR")||0==e.indexOf("APIREQUEST")?webphone_api.common.PutToDebugLog(3,"WARNING, audidevicelist invaid answer: "+e+" (for "+n+")"):0==n?(webphone_api.global.audio_rec_curr_device=e,webphone_api.common.SaveParameter("cache_audio_rec_curr_device",e)):1==n?(webphone_api.global.audio_play_curr_device=e,webphone_api.common.SaveParameter("cache_audio_play_curr_device",e)):2==n?(webphone_api.global.audio_ring_curr_device=e,webphone_api.common.SaveParameter("cache_audio_ring_curr_device",e)):3==n?(webphone_api.global.video_rec_curr_device=e,webphone_api.common.SaveParameter("cache_video_rec_curr_device",e)):webphone_api.common.PutToDebugLog(3,"WARNING, audidevicelist answer with unknow dev: "+e),o=17;var t=zt.shift();if(o=18,webphone_api.common.PutToDebugLog(4,"EVENT, GetDevice (1), res: "+e),t(e),o=19,!webphone_api.common.isNull(zt)&&zt.length>0){o=20;var i=qt[0];o=21,setTimeout(function(){o=22,Ve(i,null,!0)},8)}}},e);if(o=23,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA){o=24;var a="",r=qt.shift();o=25,a=webphone_api.webphone.GetAudioDevice(e),o=26,webphone_api.common.isNull(a)&&(a=""),a=webphone_api.common.Trim(a),0===a.indexOf("_BASE64_")&&(o=27,a=webphone_api.common.B64Dec(a),webphone_api.common.isNull(a)&&(a=""),a=webphone_api.common.Trim(a)),o=28,0==a.indexOf("ERROR")||0==a.indexOf("APIREQUEST")?webphone_api.common.PutToDebugLog(3,"WARNING, audidevicelist invaid answer: "+a+" (for "+r+")"):0==r?(webphone_api.global.audio_rec_curr_device=a,webphone_api.common.SaveParameter("cache_audio_rec_curr_device",a)):1==r?(webphone_api.global.audio_play_curr_device=a,webphone_api.common.SaveParameter("cache_audio_play_curr_device",a)):2==r?(webphone_api.global.audio_ring_curr_device=a,webphone_api.common.SaveParameter("cache_audio_ring_curr_device",a)):(webphone_api.global.video_rec_curr_device=a,webphone_api.common.SaveParameter("cache_video_rec_curr_device",a)),o=29;var l=zt.shift();if(o=30,webphone_api.common.PutToDebugLog(4,"EVENT, GetDevice (2), dev: "+r+"; res: "+a),l(a),o=31,!webphone_api.common.isNull(zt)&&zt.length>0){o=32;var i=qt[0];setTimeout(function(){o=33,Ve(i,null,!0)},8)}return}if(o=34,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){o=35;var a="",r=qt.shift();o=36,0==r?(o=37,a=webphone_api.webrtcapi.GetAudioDevice(e),webphone_api.global.audio_rec_curr_device=a,webphone_api.common.SaveParameter("cache_audio_rec_curr_device",a)):1==r?(o=38,a=webphone_api.webrtcapi.GetAudioDevice(e),webphone_api.global.audio_play_curr_device=a,webphone_api.common.SaveParameter("cache_audio_play_curr_device",a)):2==r?(a=webphone_api.webrtcapi.GetAudioDevice(e),webphone_api.global.audio_ring_curr_device=a,webphone_api.common.SaveParameter("cache_audio_ring_curr_device",a)):(a=webphone_api.webrtcapi.GetAudioDevice(e),webphone_api.global.video_rec_curr_device=a,webphone_api.common.SaveParameter("cache_video_rec_curr_device",a)),o=40;var l=zt.shift();if(o=41,webphone_api.common.PutToDebugLog(4,"EVENT, GetDevice (3), dev: "+r+"; res: "+a),o=42,l(a),o=43,!webphone_api.common.isNull(zt)&&zt.length>0){o=44;var i=qt[0];o=45,setTimeout(function(){o=46,Ve(i,null,!0)},100)}return}}catch(s){webphone_api.common.PutToDebugLogException(2,"plhandler: GetDevice "+o,s)}}function We(e,n,t,o,i,a){try{if(webphone_api.common.isNull(e)&&(e=0),!0!==a&&(Jn("SetDevice"),Xt.push(e),Jt.push(n),Yt.push(t),Qt.push(o),Zt.push(i)),webphone_api.common.getuseengine().length<1||webphone_api.global.phonestarted<2)return webphone_api.common.isNull(eo)||clearTimeout(eo),eo=null,void(eo=setTimeout(function(){We(null,null,null,null,null,!0)},250));if(webphone_api.common.isNull(eo)||clearTimeout(eo),eo=null,null===n&&!webphone_api.common.isNull(Jt)&&Jt.length>0&&(e=Xt.shift(),n=Jt.shift(),t=Yt.shift(),o=Qt.shift(),i=Zt.shift()),null===n&&null===t)return;if(webphone_api.common.isNull(e)&&(e=0),webphone_api.common.PutToDebugLog(4,"EVENT, setdevice, dev: "+n+"; devicename: "+t+"; immediate: "+o+"; from: "+e.toString()),webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_SetAudioDevice",null,n,t,o),void(!webphone_api.common.isNull(Jt)&&Jt.length>0&&setTimeout(function(){We(e+1e3,null,null,null,null)},100));if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return webphone_api.webphone.SetAudioDevice(n,t,o),!webphone_api.common.isNull(Jt)&&Jt.length>0&&setTimeout(function(){We(e+2e3,null,null,null,null)},100),!0;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return webphone_api.webrtcapi.SetAudioDevice(n,t,i),!webphone_api.common.isNull(Jt)&&Jt.length>0&&setTimeout(function(){We(e+3e3,null,null,null,null)},100),!0}catch(r){webphone_api.common.PutToDebugLogException(2,"plhandler: SetDevice",r)}}function Fe(e,n){try{if(webphone_api.global.isappenginestarted=!1,webphone_api.global.sipstackstarted=!1,(webphone_api.common.isNull(e)||e.length<1)&&(e=webphone_api.common.getuseengine()),(webphone_api.common.isNull(e)||e.length<1)&&(e=webphone_api.global.last_last_useengine),webphone_api.common.isNull(e)||e.length<1)return void webphone_api.common.PutToDebugLog(2,"EVENT, plhandler: StopEngine engine is not defined");webphone_api.global.webrtc_regstate=0,webphone_api.common.PutToDebugLog(2,"EVENT, USER, stopengine (API_StopEngine)");if(!1===webphone_api.common.GetParameterBool("needunregister",!0)&&!0!==n)return void webphone_api.common.PutToDebugLog(2,"EVENT, API_StopEngine needunregister is FALSE");if(webphone_api.common.Glsp()){if(e===webphone_api.global.ENGINE_SERVICE)return webphone_api.global.apistartstate=0,webphone_api.global.apistarttick=0,webphone_api.global.wnotstartedsession=!1,void(!1===webphone_api.common.NSMacLinEnabled()&&webphone_api.common.WinAPI("API_Exit",null,"1"));if(e===webphone_api.global.ENGINE_JAVA)return webphone_api.global.apistartstate=0,webphone_api.global.apistarttick=0,webphone_api.global.wnotstartedsession=!1,webphone_api.webphone.Exit()}}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: StopEngine",t)}}function Me(e,n){try{webphone_api.common.PutToDebugLog(2,"EVENT, USER, API_Stop (force: "+e+" from: "+n+")"),webphone_api.flagrestartwebrtc=!1,webphone_api.global.laststarttick=0,webphone_api.global.webrtc_regstate=0,webphone_api.global.sipstackstarted=!1,webphone_api.global.unregisteredfromidle=0,webphone_api.global.apistartstate=0,webphone_api.global.apistarttick=0,webphone_api.global.webrtcsipsignalingreceived=0,webphone_api.global.wnotstartedsession=!1,webphone_api.global.isappenginestarted=!1,webphone_api.global.onunload_flag&&(e=!0),Oe(),setTimeout(function(){Fe(webphone_api.common.getuseengine(),e)},900),setTimeout(function(){webphone_api.common.isNull(webphone_api.global.maintimerid)||(clearInterval(webphone_api.global.maintimerid),webphone_api.global.maintimerid=null,webphone_api.common.isNull(webphone_api.global.initcalled)||(webphone_api.global.initcalled=!1)),webphone_api.global.apistartstate=0,webphone_api.global.apistarttick=0,webphone_api.global.webrtcsipsignalingreceived=0,webphone_api.global.wnotstartedsession=!1},1100),setTimeout(function(){try{webphone_api.onAppStateChangeCb("stopped")}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: There is an error in onAppStateChange(stopped) callback",e)}try{webphone_api.onStopCb()}catch(e){webphone_api.common.PutToDebugLogException(2,"There is an error in onStop() callback",e)}},1250),webphone_api.common.isNull(webphone_api.global.serviceStatusPollTimer)||clearInterval(webphone_api.global.serviceStatusPollTimer),webphone_api.common.isNull(webphone_api.global.polltimerid)||clearInterval(webphone_api.global.polltimerid),webphone_api.common.isNull(webphone_api.global.worktimer)||clearTimeout(webphone_api.global.worktimer),webphone_api.global.worktimer=null;if(!1===webphone_api.common.GetParameterBool("needunregister",!0)&&!0!==e)return void webphone_api.common.PutToDebugLog(2,"EVENT, API_Stop needunregister is FALSE");webphone_api.common.Glsp()&&(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC?webphone_api.global.phonestarted>2&&(webphone_api.webrtcapi.SipStop(2),webphone_api.common.Wsunreg()):webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE?!1===webphone_api.common.NSMacLinEnabled()&&webphone_api.common.WinAPI("API_Exit",null,"2"):webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&webphone_api.webphone.Exit()),webphone_api.global.onunload_flag&&Fe(webphone_api.common.getuseengine(),e)}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: Stop",t)}webphone_api.global.phonestarted=0}function He(e){try{if(Jn("SendChatIsComposing"),webphone_api.common.isNull(e)||e.length<1)return void webphone_api.common.PutToDebugLog(2,"ERROR, SendChatIsComposing invalid destination");var n=webphone_api.global.aline;if((webphone_api.common.isNull(n)||-3===n)&&(n=-1),webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_SendChatIsComposing",null,webphone_api.common.GetLineForJavaAPI(),e);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA)return webphone_api.webphone.SendChatIsComposing(n,e)}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: SendChatIsComposing",t)}}function Be(){return webphone_api.common.BrowserWindowIsActive()}function je(){try{return Jn("HelpWindow"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, helpwindow (API_HelpWindow)"),webphone_api.common.HelpWindow()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: HelpWindow",e)}return!1}function $e(){try{return Jn("SettingsPage"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, settingspage (API_SettingsPage)"),webphone_api.common.OpenSettings(!0,9),!0}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: SettingsPage",e)}return!1}function qe(){try{return Jn("DialPage"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, dialpage (API_DialPage)"),webphone_api.$.mobile.changePage("#page_dialpad",{transition:"pop",role:"page"}),!0}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: DialPage",e)}return!1}function ze(){try{return Jn("MessageInboxPage"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, messageinboxpage (API_MessageInboxPage)"),webphone_api.$.mobile.changePage("#page_messagelist",{transition:"none",role:"page"}),!0}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: MessageInboxPage",e)}return!1}function Ke(){try{return Jn("MessagePage"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, messagepage (API_MessagePage)"),webphone_api.global.intentmsg[0]="action=",webphone_api.global.intentmsg[1]="to=",webphone_api.global.intentmsg[2]="message=",webphone_api.$.mobile.changePage("#page_message",{transition:"none",role:"page"}),!0}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: MessagePage",e)}return!1}function Xe(){try{return Jn("AddContactPage"),webphone_api.common.PutToDebugLog(2,"EVENT, USER, addcontactpage (API_AddContactPage)"),webphone_api.global.intentaddeditct[0]="action=add",webphone_api.$.mobile.changePage("#page_addeditcontact",{transition:"pop",role:"page"}),!0}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: AddContactPage",e)}return!1}function Je(e){try{webphone_api.webphone.InsertApplet(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: InsertApplet",n)}}function Ye(){try{return webphone_api.common.EnterKeyPress()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: EnterKeyPress",e)}return!1}function Qe(e){ne(e,"FILETRANSFER_DELIVERED:"+e)}function Ze(e,n){try{if(Jn("GetTelSearchName"),!n||"function"!=typeof n)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetTelsearchName callback is not definaed");if(webphone_api.common.isNull(e)||e.length<2)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: GetTelsearchName invalid number: "+e);webphone_api.common.GetTelsearchName(e,n)}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: EnterKeyPress",t)}}function en(e){try{webphone_api.common.bwanswer(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: bwanswer",n)}}function nn(){try{if(webphone_api.global.wasSettModified){var e=webphone_api.common.GetActiveAccSettingsFilename();!webphone_api.common.isNull(e)&&e.length>0&&webphone_api.common.SaveSettingsFile(5,e,function(e){webphone_api.common.CanLog(2)&&(e?webphone_api.common.PutToDebugLog(2,"EVENT, SaveSettingsFile from onappexit Successfull"):webphone_api.common.PutToDebugLog(2,"ERROR, SaveSettingsFile from onappexit Failed"))})}}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: onappexit",n)}}function tn(){Jn("getlogs"),webphone_api.common.PutToDebugLog(2,"EVENT, getlogs called");var e=webphone_api.global.logs;return webphone_api.global.logs="",e}function on(){try{Jn("getlogsex"),webphone_api.common.PutToDebugLog(2,"EVENT, getlogsex called"),webphone_api.common.WinAPI("API_SetLogs",null,webphone_api.global.logs)}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: getlogsex",e)}}function an(e){try{webphone_api.common.isNull(e)&&(e=""),webphone_api.common.PutToDebugLog(2,"APILOGS: "+e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: putlogs",n)}}function rn(){try{Jn("ImportContacts"),webphone_api.common.PutToDebugLog(2,"EVENT, importcontacts called"),webphone_api.common.DownloadContacts()}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: ImportContacts",e)}}function ln(e,n){try{Jn("delsettings"),webphone_api.common.isNull(e)&&(e=0),no&&e<1&&webphone_api.common.PutToDebugLog(3,"EVENT, ignore delsettings because it was already executed A"),no=!0,webphone_api.global.phonestarted<2&&e>0&&(webphone_api.common.PutToDebugLog(2,"EVENT, resetsettings set to TRUE"),webphone_api.common.SaveParameter("resetsettings","true")),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE?webphone_api.common.WinAPI("API_DelSettings",null,e):webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&webphone_api.webphone.DelSettings(e),!0!==n&&webphone_api.common.delsettings(e),webphone_api.global.loglevel=webphone_api.common.GetLogLevel()}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: delsettings",t)}}function sn(e){try{if(Jn("needratingrequest"),!e||"function"!=typeof e)return!1;if(webphone_api.global.phonestarted<2)return void Yn("needratingrequest",[e]);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_IsEncrypted",function(n){e(webphone_api.common.isNull(n)?"true"===n||!0===n?!0:!1:!1)});webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&webphone_api.webphone.NeedRatingRequest(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: needratingrequest",n),e(!1)}}function pn(){try{if(!webphone_api.common.isNull(platform)&&!webphone_api.common.isNull(platform.name)){var e=webphone_api.platform.name.toString();if(e=e.toLowerCase(),e.indexOf("mobile")>=0)return!0}var n=!1;return function(e){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(n=!0)}(navigator.userAgent||navigator.vendor||window.opera),n}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: IsMobileBrowser",t)}return!1}function cn(){try{return webphone_api.common.isNull(webphone_api.global.useengine)?"":webphone_api.global.useengine}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: Getenginename",e)}}function un(e){try{if(Jn("GetLastInvite"),!e||"function"!=typeof e)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: getlastinvite callback is not defined");if(webphone_api.global.phonestarted<2)return void Yn("GetLastInvite",[e]);var n=webphone_api.global.aline;if((webphone_api.common.isNull(n)||-3===n)&&(n=-1),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){n<1&&(n=webphone_api.common.GetBestLine());var t=webphone_api.common.GetEndpoint(1020,n,"","","",!1),o="";return webphone_api.common.isNull(t)||(o=t[webphone_api.common.EP_SIPINVITE]),void e(o)}if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"ERROR, getlastinvite is not supported by flash engine"),void e("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetLastInvite",function(n){e(n)},webphone_api.common.GetLineForJavaAPI());if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void e(webphone_api.webphone.GetGetLastInvite(webphone_api.common.GetLineForJavaAPI(),e))}catch(i){webphone_api.common.PutToDebugLogException(2,"plhandler: GetLastInvite",i)}}function gn(e){try{if(Jn("GetLastRecInvite"),!e||"function"!=typeof e)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: getlastrecinvite callback is not defined");if(webphone_api.global.phonestarted<2)return void Yn("GetLastRecInvite",[e]);var n=webphone_api.global.aline;if((webphone_api.common.isNull(n)||-3===n)&&(n=-1),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void e(webphone_api.common.GetLastRecInvite());if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"ERROR, getlastrecinvite is not supported by flash engine"),void e("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetLastRecInvite",function(n){e(n)},webphone_api.common.GetLineForJavaAPI());if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void e(webphone_api.webphone.GetGetLastRecInvite(webphone_api.common.GetLineForJavaAPI(),e))}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: GetLastRecInvite",t)}}function hn(e){try{if(Jn("GetLastSentInvite"),!e||"function"!=typeof e)return void webphone_api.common.PutToDebugLog(2,"ERROR, plhandler: getlastsentinvite callback is not defined");if(webphone_api.global.phonestarted<2)return void Yn("GetLastSentInvite",[e]);var n=webphone_api.global.aline;if((webphone_api.common.isNull(n)||-3===n)&&(n=-1),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC)return void e(webphone_api.common.GetLastSentInvite());if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_FLASH)return webphone_api.common.PutToDebugLog(2,"ERROR, getlastsentinvite is not supported by flash engine"),void e("");if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.WinAPI("API_GetLastSentInvite",function(n){e(n)},webphone_api.common.GetLineForJavaAPI());if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return void e(webphone_api.webphone.GetLastSentInvite(webphone_api.common.GetLineForJavaAPI(),e))}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: GetLastSentInvite",t)}}function mn(){try{if(Jn("API_RecFiles_Upload"),webphone_api.global.phonestarted<2)return void Yn("API_RecFiles_Upload",[]);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_RecFiles_Upload",null),!0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.API_RecFiles_Upload();webphone_api.common.PutToDebugLog(2,"WARNING, API_RecFiles_Upload not supported by engine: "+webphone_api.common.getuseengine())}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: API_RecFiles_Upload",e)}return!1}function dn(e,n){try{if(Jn("API_RecFiles_UploadEx"),webphone_api.global.phonestarted<2)return void Yn("API_RecFiles_UploadEx",[e,n]);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_RecFiles_UploadEx",null,e,n),!0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.API_RecFiles_UploadEx(e,n);webphone_api.common.PutToDebugLog(2,"WARNING, API_RecFiles_UploadEx not supported by engine: "+webphone_api.common.getuseengine())}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: API_RecFiles_UploadEx",t)}return!1}function bn(){try{if(Jn("API_RecFiles_Clear"),webphone_api.global.phonestarted<2)return void Yn("API_RecFiles_Clear",[]);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_RecFiles_Clear",null),!0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.API_RecFiles_Clear();webphone_api.common.PutToDebugLog(2,"WARNING, API_RecFiles_Clear not supported by engine: "+webphone_api.common.getuseengine())}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: API_RecFiles_Clear",e)}return!1}function _n(){try{if(Jn("API_RecFiles_Del"),webphone_api.global.phonestarted<2)return void Yn("API_RecFiles_Del",[]);if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)return webphone_api.common.WinAPI("API_RecFiles_Del",null),!0;if(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE())return webphone_api.webphone.API_RecFiles_Del();webphone_api.common.PutToDebugLog(2,"WARNING, API_RecFiles_Del not supported by engine: "+webphone_api.common.getuseengine())}catch(e){webphone_api.common.PutToDebugLogException(2,"plhandler: API_RecFiles_Del",e)}return!1}function fn(e){try{return webphone_api.stringres.get(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"plhandler: getstringresource",n)}return""}function wn(e,n){try{Jn("Jvoip-"+e);var t=cn();if(webphone_api.common.isNull(t)||t.length<2)return void webphone_api.common.PutToDebugLog(2,"ERROR, Jvoip no engine available at the moment");if(t!==webphone_api.global.ENGINE_JAVA&&t!==webphone_api.global.ENGINE_SERVICE)return void webphone_api.common.PutToDebugLog(2,"ERROR, Jvoip not applicable for engine: "+webphone_api.common.GetEngineDisplayName(t));if(webphone_api.common.isNull(e)||e.length<3)return void webphone_api.common.PutToDebugLog(2,"ERROR, Jvoip invalid api function name: "+e);var o=e.indexOf("(");o>0&&(e=e.substring(0,o)),e=webphone_api.common.Trim(e),webphone_api.common.isNull(n)&&(n=[]);for(var i="",a=0;a0&&(i+=","),i+=n[a];webphone_api.common.PutToDebugLog(2,"EVENT, USER, jvoip (API_Jvoip): "+e+"; arguments: ["+i+"]"),webphone_api.webphone.Jvoip(e,n)}catch(r){webphone_api.common.PutToDebugLogException(2,"plhandler: Jvoip",r)}}function vn(){return webphone_api.common.GetOneStunSrv()}function En(e,n){try{Jn("RemoveCodecFromMediaLine");var t=e;if(webphone_api.common.isNull(n)||!1===webphone_api.common.IsNumber(n))return webphone_api.common.PutToDebugLog(2,"ERROR, RemoveCodecFromMediaLine invalid codec: "+n),e;if(webphone_api.common.isNull(t))return webphone_api.common.PutToDebugLog(2,"WARNING, RemoveCodecFromMediaLine invalid m line"),e;if(e.indexOf("m=audio")<0&&e.indexOf("m=video")<0)return webphone_api.common.PutToDebugLog(5,"EVENT, (warn) RemoveCodecFromMediaLine codec line not found: "+webphone_api.common.Trim(t)+" / "+n.toString()),e;var o=t.indexOf("/");if(o<0)return webphone_api.common.PutToDebugLog(2,"ERROR, RemoveCodecFromMediaLine cannot parse m: "+webphone_api.common.Trim(t)),e;var i=t.substring(0,o);if(t=t.substring(o),t.indexOf(" "+n+" ")>=0)t=t.replace(" "+n+" "," ");else{if(!(t.indexOf(" "+n+"\r")>=0))return webphone_api.common.PutToDebugLog(5,"EVENT, (warn) RemoveCodecFromMediaLine codec number not found: "+webphone_api.common.Trim(t)+" / "+n.toString()),e;t=t.replace(" "+n+"\r","\r")}return i+t}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: RemoveCodecFromMediaLine",a)}return e}function Pn(e,n){try{Jn("SetPrefCodec");var t=e;if(webphone_api.common.isNull(n)||!1===webphone_api.common.IsNumber(n))return webphone_api.common.PutToDebugLog(2,"ERROR, SetPrefCodec invalid codec: "+n),e;if(webphone_api.common.isNull(t))return webphone_api.common.PutToDebugLog(2,"ERROR, SetPrefCodec invalid m line"),e;if(e.indexOf("m=audio")<0&&e.indexOf("m=video")<0)return webphone_api.common.PutToDebugLog(5,"EVENT, (warn) SetPrefCodec codec line not found: "+webphone_api.common.Trim(t)+" / "+n.toString()),e;var o=t.indexOf("/");if(o<0)return webphone_api.common.PutToDebugLog(2,"ERROR, SetPrefCodec cannot parse m=audio: "+webphone_api.common.Trim(t)),e;var i=t.substring(0,o);if(t=t.substring(o),(o=t.indexOf(" "))>0)return i+=t.substring(0,o),t=t.substring(o),t.indexOf(" "+n+" ")>=0?(t=t.replace(" "+n+" "," "),t=" "+n+t):t.indexOf(" "+n+"\r")>=0&&(t=t.replace(" "+n+"\r","\r"),t=" "+n+t),i+t}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: RemoveCodecFromMediaLine",a)}return e}function Tn(e){return webphone_api.common.CanLog(12)&&webphone_api.common.PutToDebugLog(12,"EVENT, HandleWebrtcCodecs start sdp: \r\n"+e),e=Sn(Nn(e)),webphone_api.common.CanLog(12)&&webphone_api.common.PutToDebugLog(12,"EVENT, HandleWebrtcCodecs end sdp: \r\n"+e),e}function Sn(e){try{var n=e,t=webphone_api.common.GetParameter("codec");if(webphone_api.common.isNull(t)||t.length<1||"-1"===t||","===t)return e;var o=t.split(",");if(webphone_api.common.isNull(o)||o.length<1)return e;var i=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_pcmu")),a=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_pcma")),r=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_speexwb")),l=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_opuswb"));l||(l=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_opus"))),l||(l=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_opusswb"))),l||(l=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_opusuwb")));for(var s=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_isac")),p=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_g722")),c=0;c=0&&d<=m&&(d=-1);var b=!1;!l&&n.indexOf("opus")>=0&&n.indexOf("red")>=0&&(b=!1);for(var _=n.toLowerCase(),t="",f="",w=0;w<7;w++){switch(t="",w){case 0:i||(t="pcmu");break;case 1:a||(t="pcma");break;case 2:r||(t="speex");break;case 3:l||(t="opus");break;case 4:s||(t="isac");break;case 5:p||(t="g722");break;case 6:b||(t="red")}if(!(t.length<1)&&!(_.indexOf(t)<0))for(var c=h.length-1;c>m;c--)if(d>=0&&c>=d&&(c=d),c>=h.length&&(c=h.length-1),!webphone_api.common.isNull(h[c])&&0==h[c].indexOf("a=rtpmap:")&&h[c].toLowerCase().indexOf(t)>0&&(f=webphone_api.common.Trim(webphone_api.common.StrGetBetween(h[c],"a=rtpmap:"," ")),f.length>0&&webphone_api.common.IsNumber(f))){webphone_api.common.CanLog(12)&&webphone_api.common.PutToDebugLog(12,"EVENT, HandleWebrtcCodecsAudio remove "+t+" "+f),h[m]=En(h[m],f);for(var v=h.length-1;v>m;v--)!webphone_api.common.isNull(h[v])&&(h[v].indexOf("a=rtpmap:"+f+" ")>=0||h[v].indexOf("a=rtcp-fb:"+f+" ")>=0||h[v].indexOf("a=fmtp:"+f+" ")>=0)&&(h.splice(v,1),d--)}}n="";for(var c=0;c0&&(n+="\n"),n+=h[c];return n}catch(E){webphone_api.common.PutToDebugLogException(2,"plhandler: HandleWebrtcCodecsAudio",E)}return e}function Nn(e){try{var n=e,t=webphone_api.common.GetParameter("vcodec");if(webphone_api.common.isNull(t)||t.length<1||"-1"===t||","===t)return e;var o=t.split(",");if(webphone_api.common.isNull(o)||o.length<1)return e;for(var i=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_h264")),a=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_h265")),r=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_vp8")),l=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_vp9")),s=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_vp10")),p=webphone_api.common.ParamAsBool(webphone_api.common.GetParameter2("use_av1")),c=0;cm;c--)if(c>=h.length&&(c=h.length-1),!webphone_api.common.isNull(h[c])&&0==h[c].indexOf("a=rtpmap:")&&h[c].toLowerCase().indexOf(t)>0&&(_=webphone_api.common.Trim(webphone_api.common.StrGetBetween(h[c],"a=rtpmap:"," ")),_.length>0&&webphone_api.common.IsNumber(_))){webphone_api.common.CanLog(12)&&webphone_api.common.PutToDebugLog(12,"EVENT, HandleWebrtcCodecsVideo remove "+t+" "+_),h[m]=En(h[m],_);for(var v=h.length-1;v>m;v--)if(v>=h.length&&(v=h.length-1),!webphone_api.common.isNull(h[v])&&(0==h[v].indexOf("a=rtpmap:"+_+" ")||0==h[v].indexOf("a=rtcp-fb:"+_+" ")||0==h[v].indexOf("a=fmtp:"+_+" ")||0==h[v].indexOf("a=fmtp:")&&h[v].indexOf(" apt="+_)>=0)&&(d=h[v],h.splice(v,1),0==d.indexOf("a=fmtp:")&&d.indexOf(" apt="+_)>=0)){var f=webphone_api.common.Trim(webphone_api.common.StrGetBetween(d,"a=fmtp:","apt="+_));if(f.length>0){webphone_api.common.CanLog(12)&&webphone_api.common.PutToDebugLog(12,"EVENT, HandleWebrtcCodecsVideo remove rtx "+f),h[m]=En(h[m],f);for(var E=h.length-1;E>m;E--)E>=h.length&&(E=h.length-1),!webphone_api.common.isNull(h[E])&&(h[E].indexOf("a=rtpmap:"+f+" ")>=0||h[E].indexOf("a=rtcp-fb:"+f+" ")>=0||h[E].indexOf("a=fmtp:"+f+" ")>=0)&&h.splice(E,1)}}}}n="";for(var c=0;c0&&(n+="\n"),n+=h[c];return n}catch(P){webphone_api.common.PutToDebugLogException(2,"plhandler: HandleWebrtcCodecsVideo",P)}return e}function In(e){return Cn(Gn(e))}function Cn(e){try{var n=e,t=webphone_api.common.GetParameter("prefcodec");if(webphone_api.common.isNull(t)||t.length<1||"-1"===t||","===t)return e;var o=!1,i=!1,a=!1,r=!1,l=!1,s=!1,p=t.toLowerCase().trim();if("1"===p?o=!0:"2"===p?i=!0:"5"===p||"6"===p?a=!0:"10"===p||"11"===p||"12"===p||"13"===p?r=!0:"14"===p?s=!0:"15"===p?l=!0:"pcmu"===p?o=!0:"pcma"===p?i=!0:"g.711"===p||"g711"===p?o=!0:"speex"===p||"speexwb"===p?a=!0:"opus"===p||"opuswb"===p||"opusswb"===p||"opusuwb"===p?r=!0:"isac"===p?l=!0:"g.722"!==p&&"g722"!==p||(s=!0),!1===webphone_api.common.Glop()&&(r=!1),!(o||i||a||r||l||s))return e;var c=n.split("\n");if(webphone_api.common.isNull(c)&&c.length<10)return e;for(var u=-1,g=0;g=0&&h<=u&&(h=-1);for(var m=n.toLowerCase(),d="",b="",_=0;_<6;_++){switch(d="",b="",_){case 0:o&&(d="pcmu",b="0");break;case 1:i&&(d="pcma",b="8");break;case 2:a&&(d="speex");break;case 3:r&&(d="opus");break;case 4:l&&(d="isac");break;case 5:s&&(d="g722")}if(!(d.length<1&&b.length<1)&&!(d.length>0&&b.length<1&&m.indexOf(d)<0))if(webphone_api.common.CanLog(12)&&webphone_api.common.PutToDebugLog(12,"EVENT, HandleWebrtcPrefCodecAudio set "+d+" "+b),b.length>0){c[u]=Pn(c[u],b);for(var f=c.length-1;f>u;f--)f>=c.length&&(f=c.length-1),webphone_api.common.isNull(c[f])||0!=c[f].indexOf("a=rtpmap:"+b+" ")&&0!=c[f].indexOf("a=rtcp-fb:"+b+" ")&&0!=c[f].indexOf("a=fmtp:"+b+" ")||c.splice(f,1)}else if(d.length>0)for(var g=c.length-1;g>u;g--)h>=0&&g>=h&&(g=h),g>=c.length&&(g=c.length-1),!webphone_api.common.isNull(c[g])&&0==c[g].indexOf("a=rtpmap:")&&c[g].toLowerCase().indexOf(d)>0&&(b=webphone_api.common.Trim(webphone_api.common.StrGetBetween(c[g],"a=rtpmap:"," ")),b.length>0&&webphone_api.common.IsNumber(b)&&(c[u]=Pn(c[u],b)))}n="";for(var g=0;g0&&(n+="\n"),n+=c[g];return n}catch(w){webphone_api.common.PutToDebugLogException(2,"plhandler: HandleWebrtcPrefCodecAudio",w)}return e}function Gn(e){try{var n=e,t=webphone_api.common.GetParameter("prefvcodec");if(webphone_api.common.isNull(t)||t.length<1||"-1"===t||","===t)return e;var o=!1,i=!1,a=!1,r=!1,l=!1,s=!1,p=t.toLowerCase().trim();if("50"===p?o=!0:"51"===p?i=!0:"52"===p?a=!0:"53"===p?r=!0:"54"===p?l=!0:"55"===p?s=!0:"h.264"===p||"h264"===p?o=!0:"h.265"===p||"h265"===p?i=!0:"vp8"===p||"vp.8"===p?a=!0:"vp9"===p||"vp.9"===p?r=!0:"vp10"===p||"vp.10"===p?l=!0:"av1"!==p&&"av.1"!==p||(s=!0),!(o||i||a||r||l||s))return e;var c=n.split("\n");if(webphone_api.common.isNull(c)&&c.length<10)return e;for(var u=-1,g=0;gu;g--)g>=c.length&&(g=c.length-1),!webphone_api.common.isNull(c[g])&&0==c[g].indexOf("a=rtpmap:")&&c[g].toLowerCase().indexOf(m)>0&&(d=webphone_api.common.Trim(webphone_api.common.StrGetBetween(c[g],"a=rtpmap:"," ")),d.length>0&&webphone_api.common.IsNumber(d)&&(c[u]=Pn(c[u],d)))}}n="";for(var g=0;g0&&(n+="\n"),n+=c[g];return n}catch(_){webphone_api.common.PutToDebugLogException(2,"plhandler: HandleWebrtcPrefCodecVideo",_)}return e}function Ln(e){try{if("Firefox"!==webphone_api.common.GetBrowser()||webphone_api.common.GetBrowserVersion()<75)return e;if(void 0===e||null===e||e.indexOf("\r\n\r\n")<0)return e;var n=e.toLowerCase();if(n.indexOf("invite sip:")<0&&n.indexOf("invite sips:")<0)return e;var t=e,o=t.split("\n");if(webphone_api.common.isNull(o)&&o.length<10)return e;t="";for(var i=0,a=-1,r=-1,l=0;l=0&&(i++,a=l),o[l].indexOf("a=sendonly")>=0&&(i++,r=l);if(i>1&&a>0){r>0&&(o[a]=o[a].replace("a=sendrecv","a=sendonly")),o.splice(a,1),webphone_api.common.PutToDebugLog(2,"EVENT, HandleWebrtcFirefoxHold sendrecv removed_2");for(var l=0;l0&&(t+="\n"),t+=o[l];return t}}catch(s){webphone_api.common.PutToDebugLogException(2,"plhandler: HandleWebrtcFirefoxHold",s)}return e}function Rn(e){try{if(void 0===e||null===e)return e;if("Firefox"!==webphone_api.common.GetBrowser())return e;var n=e,t=n.split("\n");if(webphone_api.common.isNull(t)&&t.length<10)return e;n="";for(var o=0,i=-1,a=0;a=0&&(o++,i=a);if(o>1&&i>0){t.splice(i,1),webphone_api.common.PutToDebugLog(2,"EVENT, HandleWebrtcFirefoxHold_RemoveDuplicateHeader removed");for(var a=0;a0&&(n+="\n"),n+=t[a];return n}}catch(r){webphone_api.common.PutToDebugLogException(2,"plhandler: HandleWebrtcFirefoxHold_RemoveDuplicateHeader",r)}return e}function yn(e){try{var n=!1,t=webphone_api.common.GetParameter("serveraddressbook_url");if(webphone_api.common.isNull(t)||t.length<1)return;if(webphone_api.common.isNull(e)||1!=e||(n=!0),!n){var o=webphone_api.common.GetParameterInt("serveraddressbook_sync",0),i=webphone_api.common.GetParameterInt("serveraddressbook_status",2);i<1?n=!0:1===i&&o>0&&(n=!0),o>1&&(n=!0)}if(!n)return;webphone_api.common.IsHttps()&&(t=t.replace("http:","https:")),webphone_api.common.PutToDebugLog(3,"EVENT, DownloadServerAddressbook url: "+t);var a=new XMLHttpRequest;if("withCredentials"in a)a.open("GET",t,!0);else{if("undefined"==typeof XDomainRequest)return void webphone_api.common.PutToDebugLog(2,"ERROR, common: DownloadServerAddressbook, CORS not supported");a=new XDomainRequest,a.open("GET",t)}var r=0;a.onload=function(){try{webphone_api.common.PutToDebugLog(4,"EVENT, DownloadServerAddressbook.onload"),r=19;var e=a.responseText;return r=20,webphone_api.common.PutToDebugLog(2,"EVENT, DownloadServerAddressbook response: "+e),r=21,webphone_api.common.isNull(e)||e.length<1?(r=23,void webphone_api.common.PutToDebugLog(2,"ERROR, DownloadServerAddressbook response is NULL")):void Dn(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"DownloadServerAddressbook.onload inner ("+r+")",n)}},a.onerror=function(e){var n="";webphone_api.common.isNull(e)||(n=e.toString(),webphone_api.common.isNull(e.target)||(n=webphone_api.common.isNull(e.target.status)?n+" "+e.target.toString():n+" "+e.target.status.toString())),webphone_api.common.PutToDebugLog(2,"ERROR, common: DownloadServerAddressbook: onerror: "+n)},a.timeout=9e3,a.ontimeout=function(e){webphone_api.common.PutToDebugLog(2,"ERROR, common: DownloadServerAddressbook: Timeout")},a.send()}catch(l){webphone_api.common.PutToDebugLogException(2,"plhandler: DownloadServerAddressbook",l)}}function Dn(e){try{if(webphone_api.common.isNull(e)||e.length<1)return;var n=e.split("\r\n"),t=0;if(webphone_api.common.isNull(n))return void webphone_api.common.PutToDebugLog(2,"ERROR, ParserServerAddressbook list is NULL: "+e);if(n.length<1)return;1==webphone_api.common.GetParameterInt("serveraddressbook_clear",-1)&&(webphone_api.global.ctlist=[]);for(var o=0;o2&&(webphone_api.common.isNull(i[2])||"1"!==webphone_api.common.Trim(i[2])||(l=1)),i.length>3&&!webphone_api.common.isNull(i[3])&&webphone_api.common.Trim(i[3]).length>3&&(s=webphone_api.common.Trim(i[3])),i.length>4&&!webphone_api.common.isNull(i[4])&&webphone_api.common.Trim(i[4]).length>3&&(p=webphone_api.common.Trim(i[4])),i.length>5&&!webphone_api.common.isNull(i[5])&&webphone_api.common.Trim(i[5]).length>0&&(c=webphone_api.common.Trim(i[5])),i.length>6&&!webphone_api.common.isNull(i[6])&&webphone_api.common.Trim(i[6]).length>3&&(u=webphone_api.common.Trim(i[6]));var g=r.replace("+",""),h="sip";webphone_api.common.IsNumber(g)&&(h="phone"),i.length>7&&!webphone_api.common.isNull(i[7])&&webphone_api.common.Trim(i[7]).length>0&&(h=webphone_api.common.Trim(i[7])),t++;he(a,r,l,h,webphone_api.common.GetTickCount(),s,p,c,u,"1")}}}webphone_api.common.PutToDebugLog(4,"EVENT, ParserServerAddressbook: "+t.toString()+" contacts added sucessfully")}catch(m){webphone_api.common.PutToDebugLogException(2,"plhandler: ParserServerAddressbook",m)}}function On(e,n){Jn("IsServiceInstalled"),webphone_api.common.IsServiceInstalled(e,n)}function xn(){return Jn("CanIUseWebrtc"),webphone_api.common.CanIUseWebRTC()}function An(e,n,t){Jn("ShowToast-"+e),webphone_api.common.ShowToast(e,n,t)}function kn(e,n,t){Jn("AlertDialog-"+n),webphone_api.common.AlertDialog(e,n,t)}function Un(e,n,t,o,i){webphone_api.webphone.API_SetCredentials(e,n,t,o,i)}function Vn(e,n,t,o){webphone_api.webphone.API_SetCredentialsMD5(e,n,t,o)}function Wn(e){webphone_api.webphone.API_CheckVoicemail(e)}function Fn(e){webphone_api.webphone.API_SetLine(e)}function Mn(e){webphone_api.webphone.API_GetLine(e)}function Hn(e){webphone_api.webphone.API_GetLineStatus(e)}function Bn(e,n){webphone_api.webphone.API_Forward(e,n)}function jn(e){webphone_api.webphone.API_IsMuted(e)}function $n(e){webphone_api.webphone.API_IsOnHold(e)}function qn(e){webphone_api.webphone.API_GetAudioDeviceList(e)}function zn(e){webphone_api.webphone.API_GetAudioDevice(e)}function Kn(e){webphone_api.webphone.API_SetAudioDevice(e)}function Xn(e){webphone_api.webphone.API_GetVolume(e)}function Jn(e){try{if(!0===webphone_api.common.IsWindowsSoftphone())return;if(!1===webphone_api.global.wploaded){var n="WARNING,WapiTouced API called before webphone loaded ("+webphone_api.global.phonestarted.toString()+"): "+e;if(webphone_api.common.PutToDebugLog(2,n),"undefined"!=typeof console&&null!==console)if("delsettings"===e&&"undefined"!=typeof console.log&&null!==console.log)try{console.log(n)}catch(t){}else if("undefined"!=typeof console.error&&null!==console.error)try{console.error(n)}catch(t){}else if("undefined"!=typeof console.log&&null!==console.log)try{console.log(n)}catch(t){}}}catch(o){webphone_api.common.PutToDebugLogSpecial(2,"EVENT, plhandler WapiTouced",!0,o)}}function Yn(e,n){webphone_api.common.isNull(e)||e.length<1||(Qn(),webphone_api.common.isNull(to)&&(to=[]),webphone_api.common.isNull(n)&&(n=[]),webphone_api.common.PutToDebugLog(2,"EVENT,AddToQueueEn cached for execution after engine start ("+webphone_api.global.phonestarted.toString()+" "+webphone_api.global.wploaded.toString()+") : "+e.toLowerCase()+"("+n.toString()+")"),n.unshift(e),n.unshift(webphone_api.common.GetTickCount().toString()),to.push(n))}function Qn(){webphone_api.common.isNull(oo)&&(oo=setInterval(function(){if(++io>1e5||io>1e5&&(webphone_api.common.isNull(to)||to.length<1||webphone_api.global.phonestarted>=2))return void 0!==oo&&null!==oo&&clearInterval(oo),oo=null,to=[],void(io=0);if(!(webphone_api.common.isNull(to)||to.length<1)&&webphone_api.global.phonestarted>=2){var e=to.shift();if(webphone_api.common.isNull(e)||e.length<2)return;var n=0;try{n=webphone_api.common.StrToInt(e[0])}catch(i){}e.shift();var t=e[0];if(webphone_api.common.isNull(t)||t.length<1)return void webphone_api.common.PutToDebugLog(2,"ERROR, handle API function queue invalid name(engine: "+webphone_api.common.getuseengine()+"): "+t);if(webphone_api.common.GetTickCount()-n>6e5)return void webphone_api.common.PutToDebugLog(2,"ERROR, handle API function queue(engine: "+webphone_api.common.getuseengine()+"): "+t+" (too late)");e.shift();var o="";webphone_api.common.isNull(e)||(o=e.toString()),webphone_api.common.PutToDebugLog(2,"EVENT, handle API function queue(engine: "+webphone_api.common.getuseengine()+"): "+t+" ("+o+");"),Zn(t,e)}},15))}function Zn(e,n){var t=window.webphone_api.plhandler[e];"function"==typeof t&&t.apply(window,n)}function et(e){try{if(webphone_api.common.isNull(e)||e.length<1||webphone_api.common.isNull(webphone_api.origparameters))return"";if("undefined"!=typeof webphone_api.origparameters[e]&&null!=webphone_api.origparameters[e]&&webphone_api.origparameters[e].toString().length>0){var n=webphone_api.origparameters[e];return!webphone_api.common.isNull(n)&&n.toString().length>0&&n.toString().indexOf("dcid_")>=0&&(n=webphone_api.common.StrDc(n.toString(),"X9hAm21TaGzqeR45Bj")),webphone_api.common.isNull(n)?"":n}}catch(t){webphone_api.common.PutToDebugLogException(2,"plhandler: GetOrigConfigParam ("+e+")",t)}return""}function nt(e){var n=0;try{if(n=1,webphone_api.common.isNull(e)||e.length<1)return"";n=2;var t=webphone_api.common.GetConfig(e);n=3;var o=webphone_api.common.GetConfigAll(!0);if(n=4,!webphone_api.common.isNull(o)){n=5;var i="overwrite_"+e;n=21,"undefined"!=typeof o[i]&&null!==o[i]&&o[i].toString().length>0&&(n=22,t=o[i].toString())}n=6,"undefined"!=typeof webphone_api.parameters[e]&&null!=webphone_api.parameters[e]&&webphone_api.parameters[e].toString().length>0&&(n=23,t=webphone_api.parameters[e]),n=7;var a=window.location.href;if(!webphone_api.common.isNull(a)){n=8;var r=webphone_api.common.GetUrlParamVal(a,e);n=24,!webphone_api.common.isNull(r)&&r.toString().length>0&&(n=25,t=r)}return n=9,(!webphone_api.common.isNull(t)&&t.toString().length>0&&t.toString().indexOf("dcid_")>=0&&(n=10,t=webphone_api.common.StrDc(t.toString(),"X9hAm21TaGzqeR45Bj")),n=11,webphone_api.common.isNull(t))?"":(n=12,t)}catch(l){webphone_api.common.PutToDebugLogException(2,"plhandler GetCCParam "+n+" ("+e+")",l)}return""}function tt(){try{var e=nt("serveraddress"),n=nt("webrtcserveraddress"),t=nt("proxyaddress"),o=nt("transport"),i=nt("realm"),a=et("serveraddress"),r=et("webrtcserveraddress"),l=et("proxyaddress"),s=et("transport"),p=et("realm");webphone_api.common.isNull(e)&&(e=""),webphone_api.common.isNull(n)&&(n=""),webphone_api.common.isNull(t)&&(t=""),webphone_api.common.isNull(o)&&(o=""),webphone_api.common.isNull(i)&&(i=""),webphone_api.common.isNull(a)&&(a=""),webphone_api.common.isNull(r)&&(r=""),webphone_api.common.isNull(l)&&(l=""),webphone_api.common.isNull(s)&&(s=""),webphone_api.common.isNull(p)&&(p=""),e=e.toString().toLowerCase(),n=n.toString().toLowerCase(),t=t.toString().toLowerCase(),o=o.toString().toLowerCase(),i=i.toString().toLowerCase(),a=a.toString().toLowerCase(),r=r.toString().toLowerCase(),l=l.toString().toLowerCase(),s=s.toString().toLowerCase(),p=p.toString().toLowerCase();return e+n+i+t+o+a+r+p+l+s}catch(c){webphone_api.common.PutToDebugLogException(2,"plhandler: GetMainConfigsAsString",c)}return""}function ot(){try{if(ao)return;var e=webphone_api.common.GetParameter("lastwpapixxx"),n=Ee("configversion"),t=Ee("prevconfigversion");if(webphone_api.common.isNull(t)||!webphone_api.common.IsNumber(t)){var o=n;!webphone_api.common.isNull(o)&&webphone_api.common.IsNumber(o)||(o=0),webphone_api.common.SaveParameter("prevconfigversion",o)}var i=tt();!webphone_api.common.isNull(n)&&webphone_api.common.IsNumber(n)&&n>0&&!webphone_api.common.isNull(t)&&webphone_api.common.IsNumber(t)&&n!==t?(ao=!0,webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"WARNING, DelSettings on start because configversion new: "+n+", old: "+t),ln(0,!1)):!webphone_api.common.isNull(e)&&e.length>0&&!webphone_api.common.isNull(i)&&i.length>0?(ao=!0,e!==i?(webphone_api.common.CanLog(2)&&(webphone_api.common.PutToDebugLog(2,"WARNING, DelSettings on start because main configs changed x"),webphone_api.common.PutToDebugLog(4,"EVENT, DelSettings old config: "+e),webphone_api.common.PutToDebugLog(4,"EVENT, DelSettings new config: "+i)),ln(0,!1),webphone_api.common.CanLog(2)&&(webphone_api.common.PutToDebugLog(4,"EVENT, DelSettings new2 config: "+tt()),webphone_api.common.PutToDebugLog(4,"EVENT, DelSettings new3 config: "+Ee("serveraddress")+Ee("webrtcserveraddress")+Ee("realm")+Ee("proxyaddress")+Ee("transport")))):webphone_api.common.CanLog(6)&&webphone_api.common.PutToDebugLog(6,"EVENT, check config change old: "+e+", new: "+i)):webphone_api.common.CanLog(5)&&(!webphone_api.common.isNull(i)&&i.length>0?webphone_api.common.PutToDebugLog(5,"EVENT, check config change old: null, new: "+i):!webphone_api.common.isNull(e)&&e.length>0&&webphone_api.common.PutToDebugLog(5,"EVENT, check config change old: "+e+", new: null")),!webphone_api.common.isNull(i)&&i.length>0&&webphone_api.common.SaveParameter("lastwpapixxx",i)}catch(a){webphone_api.common.PutToDebugLogException(2,"plhandler: ConfigChanged",a)}}var it="",at=!1,rt=null;webphone_api.global.isfirststart=!0,1==webphone_api.common.IsSDK()&&(webphone_api.common.PutToDebugLogSpecial(1,"EVENT, plhandler call HandleSettingsSDK",!1,""),webphone_api.global.domloaded_tick=webphone_api.common.GetTickCount(),a(function(n){if(webphone_api.common.PutToDebugLogSpecial(1,"EVENT, plhandler onload HandleSettingsSDK FINISHED: "+n,!1,""),webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, plhandler: initialize start"),webphone_api.common.Glv()<1)return void(webphone_api.global.webrtcavailable=0);webphone_api.$(document).ready(function(){webphone_api.loadwebrtc_timestamp=webphone_api.common.GetTickCount();var n=webphone_api.common.GetForcedEngine();if(n&&"webrtc"!=n.name)return webphone_api.global.webrtcavailable=0,webphone_api.common.PutToDebugLog(2,"webrtc engine not needed"),void(!0===webphone_api.common.UseCustomAutoprov(!0)?webphone_api.common.GetCustomAutoprov(function(n){webphone_api.common.RecAutoprovCustom(n),e()}):e());webphone_api.webrtcapi.WebRtcIsSupported(function(n){var t="";if(t+=n?"A":"b","Windows"===webphone_api.common.GetOs()&&("MSIE"===webphone_api.common.GetBrowser()?(t+="c",n=!1):"Edge"===webphone_api.common.GetBrowser()&&(webphone_api.common.GetBrowserVersion()<14?(t+="d",n=!1):!1===n&&(t+="e",webphone_api.common.PutToDebugLog(2,"ERROR,plhandler Edge webrtc is not supported, getusermedia: "+typeof navigator.getUserMedia+"; RTCPeerConnection: "+typeof window.RTCPeerConnection)))),"iOS"===webphone_api.common.GetOs()?(("Safari"===webphone_api.common.GetBrowser()||"iPhone"===webphone_api.common.GetBrowser())&&webphone_api.common.GetBrowserVersion()<11&&(n=!1,t+="f"),"Firefox"!==webphone_api.common.GetBrowser()||navigator.mozGetUserMedia||navigator.GetUserMedia||(n=!1,t+="g"),"Chrome"!==webphone_api.common.GetBrowser()||navigator.webkitGetUserMedia||navigator.GetUserMedia||(n=!1,t+="h")):"Windows"===webphone_api.common.GetOs()&&"Safari"===webphone_api.common.GetBrowser()&&(t+="i",n=!1),webphone_api.common.isNull(n)&&(n="",t+="j"),webphone_api.common.PutToDebugLog(2,"EVENT, plhandler: Webrtc engine available at plh: "+n+" "+t),!0===n){webphone_api.global.webrtcavailable=1;var o=webphone_api.common.GetEngine("webrtc"),i=webphone_api.common.GetParameter2("serveraddress_user");(webphone_api.common.isNull(i)||i.length<2)&&(i=webphone_api.common.GetParameter2("serveraddress")),(webphone_api.common.isNull(i)||i.length<2)&&(i=webphone_api.common.GetConfig("serveraddress")),webphone_api.common.isNull(i)&&(i="");var a=!1;webphone_api.common.CanUseAnyAddrForWebRTC()||(1==webphone_api.common.IsLanIPEx(webphone_api.common.GetWebrtcUpperServer())?a=!0:0==webphone_api.common.IsLanIPEx(webphone_api.common.GetWebrtcUpperServer())||1==webphone_api.common.IsLanIPEx(i)&&(a=!0)),a?webphone_api.common.isNull(o)||(o.issupported_cache=0,o.available=0):!0===webphone_api.common.BrowserRequiresHttps(!0)?webphone_api.common.isNull(o)||(o.issupported_cache=1,o.available=2):webphone_api.common.isNull(o)||(o.issupported_cache=2,o.available=3)}else!1===n&&(webphone_api.global.webrtcavailable=0,webphone_api.common.PutToDebugLog(2,"EVENT, webrtc engine NOT available (b) "+t));!0===webphone_api.common.UseCustomAutoprov(!0)?webphone_api.common.GetCustomAutoprov(function(n){webphone_api.common.RecAutoprovCustom(n),e()}):e()})})}));var lt=null,st=!1,pt=null,ct=!1,ut=null,gt=10,ht=185,mt=null,dt=null,bt=!1,_t=0,ft="",wt=!1,vt=null,Et=0,Pt=0,Tt=!0,St=!1,Nt=!1,It=null,Ct=-1,Gt=0,Lt=0,Rt=null,yt=null,Dt=!1,Ot=0,xt=null,At=0,kt=0,Ut=null,Vt=[],Wt=[],Ft=null,Mt=null,Ht=!1,Bt=[],jt=[],$t=null,qt=[],zt=[],Kt=null,Xt=[],Jt=[],Yt=[],Qt=[],Zt=[],eo=null,no=!1,to=[],oo=null,io=0,ao=!1;return{Start:n,StartUp:i,Register:m,RegisterEx:b,CheckPresence:_,SetPresenceStatus:f,CheckBLF:w,GetVersionNS:v,GetVersionNSNum:E,GetVersionJava:P,IsEncrypted:T,SetSipHeader:S,GetSipHeader:I,GetSipHeaderInternal:N,GetSipMessage:C,ChangeTheme:G,GetWorkDir:L,Call:x,CallDelayed:A,VideoCall:R,MuteVideo:y,ScreenShare:D,StopScreenShare:U,Hangup:V,Accept:F,Reject:M,Ignore:H,SetVideoSize:B,GetAvailableCallfunc:j,Forward:$,Conference:z,Transfer:K,Dtmf:X,MuteEx:J,IsMuted:Y,Hold:Q,IsOnHold:ee,SendChat:ne,SendSms:oe,Voicerecord:ie,DevicePopup:le,SetVolume:se,GetVolume:pe,SetLoudspeaker:ce,PlaySound:ue,AddContact:ge,SaveTheContact:he,DeleteContact:me,DeleteAllContacts:de,DownloadServerAddressbook:yn,GetContact:_e,ListContacts:fe,ListCallhistory:we,SetParameter:ve,GetParameter:Ee,SetLine:Pe,GetLine:Te,LineToCallID:Se,CallIDToLine:Ne,NextCallID:Ge,IsRegistered:Ae,IsInCall:ke,GetDeviceList:Ue,GetDevice:Ve,SetDevice:We,StopEngine:Fe,Stop:Me,HelpWindow:je,BrowserWindowIsActive:Be,SettingsPage:$e,DialPage:qe,MessageInboxPage:ze,MessagePage:Ke,AddContactPage:Xe,InsertApplet:Je,EnterKeyPress:Ye,FileTransferCallback:Qe,GetTelsearchName:Ze,CallWsuser:t,Cfin:O,bwanswer:en,onappexit:nn,getlogs:tn,getlogsex:on,putlogs:an,ImportContacts:rn,delsettings:ln,needratingrequest:sn,IsMobileBrowser:pn,Getenginename:cn,GetLastInvite:un,GetLastRecInvite:gn,GetLastSentInvite:hn,getstringresource:fn,Jvoip:wn,GetStatus:ae,GetRegFailReason:re,Unregister:De,UnregisterEngine:Oe,HTTPKeepAlive:xe,GetLineDetails:Le,GetLastCallDetails:Re,GetIncomingDisplay:ye,ParseReceivedParameters:l,GetOneStunSrv:vn,HandleWebrtcCodecs:Tn,HandleWebrtcCodecsAudio:Sn,HandleWebrtcCodecsVideo:Nn,HandleWebrtcPrefCodec:In,HandleWebrtcPrefCodecAudio:Cn,HandleWebrtcPrefCodecVideo:Gn,HandleWebrtcFirefoxHold:Ln,HandleWebrtcFirefoxHold_RemoveDuplicateHeader:Rn,IsServiceInstalled:On,CanIUseWebrtc:xn,API_SetCredentials:Un,API_SetCredentialsMD5:Vn,API_CheckVoicemail:Wn,API_SetLine:Fn,API_GetLine:Mn,API_GetLineStatus:Hn,API_Forward:Bn,API_IsMuted:jn,API_IsOnHold:$n,API_GetAudioDeviceList:qn,API_GetAudioDevice:zn,API_SetAudioDevice:Kn,API_GetVolume:Xn,API_RecFiles_Upload:mn,API_RecFiles_UploadEx:dn,API_RecFiles_Clear:bn,API_RecFiles_Del:_n,SendChatIsComposing:He,ShowToast:An,AlertDialog:kn,LoginSkin:g,GetAudioDevicesForMenu:h,ConfigChanged:ot}}(),webphone_api.webphone=function(){function e(){try{webphone_api.common.PutToDebugLog(2,"EVENT, webphone Init called"),Me=!1,He=null,Be=0,je=!1,$e=!0,qe=!1,ze=!1,Qe=!1,Ze=0,webphone_api.webphone_pollstatus=!0,webphone_api.global.apppletloaded=!1}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: Init",e)}}function n(){try{webphone_api.common.PutToDebugLog(2,"EVENT, webphone: CheckWebphonetojs called"),void 0!==Ye&&null!==Ye&&clearTimeout(Ye),Ye=setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, webphone: CheckWebphonetojs starting timer"),!0===webphone_api.webphone_pollstatus&&(webphone_api.common.PutToDebugLog(2,"EVENT, webphone: CheckWebphonetojs starting status polling"),qe=!0,webphone_api.global.polltimerid=setInterval(function(){webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WEBPHONE()&&He&&He.API_Poll&&webphonetojs(He.API_Poll())},Xe))},Je),setTimeout(function(){!0===qe&&webphone_api.common.WinAPI("API_RegisterNoParam",function(){webphone_api.common.PutToDebugLog(2,"ERROR, webphone API_RegisterNoParam called")})},Je+1e3)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: CheckWebphonetojs",e)}}function t(){try{webphone_api.common.PutToDebugLog(1,"EVENT, "+webphone_api.stringres.get("initializing")),e();try{if(!webphone_api.common.isNull(webphone_api.global.settmap2)){for(var n in webphone_api.global.settmap2){var t=webphone_api.global.settmap2[n];if(!webphone_api.common.isNull(t)&&!(n.indexOf("server")<0&&n.indexOf("username")<0&&n.indexOf("password")<0&&"1"===t[webphone_api.common.SETT_ISDEFAULT])){if("username"===n||"sipusername"===n||"password"===n){var i=t[webphone_api.common.SETT_VALUE];if(!webphone_api.common.isNull(i)&&i.length>0){i=o(i),Ke[n]=i;continue}}if("serveraddress"===n){var i=t[webphone_api.common.SETT_VALUE],a=Ke.serveraddress;if((webphone_api.common.isNull(i)||i.length<1)&&a.length>1)continue;if((webphone_api.common.isNull(a)||a.length<1)&&(webphone_api.common.isNull(i)||i.length<1)){Ke.serveraddress=webphone_api.common.GetParameter("serveraddress_user");continue}}else if("serveraddress_orig"===n)n="serveraddress";else if("upperserver"===n){var i=t[webphone_api.common.SETT_VALUE],a=webphone_api.common.GetParameter("serveraddress_orig");i===a||i.length<1?Ke[n]="":Ke[n]=webphone_api.common.GetParameter("serveraddress_orig")}else"aec"===n?n="aec_orig":"agc"===n?n="agc_orig":"denoise"===n?n="denoise_orig":"plc"===n?n="plc_orig":"has_video"===n?"0"===webphone_api.common.GetParameter2("video")?Ke[n]="false":Ke[n]="true":Ke[n]=t[webphone_api.common.SETT_VALUE]}}var r=webphone_api.common.GetParameter("extraoption");if(!webphone_api.common.isNull(r)&&r.length>0){r=webphone_api.common.Trim(r);var l=r.split(";");if(!webphone_api.common.isNull(l)&&l.length>0)for(var s=0;s0&&!webphone_api.common.isNull(t)&&(Ke[n]=t)}}}webphone_api.common.GetConfig("upperserverip").length>0&&(Ke.upperserverip=webphone_api.common.GetConfig("upperserverip")),webphone_api.common.GetConfig("upperserverdomain").length>0&&(Ke.upperserverdomain=webphone_api.common.GetConfig("upperserverdomain")),Ke.jsscriptevent=3,(webphone_api.common.isNull(Ke.serveraddress_orig)||Ke.serveraddress_orig.length<1)&&(Ke.serveraddress_orig=Ke.serveraddress);var p=webphone_api.parameters.customsipheader;if(!webphone_api.common.isNull(p)&&p.length>0&&(p=webphone_api.common.Trim(p), !webphone_api.common.isNull(Ke.customsipheader)&&Ke.customsipheader.toString().length>0?Ke.customsipheader.lastIndexOf(";")0){for(var s=0;s0&&(Ke.extraregisteraccounts=Ke.extraregisteraccounts+";"),Ke.extraregisteraccounts=Ke.extraregisteraccounts+u+","+m+","+h+","+c.ival+","+b+","+_+","+g}}var f=webphone_api.common.GetExtraRegAccFromAPIparam();!webphone_api.common.isNull(f)&&f.length>5&&(Ke.extraregisteraccounts.length>0&&(Ke.extraregisteraccounts=Ke.extraregisteraccounts+";"),Ke.extraregisteraccounts=Ke.extraregisteraccounts+f)}Ke.autohold="0",Ke.automute="0",webphone_api.common.CanLog(4)&&webphone_api.common.LogAllParameters("Webphone all parameters:",Ke)}catch(w){webphone_api.common.PutToDebugLogException(2,"webphone: Start Setting parameters",w)}de(),setTimeout(function(){on=webphone_api.common.GetTickCount(),_e()},1e3)}catch(w){webphone_api.common.PutToDebugLogException(2,"webphone: Start",w)}}function o(e){try{if(webphone_api.common.isNull(e))return webphone_api.common.PutToDebugLog(2,"ERROR, wp B4 invalid extracted value"),"";if(e.length<1)return"";var n=e;if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA){if(n.indexOf("=")>=0)return n="Bb7Sb2VVVVV_"+webphone_api.common.B64Enc(n)}else if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE||!0===webphone_api.common.IsWindowsSoftphone()){var t=webphone_api.common.GetParameterInt("srvupgrade_currversion",0);if(t>18&&(n.indexOf("%")>=0||n.indexOf("^")>=0||n.indexOf("&")>=0||n.indexOf("<")>=0||n.indexOf(">")>=0||n.indexOf("|")>=0||n.indexOf("'")>=0||n.indexOf("`")>=0||n.indexOf(",")>=0||n.indexOf(";")>=0||n.indexOf("=")>=0||n.indexOf("(")>=0||n.indexOf(")")>=0||n.indexOf("!")>=0||n.indexOf('"')>=0||n.indexOf("\\")>=0||n.indexOf("[")>=0||n.indexOf("]")>=0||n.indexOf('"')>=0||n.indexOf(".")>=0||n.indexOf("*")>=0||n.indexOf("?")>=0))return n="Bb7Sb2VVVVV_"+webphone_api.common.B64Enc(n)}}catch(o){webphone_api.common.PutToDebugLogException(2,"webphone: B64EncUserPwd",o)}return e}function i(){function t(e){S&&(webphone_api.common.PutToDebugLog(2,"EVENT, webphone: StartWin: API_SetParameters called"),webphone_api.common.PutToDebugLog(4,"EVENT, webphone: StartWin: API_SetParameters paramlist: "+l)),i=37,webphone_api.common.WinAPI("API_SetParameters",function(e){Qe=!0,Ze=0,i=41,webphone_api.common.isNull(e)&&(e=""),e=e.toString(),e=e.toLowerCase(),e.indexOf("ok:")<0&&e.indexOf("true")<0&&webphone_api.common.PutToDebugLog(2,"ERROR, webphone: StartWin: API_SetParameters callback: failed to save settings"),i=42,webphone_api.global.apistartstate=1,webphone_api.global.apistarttick=webphone_api.common.GetTickCount(),webphone_api.common.WinAPI("API_Start",function(e){i=43,webphone_api.common.SetDID(),ze=!0,i=44,webphone_api.common.isNull(e)&&(e=""),e=e.toString(),e=e.toLowerCase(),e.indexOf("ok:")<0&&e.indexOf("true")<0?(i=45,webphone_api.common.PutToDebugLog(2,"ERROR, webphone: StartWin: API_Start callback: failed to start webphone (1), answ: "+e)):(i=46,r(),setTimeout(function(){webphone_api.global.phonestarted<2&&(webphone_api.global.phonestarted=2)},1e3))},webphone_api.common.GetBrowserSessionID()),i=47,n()},e),setTimeout(function(){webphone_api.common.GetSrvVersions()},1e3)}var i=0;webphone_api.common.PutToDebugLog(2,"EVENT, webphone: StartWin called"),webphone_api.common.PutToDebugLog(1,"EVENT, "+webphone_api.stringres.get("initializing"));try{e(),i=1;var a="",l="",s=[];if(!webphone_api.common.isNull(webphone_api.global.settmap2)){i=2;for(var p in webphone_api.global.settmap2)if(!(webphone_api.common.isNull(p)||p.length<1)){var c=webphone_api.global.settmap2[p];"has_video"===p&&("0"===webphone_api.common.GetParameter2("video")?c[0]="false":c[0]="true"),p.indexOf("server")<0&&p.indexOf("username")<0&&p.indexOf("password")<0&&"1"===c[webphone_api.common.SETT_ISDEFAULT]||(s[p]=c[0])}i=3}var u=webphone_api.common.GetParameterInt("nsloglevel",webphone_api.common.GetLogLevel());i=4;for(var p in Ke)if(!(webphone_api.common.isNull(p)||p.length<1||"username"===p&&!webphone_api.common.isNull(s[p])&&s[p].length>0&&(webphone_api.common.isNull(Ke[p])||Ke[p].length<1)||0==p.indexOf("pgw"))){if("loglevel"===p)try{s.jsscriptevent=u>1?"3":"2"}catch(L){}s[p]=Ke[p]}i=5,!webphone_api.common.isNull(webphone_api.common.GetConfig("upperserverip"))&&webphone_api.common.GetConfig("upperserverip").length>0&&(s.upperserverip=webphone_api.common.GetConfig("upperserverip")),i=11,!webphone_api.common.isNull(webphone_api.common.GetConfig("upperserverdomain"))&&webphone_api.common.GetConfig("upperserverdomain").length>0&&(s.upperserverdomain=webphone_api.common.GetConfig("upperserverdomain")),i=12,webphone_api.common.isNull(s.serveraddress_orig||s.serveraddress_orig.length<1)&&(s.serveraddress_orig=s.serveraddress),i=13;var g=webphone_api.parameters.customsipheader;if(!webphone_api.common.isNull(g)&&g.length>0&&(i=14,g=webphone_api.common.Trim(g),!webphone_api.common.isNull(s.customsipheader)&&s.customsipheader.toString().length>0?(i=15,s.customsipheader.lastIndexOf(";")0){for(var h=0;h0&&(s.extraregisteraccounts=s.extraregisteraccounts+";"),s.extraregisteraccounts=s.extraregisteraccounts+d+","+f+","+_+","+m.ival+","+v+","+E+","+b}}var P=webphone_api.common.GetExtraRegAccFromAPIparam();!webphone_api.common.isNull(P)&&P.length>5&&(Ke.extraregisteraccounts.length>0&&(s.extraregisteraccounts=s.extraregisteraccounts+";"),s.extraregisteraccounts=s.extraregisteraccounts+P)}s.loglevel=u.toString(),s.jsscriptevent=u>1?"3":"2";var T=!1;(webphone_api.common.GetLogLevel()>=7||!0===webphone_api.global.isdebugversion&&webphone_api.common.GetLogLevel()>=5)&&(T=!0);var S=!1;webphone_api.common.CanLog(2)&&(S=!0);for(var p in s)if(!(webphone_api.common.isNull(p)||p.length<1||"callto"===p||"platform"===p)){if(p.length>9){if(0==p.indexOf("transfertype")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("transfwithreplace")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("allowreplace")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("discontransfer")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("disconincomingrefer")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("inversetransfer")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("transferdelay")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("newdialogforrefer")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("useserverdomainforrefer")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue;if(0==p.indexOf("holdontransfer")&&p.charAt(p.length-1)>="0"&&p.charAt(p.length-1)<="9")continue}"autohold"!==p&&"automute"!==p||(s[p]="0"),"sippassword"===p&&(p="password");var N=s[p];webphone_api.common.isNull(N)||(N=N.toString()),"password"===p&&!webphone_api.common.isNull(N)&&N.length>0&&(N=o(N)),webphone_api.common.isNull(N)||N.length<=0||(a.length>0&&(a+="\r\n"),a=a+p+"="+N,S&&(!T&&(p.indexOf("password")>=0||"extraregisteraccounts"===p)||"passphrase"==p||"serverapikey"==p?(l.length>0&&(l+="\r\n"),l=l+p+"= *"):!T&&(0==p.indexOf("pgw")||N.indexOf("com.mizuvoip.mizudroid")>=0||N.indexOf("app/mizuphone")>=0||p.indexOf("transfwithreplace")>=0&&"-1"==N||p.indexOf("log_email")>=0&&N.indexOf("mizu")>=0||p.indexOf("domaintoip_cache")>=0||"get"==p||"getAll"==p||"usingmizuserveronly"==p||p.indexOf("supportend")>=0||"demoversion"==p||"demoyear"==p||"demomonth"==p||"demoday"==p)||(l.length>0&&(l+="\r\n"),l=l+p+"="+N)))}i=22;var I="";I=I+"\r\nminserviceversion="+webphone_api.common.GetMinServiceVersion(),i=27,"rigitel"===webphone_api.common.GetConfig("brandname").toLowerCase()&&(I+="\r\nhasincomingcall=false");var C=webphone_api.common.GetNPLocation();i=31,webphone_api.common.isNull(C)&&(C=""),i=32;var G=C.indexOf("native/");G>0&&(C=C.substr(0,G)),i=33,I=I+"\r\nlanguage="+webphone_api.stringres.getlang(),I+="\r\ntranslatemode=2",I=I+"\r\nwebphoneurl="+C,i=34,I+="\r\ndummy=3",i=35,I="akarmidw=true\r\n"+I,i=36,a+=I,S&&(l+=I),t(a),en=setInterval(function(){return!0===Qe?(webphone_api.common.isNull(en)||clearInterval(en),en=null,void(Ze=0)):++Ze>15?(webphone_api.common.PutToDebugLog(2,"ERROR, API_Setparameters timer reached maxloop"),webphone_api.common.isNull(en)||clearInterval(en),void(en=null)):(webphone_api.common.PutToDebugLog(2,"ERROR, API_Setparameters try to send parameters again, because earlier send failed"),void t(a))},1e3),i=51,setTimeout(function(){i=52,ze||!0!==Qe||(i=53,webphone_api.global.apistartstate=1,webphone_api.global.apistarttick=webphone_api.common.GetTickCount(),webphone_api.common.WinAPI("API_Start",function(e){i=54,webphone_api.common.SetDID(),webphone_api.common.isNull(e)&&(e=""),e=e.toString(),e=e.toLowerCase(),e.indexOf("ok:")<0&&e.indexOf("true")<0?(i=55,webphone_api.common.PutToDebugLog(2,"ERROR, webphone: StartWin: API_Start callback: failed to start webphone (2) answ: "+e)):(i=56,r())},webphone_api.common.GetBrowserSessionID())),i=57,ze=!1},2500),webphone_api.common.GetCustomMenus(),i=58}catch(R){webphone_api.common.PutToDebugLogException(2,"webphone: StartWin ("+i.toString()+")",R)}}function a(){try{webphone_api.common.PutToDebugLog(3,"EVENT, StartService"),i()}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: StartService",e)}}function r(){}function l(){try{return fe()?He.API_Restart():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Restart(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: Restart",e)}}function s(e){try{return fe()?He.API_PushContactlist(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: PushContactlist(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: PushContactlist",n)}}function p(e){try{return fe()?He.API_CheckPresence(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: CheckPresence(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: CheckPresence",n)}}function c(e){try{return fe()?He.API_SetPresenceStatus(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetPresenceStatus(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: SetPresenceStatus",n)}}function u(e){try{return fe()?He.API_CheckBLF(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: CheckBLF(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: CheckBLF",n)}return!1}function g(){try{return fe()?He.API_GetExeVersion():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetVersionNS(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: GetVersionNS",e)}return 0}function h(){try{return fe()?He.API_GetExeVersionNumber():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetVersionNSNum(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: GetVersionNSNum",e)}return 0}function m(){try{return fe()?He.API_GetVersion():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetVersionJava(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: GetVersionJava",e)}return 0}function d(){try{return fe()?He.API_IsEncrypted():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: IsEncrypted(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: IsEncrypted",e)}return 0}function b(e){try{return fe()?He.RegisterEx(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: RegisterEx(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: RegisterEx",n)}}function _(e,n){try{return fe()?He.API_SetSIPHeader(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetSipHeader(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: SetSipHeader",t)}}function f(e,n){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetSipHeader(), no applethandle "),"ERROR, webphone: GetSipHeader(), no applethandle";return He.API_GetSIPHeader(e,n)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: GetSipHeader",t)}return""}function w(e,n){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetSipHeaderInternal(), no applethandle "),"ERROR, webphone: GetSipHeader(), no applethandle";return He.API_GetSipHeaderInternal(e,n)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: GetSipHeaderInternal",t)}return""}function v(e,n,t){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetSipMessage(), no applethandle "),"ERROR, webphone: GetSipMessage(), no applethandle";return He.API_GetSIPMessage(e,n,t)}catch(o){webphone_api.common.PutToDebugLogException(2,"webphone: GetSipMessage",o)}return""}function E(e,n){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetGetLastInvite(), no applethandle "),"";n(He.API_GetLastInvite(e))}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: GetGetLastInvite",t)}n("")}function P(e,n){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetGetLastRecInvite(), no applethandle "),"";n(He.API_GetGetLastRecInvite(e))}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: GetGetLastRecInvite",t)}n("")}function T(e,n){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetGetLastSentInvite(), no applethandle "),"";n(He.API_GetGetLastSentInvite(e))}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: GetGetLastSentInvite",t)}n("")}function S(){try{return fe()?He.API_GetWorkdir():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetWorkDir(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: GetWorkDir",e)}return""}function N(){try{return fe()?He.API_Unregister():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Unregister(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: Unregister",e)}}function I(){try{return fe()?He.API_ReRegister():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: ReRegister(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: ReRegister",e)}}function C(){try{return fe()?He.API_HTTPKeepAlive():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: HTTPKeepAlive(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: HTTPKeepAlive",e)}}function G(e,n){try{return fe()?He.API_Call(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Call(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: Call",t)}}function L(e){try{return fe()?He.API_Hangup(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Hangup(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: Hangup",n)}}function R(e){try{return fe()?He.API_Accept(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Accept(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: Accept",n)}}function y(e){try{return fe()?He.API_Reject(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Reject(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: Reject",n)}}function D(e){try{return fe()?He.API_Ignore(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Ignore(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: Ignore",n)}}function O(e,n){try{return fe()?He.API_Forward(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Forward(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: Forward",t)}}function x(e){try{return fe()?He.API_Conf(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Conference(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: Conference",n)}}function A(e,n,t){try{return fe()?He.API_ConfEx(e,n,t):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: ConferenceEx(), no applethandle "),!1)}catch(o){webphone_api.common.PutToDebugLogException(2,"webphone: ConferenceEx",o)}}function k(e,n){try{return fe()?He.API_Transfer(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Transfer(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: Transfer",t)}}function U(e,n){try{return fe()?He.API_Dtmf(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Dtmf(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: Dtmf",t)}}function V(e,n,t){try{return fe()?He.API_MuteEx(e,n,t):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: MuteEx(), no applethandle "),!1)}catch(o){webphone_api.common.PutToDebugLogException(2,"webphone: MuteEx",o)}}function W(e){try{return fe()?He.API_IsMuted(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: IsMuted(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: IsMuted",n)}}function F(e,n){try{return fe()?He.API_Hold(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Hold(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: Hold",t)}}function M(e){try{return fe()?He.API_IsOnHold(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: IsOnHold(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: IsOnHold",n)}}function H(e,n,t,o){try{return fe()?He.API_SendChat(e,n,t,o):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SendChat(), no applethandle "),!1)}catch(i){webphone_api.common.PutToDebugLogException(2,"webphone: SendChat",i)}}function B(e,n,t){try{return fe()?He.API_VoiceRecord(e,n,t):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: VoiceRecord(), no applethandle "),!1)}catch(o){webphone_api.common.PutToDebugLogException(2,"webphone: VoiceRecord",o)}}function j(){try{return fe()?He.API_AudioDevice():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: AudioDevice(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: AudioDevice",e)}}function $(e,n){try{return fe()?He.API_SetVolume(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetVolume(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: SetVolume",t)}}function q(e){try{return fe()?He.API_GetVolume(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetVolume(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: GetVolume",n)}}function z(e,n,t,o,i,a,r){try{return fe()?He.API_PlaySound(e,n,t,o,i,a,r):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: PlaySound(), no applethandle "),!1)}catch(l){webphone_api.common.PutToDebugLogException(2,"webphone: PlaySound",l)}return!1}function K(e,n){var t="";try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetRegFailReason(), no applethandle "),!1;t=He.API_GetRegFailReason(n)}catch(o){webphone_api.common.PutToDebugLogException(2,"webphone: GetVolume",o)}e(t)}function X(e,n){try{if(!je)return;return webphone_api.common.isNull(webphone_api.global.maintimerid)?(webphone_api.common.PutToDebugLog(3,"EVENT, webphone: SetParameter: cannot set parameter, because webphone is not running"),!1):"callto"!==e&&(fe()?He.API_SetParameter(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetParameter(), no applethandle "),!1))}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: SetParameter",t)}}function J(e){try{if(webphone_api.common.isNull(e)||e<-4||e>35)return webphone_api.common.PutToDebugLog(3,"EVENT, webphone: SetLine: invalid line"),!1;if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetLine(), no applethandle "),!1;He.API_SetLine(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: SetLine",n)}}function Y(e){try{if(webphone_api.common.isNull(e))return webphone_api.common.PutToDebugLog(3,"EVENT, webphone: SetLineEx: invalid line"),!1;if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetLineEx(), no applethandle "),!1;He.API_SetLineEx(e)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: SetLine",n)}}function Q(){try{return fe()?He.API_GetLine():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetLine(), no applethandle "),-1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: GetLine",e)}return-1}function Z(e){try{return fe()?He.API_LineToCallID(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: LineToCallID(), no applethandle "),-1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: LineToCallID",n)}return""}function ee(e){try{return fe()?He.API_CallIDToLine(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: CallIDToLine(), no applethandle "),-1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: CallIDToLine",n)}return-10}function ne(e){try{return fe()?He.API_NextCallID(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: NextCallID(), no applethandle "),-1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: NextCallID",n)}return""}function te(e){try{return fe()?He.API_GetLineDetails(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetLineDetails(), no applethandle "),"")}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: GetLineDetails",n)}return""}function oe(){try{return fe()?He.API_IsRegistered():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: IsRegistered(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: IsRegistered",e)}}function ie(e){try{return fe()?He.API_GetAudioDeviceList(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetAudioDeviceList(), no applethandle "),"")}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: GetAudioDeviceList",n)}}function ae(e){try{return fe()?He.API_GetAudioDevice(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetAudioDevice(), no applethandle "),"")}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: GetAudioDevice",n)}}function re(e,n,t){try{return fe()?He.API_SetAudioDevice(e,n,t):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetAudioDevice(), no applethandle "),!1)}catch(o){webphone_api.common.PutToDebugLogException(2,"webphone: SetAudioDevice",o)}}function le(e,n,t,o){try{return fe()?He.API_SetPushNotifications(e,n,t,o):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SetPushNotifications(), no applethandle "),!1)}catch(i){webphone_api.common.PutToDebugLogException(2,"webphone: SetPushNotifications",i)}}function se(){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Exit(), no applethandle "),!1;var e=He.API_Exit();return webphone_api.common.isNull(e)&&(e=!1),webphone_api.common.PutToDebugLog(3,"EVENT, webphone: Exit result: "+e.toString()),e}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: Exit",n)}}function pe(e,n){try{return fe()?He.API_SendChatIsComposing(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: SendChatIsComposing(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: SendChatIsComposing",t)}}function ce(e){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: NeedRatingRequest(), no applethandle "),e(!1),!1;e(He.API_NeedRatingRequest())}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: NeedRatingRequest",n)}}function ue(){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetLastCallDetails(), no applethandle "),webphone_api.global.lastcalldetails;var e=He.API_GetLastCallDetails();if(!webphone_api.common.isNull(e)&&e.length>0){var n=e.split(",");webphone_api.common.isNull(n)&&(n="");for(var t="",o=0;o0&&(t+="
"),t+=webphone_api.common.Trim(n[o]));if(t.length>0)return t}}catch(i){webphone_api.common.PutToDebugLogException(2,"webphone: GetLastCallDetails",i)}return webphone_api.global.lastcalldetails}function ge(){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: GetIncomingDisplay(), no applethandle "),"";var e=He.API_GetIncomingDisplay();return webphone_api.common.PutToDebugLog(5,"EVENT, webphone: API_GetIncomingDisplay: "+e),e}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: GetIncomingDisplay",n)}return""}function he(e){try{return fe()?He.API_DelSettings(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: DelSettings(), no applethandle "),"")}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: DelSettings",n)}return""}function me(e,n){try{if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA){if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: Jvoip(), no applethandle "),!1;He[e].apply(He,n)}else if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE){var t=null,o=null,i=null,a=null,r=null,l=null,s=null,p=null,c=null;if(!webphone_api.common.isNull(n)&&n.length>0)for(var u=0;u";webphone_api.$("body").append(n),webphone_api.common.PutToDebugLog(2,"EVENT, webphone LoadApplet InsertApplet inserted")}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: InsertApplet",t)}}function _e(){if(Be>20)return void webphone_api.common.PutToDebugLog(2,"ERROR, waitForWebphone maxloop elapsed");if(webphone_api.global.useengine.length>0&&"java"!==webphone_api.global.useengine)return void webphone_api.common.PutToDebugLog(2,"ERROR, waitForWebphone useengine not set or incorrect: "+webphone_api.global.useengine);if(webphone_api.common.GetTickCount()-on>45e3&&webphone_api.global.phonestarted<3){var e=100;if(!1===webphone_api.common.IsSDK()){var t=webphone_api.$.mobile.activePage.attr("id");if(!webphone_api.common.isNull(t)&&t.indexOf("_settings")>0)return void setTimeout(function(){_e()},1e3);e=webphone_api.common.GetDeviceWidth(),!webphone_api.common.isNull(e)&&webphone_api.common.IsNumber(e)||(e=200)}webphone_api.common.PutToDebugLog(2,"WARNING, waitForWebphone display Applet, because no handle found_1");var o=webphone_api.common.GetDeviceHeight();webphone_api.common.isNull(o)&&(o=200),webphone_api.$("#webphone").css("position","absolute"),webphone_api.$("#webphone").css("top","100px"),webphone_api.$("#webphone").width(e),webphone_api.$("#webphone").height(o-100)}if(!1===webphone_api.global.applet_started&&webphone_api.global.phonestarted<3)return void setTimeout(function(){_e()},250);if((webphone_api.common.isNull(nn)||webphone_api.common.isNull(tn)||nn<10||tn<10)&&(nn=webphone_api.common.GetDeviceWidth(),(webphone_api.common.isNull(nn)||webphone_api.common.isNull(tn)||nn<50||tn<50)&&(nn=150,tn=100)),Be++,je=fe())setTimeout(function(){webphone_api.$("#webphone").width(1),webphone_api.$("#webphone").height(1)},10),webphone_api.global.phonestarted<2&&(webphone_api.global.phonestarted=2),webphone_api.common.isNull(document.getElementById("javaerrormsg"))||(document.getElementById("javaerrormsg").style.display="none"),Be=0,webphone_api.common.SaveParameter("isfirststart","false"),n(),webphone_api.common.PutToDebugLog(2,"EVENT, appletAvailable: "+je),r();else{var i=0;if(i=!0===$e?25:50,Be>=i&&webphone_api.global.phonestarted<3){webphone_api.common.PutToDebugLog(2,"WARNING, waitForWebphone display Applet, because no handle found_2");var o=webphone_api.common.GetDeviceHeight();webphone_api.common.isNull(o)&&(o=200),webphone_api.$("#webphone").css("position","absolute"),webphone_api.$("#webphone").css("top","100px"),webphone_api.$("#webphone").width(nn-1),webphone_api.$("#webphone").height(o-100),webphone_api.common.isNull(document.getElementById("javaerrormsg"))||(document.getElementById("javaerrormsg").style.display="block")}setTimeout(function(){_e()},450)}}function fe(){if(!1===webphone_api.global.applet_started)return!1;if(null===He||void 0===He){try{He=document.getElementById("webphone")}catch(r){}if(null==He){var e=null;try{e=document.applets,0==e.length&&(e=document.getElementsByTagName("object")),0==e.length&&(e=document.getElementsByTagName("applet"));for(var n=0;n0||i.indexOf("trident")>0)for(var a in He)if("contentDocument"===a){if(null==He)return!1;o=He[a].toString();break}}catch(r){webphone_api.common.PutToDebugLogException(2,"ERROR, webphone: initcheck",r)}return null==o||""==o||o.toLowerCase().indexOf("[object")>=0&&o.toLowerCase().indexOf("[object")<5?(He=null,!1):(webphone_api.webphone_handle=He,!0)}function we(e,n,t,o,i){try{return fe()?He.API_SetCredentials(e,n,t,o,i):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_SetCredentials(), no applethandle "),!1)}catch(a){ webphone_api.common.PutToDebugLogException(2,"webphone: API_SetCredentials",a)}}function ve(e,n,t,o){try{return fe()?He.API_SetCredentials(e,n,t,o):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_SetCredentialsMD5(), no applethandle "),!1)}catch(i){webphone_api.common.PutToDebugLogException(2,"webphone: API_SetCredentialsMD5",i)}}function Ee(e){try{return fe()?He.API_CheckVoicemail(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_CheckVoicemail(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_CheckVoicemail",n)}}function Pe(e){try{return fe()?He.API_SetLine(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_SetLine(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_SetLine",n)}}function Te(e){try{return fe()?He.API_GetLine(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_GetLine(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_GetLine",n)}}function Se(e){try{return fe()?He.API_GetLineStatus(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_GetLineStatus(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_GetLineStatus",n)}}function Ne(e,n){try{return fe()?He.API_Forward(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_Forward(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: API_Forward",t)}}function Ie(e){try{return fe()?He.API_IsMuted(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_IsMuted(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_IsMuted",n)}}function Ce(e){try{return fe()?He.API_IsOnHold(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_IsOnHold(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_IsOnHold",n)}}function Ge(e){try{return fe()?He.API_GetAudioDeviceList(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_GetAudioDeviceList(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_GetAudioDeviceList",n)}}function Le(e){try{return fe()?He.API_GetAudioDevice(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_GetAudioDevice(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_GetAudioDevice",n)}}function Re(e){try{return fe()?He.API_SetAudioDevice(e):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_SetAudioDevice(), no applethandle "),!1)}catch(n){webphone_api.common.PutToDebugLogException(2,"webphone: API_SetAudioDevice",n)}}function ye(e){try{if(!fe())return webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_GetVolume(), no applethandle "),!1;var n=He.API_GetVolume(e);return webphone_api.common.PutToDebugLog(2,"webphone: GetVolume java returned: "+n.toString()),n}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: API_GetVolume",t)}}function De(){try{return fe()?He.API_RecFiles_Upload():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_RecFiles_Upload(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: API_RecFiles_Upload",e)}return!1}function Oe(e,n){try{return fe()?He.API_RecFiles_UploadEx(e,n):(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_RecFiles_UploadEx(), no applethandle "),!1)}catch(t){webphone_api.common.PutToDebugLogException(2,"webphone: API_RecFiles_UploadEx",t)}return!1}function xe(){try{return fe()?He.API_RecFiles_Clear():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_RecFiles_Clear(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: API_RecFiles_Clear",e)}return!1}function Ae(){try{return fe()?He.API_RecFiles_Del():(webphone_api.common.PutToDebugLog(3,"ERROR, webphone: API_RecFiles_Del(), no applethandle "),!1)}catch(e){webphone_api.common.PutToDebugLogException(2,"webphone: API_RecFiles_Del",e)}return!1}var ke=webphone_api.getbasedir2()+"native",Ue={id:"webphone",code:"webphone.webphone.class",name:"webphone",archive:"webphone.jar",codebase:ke,width:1,height:1,MAYSCRIPT:!0},Ve="X-Webdomain: "+webphone_api.common.GetWebdomain(),We=webphone_api.common.GetParameter("companyname");!webphone_api.common.isNull(We)&&We.length>0&&(Ve=Ve+"\r\nX-Company: "+We);var Fe=webphone_api.common.GetParameter("brandname");!webphone_api.common.isNull(Fe)&&Fe.length>0&&(Ve=Ve+"\r\nX-Brand: "+Fe);var Me,He,Be,je,$e,qe,ze,Ke={serveraddress:"",username:"",MAYSCRIPT:!0,mayscript:"yes",scriptable:!0,jsscriptevent:3,autocfgsave:3,align:"middle",customsipheader:Ve,loglevel:3,canopenlogview:!1,hasincomingcall:!1,textmessaging:-1,pluginspage:"https://java.com/download/",permissions:"all-permissions",alt:"Enable or install java: https://www.java.com/en/download/index.jsp",java_arguments:"-Dsun.net.maxDatagramSockets=256"},Xe=300,Je=8e3,Ye=null,Qe=!1,Ze=0,en=null,nn=0,tn=0,on=0;return webphone_api.webphone_handle=He,webphone_api.webphone_pollstatus=!0,{InsertApplet:be,Start:t,StartWin:i,StartService:a,LoadApplet:de,Restart:l,PushContactlist:s,StartPresence:r,CheckPresence:p,SetPresenceStatus:c,CheckBLF:u,GetVersionNS:g,GetVersionNSNum:h,GetVersionJava:m,IsEncrypted:d,RegisterEx:b,SetSipHeader:_,GetSipHeader:f,GetSipHeaderInternal:w,GetSipMessage:v,GetGetLastInvite:E,GetGetLastRecInvite:P,GetGetLastSentInvite:T,GetWorkDir:S,Unregister:N,ReRegister:I,HTTPKeepAlive:C,Call:G,Hangup:L,Accept:R,Reject:y,Ignore:D,Forward:O,Conference:x,ConferenceEx:A,Transfer:k,Dtmf:U,MuteEx:V,IsMuted:W,Hold:F,IsOnHold:M,SendChat:H,VoiceRecord:B,AudioDevice:j,SetVolume:$,GetVolume:q,PlaySound:z,GetRegFailReason:K,SetParameter:X,SetLine:J,SetLineEx:Y,GetLine:Q,LineToCallID:Z,CallIDToLine:ee,NextCallID:ne,GetLineDetails:te,IsRegistered:oe,GetAudioDeviceList:ie,GetAudioDevice:ae,SetAudioDevice:re,SetPushNotifications:le,Exit:se,NeedRatingRequest:ce,Jvoip:me,GetLastCallDetails:ue,GetIncomingDisplay:ge,DelSettings:he,API_SetCredentials:we,API_SetCredentialsMD5:ve,API_CheckVoicemail:Ee,API_SetLine:Pe,API_GetLine:Te,API_GetLineStatus:Se,API_Forward:Ne,API_IsMuted:Ie,API_IsOnHold:Ce,API_GetAudioDeviceList:Ge,API_GetAudioDevice:Le,API_SetAudioDevice:Re,API_GetVolume:ye,API_RecFiles_Upload:De,API_RecFiles_UploadEx:Oe,API_RecFiles_Clear:xe,API_RecFiles_Del:Ae,SendChatIsComposing:pe}}(),webphone_api.notifications=function(){function e(){var e=0;try{e=1,webphone_api.global.creditRequestIval=100,webphone_api.global.closeCallAtivity=!1,_=!1,g=0,e=2;var n=webphone_api.common.GetTickCount();S=n,N=n,I=n,h=0,m=!1,d=!1,Ne="",b="",webphone_api.global.last_event="",L=n,webphone_api.global.httpkatimer=n,webphone_api.global.audio_devices_loaded=!1,e=3;var t=webphone_api.common.GetAudioRecList();!webphone_api.common.isNull(t)&&t.length>5&&(webphone_api.global.audio_devices_loaded=!0),e=4,webphone_api.global.lastcallduration=0,y=-1,D=n,x=n,j=null,$="",q="",z="",K="",X="";var o=webphone_api.common.GetParameter2("ringtimeout"),i=webphone_api.common.GetParameter2("ringtimeoutin"),a=webphone_api.common.GetParameter2("ringtimeoutout"),r=webphone_api.common.GetParameter2("calltimeout");if(e=5,(webphone_api.common.isNull(o)||o.length<2||!1===webphone_api.common.IsNumber(o))&&(o=9e4),(webphone_api.common.isNull(i)||i.length<2||!1===webphone_api.common.IsNumber(i))&&(i=0),(webphone_api.common.isNull(a)||a.length<2||!1===webphone_api.common.IsNumber(a))&&(a=0),(webphone_api.common.isNull(r)||r.length<2||!1===webphone_api.common.IsNumber(r))&&(o=108e5),e=6,k=webphone_api.common.StrToInt(o),U=webphone_api.common.StrToInt(i),V=webphone_api.common.StrToInt(a),W=webphone_api.common.StrToInt(r),e=7,webphone_api.global.ringstart_time=0,webphone_api.global.callstart_time=0,webphone_api.global.useajax_forservice=!1,webphone_api.global.wsuser_succeded=!1,F=!1,webphone_api.global.acallcount=0,webphone_api.global.enstarteddisplayed=!1,M=!1,Se=0,webphone_api.global.httpheaderslogged=!1,webphone_api.global.onregisteredcalled=!1,webphone_api.global.wsc_contimeout=0,webphone_api.global.wsc_reqtimeout=0,webphone_api.global.firstregister_sessiontick=0,e=8,webphone_api.common.isNull(document.getElementById("loader")))if(e=9,webphone_api.common.PutToDebugLog(2,"EVENT, init adding loader iframe, because not found in page"),webphone_api.common.isNull(document.body))webphone_api.common.PutToDebugLog(2,"ERROR, init adding loader iframe, document.body is NULL");else{e=10;var l=document.createElement("iframe");l.style.display="none",l.style.height="0",l.style.width="0",l.id="loader",l.setAttribute("allow","microphone; camera; autoplay"),e=11,document.body.appendChild(l)}}catch(s){webphone_api.common.PutToDebugLogException(2,"notifications: Init "+e,s)}}function n(t){var s=0;try{if(webphone_api.common.CanLog(7)&&webphone_api.common.PutToDebugLog(7,"PROCESSING_NOTIFICATIONS: "+t),webphone_api.global.initcalled||(webphone_api.global.initcalled=!0,e()),!webphone_api.common.isNull(t)&&t.length>0)try{t=t.toString();var g=t.split(",");if(!webphone_api.common.isNull(g)&&g.length>0){for(var h="",S=0;S0&&(h+=","),h+=g[S];!webphone_api.common.isNull(h)&&h.length>0&&(t=h)}}catch(rt){webphone_api.common.PutToDebugLogException(2,"notifications: ProcessNotifications base64 decode",rt)}if(le<0&&(le=webphone_api.common.IsCExt()),webphone_api.common.isNull(te)&&webphone_api.common.getuseengine().length>0&&(te=webphone_api.common.Te2(),webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_WEBRTC&&(te=!1),te)){var N=[];N.push("L"),N.push("i"),N.push("m"),N.push("i"),N.push("t"),N.push(" "),N.push("f"),N.push("u"),N.push("n"),N.push("c");var I=N.join("");setTimeout(function(){webphone_api.common.PutToDebugLog(3,"EVENT, "+I)},920),N=[],N.push("S"),N.push("T"),N.push("A"),N.push("T"),N.push("U"),N.push("S"),re=N.join("")}if(te&&!webphone_api.common.isNull(re)&&re.length>0){var L="";if(!webphone_api.common.isNull(webphone_api.global.ep)&&webphone_api.global.ep.length>0)for(var S=0;S3){L=webphone_api.global.ep[S][webphone_api.common.EP_CALLID];break}!webphone_api.common.isNull(L)&&L.length>3&&!1===p(L)&&!webphone_api.common.isNull(t)&&t.indexOf(re)>=0&&(t=t.toString(),t=t.replace(re,""),t=webphone_api.common.Trim(t),t=t.substring(1),t=webphone_api.common.Trim(t))}if(s=10,!_){webphone_api.global.presence_started=!1,_=!0,webphone_api.common.isNull(webphone_api.global.maintimerid)||clearInterval(webphone_api.global.maintimerid),webphone_api.global.maintimerid=null,webphone_api.global.maintimerid=setInterval(function(){o()},C),webphone_api.common.LcAc(!0,!1),s=14;try{if(0==webphone_api.common.IsSDK()){var D=webphone_api.common.GetColortheme(),O=webphone_api.themes.gettheme("theme_"+D);if(webphone_api.common.isNull(O))R="#ffffff";else{var x=O.fontcstatus;R=webphone_api.common.isNull(x.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i))?"#ffffff":x}}}catch(lt){webphone_api.common.PutToDebugLogException(2,"notifications: ProcessNotifications at init 1",lt)}}if(s=20,webphone_api.common.isNull(t))return;if(t=t.toString(),t=webphone_api.common.Trim(t),t.length<1)return;if(t=t.replace("NORETRY",""),Q=t,0===Q.indexOf("START")&&(Q.indexOf("api")>0||Q.indexOf("sip")>0)&&(webphone_api.global.apistartstate=2,webphone_api.plhandler.GetAudioDevicesForMenu(100)),!1===webphone_api.global.applet_started&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&"START,api"===Q){webphone_api.global.applet_started=!0,s=24;var A=webphone_api.common.GetParameter2("serveraddress_user");if((webphone_api.common.isNull(A)||A.length<2)&&(A=webphone_api.common.GetParameter2("serveraddress")),(webphone_api.common.isNull(A)||A.length<2)&&webphone_api.common.PutToDebugLog(2,"EVENT, notifications ProcessNotifications serveraddress not set"),!1===webphone_api.global.usestorage&&!webphone_api.common.CheckDID(A,!1)){var N=[];N.push("E"),N.push("R"),N.push("R"),N.push("O"),N.push("R"),N.push(","),N.push("S"),N.push("e"),N.push("r"),N.push("v"),N.push("e"),N.push("r"),N.push(" "),N.push("n"),N.push("o"),N.push("t"),N.push(" "),N.push("a"),N.push("l"),N.push("l"),N.push("o"),N.push("w"),N.push("e"),N.push("d"),N.push("_"),N.push("3");var I=N.join("");return s=26,void setTimeout(function(){webphone_api.common.PutToDebugLog(1,I+" "+A)},1251)}}if(s=30,Q.indexOf("CHATCOMPOSING")>=0){var k=0,U="",V=Q.indexOf(",");if(V>0&&(s=32,Q=Q.substring(V+1),(V=Q.indexOf(","))>0&&(s=34,k=webphone_api.common.Trim(Q.substring(0,V)),Q=Q.substring(V+1),(V=Q.indexOf(","))>0))){s=36,U=webphone_api.common.Trim(Q.substring(0,V));var W=webphone_api.common.Trim(Q.substring(V+1));!webphone_api.common.isNull(W)&&webphone_api.common.IsNumber(W)&&1===webphone_api.common.StrToInt(W)&&(s=39,l(U+" "+webphone_api.stringres.get("composing")+"...","EVENT",1,-1))}return}if(s=40,Q.indexOf("SERVERCONTACTS")>=0){if(webphone_api.common.CanLog(3)&&webphone_api.common.PutToDebugLog(3,"EVENT, notifications: "+Q),Q.toLowerCase().indexOf("error")>=0)return void webphone_api.common.PutToDebugLog(2,"ERROR, notifications: "+Q);s=44;var M="",V=0;V=Q.indexOf(","),V>0&&(M=webphone_api.common.Trim(Q.substring(V+1,Q.length))),s=48,webphone_api.common.SaveParameter("servercontacts",M),!webphone_api.common.isNull(M)&&M.length>0&&webphone_api.common.PutToDebugLog(2,"EVENT, servercontacts list: "+M)}if(s=50,Q.indexOf("PRESENCE")>=0&&!0===webphone_api.common.UsePresence2()){if(webphone_api.common.CanLog(3)&&webphone_api.common.PutToDebugLog(3,"EVENT, notifications: "+Q),Q.toLowerCase().indexOf("error")>=0)return void webphone_api.common.PutToDebugLog(2,"ERROR, notifications: "+Q);var H="",V=0;if(V=Q.indexOf(","),s=54,V>0){H=webphone_api.common.Trim(Q.substring(V+1,Q.length));var B="",X="",se="",pe="",ce="",he=H.split(",");if(!webphone_api.common.isNull(he)&&he.length>1){B=webphone_api.common.Trim(he[0]),X=webphone_api.common.Trim(he[1]),he.length>2&&(se=webphone_api.common.Trim(he[2])),he.length>3&&(pe=webphone_api.common.Trim(he[3])),he.length>4&&(ce=webphone_api.common.Trim(he[4]));var me="-1";(webphone_api.common.isNull(se)||se.length<1)&&(se=X),me=webphone_api.common.SaveReceivedPresence2(B,se),"-2"===me&&X.length>1&&se!==X&&(me=webphone_api.common.SaveReceivedPresence2(B,X));try{webphone_api.onPresenceCb(B,X,pe,ce)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onPresenceStateChange() callback",st)}s=58,!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._dialpad)||webphone_api._dialpad.PopulateListRecents(),s=59,!0!==webphone_api.global.isContactdetailsStarted||!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._contactdetails)||webphone_api._contactdetails.PopulateData(),!0===webphone_api.global.isMessageStarted&&webphone_api._message.DisplayPresence(me)}}}if(Q.indexOf("BLF")>=0&&webphone_api.common.GetParameterInt("enableblf",1)>0){if(webphone_api.common.CanLog(3)&&webphone_api.common.PutToDebugLog(3,"EVENT, notifications: "+Q),Q.toLowerCase().indexOf("error")>=0)return void webphone_api.common.PutToDebugLog(2,"ERROR, notifications: "+Q);var de="",V=0;if(V=Q.indexOf(","),s=54,V>0){de=webphone_api.common.Trim(Q.substring(V+1,Q.length));var B="",_e="",X="",fe="",we=de.split(",");if(!webphone_api.common.isNull(we)&&we.length>1){B=webphone_api.common.Trim(we[0]),_e=webphone_api.common.Trim(we[1]),we.length>2&&(X=webphone_api.common.Trim(we[2])),we.length>3&&(fe=webphone_api.common.Trim(we[3]));try{webphone_api.onBLFCb(B,_e,X,fe)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onBLFStateChange() callback",st)}}}}s=60,J="",Y="";var V=0;if("["===Q.charAt(0)&&(V=Q.indexOf("]"))>0&&(Q=webphone_api.common.Trim(Q.substring(V+1,Q.length))),s=63,V=Q.indexOf(","),V>0?(J=webphone_api.common.Trim(Q.substring(0,V)),Q=webphone_api.common.Trim(Q.substring(V+1,Q.length))):J="EVENT",s=65,"ANSWER"===J)return s=69,void webphone_api.common.HttpAsyncHandler(Q);if(s=70,"DTMF"===J){var ve=-1,Ee=t,Pe=Ee.indexOf(",");Pe>0&&(Ee=Ee.substring(Pe+1),(Pe=Ee.indexOf(","))>0&&(Ee=webphone_api.common.Trim(Ee.substring(0,Pe)),!webphone_api.common.isNull(Ee)&&webphone_api.common.IsNumber(Ee)&&(ve=webphone_api.common.StrToInt(Ee))));try{webphone_api.onDTMFCb(Q,ve)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onDTMF() callback",st)}}if("STATUS"===J||"CDR"===J||"CHAT"===J||"SUBSCRIBE"===J||"NOTIFY"===J||"EVENT"===J||"ERROR"===J||"WARNING"===J||"POPUP"===J||"CREDIT"===J||"RATING"===J||"MWI"===J||"START"===J||"VREC"===J||"DTMF"===J||"REGISTER"===J||"PRESENCE"===J||"CHATREPORT"===J||"CHATCOMPOSING"===J||"BLF"===J||"LINE"===J||"STOP"===J||"LINEDETAILS"===J||"QRCODE"===J||"NOTIFICATION"===J||"GROUP"===J||"RTPSTAT"===J||"INFO"===J||"SHOULDRESET"===J||"PLAYREADY"===J||"VAD"===J||"SERVERCONTACTS"===J||"NEWUSER"===J||"ANSWER"===J||"LICKEY"===J||"USSD"===J||"SIP"===J||"BLOCK"===J||"RTPE"===J||"SRS"===J||"VIDEO"===J||"XXX"===J||"XXX"===J||"XXX"===J){s=71;try{webphone_api.onEventCb("event",t,null)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an ERROR in onEvent() callback at notification: "+t,st)}try{webphone_api.RecEvt(t)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an ERROR at the onEvents() callback in your code (triggered by notification: "+t+")",st)}try{le>0&&"undefined"!=typeof AndroidWebphoneJsInterface&&null!==AndroidWebphoneJsInterface&&"undefined"!=typeof AndroidWebphoneJsInterface.jstoandroidEvents&&null!==AndroidWebphoneJsInterface.jstoandroidEvents&&AndroidWebphoneJsInterface.jstoandroidEvents(t)}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: ProcessNotifications AndroidWebphoneJsInterface send",st)}}else if("LOG"!==J)return s=74,void(!1===te&&webphone_api.common.PutToDebugLog(5,"EVENT, unknown notification a: "+t));if(t.indexOf("-1,Stop")>=0&&webphone_api.global.phonestarted>0&&webphone_api.common.OpenSettings(!0,8),"GROUP"===J&&Q.toLowerCase().indexOf("error")<0&&!1===webphone_api.common.IsSDK())try{var Te=Q.split(",");if(!webphone_api.common.isNull(Te)&&Te.length>2){var Se=Te[2];!webphone_api.common.isNull(Se)&&Se.length>0&&webphone_api.global.isCallStarted&&(webphone_api.common.PutToDebugLog(2,"EVENT, Group conference update peers to: "+Se),webphone_api.$("#page_call_additional_info").html(Se),webphone_api.$("#page_call_peer_details").html(""),webphone_api.$("#page_call_peer_details").hide(),webphone_api.$("#display_notmain_account").html(""),webphone_api.$("#display_notmain_account").hide(),webphone_api.$("#contact_image_img").attr("src",webphone_api.common.GetElementSource()+"images/default_contact_conf.png"))}}catch(pt){webphone_api.common.PutToDebugLogException(2,"notifications ProcessNotifications handle group conference",pt)}if("QRCODE"===J)webphone_api.common.ParseQRcode(Q);else if("LOG"===J)Q.indexOf("mzserver detected")>=0&&(Q.indexOf("gw")>=0?2==webphone_api.common.ismizuserverdetected?webphone_api.common.ismizuserverdetected=3:webphone_api.common.ismizuserverdetected=1:Q.indexOf("both")>=0?webphone_api.common.ismizuserverdetected=3:1==webphone_api.common.ismizuserverdetected?webphone_api.common.ismizuserverdetected=3:webphone_api.common.ismizuserverdetected=2);else if("CHATREPORT"===J){var Ne=Q.split(",");if(!webphone_api.common.isNull(Ne)&&Ne.length>5){var Ie=Ne[1],Ce=Ne[2],Ge=Ne[5];if(webphone_api.common.isNull(Ie)&&(Ie=""),Ie=webphone_api.common.Trim(Ie),Ie=Ie.toLowerCase(),webphone_api.common.isNull(Ce)&&(Ce=""),Ce=webphone_api.common.Trim(Ce),webphone_api.common.isNull(Ge)&&(Ge=""),Ge=webphone_api.common.Trim(Ge),"2"==Ce||"4"==Ce){var Le="chat_"+webphone_api.common.GetSipusername(!0)+"_"+Ie;Ie.length>0&&Ce.length>0&&Ge.length>0&&(Ge=Ge.toLowerCase(),webphone_api.common.IsWindowsSoftphone()?webphone_api.common.ApiWinLoadFile(Le,function(e){webphone_api.common.isNull(e)&&(e=""),r(Le,Ce,Ge,e,Ie)}):webphone_api.File.ReadFile(Le,webphone_api.global.STORAGE_LOCAL,function(e){webphone_api.common.isNull(e)&&(e=""),r(Le,Ce,Ge,e,Ie)}))}}}else if("LINEDETAILS"===J){var Re=Q.split(",");if(!webphone_api.common.isNull(Re)&&Re.length>10){webphone_api.common.PutToDebugLog(2,"EVENT, update ep from received LINEDETAILS notification");var ye=Re[0],De=Re[3],Oe=Re[2],xe=Re[5],Ae=Re[8],ke=Re[9],Ue="";Re.length>10&&(Ue=Re[10]),webphone_api.common.SaveCallSession(11,ye,null,De,xe,-1,-1,-1,null,Oe,"","","",Ae,ke,null,null,null,Ue)}}else if("LINE"===J){var Ve=-20,We=Q,V=We.indexOf(",");if(V>0&&(We=We.substring(0,V)),We=webphone_api.common.Trim(We),webphone_api.common.IsNumber(We)&&(Ve=webphone_api.common.StrToInt(We)),Ve>-5)return void webphone_api.common.SetALineInternal(Ve,1)}else if("STATUS"===J){webphone_api.global.apistartstate=2,b=Q;var Fe=c(t,-1);webphone_api.global.lnstat[Fe]=[webphone_api.common.GetTickCount(),Q]}else("STATUS"===J||"EVENT"===J)&&Q.toLowerCase().indexOf("permission")<0&&(webphone_api.global.last_event=Q);if(!0===webphone_api.common.Glbr()&&"CREDIT"===J)T=!0,webphone_api.global.credit=" "+Q;else if(!0===webphone_api.common.Glbr()&&"RATING"===J)s=82,webphone_api.global.rating=" ("+webphone_api.common.Trim(Q)+")";else if("MWI"===J&&(s=83,!webphone_api.common.isNull(Q)&&Q.length>0&&Q.indexOf(",")>=0)){var Me=Q.split(",");if(!webphone_api.common.isNull(Me)&&Me.length>=2)if("no"===Me[0])s=85,60===webphone_api.common.GetConfigInt("brandid",-1)?webphone_api.common.SetNotCounter("dialpad_message_counter","0"):webphone_api.common.SetNotCounter("dialpad_voicemail_counter","0");else{s=87;var He=Me[3];webphone_api.common.isNull(He)&&(He=""),He=webphone_api.common.Trim(He),He.length>0&&webphone_api.common.IsNumber(He)&&(s=88,webphone_api.common.PutToDebugLog(3,"EVENT, New voicemail messages found: "+He),60===webphone_api.common.GetConfigInt("brandid",-1)?webphone_api.common.SetNotCounter("dialpad_message_counter",He):webphone_api.common.SetNotCounter("dialpad_voicemail_counter",He))}}s=90;var Be=Q.indexOf("POPUP");if(Be>=0){var je=Q.substring(Be+5);je=webphone_api.common.Trim(je),Be=je.indexOf(","),Be>=0&&(je=je.substring(Be+1)),s=94,!webphone_api.common.isNull(je)&&je.length>0&&webphone_api.common.ShowToast(je,5e3)}if(V=Q.indexOf(","),Q=webphone_api.common.Trim(Q),V>0&&(Q=webphone_api.common.Trim(Q.substring(V+1,Q.length))),s=96,V=Q.indexOf(","),V>0?(Y=webphone_api.common.Trim(Q.substring(0,V)),Q=webphone_api.common.Trim(Q.substring(V+1,Q.length))):Y=Q,s=100,V=Y.indexOf("("),V>0&&Y.indexOf(ie)<0&&Y.indexOf(ae)<0&&(Y=webphone_api.common.Trim(Y.substring(0,V))),Y.length<1&&!1===te)return void webphone_api.common.PutToDebugLog(5,"WARNING, unknown notification b: "+t);if(Q.length<1&&!1===te)return void webphone_api.common.PutToDebugLog(5,"WARNING, unknown notification c: "+t);if(s=110,"CDR"===J&&(webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, notifications: ProcessNotifications CDR received: "+t),webphone_api.global.lastcallcdr=t,(V=t.indexOf(","))>0))try{s=115;var $e=t.split(","),qe=$e[1],B=$e[2],ze=$e[3],Ke=$e[4],Xe=($e[5],$e[6]),Je=$e[7],Ye=$e[8],Qe=$e[9],fe="";$e.length>10&&(fe=$e[10]);$e.length>11&&$e[11],Ye.length<1&&(Ye="0");var Ze=2;"1"==_e?Ze=1:"2"==_e?Ze=2:B===Ke&&(Ze=1);var _e="incoming";1===Ze&&(_e="outgoing");var en="";en=1==Ze?Ke:ze,webphone_api.common.isNull(Qe)&&(Qe=""),Qe.indexOf("[")>0&&(Qe=Qe.substring(0,Qe.indexOf("["))),s=120,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.common.GetDiscReasonFromSignaling(function(e){(webphone_api.common.isNull(e)||e.length<2)&&(e=Qe),!0===webphone_api.global.dontshowdiscreason?webphone_api.common.PutToDebugLog(2,"EVENT, "+webphone_api.stringres.get("disc_reason")+": "+e):(webphone_api.common.PutToDebugLog(1,"EVENT, "+webphone_api.stringres.get("disc_reason")+": "+e),l(webphone_api.stringres.get("disc_reason")+": "+e,"EVENT",0,webphone_api.common.StrToIntDef(qe,-1),2)),webphone_api.common.RemoveSessionHeadersFromCache(webphone_api.common.StrToIntDef(qe,-1))}),webphone_api.common.RemoveSessionHeadersFromCache(webphone_api.common.StrToInt(qe)),webphone_api.global.lastcalldetails="",webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE||webphone_api.common.WinAPI("API_GetLastCallDetails",null),s=124;var nn="
";if(webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Line: "+qe+", Direction: "+_e+nn,webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Auth Username: "+webphone_api.common.GetSipusername()+nn,2===Ze?(webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Caller: "+ze+nn,ze!==B?webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Caller Name: "+B+nn:ze!==en&&(webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Caller Name: "+en+nn)):webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Caller ID: "+webphone_api.common.GetCallerid()+nn,s=128,webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Connecttime: "+Xe+" msec"+nn,webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Duration: "+Je+" msec"+nn,webphone_api.global.lastcalldetails="1"===Ye?webphone_api.global.lastcalldetails+"Disconnect By: Local"+nn:webphone_api.global.lastcalldetails+"Disconnect By: Remote"+nn,webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"Reason: "+Qe+nn,webphone_api.global.lastcalldetails=webphone_api.global.lastcalldetails+"CDR: "+webphone_api.global.lastcallcdr+nn,webphone_api.common.getuseengine===webphone_api.global.ENGINE_WEBRTC){var tn=webphone_api.common.ReplaceAll(webphone_api.global.lastcalldetails,nn,"\n");setTimeout(function(){webphone_api.common.PutToDebugLog(2,"EVENT, Call details:\n"+tn)},1)}webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_WEBRTC&&(!0===webphone_api.global.dontshowdiscreason?webphone_api.common.PutToDebugLog(2,"EVENT, "+webphone_api.stringres.get("disc_reason")+": "+Qe):(webphone_api.common.PutToDebugLog(1,"EVENT, "+webphone_api.stringres.get("disc_reason")+": "+Qe),l(webphone_api.stringres.get("disc_reason")+": "+Qe,"EVENT",0,webphone_api.common.StrToIntDef(qe,-1),3))),s=122;try{webphone_api.onCdrCb(ze,Ke,Xe,Je,Ze,B,Qe,webphone_api.common.StrToInt(qe),fe,Ye)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCdr() callback",st)}if(!0===webphone_api.common.UsePresence2()&&!webphone_api.common.isNull(Je)&&webphone_api.common.IsNumber(Je)){if(webphone_api.common.StrToInt(Je)<=0)webphone_api.common.PutToDebugLog(4,"EVENT,notifications CDR 0 duration get presence status for: "+B),!1===webphone_api.common.IsSDK()&&webphone_api.common.PresenceGet2(B);else{if(!webphone_api.common.isNull(webphone_api.global.presenceHM))var on=webphone_api.global.presenceHM[B];if(!webphone_api.common.isNull(on)){var an=on[webphone_api.common.PRES_STATUS];webphone_api.common.isNull(an)||"0"!==an||(webphone_api.common.PutToDebugLog(4,"EVENT,notifications CDR connected call but presence was offline, so set it to online for: "+B),webphone_api.common.SaveReceivedPresence2(B,"online"))}}}s=130,!webphone_api.common.isNull($e[9])&&$e[9].length>0&&webphone_api.common.PutToDebugLog(1,"EVENT, "+$e[9]);var rn=0;try{rn=webphone_api.common.StrToInt($e[7])/1e3}catch(ct){}webphone_api.global.lastcallduration=rn,s=132;var ln="recfile";if(2===Ze?(f=!1,!1===webphone_api.global.acceptReject?(s=136,i(B,"2",ln,rn,qe,Qe,en)):(s=137,i(B,"1",ln,rn,qe,Qe,en)),webphone_api.global.acceptReject=!1):(s=138,i(B,"0",ln,rn,qe,Qe,en)),w="",ln="",rn>60){var sn=webphone_api.common.GetParameterInt("successfulcalls",0),pn=webphone_api.common.GetParameterInt("webrtc_successfulcalls",0);sn<0&&(sn=0),pn<0&&(pn=0),sn++,webphone_api.common.SaveParameter("successfulcalls",sn.toString()),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(pn++,webphone_api.common.SaveParameter("webrtc_successfulcalls",pn.toString()));var cn=4;sn===cn&&"Android"===webphone_api.common.GetOs()&&(!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api.common.PutToDebugLog(4,"EVENT, Close call page because trying to display Add to Home Screen popup"),webphone_api._call.CloseCall()),setTimeout(function(){var e=webphone_api.$(".ui-page-active .ui-popup-active").length;!0===webphone_api.common.IsSDK()||e<1?(webphone_api.common.PutToDebugLog(2,"EVENT, Offer pin to desktop Home Screen Android"),webphone_api.common.AlertDialog(webphone_api.stringres.get("add_to_home_title"),webphone_api.stringres.get("add_to_home_msg"))):(cn-=1,webphone_api.common.SaveParameter("successfulcalls",cn.toString()))},500))}}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: ProcessNotifications CDR and save to call history",st)}if(s=140,"STATUS"===J){if("Registered."===Y||"Registered"===Y){webphone_api.global.phonestarted=3,webphone_api.common.SaveParameter("firststart_webrtc","false"),webphone_api.common.SaveParameter("last_login_failed","false");var un=webphone_api.common.GetParameter("profilepicture");if(!webphone_api.common.isNull(un)&&un.length>10&&webphone_api.plhandler.SetSipHeader("X-Profile: "+un,-1),webphone_api.global.firstregister_sessiontick<1&&(webphone_api.global.firstregister_sessiontick=webphone_api.common.GetTickCount()),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.global.pgw_selected>=0&&webphone_api.common.SaveParameter("last_good_webrtc_gw",webphone_api.global.pgw_selected),!1===webphone_api.common.IsSDK()&&("undefined"!=typeof webphone_api._dialpad&&null!==webphone_api._dialpad?webphone_api._dialpad.HandleAutoaction():console&&console.log&&console.log("ERROR, notifications ProcessNotifications webphone_api._dialpad is not defined")),s=141,!0===webphone_api.common.UsePresence2()&&!1===webphone_api.global.pres_set_at_start&&(s=142,setTimeout(function(){webphone_api.global.pres_set_at_start=!0,webphone_api.common.PutToDebugLog(2,"EVENT,SetSelectedPresence to Online on notification reg"),webphone_api.common.SetSelectedPresence("Online"),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.common.IsMizuServerOrGateway()&&webphone_api.webrtcapi.SetSipHeader(-2,"X-IMStatus:"+webphone_api.common.GetParameter("presencestatus"))},200)),s=143,!1===webphone_api.global.onregisteredcalled){webphone_api.global.onregisteredcalled=!0;try{webphone_api.onRegStateChangeCb("registered",null)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onRegStateChangeCb(registered) callback",st)}try{webphone_api.onRegisteredCb()}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onRegistered() callback",st)}webphone_api.common.InitUnregOnIdle()}if(webphone_api.$("#webphone").width(1),webphone_api.$("#webphone").height(1),s=145,s=147,!0===webphone_api.common.Glbr()&&!T){var gn=webphone_api.common.GetParameter("creditrequest");!webphone_api.common.isNull(gn)&&gn.length>0&&(s=148,webphone_api.common.UriParser(gn,"","","","","creditrequest"))}}else if(Y.toLowerCase().indexOf("unregistered")>=0){if(s=150,webphone_api.global.authenticated_displayed=!1,!1===webphone_api.global.onunregistered_flag){webphone_api.global.onunregistered_flag=!0,webphone_api.global.onregisteredcalled=!1,setTimeout(function(){webphone_api.global.onunregistered_flag=!1},2e3),s=152;try{webphone_api.onRegStateChangeCb("unregistered",null)}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: There is an error in onRegStateChangeCb(unregistered) callback",st)}try{webphone_api.onUnRegisteredCb()}catch(st){ webphone_api.common.PutToDebugLogException(2,"notifications: There is an error in onUnRegistered() callback",st)}}}else if("InProgress"===Y||"Routed"===Y||"Calling"===Y||"Calling..."===Y){s=160;var hn=Q.split(",");if(webphone_api.common.isNull(hn)||hn.length<3)return void webphone_api.common.PutToDebugLog(3,"EVENT, ProcessNotifications, skip InProgress event, because not enough parameters: "+Q);var mn="",B="",_e="",dn=t.replace(" ",""),bn="";if(!webphone_api.common.isNull(hn)&&hn.length>4&&(bn=hn[4]),!webphone_api.common.isNull(hn)&&hn.length>2&&(!webphone_api.common.isNull(hn[0])&&hn[0].length>1?mn=webphone_api.common.Trim(hn[0]):!webphone_api.common.isNull(hn[1])&&hn[1].length>1&&(mn=webphone_api.common.Trim(hn[1])),!webphone_api.common.isNull(hn[2])&&hn[2].length>0&&(_e=webphone_api.common.Trim(hn[2])),hn.length>3&&(B=hn[3],(webphone_api.common.isNull(B)||B.length<1)&&(B=mn))),webphone_api.common.isNull(mn)&&(mn=""),!webphone_api.common.isNull(z)&&z===bn&&z.length>0)return;z=bn;var Ve=webphone_api.global.aline;if(webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_WEBRTC){var _n=webphone_api.common.Trim(t),fn=_n.indexOf(",");fn>0&&(_n=_n.substring(fn+1),_n=webphone_api.common.Trim(_n),(fn=_n.indexOf(","))>0&&(_n=_n.substring(0,fn),_n=webphone_api.common.Trim(_n),!webphone_api.common.isNull(_n)&&webphone_api.common.IsNumber(_n)&&(Ve=webphone_api.common.StrToInt(_n),webphone_api.common.SetALineInternal(Ve,2,!1),webphone_api.global.lastalinesettick=0)))}if(1!==webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("callTrying",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback callTrying",st)}try{webphone_api.onCallStateChangeCb("trying",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback trying",st)}}else if("Midcall"===Y){var hn=Q.split(",");if(webphone_api.common.isNull(hn)||hn.length<3)return void webphone_api.common.PutToDebugLog(3,"EVENT, ProcessNotifications, skip Midcall event, because not enough parameters: "+Q);var mn="",B="",_e="",dn=t.replace(" ",""),bn="";!webphone_api.common.isNull(hn)&&hn.length>4&&(bn=hn[4]),!webphone_api.common.isNull(hn)&&hn.length>2&&(!webphone_api.common.isNull(hn[0])&&hn[0].length>1?mn=webphone_api.common.Trim(hn[0]):!webphone_api.common.isNull(hn[1])&&hn[1].length>1&&(mn=webphone_api.common.Trim(hn[1])),!webphone_api.common.isNull(hn[2])&&hn[2].length>0&&(_e=webphone_api.common.Trim(hn[2])),hn.length>3&&(B=hn[3],(webphone_api.common.isNull(B)||B.length<1)&&(B=mn))),webphone_api.common.isNull(mn)&&(mn="");var Ve=webphone_api.global.aline;if(webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_WEBRTC){var _n=webphone_api.common.Trim(t),fn=_n.indexOf(",");fn>0&&(_n=_n.substring(fn+1),_n=webphone_api.common.Trim(_n),(fn=_n.indexOf(","))>0&&(_n=_n.substring(0,fn),_n=webphone_api.common.Trim(_n),!webphone_api.common.isNull(_n)&&webphone_api.common.IsNumber(_n)&&(Ve=webphone_api.common.StrToInt(_n))))}if(1===webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("midcall",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback midcall",st)}}else if(Y===webphone_api.stringres.get("muted")||Y===webphone_api.stringres.get("unmuted")){var dn=t.replace(" ",""),hn=dn.split(","),Ve=webphone_api.global.aline;if(!webphone_api.common.isNull(hn)&&hn.length>1&&webphone_api.common.IsNumber(hn[1])&&(Ve=webphone_api.common.StrToInt(hn[1])),1===webphone_api.common.GetApibehaviour())if(Y===webphone_api.stringres.get("muted"))try{webphone_api.onCallStateChangeCb("muted","","","",Ve,"")}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback muted",st)}else try{webphone_api.onCallStateChangeCb("unmuted","","","",Ve,"")}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback unmuted",st)}}else if("Transfer"===Y){if(1===webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("transfer","","","",-1,"")}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback transfer",st)}}else"Exit"===Y&&webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, exit status received "+(webphone_api.common.GetTickCount()-webphone_api.global.httpkatimer).toString()+" / "+be.toString()+" / "+_?"true":(webphone_api.common.isNull(webphone_api.global.maintimerid),"true"));if(t.indexOf("EVENT,Hold")>=0){if(1===webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("hold","","","","","")}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback hold",st)}}else if(t.indexOf("EVENT,Reload")>=0&&1===webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("reload","","","","","")}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback reload",st)}if(t.indexOf("EVENT,conference created")>=0&&1===webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("conference","","","","","")}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback conference",st)}if("CallSetup"===Y||"Ringing"===Y){!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api._call.MeasureCall(),setTimeout(function(){webphone_api._call.MeasureCall()},200));var hn=Q.split(",");if(webphone_api.common.isNull(hn)||hn.length<3)return void webphone_api.common.PutToDebugLog(3,"EVENT, ProcessNotifications, skip ringing event, because not enough parameters: "+Q);var mn="",B="",_e="",dn=t.replace(" ","");!webphone_api.common.isNull(hn)&&hn.length>1&&hn[1];var bn="";!webphone_api.common.isNull(hn)&&hn.length>4&&(bn=hn[4]),!webphone_api.common.isNull(hn)&&hn.length>2&&(!webphone_api.common.isNull(hn[0])&&hn[0].length>1?mn=webphone_api.common.Trim(hn[0]):!webphone_api.common.isNull(hn[1])&&hn[1].length>1&&(mn=webphone_api.common.Trim(hn[1])),s=163,!webphone_api.common.isNull(hn[2])&&hn[2].length>0&&(_e=webphone_api.common.Trim(hn[2])),s=164,hn.length>3&&(B=hn[3],(webphone_api.common.isNull(B)||B.length<1)&&(B=mn))),s=167,webphone_api.common.isNull(mn)&&(mn="");var Ve=webphone_api.global.aline;if(s=3221,webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_WEBRTC){var _n=webphone_api.common.Trim(t),fn=_n.indexOf(",");s=169,fn>0&&(_n=_n.substring(fn+1),_n=webphone_api.common.Trim(_n),(fn=_n.indexOf(","))>0&&(s=172,_n=_n.substring(0,fn),_n=webphone_api.common.Trim(_n),!webphone_api.common.isNull(_n)&&webphone_api.common.IsNumber(_n)&&(s=175,Ve=webphone_api.common.StrToInt(_n),webphone_api.common.SetALineInternal(Ve,3,!1),webphone_api.global.lastalinesettick=0)))}if(s=3223,!webphone_api.common.isNull($)&&$===bn&&$.length>0||!webphone_api.common.isNull(q)&&q===bn&&q.length>0){if(s=3224,!webphone_api.common.isNull(q)&&q===bn||"Ringing"!==Y&&"Ringing..."!==Y&&"Incoming"!==Y&&"Incoming..."!==Y)webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, Skip "+Y+" handling, because already handled for this call: "+bn+" ("+q+")");else{if(1!==webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("callRinging",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback callSetup",st)}try{webphone_api.onCallStateChangeCb("ringing",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback setup",st)}"1"==_e?(s=271,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onoutcallringing,"callRinging",_e,mn,mn,"")):(s=272,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onincallringing,"callRinging",_e,mn,mn,""))}return}s=3225;var wn=!1,vn=webphone_api.global.aline,En=webphone_api.common.GetParameterInt("multilineoop",2);if(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(-1==En||webphone_api.common.GetNrOfActiveCalls()>0&&(En<2||En<3&&"Firefox"===webphone_api.common.GetBrowser()))&&!webphone_api.common.isNull(webphone_api.global.ep)&&webphone_api.global.ep.length>0)for(var S=0;S0&&webphone_api.common.GetOtherPartyName(ve,mn),E=webphone_api.common.GetTickCount(),w=mn,webphone_api.global.currcallnumber=w,webphone_api.global.checkIfInCall=!0,webphone_api.global.checkIfCallActive=!1,webphone_api.common.SaveCallSession(12,Ve,null,mn,_e,webphone_api.common.GetTickCount(),-1,-1,"",bn,"","",null,null,null,null,null,null,B),!0!==webphone_api.common.GetParameterBool("voicerecording",!1)||webphone_api.common.isNull(webphone_api._call)||!1===webphone_api._call.IsRecStarted(mn)&&webphone_api._call.StartRecording(mn),s=177,1!==webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("callSetup",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback callSetup",st)}try{webphone_api.onCallStateChangeCb("setup",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback setup",st)}if("1"==_e?(s=178,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onoutcallsetup,"callSetup",_e,mn,mn,"","additional_info")):(s=179,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onincallsetup,"callSetup",_e,mn,mn,"","additional_info"),0!=webphone_api.common.GetParameterInt("beeponincoming",1)&&0!=webphone_api.common.GetParameterBool("beeponincoming",!0)&&0!=webphone_api.common.GetParameterBool("useaudiodeviceplayback",!0)&&webphone_api.common.Beep("1")),"Ringing"===Y||"Ringing..."===Y||"Incoming"===Y||"Incoming..."===Y){if(1!==webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("callRinging",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback callRinging",st)}try{webphone_api.onCallStateChangeCb("ringing",webphone_api.common.StrToInt(_e),mn,B,Ve,bn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback ringing",st)}"1"==_e?(s=271,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onoutcallringing,"callRinging",_e,mn,mn,"")):(s=272,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onincallringing,"callRinging",_e,mn,mn,""))}if(webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_displaypeerdetails,"callSetup",_e,mn,mn,"","scurl_displaypeerdetails"),webphone_api.common.PutToDebugLog(5,"EVENT, currevent: "+dn+"; isIcomingCall: "+_e+"; line: "+ne+", lastRingEvent: "+webphone_api.global.lastRingEvenet),webphone_api.common.UpdateContactLastActive(mn),"2"==_e){if(!1===webphone_api.common.IsSDK()&&!webphone_api.common.isNull(document.getElementById("display_notmain_account"))&&webphone_api.common.GetNrOfAcc()>1){var Tn="",Sn=hn[1];if(!webphone_api.common.isNull(webphone_api.global.sipaccounts)&&webphone_api.global.sipaccounts.length>0){for(var S=0;S0&&Sn!=Nn.username)for(var In=0;In0&&(Tn=Tn+"@"+webphone_api.global.sipaccounts[In].serveraddress);break}break}}!webphone_api.common.isNull(Tn)&&Tn.length>0&&(webphone_api.$("#display_notmain_account").html(Tn),webphone_api.$("#display_notmain_account").show())}}var Cn=webphone_api.common.GetParameter("callnot_title"),Gn=webphone_api.common.GetParameter("callnot_body"),Ln=webphone_api.common.GetParameter("callnot_icon"),Rn=webphone_api.common.GetParameter("callnot_image");(webphone_api.common.isNull(Cn)||Cn.length<1)&&(Cn=webphone_api.common.GetBrandName()),(webphone_api.common.isNull(Gn)||Gn.length<1)&&(Gn=webphone_api.stringres.get("notification_message")),Gn+=": ",B.length>0&&B!==mn?Gn=Gn+B+" ("+mn+")":Gn+=mn,(webphone_api.common.isNull(Ln)||Ln.length<1)&&(Ln=webphone_api.common.GetElementSource()+"images/notification_icon.png"),webphone_api.common.isNull(Rn)&&(Rn=""),webphone_api.common.ShowIncomingCallNotification(Cn,Gn,Ln,!1,Rn)}if(!webphone_api.common.isNull(_e)&&"2"==_e&&dn!==webphone_api.global.lastRingEvenet){if(s=280,webphone_api.common.IsContactBlocked(w,null))return s=281,webphone_api.common.PutToDebugLog(4,"EVENT, call dropped (hangup) because blocked contact: "+w),webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Hangup blocked contact: "+w),void webphone_api.hangup(!0);if(webphone_api.common.IsNumberBlacklisted(w,null))return s=282,webphone_api.common.PutToDebugLog(4,"EVENT, call dropped (hangup) because blacklisted number: "+w),webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Hangup blacklisted number: "+w),void webphone_api.hangup(!0);if(webphone_api.global.active_incoming_call=!0,webphone_api.global.incommingCall=!0,f=!0,webphone_api.global.checkIfInCall=!0,webphone_api.global.checkIfCallActive=!1,s=285,webphone_api.common.SaveParameter("redial",w),webphone_api.common.SaveParameter("lastincalltime",webphone_api.common.GetTickCount()),webphone_api.global.intentcall[0]="number="+w,webphone_api.global.intentcall[1]="calltype=incoming",webphone_api.global.intentcall[2]="name=",s=286,!0===webphone_api.common.UsePresence2()&&!0===webphone_api.global.incommingCall&&"dnd"===webphone_api.common.GetParameter("presencestatus").toLowerCase())return webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Hangup incoming call from: "+mn+", because presence is DND"),void webphone_api.hangup(!0);0==webphone_api.common.IsSDK()&&setTimeout(function(){s=290,!1===webphone_api.global.isCallStarted?webphone_api.$.mobile.changePage("#page_call",{transition:"pop",role:"page"}):(s=292,webphone_api.common.isNull(webphone_api._call)||webphone_api._call.OnNewIncomingCall())},500)}s=297,(webphone_api.common.isNull(webphone_api.global.lastRingEvenet)||webphone_api.global.lastRingEvenet.length<1)&&(webphone_api.global.lastRingEvenet=dn)}if(s=180,"CallConnect"===Y){!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api._call.MeasureCall(),setTimeout(function(){webphone_api._call.MeasureCall()},200));var mn="",B="",_e="",hn=Q.split(","),yn="";if(hn.length>4&&!webphone_api.common.isNull(hn[4])&&(yn=hn[4]),!webphone_api.common.isNull(K)&&K===yn&&K.length>0)return;K=yn;if(!webphone_api.common.isNull(hn)&&hn.length>1&&hn[1],le>0&&u(),webphone_api.common.PutToDebugLog(5,"EVENT, callConnected event received"),"Android"===webphone_api.common.GetOs()&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&(webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_GetDevice Callconnect"),webphone_api.getdevice(0,function(e){try{var n=webphone_api.common.GetParameterInt("androidspeaker",-1);-1==n&&(n=webphone_api.global.isvideocall?0:1);var t=e;if(-2==n);else if(n>0){if("Default"===e){var o=webphone_api.common.GetAudioRecList();if(!webphone_api.common.isNull(o)&&o.length>0)for(var i=o.split("\r\n"),a=0;a=0||i[a].toLowerCase().indexOf("headset")>=0)&&(e=i[a],webphone_api.common.SaveParameter("sel_rtc_audio_in",e),webphone_api.global.audio_rec_curr_device=e,webphone_api.common.SaveParameter("cache_audio_rec_curr_device",e))}!webphone_api.common.isNull(e)&&e.length>0&&(webphone_api.common.PutToDebugLog(4,"EVENT, Set input device id for Android loudspeaker: "+e),webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_SetDevice Callconnect"),webphone_api.setdevice(0,e,2,10))}else{if(e.toLowerCase().indexOf("earpiece")>=0||e.toLowerCase().indexOf("headset")>=0){var o=webphone_api.common.GetAudioRecList();if(!webphone_api.common.isNull(o)&&o.length>0)for(var i=o.split("\r\n"),a=0;a=0&&(e=i[a],webphone_api.common.SaveParameter("sel_rtc_audio_in",e),webphone_api.global.audio_rec_curr_device=e,webphone_api.common.SaveParameter("cache_audio_rec_curr_device",e))}!webphone_api.common.isNull(e)&&e.length>0&&(webphone_api.common.PutToDebugLog(4,"EVENT, Set input device id for Android loudspeaker: "+e),webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_SetDevice Callconnect"),webphone_api.setdevice(0,e,2,11))}webphone_api.common.PutToDebugLog(5,"EVENT, set android loudspeaker/speakerphone: "+n+" from: "+t+" to: "+e)}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: getdevice loudspeaker 2",st)}})),webphone_api.common.ShowIncomingCallNotification("","","",!0,""),webphone_api.global.checkIfInCall=!0,webphone_api.global.callstart_time=webphone_api.common.GetTickCount(),s=182,!webphone_api.common.isNull(hn)&&hn.length>2&&(!webphone_api.common.isNull(hn[0])&&hn[0].length>1?mn=webphone_api.common.Trim(hn[0]):!webphone_api.common.isNull(hn[1])&&hn[1].length>1&&(mn=webphone_api.common.Trim(hn[1])),s=184,!webphone_api.common.isNull(hn[2])&&hn[2].length>0&&(_e=webphone_api.common.Trim(hn[2])),hn.length>3&&(B=hn[3],(webphone_api.common.isNull(B)||B.length<1)&&(B=mn)),s=188),webphone_api.common.isNull(mn)&&(mn=""),s=190,1!==webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("callConnected",webphone_api.common.StrToInt(_e),mn,B,webphone_api.common.StrToInt(webphone_api.global.aline),yn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback callConnected",st)}try{webphone_api.common.PutToDebugLog(5,"EVENT, call connected event sent"),webphone_api.onCallStateChangeCb("connected",webphone_api.common.StrToInt(_e),mn,B,webphone_api.common.StrToInt(webphone_api.global.aline),yn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback connected",st)}if(1===webphone_api.common.StrToInt(_e)){if(s=205,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onoutcallconnected,"callConnected",_e,mn,mn,""),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){var Dn=webphone_api.common.GetParameterInt("beeponconnect",0);3!==Dn&&4!==Dn||webphone_api.common.Beep("1")}}else s=206,webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onincallconnected,"callConnected",_e,mn,mn,"");s=207,webphone_api.common.SaveCallSession(13,webphone_api.global.aline,null,mn,_e,-1,webphone_api.common.GetTickCount(),-1,"",yn,"","",null,null,null,null,null,null,B),setTimeout(function(){webphone_api.common.RefreshInfo(7)},400),1==webphone_api.global.addrtcpmux&&(webphone_api.global.addrtcpmux=2)}if(s=200,"CallDisconnect"===Y){webphone_api.common.PutToDebugLog(2,"EVENT, ProcessNotifications call disc received");var On=0;try{var hn=Q.split(","),yn="";hn.length>4&&!webphone_api.common.isNull(hn[4])&&(yn=hn[4]);var xn=webphone_api.common.Trim(t).split(",");!webphone_api.common.isNull(xn)&&xn.length>3&&xn[4],On=2,webphone_api.common.ShowIncomingCallNotification("","","",!0,"");var k=webphone_api.global.aline,An="";On=3,!webphone_api.common.isNull(xn)&&xn.length>3&&(!webphone_api.common.isNull(xn[1])&&webphone_api.common.IsNumber(xn[1])&&(k=webphone_api.common.StrToInt(xn[1])),webphone_api.common.isNull(xn[3])||(An=webphone_api.common.Trim(xn[3]))),On=4,webphone_api.common.RemoveSessionHeadersFromCache(k);var mn="",B="",_e="",yn="";if(hn.length>4&&!webphone_api.common.isNull(hn[4])&&(yn=hn[4]),setTimeout(function(){webphone_api.common.CanLog(2)&&webphone_api.common.PutToDebugLog(2,"EVENT, notifications delete/remove endpoint on call disconnected for number: "+An+"; line: "+k.toString());var e=!0;!0===webphone_api.global.calltransf_completed&&(e=!1),(!0!==webphone_api.global.checkIfInCall||webphone_api.common.isNull(webphone_api.global.ep)||1!==webphone_api.global.ep.length)&&webphone_api.common.GetEndpoint(1021,k,An,yn,"",e)},350),On=5,On=7,s=202,!webphone_api.common.isNull(hn)&&hn.length>2&&(!webphone_api.common.isNull(hn[0])&&hn[0].length>1?mn=webphone_api.common.Trim(hn[0]):!webphone_api.common.isNull(hn[1])&&hn[1].length>1&&(mn=webphone_api.common.Trim(hn[1])),s=204,!webphone_api.common.isNull(hn[2])&&hn[2].length>0&&(_e=webphone_api.common.Trim(hn[2])),s=206,hn.length>3&&(B=hn[3],(webphone_api.common.isNull(B)||B.length<1)&&(B=mn))),webphone_api.global.CLOSE_CALL_TIMER<0){var kn=0,Un=webphone_api.common.GetEndpoint(1022,k,An,yn,"",!1);if(!webphone_api.common.isNull(Un)&&Un.length>5){var Vn=Un[webphone_api.common.EP_CONNECTTIME];!webphone_api.common.isNull(Vn)&&webphone_api.common.IsNumber(Vn)&&(Vn=webphone_api.common.StrToIntDef(Vn,0))>0&&(kn=webphone_api.common.GetTickCount()-Vn)}webphone_api.global.CLOSE_CALL_TIMER=webphone_api.common.GetParameterInt("closecall_timeout",3e3),(1==_e||"1"==_e)&&kn<4e3&&(webphone_api.global.CLOSE_CALL_TIMER=webphone_api.common.GetParameterInt("closecall_timeout_err",7e3))}if(webphone_api.common.GetNrOfActiveCalls()<2&&(webphone_api.global.checkIfInCall=!1,webphone_api.global.isconfcall=!1),webphone_api.global.hadStartMediaPending=!1,On=6,s=201,webphone_api.common.ResetIce(),On=8,s=213,webphone_api.common.isNull(mn)&&(mn=""),!1===webphone_api.common.IsSDK()&&(s=215),On=9,!0!==webphone_api.common.GetParameterBool("voicerecording",!1)||webphone_api.common.isNull(webphone_api._call)||!0===webphone_api._call.IsRecStarted(mn)&&webphone_api._call.StopRecording(mn),On=10,s=218,1!==webphone_api.common.GetApibehaviour())try{webphone_api.onCallStateChangeCb("callDisconnected",webphone_api.common.StrToInt(_e),mn,B,k,yn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback callDisconnected",st)}try{webphone_api.onCallStateChangeCb("disconnected",webphone_api.common.StrToInt(_e),mn,B,k,yn)}catch(st){webphone_api.common.PutToDebugLogException(2,"There is an error in onCallStateChange() callback disconnected",st)}!1===webphone_api.global.calltransf_completed&&webphone_api.common.SaveCallSession(14,null,null,mn,webphone_api.common.StrToInt(_e),-1,-1,webphone_api.common.GetTickCount(),"",yn,"","",null),On=11,webphone_api.global.acallcount--,webphone_api.common.GetNrOfActiveCalls()<1&&(webphone_api.global.usemutemutiline=!1),On=12}catch(st){webphone_api.common.PutToDebugLogException(2,"ProcessNotifications CallDisconnect error: "+On.toString(),st)}}if(s=220,"Call Finished"===Y){if(oe=!1,webphone_api.global.bothpartyhold=!1,webphone_api.global.authenticated_displayed=!1,webphone_api.global.ringstart_time=0,webphone_api.global.callstart_time=0,webphone_api.isscreensharecall=!1,webphone_api.global.rating="",webphone_api.global.isholdresume=!1,webphone_api.global.needholdreinvite=0,webphone_api.global.isresume=0,webphone_api.global.ishold=0,webphone_api.global.holdresumecount=0,webphone_api.global.add_recall_header=!1,le>0)try{"undefined"!=typeof AndroidWebphoneJsInterface&&null!==AndroidWebphoneJsInterface&&"undefined"!=typeof AndroidWebphoneJsInterface.jstoandroidEvents&&null!==AndroidWebphoneJsInterface.jstoandroidEvents&&AndroidWebphoneJsInterface.jstoandroidEvents("[HANGUP]_NOTIFICATION")}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: ProcessNotifications inner AndroidWebphoneJsInterface",st)}s=222,webphone_api.common.ResetIce(),v=webphone_api.common.GetTickCount(),webphone_api.common.GetNrOfActiveCalls()<1&&(webphone_api.global.closeCallAtivity=!0),webphone_api.global.isCallStarted&&webphone_api.common.GetNrOfActiveCalls()<1&&(webphone_api.common.isNull(webphone_api.global.waiting_conf_numbers)||webphone_api.global.waiting_conf_numbers.length<1)&&!1===webphone_api.global.dontshow_closecall&&(webphone_api.$("#btn_hangup_img").attr("src",webphone_api.common.GetElementSource()+"images/btn_close_txt.png"),webphone_api.$("#btn_hangup").attr("title",webphone_api.stringres.get("hint_closecall")),webphone_api.$("#acceptreject_layout").hide(),webphone_api.$("#callfunctions_layout").hide(),webphone_api.$("#hangup_layout").show()),webphone_api.common.IsMultiline()||(webphone_api.global.hangupPressedCount=1),s=232,webphone_api.common.GetNrOfActiveCalls()<1&&(webphone_api.global.checkIfInCall=!1,webphone_api.global.checkIfCallActive=!1,webphone_api.global.isconfcall=!1,F=!1,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.webrtcapi.ClearPendingStartMedia()),webphone_api.global.hadStartMediaPending=!1,webphone_api.global.callTypeInOut="",webphone_api.global.creditRequestTimer=webphone_api.global.CREDIT_REQUEST_IVAL_DEFVAL-50,webphone_api.global.lastRingEvenet="",webphone_api.global.isfirstcall=!1,d=!1}if(s=240,"Finished"===Y){!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api._call.MeasureCall(),setTimeout(function(){webphone_api._call.MeasureCall()},200)),oe=!1,webphone_api.global.bothpartyhold=!1,webphone_api.global.ringstart_time=0,webphone_api.global.callstart_time=0,webphone_api.global.rating="",webphone_api.global.firefoxholdcount=0,webphone_api.global.isholdresume=!1,webphone_api.global.needholdreinvite=0,webphone_api.global.isresume=0,webphone_api.global.ishold=0,webphone_api.global.holdresumecount=0,webphone_api.global.add_recall_header=!1,s=242,webphone_api.common.ResetIce(),!0===webphone_api.global.incommingCall&&!1===webphone_api.global.acceptReject&&webphone_api.global.isCallStarted&&(s=245,!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||webphone_api._call.OnCallerHangup()),webphone_api.common.GetNrOfActiveCalls()<1&&(webphone_api.global.checkIfInCall=!1,webphone_api.global.checkIfCallActive=!1,webphone_api.global.isconfcall=!1,F=!1,webphone_api.global.incommingCall=!1,webphone_api.global.speakerState=!0,webphone_api.global.bluetoothState=!0,webphone_api.global.lastBTclicktick=0,webphone_api.global.callTypeInOut="",webphone_api.global.lastRingEvenet="",webphone_api.global.isfirstcall=!1,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.webrtcapi.ClearPendingStartMedia()),webphone_api.global.hadStartMediaPending=!1,d=!1;var Wn=webphone_api.common.GetParameterInt("vdnr",0);if(webphone_api.global.isvideocall||webphone_api.isscreensharecall){Wn+=1,webphone_api.common.SaveParameter("vdnr",Wn);4===webphone_api.common.GetParameterInt("videomode",0)&&webphone_api.common.ExitVideoMode("Auto, on call finished")}if(webphone_api.global.isvideocall=!1,webphone_api.isscreensharecall=!1,s=247,!1===webphone_api.global.usestorage&&!1===webphone_api.common.Strl(60)&&Wn<2&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&!0===webphone_api.common.CanIUseService()){if(!0===(!0===webphone_api.common.IsWindows()&&!0===webphone_api.common.IsMizuReallyPublicWebRTCGateway())){s=248;var Fn=webphone_api.common.GetParameterInt("lccnr",0);if(Fn>0&&Fn<46){var Mn=webphone_api.common.GetParameterInt("closecall_timeout_err",7e3);Mn0&&"ns"!=webphone_api.common.GetParameter("lastusedengine")&&webphone_api.common.SaveParameter("prevusedengine",webphone_api.common.GetParameter("lastusedengine")),webphone_api.common.SaveParameter("lastusedengine","ns"),webphone_api.flagrestartwebrtc=!1,s=253,webphone_api.common.ResetEngineClicked();var e=webphone_api.common.GetEngine("ns");e.clicked=2,webphone_api.common.SetEngine("ns",e),webphone_api.common.EngineSelect(1,1),s=257,webphone_api.common.PutToDebugLog(2,"EVENT, notifications: offer ns engine instead of WebRTC: "+webphone_api.common.GetMinServiceVersion().toString()),s=259,webphone_api.common.EngineForcedInstall("ns",webphone_api.stringres.get("serviceengine_msg"),null,function(){webphone_api.startInner()})}var n=webphone_api.$.mobile.activePage.find(".messagePopup");!webphone_api.common.isNull(n)&&n.length>0&&!0!==webphone_api.global.dontclosecurrpopup?webphone_api.$.mobile.activePage.find(".messagePopup").popup("close").bind({popupafterclose:function(){webphone_api.$(this).unbind("popupafterclose").remove(),e()}}):e()},Mn)}}}}if(s=260,s=300,"Starting call"===Y&&(!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api._call.MeasureCall(),setTimeout(function(){webphone_api._call.MeasureCall()},200)),webphone_api.global.checkIfInCall=!0,webphone_api.global.checkIfCallActive=!1,webphone_api.global.hadStartMediaPending=!1,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC&&webphone_api.webrtcapi.ClearPendingStartMedia()),s=304,"InCall"!==Y&&"In Call"!==Y||(webphone_api.global.checkIfInCall=!0,f&&(s=307,!1===webphone_api.common.IsSDK()&&webphone_api.common.GetNrOfActiveCalls()<2&&!webphone_api.common.isNull(webphone_api._call)&&webphone_api._call.AcceptCall(!1))),s=310,"Speaking"===Y){!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||(webphone_api._call.MeasureCall(),setTimeout(function(){webphone_api._call.MeasureCall()},200));var hn=Q.split(",");if(!webphone_api.common.isNull(hn)&&hn.length>1&&hn[1],webphone_api.global.apistartstate=2,!1===oe&&(s=312,oe=!0,!1===webphone_api.common.IsSDK()&&webphone_api.common.GetNrOfActiveCalls()<2&&!webphone_api.common.isNull(webphone_api._call)&&webphone_api._call.AcceptCall(!1)),!1===webphone_api.common.IsSDK()&&!1===webphone_api.global.isCallStarted&&webphone_api.common.isNull(j)&&(j=setTimeout(function(){!1===webphone_api.global.isCallStarted&&(webphone_api.global.intentcall[0]="number=",webphone_api.global.intentcall[1]="calltype=outgoing",webphone_api.global.intentcall[2]="name=",webphone_api.global.intentcall[3]="callmode=0",webphone_api.$.mobile.changePage("#page_call",{transition:"pop",role:"page"}))},1e3)),G=!0,webphone_api.global.incommingCall&&(webphone_api.global.incommingCall=!1),webphone_api.global.checkIfCallActive=!0,webphone_api.global.checkIfInCall=!0,webphone_api.global.lastRingEvenet="",s=314,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC){s=315;var Hn=location.hostname;webphone_api.common.isNull(Hn)&&(Hn=""),Hn+=" / ",Hn+=window.location.href,Hn+=" / ",Hn+=webphone_api.getbasedir2();var Bn=1;if(!1===webphone_api.common.Awb2()){var N=[];N.push("L"),N.push("i"),N.push("c"),N.push("e"),N.push("n"),N.push("s"), N.push("e "),N.push("e"),N.push("r"),N.push("r"),N.push("o"),N.push("r"),N.push(", "),N.push("w"),N.push("e"),N.push("b"),N.push("s"),N.push("e"),N.push("r"),N.push("v"),N.push("e"),N.push("r"),N.push(" "),N.push("n"),N.push("o"),N.push("t"),N.push(" "),N.push("a"),N.push("l"),N.push("l"),N.push("o"),N.push("w"),N.push("e"),N.push("d"),N.push(" "),N.push("(");var jn=[];jn.push(")"),jn.push(" "),jn.push("h"),jn.push("a"),jn.push("n"),jn.push("g"),jn.push("u"),jn.push("p");var I=N.join(""),$n=jn.join("");s=320,setTimeout(function(){webphone_api.common.PutToDebugLog(1,"ERROR,"+I+Hn+$n)},3576),setTimeout(function(){webphone_api.common.ShowToast(I+Hn+$n)},4235),Bn=10}if(Bn>5&&setTimeout(function(){webphone_api.hangup(!0)},1180),y<0){if(!0===webphone_api.common.Ch())y=1;else{y=0;var N=[];N.push("L"),N.push("i"),N.push("c"),N.push("e"),N.push("n"),N.push("s"),N.push("e "),N.push("e"),N.push("r"),N.push("r"),N.push("o"),N.push("r"),N.push(", "),N.push("i"),N.push("n"),N.push("v"),N.push("a"),N.push("l"),N.push("i"),N.push("d "),N.push("s"),N.push("e"),N.push("r"),N.push("v"),N.push("e"),N.push("r"),N.push("a"),N.push("d"),N.push("d"),N.push("r"),N.push("e"),N.push("s"),N.push("s"),N.push(" "),N.push("h"),N.push("a"),N.push("n"),N.push("g"),N.push("u"),N.push("p");var I=N.join("");s=320,setTimeout(function(){webphone_api.common.PutToDebugLog(1,"ERROR,"+I)},351),setTimeout(function(){webphone_api.common.ShowToast(I)},391)}}0===y&&setTimeout(function(){webphone_api.hangup(!0)},123)}if(s=322,webphone_api.common.GetNrOfActiveCalls()>1&&!1===F){F=!0;var qn=webphone_api.common.StrToInt(webphone_api.common.GetParameter("automute")),zn=webphone_api.common.StrToInt(webphone_api.common.GetParameter("autohold")),Kn=webphone_api.common.GetParameterInt("defmute",0);if(3!==Kn&&4!==Kn||(Kn=0),(webphone_api.common.isNull(qn)||qn<1)&&(webphone_api.common.isNull(zn)||zn<1));else for(var S=0;S10)continue}var Yn=Xn[webphone_api.common.EP_LINE];if(!(webphone_api.common.isNull(Yn)||Yn.length<1||!1===webphone_api.common.IsNumber(Yn))){var Qn=webphone_api.common.StrToInt(Yn);if(webphone_api.global.aline!=Qn){var Zn=Xn[webphone_api.common.EP_MUTESTATE],et=Xn[webphone_api.common.EP_HOLDSTATE];"false"==Zn&&(3===qn||6===qn||(2===qn||5===qn)&&!1===f||1===qn&&!0===f)&&(webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC?webphone_api.webrtcapi.SipToggleMute(!0,Kn,Qn)&&(webphone_api.global.ep[S][webphone_api.common.EP_MUTESTATE]="true"):webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE?(webphone_api.common.WinAPI("API_MuteEx",null,Qn,!0,Kn),webphone_api.global.ep[S][webphone_api.common.EP_MUTESTATE]="true"):webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&(webphone_api.webphone.MuteEx(Qn,!0,Kn),webphone_api.global.ep[S][webphone_api.common.EP_MUTESTATE]="true")),"false"==et&&(3===zn||6===zn||(2===zn||5===zn)&&!1===f||1===zn&&!0===f)&&(webphone_api.common.PutToDebugLog(2,"EVENT, API_Hold mainlogic hold call because autohold "+zn.toString()+" ; peer: "+webphone_api.global.ep[S][webphone_api.common.EP_DESTNR]+" on line: "+webphone_api.global.ep[S][webphone_api.common.EP_LINE]),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_WEBRTC?webphone_api.webrtcapi.SipToggleHoldResume(!0,Qn,10)&&(webphone_api.global.ep[S][webphone_api.common.EP_HOLDSTATE]="true"):webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE?(webphone_api.common.WinAPI("API_Hold",null,Qn,!0),webphone_api.global.ep[S][webphone_api.common.EP_HOLDSTATE]="true"):webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&(webphone_api.webphone.Hold(Qn,!0),webphone_api.global.ep[S][webphone_api.common.EP_HOLDSTATE]="true"))}}}}}d||(d=!0,s=338,webphone_api.global.isencrypted=webphone_api.isencrypted(),setTimeout(function(){webphone_api.global.isencrypted>0?webphone_api.$(".img_encrypt").show():webphone_api.$(".img_encrypt").hide()},1e3))}s=340,Y.toLowerCase().indexOf("registered")>=0&&Y.toLowerCase().indexOf("unregistered")<0&&(P<4&&(P=4),s=342,webphone_api.global.phonestarted=3,webphone_api.common.SaveParameter("lastsucc","1"),m||(m=!0),s=344,setTimeout(function(){webphone_api.global.isencrypted>0?webphone_api.$(".img_encrypt").show():webphone_api.$(".img_encrypt").hide()},1e3)),s=360}else if("CHAT"===J){var ve=-1,Ee=webphone_api.common.Trim(t),Pe=Ee.indexOf(",");if(Pe>0&&(Ee=Ee.substring(Pe+1),(Pe=Ee.indexOf(","))>0&&(Ee=webphone_api.common.Trim(Ee.substring(0,Pe)),!webphone_api.common.isNull(Ee)&&webphone_api.common.IsNumber(Ee)&&(ve=webphone_api.common.StrToInt(Ee)))),Q.indexOf("[PRESENCE")>=0)return Q=Q.replace("[",""),Q=Q.replace("]",""),void n(Q);s=361,a(Y,Q,ve)}"Rejected"===Y&&f&&(s=364,!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||webphone_api._call.RejectCall(!1)),V=Q.indexOf(","),V>=0&&(V>0||Q.substring(1).indexOf(",")>=0)&&(Q=Y),s=366,V=Y.indexOf("[ep"),V>0&&(Y=webphone_api.common.Trim(Y.substring(0,V)),Q=Y),s=370;var nt="";if(("EVENT"===J||"ERROR"===J||"WARNING"===J||"STATUS"===J)&&(s=371,V=Q.indexOf("("),nt=V>0&&Y.indexOf(ie)<0&&Y.indexOf(ae)<0?webphone_api.common.Trim(Q.substring(0,V)):Q,s=374,!webphone_api.common.IsNumber(nt.charAt(0)))){if(nt=nt.substring(0,1).toUpperCase()+nt.substring(1),"STATUS"===J){if("Deletable"!==nt&&nt.indexOf("Chat")<0){ue=nt,ge=-1;var tt=t.split(",");if(!webphone_api.common.isNull(tt)&&tt.length>1&&!webphone_api.common.isNull(tt[1])&&webphone_api.common.IsNumber(tt[1])&&(ge=webphone_api.common.StrToIntDef(tt[1],-1)),webphone_api.common.isNull(webphone_api.global.callPageStatusCachePerLine)&&(webphone_api.global.callPageStatusCachePerLine={}),!1===webphone_api.common.IsSDK()&&("page_call"===webphone_api.$.mobile.activePage.attr("id")||t.indexOf("CallSetup")>0)){var ot=webphone_api.common.StrToIntDef(tt[1],-1);if(ot>0){var it=R;t.indexOf("ERROR")>=0?it="#FF0000":t.indexOf("WARNING")>=0&&(it="#D28F00"),"undefined"!=typeof webphone_api.global.callPageStatusCachePerLine[ot]&&null!==webphone_api.global.callPageStatusCachePerLine[ot]&&"undefined"!=typeof webphone_api.global.callPageStatusCachePerLine[ot][0]&&null!==webphone_api.global.callPageStatusCachePerLine[ot][0]&&"Muted"===webphone_api.global.callPageStatusCachePerLine[ot][0]&&"Speaking"===nt||(webphone_api.global.callPageStatusCachePerLine[ot]=[nt,it])}}}}else{Z=nt,ee=J,ne=-1;var tt=t.split(",");!webphone_api.common.isNull(tt)&&tt.length>1&&!webphone_api.common.isNull(tt[1])&&webphone_api.common.IsNumber(tt[1])&&(ne=webphone_api.common.StrToIntDef(tt[1],-1))}if(s=377,"Register failed"===nt){ue=nt,ge=-1;var tt=t.split(",");!webphone_api.common.isNull(tt)&&tt.length>1&&!webphone_api.common.isNull(tt[1])&&webphone_api.common.IsNumber(tt[1])&&(ge=webphone_api.common.StrToIntDef(tt[1],-1))}if(s=379,(nt.indexOf("Register failed")>=0||nt.indexOf("Connection lost")>=0||nt.indexOf("No network")>=0||nt.indexOf("Network is down")>=0||nt.indexOf("No response from server")>=0||nt.indexOf("Server lost")>=0||nt.indexOf("Authentication failed")>=0||nt.indexOf("Rejected by server")>=0||nt.indexOf("Register rejected")>=0||nt.indexOf("Register expired")>=0||nt.indexOf("Register failed")>=0)&&(webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE||webphone_api.common.WinAPI("API_GetRegFailReason",function(e){try{webphone_api.onRegStateChangeCb("failed",e)}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: There is an error in onRegStateChangeCb(failed) callback service",st)}try{webphone_api.onRegisterFailedCb(e)}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: There is an error in onRegisterFailed() callback service",st)}},!0),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&webphone_api.webphone.GetRegFailReason(function(e){try{webphone_api.onRegStateChangeCb("failed",e)}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: There is an error in onRegStateChangeCb(failed) callback webphone",st)}try{webphone_api.onRegisterFailedCb(e)}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: There is an error in onRegisterFailed() callback webphone",st)}},!0),!0===webphone_api.global.onunregistered_flag||!1===webphone_api.flagrestartwebrtc||webphone_api.common.SaveParameter("lastsucc","0"),webphone_api.global.dispregfailed<2&&(webphone_api.global.laststarttick<1||webphone_api.common.GetTickCount()-webphone_api.global.laststarttick>2500))){s=382,webphone_api.global.dispregfailed=2;var at=nt;at=at.indexOf("Register failed")<0?"Register failed_: "+at:at.replace("Register failed","Register failed_"),webphone_api.common.PutToDebugLog(2,"EVENT, notification ProcessNotifications display: Register failed_: "+at),webphone_api.common.ShowToast(at,6e3)}}s=400}catch(st){webphone_api.common.PutToDebugLogException(2,"notifications: ProcessNotifications ("+s.toString()+"), not: "+t,st)}}function t(e){Ee=e}function o(){function e(e){try{webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Hangup EarlyHangup: "+e),webphone_api.hangup(!0)}catch(n){webphone_api.common.PutToDebugLogException(2,"notifications: EarlyHangup",n)}}var n=0;try{n=444101;var t=webphone_api.common.GetTickCount();if(n=444102,webphone_api.global.ever_received_pong&&webphone_api.global.pingpong>2){n=444103;!0===webphone_api.common.WSReConnect()?webphone_api.common.PutToDebugLog(2,"EVENT, WSReConnect from timer succeded"):webphone_api.common.PutToDebugLog(2,"ERROR, WSReConnect from timer failed")}n=444104,webphone_api.global.wsc_contimeout>10&&t-webphone_api.global.wsc_contimeout>5e3&&(webphone_api.global.wsc_contimeout=0,webphone_api.common.PutToDebugLog(2,"ERROR, WSReConnect websocketAPI connection timed out (from timer)"),webphone_api.common.WSReConnect()),webphone_api.global.wsc_reqtimeout>10&&t-webphone_api.global.wsc_reqtimeout>5e3&&(webphone_api.global.wsc_reqtimeout=0,webphone_api.common.PutToDebugLog(2,"ERROR, WSReConnect websocketAPI request timed out (from timer)"),webphone_api.common.WSReConnect()),!0===webphone_api.global.dontshowdiscreason&&H>25&&(H=0,webphone_api.global.dontshowdiscreason=!1),1===webphone_api.global.dispregfailed&&++Se>330&&(Se=0,n=444105,webphone_api.global.dispregfailed=2,webphone_api.global.phonestarted<2&&!0===webphone_api.common.NeedRegister()&&(webphone_api.common.PutToDebugLog(2,"EVENT, notification OnTimerCycle display: Register failed"),webphone_api.common.ShowToast("Register failed"))),n=444106,pe<5e3&&pe++,Z.length>0?(n=444107,Z.toLowerCase().indexOf("authenticated successfully")>=0&&(ue="Registered.",ge=-1),he=Z,me=ee,de=ne,pe=0,Z="",ee="",ne=-1):pe>ce?(he=ue,me="STATUS",de=ge):ue.indexOf("Registered.")>=0&&"ERROR"!==me&&"WARNING"!==me&&(n=444108,(webphone_api.global.firstregister_sessiontick<1||webphone_api.global.firstregister_sessiontick>0&&t-webphone_api.global.firstregister_sessiontick<5e3)&&(he=ue,me="STATUS",de=ge));try{var o=he.indexOf("[");o>0&&(he=he.substring(0,o)),he=webphone_api.common.Trim(he),o=he.indexOf("]"),o>0&&(he=he.substring(o+1)),he=webphone_api.common.Trim(he)}catch(w){webphone_api.common.PutToDebugLogException(3,"notifications OnTimerCycle parse displayed status",w)}if("Registered."!==he&&"Registered"!==he||(he+=webphone_api.global.credit),(he.indexOf("Registered")>=0||"Not Found"===he||he.indexOf("Ringing")>=0||he.indexOf("Incoming")>=0||he.indexOf("In Call")>=0||he.indexOf("Ringing")>=0||"Ringing"===he||"CallConnect"===he||"InCall"===he||"Speaking"===he)&&Ne!==webphone_api.global.useengine&&(Ne=webphone_api.global.useengine,webphone_api.common.SaveLastUsedEngine()),0!==he.indexOf("Credit:")&&1!==he.indexOf("Credit:")&&he.indexOf("Outband")<0&&he.indexOf("Deletable")<0&&he.indexOf("Outbound")<0&&he.toLowerCase().indexOf("subscribe")<0&&(he.toLowerCase().indexOf("hide")>=0&&(he=" "),"Finished"==he&&(he="Finished"),l(he,me,0,de,1)),n=40,webphone_api.global.ringstart_time>0&&webphone_api.global.callstart_time<1&&webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE){n=41,(webphone_api.common.isNull(k)||!1===webphone_api.common.IsNumber(k))&&(k=90001),(webphone_api.common.isNull(U)||!1===webphone_api.common.IsNumber(U))&&(U=0),(webphone_api.common.isNull(V)||!1===webphone_api.common.IsNumber(V))&&(V=0);var i=k;!0===webphone_api.global.incommingCall?U>0&&(i=U):V>0&&(i=V);var a=webphone_api.common.GetParameter2("cutincoming"),r=0;"-1"===a?r=-1:"0"===a?r=0:"1"===a&&(r=1),n=51,t-webphone_api.global.ringstart_time>i&&(0==webphone_api.global.lastringtimeouttick||t-webphone_api.global.ringstart_time>3e3)&&(webphone_api.global.lastringtimeouttick=t,e("Hangup because ringtimeout limit reached: "+i)),-1===r?!0===webphone_api.global.incommingCall&&t-webphone_api.global.ringstart_time>14e3&&"Chrome"===webphone_api.common.GetBrowser()&&e("Hangup because ringtimeout in Chrome browser limit reached: 14000"):1===r&&!0===webphone_api.global.incommingCall&&t-webphone_api.global.ringstart_time>14e3&&e("Hangup because ringtimeout in ALL browsers limit reached: 14000")}if(n=55,webphone_api.global.callstart_time>0&&webphone_api.common.GetParameter("devicetype")!==webphone_api.common.DEVICE_WIN_SOFTPHONE()&&webphone_api.common.getuseengine()!==webphone_api.global.ENGINE_SERVICE&&(n=56,(webphone_api.common.isNull(W)||!1===webphone_api.common.IsNumber(W))&&(n=57,W=108e5),n=58,t-webphone_api.global.callstart_time>W&&(n=67,webphone_api.common.PutToDebugLog(2,"EVENT, mlogic API_Hangup because calltimeout limit reached: "+W),n=68,webphone_api.hangup(!0),n=69)),n=70,!0===webphone_api.common.Glbr()&&!T&&0===webphone_api.global.creditRequestTimer&&P>2){var s=webphone_api.common.GetParameter("creditrequest");!webphone_api.common.isNull(s)&&s.length>0&&webphone_api.common.UriParser(s,"","","","","creditrequest")}if(webphone_api.global.creditRequestTimer++,webphone_api.global.creditRequestTimer>webphone_api.global.creditRequestIval&&(webphone_api.global.creditRequestTimer=0),t-L>webphone_api.global.presenceinterval&&(L=t,!1===webphone_api.common.IsSDK()&&!0===(M=webphone_api.common.UsePresence2())&&webphone_api.common.PresenceGet2(webphone_api.common.GetParameter("srvcontacts"))),!0===M&&!0===webphone_api.global.isMessageStarted&&++webphone_api.global.msg_presence_timer>200&&(webphone_api.global.msg_presence_timer=0,!1===webphone_api.common.IsSDK()&&webphone_api._message.RefreshPresence()),n=444110,t-D>O&&(D=t,webphone_api.common.CallWsuserKeepAlive(!1)),t-x>A&&webphone_api.global.phonestarted>2&&(x=t,webphone_api.common.PutToDebugLog(2,"EVENT, wsuser keepalive hourly"),webphone_api.common.CallWsuserKeepAlive(!0)),webphone_api.global.closeCallAtivity&&(webphone_api.global.CLOSE_CALL_TIMER<0&&(webphone_api.global.CLOSE_CALL_TIMER=webphone_api.common.GetParameterInt("closecall_timeout",3e3)),t-v>webphone_api.global.CLOSE_CALL_TIMER&&(n=444111,webphone_api.global.CLOSE_CALL_TIMER=-100,webphone_api.global.closeCallAtivity=!1,v=0,!1===webphone_api.global.incommingCall&&!1===webphone_api.global.checkIfInCall&&webphone_api.global.isCallStarted&&(!1!==webphone_api.common.IsSDK()||webphone_api.common.isNull(webphone_api._call)||webphone_api._call.CloseCall()))),t-S>5e3&&!0===webphone_api.global.wasSettModified){n=444112,S=t,webphone_api.global.wasSettModified=!1;var p="";p=1==webphone_api.common.IsSDK()?webphone_api.common.GetSettFilenameSDK():webphone_api.common.GetActiveAccSettingsFilename(),webphone_api.common.SaveSettingsFile(1,p,function(e){webphone_api.common.CanLog(2)&&(e?webphone_api.common.PutToDebugLog(3,"EVENT, SaveSettingsFile from timer Successfull"):webphone_api.common.PutToDebugLog(3,"ERROR, SaveSettingsFile from timer Failed"))})}if(t-N>200&&(N=t,!0===webphone_api.global.wasCtModified&&(n=444113,webphone_api.global.wasCtModified=!1,webphone_api.common.SaveContactsFile(function(e){e?webphone_api.common.PutToDebugLog(2,"EVENT, SaveContactsFile from timer Successfull"):webphone_api.common.PutToDebugLog(2,"ERROR, SaveContactsFile from timer Failed")}))),t-I>400&&(I=t,webphone_api.global.wasChModified&&(n=444114,webphone_api.global.wasChModified=!1,webphone_api.common.SaveCallhistoryFile(function(e){e?webphone_api.common.PutToDebugLog(2,"EVENT, SaveCallhistoryFile from timer Successfull"):webphone_api.common.PutToDebugLog(2,"ERROR, SaveCallhistoryFile from timer Failed")}))),n=444115,"Ringing"===Y&&!0===fe&&(Ee=webphone_api.common.GetTickCount(),fe=!1,ve=!0),"Speaking"===Y&&!0===we&&(Ee=webphone_api.common.GetTickCount(),we=!1,ve=!0),!1===webphone_api.common.IsSDK()&&webphone_api.global.isCallStarted&&!0===ve&&++Pe>=3){n=444116,Te=!0===webphone_api.common.GetHoldState(-1)?webphone_api.stringres.get("in_hold")+" ":"";var t=webphone_api.common.GetTickCount(),c=webphone_api.common.GetTickCount()-Ee,u=Math.floor(c/1e3),g=Math.floor(u/60);u%=60,u<10&&(u="0"+u),webphone_api.global.isCallStarted&&webphone_api.$("#call_duration").html(Te+g+":"+u+" "),Pe=0}if("Call Finished"!==Y&&"Finished"!==Y||webphone_api.common.GetNrOfActiveCalls()<1&&(ve=!1,fe=!0,we=!0,webphone_api.webrtcapi.RemoveUnusedAudioElements()),Q.indexOf(":")>0){n=444117;if("Call duration"===webphone_api.common.Trim(Q.substring(0,Q.indexOf(":")))){ve=!1,Te=webphone_api.stringres.get("duration")+" ";var h=webphone_api.common.Trim(Q.substring(Q.indexOf(":")+1,Q.length)),m=0,g=0,u=0;if(h.indexOf(":")<0?u=webphone_api.common.Trim(h.substring(0,h.indexOf(" "))):(m=webphone_api.common.Trim(h.substring(0,h.indexOf(":"))),h=webphone_api.common.Trim(h.substring(h.indexOf(":")+1,h.length)),g=webphone_api.common.Trim(h.substring(0,h.indexOf(":"))),h=webphone_api.common.Trim(h.substring(h.indexOf(":")+1,h.length)),u=webphone_api.common.Trim(h.substring(0,h.length))),!webphone_api.common.isNull(m)&&m.length>0&&webphone_api.common.IsNumber(m)){var d=webphone_api.common.StrToInt(m);d*=60,g=webphone_api.common.StrToInt(g)+d}if(webphone_api.global.isCallStarted&&webphone_api.$("#call_duration").html(Te+g+":"+u+" "),G&&!1===webphone_api.common.GetParameterBool("customizedversion",!0)){var b=webphone_api.common.StrToInt(g),_=webphone_api.common.StrToInt(u);if(b>0||_>30){var f=0;try{f=webphone_api.common.StrToInt(webphone_api.common.GetParameter("proversioncallcount"))}catch(E){webphone_api.common.SaveParameter("proversioncallcount","0")}f<25&&f++,webphone_api.common.SaveParameter("proversioncallcount",f.toString()),G=!1}}}}(t-webphone_api.global.httpkatimer>be||t-webphone_api.global.httpkatimer<0)&&webphone_api.global.phonestarted>1&&(webphone_api.common.GetParameter("devicetype")===webphone_api.common.DEVICE_WIN_SOFTPHONE()||webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE)&&(n=444118,webphone_api.global.httpkatimer=t,webphone_api.common.WinAPI("API_HTTPKeepAlive",function(e){webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, notifications OnTimerCycle API_HTTPKeepAlive response: "+e)}),webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE&&webphone_api.global.service_last_life_signal>10&&t-webphone_api.global.service_last_life_signal>8e3&&(webphone_api.common.WinAPI("API_HTTPKeepAlive",function(e){webphone_api.common.CanLog(5)&&webphone_api.common.PutToDebugLog(5,"EVENT, notifications OnTimerCycle API_HTTPKeepAlive responseB: "+e)}),webphone_api.common.isNull(B)||clearTimeout(B),B=null,B=setTimeout(function(){webphone_api.common.GetTickCount()-webphone_api.global.service_last_life_signal>8e3&&(webphone_api.global.service_last_life_signal=webphone_api.common.GetTickCount(),webphone_api.common.PutToDebugLog(2,"WARNING, call Handle WSAPIReConnect from timer"),webphone_api.common.WSAPIHandleReConnect()),webphone_api.common.isNull(B)||clearTimeout(B),B=null},2e3))),t-webphone_api.global.httpkatimer>_e&&webphone_api.common.getuseengine()===webphone_api.global.ENGINE_JAVA&&(webphone_api.global.httpkatimer=t,webphone_api.HTTPKeepAlive())}catch(C){webphone_api.common.PutToDebugLogException(2,"notifications: OnTimerCycle ("+n.toString()+")",C)}}function i(e,n,t,o,i,a,r){try{if(webphone_api.common.CanLog(4)&&webphone_api.common.PutToDebugLog(4,"EVENT, notifications CDR added; AddToCallLog(); number: "+e+"; type: "+n+"; recorded: "+t+"; duration: "+o+"; callDateTime = "+E+"; line: "+i),webphone_api.common.isNull(e)&&e.length<1)return;webphone_api.common.isNull(a)&&(a=""),a=webphone_api.common.ReplaceAll(a,","," "),a=webphone_api.common.Trim(a),webphone_api.global.refreshrecents=!0;var l=0;l=E>0?E:webphone_api.common.GetTickCount(),E=0,webphone_api.common.getuseengine()===webphone_api.global.ENGINE_SERVICE&&!webphone_api.common.isNull(o)&&webphone_api.common.IsNumber(o)&&o>0&&(webphone_api.common.SaveParameter("nsupdate","-1"),o>30&&(!0===webphone_api.global.usestorage||webphone_api.common.Strl(60))?webphone_api.common.SaveParameter("lnsengine","0"):webphone_api.common.SaveParameter("lnsengine","1"));var s=0,p=0,c="";try{o=Math.floor(o),s=Math.floor(o/60),p=o%60,s<10&&(c+="0"),c+=0===s?"0:":s+":",p<10&&(c+="0"),c+=p}catch(P){webphone_api.common.PutToDebugLogException(3,"notifications AddToCallLog calc duration",P)}webphone_api.common.isNull(webphone_api.global.callName)&&(webphone_api.global.callName=""),webphone_api.common.isNull(n)&&(n=""),webphone_api.common.isNull(t)&&(t=""),webphone_api.common.isNull(r)&&(r="");var u=r;u.length<1&&(1===webphone_api.common.IsMultiline()||!webphone_api.common.isNull(i)&&webphone_api.common.StrToInt(i)>1)&&(u=webphone_api.common.GetContactNameFromNumber(e));var g=webphone_api.common.GetContactIdFromNumber(e);if(g>=0){var h=webphone_api.global.ctlist[g];if(webphone_api.common.IsNumber(h[webphone_api.common.CT_USAGE])){var m=webphone_api.common.StrToInt(h[webphone_api.common.CT_USAGE]);m++,h[webphone_api.common.CT_USAGE]=m.toString(),webphone_api.global.ctlist[g]=h}}u==r||u===e&&(u=!webphone_api.common.isNull(webphone_api.global.telsearchname)&&webphone_api.global.telsearchname.length>0?webphone_api.common.Trim(webphone_api.global.telsearchname):webphone_api.global.callName),webphone_api.global.telsearchname="",(webphone_api.common.isNull(u)||u.length<1)&&(u=e);var d=1;"0"!==n&&(d=2),1==d?webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onoutcalldisconnected,"callDisconnected",d,e,u,"",l,o,webphone_api.global.lastcallcdr):webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_onincalldisconnected,"callDisconnected",d,e,u,"","","",webphone_api.global.lastcallcdr);var b=[n,u,e,""+l,""+o,t,a];if(webphone_api.global.chlist.unshift(b),webphone_api.global.wasChModified=!0,"2"===n){var _=e;_.length<1&&(_=u),u!=e&&e.length>0&&u.length>0&&(_=u+" - "+e),webphone_api.common.PutNotifications2("0",a,_,0)}if(webphone_api.common.isNull(u)||u.length<1||!1===webphone_api.common.ContactExists(u,"")){var f=null,w=!1;if(!webphone_api.common.isNull(webphone_api.global.alreadyCalledNrs)&&webphone_api.global.alreadyCalledNrs.length>0&&(f=webphone_api.global.alreadyCalledNrs.split(",")),!webphone_api.common.isNull(f))for(var v=0;v=0&&(n=n.substring(n.indexOf("MULTIPART:")+6),n=webphone_api.common.Trim(n.substring(n.indexOf(":")+1)));var o="";if(n.indexOf("GROUP:")>=0&&(o=n.substring(n.indexOf("GROUP:")+6),o=webphone_api.common.Trim(o.substring(0,o.indexOf(":"))),webphone_api.common.isNull(o)&&(o=""),n=n.substring(n.indexOf("GROUP:")+6),n=webphone_api.common.Trim(n.substring(n.indexOf(":")+1))),webphone_api.common.isNull(n)&&(n=""),n=webphone_api.common.Trim(n),0===n.indexOf("_BASE64_")&&(n=webphone_api.common.B64Dec(n),webphone_api.common.isNull(n)&&(n=""),n=webphone_api.common.Trim(n)),n===webphone_api.stringres.get("composing")||n===webphone_api.stringres.get("composing")+"...")return void webphone_api.common.PutToDebugLog(2,"CHATCOMPOSING,"+t+","+e+",1");if(n.indexOf("FILETRANSFER_DELIVERED:")>=0)return void(!0===webphone_api.global.isFiletransferStarted&&webphone_api.$("#ftranf_status").html(webphone_api.stringres.get("ftrnasf_status_delivered")));if(n.indexOf("[CONFERENCE]")>=0)return void webphone_api.common.ReceivedConferenceInvite(e,n);if(n.indexOf("[CONFERENCE_ANSWER]")>=0)return void(webphone_api.global.confanswer_received=!0);var i=n.indexOf("[PRESENCE,");if(i>=0){if(n=n.substring(i+10),(i=n.indexOf(","))>0){var a=webphone_api.common.Trim(n.substring(0,i)),r=webphone_api.common.Trim(n.substring(i));i=r.indexOf(","),i>0&&(r=r.substring(0,i)),r=webphone_api.common.Trim(r),webphone_api.common.SaveReceivedPresence2(a,r)}return}try{webphone_api.onChatCb(e,n,t,o)}catch(s){webphone_api.common.PutToDebugLogException(2,"There is an error in onChat() callback",s)}if(webphone_api.common.CallScriptingUrl(webphone_api.parameters.scurl_oninchat,"inChat","",e,e,n),0==webphone_api.common.IsSDK()){if(!0===webphone_api.common.UsePresence2()&&"dnd"===webphone_api.common.GetParameter("presencestatus").toLowerCase()){webphone_api.common.PutToDebugLog(2,"EVENT, dont show incoming chat from: "+e+", because presence is DND");var l=webphone_api.common.GetContactNameFromNumber(e);webphone_api.common.PutNotifications2("1","",l+" - "+e,0),!1===webphone_api.common.IsSDK()&&webphone_api._message.SaveMissedIncomingMessage("chat",e,l,n)}if(3==webphone_api.common.GetParameterInt("chatsms",0)||0==webphone_api.common.GetParameterInt("textmessaging",-1)||1==webphone_api.common.GetParameterInt("textmessaging",-1))return void webphone_api.common.PutToDebugLog(4,"ERROR, OnMessageReceived message dropped because chat is disabled by user");if(webphone_api.global.isMessageStarted)!1===webphone_api.common.IsSDK()&&webphone_api._message.ShowIncomingMessage("chat",e,n);else if(webphone_api.global.checkIfInCall){var l=webphone_api.common.GetContactNameFromNumber(e);webphone_api.common.PutNotifications2("1","",l+" - "+e,0),!1===webphone_api.common.IsSDK()&&webphone_api._message.SaveMissedIncomingMessage("chat",e,l,n)}else webphone_api.global.intentmsg[0]="action=chat",webphone_api.global.intentmsg[1]="to="+e,webphone_api.global.intentmsg[2]="message="+n,webphone_api.$.mobile.changePage("#page_message",{transition:"slide",role:"page"})}}catch(s){webphone_api.common.PutToDebugLogException(2,"notifications: OnMessageReceived",s)}}function r(e,n,t,o,i){var a='border="0"/>';try{if(e.length<1||n.length<1||t.length<1||o<1)return;if("2"!=n&&"4"!=n)return;var r=!1,l=o.split(a);if(webphone_api.common.isNull(l)||l.length<1)return;for(var s=l.length-1;s>=0;s--)if(!(webphone_api.common.isNull(l[s])||l[s].length<1)){var p=l[s].indexOf("

"),c=l[s].indexOf("

");if(!(p<0||c0){l[s]=l[s].substring(0,p);var g="spacer.png";"2"==n?g="icon_chat_status_green.png":"4"==n&&(g="icon_chat_status_black.png");var h='"),c=l[s].indexOf("

");p<0||c=0)return;if("Authenticated successfully"===e){if(a=2,!0===webphone_api.global.authenticated_displayed)return;webphone_api.global.authenticated_displayed=!0}if(webphone_api.global.flagWaitforautoprov)return;a=3,webphone_api.common.Trim(e).length<1&&(e=" "),e.indexOf(Ue)<0&&"ERROR"!==n&&"WARNING"!==n&&(a=4,webphone_api.global.last_good_status=e),a=5,webphone_api.global.laststatusdisplay=e;var r=webphone_api.common.GetTickCount();if(r-xe<5e3)return;!webphone_api.common.isNull(Ae)&&Ae.length>0&&e.indexOf(Ae)>=0&&(a=6,xe=r),a=7,e=e.replace("DISPLAY",""),a=8,e.toLowerCase().indexOf("demo")>=0&&(a=9,ye=r,Oe=e,De=n),r-ye<15e3?(e=Oe,n=De):(Oe="",De=""),a=10;var l=R;if(a=11,(webphone_api.common.isNull(n)||n.length<1)&&(a=12,n="EVENT"),a=13,"ERROR"===n&&(l="#FF0000"),"WARNING"===n&&(l="#D28F00"),e.toLowerCase().indexOf("success")>=0&&(l="#4EC200"),a=14,1===t?(a=15,webphone_api.common.isNull(Re)&&(Re=document.getElementById("status_message"))):(a=16,webphone_api.common.isNull(Ie)&&(Ie=document.getElementById("status_dialpad")),webphone_api.common.isNull(Ce)&&(Ce=document.getElementById("status_contactslist")),webphone_api.common.isNull(Ge)&&(Ge=document.getElementById("status_callhistorylist")),webphone_api.common.isNull(Le)&&(Le=document.getElementById("status_call")),webphone_api.common.isNull(Re)&&(Re=document.getElementById("status_message"))),a=17,!0===webphone_api.global.last_presence_enabled&&!0===webphone_api.global.pres_unreg_called){a=18;var s=e.toLowerCase();(s.indexOf("unregister")>=0||s.indexOf("register failed")>=0||s.indexOf("disconnected")>=0)&&(e="Offline")}a=19;var p=webphone_api.common.Translate(e);if(a=20,webphone_api.common.isNull(Ie)||-1!==o||(a=21,Ie.innerHTML=p,Ie.style.color=l),webphone_api.common.isNull(Ce)||-1!==o||(a=22,Ce.innerHTML=p,Ce.style.color=l),webphone_api.common.isNull(Ge)||-1!==o||(a=23,Ge.innerHTML=p,Ge.style.color=l),a=24,!webphone_api.common.isNull(Le)&&p.indexOf("uthenticated successfully")<1&&e.indexOf("uthenticated successfully")<1){a=25;var c=webphone_api.common.StrToIntDef(webphone_api.global.aline,-1),u="";if(a=26,c>=0&&"undefined"!=typeof webphone_api.global.callPageStatusCachePerLine[c]&&null!==webphone_api.global.callPageStatusCachePerLine[c]&&webphone_api.global.callPageStatusCachePerLine[c].length>=2&&(a=27,u=webphone_api.global.callPageStatusCachePerLine[c][0],webphone_api.common.isNull(u)&&(u="")),a=28,o>0||u.length>0&&c>0){a=29,webphone_api.common.isNull(webphone_api.global.rating)||!webphone_api.global.rating.length||"STATUS"!==n&&"EVENT"!==n||(a=30, p+=webphone_api.global.rating);try{if(a=31,"Finished"==u){a=32;0==e.indexOf("disc_reason: ")?(a=33,!0,u=webphone_api.common.Translate("Disconnected")+"
"+webphone_api.common.Translate(webphone_api.common.StrGetAfter(e,"disc_reason: ").trim())):0==e.indexOf(webphone_api.stringres.get("disc_reason")+": ")&&(a=34,!0,u=webphone_api.common.Translate("Disconnected")+"
"+webphone_api.common.Translate(webphone_api.common.StrGetAfter(e,webphone_api.stringres.get("disc_reason")+": ").trim())),a=35,null==ke&&(a=36,ke=setTimeout(function(){a=37;try{a=371,"Finished"!=Le.innerHTML&&0!=Le.innerHTML.indexOf("Disconnected")&&Le.innerHTML!=webphone_api.common.Translate("Finished")&&0!=Le.innerHTML.indexOf(webphone_api.common.Translate("Disconnected"))||(a=38,Le.innerHTML="")}catch(n){webphone_api.common.PutToDebugLogException(2,"notifications: DisplayStatus hidedisconnecttimer "+a.toString()+" "+i.toString()+" "+e,n)}},5e3))}else a=39,null!=ke&&(a=40,clearTimeout(ke),ke=null);if(a=41,(0==Le.innerHTML.indexOf("Disconnected")||0==Le.innerHTML.indexOf(webphone_api.common.Translate("Disconnected")))&&u.length>0&&"Finished"==u||u.length<1&&"Finished"==e)a=42;else if(u.length>0){a=43;var g=webphone_api.global.callPageStatusCachePerLine[c][1];a=44,u=webphone_api.common.Translate(u),a=45,Le.innerHTML=u,Le.style.color=g}else a=46,Le.innerHTML=p,Le.style.color=l}catch(m){try{webphone_api.common.PutToDebugLogException(2,"ERROR, DisplayStatus per line on call page "+a.toString(),m),Le.innerHTML=p,Le.style.color=l}catch(d){}}}}a=47,!webphone_api.common.isNull(Re)&&o>0&&(a=48,Re.innerHTML=p,Re.style.color=l),a=49;var h=''+p+"";try{a=50,webphone_api.RecDisplayableNotifications(h)}catch(d){webphone_api.common.PutToDebugLogException(2,"notifications: DisplayStatus RecDisplayableNotifications",d)}}catch(d){webphone_api.common.PutToDebugLogException(2,"notifications: DisplayStatus "+a.toString()+" "+i.toString()+" "+e,d)}}function s(){try{return webphone_api.common.isNull(b)&&(b="STATUS,-1,Ready."),b}catch(e){webphone_api.common.PutToDebugLogException(2,"notifications: GetStatus",e)}return""}function p(e){try{if(webphone_api.common.isNull(e)||e.length<1)return!0;var n=[];n.push("C"),n.push("a"),n.push("l"),n.push("l"),n.push("-"),n.push("I"),n.push("D"),n.push(":");var t=n.join(""),o=e.indexOf(t);if(o>0){var e=webphone_api.common.Trim(e.substring(o+8));e.indexOf("\r\n")>0&&(e=webphone_api.common.Trim(e.substring(0,e.indexOf("\r\n"))))}var i=0;e=e.toString();for(var a=0;a-3&&o<100)return o}}catch(i){webphone_api.common.PutToDebugLogException(2,"notifications: GetLineFromNot",i)}return n}function u(){try{le>0&&(webphone_api.$(document).mousemove(function(e){Ve=webphone_api.common.GetTickCount()}),webphone_api.$(document).keypress(function(e){Ve=webphone_api.common.GetTickCount()}),webphone_api.$(document).scroll(function(e){Ve=webphone_api.common.GetTickCount()}),webphone_api.common.isNull(se)||clearInterval(se),se=setInterval(function(){try{webphone_api.common.GetTickCount()-Ve<2e3&&"undefined"!=typeof AndroidWebphoneJsInterface&&null!==AndroidWebphoneJsInterface&&"undefined"!=typeof AndroidWebphoneJsInterface.jstoandroidEvents&&null!==AndroidWebphoneJsInterface.jstoandroidEvents&&AndroidWebphoneJsInterface.jstoandroidEvents("[USERINTERACTION]_NOTIFICATION")}catch(e){webphone_api.common.PutToDebugLogException(2,"notifications: ProcessNotifications inner AndroidWebphoneJsInterface userinteraction",e)}},500))}catch(e){webphone_api.common.PutToDebugLogException(2,"notifications: HandleAndroidUserInteraction",e)}}var g,h,m,d,b,_=!1,f=!1,w="",v=0,E=0,P=0,T=!1,S=0,N=0,I=0,C=100,G=!1,L=0,R="#ffffff",y=-1,D=0,O=18e4,x=0,A=36e5,k=0,U=0,V=0,W=0,F=!1,M=!1,H=0,B=null,j=null,$="",q="",z="",K="",X="",J="",Y="",Q="",Z="",ee="",ne=-1,te=null,oe=!1,ie=webphone_api.stringres.get("status_startingengine"),ae=webphone_api.stringres.get("status_enginestarted"),re="",le=-1,se=null,pe=0,ce=35,ue="",ge=-1,he="",me="",de=-1,be=9e3,_e=24e3,fe=!0,we=!0,ve=!1,Ee=0,Pe=0,Te="",Se=0,Ne="",Ie=null,Ce=null,Ge=null,Le=null,Re=null,ye=0,De="",Oe="",xe=0,Ae=webphone_api.stringres.get("disc_reason"),ke=null,Ue=webphone_api.stringres.get("ns_engine_unreachable"),Ve=0;return{ProcessNotifications:n,GetStatus:s,AddToCallLog:i,SetCallStartTime:t,IsGoodCRC:p,OnMessageReceived:a}}();