Index: /trunk/UPGRADE =================================================================== --- /trunk/UPGRADE (revision 81) +++ /trunk/UPGRADE (revision 1) @@ -1,29 +1,4 @@ Notes on upgrading from an older release ======================================== - -o Upgrading from version .28 to .29: - - No special features, just bugfixing and serving the policy file - from op_server.pl for newer flash clients. - -o Upgrading from version .27 to .28: - - New parameters in op_buttons.cfg - - SpyExt=100@spy - It lets you specify an extension@context to triger a chanspy - action for that call when dropping your phone over the Arrow - - no_label_counter=1 - To not show increment counter when specifying multiple - positions for a button. - - New experimental button type [DID/5555555] - It will try to match Freepbx FROM_DID incoming calls - - - New paramter "passvars" in op_server.cfg to pass extra values to - popups. It will pass the variable that is set to the channel via Set - in the dialplan before dialing to it in the GET request on the popup. o Upgrading from version .26 to .27: Index: /trunk/ming-source/operator_panel.pl =================================================================== --- /trunk/ming-source/operator_panel.pl (revision 92) +++ /trunk/ming-source/operator_panel.pl (revision 1) @@ -23,11 +23,8 @@ use SWF::Constants qw(:Text :Button :DisplayItem :Fill); -$stage_width = 996; -$stage_height = 600; - SWF::setScale(2); SWF::useSWFVersion(7); my $movie = new SWF::Movie(); -$movie->setDimension($stage_width * 10, $stage_height * 10); +$movie->setDimension(9960, 6000); $movie->setBackground(0xFF, 0xFF, 0xFF); $movie->setRate(20); @@ -35,5 +32,5 @@ -$fuente="/usr/src/ming/util/fonts/Arial.fdb"; +$fuente="fonts/Arial.fdb"; $fuente_nombre="Arial"; @@ -7296,11 +7293,4 @@ $movie->add(new SWF::Action(<<"EndOfActionScript")); -/* -XMLSocket.prototype.onData = function(msg) -{ - trace("MSG: " + msg) - msgArea.htmlText += msg -} -*/ function conecta() { @@ -7415,5 +7405,5 @@ } - logea(numeroboton+"|"+comando+"|"+textofinal.substring(0,20)); + // logea(numeroboton+"|"+comando+"|"+textofinal.substring(0,20)); var botonparte = numeroboton.split("@"); @@ -7504,5 +7494,4 @@ if (comando == "settext") { - _global.ipboton[boton_numero]=textofinal; setclid(statusclid,textofinal); } @@ -7734,9 +7723,9 @@ inicio_timer[boton_numero] = 0; - //if (_global.ipboton[boton_numero] != undefined) { - // setclid(statusclid,_global.ipboton[boton_numero]); - //} else { + if (_global.ipboton[boton_numero] != undefined) { + setclid(statusclid,_global.ipboton[boton_numero]); + } else { statusclid.text = ""; - //} + } flechita.gotoAndStop(3); @@ -7754,5 +7743,5 @@ } if (comando == "linked") { - if (textofinal.indexOf("@") == -1) { + if (textofinal.indexof("@") == -1) { sdo_boton = textofinal; } else { @@ -7770,11 +7759,5 @@ //var clidname = base64_decode(textofinal); _global.clidname[boton_numero]=textofinal; - //var clidname = base64_decode(textofinal); - } - if (comando == "setvar") { - if(_global.chanvars[boton_numero].length == undefined ) { - _global.chanvars[boton_numero] = new Array; - } - chanvars[boton_numero].push(textofinal); + var clidname = base64_decode(textofinal); } @@ -7805,38 +7788,8 @@ var c = new LoadVars(); //c.clid = clidnumber; - c.clid = Trim(_global.clidnumber[boton_numero]); + c.clid = _global.clidnumber[boton_numero]; c.clidname = _global.clidname[boton_numero]; - - - var decodeName = base64_decode(c.clidname); - var clidnumb = only_numbers(c.clid); - if(clidnumb.length>4) { - clidnumb="99999"; - } - clidnumb = int(clidnumb); - clidnumb = clidnumb+0; - - var isClickCall = decodeName.indexOf("Click to Dial"); - - var a=-1; - while (++a < chanvars[boton_numero].length) { - var datossplit = chanvars[boton_numero][a].split("="); - var mivar = datossplit[0]; - var mival = datossplit[1]; - c[mivar]=mival; - logea("mivar "+mivar+" has val "+mival); - } - delete chanvars[boton_numero]; - if (isClickCall > -1 || clidnumb<=9999) { - logea("avoid pop for clidnum or clidname"); - logea("number="+clidnumb); - logea("name="+decodeName); - } else { - c.send(url, target, 'GET'); - logea("send pop isclickcall = "+isClickCall); - logea("number="+clidnumb); - logea("name="+decodeName); - logea("Open url "+url+" in target "+target+" with clid "+c.clid); - } + c.send(url, target, 'GET'); + logea("Open url "+url+" in target "+target+" with clid "+clidnumber); } } else { @@ -7985,10 +7938,9 @@ if (comando == "registrado") { - if( _global.meetmemember[boton_numero]==0 || _global.meetmemember[boton_numero] == undefined ) { + if( _global.meetmemember[boton_numero]==0) { _root["rectangulo"+boton_numero]._alpha = 100; _root["resaltado"+boton_numero]._alpha = 100; } else { - logea("No alpha muted o unmuted "+boton_numero); - logea(_global.meetmemember[boton_numero]); + // logea("No le cambio alpha porque esta muted o unmuted"); } return; @@ -8043,6 +7995,6 @@ var lTextExtent = fmtLabel.getTextExtent ( text ); - var lWidth = lTextExtent.textFieldWidth + _global.label_extent_x; - var lHeight = lTextExtent.textFieldHeight + _global.label_extent_y; + var lWidth = lTextExtent.textFieldWidth + 10; + var lHeight = lTextExtent.textFieldHeight + 2; botref._width = lWidth; @@ -8406,25 +8358,4 @@ }; - flechi.onEnterFrame = function() { - if(this.hitTest(clip_arrastrado)) { - this._xscale = arrow_scale * 1.5; - this._yscale = arrow_scale * 1.5; - this.hitted = 1; - _global.flechahit = this; - } else { - if(this.hitted == 1) { - this.hitted = 0; - _global.flechahit = undefined; - } - } - if(this.hitted == 0) { - this._xscale = arrow_scale; - this._yscale = arrow_scale; - this.hitted = -1; - } - }; - - - // createCircle(cual,12*(arrow_scale/100),arrow_margin_left,arrow_margin_top-offsetboton+1,'0xff0000'); @@ -8724,5 +8655,5 @@ lastclick=0; doubleclickduration=300; - _global.swfversion="SVNVERSION"; + _global.swfversion="027.001"; _global.frames = 0; _global.step=2; @@ -8749,5 +8680,4 @@ _global.logwindow = 1; _global.margenbar = 2; - _global.chanvars = new Array(); _global.loglines = new Array(); _global.texto_tip = new Array(); @@ -8811,6 +8741,6 @@ // ancho_pantalla = System.capabilities.screenResolutionX; // alto_pantalla = System.capabilities.screenResolutionY; - ancho_pantalla_real = $stage_width; - alto_pantalla_real = $stage_height; + ancho_pantalla_real = 996; + alto_pantalla_real = 600; ancho_boton = Number(_root.vr.btn_width); alto_boton = Number(_root.vr.btn_height); @@ -9450,12 +9380,12 @@ // Un solo click if (clip._name.substring(0, 7) != "casilla") { - if (_global.authorized == true) { - if (_root.context.length>0) { - boton_numero_con_contexto = numeroclip+"@"+context; - } else { - boton_numero_con_contexto = numeroclip; - } - if (_global.meetmemember[numeroclip]>0) { + if (_global.meetmemember[numeroclip]>0) { + if (_global.authorized == true) { var statusclid = eval("rectangulo"+numeroclip+".statusprint"+numeroclip); + if (_root.context.length>0) { + boton_numero_con_contexto = numeroclip+"@"+context; + } else { + boton_numero_con_contexto = numeroclip; + } if (_global.meetmemute[numeroclip]>0) { logea("envio meetmemute"); @@ -9470,14 +9400,13 @@ } } else { - logea("no es meetmemember, empiezo record"); - envia_comando("startmonitor",numeroclip,numeroclip); - } + // Not authorized + envia_comando("bogus", 0, 0); + logea("no esta autorizado"); + } } else { - // Not authorized - envia_comando("bogus", 0, 0); - logea("no esta autorizado"); - } + logea("no es meetmemember"); + } } else { - logea("single click en led no hace nada "+clip._name); + logea("single click en led no hace nada"); } } @@ -9978,5 +9907,5 @@ // f_origen = timer_type[origen]; // f_destino = timer_type[destino]; - var extraclid = Trim(infotext1.clid_text.text); + var extraclid = Trim(infotext1.clidvalue); if (extraclid == undefined) { extraclid = ""; @@ -9996,17 +9925,4 @@ } } -//NICOX - if (_global.flechahit != undefined) { - var sobrecito = eval("rectangulo"+destino+".flecha"+destino); - if(sobrecito._visible == true) { - logea("como esta sobrecito: "+flecha._visible); - destino = ExtraeNumeroClip(_global.flechahit); - logea("transfiero "+origen+" a destino voicemail "+destino); - logea("_global.flechahit = "+_global.flechahit); - envia_comando("tospy", origen, destino); - done = 1; - } - } - if (destino!="" && origen!=destino && done!=1) { if (f_origen==1 && f_destino==0) { @@ -10035,9 +9951,8 @@ logea("f_origen "+f_origen+" f_destino "+f_destino); logea("timeout "+_global.timeout_value); - logea("extraclid "+extraclid); if (extraclid != "" && extraclid != "undefined") { extraclid = only_allowed_chars(extraclid); var comando = "coriginate-"+extraclid+"-"; - infotext1.clid_text.text = ""; + infotext1.clidvalue = ""; } else { var comando = "originate"; @@ -10054,20 +9969,4 @@ } -function only_numbers(str) { - allowed = "0123456789"; - var temp = new String(""); - for (a=0; a -# -# This program is free software, distributed under the terms of -# the GNU General Public License. -# -# THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -# IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -use SWF qw(:ALL); -use SWF::Constants qw(:Text :Button :DisplayItem :Fill); - -SWF::setScale(1); -SWF::useSWFVersion(6); -my $movie = new SWF::Movie(); -$movie->setDimension(100, 100); -$movie->setBackground(0xFF, 0xFF, 0xFF); -$movie->setRate(30); -$movie->add(new SWF::Action(<<"EndOfActionScript")); - -var dummyVar=(getTimer()+random(100000)); - -if(context != undefined) { - context = context.toUpperCase(); - colaEvento(0,"debug","contexto leido "+context); - if(context == "DEFAULT") { context=""; } -} else { - colaEvento(0,"debug","context undefined"); - context=""; -} - -var archivo = "variables"+context+".txt?rand="+dummyVar; - -vr = new LoadVars (); - -vr.onLoad = function (success) -{ - if (success == true) { - colaEvento(0,"debug","Ok al leer "+archivo); - nextFrame(); - } else { - colaEvento(0,"debug","Fallo al leer "+archivo); - stop(); - } -}; - -vr.load(archivo); - -EndOfActionScript - -$movie->nextFrame(); -$movie->add(new SWF::Action(<<"EndOfActionScript")); - -function conecta() { - _global.sock = new XMLSocket; - _global.sock.onConnect = handleConnect; - _global.sock.onClose = handleDisconnect; - _global.sock.onXML = handleXML; - if(_global.port == undefined) { - _global.port = 4445; - } - if(_global.server == undefined) { - _global.sock.connect(null, _global.port); - _global.server_print = "default"; - } else { - _global.sock.connect(_global.server, _global.port); - _global.server_print = _global.server; - } -} - -function handleConnect(connectionStatus){ - - if (connectionStatus) { - colaEvento(0,"debug","Conectado! con contexto: "+context); - _global.reconecta = 0; - if(_global.enable_crypto==1) { - envia_comando("contexto", 0, 0); - } else { - envia_comando("contexto", 1, 0); - } - if(restrict != undefined) { - envia_comando("restrict",restrict,0); - } - } else { - colaEvento(0,"debug","No pude conectar!"); - _global.reconecta = 1; - } -} - -function handleXML(doc){ - var e = doc.firstChild; - if (e != null) { - if (e.nodeName == "response") { - var numeroboton = e.attributes.btn; // btn is the button number - var comando = e.attributes.cmd; - var textofinal = e.attributes.data; - - if (_global.key != undefined) { - if(_global.enable_crypto == 1) { - comando = decrypt(comando, _global.key); - if (textofinal.length > 0) { - textofinal = decrypt(textofinal, _global.key); - } - } - } - - - var botonparte = numeroboton.split("@"); - var boton_numero = botonparte[0]; - var boton_contexto = botonparte[1]; - var timernumber = 0; - - - if (boton_contexto == undefined) { - boton_contexto = ""; - } - if (_root.context == undefined) { - _root.context = ""; - } - - - if (comando == "key") { - _global.key = textofinal; - return; - } - - if (comando == "restrict") { - _global.restrict = numeroboton; - _global.mybutton = numeroboton; - } - - if (comando == "version") { - if(textofinal != _global.swfversion) - { - _global.statusline=vr.version_mismatch; - } else { - _global.statusline=""; - } - } - - if (_root.context == boton_contexto) { - if(_global.restrict != undefined) { - if(_global.restrict == boton_numero) { - colaEvento(boton_numero,comando,textofinal); - } - } else { - colaEvento(boton_numero,comando,textofinal); - } - } - // endif root.context - } - // endif == response - } - // endiff e != null -} - -function colaEvento(boton_numero,comando,textofinal) { - - if(_global.VersionFlash == "MAC") { - // GetURL method for MAC - jsQueue.push("javascript: docommand('"+boton_numero+"','"+comando+"','"+textofinal+"')"); - } else { - // FSCommand method for anything else - jsQueue.push("newevent;"+boton_numero+"|"+comando+"|"+textofinal); - } -} - - -function handleDisconnect(){ - delete _global.key; - _global.reconecta = 1; - colaEvento(0,"debug","Attempt reconnection"); -} - - -Inicia_Variables = function () { - _global.jsQueue = new Array(); - var flashVersion = System.capabilities.version; - var datos = flashVersion.split(" "); - _global.VersionFlash = datos[0]; - _global.server = vr.server; - _global.port = vr.port; - _global.enable_crypto = Number(vr.enable_crypto); - if (isNaN(_global.enable_crypto)) { - _global.enable_crypto=0; - } else { - if(_global.enable_crypto != 0) { - _global.enable_crypto = 1; - } - } -}; - - -recarga = function () { - if(_global.restart == 1) { - // Send command to restart Asterisk - envia_comando("restart","1","1"); - } else { - // Reloads FLASH client - delete _global.key; - var incontext = context; - var inbutton = mybutton; - var inrestrict = _global.restrict; - var indial = dial; - var innohighlight = nohighlight; - for (var a in _root) { - if (typeof (_root[a]) == "object") { - removeMovieClip(_root[a]); - } - if (typeof (_root[a]) == "movieclip") { - removeMovieClip(_root[a]); - } - } - _global.context = incontext; - _global.mybutton = inbutton; - _global.restrict = inrestrict; - _global.dial = indial; - _global.nohighlight = inhighlight; - stop(); - gotoAndPlay(1); - } -}; - - -_root.onEnterFrame = function() { - - if(_global.jsQueue.length>0) { - if(_global.VersionFlash == "MAC") { - getURL(jsQueue.shift()); - } else { - var partes = jsQueue.shift().split(";"); - var comando=partes[0]; - var params=partes[1]; - getURL("FSCommand:"+comando,params); - } - } - -}; - -Timers = function () { - - if (_global.reconecta == 1) { - delete setInterval; - delete _global.key; - recarga(); - return; - } -}; - -setInterval(Timers, 10000); - -function ExtraeNumeroClip(name) { - var destino = ""; - name = name._name; - for (var s = 0; s"9") { - } else { - destino = destino+""+c; - } - if (c == ".") { - destino = ""; - } - } - return destino; -} - -envia_comando = function (comando, origen, destino) { - if (comando != "bogus" && comando != "contexto" && comando != "restrict") { - if (_global.restrict!=0) { - if(comando == "cortar") { - origen_number = ExtraeNumeroClip(origen); - } else { - origen_number = origen; - } - if(_global.restrict != undefined) { - if (_global.restrict == origen_number ) { - } else { - return; - } - } - } - } - message = new XML(); - message_data = message.createElement("msg"); - if (_root.context.length>0) { - agrega_contexto = "@"+context; - } - if (agrega_contexto == undefined) { - agrega_contexto = ""; - } - if (_level0.claveinput.secret == undefined) { - _level0.claveinput.secret = ""; - } - if (_global.claveingresada == undefined && ( comando != "contexto" && comando != "bogus" && comando != "dial" && comando != "restrict")) { - _root.codebox._visible = true; - Selection.setFocus(_root.codebox.claveform); - _root.codebox.swapDepths(_root.log); - return; - } - // var clave=_level0.claveinput.secret+_global.key; - var clave = _global.claveingresada+_global.key; - var md5clave = ""; - var md5clave = calcMD5(clave); - if (comando == "contexto" || comando == "restrict") { - md5clave = ""; - } - message_data.attributes.data = origen+agrega_contexto+"|"+comando+destino+"|"+md5clave; - message.appendChild(message_data); - _global.sock.send(message); - var clave = ""; -}; - -function LTrim(str) { - var whitespace = new String(" \t\n\r"); - var s = new String(str); - if (whitespace.indexOf(s.charAt(0)) != -1) { - var j = 0, i = s.length; - while (j=0 && whitespace.indexOf(s.charAt(i)) != -1) { - i--; - } - s = s.substring(0, i+1); - } - return s; -} - -function Trim(str) { - return RTrim(LTrim(str)); -} - -function setDND(obj, item) { - var nroboton = ExtraeNumeroClip(obj); - envia_comando("dnd", nroboton, nroboton); -} - -function genera_selecttimeout() { - - _global.positionselect = 0; - test = attachMovie("option","optionselected", getNextHighestDepth(), {_x:800, _y:6}); - test._visible = true; - test.legend = "No timeout"; - - test.onPress = function() { - _root.despliega_select(); - }; - - - for (a=0; a<5; a++) { - var b=a+1; - if (_global.opcionesTimeout[a] != undefined) { - - testa = attachMovie("option","option"+a, getNextHighestDepth(), {_x:800, _y:(b*22)+6}); - testa.legend = _global.opcionesTimeout[a]; - testa._visible = false; - - - testa.onRollOver = function() { - this.legend = "* "+this.legend; - }; - - testa.onRollOut = function() { - this.legend = this.legend.substring(2, this.legend.length); - }; - - testa.onPress = function() { - this.legend = this.legend.substring(2, this.legend.length); - var posicion = ExtraeNumeroClip(this); - _global.timeout_value = _global.opcionesTimeoutSecs[posicion]; - _root.muestra_selecttimeout(0); - _root.selectbox1.gotoAndStop(1); - _root.optionselected._visible=true; - _root.optionselected.legend = this.legend; - }; - } - } -}; - -function muestra_selecttimeout(value) { - for (a=0; a<5; a++) { - var v = eval("_root.option"+a); - if(value) { - v._visible = true; - } else { - v._visible = false; - } - } -}; - -function despliega_select() { - _root.optionselected._visible=false; - _root.selectbox1.gotoAndStop(2); - _root.muestra_selecttimeout(1); - -}; - -function base64_decode(opString) { - if ( opString == undefined ) { - return; - } - var str = opString; - var base64s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - var bits, bit1, bit2, bit3, bit4, i = 0; - var decOut = ""; - for (i=0; i> 16, (bits & 0xff00) >> 8, bits & 0xff); - } - if (str.charCodeAt(i-2) == 61) { - return decOut.substring(0, decOut.length-2); - } else if (str.charCodeAt(i-1) == 61) { - return decOut.substring(0, decOut.length-1); - } else { - return decOut.substring(0, decOut.length); - } -}; - - - -// MD5 ROUTINE -/* - * Convert a 32-bit number to a hex string with ls-byte first - */ -var hex_chr = "0123456789abcdef"; -// -// somehow the expression (bitAND(b, c) | bitAND((~b), d)) didn't return coorect results on Mac -// for: -// b&c = a8a20450, ((~b)&d) = 0101c88b, (bitAND(b, c) | bitAND((~b), d)) = a8a20450 <-- !!! -// looks like the OR is not executed at all. -// -// let's try to trick the P-code compiler into working with us... Prayer beads are GO! -// -function bitOR(a, b) { - var lsb = (a & 0x1) | (b & 0x1); - var msb31 = (a >>> 1) | (b >>> 1); - return (msb31 << 1) | lsb; -} -// -// will bitXOR be the only one working...? -// Nope. XOR fails too if values with bit31 set are XORed. -// -// Note however that OR (and AND and XOR?!) works alright for the statement -// (msb31 << 1) | lsb -// even if the result of the left-shift operation has bit 31 set. -// So there might be an extra condition here (Guessmode turned on): -// Mac Flash fails (OR, AND and XOR) if either one of the input operands has bit31 set -// *and* both operands have one or more bits both set to 1. In other words: when both -// input bit-patterns 'overlap'. -// Stuff to munch on for the MM guys, I guess... -// -function bitXOR(a, b) { - var lsb = (a & 0x1) ^ (b & 0x1); - var msb31 = (a >>> 1) ^ (b >>> 1); - return (msb31 << 1) | lsb; -} -// -// bitwise AND for 32-bit integers. This uses 31 + 1-bit operations internally -// to work around bug in some AS interpreters. (Mac Flash!) -// -function bitAND(a, b) { - var lsb = (a & 0x1) & (b & 0x1); - var msb31 = (a >>> 1) & (b >>> 1); - return (msb31 << 1) | lsb; - // return (a & b); -} -// -// Add integers, wrapping at 2^32. This uses 16-bit operations internally -// to work around bugs in some AS interpreters. (Mac Flash!) -// -function addme(x, y) { - var lsw = (x & 0xFFFF)+(y & 0xFFFF); - var msw = (x >> 16)+(y >> 16)+(lsw >> 16); - return (msw << 16) | (lsw & 0xFFFF); -} -function rhex(num) { - str = ""; - for (j=0; j<=3; j++) { - str += hex_chr.charAt((num >> (j*8+4)) & 0x0F)+hex_chr.charAt((num >> (j*8)) & 0x0F); - } - return str; -} -/* - * Convert a string to a sequence of 16-word blocks, stored as an array. - * Append padding bits and the length, as described in the MD5 standard. - */ -function str2blks_MD5(str) { - nblk = ((str.length+8) >> 6)+1; - // 1 + (len + 8)/64 - blks = new Array(nblk*16); - for (i=0; i> 2] |= str.charCodeAt(i) << (((str.length*8+i)%4)*8); - } - blks[i >> 2] |= 0x80 << (((str.length*8+i)%4)*8); - var l = str.length*8; - blks[nblk*16-2] = (l & 0xFF); - blks[nblk*16-2] |= ((l >>> 8) & 0xFF) << 8; - blks[nblk*16-2] |= ((l >>> 16) & 0xFF) << 16; - blks[nblk*16-2] |= ((l >>> 24) & 0xFF) << 24; - return blks; -} -/* - * Bitwise rotate a 32-bit number to the left - */ -function rol(num, cnt) { - return (num << cnt) | (num >>> (32-cnt)); -} -/* - * These functions implement the basic operation for each round of the - * algorithm. - */ -function cmn(q, a, b, x, s, t) { - return addme(rol((addme(addme(a, q), addme(x, t))), s), b); -} - -function ff(a, b, c, d, x, s, t) { - return cmn(bitOR(bitAND(b, c), bitAND((~b), d)), a, b, x, s, t); -} - -function gg(a, b, c, d, x, s, t) { - return cmn(bitOR(bitAND(b, d), bitAND(c, (~d))), a, b, x, s, t); -} - -function hh(a, b, c, d, x, s, t) { - return cmn(bitXOR(bitXOR(b, c), d), a, b, x, s, t); -} - -function ii(a, b, c, d, x, s, t) { - return cmn(bitXOR(c, bitOR(b, (~d))), a, b, x, s, t); -} -/* - * Take a string and return the hex representation of its MD5. - */ -function calcMD5(str) { - x = str2blks_MD5(str); - a = 1732584193; - b = -271733879; - c = -1732584194; - d = 271733878; - var step; - for (i=0; i=ls) { - break; - } - var pepe=s.charAt(is); - if (c2b[s.charAt(is)] == null) { - b[is] = 0xF7; - } else { - b[is] = c2b[s.charAt(is)]; - } - is++; - } - return b; -} -function bytes2str(b) { - var ib = 0; - var lb = b.length; - var s = ''; - while (1) { - if (ib>=lb) { - break; - } - if (b2c[0xFF & b[ib]]!=undefined) { - s += b2c[0xFF & b[ib]]; - } - ib++; - } - return s; -} -function ascii2bytes(a) { - var ia = -1; - var la = a.length; - var ib = 0; - var b = new Array(); - var carry; - while (1) { - // reads 4 chars and produces 3 bytes - while (1) { - ia++; - if (ia>=la) { - return b; - } - if (a2b[a.charAt(ia)] != null) { - break; - } - } - b[ib] = a2b[a.charAt(ia)] << 2; - while (1) { - ia++; - if (ia>=la) { - return b; - } - if (a2b[a.charAt(ia)] != null) { - break; - } - } - carry = a2b[a.charAt(ia)]; - b[ib] |= carry >>> 4; - ib++; - carry = 0xF & carry; - if (carry == 0 && ia == (la-1)) { - return b; - } - b[ib] = carry << 4; - while (1) { - ia++; - if (ia>=la) { - return b; - } - if (a2b[a.charAt(ia)] != null) { - break; - } - } - carry = a2b[a.charAt(ia)]; - b[ib] |= carry >>> 2; - ib++; - carry = 3 & carry; - if (carry == 0 && ia == (la-1)) { - return b; - } - b[ib] = carry << 6; - while (1) { - ia++; - if (ia>=la) { - return b; - } - if (a2b[a.charAt(ia)] != null) { - break; - } - } - b[ib] |= a2b[a.charAt(ia)]; - ib++; - } - return b; -} -function bytes2ascii(b) { - var ib = 0; - var lb = b.length; - var s = ''; - var b1; - var b2; - var b3; - var carry; - while (1) { - // reads 3 bytes and produces 4 chars - if (ib>=lb) { - break; - } - b1 = 0xFF & b[ib]; - s += b2a[63 & (b1 >>> 2)]; - carry = 3 & b1; - ib++; - if (ib>=lb) { - s += b2a[carry << 4]; - break; - } - b2 = 0xFF & b[ib]; - s += b2a[(0xF0 & (carry << 4)) | (b2 >>> 4)]; - carry = 0xF & b2; - ib++; - if (ib>=lb) { - s += b2a[carry << 2]; - break; - } - b3 = 0xFF & b[ib]; - s += b2a[(60 & (carry << 2)) | (b3 >>> 6)]+b2a[63 & b3]; - ib++; - if (ib%36 == 0) { - s += "\n"; - } - } - return s; -} -function bytes2blocks(bytes) { - var blocks = new Array(); - var ibl = 0; - var iby = 0; - var nby = bytes.length; - while (1) { - blocks[ibl] = (0xFF & bytes[iby]) << 24; - iby++; - if (iby>=nby) { - break; - } - blocks[ibl] |= (0xFF & bytes[iby]) << 16; - iby++; - if (iby>=nby) { - break; - } - blocks[ibl] |= (0xFF & bytes[iby]) << 8; - iby++; - if (iby>=nby) { - break; - } - blocks[ibl] |= 0xFF & bytes[iby]; - iby++; - if (iby>=nby) { - break; - } - ibl++; - } - return blocks; -} -function blocks2bytes(blocks) { - var bytes = new Array(); - var iby = 0; - var ibl = 0; - var nbl = blocks.length; - while (1) { - if (ibl>=nbl) { - break; - } - bytes[iby] = 0xFF & (blocks[ibl] >>> 24); - iby++; - bytes[iby] = 0xFF & (blocks[ibl] >>> 16); - iby++; - bytes[iby] = 0xFF & (blocks[ibl] >>> 8); - iby++; - bytes[iby] = 0xFF & blocks[ibl]; - iby++; - ibl++; - } - return bytes; -} -function digest_pad(bytearray) { - var newarray = new Array(); - var ina = 0; - var iba = 0; - var nba = bytearray.length; - var npads = 15-(nba%16); - newarray[ina] = npads; - ina++; - while (iba0) { - newarray[ina] = 0; - ina++; - ip--; - } - return newarray; -} -function pad(bytearray) { - var newarray = new Array(); - var ina = 0; - var iba = 0; - var nba = bytearray.length; - var npads = 7-(nba%8); - newarray[ina] = (0xF8 & rand_byte()) | (7 & npads); - ina++; - while (iba0) { - newarray[ina] = rand_byte(); - ina++; - ip--; - } - return newarray; -} -function rand_byte() { - return Math.floor(256*Math.random()); - if (!rand_byte_already_called) { - var now = new Date(); - seed = now.milliseconds; - rand_byte_already_called = true; - } - seed = (1029*seed+221591)%1048576; - return Math.floor(seed/4096); -} -function unpad(bytearray) { - var iba = 0; - var newarray = new Array(); - var ina = 0; - var npads = 0x7 & bytearray[iba]; - iba++; - var nba = bytearray.length-npads; - while (iba=nbl) { - break; - } - v0[0] = blocks[ibl]; - ibl++; - v0[1] = blocks[ibl]; - ibl++; - v1[0] = blocks[ibl]; - ibl++; - v1[1] = blocks[ibl]; - ibl++; - c0 = tea_code(xor_blocks(v0, c0), key); - c1 = tea_code(xor_blocks(v1, c1), key); - swap = c0[0]; - c0[0] = c0[1]; - c0[1] = c1[0]; - c1[0] = c1[1]; - c1[1] = swap; - } - var concat = new Array(); - concat[0] = c0[0]; - concat[1] = c0[1]; - concat[2] = c1[0]; - concat[3] = c1[1]; - return concat; -} -function encrypt(str, keystr) { - var key = new Array(); - key = binarydigest(keystr); - var blocks = new Array(); - blocks = bytes2blocks(pad(str2bytes(str))); - var ibl = 0; - var nbl = blocks.length; - // Initial Value for CBC mode = "abcdbcde". Retain for interoperability. - var c = new Array(); - c[0] = 0x61626364; - c[1] = 0x62636465; - var v = new Array(); - var cblocks = new Array(); - var icb = 0; - while (1) { - if (ibl>=nbl) { - break; - } - v[0] = blocks[ibl]; - ibl++; - v[1] = blocks[ibl]; - ibl++; - c = tea_code(xor_blocks(v, c), key); - cblocks[icb] = c[0]; - icb++; - cblocks[icb] = c[1]; - icb++; - } - return binary2ascii(cblocks); -} -function decrypt(ascii, keystr) { - var key = new Array(); - key = binarydigest(keystr); - var cblocks = new Array(); - cblocks = ascii2binary(ascii); - var icbl = 0; - var ncbl = cblocks.length; - var lastc = new Array(); - lastc[0] = 0x61626364; - lastc[1] = 0x62636465; - var v = new Array(); - var c = new Array(); - var blocks = new Array(); - var ibl = 0; - while (1) { - if (icbl>=ncbl) { - break; - } - c[0] = cblocks[icbl]; - icbl++; - c[1] = cblocks[icbl]; - icbl++; - v = xor_blocks(lastc, tea_decode(c, key)); - blocks[ibl] = v[0]; - ibl++; - blocks[ibl] = v[1]; - ibl++; - lastc[0] = c[0]; - lastc[1] = c[1]; - } - return bytes2str(unpad(blocks2bytes(blocks))); -} -function xor_blocks(blk1, blk2) { - var blk = new Array(); - blk[0] = blk1[0] ^ blk2[0]; - blk[1] = blk1[1] ^ blk2[1]; - return blk; -} -function tea_code(v, k) { - var v0 = v[0]; - var v1 = v[1]; - var k0 = k[0]; - var k1 = k[1]; - var k2 = k[2]; - var k3 = k[3]; - var sum = 0; - var n = 32; - while (n-->0) { - sum -= 1640531527; - // TEA magic number 0x9e3779b9 - sum = sum | 0; - v0 += ((v1 << 4)+k0) ^ (v1+sum) ^ ((v1 >>> 5)+k1); - v1 += ((v0 << 4)+k2) ^ (v0+sum) ^ ((v0 >>> 5)+k3); - } - var w = new Array(); - w[0] = v0 | 0; - w[1] = v1 | 0; - return w; -} -function tea_decode(v, k) { - var v0 = v[0]; - var v1 = v[1]; - var k0 = k[0]; - var k1 = k[1]; - var k2 = k[2]; - var k3 = k[3]; - var sum = 0; - var n = 32; - sum = -957401312; - while (n-->0) { - v1 -= ((v0 << 4)+k2) ^ (v0+sum) ^ ((v0 >>> 5)+k3); - v0 -= ((v1 << 4)+k0) ^ (v1+sum) ^ ((v1 >>> 5)+k1); - sum += 1640531527; - sum = sum | 0; - } - var w = new Array(); - w[0] = v0 | 0; - w[1] = v1 | 0; - return w; -} - -Key.addListener(Key); - -Key.onKeyDown = function(){ - var incremento = 1; - var tecla = Key.getCode(); - - if(tecla == 16) { - _global.shift = 1; - } - - if(tecla == 40) // DOWN - { - // Select next button DOWN - myapaga = eval('_root.resaltado'+_global.rectanguloprendido); - dif1 = (_global.rectanguloprendido) % _root.cuantas_filas; - incremento = 1; - if(dif1 == 0) { - // It changed the column, increment it again - incremento = incremento - _root.cuantas_filas; - } - proximo = _global.rectanguloprendido + incremento; - var myresa = eval('_root.resaltado'+proximo); - if(_global.rectanguloprendido != _global.restrict) { - myapaga._visible = false; - } - myresa._visible = true; - _global.rectanguloprendido = proximo; - _root.makeStatus(proximo); - } - if(tecla == 38) // UP - { - // Select next button UP - myapaga = eval('_root.resaltado'+_global.rectanguloprendido); - dif1 = (_global.rectanguloprendido-1) % _root.cuantas_filas; - incremento = -1; - if(dif1 == 0) { - // It changed the column, increment it again - incremento = incremento + _root.cuantas_filas; - } - proximo = _global.rectanguloprendido + incremento; - var myresa = eval('_root.resaltado'+proximo); - if(_global.rectanguloprendido != _global.restrict) { - myapaga._visible = false; - } - myresa._visible = true; - _global.rectanguloprendido = proximo; - _root.makeStatus(proximo); - } - if(tecla == 37) // LEFT - { - - if (_root.superdetails._visible == true) { - var tab = _root.superdetails.tab1._currentframe; - if(tab == 2) { - _root.superdetails.tab1.gotoAndStop(1); - _root.superdetails.tab2.gotoAndStop(2); - _root.superdetails.texto = _global.superdetailstexttab1; - } else { - _root.superdetails.tab1.gotoAndStop(2); - _root.superdetails.tab2.gotoAndStop(1); - _root.superdetails.texto = _global.superdetailstexttab2; - } - } else { - // Select next button on the LEFT - myapaga = eval('_root.resaltado'+_global.rectanguloprendido); - incremento = _root.cuantas_filas; - diferencia = _global.rectanguloprendido % _root.cuantas_filas; - proximo = _global.rectanguloprendido - incremento; - - if(proximo < 1) { - proximo = ((_root.cuantas_columnas - 1) * _root.cuantas_filas)+diferencia; - } - var myresa = eval('_root.resaltado'+proximo); - if(_global.rectanguloprendido != _global.restrict) { - myapaga._visible = false; - } - myresa._visible = true; - _global.rectanguloprendido = proximo; - _root.makeStatus(proximo); - } - } - - if(tecla == 39) // RIGHT - { - if(_root.detail._visible == true) { - _root.superdetails._visible = true; - _root.detail._visible = false; - } else if (_root.superdetails._visible == true) { - var tab = _root.superdetails.tab1._currentframe; - if(tab == 2) { - _root.superdetails.tab1.gotoAndStop(1); - _root.superdetails.tab2.gotoAndStop(2); - _root.superdetails.texto = _global.superdetailstexttab1; - } else { - _root.superdetails.tab1.gotoAndStop(2); - _root.superdetails.tab2.gotoAndStop(1); - _root.superdetails.texto = _global.superdetailstexttab2; - } - } else { - // Select next button on the RIGHT - myapaga = eval('_root.resaltado'+_global.rectanguloprendido); - total = _root.cuantas_filas * _root.cuantas_columnas; - incremento = _root.cuantas_filas; - diferencia = _global.rectanguloprendido % _root.cuantas_filas; - proximo = _global.rectanguloprendido + incremento; - - if(proximo > total) { - proximo = 1+diferencia-1; - } - var myresa = eval('_root.resaltado'+proximo); - if(_global.rectanguloprendido != _global.restrict) { - myapaga._visible = false; - } - myresa._visible = true; - _global.rectanguloprendido = proximo; - _root.makeStatus(proximo); - } - } - if(tecla == 9) // TAB - { - myapaga = eval('_root.resaltado'+_global.rectanguloprendido); - total = _root.cuantas_filas * _root.cuantas_columnas; - if(_global.shift == 1) { - incremento = -1; - } else { - incremento = 1; - } - proximo = _global.rectanguloprendido + incremento; - - if(proximo > total) { - proximo = 1; - } - if(proximo < 1) { - proximo = total; - } - var myresa = eval('_root.resaltado'+proximo); - if(_global.rectanguloprendido == _global.restrict) { - myapaga._visible = false; - } - myresa._visible = true; - _global.rectanguloprendido = proximo; - _root.makeStatus(proximo); - } - - if(tecla == 27) // ESC - { - _root.codebox._visible = false; - _root.log._visible = false; - _root.detail._visible = false; - _root.superdetails._visible = false; - } - - if(tecla == 18) // ALT - { - var myon = _global.rectanguloprendido; - if(myon>0) { - var myclip = eval('_level0.rectangulo'+myon+'.flecha'+myon); - _root.displaydetails(myclip); - } - } - - if(tecla == 13) // ENTER - { - if(_root.codebox._visible == true) { - // The security code box is visible, sends code and hides it - _global.claveingresada = _root.codebox.claveform.text; - _root.codebox._visible = false; - _root.envia_comando('bogus', 0, 0); - } else { - // The security code is not visible, open detail windows of - // highlighted button - var myon = _global.rectanguloprendido; - if(myon>0) { - var myclip = eval('_level0.rectangulo'+myon+'.flecha'+myon); - _root.displaydetails(myclip); - } - } - } - - -}; - -Key.onKeyUp = function(){ - var tecla = Key.getCode(); - if(tecla == 16) { - _global.shift = 0; - } -}; - -Inicia_Variables(); -conecta(); - -EndOfActionScript - -# Saves the movie -$movie->nextFrame(); -$movie->save("comunicator.swf",9); Index: /trunk/pepe =================================================================== --- /trunk/pepe (revision 1) +++ /trunk/pepe (revision 1) @@ -0,0 +1,319 @@ +Thu Dec 21 20:16:08 ART 2006 nicolas@house.com.ar + * restructure some if blocks, formatting fixes + +Thu Dec 21 20:14:51 ART 2006 nicolas@house.com.ar + * fix big memory leak + +Thu Dec 21 20:08:27 ART 2006 nicolas@house.com.ar + * updated swf back to new version + +Mon Dec 11 12:23:31 ART 2006 nicolas@house.com.ar + * link fix + +Mon Nov 20 11:41:39 ART 2006 nicolas@house.com.ar + * update CHANGES + +Mon Nov 20 11:40:40 ART 2006 nicolas@house.com.ar + * defaults to free after fopledcolor + +Fri Nov 17 21:02:38 ART 2006 nicolas@house.com.ar + * update docs and binary swf + +Fri Nov 17 21:00:38 ART 2006 nicolas@house.com.ar + * fix event order to give precedence to astdb fopledcolors + +Fri Nov 17 21:00:04 ART 2006 nicolas@house.com.ar + * update docs on astdbkey and groupcount features + +Fri Nov 17 20:58:56 ART 2006 nicolas@house.com.ar + * update ming source for flash client adding images and textexten + +Fri Nov 17 20:57:07 ART 2006 nicolas@house.com.ar + * add park support to dhtml panel (thanks Jeremy) + +Thu Nov 16 14:46:07 ART 2006 nicolas@house.com.ar + * add CHANGES file that was somewhat forgotten + +Thu Nov 16 14:43:18 ART 2006 nicolas@house.com.ar + * Improve Autosip buttons + +Tue Nov 14 14:18:57 ART 2006 nicolas@house.com.ar + * fix groupcount outbound label + +Mon Nov 13 20:57:26 ART 2006 nicolas@house.com.ar + * groupcount example button + +Mon Nov 13 20:47:37 ART 2006 nicolas@house.com.ar + * add norwegian lang + +Mon Nov 13 20:46:29 ART 2006 nicolas@house.com.ar + * doc formatting fix + +Mon Nov 13 20:46:05 ART 2006 nicolas@house.com.ar + * assorted fixes + +Mon Nov 13 20:45:37 ART 2006 nicolas@house.com.ar + * groupcount button feature + +Mon Nov 13 20:44:52 ART 2006 nicolas@house.com.ar + * add image primitive + +Mon Nov 13 20:43:03 ART 2006 nicolas@house.com.ar + * lang updates + +Mon Nov 13 20:41:47 ART 2006 nicolas@house.com.ar + * docs update + +Fri Oct 20 15:46:47 ART 2006 nicolas@house.com.ar + * add images + +Wed Oct 11 18:29:05 ART 2006 nicolas@house.com.ar + * config doc and style update + +Wed Oct 11 18:22:26 ART 2006 nicolas@house.com.ar + * config and lang updates + +Wed Oct 11 18:19:17 ART 2006 nicolas@house.com.ar + * Agent fixes + +Mon Oct 9 17:37:19 ART 2006 nicolas@house.com.ar + * Fix ASTDB + +Mon Oct 9 17:36:54 ART 2006 nicolas@house.com.ar + * new swf + +Thu Sep 14 19:00:16 ART 2006 nicolas@house.com.ar + * clidname + +Sat Sep 9 13:13:42 ART 2006 nicolas@house.com.ar + * Fix reverse transfer for runk buttons + +Sat Sep 9 13:13:29 ART 2006 nicolas@house.com.ar + * typo in dhtml panel + +Sat Sep 9 13:12:55 ART 2006 nicolas@house.com.ar + * doc update + +Mon Aug 28 16:55:23 ART 2006 nicolas@house.com.ar + * comment config + +Mon Aug 28 16:45:20 ART 2006 nicolas@house.com.ar + * Assorted patches, show borders, paused, attendant transfers + +Thu Jun 1 10:12:09 ART 2006 nicolas@house.com.ar + * auto_sip buttons entry in doc[_^H_] and config + +Thu Jun 1 10:08:18 ART 2006 nicolas@house.com.ar + * fix warning when computing queue positions + +Thu Jun 1 10:07:27 ART 2006 nicolas@house.com.ar + * add queue_object hash to keep track of agent status per queue (talking, ready, unavailable) + +Thu Jun 1 10:06:02 ART 2006 nicolas@house.com.ar + * first pass at auto_sip buttons + +Thu Jun 1 10:04:31 ART 2006 nicolas@house.com.ar + * fix crash on meetme transfers to voicemail + +Thu Jun 1 09:59:22 ART 2006 nicolas@house.com.ar + * rename hash to better name and remove some comments for queue-agents + +Thu Jun 1 09:57:16 ART 2006 nicolas@house.com.ar + * flash client optimization on debug windown[_^H_] + +Fri May 19 17:45:49 ART 2006 nicolas@house.com.ar + tagged 0.27 + +Fri May 19 17:44:52 ART 2006 nicolas@house.com.ar + * update docs + +Fri May 19 17:41:26 ART 2006 nicolas@house.com.ar + * tovoicemail fix and label renaming fix + +Fri May 19 17:39:43 ART 2006 nicolas@house.com.ar + * queue position fix + +Wed May 10 09:03:29 ART 2006 nicolas@house.com.ar + * dhtml client files + +Tue May 9 21:42:51 ART 2006 nicolas@house.com.ar + * update docs + +Tue May 9 21:41:47 ART 2006 nicolas@house.com.ar + * doc updates + +Tue May 9 20:19:51 ART 2006 nicolas@house.com.ar + * yyy[_^H_][_^H_][_^H_]format fixes + +Tue May 9 20:18:24 ART 2006 nicolas@house.com.ar + * doc updates + +Tue May 9 19:24:08 ART 2006 nicolas@house.com.ar + * yyyyyy[_^H_][_^H_][_^H_][_^H_][_^H_]new dhtml client + +Tue May 9 19:18:54 ART 2006 nicolas@house.com.ar + * new swf + +Tue May 9 19:16:16 ART 2006 nicolas@house.com.ar + * doc updates + +Tue May 9 15:37:40 ART 2006 nicolas@house.com.ar + * yyy[_^H_][_^H_][_^H_]reorginizing directories + +Tue May 9 15:37:26 ART 2006 nicolas@house.com.ar + * reorginizing dir + +Tue May 9 15:36:57 ART 2006 nicolas@house.com.ar + * organizing directories + +Tue May 9 15:33:27 ART 2006 nicolas@house.com.ar + * documentation updates + +Tue May 9 15:05:22 ART 2006 nicolas@house.com.ar + * assorted client fixes, removed scriptable actions for now + +Tue May 9 15:03:27 ART 2006 nicolas@house.com.ar + * y[_^H_]removed scriptable actions and assorted bug fixes + +Sat Apr 29 15:41:14 ART 2006 nicolas@house.com.ar + * ming client updates + +Sat Apr 29 15:40:06 ART 2006 nicolas@house.com.ar + * formatting fixes + +Sat Apr 29 13:33:28 ART 2006 nicolas@house.com.ar + * formattng fixes + +Sat Apr 29 13:04:58 ART 2006 nicolas@house.com.ar + * set clid format on link event + +Sat Apr 29 13:04:43 ART 2006 nicolas@house.com.ar + * fix auto counters when using regexp butons + +Sat Apr 29 13:03:25 ART 2006 nicolas@house.com.ar + * scriptable actions, tovoicemail actions, formatting fixs + +Sat Apr 29 12:58:54 ART 2006 nicolas@house.com.ar + * includes style, simplify read configs, formatting fixes, removed commentes + +Sat Apr 29 12:57:22 ART 2006 nicolas@house.com.ar + * log fake events + +Sat Apr 29 12:52:48 ART 2006 nicolas@house.com.ar + * transfer to voicemail + +Sat Apr 29 11:40:50 ART 2006 nicolas@house.com.ar + * agent status updates, paused and some formatting fixes + +Sat Apr 29 11:13:04 ART 2006 nicolas@house.com.ar + * clid privacy per button + +Sat Apr 29 11:02:16 ART 2006 nicolas@house.com.ar + * background jpg foor[_^H_][_^H_][_^H_][_^H_] + +Thu Mar 23 14:47:57 ART 2006 nicolas@house.com.ar + * remove duplicated code + +Thu Mar 23 14:47:18 ART 2006 nicolas@house.com.ar + * suse init fixes + +Thu Mar 23 14:46:39 ART 2006 nicolas@house.com.ar + * configurable dimm/alpha + +Thu Mar 16 16:14:36 ART 2006 nicolas@house.com.ar + tagged 0.26 + +Mon Mar 13 17:01:23 ART 2006 nicolas@house.com.ar + * documentation updates + +Mon Mar 13 16:56:00 ART 2006 nicolas@house.com.ar + * queueagent optimizations + +Fri Mar 10 17:39:17 ART 2006 nicolas@house.com.ar + * noconvert + +Fri Mar 10 17:37:28 ART 2006 nicolas@house.com.ar + * nochanges + +Fri Mar 10 17:33:25 ART 2006 nicolas@house.com.ar + * clean internal state when connecting to server + +Fri Mar 10 17:07:09 ART 2006 nicolas@house.com.ar + * add_server_to_fake_events + We need to add the server header to fake events! + +Fri Mar 10 17:06:44 ART 2006 nicolas@house.com.ar + * formatting_fixes + +Fri Mar 10 17:05:26 ART 2006 nicolas@house.com.ar + * nocontext_in_button_hash + Do we really need to store the panel context in the buttons hash? + +Fri Mar 10 17:05:03 ART 2006 nicolas@house.com.ar + * update docs + +Mon Feb 27 19:40:37 ART 2006 nicolas@house.com.ar + * updated docs + +Mon Feb 27 19:27:28 ART 2006 nicolas@house.com.ar + * do not send settimer for nonexistant queues + +Mon Feb 27 19:27:13 ART 2006 nicolas@house.com.ar + * formatting fix + +Mon Feb 27 19:26:48 ART 2006 nicolas@house.com.ar + * formatting fix + +Mon Feb 27 19:25:36 ART 2006 nicolas@house.com.ar + * Clear counter when there are no calls in queue + +Mon Feb 27 17:27:41 ART 2006 nicolas@house.com.ar + * restrict to channel name same as mybutton + +Mon Feb 27 17:26:42 ART 2006 nicolas@house.com.ar + * restrict to channel name same as mybutton + +Tue Feb 21 17:26:31 ART 2006 nicolas@house.com.ar + * formatting cleanups + +Tue Feb 21 17:26:13 ART 2006 nicolas@house.com.ar + * fix_meetme_sccp + +Tue Feb 21 16:09:02 ART 2006 nicolas@house.com.ar + * Catalan language + +Mon Feb 20 16:10:40 ART 2006 nicolas@house.com.ar + * suse_init + +Mon Feb 20 15:55:22 ART 2006 nicolas@house.com.ar + * link_buttons + Add url and target to the button definition so you can hyperlink + to anything you want from any button. + Also added the enable_label_background that sets the background + color on the labels to the led colors depeding on state. + +Thu Feb 2 17:51:42 ART 2006 nicolas@house.com.ar + * listen_addr + Add listen_addr parameter to select the ip address the server will bind to + +Tue Jan 31 20:49:13 ART 2006 nicolas@house.com.ar + * NewSwf + +Tue Jan 31 20:47:11 ART 2006 nicolas@house.com.ar + * fontfix + Fix several font issues on the flash client + +Tue Jan 31 20:41:04 ART 2006 nicolas@house.com.ar + * Remove channel from queue hash on rename.. fix for queue buttons + +Tue Jan 31 20:32:40 ART 2006 nicolas@house.com.ar + * Ignore & from trunk sessions, fix TRUNK problem. + +Tue Dec 27 00:33:17 ART 2005 nicolas@house.com.ar + * Fixed trunk sticky problem + +Tue Dec 27 00:32:16 ART 2005 nicolas@house.com.ar + tagged 0.25 + +Tue Dec 27 00:32:06 ART 2005 nicolas@house.com.ar + * Initial import. Index: /trunk/op_buttons.cfg =================================================================== --- /trunk/op_buttons.cfg (revision 74) +++ /trunk/op_buttons.cfg (revision 1) @@ -20,5 +20,4 @@ Astdbkey=10 ; If using astdb functions, enable it for this button ; using the key provided -SpyExt=20@spy [SIP/11] @@ -277,30 +276,4 @@ y=30 - - -# The entry below will create ONE button -# showing the number of ZAP channels used -# for an E1 trunk (zap/1 to zap/31 -# -# Interesting bits: regexp, groupcount, and count -# -# groupcount will count number of channels used -# count will set and limit the number of sessions matched -;[_Zap\/(\d$|1\d$|2\d$|3[01]$)] -;Position=70 -;Count=31 -;Label=Trama 1 -;Icon=2 -;groupcount=1 - - -# The following entry same as above but -# for 2nd E1 line (zap/32 to zap/62) -;[_Zap\/(3[2-9]$|4\d$|5\d$|6[012]$)] -;Position=71 -;Count=31 -;Label=Trama 2 -;Icon=2 -;groupcount=1 Index: /trunk/RECIPES =================================================================== --- /trunk/RECIPES (revision 5) +++ /trunk/RECIPES (revision 1) @@ -15,23 +15,20 @@ in extensions.conf: -exten => *78,1,Set(DB(dnd/${CUT(CHANNEL|-|1)})=Break) -exten => *78,n,UserEvent(ASTDB|Channel: ${CHANNEL}^Family: dnd^Value: Break) -exten => *78,n,Hangup +exten => *78,1,UserEvent(ASTDB|Family: dnd^Value: On) +exten => *78,2,SetVar(temp=${CHANNEL}) +exten => *78,3,Cut(temp=temp,,1) +exten => *78,4,DBPut(dnd/${temp}=On) +exten => *78,5,Hangup -exten => *79,1,Set(DB(dnd/${CUT(CHANNEL|-|1)})=) -exten => *79,n,UserEvent(ASTDB|Channel: ${CHANNEL}^Family: dnd^Value: ^) -exten => *79,n,Hangup +exten => *79,1,UserEvent(ASTDB|Family: dnd^Value: ^) +exten => *79,2,SetVar(temp=${CHANNEL}) +exten => *79,3,Cut(temp=temp,,1) +exten => *79,4,DBDel(dnd/${temp}) +exten => *79,5,Hangup in op_astdb.cfg: - [dnd] -settext=DND: ${value}| -fopledcolor=0x001020^0|0x00A000^0 - -in op_buttons.cfg - -[SIP/1234] -.. -astdbkey=SIP/1234 +settext=DND: ${value} +setalpha=70 RECIPE 2 @@ -46,6 +43,6 @@ [rxfax] -exten => s,1,Set(FAXFILE=/var/spool/fax/fax-${TIMESTAMP}.tif) -exten => s,2,Set(LOCALSTATIONID=My Company) +exten => s,1,SetVar(FAXFILE=/var/spool/fax/fax-${TIMESTAMP}.tif) +exten => s,2,SetVar(LOCALSTATIONID=My Company) exten => s,3,UserEvent(Newexten|Channel: FAX/FAX-${UNIQUEID}^State: Up^Uniqueid: 1234) exten => s,4,rxfax(${FAXFILE}) Index: /unk/flash/crossdomain.xml =================================================================== --- /trunk/flash/crossdomain.xml (revision 69) +++ (revision ) @@ -1,5 +1,0 @@ - - - - - Index: /unk/flash/help_ru.html =================================================================== --- /trunk/flash/help_ru.html (revision 36) +++ (revision ) @@ -1,14 +1,0 @@ -

ПереЎ выпПлМеМОеЌ ÐºÐ°ÐºÐžÑ --лОбП ЎействОй, ваЌ слеЎует ввестО кПЎ безПпасМПстО.
-
-ППсле этПгП вы сЌПжете: -

    -
  • ПеревПЎОть звПМкО: перетащОв зМачПк телефПМа Ма МужМПе ваЌ целевПй МПЌер
  • -
  • Сбрасывать звПМкО: ЎвПйМыЌ клОкПЌ Ма красМую кМПпку
  • -
  • ИМОцООрПвать звПМкО: перетаскОваМОеЌ свПбПЎМПгП вМутреММегП МПЌера Ма свПбПЎМый целевПй МПЌер
  • -
  • КПМфереМц-связь: Вы ЌПжете ЎПбавОть третьегП сПбесеЎМОка в существующОй разгПвПр путеЌ перетаскОваМОя свПбПЎМПгП вМутреММегП МПЌера в зПМу ЎействующегП разгПвПра.
  • -
-Также Вы ЌПжете впОсать ЎПбавПчМую ОМфПрЌацОю в пПле ОМфПрЌацОО переЎ перевПЎПЌ ОлО МачалПЌ МПвПгП звПМка. -В такПЌ случае, ПМ пПказывается как текст АОНа Ўля любПгП МПвПгП ОлО перевеЎеММПгП звПМка МапрОЌер: -"740-9982 НОкПлай Оз ЊеМтрПбаМка" -

Index: /trunk/README =================================================================== --- /trunk/README (revision 5) +++ /trunk/README (revision 1) @@ -68,31 +68,22 @@ (if you are reading this you probably already done that) -2) Copy the files in the 'flash' or 'dhtml' subdirectory to a suitable place +1) Copy the files in the 'flash' or 'dhtml' subdirectory to a suitable place on your web server. If your web root is /var/www/html, you can create a - subdirectory 'panel' and copy the files there. The base files required - for the flash client are index.html and operator_panel.swf, you can also - copy the help files for your language. + subdirectory 'panel' and copy the files there. There are several ways (index files) to load the flash applet, try them out. You can modify the file help-xx.html files to your liking. - The dhtml panel allows you to use javascript/dhtml to desing your own - layout. But the client is limited to monitoring (you cannot perform - actions yet) - -3) Edit op_server.cfg and change the appropriate parameters for your setup. +2) Edit op_server.cfg and change the appropriate parameters for your setup. "flash_dir" parameter must be the exact location of the directory where - the html and swf files are placed (where you copied the files from step - 2 above) + the html and swf files are placed. - The rest of the parameters are well commented in the cfg file, basically - you have to set the manager host, user and password. (Be sure to enable - the manager in /etc/asterisk/manager.conf) + The rest of the parameters are well commented in the cfg file -4) Edit op_buttons.cfg to suit your needs. The file is commented and its +3) Edit op_buttons.cfg to suit your needs. The file is commented and its self explanatory. -5) Edit op_style.cfg to suit your needs. You can change the button size and +4) Edit op_style.cfg to suit your needs. You can change the button size and colors, icon placement and size, etc. DO NOT modify the variable names, just the value after the equal sign and DO NOT use spaces. With proper @@ -131,6 +122,5 @@ ------- -The op_server.pl must run on the same computer as the web server, but not -necesarily on the machine where asterisk is installed. +The op_server.pl must run on the same computer as the web server When started, it writes the file 'variables.txt' to the http directory where Index: /trunk/op_server.cfg =================================================================== --- /trunk/op_server.cfg (revision 69) +++ /trunk/op_server.cfg (revision 1) @@ -1,6 +1,3 @@ [general] -; If you want to use freepbx/trixbox conf file, set this to 1 -use_amportal_conf=0; - ; host or ip address of asterisk manager_host=192.168.0.1 @@ -60,5 +57,5 @@ ; Frequency in second to poll for sip and iax status -poll_interval=12000 +poll_interval=120 ; Poll for voicemail status (only necesary when you access the @@ -69,8 +66,4 @@ ; 0 Disable kill_zombies=0 - - -parkexten=700 -parktimeout=30 ; Debug level to stdout (bitmap) @@ -198,12 +191,4 @@ voicemail_extension = 3000@features - -; Channel variables to be passed from origin channels to Ringing channels -; Those variables will appear in the popup base64 encoded. A new event -; will be generated to clients in the form: -; "setvar" and data VARNAME=BASE64(value) -passvars=FROM_DID - - ; Attendant transfers. If this parameters are uncomented, then ; barge in functionality will be replaced with attendant transfers @@ -236,13 +221,4 @@ ;attendant_failure_redirect_to = 6${EXTEN}@${CONTEXT} - -; It is possible to start monitoring a conversation -; by single clicking on the arrow for a button -; FOP will use a filename and format based on the -; following two paramters: - -;monitor_filename = FOP-${CLIDNUM}-${LINK}-${UNIQUEID} -;monitor_format = gsm - ; You can have panel contexts with their own Index: /trunk/init/op_panel_redhat.sh =================================================================== --- /trunk/init/op_panel_redhat.sh (revision 37) +++ /trunk/init/op_panel_redhat.sh (revision 1) @@ -8,6 +8,6 @@ . /etc/rc.d/init.d/functions -DAEMON=/usr/local/fop/op_server.pl -OPTIONS="-d -c /etc/asterisk/fop" +DAEMON=/usr/local/operator/op_server.pl +OPTIONS=-d RETVAL=0 Index: /trunk/extensions.conf.sample =================================================================== --- /trunk/extensions.conf.sample (revision 5) +++ /trunk/extensions.conf.sample (revision 1) @@ -24,2 +24,23 @@ +# Example on setting DND state from the dialplan +# *78 Sets DND ON +# *79 Sets DND OFF +# +# This example only sets the dnd db value and +# signals FOP to display the status on the button +# you might have to add a check in your stdext +# macro to honour the DND status + +exten => *78,1,UserEvent(ASTDB|Family: dnd^State: On) +exten => *78,2,SetVar(temp=${CHANNEL}) +exten => *78,3,Cut(temp=temp,,1) +exten => *78,4,DBPut(dnd/${temp}=On) +exten => *78,5,Hangup + +exten => *79,1,UserEvent(ASTDB|Family: dnd^State: ^) +exten => *79,2,SetVar(temp=${CHANNEL}) +exten => *79,3,Cut(temp=temp,,1) +exten => *79,4,DBDel(dnd/${temp}) +exten => *79,5,Hangup + Index: /trunk/TODO =================================================================== --- /trunk/TODO (revision 6) +++ /trunk/TODO (revision 1) @@ -2,4 +2,5 @@ * A way to set astdb values from the .swf * A way to perform any cli or manager action from the .swf +* Go to Astricon USA with more help * Change user authentication and restrictions methods * Get some sleep Index: /trunk/dhtml/js/operator.js =================================================================== --- /trunk/dhtml/js/operator.js (revision 72) +++ /trunk/dhtml/js/operator.js (revision 1) @@ -1,2 +1,4 @@ +info = new Object(); +mwiinfo = new Object(); Event.observe(window, 'load', init, false); @@ -145,9 +147,9 @@ } } - - if(comando=="park") { - boton.className="park"; - clid.innerHTML=texto; - } + + if(comando=="park") { + boton.className="park"; + clid.innerHTML=texto; + } if(comando == "settext") { @@ -160,5 +162,5 @@ var i = textodecode.indexOf("\n"); textodecode = replace(textodecode,'\n','
'); - $('phonetip'+nro).innerHTML=textodecode; + info["phone"+nro]=textodecode; } @@ -218,7 +220,7 @@ } if(comando == "voicemailcount") { - $('mwitip'+nro).innerHTML=texto; - } - -} - + mwiinfo["mwi"+nro]=texto; + } + +} + Index: /trunk/dhtml/js/dhtmltooltip.js =================================================================== --- /trunk/dhtml/js/dhtmltooltip.js (revision 1) +++ /trunk/dhtml/js/dhtmltooltip.js (revision 1) @@ -0,0 +1,113 @@ +/*********************************************** +* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com) +* This notice MUST stay intact for legal use +* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code +***********************************************/ + +var offsetxpoint=-60 //Customize x offset of tooltip +var offsetypoint=20 //Customize y offset of tooltip +var ie=document.all +var ns6=document.getElementById && !document.all +var enabletip=false +if (ie||ns6) + +function ietruebody(){ +return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body +} + + +function ExtraeNumero(name) { + var destino = ""; + name = name.id; + for (var s = 0; s"9") { + } else { + destino = destino+""+c; + } + } + return destino; +} + +function ExtraeNombre(name) { + var destino = ""; + name = name.id; + for (var s = 0; s"9") { + destino = destino+""+c; + } + } + return destino; +} + + + +function ddrivetip(element, thecolor, thewidth){ + if (ns6||ie){ + if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px" + if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor + + var nombre = ExtraeNombre(element); + var numero = ExtraeNumero(element); + + if(nombre=="phone") { + var dato = info["phone"+numero]; + } + if(nombre=="mwi") { + var dato = mwiinfo["mwi"+numero]; + } + + tipobj.innerHTML=dato; + + if(dato == undefined) { + enabletip=false + } else { + enabletip=true + } + + + return false + } +} + +function positiontip(e){ +if (enabletip){ +var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft; +var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop; +//Find out how close the mouse is to the corner of the window +var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20 +var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20 + +var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000 + +//if the horizontal distance isn't enough to accomodate the width of the context menu +if (rightedge section, and invoke -Tip('Tooltip text') from the desired HTML onmouseover eventhandlers, -and UnTip(), usually from the onmouseout eventhandlers, to hide the tip. -No container DIV required. -By default, width and height of tooltips are automatically adapted to content. -Is even capable of dynamically converting arbitrary HTML elements to tooltips -by calling TagToTip('ID_of_HTML_element_to_be_converted') instead of Tip(), -which means you can put important, search-engine-relevant stuff into tooltips. -Appearance of tooltips can be individually configured -via commands passed to Tip() or TagToTip(). - -Tab Width: 4 -LICENSE: LGPL - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License (LGPL) as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -For more details on the GNU Lesser General Public License, -see http://www.gnu.org/copyleft/lesser.html -*/ - -var config = new Object(); - - -//=================== GLOBAL TOOPTIP CONFIGURATION =========================// -var tt_Debug = true // false or true - recommended: false once you release your page to the public -var tt_Enabled = true // Allows to (temporarily) suppress tooltips, e.g. by providing the user with a button that sets this global variable to false -var TagsToTip = true // false or true - if true, HTML elements to be converted to tooltips via TagToTip() are automatically hidden; - // if false, you should hide those HTML elements yourself - -// For each of the following config variables there exists a command, which is -// just the variablename in uppercase, to be passed to Tip() or TagToTip() to -// configure tooltips individually. Individual commands override global -// configuration. Order of commands is arbitrary. -// Example: onmouseover="Tip('Tooltip text', LEFT, true, BGCOLOR, '#FF9900', FADEIN, 400)" - -config. Above = false // false or true - tooltip above mousepointer -config. BgColor = '#E2E7FF' // Background colour (HTML colour value, in quotes) -config. BgImg = '' // Path to background image, none if empty string '' -config. BorderColor = '#003099' -config. BorderStyle = 'solid' // Any permitted CSS value, but I recommend 'solid', 'dotted' or 'dashed' -config. BorderWidth = 1 -config. CenterMouse = false // false or true - center the tip horizontally below (or above) the mousepointer -config. ClickClose = false // false or true - close tooltip if the user clicks somewhere -config. ClickSticky = false // false or true - make tooltip sticky if user left-clicks on the hovered element while the tooltip is active -config. CloseBtn = false // false or true - closebutton in titlebar -config. CloseBtnColors = ['#990000', '#FFFFFF', '#DD3333', '#FFFFFF'] // [Background, text, hovered background, hovered text] - use empty strings '' to inherit title colours -config. CloseBtnText = ' X ' // Close button text (may also be an image tag) -config. CopyContent = true // When converting a HTML element to a tooltip, copy only the element's content, rather than converting the element by its own -config. Delay = 400 // Time span in ms until tooltip shows up -config. Duration = 0 // Time span in ms after which the tooltip disappears; 0 for infinite duration, < 0 for delay in ms _after_ the onmouseout until the tooltip disappears -config. FadeIn = 0 // Fade-in duration in ms, e.g. 400; 0 for no animation -config. FadeOut = 0 -config. FadeInterval = 30 // Duration of each fade step in ms (recommended: 30) - shorter is smoother but causes more CPU-load -config. Fix = null // Fixated position - x- an y-oordinates in brackets, e.g. [210, 480], or null for no fixation -config. FollowMouse = true // false or true - tooltip follows the mouse -config. FontColor = '#000044' -config. FontFace = 'Verdana,Geneva,sans-serif' -config. FontSize = '8pt' // E.g. '9pt' or '12px' - unit is mandatory -config. FontWeight = 'normal' // 'normal' or 'bold'; -config. Height = 0 // Tooltip height; 0 for automatic adaption to tooltip content, < 0 (e.g. -100) for a maximum for automatic adaption -config. JumpHorz = false // false or true - jump horizontally to other side of mouse if tooltip would extend past clientarea boundary -config. JumpVert = true // false or true - jump vertically " -config. Left = false // false or true - tooltip on the left of the mouse -config. OffsetX = 14 // Horizontal offset of left-top corner from mousepointer -config. OffsetY = 8 // Vertical offset -config. Opacity = 100 // Integer between 0 and 100 - opacity of tooltip in percent -config. Padding = 3 // Spacing between border and content -config. Shadow = false // false or true -config. ShadowColor = '#C0C0C0' -config. ShadowWidth = 5 -config. Sticky = false // false or true - fixate tip, ie. don't follow the mouse and don't hide on mouseout -config. TextAlign = 'left' // 'left', 'right' or 'justify' -config. Title = '' // Default title text applied to all tips (no default title: empty string '') -config. TitleAlign = 'left' // 'left' or 'right' - text alignment inside the title bar -config. TitleBgColor = '' // If empty string '', BorderColor will be used -config. TitleFontColor = '#FFFFFF' // Color of title text - if '', BgColor (of tooltip body) will be used -config. TitleFontFace = '' // If '' use FontFace (boldified) -config. TitleFontSize = '' // If '' use FontSize -config. Width = 0 // Tooltip width; 0 for automatic adaption to tooltip content; < -1 (e.g. -240) for a maximum width for that automatic adaption; - // -1: tooltip width confined to the width required for the titlebar -//======= END OF TOOLTIP CONFIG, DO NOT CHANGE ANYTHING BELOW ==============// - - - - -//===================== PUBLIC =============================================// -function Tip() -{ - tt_Tip(arguments, null); -} -function TagToTip() -{ - var t2t = tt_GetElt(arguments[0]); - if(t2t) - tt_Tip(arguments, t2t); -} -function UnTip() -{ - tt_OpReHref(); - if(tt_aV[DURATION] < 0) - tt_tDurt.Timer("tt_HideInit()", -tt_aV[DURATION], true); - else if(!(tt_aV[STICKY] && (tt_iState & 0x2))) - tt_HideInit(); -} - -//================== PUBLIC PLUGIN API =====================================// -// Extension eventhandlers currently supported: -// OnLoadConfig, OnCreateContentString, OnSubDivsCreated, OnShow, OnMoveBefore, -// OnMoveAfter, OnHideInit, OnHide, OnKill - -var tt_aElt = new Array(10), // Container DIV, outer title & body DIVs, inner title & body TDs, closebutton SPAN, shadow DIVs, and IFRAME to cover windowed elements in IE -tt_aV = new Array(), // Caches and enumerates config data for currently active tooltip -tt_sContent, // Inner tooltip text or HTML -tt_scrlX = 0, tt_scrlY = 0, -tt_musX, tt_musY, -tt_over, -tt_x, tt_y, tt_w, tt_h; // Position, width and height of currently displayed tooltip - -function tt_Extension() -{ - tt_ExtCmdEnum(); - tt_aExt[tt_aExt.length] = this; - return this; -} -function tt_SetTipPos(x, y) -{ - var css = tt_aElt[0].style; - - tt_x = x; - tt_y = y; - css.left = x + "px"; - css.top = y + "px"; - if(tt_ie56) - { - var ifrm = tt_aElt[tt_aElt.length - 1]; - if(ifrm) - { - ifrm.style.left = css.left; - ifrm.style.top = css.top; - } - } -} -function tt_HideInit() -{ - if(tt_iState) - { - tt_ExtCallFncs(0, "HideInit"); - tt_iState &= ~0x4; - if(tt_flagOpa && tt_aV[FADEOUT]) - { - tt_tFade.EndTimer(); - if(tt_opa) - { - var n = Math.round(tt_aV[FADEOUT] / (tt_aV[FADEINTERVAL] * (tt_aV[OPACITY] / tt_opa))); - tt_Fade(tt_opa, tt_opa, 0, n); - return; - } - } - tt_tHide.Timer("tt_Hide();", 1, false); - } -} -function tt_Hide() -{ - if(tt_db && tt_iState) - { - tt_OpReHref(); - if(tt_iState & 0x2) - { - tt_aElt[0].style.visibility = "hidden"; - tt_ExtCallFncs(0, "Hide"); - } - tt_tShow.EndTimer(); - tt_tHide.EndTimer(); - tt_tDurt.EndTimer(); - tt_tFade.EndTimer(); - if(!tt_op && !tt_ie) - { - tt_tWaitMov.EndTimer(); - tt_bWait = false; - } - if(tt_aV[CLICKCLOSE] || tt_aV[CLICKSTICKY]) - tt_RemEvtFnc(document, "mouseup", tt_OnLClick); - tt_ExtCallFncs(0, "Kill"); - // In case of a TagToTip tooltip, hide converted DOM node and - // re-insert it into document - if(tt_t2t && !tt_aV[COPYCONTENT]) - { - tt_t2t.style.display = "none"; - tt_MovDomNode(tt_t2t, tt_aElt[6], tt_t2tDad); - } - tt_iState = 0; - tt_over = null; - tt_ResetMainDiv(); - if(tt_aElt[tt_aElt.length - 1]) - tt_aElt[tt_aElt.length - 1].style.display = "none"; - } -} -function tt_GetElt(id) -{ - return(document.getElementById ? document.getElementById(id) - : document.all ? document.all[id] - : null); -} -function tt_GetDivW(el) -{ - return(el ? (el.offsetWidth || el.style.pixelWidth || 0) : 0); -} -function tt_GetDivH(el) -{ - return(el ? (el.offsetHeight || el.style.pixelHeight || 0) : 0); -} -function tt_GetScrollX() -{ - return(window.pageXOffset || (tt_db ? (tt_db.scrollLeft || 0) : 0)); -} -function tt_GetScrollY() -{ - return(window.pageYOffset || (tt_db ? (tt_db.scrollTop || 0) : 0)); -} -function tt_GetClientW() -{ - return(document.body && (typeof(document.body.clientWidth) != tt_u) ? document.body.clientWidth - : (typeof(window.innerWidth) != tt_u) ? window.innerWidth - : tt_db ? (tt_db.clientWidth || 0) - : 0); -} -function tt_GetClientH() -{ - // Exactly this order seems to yield correct values in all major browsers - return(document.body && (typeof(document.body.clientHeight) != tt_u) ? document.body.clientHeight - : (typeof(window.innerHeight) != tt_u) ? window.innerHeight - : tt_db ? (tt_db.clientHeight || 0) - : 0); -} -function tt_GetEvtX(e) -{ - return (e ? ((typeof(e.pageX) != tt_u) ? e.pageX : (e.clientX + tt_scrlX)) : 0); -} -function tt_GetEvtY(e) -{ - return (e ? ((typeof(e.pageY) != tt_u) ? e.pageY : (e.clientY + tt_scrlY)) : 0); -} -function tt_AddEvtFnc(el, sEvt, PFnc) -{ - if(el) - { - if(el.addEventListener) - el.addEventListener(sEvt, PFnc, false); - else - el.attachEvent("on" + sEvt, PFnc); - } -} -function tt_RemEvtFnc(el, sEvt, PFnc) -{ - if(el) - { - if(el.removeEventListener) - el.removeEventListener(sEvt, PFnc, false); - else - el.detachEvent("on" + sEvt, PFnc); - } -} - -//====================== PRIVATE ===========================================// -var tt_aExt = new Array(), // Array of extension objects - -tt_db, tt_op, tt_ie, tt_ie56, tt_bBoxOld, // Browser flags -tt_body, -tt_ovr_, // HTML element the mouse is currently over -tt_flagOpa, // Opacity support: 1=IE, 2=Khtml, 3=KHTML, 4=Moz, 5=W3C -tt_maxPosX, tt_maxPosY, -tt_iState = 0, // Tooltip active |= 1, shown |= 2, move with mouse |= 4 -tt_opa, // Currently applied opacity -tt_bJmpVert, tt_bJmpHorz,// Tip temporarily on other side of mouse -tt_t2t, tt_t2tDad, // Tag converted to tip, and its parent element in the document -tt_elDeHref, // The tag from which we've removed the href attribute -// Timer -tt_tShow = new Number(0), tt_tHide = new Number(0), tt_tDurt = new Number(0), -tt_tFade = new Number(0), tt_tWaitMov = new Number(0), -tt_bWait = false, -tt_u = "undefined"; - - -function tt_Init() -{ - tt_MkCmdEnum(); - // Send old browsers instantly to hell - if(!tt_Browser() || !tt_MkMainDiv()) - return; - tt_IsW3cBox(); - tt_OpaSupport(); - tt_AddEvtFnc(window, "scroll", tt_OnScrl); - // IE doesn't fire onscroll event when switching to fullscreen; - // fix suggested by Yoav Karpeles 14.2.2008 - tt_AddEvtFnc(window, "resize", tt_OnScrl); - tt_AddEvtFnc(document, "mousemove", tt_Move); - // In Debug mode we search for TagToTip() calls in order to notify - // the user if they've forgotten to set the TagsToTip config flag - if(TagsToTip || tt_Debug) - tt_SetOnloadFnc(); - // Ensure the tip be hidden when the page unloads - tt_AddEvtFnc(window, "unload", tt_Hide); -} -// Creates command names by translating config variable names to upper case -function tt_MkCmdEnum() -{ - var n = 0; - for(var i in config) - eval("window." + i.toString().toUpperCase() + " = " + n++); - tt_aV.length = n; -} -function tt_Browser() -{ - var n, nv, n6, w3c; - - n = navigator.userAgent.toLowerCase(), - nv = navigator.appVersion; - tt_op = (document.defaultView && typeof(eval("w" + "indow" + "." + "o" + "p" + "er" + "a")) != tt_u); - tt_ie = n.indexOf("msie") != -1 && document.all && !tt_op; - if(tt_ie) - { - var ieOld = (!document.compatMode || document.compatMode == "BackCompat"); - tt_db = !ieOld ? document.documentElement : (document.body || null); - if(tt_db) - tt_ie56 = parseFloat(nv.substring(nv.indexOf("MSIE") + 5)) >= 5.5 - && typeof document.body.style.maxHeight == tt_u; - } - else - { - tt_db = document.documentElement || document.body || - (document.getElementsByTagName ? document.getElementsByTagName("body")[0] - : null); - if(!tt_op) - { - n6 = document.defaultView && typeof document.defaultView.getComputedStyle != tt_u; - w3c = !n6 && document.getElementById; - } - } - tt_body = (document.getElementsByTagName ? document.getElementsByTagName("body")[0] - : (document.body || null)); - if(tt_ie || n6 || tt_op || w3c) - { - if(tt_body && tt_db) - { - if(document.attachEvent || document.addEventListener) - return true; - } - else - tt_Err("wz_tooltip.js must be included INSIDE the body section," - + " immediately after the opening tag.", false); - } - tt_db = null; - return false; -} -function tt_MkMainDiv() -{ - // Create the tooltip DIV - if(tt_body.insertAdjacentHTML) - tt_body.insertAdjacentHTML("afterBegin", tt_MkMainDivHtm()); - else if(typeof tt_body.innerHTML != tt_u && document.createElement && tt_body.appendChild) - tt_body.appendChild(tt_MkMainDivDom()); - if(window.tt_GetMainDivRefs /* FireFox Alzheimer */ && tt_GetMainDivRefs()) - return true; - tt_db = null; - return false; -} -function tt_MkMainDivHtm() -{ - return('
' + - (tt_ie56 ? ('') - : '')); -} -function tt_MkMainDivDom() -{ - var el = document.createElement("div"); - if(el) - el.id = "WzTtDiV"; - return el; -} -function tt_GetMainDivRefs() -{ - tt_aElt[0] = tt_GetElt("WzTtDiV"); - if(tt_ie56 && tt_aElt[0]) - { - tt_aElt[tt_aElt.length - 1] = tt_GetElt("WzTtIfRm"); - if(!tt_aElt[tt_aElt.length - 1]) - tt_aElt[0] = null; - } - if(tt_aElt[0]) - { - var css = tt_aElt[0].style; - - css.visibility = "hidden"; - css.position = "absolute"; - css.overflow = "hidden"; - return true; - } - return false; -} -function tt_ResetMainDiv() -{ - var w = (window.screen && screen.width) ? screen.width : 10000; - - tt_SetTipPos(-w, 0); - tt_aElt[0].innerHTML = ""; - tt_aElt[0].style.width = (w - 1) + "px"; - tt_h = 0; -} -function tt_IsW3cBox() -{ - var css = tt_aElt[0].style; - - css.padding = "10px"; - css.width = "40px"; - tt_bBoxOld = (tt_GetDivW(tt_aElt[0]) == 40); - css.padding = "0px"; - tt_ResetMainDiv(); -} -function tt_OpaSupport() -{ - var css = tt_body.style; - - tt_flagOpa = (typeof(css.filter) != tt_u) ? 1 - : (typeof(css.KhtmlOpacity) != tt_u) ? 2 - : (typeof(css.KHTMLOpacity) != tt_u) ? 3 - : (typeof(css.MozOpacity) != tt_u) ? 4 - : (typeof(css.opacity) != tt_u) ? 5 - : 0; -} -// Ported from http://dean.edwards.name/weblog/2006/06/again/ -// (Dean Edwards et al.) -function tt_SetOnloadFnc() -{ - tt_AddEvtFnc(document, "DOMContentLoaded", tt_HideSrcTags); - tt_AddEvtFnc(window, "load", tt_HideSrcTags); - if(tt_body.attachEvent) - tt_body.attachEvent("onreadystatechange", - function() { - if(tt_body.readyState == "complete") - tt_HideSrcTags(); - } ); - if(/WebKit|KHTML/i.test(navigator.userAgent)) - { - var t = setInterval(function() { - if(/loaded|complete/.test(document.readyState)) - { - clearInterval(t); - tt_HideSrcTags(); - } - }, 10); - } -} -function tt_HideSrcTags() -{ - if(!window.tt_HideSrcTags || window.tt_HideSrcTags.done) - return; - window.tt_HideSrcTags.done = true; - if(!tt_HideSrcTagsRecurs(tt_body)) - tt_Err("There are HTML elements to be converted to tooltips.\nIf you" - + " want these HTML elements to be automatically hidden, you" - + " must edit wz_tooltip.js, and set TagsToTip in the global" - + " tooltip configuration to true.", true); -} -function tt_HideSrcTagsRecurs(dad) -{ - var ovr, asT2t; - // Walk the DOM tree for tags that have an onmouseover or onclick attribute - // containing a TagToTip('...') call. - // (.childNodes first since .children is bugous in Safari) - var a = dad.childNodes || dad.children || null; - - for(var i = a ? a.length : 0; i;) - {--i; - if(!tt_HideSrcTagsRecurs(a[i])) - return false; - ovr = a[i].getAttribute ? (a[i].getAttribute("onmouseover") || a[i].getAttribute("onclick")) - : (typeof a[i].onmouseover == "function") ? (a[i].onmouseover || a[i].onclick) - : null; - if(ovr) - { - asT2t = ovr.toString().match(/TagToTip\s*\(\s*'[^'.]+'\s*[\),]/); - if(asT2t && asT2t.length) - { - if(!tt_HideSrcTag(asT2t[0])) - return false; - } - } - } - return true; -} -function tt_HideSrcTag(sT2t) -{ - var id, el; - - // The ID passed to the found TagToTip() call identifies an HTML element - // to be converted to a tooltip, so hide that element - id = sT2t.replace(/.+'([^'.]+)'.+/, "$1"); - el = tt_GetElt(id); - if(el) - { - if(tt_Debug && !TagsToTip) - return false; - else - el.style.display = "none"; - } - else - tt_Err("Invalid ID\n'" + id + "'\npassed to TagToTip()." - + " There exists no HTML element with that ID.", true); - return true; -} -function tt_Tip(arg, t2t) -{ - if(!tt_db) - return; - if(tt_iState) - tt_Hide(); - if(!tt_Enabled) - return; - tt_t2t = t2t; - if(!tt_ReadCmds(arg)) - return; - tt_iState = 0x1 | 0x4; - tt_AdaptConfig1(); - tt_MkTipContent(arg); - tt_MkTipSubDivs(); - tt_FormatTip(); - tt_bJmpVert = false; - tt_bJmpHorz = false; - tt_maxPosX = tt_GetClientW() + tt_scrlX - tt_w - 1; - tt_maxPosY = tt_GetClientH() + tt_scrlY - tt_h - 1; - tt_AdaptConfig2(); - // Ensure the tip be shown and positioned before the first onmousemove - tt_OverInit(); - tt_ShowInit(); - tt_Move(); -} -function tt_ReadCmds(a) -{ - var i; - - // First load the global config values, to initialize also values - // for which no command is passed - i = 0; - for(var j in config) - tt_aV[i++] = config[j]; - // Then replace each cached config value for which a command is - // passed (ensure the # of command args plus value args be even) - if(a.length & 1) - { - for(i = a.length - 1; i > 0; i -= 2) - tt_aV[a[i - 1]] = a[i]; - return true; - } - tt_Err("Incorrect call of Tip() or TagToTip().\n" - + "Each command must be followed by a value.", true); - return false; -} -function tt_AdaptConfig1() -{ - tt_ExtCallFncs(0, "LoadConfig"); - // Inherit unspecified title formattings from body - if(!tt_aV[TITLEBGCOLOR].length) - tt_aV[TITLEBGCOLOR] = tt_aV[BORDERCOLOR]; - if(!tt_aV[TITLEFONTCOLOR].length) - tt_aV[TITLEFONTCOLOR] = tt_aV[BGCOLOR]; - if(!tt_aV[TITLEFONTFACE].length) - tt_aV[TITLEFONTFACE] = tt_aV[FONTFACE]; - if(!tt_aV[TITLEFONTSIZE].length) - tt_aV[TITLEFONTSIZE] = tt_aV[FONTSIZE]; - if(tt_aV[CLOSEBTN]) - { - // Use title colours for non-specified closebutton colours - if(!tt_aV[CLOSEBTNCOLORS]) - tt_aV[CLOSEBTNCOLORS] = new Array("", "", "", ""); - for(var i = 4; i;) - {--i; - if(!tt_aV[CLOSEBTNCOLORS][i].length) - tt_aV[CLOSEBTNCOLORS][i] = (i & 1) ? tt_aV[TITLEFONTCOLOR] : tt_aV[TITLEBGCOLOR]; - } - // Enforce titlebar be shown - if(!tt_aV[TITLE].length) - tt_aV[TITLE] = " "; - } - // Circumvents broken display of images and fade-in flicker in Geckos < 1.8 - if(tt_aV[OPACITY] == 100 && typeof tt_aElt[0].style.MozOpacity != tt_u && !Array.every) - tt_aV[OPACITY] = 99; - // Smartly shorten the delay for fade-in tooltips - if(tt_aV[FADEIN] && tt_flagOpa && tt_aV[DELAY] > 100) - tt_aV[DELAY] = Math.max(tt_aV[DELAY] - tt_aV[FADEIN], 100); -} -function tt_AdaptConfig2() -{ - if(tt_aV[CENTERMOUSE]) - { - tt_aV[OFFSETX] -= ((tt_w - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0)) >> 1); - tt_aV[JUMPHORZ] = false; - } -} -// Expose content globally so extensions can modify it -function tt_MkTipContent(a) -{ - if(tt_t2t) - { - if(tt_aV[COPYCONTENT]) - tt_sContent = tt_t2t.innerHTML; - else - tt_sContent = ""; - } - else - tt_sContent = a[0]; - tt_ExtCallFncs(0, "CreateContentString"); -} -function tt_MkTipSubDivs() -{ - var sCss = 'position:relative;margin:0px;padding:0px;border-width:0px;left:0px;top:0px;line-height:normal;width:auto;', - sTbTrTd = ' cellspacing="0" cellpadding="0" border="0" style="' + sCss + '">' - + '' - + tt_aV[TITLE] - + '' - + (tt_aV[CLOSEBTN] ? - ('') - : '') - + '
' - + '' - + tt_aV[CLOSEBTNTEXT] - + '
') - : '') - + '
' - + '' - + tt_sContent - + '
' - + (tt_aV[SHADOW] - ? ('
' - + '
') - : '') - ); - tt_GetSubDivRefs(); - // Convert DOM node to tip - if(tt_t2t && !tt_aV[COPYCONTENT]) - { - // Store the tag's parent element so we can restore that DOM branch - // once the tooltip is hidden - tt_t2tDad = tt_t2t.parentNode || tt_t2t.parentElement || tt_t2t.offsetParent || null; - if(tt_t2tDad) - { - tt_MovDomNode(tt_t2t, tt_t2tDad, tt_aElt[6]); - tt_t2t.style.display = "block"; - } - } - tt_ExtCallFncs(0, "SubDivsCreated"); -} -function tt_GetSubDivRefs() -{ - var aId = new Array("WzTiTl", "WzTiTlTb", "WzTiTlI", "WzClOsE", "WzBoDy", "WzBoDyI", "WzTtShDwB", "WzTtShDwR"); - - for(var i = aId.length; i; --i) - tt_aElt[i] = tt_GetElt(aId[i - 1]); -} -function tt_FormatTip() -{ - var css, w, h, iOffY, iOffSh, - iAdd = (tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1; - - //--------- Title DIV ---------- - if(tt_aV[TITLE].length) - { - css = tt_aElt[1].style; - css.background = tt_aV[TITLEBGCOLOR]; - css.paddingTop = (tt_aV[CLOSEBTN] ? 2 : 0) + "px"; - css.paddingBottom = "1px"; - css.paddingLeft = css.paddingRight = tt_aV[PADDING] + "px"; - css = tt_aElt[3].style; - css.color = tt_aV[TITLEFONTCOLOR]; - if (tt_aV[WIDTH] == -1) - css.whiteSpace = "nowrap"; - css.fontFamily = tt_aV[TITLEFONTFACE]; - css.fontSize = tt_aV[TITLEFONTSIZE]; - css.fontWeight = "bold"; - css.textAlign = tt_aV[TITLEALIGN]; - // Close button DIV - if(tt_aElt[4]) - { - css.paddingRight = (tt_aV[PADDING] << 1) + "px"; - css = tt_aElt[4].style; - css.background = tt_aV[CLOSEBTNCOLORS][0]; - css.color = tt_aV[CLOSEBTNCOLORS][1]; - css.fontFamily = tt_aV[TITLEFONTFACE]; - css.fontSize = tt_aV[TITLEFONTSIZE]; - css.fontWeight = "bold"; - } - if(tt_aV[WIDTH] > 0) - tt_w = tt_aV[WIDTH]; - else - { - tt_w = tt_GetDivW(tt_aElt[3]) + tt_GetDivW(tt_aElt[4]); - // Some spacing between title DIV and closebutton - if(tt_aElt[4]) - tt_w += tt_aV[PADDING]; - // Restrict auto width to max width - if(tt_aV[WIDTH] < -1 && tt_w > -tt_aV[WIDTH]) - tt_w = -tt_aV[WIDTH]; - } - // Ensure the top border of the body DIV be covered by the title DIV - iOffY = -tt_aV[BORDERWIDTH]; - } - else - { - tt_w = 0; - iOffY = 0; - } - - //-------- Body DIV ------------ - css = tt_aElt[5].style; - css.top = iOffY + "px"; - if(tt_aV[BORDERWIDTH]) - { - css.borderColor = tt_aV[BORDERCOLOR]; - css.borderStyle = tt_aV[BORDERSTYLE]; - css.borderWidth = tt_aV[BORDERWIDTH] + "px"; - } - if(tt_aV[BGCOLOR].length) - css.background = tt_aV[BGCOLOR]; - if(tt_aV[BGIMG].length) - css.backgroundImage = "url(" + tt_aV[BGIMG] + ")"; - css.padding = tt_aV[PADDING] + "px"; - css.textAlign = tt_aV[TEXTALIGN]; - if(tt_aV[HEIGHT]) - { - css.overflow = "auto"; - if(tt_aV[HEIGHT] > 0) - css.height = (tt_aV[HEIGHT] + iAdd) + "px"; - else - tt_h = iAdd - tt_aV[HEIGHT]; - } - // TD inside body DIV - css = tt_aElt[6].style; - css.color = tt_aV[FONTCOLOR]; - css.fontFamily = tt_aV[FONTFACE]; - css.fontSize = tt_aV[FONTSIZE]; - css.fontWeight = tt_aV[FONTWEIGHT]; - css.background = ""; - css.textAlign = tt_aV[TEXTALIGN]; - if(tt_aV[WIDTH] > 0) - w = tt_aV[WIDTH]; - // Width like title (if existent) - else if(tt_aV[WIDTH] == -1 && tt_w) - w = tt_w; - else - { - // Measure width of the body's inner TD, as some browsers would expand - // the container and outer body DIV to 100% - w = tt_GetDivW(tt_aElt[6]); - // Restrict auto width to max width - if(tt_aV[WIDTH] < -1 && w > -tt_aV[WIDTH]) - w = -tt_aV[WIDTH]; - } - if(w > tt_w) - tt_w = w; - tt_w += iAdd; - - //--------- Shadow DIVs ------------ - if(tt_aV[SHADOW]) - { - tt_w += tt_aV[SHADOWWIDTH]; - iOffSh = Math.floor((tt_aV[SHADOWWIDTH] * 4) / 3); - // Bottom shadow - css = tt_aElt[7].style; - css.top = iOffY + "px"; - css.left = iOffSh + "px"; - css.width = (tt_w - iOffSh - tt_aV[SHADOWWIDTH]) + "px"; - css.height = tt_aV[SHADOWWIDTH] + "px"; - css.background = tt_aV[SHADOWCOLOR]; - // Right shadow - css = tt_aElt[8].style; - css.top = iOffSh + "px"; - css.left = (tt_w - tt_aV[SHADOWWIDTH]) + "px"; - css.width = tt_aV[SHADOWWIDTH] + "px"; - css.background = tt_aV[SHADOWCOLOR]; - } - else - iOffSh = 0; - - //-------- Container DIV ------- - tt_SetTipOpa(tt_aV[FADEIN] ? 0 : tt_aV[OPACITY]); - tt_FixSize(iOffY, iOffSh); -} -// Fixate the size so it can't dynamically change while the tooltip is moving. -function tt_FixSize(iOffY, iOffSh) -{ - var wIn, wOut, h, add, i; - - tt_aElt[0].style.width = tt_w + "px"; - tt_aElt[0].style.pixelWidth = tt_w; - wOut = tt_w - ((tt_aV[SHADOW]) ? tt_aV[SHADOWWIDTH] : 0); - // Body - wIn = wOut; - if(!tt_bBoxOld) - wIn -= (tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1; - tt_aElt[5].style.width = wIn + "px"; - // Title - if(tt_aElt[1]) - { - wIn = wOut - (tt_aV[PADDING] << 1); - if(!tt_bBoxOld) - wOut = wIn; - tt_aElt[1].style.width = wOut + "px"; - tt_aElt[2].style.width = wIn + "px"; - } - // Max height specified - if(tt_h) - { - h = tt_GetDivH(tt_aElt[5]); - if(h > tt_h) - { - if(!tt_bBoxOld) - tt_h -= (tt_aV[PADDING] + tt_aV[BORDERWIDTH]) << 1; - tt_aElt[5].style.height = tt_h + "px"; - } - } - tt_h = tt_GetDivH(tt_aElt[0]) + iOffY; - // Right shadow - if(tt_aElt[8]) - tt_aElt[8].style.height = (tt_h - iOffSh) + "px"; - i = tt_aElt.length - 1; - if(tt_aElt[i]) - { - tt_aElt[i].style.width = tt_w + "px"; - tt_aElt[i].style.height = tt_h + "px"; - } -} -function tt_DeAlt(el) -{ - var aKid; - - if(el) - { - if(el.alt) - el.alt = ""; - if(el.title) - el.title = ""; - aKid = el.childNodes || el.children || null; - if(aKid) - { - for(var i = aKid.length; i;) - tt_DeAlt(aKid[--i]); - } - } -} -// This hack removes the native tooltips over links in Opera -function tt_OpDeHref(el) -{ - if(!tt_op) - return; - if(tt_elDeHref) - tt_OpReHref(); - while(el) - { - if(el.hasAttribute("href")) - { - el.t_href = el.getAttribute("href"); - el.t_stats = window.status; - el.removeAttribute("href"); - el.style.cursor = "hand"; - tt_AddEvtFnc(el, "mousedown", tt_OpReHref); - window.status = el.t_href; - tt_elDeHref = el; - break; - } - el = el.parentElement; - } -} -function tt_OpReHref() -{ - if(tt_elDeHref) - { - tt_elDeHref.setAttribute("href", tt_elDeHref.t_href); - tt_RemEvtFnc(tt_elDeHref, "mousedown", tt_OpReHref); - window.status = tt_elDeHref.t_stats; - tt_elDeHref = null; - } -} -function tt_OverInit() -{ - if(window.event) - tt_over = window.event.target || window.event.srcElement; - else - tt_over = tt_ovr_; - tt_DeAlt(tt_over); - tt_OpDeHref(tt_over); -} -function tt_ShowInit() -{ - tt_tShow.Timer("tt_Show()", tt_aV[DELAY], true); - if(tt_aV[CLICKCLOSE] || tt_aV[CLICKSTICKY]) - tt_AddEvtFnc(document, "mouseup", tt_OnLClick); -} -function tt_Show() -{ - var css = tt_aElt[0].style; - - // Override the z-index of the topmost wz_dragdrop.js D&D item - css.zIndex = Math.max((window.dd && dd.z) ? (dd.z + 2) : 0, 1010); - if(tt_aV[STICKY] || !tt_aV[FOLLOWMOUSE]) - tt_iState &= ~0x4; - if(tt_aV[DURATION] > 0) - tt_tDurt.Timer("tt_HideInit()", tt_aV[DURATION], true); - tt_ExtCallFncs(0, "Show") - css.visibility = "visible"; - tt_iState |= 0x2; - if(tt_aV[FADEIN]) - tt_Fade(0, 0, tt_aV[OPACITY], Math.round(tt_aV[FADEIN] / tt_aV[FADEINTERVAL])); - tt_ShowIfrm(); -} -function tt_ShowIfrm() -{ - if(tt_ie56) - { - var ifrm = tt_aElt[tt_aElt.length - 1]; - if(ifrm) - { - var css = ifrm.style; - css.zIndex = tt_aElt[0].style.zIndex - 1; - css.display = "block"; - } - } -} -function tt_Move(e) -{ - if(e) - tt_ovr_ = e.target || e.srcElement; - e = e || window.event; - if(e) - { - tt_musX = tt_GetEvtX(e); - tt_musY = tt_GetEvtY(e); - } - if(tt_iState & 0x04) - { - // Prevent jam of mousemove events - if(!tt_op && !tt_ie) - { - if(tt_bWait) - return; - tt_bWait = true; - tt_tWaitMov.Timer("tt_bWait = false;", 1, true); - } - if(tt_aV[FIX]) - { - var iY = tt_aV[FIX][1]; - // For a fixed tip to be positioned above the mouse, use the - // bottom edge as anchor - // (recommended by Christophe Rebeschini, 31.1.2008) - if(tt_aV[ABOVE]) - iY -= tt_h; - tt_iState &= ~0x4; - tt_SetTipPos(tt_aV[FIX][0], tt_aV[FIX][1]); - } - else if(!tt_ExtCallFncs(e, "MoveBefore")) - tt_SetTipPos(tt_Pos(0), tt_Pos(1)); - tt_ExtCallFncs([tt_musX, tt_musY], "MoveAfter") - } -} -function tt_Pos(iDim) -{ - var iX, bJmpMode, cmdAlt, cmdOff, cx, iMax, iScrl, iMus, bJmp; - - // Map values according to dimension to calculate - if(iDim) - { - bJmpMode = tt_aV[JUMPVERT]; - cmdAlt = ABOVE; - cmdOff = OFFSETY; - cx = tt_h; - iMax = tt_maxPosY; - iScrl = tt_scrlY; - iMus = tt_musY; - bJmp = tt_bJmpVert; - } - else - { - bJmpMode = tt_aV[JUMPHORZ]; - cmdAlt = LEFT; - cmdOff = OFFSETX; - cx = tt_w; - iMax = tt_maxPosX; - iScrl = tt_scrlX; - iMus = tt_musX; - bJmp = tt_bJmpHorz; - } - if(bJmpMode) - { - if(tt_aV[cmdAlt] && (!bJmp || tt_CalcPosAlt(iDim) >= iScrl + 16)) - iX = tt_PosAlt(iDim); - else if(!tt_aV[cmdAlt] && bJmp && tt_CalcPosDef(iDim) > iMax - 16) - iX = tt_PosAlt(iDim); - else - iX = tt_PosDef(iDim); - } - else - { - iX = iMus; - if(tt_aV[cmdAlt]) - iX -= cx + tt_aV[cmdOff] - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0); - else - iX += tt_aV[cmdOff]; - } - // Prevent tip from extending past clientarea boundary - if(iX > iMax) - iX = bJmpMode ? tt_PosAlt(iDim) : iMax; - // In case of insufficient space on both sides, ensure the left/upper part - // of the tip be visible - if(iX < iScrl) - iX = bJmpMode ? tt_PosDef(iDim) : iScrl; - return iX; -} -function tt_PosDef(iDim) -{ - if(iDim) - tt_bJmpVert = tt_aV[ABOVE]; - else - tt_bJmpHorz = tt_aV[LEFT]; - return tt_CalcPosDef(iDim); -} -function tt_PosAlt(iDim) -{ - if(iDim) - tt_bJmpVert = !tt_aV[ABOVE]; - else - tt_bJmpHorz = !tt_aV[LEFT]; - return tt_CalcPosAlt(iDim); -} -function tt_CalcPosDef(iDim) -{ - return iDim ? (tt_musY + tt_aV[OFFSETY]) : (tt_musX + tt_aV[OFFSETX]); -} -function tt_CalcPosAlt(iDim) -{ - var cmdOff = iDim ? OFFSETY : OFFSETX; - var dx = tt_aV[cmdOff] - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0); - if(tt_aV[cmdOff] > 0 && dx <= 0) - dx = 1; - return((iDim ? (tt_musY - tt_h) : (tt_musX - tt_w)) - dx); -} -function tt_Fade(a, now, z, n) -{ - if(n) - { - now += Math.round((z - now) / n); - if((z > a) ? (now >= z) : (now <= z)) - now = z; - else - tt_tFade.Timer("tt_Fade(" - + a + "," + now + "," + z + "," + (n - 1) - + ")", - tt_aV[FADEINTERVAL], - true); - } - now ? tt_SetTipOpa(now) : tt_Hide(); -} -function tt_SetTipOpa(opa) -{ - // To circumvent the opacity nesting flaws of IE, we set the opacity - // for each sub-DIV separately, rather than for the container DIV. - tt_SetOpa(tt_aElt[5], opa); - if(tt_aElt[1]) - tt_SetOpa(tt_aElt[1], opa); - if(tt_aV[SHADOW]) - { - opa = Math.round(opa * 0.8); - tt_SetOpa(tt_aElt[7], opa); - tt_SetOpa(tt_aElt[8], opa); - } -} -function tt_OnScrl() -{ - tt_scrlX = tt_GetScrollX(); - tt_scrlY = tt_GetScrollY(); -} -function tt_OnCloseBtnOver(iOver) -{ - var css = tt_aElt[4].style; - - iOver <<= 1; - css.background = tt_aV[CLOSEBTNCOLORS][iOver]; - css.color = tt_aV[CLOSEBTNCOLORS][iOver + 1]; -} -function tt_OnLClick(e) -{ - // Ignore right-clicks - e = e || window.event; - if(!((e.button && e.button & 2) || (e.which && e.which == 3))) - { - if(tt_aV[CLICKSTICKY] && (tt_iState & 0x4)) - { - tt_aV[STICKY] = true; - tt_iState &= ~0x4; - } - else if(tt_aV[CLICKCLOSE]) - tt_HideInit(); - } -} -function tt_Int(x) -{ - var y; - - return(isNaN(y = parseInt(x)) ? 0 : y); -} -Number.prototype.Timer = function(s, iT, bUrge) -{ - if(!this.value || bUrge) - this.value = window.setTimeout(s, iT); -} -Number.prototype.EndTimer = function() -{ - if(this.value) - { - window.clearTimeout(this.value); - this.value = 0; - } -} -function tt_SetOpa(el, opa) -{ - var css = el.style; - - tt_opa = opa; - if(tt_flagOpa == 1) - { - if(opa < 100) - { - // Hacks for bugs of IE: - // 1.) Once a CSS filter has been applied, fonts are no longer - // anti-aliased, so we store the previous 'non-filter' to be - // able to restore it - if(typeof(el.filtNo) == tt_u) - el.filtNo = css.filter; - // 2.) A DIV cannot be made visible in a single step if an - // opacity < 100 has been applied while the DIV was hidden - var bVis = css.visibility != "hidden"; - // 3.) In IE6, applying an opacity < 100 has no effect if the - // element has no layout (position, size, zoom, ...) - css.zoom = "100%"; - if(!bVis) - css.visibility = "visible"; - css.filter = "alpha(opacity=" + opa + ")"; - if(!bVis) - css.visibility = "hidden"; - } - else if(typeof(el.filtNo) != tt_u) - // Restore 'non-filter' - css.filter = el.filtNo; - } - else - { - opa /= 100.0; - switch(tt_flagOpa) - { - case 2: - css.KhtmlOpacity = opa; break; - case 3: - css.KHTMLOpacity = opa; break; - case 4: - css.MozOpacity = opa; break; - case 5: - css.opacity = opa; break; - } - } -} -function tt_MovDomNode(el, dadFrom, dadTo) -{ - if(dadFrom) - dadFrom.removeChild(el); - if(dadTo) - dadTo.appendChild(el); -} -function tt_Err(sErr, bIfDebug) -{ - if(tt_Debug || !bIfDebug) - alert("Tooltip Script Error Message:\n\n" + sErr); -} - -//============ EXTENSION (PLUGIN) MANAGER ===============// -function tt_ExtCmdEnum() -{ - var s; - - // Add new command(s) to the commands enum - for(var i in config) - { - s = "window." + i.toString().toUpperCase(); - if(eval("typeof(" + s + ") == tt_u")) - { - eval(s + " = " + tt_aV.length); - tt_aV[tt_aV.length] = null; - } - } -} -function tt_ExtCallFncs(arg, sFnc) -{ - var b = false; - for(var i = tt_aExt.length; i;) - {--i; - var fnc = tt_aExt[i]["On" + sFnc]; - // Call the method the extension has defined for this event - if(fnc && fnc(arg)) - b = true; - } - return b; -} - -tt_Init(); Index: /trunk/dhtml/comunicator.pl =================================================================== --- /trunk/dhtml/comunicator.pl (revision 1) +++ /trunk/dhtml/comunicator.pl (revision 1) @@ -0,0 +1,1617 @@ +#!/usr/bin/perl -w +# Flash Operator Panel. http://www.asternic.org +# +# Copyright (c) 2004 Nicolas Gudino. All rights reserved. +# +# Nicolas Gudino +# +# This program is free software, distributed under the terms of +# the GNU General Public License. +# +# THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +use SWF qw(:ALL); +use SWF::Constants qw(:Text :Button :DisplayItem :Fill); + +SWF::setScale(1); +SWF::useSWFVersion(6); +my $movie = new SWF::Movie(); +$movie->setDimension(100, 100); +$movie->setBackground(0xFF, 0xFF, 0xFF); +$movie->setRate(30); +$movie->add(new SWF::Action(<<"EndOfActionScript")); + +var dummyVar=(getTimer()+random(100000)); + +if(context != undefined) { + context = context.toUpperCase(); + colaEvento(0,"debug","contexto leido "+context); + if(context == "DEFAULT") { context=""; } +} else { + colaEvento(0,"debug","context undefined"); + context=""; +} + +var archivo = "variables"+context+".txt?rand="+dummyVar; + +vr = new LoadVars (); + +vr.onLoad = function (success) +{ + if (success == true) { + colaEvento(0,"debug","Ok al leer "+archivo); + nextFrame(); + } else { + colaEvento(0,"debug","Fallo al leer "+archivo); + stop(); + } +}; + +vr.load(archivo); + +EndOfActionScript + +$movie->nextFrame(); +$movie->add(new SWF::Action(<<"EndOfActionScript")); + +function conecta() { + _global.sock = new XMLSocket; + _global.sock.onConnect = handleConnect; + _global.sock.onClose = handleDisconnect; + _global.sock.onXML = handleXML; + if(_global.port == undefined) { + _global.port = 4445; + } + if(_global.server == undefined) { + _global.sock.connect(null, _global.port); + _global.server_print = "default"; + } else { + _global.sock.connect(_global.server, _global.port); + _global.server_print = _global.server; + } +} + +function handleConnect(connectionStatus){ + + if (connectionStatus) { + colaEvento(0,"debug","Conectado! con contexto: "+context); + _global.reconecta = 0; + if(_global.enable_crypto==1) { + envia_comando("contexto", 0, 0); + } else { + envia_comando("contexto", 1, 0); + } + if(restrict != undefined) { + envia_comando("restrict",restrict,0); + } + } else { + colaEvento(0,"debug","No pude conectar!"); + _global.reconecta = 1; + } +} + +function handleXML(doc){ + var e = doc.firstChild; + if (e != null) { + if (e.nodeName == "response") { + var numeroboton = e.attributes.btn; // btn is the button number + var comando = e.attributes.cmd; + var textofinal = e.attributes.data; + + if (_global.key != undefined) { + if(_global.enable_crypto == 1) { + comando = decrypt(comando, _global.key); + if (textofinal.length > 0) { + textofinal = decrypt(textofinal, _global.key); + } + } + } + + + var botonparte = numeroboton.split("@"); + var boton_numero = botonparte[0]; + var boton_contexto = botonparte[1]; + var timernumber = 0; + + + if (boton_contexto == undefined) { + boton_contexto = ""; + } + if (_root.context == undefined) { + _root.context = ""; + } + + + if (comando == "key") { + _global.key = textofinal; + return; + } + + if (comando == "restrict") { + _global.restrict = numeroboton; + _global.mybutton = numeroboton; + var myresa = eval('_root.resaltado'+_global.restrict); + myresa._visible = true; + return; + } + + if (comando == "version") { + if(textofinal != _global.swfversion) + { + _global.statusline=vr.version_mismatch; + } else { + _global.statusline=""; + } + } + + if (_root.context == boton_contexto) { + colaEvento(boton_numero,comando,textofinal); + } + // endif root.context + } + // endif == response + } + // endiff e != null +} + +function colaEvento(boton_numero,comando,textofinal) { + + if(_global.VersionFlash == "MAC") { + // GetURL method for MAC + jsQueue.push("javascript: docommand('"+boton_numero+"','"+comando+"','"+textofinal+"')"); + } else { + // FSCommand method for anything else + jsQueue.push("newevent;"+boton_numero+"|"+comando+"|"+textofinal); + } +} + + +function handleDisconnect(){ + delete _global.key; + _global.reconecta = 1; + colaEvento(0,"debug","Attempt reconnection"); +} + + +Inicia_Variables = function () { + _global.jsQueue = new Array(); + var flashVersion = System.capabilities.version; + var datos = flashVersion.split(" "); + _global.VersionFlash = datos[0]; + _global.server = vr.server; + _global.port = vr.port; + _global.enable_crypto = Number(vr.enable_crypto); + if (isNaN(_global.enable_crypto)) { + _global.enable_crypto=0; + } else { + if(_global.enable_crypto != 0) { + _global.enable_crypto = 1; + } + } +}; + + +recarga = function () { + if(_global.restart == 1) { + // Send command to restart Asterisk + envia_comando("restart","1","1"); + } else { + // Reloads FLASH client + delete _global.key; + var incontext = context; + var inbutton = mybutton; + var inrestrict = _global.restrict; + var indial = dial; + var innohighlight = nohighlight; + for (var a in _root) { + if (typeof (_root[a]) == "object") { + removeMovieClip(_root[a]); + } + if (typeof (_root[a]) == "movieclip") { + removeMovieClip(_root[a]); + } + } + _global.context = incontext; + _global.mybutton = inbutton; + _global.restrict = inrestrict; + _global.dial = indial; + _global.nohighlight = inhighlight; + stop(); + gotoAndPlay(1); + } +}; + + +_root.onEnterFrame = function() { + + if(_global.jsQueue.length>0) { + if(_global.VersionFlash == "MAC") { + getURL(jsQueue.shift()); + } else { + var partes = jsQueue.shift().split(";"); + var comando=partes[0]; + var params=partes[1]; + getURL("FSCommand:"+comando,params); + } + } + +}; + +Timers = function () { + + if (_global.reconecta == 1) { + delete setInterval; + delete _global.key; + recarga(); + return; + } +}; + +setInterval(Timers, 10000); + +function ExtraeNumeroClip(name) { + var destino = ""; + name = name._name; + for (var s = 0; s"9") { + } else { + destino = destino+""+c; + } + if (c == ".") { + destino = ""; + } + } + return destino; +} + +envia_comando = function (comando, origen, destino) { + if (comando != "bogus" && comando != "contexto" && comando != "restrict") { + if (_global.restrict!=0) { + if(comando == "cortar") { + origen_number = ExtraeNumeroClip(origen); + } else { + origen_number = origen; + } + if(_global.restrict != undefined) { + if (_global.restrict == origen_number ) { + } else { + return; + } + } + } + } + message = new XML(); + message_data = message.createElement("msg"); + if (_root.context.length>0) { + agrega_contexto = "@"+context; + } + if (agrega_contexto == undefined) { + agrega_contexto = ""; + } + if (_level0.claveinput.secret == undefined) { + _level0.claveinput.secret = ""; + } + if (_global.claveingresada == undefined && ( comando != "contexto" && comando != "bogus" && comando != "dial" && comando != "restrict")) { + _root.codebox._visible = true; + Selection.setFocus(_root.codebox.claveform); + _root.codebox.swapDepths(_root.log); + return; + } + // var clave=_level0.claveinput.secret+_global.key; + var clave = _global.claveingresada+_global.key; + var md5clave = ""; + var md5clave = calcMD5(clave); + if (comando == "contexto" || comando == "restrict") { + md5clave = ""; + } + message_data.attributes.data = origen+agrega_contexto+"|"+comando+destino+"|"+md5clave; + message.appendChild(message_data); + _global.sock.send(message); + var clave = ""; +}; + +function LTrim(str) { + var whitespace = new String(" \t\n\r"); + var s = new String(str); + if (whitespace.indexOf(s.charAt(0)) != -1) { + var j = 0, i = s.length; + while (j=0 && whitespace.indexOf(s.charAt(i)) != -1) { + i--; + } + s = s.substring(0, i+1); + } + return s; +} + +function Trim(str) { + return RTrim(LTrim(str)); +} + +function setDND(obj, item) { + var nroboton = ExtraeNumeroClip(obj); + envia_comando("dnd", nroboton, nroboton); +} + +function genera_selecttimeout() { + + _global.positionselect = 0; + test = attachMovie("option","optionselected", getNextHighestDepth(), {_x:800, _y:6}); + test._visible = true; + test.legend = "No timeout"; + + test.onPress = function() { + _root.despliega_select(); + }; + + + for (a=0; a<5; a++) { + var b=a+1; + if (_global.opcionesTimeout[a] != undefined) { + + testa = attachMovie("option","option"+a, getNextHighestDepth(), {_x:800, _y:(b*22)+6}); + testa.legend = _global.opcionesTimeout[a]; + testa._visible = false; + + + testa.onRollOver = function() { + this.legend = "* "+this.legend; + }; + + testa.onRollOut = function() { + this.legend = this.legend.substring(2, this.legend.length); + }; + + testa.onPress = function() { + this.legend = this.legend.substring(2, this.legend.length); + var posicion = ExtraeNumeroClip(this); + _global.timeout_value = _global.opcionesTimeoutSecs[posicion]; + _root.muestra_selecttimeout(0); + _root.selectbox1.gotoAndStop(1); + _root.optionselected._visible=true; + _root.optionselected.legend = this.legend; + }; + } + } +}; + +function muestra_selecttimeout(value) { + for (a=0; a<5; a++) { + var v = eval("_root.option"+a); + if(value) { + v._visible = true; + } else { + v._visible = false; + } + } +}; + +function despliega_select() { + _root.optionselected._visible=false; + _root.selectbox1.gotoAndStop(2); + _root.muestra_selecttimeout(1); + +}; + +function base64_decode(opString) { + if ( opString == undefined ) { + return; + } + var str = opString; + var base64s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + var bits, bit1, bit2, bit3, bit4, i = 0; + var decOut = ""; + for (i=0; i> 16, (bits & 0xff00) >> 8, bits & 0xff); + } + if (str.charCodeAt(i-2) == 61) { + return decOut.substring(0, decOut.length-2); + } else if (str.charCodeAt(i-1) == 61) { + return decOut.substring(0, decOut.length-1); + } else { + return decOut.substring(0, decOut.length); + } +}; + + + +// MD5 ROUTINE +/* + * Convert a 32-bit number to a hex string with ls-byte first + */ +var hex_chr = "0123456789abcdef"; +// +// somehow the expression (bitAND(b, c) | bitAND((~b), d)) didn't return coorect results on Mac +// for: +// b&c = a8a20450, ((~b)&d) = 0101c88b, (bitAND(b, c) | bitAND((~b), d)) = a8a20450 <-- !!! +// looks like the OR is not executed at all. +// +// let's try to trick the P-code compiler into working with us... Prayer beads are GO! +// +function bitOR(a, b) { + var lsb = (a & 0x1) | (b & 0x1); + var msb31 = (a >>> 1) | (b >>> 1); + return (msb31 << 1) | lsb; +} +// +// will bitXOR be the only one working...? +// Nope. XOR fails too if values with bit31 set are XORed. +// +// Note however that OR (and AND and XOR?!) works alright for the statement +// (msb31 << 1) | lsb +// even if the result of the left-shift operation has bit 31 set. +// So there might be an extra condition here (Guessmode turned on): +// Mac Flash fails (OR, AND and XOR) if either one of the input operands has bit31 set +// *and* both operands have one or more bits both set to 1. In other words: when both +// input bit-patterns 'overlap'. +// Stuff to munch on for the MM guys, I guess... +// +function bitXOR(a, b) { + var lsb = (a & 0x1) ^ (b & 0x1); + var msb31 = (a >>> 1) ^ (b >>> 1); + return (msb31 << 1) | lsb; +} +// +// bitwise AND for 32-bit integers. This uses 31 + 1-bit operations internally +// to work around bug in some AS interpreters. (Mac Flash!) +// +function bitAND(a, b) { + var lsb = (a & 0x1) & (b & 0x1); + var msb31 = (a >>> 1) & (b >>> 1); + return (msb31 << 1) | lsb; + // return (a & b); +} +// +// Add integers, wrapping at 2^32. This uses 16-bit operations internally +// to work around bugs in some AS interpreters. (Mac Flash!) +// +function addme(x, y) { + var lsw = (x & 0xFFFF)+(y & 0xFFFF); + var msw = (x >> 16)+(y >> 16)+(lsw >> 16); + return (msw << 16) | (lsw & 0xFFFF); +} +function rhex(num) { + str = ""; + for (j=0; j<=3; j++) { + str += hex_chr.charAt((num >> (j*8+4)) & 0x0F)+hex_chr.charAt((num >> (j*8)) & 0x0F); + } + return str; +} +/* + * Convert a string to a sequence of 16-word blocks, stored as an array. + * Append padding bits and the length, as described in the MD5 standard. + */ +function str2blks_MD5(str) { + nblk = ((str.length+8) >> 6)+1; + // 1 + (len + 8)/64 + blks = new Array(nblk*16); + for (i=0; i> 2] |= str.charCodeAt(i) << (((str.length*8+i)%4)*8); + } + blks[i >> 2] |= 0x80 << (((str.length*8+i)%4)*8); + var l = str.length*8; + blks[nblk*16-2] = (l & 0xFF); + blks[nblk*16-2] |= ((l >>> 8) & 0xFF) << 8; + blks[nblk*16-2] |= ((l >>> 16) & 0xFF) << 16; + blks[nblk*16-2] |= ((l >>> 24) & 0xFF) << 24; + return blks; +} +/* + * Bitwise rotate a 32-bit number to the left + */ +function rol(num, cnt) { + return (num << cnt) | (num >>> (32-cnt)); +} +/* + * These functions implement the basic operation for each round of the + * algorithm. + */ +function cmn(q, a, b, x, s, t) { + return addme(rol((addme(addme(a, q), addme(x, t))), s), b); +} + +function ff(a, b, c, d, x, s, t) { + return cmn(bitOR(bitAND(b, c), bitAND((~b), d)), a, b, x, s, t); +} + +function gg(a, b, c, d, x, s, t) { + return cmn(bitOR(bitAND(b, d), bitAND(c, (~d))), a, b, x, s, t); +} + +function hh(a, b, c, d, x, s, t) { + return cmn(bitXOR(bitXOR(b, c), d), a, b, x, s, t); +} + +function ii(a, b, c, d, x, s, t) { + return cmn(bitXOR(c, bitOR(b, (~d))), a, b, x, s, t); +} +/* + * Take a string and return the hex representation of its MD5. + */ +function calcMD5(str) { + x = str2blks_MD5(str); + a = 1732584193; + b = -271733879; + c = -1732584194; + d = 271733878; + var step; + for (i=0; i=ls) { + break; + } + var pepe=s.charAt(is); + if (c2b[s.charAt(is)] == null) { + b[is] = 0xF7; + } else { + b[is] = c2b[s.charAt(is)]; + } + is++; + } + return b; +} +function bytes2str(b) { + var ib = 0; + var lb = b.length; + var s = ''; + while (1) { + if (ib>=lb) { + break; + } + if (b2c[0xFF & b[ib]]!=undefined) { + s += b2c[0xFF & b[ib]]; + } + ib++; + } + return s; +} +function ascii2bytes(a) { + var ia = -1; + var la = a.length; + var ib = 0; + var b = new Array(); + var carry; + while (1) { + // reads 4 chars and produces 3 bytes + while (1) { + ia++; + if (ia>=la) { + return b; + } + if (a2b[a.charAt(ia)] != null) { + break; + } + } + b[ib] = a2b[a.charAt(ia)] << 2; + while (1) { + ia++; + if (ia>=la) { + return b; + } + if (a2b[a.charAt(ia)] != null) { + break; + } + } + carry = a2b[a.charAt(ia)]; + b[ib] |= carry >>> 4; + ib++; + carry = 0xF & carry; + if (carry == 0 && ia == (la-1)) { + return b; + } + b[ib] = carry << 4; + while (1) { + ia++; + if (ia>=la) { + return b; + } + if (a2b[a.charAt(ia)] != null) { + break; + } + } + carry = a2b[a.charAt(ia)]; + b[ib] |= carry >>> 2; + ib++; + carry = 3 & carry; + if (carry == 0 && ia == (la-1)) { + return b; + } + b[ib] = carry << 6; + while (1) { + ia++; + if (ia>=la) { + return b; + } + if (a2b[a.charAt(ia)] != null) { + break; + } + } + b[ib] |= a2b[a.charAt(ia)]; + ib++; + } + return b; +} +function bytes2ascii(b) { + var ib = 0; + var lb = b.length; + var s = ''; + var b1; + var b2; + var b3; + var carry; + while (1) { + // reads 3 bytes and produces 4 chars + if (ib>=lb) { + break; + } + b1 = 0xFF & b[ib]; + s += b2a[63 & (b1 >>> 2)]; + carry = 3 & b1; + ib++; + if (ib>=lb) { + s += b2a[carry << 4]; + break; + } + b2 = 0xFF & b[ib]; + s += b2a[(0xF0 & (carry << 4)) | (b2 >>> 4)]; + carry = 0xF & b2; + ib++; + if (ib>=lb) { + s += b2a[carry << 2]; + break; + } + b3 = 0xFF & b[ib]; + s += b2a[(60 & (carry << 2)) | (b3 >>> 6)]+b2a[63 & b3]; + ib++; + if (ib%36 == 0) { + s += "\n"; + } + } + return s; +} +function bytes2blocks(bytes) { + var blocks = new Array(); + var ibl = 0; + var iby = 0; + var nby = bytes.length; + while (1) { + blocks[ibl] = (0xFF & bytes[iby]) << 24; + iby++; + if (iby>=nby) { + break; + } + blocks[ibl] |= (0xFF & bytes[iby]) << 16; + iby++; + if (iby>=nby) { + break; + } + blocks[ibl] |= (0xFF & bytes[iby]) << 8; + iby++; + if (iby>=nby) { + break; + } + blocks[ibl] |= 0xFF & bytes[iby]; + iby++; + if (iby>=nby) { + break; + } + ibl++; + } + return blocks; +} +function blocks2bytes(blocks) { + var bytes = new Array(); + var iby = 0; + var ibl = 0; + var nbl = blocks.length; + while (1) { + if (ibl>=nbl) { + break; + } + bytes[iby] = 0xFF & (blocks[ibl] >>> 24); + iby++; + bytes[iby] = 0xFF & (blocks[ibl] >>> 16); + iby++; + bytes[iby] = 0xFF & (blocks[ibl] >>> 8); + iby++; + bytes[iby] = 0xFF & blocks[ibl]; + iby++; + ibl++; + } + return bytes; +} +function digest_pad(bytearray) { + var newarray = new Array(); + var ina = 0; + var iba = 0; + var nba = bytearray.length; + var npads = 15-(nba%16); + newarray[ina] = npads; + ina++; + while (iba0) { + newarray[ina] = 0; + ina++; + ip--; + } + return newarray; +} +function pad(bytearray) { + var newarray = new Array(); + var ina = 0; + var iba = 0; + var nba = bytearray.length; + var npads = 7-(nba%8); + newarray[ina] = (0xF8 & rand_byte()) | (7 & npads); + ina++; + while (iba0) { + newarray[ina] = rand_byte(); + ina++; + ip--; + } + return newarray; +} +function rand_byte() { + return Math.floor(256*Math.random()); + if (!rand_byte_already_called) { + var now = new Date(); + seed = now.milliseconds; + rand_byte_already_called = true; + } + seed = (1029*seed+221591)%1048576; + return Math.floor(seed/4096); +} +function unpad(bytearray) { + var iba = 0; + var newarray = new Array(); + var ina = 0; + var npads = 0x7 & bytearray[iba]; + iba++; + var nba = bytearray.length-npads; + while (iba=nbl) { + break; + } + v0[0] = blocks[ibl]; + ibl++; + v0[1] = blocks[ibl]; + ibl++; + v1[0] = blocks[ibl]; + ibl++; + v1[1] = blocks[ibl]; + ibl++; + c0 = tea_code(xor_blocks(v0, c0), key); + c1 = tea_code(xor_blocks(v1, c1), key); + swap = c0[0]; + c0[0] = c0[1]; + c0[1] = c1[0]; + c1[0] = c1[1]; + c1[1] = swap; + } + var concat = new Array(); + concat[0] = c0[0]; + concat[1] = c0[1]; + concat[2] = c1[0]; + concat[3] = c1[1]; + return concat; +} +function encrypt(str, keystr) { + var key = new Array(); + key = binarydigest(keystr); + var blocks = new Array(); + blocks = bytes2blocks(pad(str2bytes(str))); + var ibl = 0; + var nbl = blocks.length; + // Initial Value for CBC mode = "abcdbcde". Retain for interoperability. + var c = new Array(); + c[0] = 0x61626364; + c[1] = 0x62636465; + var v = new Array(); + var cblocks = new Array(); + var icb = 0; + while (1) { + if (ibl>=nbl) { + break; + } + v[0] = blocks[ibl]; + ibl++; + v[1] = blocks[ibl]; + ibl++; + c = tea_code(xor_blocks(v, c), key); + cblocks[icb] = c[0]; + icb++; + cblocks[icb] = c[1]; + icb++; + } + return binary2ascii(cblocks); +} +function decrypt(ascii, keystr) { + var key = new Array(); + key = binarydigest(keystr); + var cblocks = new Array(); + cblocks = ascii2binary(ascii); + var icbl = 0; + var ncbl = cblocks.length; + var lastc = new Array(); + lastc[0] = 0x61626364; + lastc[1] = 0x62636465; + var v = new Array(); + var c = new Array(); + var blocks = new Array(); + var ibl = 0; + while (1) { + if (icbl>=ncbl) { + break; + } + c[0] = cblocks[icbl]; + icbl++; + c[1] = cblocks[icbl]; + icbl++; + v = xor_blocks(lastc, tea_decode(c, key)); + blocks[ibl] = v[0]; + ibl++; + blocks[ibl] = v[1]; + ibl++; + lastc[0] = c[0]; + lastc[1] = c[1]; + } + return bytes2str(unpad(blocks2bytes(blocks))); +} +function xor_blocks(blk1, blk2) { + var blk = new Array(); + blk[0] = blk1[0] ^ blk2[0]; + blk[1] = blk1[1] ^ blk2[1]; + return blk; +} +function tea_code(v, k) { + var v0 = v[0]; + var v1 = v[1]; + var k0 = k[0]; + var k1 = k[1]; + var k2 = k[2]; + var k3 = k[3]; + var sum = 0; + var n = 32; + while (n-->0) { + sum -= 1640531527; + // TEA magic number 0x9e3779b9 + sum = sum | 0; + v0 += ((v1 << 4)+k0) ^ (v1+sum) ^ ((v1 >>> 5)+k1); + v1 += ((v0 << 4)+k2) ^ (v0+sum) ^ ((v0 >>> 5)+k3); + } + var w = new Array(); + w[0] = v0 | 0; + w[1] = v1 | 0; + return w; +} +function tea_decode(v, k) { + var v0 = v[0]; + var v1 = v[1]; + var k0 = k[0]; + var k1 = k[1]; + var k2 = k[2]; + var k3 = k[3]; + var sum = 0; + var n = 32; + sum = -957401312; + while (n-->0) { + v1 -= ((v0 << 4)+k2) ^ (v0+sum) ^ ((v0 >>> 5)+k3); + v0 -= ((v1 << 4)+k0) ^ (v1+sum) ^ ((v1 >>> 5)+k1); + sum += 1640531527; + sum = sum | 0; + } + var w = new Array(); + w[0] = v0 | 0; + w[1] = v1 | 0; + return w; +} + +Key.addListener(Key); + +Key.onKeyDown = function(){ + var incremento = 1; + var tecla = Key.getCode(); + + if(tecla == 16) { + _global.shift = 1; + } + + if(tecla == 40) // DOWN + { + // Select next button DOWN + myapaga = eval('_root.resaltado'+_global.rectanguloprendido); + dif1 = (_global.rectanguloprendido) % _root.cuantas_filas; + incremento = 1; + if(dif1 == 0) { + // It changed the column, increment it again + incremento = incremento - _root.cuantas_filas; + } + proximo = _global.rectanguloprendido + incremento; + var myresa = eval('_root.resaltado'+proximo); + if(_global.rectanguloprendido != _global.restrict) { + myapaga._visible = false; + } + myresa._visible = true; + _global.rectanguloprendido = proximo; + _root.makeStatus(proximo); + } + if(tecla == 38) // UP + { + // Select next button UP + myapaga = eval('_root.resaltado'+_global.rectanguloprendido); + dif1 = (_global.rectanguloprendido-1) % _root.cuantas_filas; + incremento = -1; + if(dif1 == 0) { + // It changed the column, increment it again + incremento = incremento + _root.cuantas_filas; + } + proximo = _global.rectanguloprendido + incremento; + var myresa = eval('_root.resaltado'+proximo); + if(_global.rectanguloprendido != _global.restrict) { + myapaga._visible = false; + } + myresa._visible = true; + _global.rectanguloprendido = proximo; + _root.makeStatus(proximo); + } + if(tecla == 37) // LEFT + { + + if (_root.superdetails._visible == true) { + var tab = _root.superdetails.tab1._currentframe; + if(tab == 2) { + _root.superdetails.tab1.gotoAndStop(1); + _root.superdetails.tab2.gotoAndStop(2); + _root.superdetails.texto = _global.superdetailstexttab1; + } else { + _root.superdetails.tab1.gotoAndStop(2); + _root.superdetails.tab2.gotoAndStop(1); + _root.superdetails.texto = _global.superdetailstexttab2; + } + } else { + // Select next button on the LEFT + myapaga = eval('_root.resaltado'+_global.rectanguloprendido); + incremento = _root.cuantas_filas; + diferencia = _global.rectanguloprendido % _root.cuantas_filas; + proximo = _global.rectanguloprendido - incremento; + + if(proximo < 1) { + proximo = ((_root.cuantas_columnas - 1) * _root.cuantas_filas)+diferencia; + } + var myresa = eval('_root.resaltado'+proximo); + if(_global.rectanguloprendido != _global.restrict) { + myapaga._visible = false; + } + myresa._visible = true; + _global.rectanguloprendido = proximo; + _root.makeStatus(proximo); + } + } + + if(tecla == 39) // RIGHT + { + if(_root.detail._visible == true) { + _root.superdetails._visible = true; + _root.detail._visible = false; + } else if (_root.superdetails._visible == true) { + var tab = _root.superdetails.tab1._currentframe; + if(tab == 2) { + _root.superdetails.tab1.gotoAndStop(1); + _root.superdetails.tab2.gotoAndStop(2); + _root.superdetails.texto = _global.superdetailstexttab1; + } else { + _root.superdetails.tab1.gotoAndStop(2); + _root.superdetails.tab2.gotoAndStop(1); + _root.superdetails.texto = _global.superdetailstexttab2; + } + } else { + // Select next button on the RIGHT + myapaga = eval('_root.resaltado'+_global.rectanguloprendido); + total = _root.cuantas_filas * _root.cuantas_columnas; + incremento = _root.cuantas_filas; + diferencia = _global.rectanguloprendido % _root.cuantas_filas; + proximo = _global.rectanguloprendido + incremento; + + if(proximo > total) { + proximo = 1+diferencia-1; + } + var myresa = eval('_root.resaltado'+proximo); + if(_global.rectanguloprendido != _global.restrict) { + myapaga._visible = false; + } + myresa._visible = true; + _global.rectanguloprendido = proximo; + _root.makeStatus(proximo); + } + } + if(tecla == 9) // TAB + { + myapaga = eval('_root.resaltado'+_global.rectanguloprendido); + total = _root.cuantas_filas * _root.cuantas_columnas; + if(_global.shift == 1) { + incremento = -1; + } else { + incremento = 1; + } + proximo = _global.rectanguloprendido + incremento; + + if(proximo > total) { + proximo = 1; + } + if(proximo < 1) { + proximo = total; + } + var myresa = eval('_root.resaltado'+proximo); + if(_global.rectanguloprendido == _global.restrict) { + myapaga._visible = false; + } + myresa._visible = true; + _global.rectanguloprendido = proximo; + _root.makeStatus(proximo); + } + + if(tecla == 27) // ESC + { + _root.codebox._visible = false; + _root.log._visible = false; + _root.detail._visible = false; + _root.superdetails._visible = false; + } + + if(tecla == 18) // ALT + { + var myon = _global.rectanguloprendido; + if(myon>0) { + var myclip = eval('_level0.rectangulo'+myon+'.flecha'+myon); + _root.displaydetails(myclip); + } + } + + if(tecla == 13) // ENTER + { + if(_root.codebox._visible == true) { + // The security code box is visible, sends code and hides it + _global.claveingresada = _root.codebox.claveform.text; + _root.codebox._visible = false; + _root.envia_comando('bogus', 0, 0); + } else { + // The security code is not visible, open detail windows of + // highlighted button + var myon = _global.rectanguloprendido; + if(myon>0) { + var myclip = eval('_level0.rectangulo'+myon+'.flecha'+myon); + _root.displaydetails(myclip); + } + } + } + + +}; + +Key.onKeyUp = function(){ + var tecla = Key.getCode(); + if(tecla == 16) { + _global.shift = 0; + } +}; + +Inicia_Variables(); +conecta(); + +EndOfActionScript + +# Saves the movie +$movie->nextFrame(); +$movie->save("comunicator.swf",9); Index: /trunk/dhtml/index.php =================================================================== --- /trunk/dhtml/index.php (revision 72) +++ /trunk/dhtml/index.php (revision 1) @@ -40,4 +40,5 @@ win.getContent().innerHTML= " "; timerID = setTimeout("UpdateTimer()", 1000); + tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : "" }; --> @@ -49,4 +50,5 @@ + @@ -56,5 +58,4 @@ - \n"; echo " 
\n"; @@ -69,6 +70,4 @@ echo "
 
"; echo "
 
"; -echo ""; -echo ""; echo "
 
"; echo "\n"; @@ -83,5 +82,5 @@
- + @@ -89,6 +88,7 @@ - + +
Index: /trunk/CHANGES =================================================================== --- /trunk/CHANGES (revision 80) +++ /trunk/CHANGES (revision 1) @@ -1,337 +1,3 @@ -Version .29 - -2008-05-29 13:26 +0000 [r77] root : - - * trunk/op_server.pl, trunk/ming-source/operator_panel.pl: Fix - - prefix in extension when using wildcard server - -2008-05-14 11:39 +0000 [r76] root : - - * trunk/op_server.pl: Remove some debug print lines - -2008-05-07 18:52 +0000 [r75] root : - - * trunk/op_server.pl: Add new event for dhtml client - -2008-05-06 14:19 +0000 [r74] root : - - * trunk/op_buttons.cfg: Fix regexp sample in op_buttons.cfg - -2008-04-10 19:44 +0000 [r73] root : - - * trunk/op_server.pl: Serve policy file from server to make new - flash clients happy. Also formatting fixes using perltidy and - line lenght of 140 - -Version .28 - -2008-03-30 [r70] - - * Remove dhtmltooltip and replace with wz_tooltip - -2008-02-19 [r69] - - * Add sample crossdomain.xml file needed by some flash players - -2008-01-28 [r68] - - * New langague added 'gallego' - -2007-12-04 [r67] - - * Fix reverse transfer for park - -2007-11-29 [r66] - - * Add extra event for meetmejoin because sometimes there are no - newexten events when redirecting to meetme in attendant transfers - -2007-11-29 [r65] - - * Add support for channel in voicemailext, so you can use it to - launch a macro via local when double clicking on the mailbox icon - -2007-11-29 [r64] - - * Add parkexten and parktimeout to op_server.cfg and support for - Park command via manager together with updates for Asterisk 1.4 - compatibility. - -2007-11-29 [r63] - - * Make it work with asterisk 1.4 originateresponse change (for - attendant transfers) - -2007-11-23 [r62] - - * add SpyExt command and drop action to arrow - -2007-11-07 [r61] - - * Honour label_extent when renaming label - -2007-08-13 [r60] - - * Fix 'waiting on queue' for normal buttons and some formatting - fixes - -2007-08-06 [r59] - - * Fix clidtext for queue summary buttons - -2007-08-06 [r58] - - * Add support for QUEUE_PRIO for queue join events - -2007-08-06 [r57] - - * Fix for groupcount and timers - -2007-08-06 [r56] - - * Fix timer issue - -2007-08-02 [r55] - - * Remove delay in syswrite because it makes asterisk 1.2.7 unhappy - -2007-08-02 [r54] - - * Example new buttons config for groupcount - -2007-08-02 [r53] - - * Ooops! Format clid fixed - -2007-08-02 [r52] - - * Ooops! Set version to SVNVERSION - -2007-08-02 [r51] - - * no_label_counter in op_buttons.cfg (prevents counting on multiple - position labels). Fixes on groupcount. Added count to - op_buttons.cfg to set number of sessions for group_count buttons - -2007-07-17 [r50] - - * Fix restrict for panel_context - -2007-07-17 [r49] - - * Fix flash client for multiple passvars values - -2007-06-29 [r48] - - * Added optional amportal.conf parsing - -2007-06-28 [r47] - - * Added date variables replacement for monitor_filename (%Y %m %d - %h %i %s) - -2007-06-21 [r46] - - * Add Monitoring to FOP actions by single clicking on the arrow - -2007-06-15 [r45] - - * Add 1ms delay to syswrite, it makes some asterisk versions - happier - -2007-05-30 [r44] - - * Add include support to op_server.cfg - -2007-05-14 [r43] - - * Add passvars parameter to op_server.cfg to pass extra values to - popups - -2007-05-14 [r42] - - * Support for patched valetparking - -2007-04-30 [r41] - - * Fix for regexp buttons when coupled with Local channels - -2007-04-27 [r40] - - * Remove AsyncGoto from channel name so parking with zap works - better. - -2007-04-27 [r39] - - * More split optimizations - -2007-04-27 [r37-38] - - * Proper debug instead of print - - * Slight change to redhat init script in preparation of .spec - -2007-04-26 [r36] - - * Russian language files. Thanks Eugene Malikov. - -2007-04-26 [r35] - - * recompute_queues optimizations and some perl tidyup - -2007-04-26 [r34] - - * More regexp optimizations and debugs - -2007-04-26 [r33] - - * Remove unused vars and optimize erase_instances_for_trunk_buttons - -2007-04-26 [r32] - - * Remove more unused vars - -2007-04-26 [r31] - - * Remove unused var and optimize some regexps - -2007-04-24 [r30] - - * Fix split contexto order. Replace nada with undef. Fix - recompute_queues states - -2007-04-23 [r29] - - * Improve and optimize perl splits. Use warnings pragma instead of - -w. - -2007-04-19 [r28] - - * Change nonblocking perl perl code (LINworks GmbH) - -2007-04-19 [r27] - - * Improve perl code (LINworks GmbH) - -2007-04-19 [r26] - - * Improve perl code (LINworks GmbH) - -2007-04-13 [r25] - - * Fixed persistent clid-label for recompute queues - -2007-03-23 [r23-24] - - * Fix on flash client for unregistration events - - * Registration caching to not flood flash clients with repited - registered events. Changed debug level for digest_event_block and - try to make some sense out of it - -2007-03-23 [r22] - - * Starting with digest_event_block clean ups - -2007-03-23 [r21] - - * Fix voicemail count (ticket #1) - -2007-03-20 [r20] - - * Fix Did/Trunk free routine and remove debug lines - -2007-03-20 [r19] - - * Fix trunk matching for CLID and DID buttons - -2007-03-20 [r18] - - * Add (experimental) DID buttons for matching FreePBX FROM_DID - lines - -2007-03-20 [r17] - - * Trunkify CLID buttons - -2007-03-19 [r12] - - * Make clid on busy buttons show up when 1st load instead of - permanent text - -2007-03-16 [r11] - - * Add onData prototype (commented) into the flash client... will - experiment to see if it is faster than standard flash XML - processing - -2007-03-16 [r10] - - * refactoring of digest_event_block, first pass... - -2007-03-16 [r9] - - * If/elseif refactoring plus fixing newexten duplication in - procesabloque - -2007-03-16 [r8] - - * Refactoring if-elseif, setting clid on newexten prio 1 for - showing dialed number. Changing settext to setclid - -2007-03-15 [r7] - - * Set svn version to op_server.pl - -2007-03-15 [r6] nicolas: - - * Update docs - -2007-03-14 [r5] - - * Update documentation. Make settext to be persistent overriding - callerid values sent by regular states. Do not default to state - up for events without state - -2007-03-14 [r4] - - * Reorganize svn, remove compiled flash movies from repository - -2007-03-14 [r3] - - * fix autosip crash after asterisk restart - - Version .27 - -Mon Feb 26 20:33:03 ART 2007 nicolas@house.com.ar - * sample config update with alarm - -Mon Feb 26 20:31:40 ART 2007 nicolas@house.com.ar - * new .swf - -Mon Feb 26 20:31:05 ART 2007 nicolas@house.com.ar - * timer alarms for buttons - -Mon Feb 26 19:23:48 ART 2007 nicolas@house.com.ar - * queuestatus fixes - -Mon Feb 26 19:19:36 ART 2007 nicolas@house.com.ar - * multiserver mionitoring, no security code fixes, userevent updates for 1.4, doc updates - -Tue Jan 23 19:09:50 ART 2007 nicolas@house.com.ar - * some callerid modifications - -Tue Jan 23 17:35:10 ART 2007 nicolas@house.com.ar - * reload when asterisk reload - -Fri Jan 19 16:22:12 ART 2007 nicolas@house.com.ar - * callerid name in clidformat and some documentation updates - -Fri Dec 22 20:57:39 ART 2006 nicolas@house.com.ar - * Exception for mISDN sessions - -Thu Dec 21 20:18:28 ART 2006 nicolas@house.com.ar - * updated CHANGES Thu Dec 21 20:16:08 ART 2006 nicolas@house.com.ar Index: /trunk/Value =================================================================== --- /trunk/Value (revision 1) +++ /trunk/Value (revision 1) @@ -0,0 +1,40 @@ +# This viminfo file was generated by Vim 6.3. +# You may edit it if you're careful! + +# Value of 'encoding' when this file was written +*encoding=utf-8 + + +# hlsearch on (H) or off (h): +~H +# Last Search Pattern: +~MSle0~/State + +# Command Line History (newest to oldest): +:q! +:x + +# Search String History (newest to oldest): +?/State + +# Expression History (newest to oldest): + +# Input Line History (newest to oldest): + +# Input Line History (newest to oldest): + +# Registers: + +# File marks: +'0 423 40 /home/asternic/op_panel-0.27/CHANGES + +# Jumplist (newest first): +-' 423 40 /home/asternic/op_panel-0.27/CHANGES +-' 421 56 /home/asternic/op_panel-0.27/CHANGES +-' 4 0 /home/asternic/op_panel-0.27/CHANGES +-' 1 0 /home/asternic/op_panel-0.27/CHANGES + +# History of marks within files (newest to oldest): + +> /home/asternic/op_panel-0.27/CHANGES + " 423 40 Index: /trunk/op_server.pl =================================================================== --- /trunk/op_server.pl (revision 92) +++ /trunk/op_server.pl (revision 1) @@ -1,3 +1,3 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w # Flash Operator Panel. http://www.asternic.org @@ -22,5 +22,4 @@ use strict; -use warnings; use integer; @@ -35,9 +34,6 @@ use POSIX qw(setsid EWOULDBLOCK); -my $FOP_VERSION = "SVNVERSION"; +my $FOP_VERSION = "027.001"; my %datos = (); -my %chanvar = (); -my %monitoring = (); -my %passvar = (); my %sesbot = (); my %linkbot = (); @@ -64,5 +60,4 @@ my %botonmeetme = (); my %botonclid = (); -my %botonpermanenttext = (); my %botonqueue = (); my %botonqueue_count = (); @@ -115,5 +110,4 @@ my %client_queue_nocrypt = (); my %ip_addy = (); -my %held_channel = (); my %agents_available_on_queue = (); my $queue_object = {}; @@ -148,5 +142,4 @@ my %mailbox; my %tovoicemail; -my %tospy; my %instancias; my %agent_to_channel; @@ -173,6 +166,4 @@ my $web_hostname; my $listen_port; -my $park_exten; -my $parktimeout; my $listen_addr; my $security_code; @@ -180,4 +171,5 @@ my $astmanproxy_server = ""; my $restrict_channel = ""; +my $socketpolicy; my $poll_interval; my $poll_voicemail; @@ -195,5 +187,4 @@ my $queue_hide; my $enable_restart; -my $passvars = ""; my $change_led; my $cdial_nosecure; @@ -221,13 +212,12 @@ my %total_legends; my %total_images; -my @serverinclude = (); -my @btninclude = (); -my @styleinclude = (); -my $command = ""; -my $daemonized = 0; -my $pidfile = "/var/run/op_panel.pid"; -my $logdir = ""; -my $confdir = ""; -my $tab = ""; +my @btninclude = (); +my @styleinclude = (); +my $command = ""; +my $daemonized = 0; +my $pidfile = "/var/run/op_panel.pid"; +my $logdir = ""; +my $confdir = ""; +my $tab = ""; my $PADDING = join( @@ -402,105 +392,67 @@ } -sub parse_amportal_config { - my $filename = shift; - my %ampconf; - - open( AMPCONF, $filename ) || die "Cannot open $filename"; - - while () { - if ( $_ =~ /^\s*([a-zA-Z0-9]+)\s*=\s*(.*)\s*([;#].*)?/ ) { - $ampconf{$1} = $2; - } - } - - close(AMPCONF); - return %ampconf; -} - sub read_server_config() { my $context = ""; - my @distinct_files; $counter_servers = -1; $/ = "\n"; - @distinct_files = unique(@serverinclude); - - foreach my $archivo (@distinct_files) { - - open( CONFIG, "<$directorio/$archivo" ) - or die("Could not open op_server.cfg. Aborting..."); - - while () { - chomp; - $_ =~ s/^\s+//g; - $_ =~ s/([^;]*)[;](.*)/$1/g; - $_ =~ s/\s+$//g; - - if ( /^#/ || /^;/ || /^$/ ) { - next; - } # Ignores comments and empty lines - - if (/^\Q[\E/) { - s/\[(.*)\]/$1/g; - tr/a-z/A-Z/; - $context = $_; - } - else { - if ( $context ne "" ) { - my ( $variable_name, $value ) = split( /=/, $_ ); - $variable_name =~ tr/A-Z/a-z/; - $variable_name =~ s/\s+//g; - $value =~ s/^\s+//g; - $value =~ s/\s+$//g; - $value =~ s/\"//g; - $config->{$context}{$variable_name} = $value; - - if ( $variable_name eq "manager_host" ) { - $counter_servers++; - $manager_host[$counter_servers] = $value; - } - - if ( $variable_name eq "manager_user" ) { - $manager_user[$counter_servers] = $value; - } - - if ( $variable_name eq "manager_secret" ) { - $manager_secret[$counter_servers] = $value; - } - - if ( $variable_name eq "manager_port" ) { - $manager_port[$counter_servers] = $value; - } - - if ( $variable_name eq "event_mask" ) { - $event_mask[$counter_servers] = $value; - } - - if ( $variable_name eq "astmanproxy_server" ) { - push @astmanproxy_servers, $value; - } - - } - } - } - close(CONFIG); - } - - if ( defined( $config->{GENERAL}{use_amportal_conf} ) ) { - if ( $config->{GENERAL}{use_amportal_conf} == 1 ) { - my $freepbx_config = "/etc/amportal.conf"; - my %ampconf; - - if ( -e $freepbx_config ) { - %ampconf = parse_amportal_config($freepbx_config); - $config->{"GENERAL"}{"web_hostname"} = $ampconf{"AMPWEBADDRESS"}; - $config->{"GENERAL"}{"security_code"} = $ampconf{"FOPPASSWORD"}; - $config->{"GENERAL"}{"flash_dir"} = $ampconf{"FOPWEBROOT"}; - $manager_user[0] = $ampconf{"AMPMGRUSER"}; - $manager_secret[0] = $ampconf{"AMPMGRPASS"}; - } - } - } + open( CONFIG, "<$directorio/op_server.cfg" ) + or die("Could not open op_server.cfg. Aborting..."); + + while () { + chomp; + $_ =~ s/^\s+//g; + $_ =~ s/([^;]*)[;](.*)/$1/g; + $_ =~ s/\s+$//g; + + if ( /^#/ || /^;/ || /^$/ ) { + next; + } # Ignores comments and empty lines + + if (/^\Q[\E/) { + s/\[(.*)\]/$1/g; + tr/a-z/A-Z/; + $context = $_; + } + else { + if ( $context ne "" ) { + my ( $variable_name, $value ) = split( /=/, $_ ); + $variable_name =~ tr/A-Z/a-z/; + $variable_name =~ s/\s+//g; + $value =~ s/^\s+//g; + $value =~ s/\s+$//g; + $value =~ s/\"//g; + $config->{$context}{$variable_name} = $value; + + if ( $variable_name eq "manager_host" ) { + $counter_servers++; + $manager_host[$counter_servers] = $value; + } + + if ( $variable_name eq "manager_user" ) { + $manager_user[$counter_servers] = $value; + } + + if ( $variable_name eq "manager_secret" ) { + $manager_secret[$counter_servers] = $value; + } + + if ( $variable_name eq "manager_port" ) { + $manager_port[$counter_servers] = $value; + } + + if ( $variable_name eq "event_mask" ) { + $event_mask[$counter_servers] = $value; + } + + if ( $variable_name eq "astmanproxy_server" ) { + push @astmanproxy_servers, $value; + } + + } + } + } + close(CONFIG); $web_hostname = $config->{GENERAL}{web_hostname}; @@ -530,7 +482,4 @@ $enable_restart = $config->{GENERAL}{enable_restart}; $defaultlanguage = $config->{GENERAL}{language}; - $passvars = $config->{GENERAL}{passvars}; - $park_exten = $config->{GENERAL}{parkexten}; - $parktimeout = $config->{GENERAL}{parktimeout}; if ( $debuglevel == -1 ) { @@ -559,5 +508,5 @@ $clid_format = $config->{GENERAL}{clid_format}; - if ( !defined($flash_dir) ) { $flash_dir = '/var/www/html' } + $flash_file = $flash_dir . "/variables.txt"; push @all_flash_files, $flash_file; @@ -608,12 +557,4 @@ } - if ( !defined $config->{GENERAL}{monitor_filename} ) { - $config->{GENERAL}{monitor_filename} = "\${UNIQUEID}"; - } - - if ( !defined $config->{GENERAL}{monitor_format} ) { - $config->{GENERAL}{monitor_format} = "wav"; - } - if ( !defined $clid_privacy ) { $clid_privacy = 0; @@ -678,19 +619,4 @@ if ( !defined $clid_format ) { $clid_format = "(xxx) xxx-xxxx"; - } - - if ( !defined $passvars ) { - $passvars = ""; - } - - if ( !defined $park_exten ) { - $park_exten = "700"; - } - - if ( !defined $parktimeout ) { - $parktimeout = 45000; - } - else { - $parktimeout = $parktimeout * 1000; } @@ -717,5 +643,5 @@ if ( $tipo eq "buttons" ) { - if ( !grep { $filename eq $_ } @btninclude ) { + if ( !inArray( $filename, @btninclude ) ) { push( @btninclude, $filename ); } @@ -726,15 +652,6 @@ } if ( $tipo eq "style" ) { - if ( !grep { $filename eq $_ } @styleinclude ) { + if ( !inArray( $filename, @styleinclude ) ) { push( @styleinclude, $filename ); - } - else { - log_debug( "** $filename already included", 16 ) if DEBUG; - return; - } - } - if ( $tipo eq "server" ) { - if ( !grep { $filename eq $_ } @serverinclude ) { - push( @serverinclude, $filename ); } else { @@ -1205,14 +1122,5 @@ my $pos = $tmphash{position}; $pos =~ s/(\d+),(\d+)/$1/g; - my $countpos = 2; - $tmphash{position} = ""; - if ( defined( $tmphash{count} ) ) { - $countpos = $tmphash{count}; - } - my $a = 0; - for ( $a = 0 ; $a < $countpos ; $a++ ) { - $tmphash{position} .= "$pos,"; - } - $tmphash{position} = substr( $tmphash{position}, 0, -1 ); + $tmphash{position} = "$pos,$pos"; $no_counter = 1; } @@ -1279,6 +1187,5 @@ $buttons{ uc("$tmphash{server}^$chan_trunk") } = $pos; $textos{$indice_contexto} = $tmphash{label}; - if ( !defined( $tmphash{no_label_counter} ) ) { $tmphash{no_label_counter} = 0; } - if ( $no_counter == 0 && $tmphash{no_label_counter} == 0 ) { + if ( $no_counter == 0 ) { $textos{$indice_contexto} .= " " . $count; } @@ -1438,12 +1345,4 @@ $tovoicemail{$indicevm} = $tmphash{voicemailext}; } - if ( defined( $tmphash{spyext} ) ) { - my $indicespy = $lastposition{ $tmphash{panel_context} }; - if ( $tmphash{panel_context} ne "" ) { - $indicespy .= "\@$tmphash{panel_context}"; - } - $tospy{$indicespy} = $tmphash{spyext}; - } - $/ = "\0"; } @@ -1606,5 +1505,6 @@ my $contextoboton = $key; if ( $contextoboton =~ m/\@/ ) { - ( undef, $contextoboton ) = split( /\@/, $contextoboton, 2 ); + my @parte = split( /\@/, $contextoboton, 2 ); + $contextoboton = $parte[1]; $contextoboton =~ tr/a-z/A-Z/; } @@ -1624,5 +1524,6 @@ my $contextoboton = $key; if ( $contextoboton =~ m/\@/ ) { - ( undef, $contextoboton ) = split( /\@/, $contextoboton, 2 ); + my @parte = split( /\@/, $contextoboton, 2 ); + $contextoboton = $parte[1]; $contextoboton =~ tr/a-z/A-Z/; } @@ -1642,5 +1543,6 @@ my $contextoboton = $key; if ( $contextoboton =~ m/\@/ ) { - ($contextoboton) = split( /\@/, $contextoboton, 2 ); + my @parte = split( /\@/, $contextoboton, 2 ); + $contextoboton = $parte[1]; $contextoboton =~ tr/a-z/A-Z/; } @@ -1661,5 +1563,6 @@ my $contextoboton = $key; if ( $contextoboton =~ m/\@/ ) { - ( undef, $contextoboton ) = split( /\@/, $contextoboton, 2 ); + my @parte = split( /\@/, $contextoboton, 2 ); + $contextoboton = $parte[1]; $contextoboton =~ tr/a-z/A-Z/; } @@ -1680,5 +1583,6 @@ my $contextoboton = $key; if ( $contextoboton =~ m/\@/ ) { - ( undef, $contextoboton ) = split( /\@/, $contextoboton, 2 ); + my @parte = split( /\@/, $contextoboton, 2 ); + $contextoboton = $parte[1]; $contextoboton =~ tr/a-z/A-Z/; } @@ -1847,6 +1751,5 @@ # a trunk button. - log_debug( "$heading START SUB canalid $canalid contexto $contexto server $server canalsesion $canalsesion", 16 ) - if DEBUG; + log_debug( "$heading START SUB canalid $canalid contexto $contexto server $server canalsesion $canalsesion", 16 ) if DEBUG; if ( $canalid eq "" ) { @@ -1897,5 +1800,5 @@ } log_debug( "$heading contexto $contexto", 32 ) if DEBUG; - my ( undef, $ses ) = separate_session_from_channel($canalsesion); + my ( $nada, $ses ) = separate_session_from_channel($canalsesion); $sesion = $ses; } @@ -1919,4 +1822,6 @@ } + my $canalconcontextosinserver = $canalconcontexto; + $canalconcontextosinserver =~ s/(\d+)\^(.*)/$2/g; if ( $canalconcontexto !~ /\^/ ) { $canalconcontexto = $server . "^" . $canalconcontexto; @@ -1968,6 +1873,10 @@ } } - if ( $elemento =~ /^(?i:mISDN)(?!.*XXXY)/ ) { - $elemento .= "-XXXY"; + if ( $elemento =~ /^mISDN/i ) { + if ( $elemento !~ /XXXY/ ) { + $elemento .= "-XXXY"; + } + + # $elemento =~ s/(.*)\/(.*)/\U$1\E\/${2}-${2}/g; } elsif ( $elemento =~ /^SRX/i ) { @@ -1975,22 +1884,22 @@ } elsif ( $elemento =~ /^CAPI\//i ) { - $elemento =~ s/(CAPI\/)(.*)\/.*-(.*)/$1$2-$3/g; - } - - $elemento =~ s/^asyncgoto\///gi; + $elemento =~ s/(CAPI\/)(.*)\/(.*)-(.*)/$1$2-$4/g; + } + $elemento =~ s/(.*)[-\/](.*)/$1\t$2/g; log_debug( "$heading elemento2 $elemento", 32 ) if DEBUG; my $canal = $1; my $sesion = $2; + log_debug( "$heading canal $canal sesion $sesion", 32 ) if DEBUG; if ( defined($canal) && defined($sesion) ) { $canal =~ tr/a-z/A-Z/; $elemento = $canal . "\t" . $sesion; - log_debug( "$heading canal $canal sesion $sesion", 32 ) if DEBUG; } $elemento =~ s/IAX2\[(.*)@(.*)\]\t(.*)/IAX2\[$1\]\t$3/; $elemento =~ s/IAX2\/(.*)@(.*)\t(.*)/IAX2\/$1\t$3/; - return split( /\t/, $elemento ); + my @partes = split( /\t/, $elemento ); + return @partes; } @@ -2017,14 +1926,15 @@ sub erase_instances_for_trunk_buttons { - my $canalid = shift; - my $canal = shift; - my $server = shift; + my $canalid = shift; + my $canal = shift; + my $server = shift; + my $canalidsinserver = ""; my $canalglobal; + my $valor; + my @new = (); my $heading = "** ERASE_INSTANCE_TRUNK"; - my $solocanal = $canalid; - $solocanal =~ s/[^\w]//g; - - $canalid = "$server^$canalid"; + $canalidsinserver = $canalid; + $canalid = "$server^$canalid"; $canalid =~ s/(.*)<(.*)>/$1/g; #discards ZOMBIE or MASQ @@ -2036,6 +1946,16 @@ $canalglobal =~ s/IAX2\[(.*)@(.*)\]/IAX2\[$1\]/g; - my ( undef, $contexto ) = split( /\&/, $canal ); - $contexto = $contexto ? "&$contexto" : ""; + my ( $nada, $contexto ) = split( /\&/, $canal ); + if ( !defined($contexto) ) { $contexto = ""; } + + my $canalconcontexto = ""; + if ( $contexto ne "" ) { + $canalconcontexto = "$canalglobal&$contexto"; + $contexto = "&$contexto"; + } + else { + $canalconcontexto = $canalglobal; + $contexto = ""; + } my $sesiontemp = $canalid; @@ -2043,11 +1963,11 @@ log_debug( "$heading looking for $canalid on instancias to erase it", 128 ) if DEBUG; - if ( $canal =~ m/^DID|^CLID/ ) { - $canal =~ s/(.*)=.*/$1/g; - $canalid = $server . "^" . $canal . "-" . $solocanal; - } - foreach my $key1 ( keys(%instancias) ) { - delete $instancias{$key1}{$canalid}; - log_debug( "$heading Erasing $canalid from instanacias!", 128 ) if DEBUG; + foreach my $key1 ( sort ( keys(%instancias) ) ) { + foreach my $key2 ( sort ( keys( %{ $instancias{$key1} } ) ) ) { + if ( $key2 eq $canalid ) { + delete $instancias{$key1}{$key2}; + log_debug( "$heading Erasing $canalid from instanacias!", 128 ) if DEBUG; + } + } } } @@ -2066,5 +1986,5 @@ } - my ( undef, $contexto1 ) = split( /\&/, $nroboton ); + my ( $nada1, $contexto1 ) = split( /\&/, $nroboton ); if ( !defined($contexto1) ) { $contexto1 = ""; } @@ -2082,5 +2002,5 @@ my @linkbotones = find_panel_buttons( $canal1, $canalsesion, $server ); foreach my $cual (@linkbotones) { - my ( undef, $contexto2 ) = split( /\&/, $cual ); + my ( $nada2, $contexto2 ) = split( /\&/, $cual ); if ( !defined($contexto2) ) { $contexto2 = ""; } if ( $contexto1 eq $contexto2 ) { @@ -2150,5 +2070,4 @@ log_debug( "$heading borro cache_hit($indice_cache)", 128 ) if DEBUG; delete $cache_hit{$indice_cache}; - delete $monitoring{$canalsesion}; if ( keys(%cache_hit) ) { for ( keys %cache_hit ) { @@ -2226,6 +2145,4 @@ log_debug( "** Found a match $canalid=$val ($quehay) - Cleared!", 16 ) if DEBUG; delete $datos{$quehay}; - delete $chanvar{$quehay}; - delete $passvar{$quehay}; } } @@ -2253,5 +2170,6 @@ # Removes the context if its set - ($canal) = split( /&/, $canal ); + my @pedazos = split( /&/, $canal ); + $canal = $pedazos[0]; # Checks if the channel name has an equal sign @@ -2304,8 +2222,11 @@ my $server = ""; - ($canal) = split( /&/, $canal ); + my @pedazos = split( /&/, $canal ); + $canal = $pedazos[0]; if ( $canal =~ /\^/ ) { - ( $server, $canal ) = split( /\^/, $canal ); + @pedazos = split( /\^/, $canal ); + $server = $pedazos[0]; + $canal = $pedazos[1]; } @@ -2344,8 +2265,11 @@ print_datos(1); - ($canal) = split( /&/, $canal ); + my @pedazos = split( /&/, $canal ); + $canal = $pedazos[0]; if ( $canal =~ /\^/ ) { - ( $server, $canal ) = split( /\^/, $canal ); + @pedazos = split( /\^/, $canal ); + $server = $pedazos[0]; + $canal = $pedazos[1]; } @@ -2368,5 +2292,5 @@ $canalaqui = 1; } - if ( $key =~ /^Server/i && ( $val eq $server || $server eq "-1" ) ) { + if ( $key =~ /^Server/i && $val eq $server ) { $serveraqui = 1; log_debug( "$heading server coincide $server = $val\n", 16 ) if DEBUG; @@ -2409,5 +2333,4 @@ my $heading = "** FIND_PANEL_BUT"; my $calleridnum = "noexiste"; - my $didnum = "noexiste"; my %trunk_matched = (); @@ -2421,13 +2344,7 @@ my $uniqueid = find_uniqueid( $canalsesion, $server ); - if ($uniqueid) { - if ( defined( $datos{$uniqueid}{CallerID} ) ) { - $calleridnum = $datos{$uniqueid}{CallerID}; - } - if ( defined( $datos{$uniqueid}{Extension} ) - && defined( $datos{$uniqueid}{AppData} ) - && $datos{$uniqueid}{AppData} =~ m/^FROM_DID/ ) - { - $didnum = $datos{$uniqueid}{"Extension"}; + if ( $uniqueid ne "" ) { + if ( defined( $datos{$uniqueid}{"CallerID"} ) ) { + $calleridnum = $datos{$uniqueid}{"CallerID"}; } } @@ -2533,5 +2450,5 @@ if ( uc($key) eq "$server^$canalsinlocal" ) { my $canalfin = $val; - $canalfin =~ s/-?\d+\^(.*)/$1/g; + $canalfin =~ s/\d+\^(.*)/$1/g; push @multicanal, $canalfin; } @@ -2547,10 +2464,10 @@ # Attemp to match a button from cache $indice_cache = $canalsesion . "-" . $canal . "-" . $server; - if ( !defined( $cache_hit{$indice_cache} ) || $didnum ne "noexiste" ) { + if ( !defined( $cache_hit{$indice_cache} ) ) { log_debug( "$heading CACHE MISS $indice_cache", 32 ) if DEBUG; for ( keys %buttons ) { $server = $server_original; $canalfinal = ""; - my ( undef, $contexto ) = split( "\&", $_ ); + my ( $nada, $contexto ) = split( "\&", $_ ); if ( !defined($contexto) ) { $contexto = ""; } if ( $contexto ne "" ) { $contexto = "&" . $contexto; } @@ -2580,37 +2497,8 @@ } } - elsif ( $_ =~ /^$server\^CLID\/\Q$calleridnum\E=/ ) { - my $solocanal = $canalsesion; - $solocanal =~ s/[^\w]//g; - my $tcanal = "CLID/" . $calleridnum . "-" . $solocanal; - if ( !exists( $trunk_matched{"$server^CLID/$calleridnum"} ) ) { - $canalfinal = get_next_trunk_button( $tcanal, $contexto, $server, $tcanal ); - if ( $canalfinal ne "" ) { - log_debug( "$heading clid match trunk ( $_ ) $canal $contexto", 32 ) if DEBUG; - $trunk_matched{"$server^CLID/$calleridnum"} = 1; - $canalfinal =~ s/(.*)\^(.*)/$2/g; - } - } - } elsif ( $_ =~ /^$server\^CLID\/\Q$calleridnum\E\&?/ ) { + log_debug( "$heading clid match ( $_ ) $canal $contexto", 32 ) if DEBUG; $canalfinal = "CLID/$calleridnum"; - } - elsif ( $_ =~ /^$server\^DID\/\Q$didnum\E=/ ) { - my $solocanal = $canalsesion; - $solocanal =~ s/[^\w]//g; - my $tcanal = "DID/" . $didnum . "-" . $solocanal; - if ( !exists( $trunk_matched{"$server^DID/$didnum"} ) ) { - $canalfinal = get_next_trunk_button( $tcanal, $contexto, $server, $tcanal ); - if ( $canalfinal ne "" ) { - log_debug( "$heading did match trunk ( $_ ) $canal $contexto", 32 ) if DEBUG; - $trunk_matched{"$server^DID/$didnum"} = 1; - $canalfinal =~ s/(.*)\^(.*)/$2/g; - } - } - } - elsif ( $_ =~ /^$server\^DID\/\Q$didnum\E\&?/ ) { - log_debug( "$heading did match ( $_ ) $canal $contexto", 32 ) if DEBUG; - $canalfinal = "DID/$didnum"; } @@ -2640,8 +2528,9 @@ $canalfinal = ""; + my $nada1 = ""; my $contextemp = ""; my %contextosencontrados; for my $val (@canales) { - ( undef, $contextemp ) = split( "&", $val ); + ( $nada1, $contextemp ) = split( "&", $val ); if ( !defined($contextemp) ) { $contextemp = ""; } $contextosencontrados{"&$contextemp"} = 1; @@ -2757,5 +2646,5 @@ while ( my ( $key, $val ) = each(%bloque) ) { if ( defined($val) ) { - $val =~ s/\s+$//; + $val =~ s/(.*)\s+$/$1/g; } else { @@ -2765,17 +2654,4 @@ } - if ( defined( $hash_temporal{Application} ) ) { - - # Chanvar hash stores the complete list of channel variables - # that are "SET" in the dialplan for a given Uniqueid - if ( $hash_temporal{Application} eq "Set" ) { - my @vardata = split( /\|/, $hash_temporal{AppData} ); - foreach my $vara (@vardata) { - my ( $vari, $valu ) = split( /=/, $vara ); - $vari =~ s/^_.?//g; - $chanvar{ $hash_temporal{Uniqueid} }{$vari} = $valu; - } - } - } if ( defined( $hash_temporal{Channel} ) ) { if ( $hash_temporal{Channel} =~ /^Agent/ ) { @@ -2817,10 +2693,8 @@ while ( my ( $key, $val ) = each(%hash_temporal) ) { if ( defined($val) && $val =~ /\^/ ) { - - #my @partes = split( /\^/, $val, 2 ); - #$hash_temporal{$key} = $partes[0]; - #my $resto_de_parametros = $partes[1]; - ( $hash_temporal{$key}, my $resto ) = split( /\^/, $val, 2 ); - my @partes = split( /\^/, $resto ); + my @partes = split( /\^/, $val, 2 ); + $hash_temporal{$key} = $partes[0]; + my $resto_de_parametros = $partes[1]; + @partes = split( /\^/, $resto_de_parametros ); foreach my $value (@partes) { my @partes2 = split( /: /, $value ); @@ -2833,29 +2707,14 @@ } - # Asterisk 1.6 to 1.4 translations - if ( defined( $hash_temporal{BridgedChannel} ) ) { - $hash_temporal{Link} = $hash_temporal{BridgedChannel}; - } - if ( defined( $hash_temporal{ChannelStateDesc} ) ) { - $hash_temporal{State} = $hash_temporal{ChannelStateDesc}; - } - if ( defined( $hash_temporal{CallerIDNum} ) ) { - $hash_temporal{CallerID} = $hash_temporal{CallerIDNum}; - } - if ( $hash_temporal{Event} eq "Bridge" ) { - $hash_temporal{Event} = "Link"; - } - - # ******************************** $canalid = ""; - $canalid = $hash_temporal{Channel} - if defined( $hash_temporal{Channel} ); + $canalid = $hash_temporal{"Channel"} + if defined( $hash_temporal{"Channel"} ); $server = 0; - $server = $hash_temporal{Server} - if defined( $hash_temporal{Server} ); - - if ( defined( $hash_temporal{Uniqueid} ) ) { - $unico_id = $hash_temporal{Uniqueid}; + $server = $hash_temporal{"Server"} + if defined( $hash_temporal{"Server"} ); + + if ( defined( $hash_temporal{"Uniqueid"} ) ) { + $unico_id = $hash_temporal{"Uniqueid"}; if ( $hash_temporal{Event} !~ /^Originate/ ) { $fill_datos = 1; @@ -2869,14 +2728,14 @@ if ( exists( $datos{$unico_id} ) ) { - if ( exists( $datos{$unico_id}{Link} ) ) { - $enlazado = $datos{$unico_id}{Link}; - } - - if ( exists( $datos{$unico_id}{Application} ) ) { - $enlazado .= " - " . $datos{$unico_id}{Application}; - } - - if ( exists( $datos{$unico_id}{AppData} ) ) { - $enlazado .= ":" . $datos{$unico_id}{AppData}; + if ( exists( $datos{$unico_id}{"Link"} ) ) { + $enlazado = $datos{$unico_id}{"Link"}; + } + + if ( exists( $datos{$unico_id}{"Application"} ) ) { + $enlazado .= " - " . $datos{$unico_id}{"Application"}; + } + + if ( exists( $datos{$unico_id}{"AppData"} ) ) { + $enlazado .= ":" . $datos{$unico_id}{"AppData"}; } @@ -2897,5 +2756,7 @@ if ( defined( $hash_temporal{"ActionID"} ) ) { if ( $hash_temporal{"ActionID"} =~ /^timeout/i ) { - ( $canalid, $timeout ) = split( /\|/, $hash_temporal{"ActionID"} ); + my @partes = split( /\|/, $hash_temporal{"ActionID"} ); + $canalid = $partes[1]; + $timeout = $partes[2]; $evento = "Timeout"; $unico_id = "YYYY-$server"; @@ -2913,5 +2774,5 @@ if ($fill_datos) { # Ignores blocks without Uniqueid log_debug( "$heading LLENANDO el global datos $unico_id", 64 ) if DEBUG; - delete $datos{$unico_id}{State}; + delete $datos{$unico_id}{"State"}; while ( my ( $key, $val ) = each(%hash_temporal) ) { if ( $key eq "Uniqueid" ) { @@ -2933,88 +2794,61 @@ } - # Convert Asterisk 1.4 Originate responses to 1.2 format so attendant transfers work - if ( $evento eq "OriginateResponse" ) { - if ( $hash_temporal{Response} eq "Success" ) { - $evento = "OriginateSuccess"; - } - else { - $evento = "OriginateFailure"; - } - } - - # Convert Asterisk 1.4 ParkedCalltimeout to UnParkedCall - if ( $evento eq "ParkedCallTimeOut" ) { - $evento = "UnParkedCall"; - } - $evento =~ s/UserEvent//g; - if ( $evento =~ /Newchannel/ ) { $evento = "newchannel"; } - elsif ( $evento =~ /Newcallerid/ ) { $evento = "newcallerid"; } - elsif ( $evento =~ /^Status$/ ) { $evento = "status"; } - elsif ( $evento =~ /^StatusComplete/ ) { $evento = "statuscomplete"; } - elsif ( $evento =~ /Newexten/ ) { $evento = "newexten"; } - elsif ( $evento =~ /^ParkedCall$/ ) { $evento = "parkedcall"; } - elsif ( $evento =~ /^UnParkedCall$/ ) { $evento = "unparkedcall"; } - elsif ( $evento =~ /^virtualvaletparkedcall/i ) { $evento = "parkedcall"; } - elsif ( $evento =~ /^virtualvaletunparkedcall$/i ) { $evento = "unparkedcall"; } - elsif ( $evento =~ /Newstate/ ) { $evento = "newstate"; } - elsif ( $evento =~ /Hangup/ ) { $evento = "hangup"; } - elsif ( $evento =~ /Rename/ ) { $evento = "rename"; } - elsif ( $evento =~ /MessageWaiting/ ) { $evento = "voicemail"; } - elsif ( $evento =~ /Regstatus/ ) { $evento = "regstatus"; } - elsif ( $evento =~ /^Unlink/ ) { $evento = "unlink"; } - elsif ( $evento =~ /QueueParams/ ) { $evento = "queueparams"; } - elsif ( $evento =~ /PeerEntry/ ) { $evento = "peerentry"; } - elsif ( $evento =~ /QueueEntry/ ) { $evento = "queueentry"; } - elsif ( $evento =~ /^QueueMember$/ ) { $evento = "queuemember"; } - elsif ( $evento =~ /^QueueMemberStatus$/ ) { $evento = "queuememberstatus"; } - elsif ( $evento =~ /QueueMemberAdded/ ) { $evento = "queuememberadded"; } - elsif ( $evento =~ /QueueMemberRemoved/ ) { $evento = "queuememberremoved"; } - elsif ( $evento =~ /QueueMemberPaused/ ) { $evento = "queuememberpaused"; } - elsif ( $evento =~ /QueueStatus$/ ) { $evento = "queuestatus"; } - elsif ( $evento =~ /QueueStatusComplete/ ) { $evento = "queuestatuscomplete"; } - elsif ( $evento =~ /^Link/ ) { $evento = "link"; } - elsif ( $evento =~ /^Join/ ) { $evento = "join"; } - elsif ( $evento =~ /^MeetmeJoin/ ) { $evento = "meetmejoin"; } - elsif ( $evento =~ /^MeetmeLeave/ ) { $evento = "meetmeleave"; } - elsif ( $evento =~ /^meetmemute/ ) { $evento = "meetmemute"; } - elsif ( $evento =~ /^meetmeunmute/ ) { $evento = "meetmeunmute"; } - elsif ( $evento =~ /^Agentlogin/ ) { $evento = "agentlogin"; } - elsif ( $evento =~ /^Agents$/ ) { $evento = "agents"; } - elsif ( $evento =~ /^RefreshQueue/ ) { $evento = "refreshqueue"; } - elsif ( $evento =~ /^Timeout/ ) { $evento = "timeout"; } - elsif ( $evento =~ /^AgentCalled/ ) { $evento = "agentcalled"; } - elsif ( $evento =~ /^AgentConnect/ ) { $evento = "agentconnect"; } - elsif ( $evento =~ /^AgentComplete/ ) { $evento = "agentcomplete"; } - elsif ( $evento =~ /^Agentcallbacklogin/ ) { $evento = "agentcblogin"; } - elsif ( $evento =~ /^Agentcallbacklogoff/ ) { $evento = "agentlogoff"; } - elsif ( $evento =~ /^Agentlogoff/ ) { $evento = "agentlogoff"; } - elsif ( $evento =~ /^IsMeetmeMember/ ) { $evento = "fakeismeetmemember"; } - elsif ( $evento =~ /^PeerStatus/ ) { $evento = "peerstatus"; } - elsif ( $evento =~ /^Leave/ ) { $evento = "leave"; } - elsif ( $evento =~ /^FOP_Popup/i ) { $evento = "foppopup"; } - elsif ( $evento =~ /^FOP_LedColor/i ) { $evento = "fopledcolor"; } - elsif ( $evento =~ /^Dial/ ) { $evento = "dial"; } - elsif ( $evento =~ /^ASTDB/ ) { $evento = "astdb"; } - elsif ( $evento =~ /^DNDState/ ) { $evento = "zapdndstate"; } - elsif ( $evento =~ /^ZapShowChannels$/ ) { $evento = "zapdndstate"; } - elsif ( $evento =~ /^ExtensionStatus$/ ) { $evento = "extensionstatus"; } - elsif ( $evento =~ /^OriginateSuccess$/ ) { $evento = "originatesuccess"; } - elsif ( $evento =~ /^OriginateFailure$/ ) { $evento = "originatefailure"; } - elsif ( $evento =~ /^ChannelReload$/ ) { $evento = "channelreload"; } - elsif ( $evento =~ /^Hold$/ ) { $evento = "hold"; } - elsif ( $evento =~ /^Unhold$/ ) { $evento = "unhold"; } - elsif ( $evento =~ /^response-/ ) { $evento = "monitor"; } + if ( $evento =~ /Newchannel/ ) { $evento = "newchannel"; } + elsif ( $evento =~ /Newcallerid/ ) { $evento = "newcallerid"; } + elsif ( $evento =~ /^Status$/ ) { $evento = "status"; } + elsif ( $evento =~ /^StatusComplete/ ) { $evento = "statuscomplete"; } + elsif ( $evento =~ /Newexten/ ) { $evento = "newexten"; } + elsif ( $evento =~ /^ParkedCall$/ ) { $evento = "parkedcall"; } + elsif ( $evento =~ /^UnParkedCall$/ ) { $evento = "unparkedcall"; } + elsif ( $evento =~ /Newstate/ ) { $evento = "newstate"; } + elsif ( $evento =~ /Hangup/ ) { $evento = "hangup"; } + elsif ( $evento =~ /Rename/ ) { $evento = "rename"; } + elsif ( $evento =~ /MessageWaiting/ ) { $evento = "voicemail"; } + elsif ( $evento =~ /Regstatus/ ) { $evento = "regstatus"; } + elsif ( $evento =~ /^Unlink/ ) { $evento = "unlink"; } + elsif ( $evento =~ /QueueParams/ ) { $evento = "queueparams"; } + elsif ( $evento =~ /PeerEntry/ ) { $evento = "peerentry"; } + elsif ( $evento =~ /QueueEntry/ ) { $evento = "queueentry"; } + elsif ( $evento =~ /^QueueMember$/ ) { $evento = "queuemember"; } + elsif ( $evento =~ /^QueueMemberStatus$/ ) { $evento = "queuememberstatus"; } + elsif ( $evento =~ /QueueMemberAdded/ ) { $evento = "queuememberadded"; } + elsif ( $evento =~ /QueueMemberRemoved/ ) { $evento = "queuememberremoved"; } + elsif ( $evento =~ /QueueMemberPaused/ ) { $evento = "queuememberpaused"; } + elsif ( $evento =~ /QueueStatus$/ ) { $evento = "queuestatus"; } + elsif ( $evento =~ /QueueStatusComplete/ ) { $evento = "queuestatuscomplete"; } + elsif ( $evento =~ /^Link/ ) { $evento = "link"; } + elsif ( $evento =~ /^Join/ ) { $evento = "join"; } + elsif ( $evento =~ /^MeetmeJoin/ ) { $evento = "meetmejoin"; } + elsif ( $evento =~ /^MeetmeLeave/ ) { $evento = "meetmeleave"; } + elsif ( $evento =~ /^meetmemute/ ) { $evento = "meetmemute"; } + elsif ( $evento =~ /^meetmeunmute/ ) { $evento = "meetmeunmute"; } + elsif ( $evento =~ /^Agentlogin/ ) { $evento = "agentlogin"; } + elsif ( $evento =~ /^RefreshQueue/ ) { $evento = "refreshqueue"; } + elsif ( $evento =~ /^Timeout/ ) { $evento = "timeout"; } + elsif ( $evento =~ /^AgentCalled/ ) { $evento = "agentcalled"; } + elsif ( $evento =~ /^AgentConnect/ ) { $evento = "agentconnect"; } + elsif ( $evento =~ /^AgentComplete/ ) { $evento = "agentcomplete"; } + elsif ( $evento =~ /^Agentcallbacklogin/ ) { $evento = "agentcblogin"; } + elsif ( $evento =~ /^Agentcallbacklogoff/ ) { $evento = "agentlogoff"; } + elsif ( $evento =~ /^Agentlogoff/ ) { $evento = "agentlogoff"; } + elsif ( $evento =~ /^IsMeetmeMember/ ) { $evento = "fakeismeetmemember"; } + elsif ( $evento =~ /^PeerStatus/ ) { $evento = "peerstatus"; } + elsif ( $evento =~ /^Leave/ ) { $evento = "leave"; } + elsif ( $evento =~ /^FOP_Popup/i ) { $evento = "foppopup"; } + elsif ( $evento =~ /^FOP_LedColor/i ) { $evento = "fopledcolor"; } + elsif ( $evento =~ /^Dial/ ) { $evento = "dial"; } + elsif ( $evento =~ /^ASTDB/ ) { $evento = "astdb"; } + elsif ( $evento =~ /^DNDState/ ) { $evento = "zapdndstate"; } + elsif ( $evento =~ /^ZapShowChannels$/ ) { $evento = "zapdndstate"; } + elsif ( $evento =~ /^ExtensionStatus$/ ) { $evento = "extensionstatus"; } + elsif ( $evento =~ /^OriginateSuccess$/ ) { $evento = "originatesuccess"; } + elsif ( $evento =~ /^OriginateFailure$/ ) { $evento = "originatefailure"; } + elsif ( $evento =~ /^ChannelReload$/ ) { $evento = "channelreload"; } else { log_debug( "$heading No event match ($evento)", 32 ); } - if ( defined( $hash_temporal{Link} ) ) { - if ( defined( $hash_temporal{Seconds} ) ) { - my $unid = ""; - if ( defined( $hash_temporal{BridgedUniqueid} ) ) { - $unid = $hash_temporal{BridgedUniqueid}; - } - else { - $unid = find_uniqueid( $hash_temporal{Link}, $server ); - } + if ( defined( $hash_temporal{"Link"} ) ) { + if ( defined( $hash_temporal{"Seconds"} ) ) { + my $unid = find_uniqueid( $hash_temporal{"Link"}, $server ) if DEBUG; $fake_bloque[$fakecounter]{Event} = "Newexten"; $fake_bloque[$fakecounter]{Channel} = $hash_temporal{Link}; @@ -3030,12 +2864,5 @@ } - if ( $evento eq "monitor" ) { - my $botinro = ""; - ( undef, $estado_final, undef ) = split( /-/, $hash_temporal{ActionID}, 3 ); - ( $canal, undef ) = separate_session_from_channel( $hash_temporal{Channel} ); - $canalid = $hash_temporal{Channel}; - $estado_final =~ tr/A-Z/a-z/; - } - elsif ( $evento eq "channelreload" ) { + if ( $evento eq "channelreload" ) { # Event: ChannelReload @@ -3059,6 +2886,5 @@ my $indice = $hash_temporal{Uniqueid} . "-" . $hash_temporal{Server}; if ( exists( $datos{"$indice"} ) ) { - log_debug( "** ATTENDANT we had that uniqueid before, extract the channel from there", 16 ) - if DEBUG; + log_debug( "** ATTENDANT we had that uniqueid before, extract the channel from there", 16 ) if DEBUG; if ( defined( $datos{$indice}{Extension} ) ) { @@ -3073,6 +2899,5 @@ } else { - log_debug( "** ATTENDANT we do not have any event with that uniqueid, save for later", 16 ) - if DEBUG; + log_debug( "** ATTENDANT we do not have any event with that uniqueid, save for later", 16 ) if DEBUG; print_datos(99); $pending_uniqueid_attendant{ $hash_temporal{Uniqueid} } = $hash_temporal{Exten} . "@" . $hash_temporal{Context}; @@ -3081,4 +2906,5 @@ } $evento = ""; + } elsif ( $evento eq "originatefailure" ) { @@ -3091,5 +2917,5 @@ my $ext_transf = $extension_transfer{"$server^$canal"}; - $ext_transf =~ s/-?\d+\^(.*)/$1/g; + $ext_transf =~ s/\d+\^(.*)/$1/g; my @part_ext = split( /\@/, $ext_transf ); @@ -3116,13 +2942,10 @@ } - if (DEBUG) { - while ( ( $key, $val ) = each(%mute_other) ) { - log_debug( "Mute other after originate failure: $key = $val", 16 ); - } - while ( ( $key, $val ) = each(%pending_uniqueid_attendant) ) { - log_debug( "Pending uniqueid attendant after originate failure: $key = $val", 16 ); - } - } - + while ( ( $key, $val ) = each(%mute_other) ) { + log_debug( "Mute other after originate failure: $key = $val", 16 ) if DEBUG; + } + while ( ( $key, $val ) = each(%pending_uniqueid_attendant) ) { + log_debug( "Pending uniqueid attendant after originate failure: $key = $val", 16 ) if DEBUG; + } my $tempval = $config->{$contexto}{'attendant_failure_redirect_to'}; $tempval =~ s/\${CHANNEL}/$hash_temporal{Channel}/g; @@ -3131,5 +2954,7 @@ if ( $tempval =~ m/\@/ ) { - ( $dst_exten, $dst_context ) = split( /\@/, $tempval, 2 ); + my @partes = split( /\@/, $tempval, 2 ); + $dst_exten = $partes[0]; + $dst_context = $partes[1]; } else { @@ -3165,4 +2990,17 @@ } + elsif ( $evento eq "newexten" ) { + + if ( exists( $pending_uniqueid_attendant{ $hash_temporal{Uniqueid} } ) ) { + + # This was from an originatesuccess for attendant transfers + # so remove the hash element and add it to attendant_pending hash + # that is used for look for hangups and perform redirects + + $attendant_pending{ $hash_temporal{Channel} } = $pending_uniqueid_attendant{ $hash_temporal{Uniqueid} }; + delete $pending_uniqueid_attendant{ $hash_temporal{Uniqueid} }; + log_debug( "Save " . $hash_temporal{Channel} . " as pending", 16 ) if DEBUG; + } + } elsif ( $evento eq "agentcomplete" ) { @@ -3176,5 +3014,5 @@ #TalkTime: 557 #Reason: agent - my ( $canal, undef ) = separate_session_from_channel( $hash_temporal{Channel} ); + my ( $canal, $nada ) = separate_session_from_channel( $hash_temporal{Channel} ); request_queue_status( $socket, $canal ); my @respuestas = set_queueobject( $server, $canal, "status", 1 ); @@ -3182,4 +3020,5 @@ push @return, $_; } + } elsif ( $evento eq "PeerlistComplete" ) { @@ -3213,4 +3052,5 @@ $autosip_detail{"autosipentry-$cnt_autosip"} = 1; send_reload_to_flash(); + } elsif ( $evento eq "sippeerentrylong" ) { @@ -3242,6 +3082,6 @@ my $cnt = 0; - foreach my $auto (@auto_config) { - my %tmphash = %$auto; + foreach (@auto_config) { + my %tmphash = %$_; if ( !defined( $tmphash{server} ) ) { $tmphash{server} = 1; } my $srv = $tmphash{server}; @@ -3308,4 +3148,5 @@ $autosip{"$server^$peer"}{server} = $server; } + } elsif ( $evento eq "agentcalled" ) { @@ -3314,7 +3155,5 @@ $estado_final = "ringing"; $canal = $hash_temporal{"AgentCalled"}; - my $unique = find_uniqueid( $hash_temporal{ChannelCalling}, $server ); - $unique =~ s/(.*)-.*/$1/g; - $canal =~ tr/a-z/A-Z/; + $canal =~ tr/a-z/A-Z/; $canalid = $canal . "-XXXX"; $clidnum = $hash_temporal{"CallerID"}; @@ -3323,15 +3162,9 @@ my $base64_clidnum = encode_base64( $clidnum . " " ); my $base64_clidname = encode_base64( $clidname . " " ); - - foreach my $var ( split( /\|/, $passvars ) ) { - if ( defined( $chanvar{$unique}{$var} ) ) { - my $base64_var = encode_base64( $chanvar{$unique}{$var} ); - push @return, "$canal|setvar|$var=$base64_var|$canalid-$server|$canalid"; - } - } push @return, "$canal|clidnum|$base64_clidnum|$canalid-$server|$canalid"; push @return, "$canal|clidname|$base64_clidname|$canalid-$server|$canalid"; push @return, "$canal|$estado_final|$texto|$canalid-$server|$canalid"; $evento = ""; + } elsif ( $evento eq "agentconnect" ) { @@ -3354,43 +3187,17 @@ $evento = ""; + } elsif ( $evento eq "dial" ) { - # try to comply with both AMI 1.0 and AMI 1.1 (* 1.6) where some messages changed, see Asterisk Documentation 1.6.0 manager_1_1.txt - # Maybe we should better check the bannner, which is either 'Asterisk Call Manager/1.0' or 'Asterisk Call Manager/1.1' - my $label_Channel; - my $label_UniqueID; - my $label_dest; - if ( defined $hash_temporal{Source} ) { - # AMI 1.0 - $label_Channel = 'Source'; - $label_UniqueID = 'SrcUniqueID'; - $label_dest = $hash_temporal{'Destination'}; - } else { - # AMI 1.1 - $label_Channel = 'Channel'; - $label_UniqueID = 'UniqueID'; - $canal = $hash_temporal{"Channel"}; - $canal =~ tr/a-z/A-Z/; - $canalid = $canal . "-XXXX"; - $label_dest = $canalid; - } - # We use this hashes to store the remote callerid for CVS-HEAD - my $key = "$server^$label_dest"; + my $key = "$server^$hash_temporal{'Destination'}"; my $dorigen = ""; my $ddestino = ""; + my $dnada = ""; $remote_callerid{$key} = $hash_temporal{"CallerID"}; $remote_callerid_name{$key} = $hash_temporal{"CallerIDName"}; - foreach my $var ( split( /\|/, $passvars ) ) { - if ( defined( $chanvar{ $hash_temporal{"$label_UniqueID"} }{$var} ) ) { - $passvar{ $hash_temporal{"DestUniqueID"} }{$var} = $chanvar{ $hash_temporal{"$label_UniqueID"} }{$var}; - } - } - - $datos{"$hash_temporal{$label_UniqueID}-$server"}{'Origin'} = "true"; - - if ( $hash_temporal{$label_Channel} =~ m/^Local/i ) { + if ( $hash_temporal{'Source'} =~ m/^Local/i ) { # We also look for Dial from Local/XX@context to TECH/XX for @@ -3398,11 +3205,11 @@ # so we can map outgoing calls to Agent buttons # It will only work after the agent receives at least one call - ( $dorigen, undef ) = separate_session_from_channel( $hash_temporal{$label_Channel} ); - ( $ddestino, undef ) = separate_session_from_channel( $hash_temporal{'Destination'} ) if defined($hash_temporal{'Destination'}); + ( $dorigen, $dnada ) = separate_session_from_channel( $hash_temporal{'Source'} ); + ( $ddestino, $dnada ) = separate_session_from_channel( $hash_temporal{'Destination'} ); if ( exists( $channel_to_agent{"$server^$dorigen"} ) ) { my $agente = $channel_to_agent{"$server^$dorigen"}; # delete $channel_to_agent{$dorigen}; - $channel_to_agent{"$server^$ddestino"} = $agente if $ddestino; + $channel_to_agent{"$server^$ddestino"} = $agente; } } @@ -3442,5 +3249,5 @@ my $valor = ""; $estado_final = "astdb"; - ( $canal, undef ) = separate_session_from_channel( $hash_temporal{"Channel"} ); + ( $canal, my $nada ) = separate_session_from_channel( $hash_temporal{"Channel"} ); $canalid = $hash_temporal{"Channel"} . "-XXXX"; my $clave = $hash_temporal{"Family"}; @@ -3475,5 +3282,6 @@ $evento = ""; } - elsif ( $evento eq "timeout" ) { + + if ( $evento eq "timeout" ) { $estado_final = "timeout"; $texto = $timeout; @@ -3485,10 +3293,11 @@ $evento = ""; } - elsif ( $evento eq "regstatus" ) { + + if ( $evento eq "regstatus" ) { # Sends the IP address of the peer to the flash client # XXXX It will have to store this value internally in future version # to avoid polling asterisk every time - ( $canal, undef ) = separate_session_from_channel( $hash_temporal{"Channel"} ); + ( $canal, my $nada ) = separate_session_from_channel( $hash_temporal{"Channel"} ); $texto = $hash_temporal{"IP"}; my $serv = $hash_temporal{"Server"}; @@ -3503,16 +3312,18 @@ } } - elsif ( $evento eq "fopledcolor" ) { + + if ( $evento eq "fopledcolor" ) { my $color = ""; my $state = ""; - ( $canal, undef ) = separate_session_from_channel( $hash_temporal{"Channel"} ); - $color = $hash_temporal{Color}; - $state = $hash_temporal{State}; + ( $canal, my $nada ) = separate_session_from_channel( $hash_temporal{"Channel"} ); + $color = $hash_temporal{"Color"}; + $state = $hash_temporal{"State"}; $estado_final = "fopledcolor"; push @return, "$canal|$estado_final|$color^$state|$unico_id|$canalid"; $evento = ""; } - elsif ( $evento eq "foppopup" ) { - ( $canal, undef ) = separate_session_from_channel( $hash_temporal{"Channel"} ); + + if ( $evento eq "foppopup" ) { + ( $canal, my $nada ) = separate_session_from_channel( $hash_temporal{"Channel"} ); my $url = $hash_temporal{"URL"}; my $target = $hash_temporal{"Target"}; @@ -3524,6 +3335,7 @@ $evento = ""; } - elsif ( $evento eq "refreshqueue" ) { - ( $canal, undef ) = separate_session_from_channel( $hash_temporal{"Channel"} ); + + if ( $evento eq "refreshqueue" ) { + ( $canal, my $nada ) = separate_session_from_channel( $hash_temporal{"Channel"} ); # Turns off led of the agent that generated the refresh @@ -3535,5 +3347,6 @@ $evento = ""; } - elsif ( $evento eq "agentcblogin" ) { + + if ( $evento eq "agentcblogin" ) { my $canal = ""; my $canallocal = ""; @@ -3575,5 +3388,5 @@ # so we populate some internal structures. If not, its a fake # callbacklogin from the show agents cli command - ( $canal, undef ) = separate_session_from_channel( $datos{$unico_id}{Channel} ); + ( $canal, my $nada ) = separate_session_from_channel( $datos{$unico_id}{Channel} ); $canal =~ tr/a-z/A-Z/; } @@ -3595,7 +3408,8 @@ # in op_buttons.cfg. $canal = $extension_transfer_reverse{$ext_transf_key}; - ( $canal, undef ) = split( /&/, $canal ); + $canal =~ s/(.*)&(.*)/$1/g; if ( $canal =~ /\^/ ) { - ( undef, $canal ) = split( /\^/, $canal ); + my @pedacete = split( /\^/, $canal ); + $canal = $pedacete[1]; } } @@ -3651,5 +3465,6 @@ $evento = ""; } - elsif ( $evento eq "queuememberpaused" && $agent_status == 1 ) { + + if ( $evento eq "queuememberpaused" && $agent_status == 1 ) { my $canal = $hash_temporal{Location}; my $canalid = $canal . "-XXXX"; @@ -3700,5 +3515,6 @@ } - elsif ( $evento eq "queuememberremoved" ) { + + if ( $evento eq "queuememberremoved" ) { my $colar = $hash_temporal{Queue}; my $canal = $hash_temporal{Location}; @@ -3717,5 +3533,6 @@ $evento = ""; } - elsif ( $evento eq "queuememberadded" ) { + + if ( $evento eq "queuememberadded" ) { my $colar = $hash_temporal{Queue}; @@ -3748,57 +3565,6 @@ } - elsif ( $evento eq "agents" ) { - - #Event: Agents - #Agent: 609 - #Name: Nicolas - #Status: AGENT_LOGGEDOFF - #LoggedInChan: n/a - #LoggedInTime: 0 - #TalkingTo: n/a - my $agent_number = $hash_temporal{Agent}; - my $agent_name = $hash_temporal{Name}; - my $agent_status = $hash_temporal{Status}; - my $agent_logchan = $hash_temporal{LoggedInChan}; - - $agents_name{"$server^$agent_number"} = $agent_name; - set_queueobject( $server, "AGENT/$agent_number", "name", $agent_name ); - - if ( $agent_status eq "AGENT_IDLE" ) { - - # Agent callback login, idle - my $agevent = ""; - if ( $agent_logchan =~ /.*\/.*-.*/ ) { - $fake_bloque[$fakecounter]{"Event"} = "Agentlogin"; - $fake_bloque[$fakecounter]{"Channel"} = $agent_logchan; - } - else { - $fake_bloque[$fakecounter]{"Event"} = "Agentcallbacklogin"; - $fake_bloque[$fakecounter]{"Loginchan"} = $agent_logchan; - } - $fake_bloque[$fakecounter]{"Agent"} = $agent_number; - $fake_bloque[$fakecounter]{"Name"} = $agent_name; - $fake_bloque[$fakecounter]{"Server"} = "$server"; - $fakecounter++; - } - elsif ( $agent_status eq "AGENT_ONCALL" ) { - - # Agent login - $fake_bloque[$fakecounter]{Event} = "Agentlogin"; - $fake_bloque[$fakecounter]{Channel} = $agent_logchan; - $fake_bloque[$fakecounter]{Agent} = $agent_number; - $fake_bloque[$fakecounter]{Server} = $server; - $fakecounter++; - } - elsif ( $agent_status eq "AGENT_LOGEDOFF" ) { - $fake_bloque[$fakecounter]{Event} = "Agentlogoff"; - $fake_bloque[$fakecounter]{Agent} = $agent_number; - $fake_bloque[$fakecounter]{Server} = $server; - $fake_bloque[$fakecounter]{Fake} = 1; - $fakecounter++; - } - - } - elsif ( $evento eq "agentlogin" ) { + + if ( $evento eq "agentlogin" ) { my $labeltext = "."; @@ -3808,10 +3574,9 @@ # This catches a live real Agentlogin event - ( my $canalreal, undef ) = separate_session_from_channel( $datos{$unico_id}{Channel} ); + ( my $canalreal, my $nada ) = separate_session_from_channel( $datos{$unico_id}{Channel} ); $canalreal =~ tr/a-z/A-Z/; $channel_to_agent{"$server^$canalreal"} = "Agent/$texto"; $agent_to_channel{"$server^Agent/$texto"} = $canalreal; - log_debug( "channel_to_agent($server^$canalreal) = " . $channel_to_agent{"$server^$canalreal"}, 64 ) - if DEBUG; + log_debug( "channel_to_agent($server^$canalreal) = " . $channel_to_agent{"$server^$canalreal"}, 64 ) if DEBUG; if ( !defined( $hash_temporal{Fake} ) || $hash_temporal{Fake} ne "init" ) { my @respuestas = set_queueobject( $server, "AGENT/$texto", "status", 1 ); @@ -3953,5 +3718,6 @@ } } - elsif ( $evento eq "agentlogoff" ) { + + if ( $evento eq "agentlogoff" ) { $canal = "Agent/" . $hash_temporal{Agent}; @@ -3973,7 +3739,5 @@ $estado_final = "changelabel" . $change_led; - if ( defined( $agent_to_channel{"$server^Agent/$canal"} ) - || defined( $channel_to_agent{"$server^$canal"} ) ) - { + if ( defined( $agent_to_channel{"$server^Agent/$canal"} ) || defined( $channel_to_agent{"$server^$canal"} ) ) { if ( defined( $agent_to_channel{"$server^Agent/$canal"} ) ) { $canal = $agent_to_channel{"$server^Agent/$canal"}; @@ -4047,7 +3811,5 @@ if ( defined( $hash_temporal{Queue} ) ) { $valor = $hash_temporal{Queue}; - if ( exists( $agents_available_on_queue{"$server^$valor"} ) - && $agents_available_on_queue{"$server^$valor"} ne "" ) - { + if ( exists( $agents_available_on_queue{"$server^$valor"} ) && $agents_available_on_queue{"$server^$valor"} ne "" ) { my $texto3 = ""; foreach my $qmem ( @{ $agents_available_on_queue{"$server^$valor"} } ) { @@ -4064,5 +3826,6 @@ } - elsif ( $evento eq "queueentry" ) { + + if ( $evento eq "queueentry" ) { if ( defined( $max_queue_waiting_time_for{"$hash_temporal{Queue}-$hash_temporal{Server}"} ) ) { @@ -4088,5 +3851,6 @@ $fakecounter++; } - elsif ( $evento eq "queuestatuscomplete" ) { + + if ( $evento eq "queuestatuscomplete" ) { for my $cola_server ( keys %max_queue_waiting_time_for ) { my ( $cola, $server ) = ( $cola_server =~ m/(.*)-(.*)/ ); @@ -4105,5 +3869,6 @@ } } - elsif ( $evento eq "queuemember" || $evento eq "queuememberstatus" ) { + + if ( $evento eq "queuemember" || $evento eq "queuememberstatus" ) { my $canalag = $hash_temporal{"Location"}; @@ -4254,5 +4019,6 @@ $evento = ""; } - elsif ( $evento eq "queuestatus" ) { + + if ( $evento eq "queuestatus" ) { $canal = $hash_temporal{Queue}; $canalid = $canal . "-XXXX"; @@ -4271,11 +4037,13 @@ $evento = ""; } - elsif ( $evento eq "meetmemute" || $evento eq "meetmeunmute" ) { - my ( $canal, undef ) = separate_session_from_channel($canalid); + + if ( $evento eq "meetmemute" || $evento eq "meetmeunmute" ) { + my ( $canal, $nada ) = separate_session_from_channel($canalid); $estado_final = $evento; push @return, "$canal|$evento||$unico_id|$canalid"; $evento = ""; } - elsif ( $evento eq "queueparams" ) { + + if ( $evento eq "queueparams" ) { $canal = $hash_temporal{Queue}; $canal =~ tr/a-z/A-Z/; @@ -4302,5 +4070,8 @@ $evento = ""; } - elsif ( $evento eq "join" ) { + + if ( $evento eq "join" ) { + my $qclidnum = ""; + my $qclidname = ""; $canal = "QUEUE/" . $hash_temporal{Queue}; my $position = $hash_temporal{Position}; @@ -4312,33 +4083,40 @@ $unico_id = "$canal-$server"; + if ( defined( $hash_temporal{CallerIDName} ) ) { + $qclidnum = $hash_temporal{CallerID}; + $qclidname = $hash_temporal{CallerIDName}; + } + elsif ( defined( $hash_temporal{CalleridName} ) ) { + $qclidnum = $hash_temporal{Callerid}; + $qclidname = $hash_temporal{CalleridName}; + } + else { + ( $qclidnum, $qclidname ) = split_callerid( $hash_temporal{CallerID} ); + } + my $texto_pos = "[$qclidname $qclidnum]"; + push @return, "$canal|$estado_final|$texto|$unico_id|$canalid"; - my @queue_events = recompute_queues_onjoin( \%hash_temporal, $server, $canalid ); - foreach my $valor (@queue_events) { - push @return, $valor; - } + push @return, "$canal=$position|$estado_final|$texto_pos|$unico_id|$canalid"; + push @return, "$canal=$position|setalpha|100|$unico_id|$canalid"; $evento = ""; - } - elsif ( $evento eq "leave" ) { - $canal = "QUEUE/" . $hash_temporal{"Queue"}; - $canal =~ tr/a-z/A-Z/; - $estado_final = "ocupado"; - my $plural = ""; - if ( $hash_temporal{"Count"} > 1 ) { $plural = "s"; } - if ( $hash_temporal{"Count"} == 0 ) { $estado_final = "corto"; } - $texto = "&waitingonqueue," . $hash_temporal{"Count"} . ",$plural&"; - $unico_id = "$canal-$server"; - push @return, "$canal|$estado_final|$texto|$unico_id|$canalid"; - $evento = ""; - - print_sesbot(1); - my @queue_events = recompute_queues_onleave($canalid); - foreach my $valor (@queue_events) { - push @return, $valor; - } - print_sesbot(2); - } - elsif ( $evento eq "meetmejoin" ) { + + my $tiempo = time(); + if ( defined( $hash_temporal{Wait} ) ) { + $tiempo = $tiempo - $hash_temporal{Wait}; + push @return, "$canal=$position|settimer|$hash_temporal{Wait}\@UP|$unico_id|$canalid"; + } + $cola->{$canalid}{POSITION} = $position; + $cola->{$canalid}{QUEUE} = $canal; + $cola->{$canalid}{CLID} = $qclidnum; + $cola->{$canalid}{CLIDNAME} = $qclidname; + $cola->{$canalid}{SERVER} = $server; + $cola->{$canalid}{TIME} = $tiempo; + + } + + if ( $evento eq "meetmejoin" ) { my $originate = "no"; my $mute_other_party = "no"; + my $nada = ""; my $contexto = ""; @@ -4518,10 +4296,9 @@ } my $canalfin = get_meetme_pos( $server, $canal, $position ); - my ( $ca1, $se1 ) = separate_session_from_channel( $hash_temporal{Channel} ); - push @return, "$ca1|$estado_final|$texto_pos|YYYY-$server|$hash_temporal{Channel}"; push @return, "$canalfin|$estado_final|$texto_pos|YYYY-$server|$hash_temporal{Channel}"; push @return, "$canalfin|meetmeuser|$hash_temporal{Usernum},$hash_temporal{Meetme}|YYYY-$server|$hash_temporal{Channel}"; } - elsif ( $evento eq "meetmeleave" ) { + + if ( $evento eq "meetmeleave" ) { $canal = $hash_temporal{Meetme}; $canal =~ tr/a-z/A-Z/; @@ -4545,5 +4322,5 @@ } - my ( $canal1, undef ) = separate_session_from_channel($canaleja); + my ( $canal1, $nada1 ) = separate_session_from_channel($canaleja); push @return, "$canal1|unsetlink|$canal|$unico_id|$canalid"; $evento = ""; @@ -4553,5 +4330,26 @@ push @return, "$canalfin|corto||$hash_temporal{Uniqueid}-$server|$canaleja"; } - elsif ( $evento eq "voicemail" ) { + + if ( $evento eq "leave" ) { + $canal = "QUEUE/" . $hash_temporal{"Queue"}; + $canal =~ tr/a-z/A-Z/; + $estado_final = "ocupado"; + my $plural = ""; + if ( $hash_temporal{"Count"} > 1 ) { $plural = "s"; } + if ( $hash_temporal{"Count"} == 0 ) { $estado_final = "corto"; } + $texto = "&waitingonqueue," . $hash_temporal{"Count"} . ",$plural&"; + $unico_id = "$canal-$server"; + push @return, "$canal|$estado_final|$texto|$unico_id|$canalid"; + $evento = ""; + + print_sesbot(1); + my @queue_events = recompute_queues($canalid); + foreach my $valor (@queue_events) { + push @return, $valor; + } + print_sesbot(2); + } + + if ( $evento eq "voicemail" ) { my @canalesvoicemail = (); @@ -4567,32 +4365,17 @@ $unico_id = $canal; $canalid = $canal . "-XXXX"; - if ( defined( $hash_temporal{Waiting} ) ) { - + if ( defined( $hash_temporal{"Waiting"} ) ) { $estado_final = "voicemail"; - $texto = $hash_temporal{Waiting}; - - if ( $texto eq "0" ) { - - # If it does not have new voicemail, ask for mailboxcount to get old mails + $texto = $hash_temporal{"Waiting"}; + + #$texto = 1; + if ( $texto eq "1" ) { + + # If it has new voicemail, ask for mailboxcount send_command_to_manager( "Action: MailboxCount\r\nMailbox: $hash_temporal{Mailbox}\r\n\r\n", $socket, 0, $astmanproxy_server ); } - else { - - # If it has new voicemail, look for the New and Old headers - if ( defined( $hash_temporal{New} ) ) { - my $nuevos = $hash_temporal{"New"}; - my $viejos = $hash_temporal{"Old"}; - push @return, "$canal|voicemailcount|&newold,$nuevos,$viejos|$unico_id-$server|$canal-XXXX"; - } - else { - send_command_to_manager( "Action: MailboxCount\r\nMailbox: $hash_temporal{Mailbox}\r\n\r\n", - $socket, 0, $astmanproxy_server ); - } - } } else { - - # This is the actual message count event $estado_final = "voicemailcount"; my $nuevos = $hash_temporal{"NewMessages"}; @@ -4605,5 +4388,6 @@ $evento = ""; } - elsif ( $evento eq "link" ) { + + if ( $evento eq "link" ) { my $uniqueid1 = $hash_temporal{"Uniqueid1"}; my $uniqueid2 = $hash_temporal{"Uniqueid2"}; @@ -4688,10 +4472,10 @@ $sclidname1 = $saved_clidname{"$server^$channel2"}; my $clid_with_format = format_clid( $clid1, $sclidname1, $clid_format ); - push @return, "$canal1|setclid|$clid_with_format|$uniqueid1|$channel1conses"; + push @return, "$canal1|settext|$clid_with_format|$uniqueid1|$channel1conses"; } if ( $clid2 ne "" && $channel1 ne "" ) { $sclidname2 = $saved_clidname{"$server^$channel1"}; my $clid_with_format = format_clid( $clid2, $sclidname2, $clid_format ); - push @return, "$canal2|setclid|$clid_with_format|$uniqueid2|$channel2conses"; + push @return, "$canal2|settext|$clid_with_format|$uniqueid2|$channel2conses"; } } @@ -4701,5 +4485,6 @@ $evento = ""; #NEW } - elsif ( $evento eq "unlink" ) { + + if ( $evento eq "unlink" ) { my $uniqueid1 = $hash_temporal{Uniqueid1}; my $uniqueid2 = $hash_temporal{Uniqueid2}; @@ -4745,5 +4530,6 @@ $evento = ""; #NEW } - elsif ( $evento eq "rename" ) { + + if ( $evento eq "rename" ) { my $nuevo_nombre = ""; my $viejo_nombre = ""; @@ -4761,10 +4547,11 @@ if ( $nuevo_nombre =~ // ) { - log_debug( "$heading $nuevo_nombre, asterisk bug, sometimes misses the hangup, so we fake it", 64 ) - if DEBUG; - my ( $canalnuevo, undef ) = separate_session_from_channel($nuevo_nombre); + log_debug( "$heading $nuevo_nombre, asterisk bug, sometimes misses the hangup, so we fake it", 64 ) if DEBUG; + my ( $canalnuevo, $nada ) = separate_session_from_channel($nuevo_nombre); push @return, "$canalnuevo|corto||$unico_id|$nuevo_nombre"; } + # Directamente borra la sesion que se debe renombrar + #if ( ( $nuevo_nombre !~ ///g; push @return, "$canal|ocupado3|$texto|$unidchan|$canalid"; - push @return, "PARK/$parksl|park|[$textid]$timeout|$hash_temporal{'Timeout'}-$server|$hash_temporal{'Channel'}"; - - log_debug( "$heading pongo parked($server^$hash_temporal{'Channel'}) en $parksl", 64 ) if DEBUG; - $parked{"$server^$hash_temporal{'Channel'}"} = $parksl; + push @return, "PARK/$hash_temporal{'Exten'}|park|[$textid]$timeout|$hash_temporal{'Timeout'}-$server|$hash_temporal{'Channel'}"; + + log_debug( "$heading pongo parked($server^$hash_temporal{'Channel'}) en $hash_temporal{'Exten'}", 64 ) if DEBUG; + $parked{"$server^$hash_temporal{'Channel'}"} = $hash_temporal{'Exten'}; $evento = ""; #NEW } - elsif ( $evento eq "newcallerid" ) { + + if ( $evento eq "newcallerid" ) { $estado_final = "setstatus"; $state = "Newcallerid"; @@ -5174,5 +4927,5 @@ if ( $evento ne "" ) { - log_debug( "$heading Event $evento, canal '$canal', estadofinal $estado_final", 32 ) if DEBUG; + log_debug( "$heading Event $evento, canal '$canal'", 32 ) if DEBUG; # De acuerdo a los datos de la extension genera @@ -5227,4 +4980,9 @@ } + if ( exists( $datos{$unico_id}{'State'} ) ) { + log_debug( "$heading EXISTE datos($unico_id){state}", 32 ) if DEBUG; + $state = $datos{$unico_id}{'State'}; + } + if ( exists( $datos{$unico_id}{'Callerid'} ) ) { $clid = $datos{$unico_id}{'Callerid'}; @@ -5257,6 +5015,6 @@ if ( $state eq "" ) { - if ( defined( $hash_temporal{State} ) ) { - $state = $hash_temporal{State}; + if ( defined( $hash_temporal{'State'} ) ) { + $state = $hash_temporal{'State'}; } else { @@ -5271,18 +5029,12 @@ if ( $clidnum ne "" ) { my $base64_clidnum = encode_base64( $clidnum . " " ); - $ret = "$canal|clidnum|$base64_clidnum|$unico_id|$hash_temporal{Channel}"; + $ret = "$canal|clidnum|$base64_clidnum|$unico_id|$hash_temporal{'Channel'}"; push @return, $ret; } if ( defined($clidname) ) { my $base64_clidname = encode_base64( $clidname . " " ); - $ret = "$canal|clidname|$base64_clidname|$unico_id|$hash_temporal{Channel}"; + $ret = "$canal|clidname|$base64_clidname|$unico_id|$hash_temporal{'Channel'}"; push @return, $ret; } - foreach my $var ( keys %{ $passvar{ $hash_temporal{Uniqueid} } } ) { - my $base64_var = encode_base64( $passvar{ $hash_temporal{Uniqueid} }{$var} ); - $ret = "$canal|setvar|$var=$base64_var|$unico_id|$hash_temporal{Channel}"; - push @return, $ret; - } - delete $passvar{ $hash_temporal{Uniqueid} }; } @@ -5292,9 +5044,9 @@ if ( $state eq "Ring" ) { - $texto = $canalid; - $estado_final = "ring"; - - #$datos{$unico_id}{'Origin'} = "true"; - #log_debug( "$heading POPULATES datos($unico_id){ Origin } = true", 128 ) if DEBUG; + print "RING $canalid\n"; + $texto = $canalid; + $estado_final = "ring"; + $datos{$unico_id}{'Origin'} = "true"; + log_debug( "$heading POPULATES datos($unico_id){ Origin } = true", 128 ) if DEBUG; } @@ -5469,7 +5221,7 @@ my $cuantos = $#return + 1; - if (DEBUG) { - log_debug( "$heading returns $cuantos", 16 ); - log_debug( "$heading END SUB returns $_", 32 ) foreach (@return); + log_debug( "$heading returns $cuantos", 16 ) if DEBUG; + foreach (@return) { + log_debug( "$heading END SUB returns $_", 32 ) if DEBUG; } $tab = substr( $tab, 0, -1 ); @@ -5497,5 +5249,5 @@ if ( defined( $extension_transfer_reverse{"$server^$local_channel"} ) ) { - if ( $extension_transfer_reverse{"$server^$local_channel"} !~ /-?\d+\^CLID/ ) { + if ( $extension_transfer_reverse{"$server^$local_channel"} !~ /\d+\^CLID/ ) { # We dont want to return CLID buttons @@ -5515,9 +5267,11 @@ $canal =~ s/(.*)&(.*)/$1/g; + # if( $canal =~ m/^CLID/ ) { + # my $extr = $extension_transfer{"$server^$canal"}; + # $extr =~ s/\d+\^(.*)/$1/g; + # $canal = "Local/$extr"; + # } + log_debug( "** LOCAL_CHANNELS devuelvo $server canal $canal", 32 ) if DEBUG; - - # If channel has a pipe due to REGEXP button, replace it with something else because - # procesa_bloque use pipes to return data to digest_event_block - $canal =~ s/\|/~/g; push @return, $server; push @return, $canal; @@ -5549,8 +5303,9 @@ $tab = $tab . "\t" if DEBUG; - log_debug( "$heading start", 256 ) if DEBUG; + log_debug( "$heading start", 16 ) if DEBUG; @fake_bloque = (); + # delete $datos{""}; foreach my $blaque (@blique) { @@ -5569,14 +5324,11 @@ } @mensajes = procesa_bloque( $blaque, $socket, $astmanproxy_server ); - foreach my $mensaje (@mensajes) { if ( defined($mensaje) && $mensaje ne "" ) { - log_debug( "$heading GOT $mensaje", 256 ) if DEBUG; + log_debug( "$heading GOT $mensaje", 32 ) if DEBUG; delete $datos{""}; # Erase the hash with no uniqueid - ( $canal, $quehace, $dos, $uniqueid, $canalid ) = split( /\|/, $mensaje ); - - # change back newflo into pipes - $canal =~ s/~/\|/g; - $canalid =~ s/~/\|/g; + ( $canal, $quehace, $dos, $uniqueid, $canalid ) = + split( /\|/, $mensaje ); + $canalid =~ s/(.*),(\d)/$1/g; # discard ,2 on Local channels @@ -5585,26 +5337,31 @@ if ( $canal =~ /\/PSEUDO/ ) { - log_debug( "$heading Ignoring pseudo channel $canal", 256 ) if DEBUG; + log_debug( "$heading Ignoring pseudo channel $canal", 32 ) if DEBUG; next; } if ( $dos eq "skip" ) { - log_debug( "$heading skipping $canal $quehace (has skip)", 256 ) if DEBUG; + log_debug( "$heading SALTEO $canal tiene skip", 32 ) if DEBUG; next; } - if ( $quehace eq "" ) { - log_debug( "$heading skipping $canal (empty quehace)", 256 ) if DEBUG; + log_debug( "$heading SALTEO $canal no tiene quehace", 32 ) if DEBUG; next; } - log_debug( "$heading canal: $canal", 256 ) if DEBUG; - log_debug( "$heading quehace: $quehace", 256 ) if DEBUG; - log_debug( "$heading dos: $dos", 256 ) if DEBUG; - log_debug( "$heading uniqueid: $uniqueid", 256 ) if DEBUG; - log_debug( "$heading canalid: $canalid", 256 ) if DEBUG; - - $canalid =~ s/\s+//g; # Removes whitespace from CHANNEL-ID - $canalid =~ s/(.*)<(.*)>/$1/g; # discards ZOMBIE or MASQ + log_debug( "$heading canal: $canal", 1 ) if DEBUG; + log_debug( "$heading quehace: $quehace", 1 ) if DEBUG; + log_debug( "$heading dos: $dos", 32 ) if DEBUG; + log_debug( "$heading uniqueid: $uniqueid", 32 ) if DEBUG; + log_debug( "$heading canalid: $canalid", 1 ) if DEBUG; + + # if ( !defined($canal) ) { $canal = ""; } + # if ( !defined($quehace) ) { $quehace = ""; } + # if ( !defined($dos) ) { $dos = ""; } + + $canalid =~ s/\s+//g; # Removes whitespace from CHANNEL-ID + my $real_canal = $canalid; + my $canalidzombie = $canalid; # Removes whitespace from CHANNEL-ID + $canalid =~ s/(.*)<(.*)>/$1/g; # discards ZOMBIE or MASQ if ( $canal =~ /^vpb\//i ) { @@ -5619,4 +5376,6 @@ $server =~ s/(.*)-(.*)/$2/g; + log_debug( "$heading Quehace $quehace", 64 ) if DEBUG; + my $buttontext = $dos; if ( $buttontext =~ /\Q[\E/ ) { @@ -5629,6 +5388,4 @@ my @canaleja = find_panel_buttons( $canal, $canalid, $server ); my $cuantos = @canaleja; - - # Perform some pre processing... if ( $quehace eq "corto" || $quehace eq "info" ) { @@ -5639,5 +5396,5 @@ $toda .= "$key = $val\n" if ( $key ne "E" ) && ( defined($val) ); - log_debug( "$heading \tAgrego $key = $val", 256 ) if DEBUG; + log_debug( "$heading \tAgrego $key = $val", 128 ) if DEBUG; } $toda .= " "; @@ -5645,21 +5402,20 @@ if ( $quehace eq "corto" ) { - log_debug( "$heading erasing datos{$uniqueid}", 256 ) if DEBUG; - delete $held_channel{$canalid}; delete $datos{$uniqueid}; - delete $chanvar{$uniqueid}; - delete $passvar{$uniqueid}; - - if ( $cuantos == 0 ) { - - # We need to call it here because a channel with no buttons defined - # might count for other button that exists, like meetmes, queues, etc. - # So we only call it when there is NO match for buttons (because - # we will call it again for existing matches) - erase_all_sessions_from_channel( $canalid, $canal, $server ); - } } - } - elsif ( $quehace eq "queueremoved" ) { + + log_debug( "$heading erasing datos{$uniqueid}", 128 ) if DEBUG; + + if ( $cuantos == 0 ) { + + # We delete all appeareance in sesbot because the channel without + # a button might occupy one slot in sesbot. If we have a button + # match then skip this step for later + erase_all_sessions_from_channel( $canalid, $canal, $server ); + } + + } + + if ( $quehace eq "queueremoved" ) { # Remove the agent from the agents_on_queue hash @@ -5692,6 +5448,6 @@ foreach $canal (@canaleja) { - log_debug( "", 256 ) if DEBUG; - log_debug( "$heading canaleja LOOP; is $canal turn", 256 ) if DEBUG; + log_debug( "", 32 ) if DEBUG; + log_debug( "$heading canaleja LOOP; is $canal turn", 32 ) if DEBUG; if ( $dosoriginal ne "" ) { @@ -5705,8 +5461,8 @@ if ( !defined( $buttons{"$server^$canal"} ) && !defined( $buttons{"-1^$canal"} ) ) { - log_debug( "$heading \tThere are no buttons for $server^$canal, skipping...", 256 ) if DEBUG; + log_debug( "$heading \tNo tengo botones para $server^$canal, END FUNCTION", 128 ) if DEBUG; if (DEBUG) { for ( keys %buttons ) { - log_debug( "$heading \t\tKey $_", 256 ); + log_debug( "$heading \t\tKey $_", 128 ); } } @@ -5717,5 +5473,5 @@ # except ocupado*, corto, setlink and unsetlink if ( $canal =~ /^_/ ) { - log_debug( "$heading canal $canal is regexp, quehace value = $quehace", 256 ) if DEBUG; + log_debug( "$heading canal $canal es un WILD y quehace vale $quehace", 32 ) if DEBUG; if ( $quehace =~ /registr/ @@ -5723,5 +5479,5 @@ || $quehace =~ /^inf/ ) { - log_debug( "$heading IGNORING $quehace because it is a regexp match", 256 ) if DEBUG; + log_debug( "$heading IGNORO $quehace porque es un wildcard", 32 ) if DEBUG; next; } @@ -5731,5 +5487,4 @@ && $quehace !~ /^state/ && $quehace !~ /^settext/ - && $quehace !~ /^setclid/ && $quehace !~ /^setlabel/ && $quehace !~ /^setlink/ @@ -5742,5 +5497,5 @@ && $quehace !~ /^unsetlink/ ) { - my ( undef, $elcontexto ) = split( /\&/, $canal ); + my ( $nada, $elcontexto ) = split( /\&/, $canal ); if ( !defined($elcontexto) ) { $elcontexto = ""; } if ( $elcontexto ne "" ) { @@ -5749,14 +5504,14 @@ my ( $canalsolo, $nrotrunk ) = split( /=/, $canal ); $canal = $canalsolo . "=1" . $elcontexto; - log_debug( "$heading quehace=$quehace, select 1st from trunk $canal", 256 ) if DEBUG; + log_debug( "$heading quehace=$quehace, elijo el 1ero del trunk $canal", 32 ) if DEBUG; #next; } - # If we have a regexp button with changelabel + # If we have a wildcard button with changelabel # and change led_color (the 1 after changelabel) # change it so to not change the led color. if ( $quehace =~ /changelabel1/ ) { - log_debug( "$heading regexp has changelabel1, lets change it to changelabel0!", 256 ) + log_debug( "$heading el wildcard tiene changelabel1, lo cambio por changelabel0!", 32 ) if DEBUG; $quehace = "changelabel0"; @@ -5766,13 +5521,8 @@ my $serverindex = $server; # Save the server in another var - if ( $canal eq "" ) { - - # No channel? continue... - log_debug( "$heading There is no command defined", 256 ) if DEBUG; - - } - else { + if ( $canal ne "" ) { $interno = $buttons{"$server^$canal"}; + if ( !defined($interno) ) { $interno = $buttons{"-1^$canal"}; @@ -5793,10 +5543,7 @@ } - # The following block cleans internal op_server states. no matter if we - # have a button defined or not. - if ( $quehace eq 'corto' || $quehace eq 'info' ) { + my @linked = erase_all_sessions_from_channel( $canalid, $canal, $server ); - push @linked, $canal; my $btnorinum = ""; @@ -5808,5 +5555,5 @@ $btnorinum = $buttons{"$serverindex^$canaleje"}; } - log_debug( "$heading call GEN_LINKED 1", 256 ) if DEBUG; + log_debug( "$heading call GEN_LINKED 1", 32 ) if DEBUG; my $listabotones = generate_linked_buttons_list( $canaleje, $server ); push @respuestas, "$btnorinum|linked|$listabotones"; @@ -5814,13 +5561,11 @@ delete $datos{$uniqueid}; - delete $chanvar{$uniqueid}; - delete $passvar{$uniqueid}; - log_debug( "$heading REMOVING datos { $uniqueid }", 256 ) if DEBUG; + log_debug( "$heading REMOVING datos { $uniqueid }", 32 ) if DEBUG; } elsif ( $quehace eq "setlink" ) { - log_debug( "$heading IF quehace = SETLINK", 256 ) if DEBUG; - my ( undef, $contexto1 ) = split( /\&/, $canal ); + log_debug( "$heading IF quehace = SETLINK", 32 ) if DEBUG; + my ( $nada1, $contexto1 ) = split( /\&/, $canal ); if ( !defined($contexto1) ) { $contexto1 = ""; } my $listabotones = ""; @@ -5829,5 +5574,5 @@ push @{ $linkbot{"$server^$canal"} }, ""; pop @{ $linkbot{"$server^$canal"} }; - log_debug( "$heading DEFINIENDO linkbot ($server^$canal)", 256 ) if DEBUG; + log_debug( "$heading DEFINIENDO linkbot ($server^$canal)", 32 ) if DEBUG; } @@ -5835,9 +5580,9 @@ my @linkbotones = find_panel_buttons( $canal1, $dos, $server ); foreach (@linkbotones) { - my ( undef, $contexto2 ) = split( /\&/, $_ ); + my ( $nada2, $contexto2 ) = split( /\&/, $_ ); if ( !defined($contexto2) ) { $contexto2 = ""; } if ( $contexto1 eq $contexto2 ) { push @{ $linkbot{"$server^$canal"} }, $dos; - log_debug( "$heading AGREGO a linkbot{ $server^$canal} el valor $dos", 256 ) + log_debug( "$heading AGREGO a linkbot{ $server^$canal} el valor $dos", 32 ) if DEBUG; } @@ -5848,18 +5593,18 @@ foreach my $valorad (@uniq) { - log_debug( "$heading linkbot ($server^$canal) = $valorad", 256 ) if DEBUG; + log_debug( "$heading linkbot ($server^$canal) = $valorad", 32 ) if DEBUG; } my $btnorinum = $buttons{"$serverindex^$canal"}; - log_debug( "$heading llamo a GENERATE_LINKED", 256 ) if DEBUG; + log_debug( "$heading llamo a GENERATE_LINKED", 32 ) if DEBUG; $listabotones = generate_linked_buttons_list( $canal, $server ); push @respuestas, "$btnorinum|linked|$listabotones"; - push @respuestas, "$btnorinum|bridgepeer|$dos"; $botonlinked{$btnorinum} = $listabotones; - log_debug( "$heading linkeado con $listabotones", 256 ) if DEBUG; - log_debug( "$heading ENDIF quehace = SETLINK", 256 ) if DEBUG; + log_debug( "$heading linkeado con $listabotones", 32 ) if DEBUG; + log_debug( "$heading ENDIF quehace = SETLINK", 32 ) if DEBUG; } elsif ( $quehace eq "unsetlink" ) { - log_debug( "$heading IF quehace = UNSETLINK", 256 ) if DEBUG; + + log_debug( "$heading IF quehace = UNSETLINK", 32 ) if DEBUG; my @final = (); foreach my $msesion ( @{ $linkbot{"$server^$canal"} } ) { @@ -5869,5 +5614,5 @@ } $linkbot{"$server^$canal"} = [@final]; - log_debug( "$heading ENDIF quehace = UNSETLINK", 256 ) if DEBUG; + log_debug( "$heading ENDIF quehace = UNSETLINK", 32 ) if DEBUG; } @@ -5888,11 +5633,10 @@ } - # Continue after cleaning internal state... if ( $interno eq "" ) { - log_debug( "$heading MISSING buttons($server^$canal), skipping...", 256 ) if DEBUG; + log_debug( "$heading NO HAY INTERNO buttons($server^$canal), ABORTO", 32 ) if DEBUG; next; } else { - log_debug( "$heading INTERNO = $interno", 256 ) if DEBUG; + log_debug( "$heading EL INTERNO es $interno", 32 ) if DEBUG; } @@ -5917,16 +5661,5 @@ # if ( $canalid eq "" || $canalid =~ /zombie/i || $canalid =~ /(.*)-XXXX$/ ) { - log_debug( "$heading ATENTION canalid = '$canalid', skipping...", 256 ) if DEBUG; - if ( $quehace eq "registrado" || $quehace eq "noregistrado" || $quehace eq "unreachable" ) { - if ( defined( $botonregistrado{$interno} ) ) { - if ( $botonregistrado{$interno} eq "$quehace|$dos" ) { - $cambiaron{$interno} = 0; - } - } - else { - $botonregistrado{$interno} = "$quehace|$dos"; - $cambiaron{$interno} = 1; - } - } + log_debug( "$heading ATENCION canalid es $canalid, NO PROCESAR?", 32 ) if DEBUG; } else { @@ -5934,6 +5667,5 @@ if ( $quehace eq "corto" ) { - log_debug( "$heading CORTO interno $interno canal $canal", 256 ) if DEBUG; - $dos = $canalid; + log_debug( "$heading CORTO interno $interno canal $canal", 32 ) if DEBUG; delete $botonpark{$interno}; @@ -5962,5 +5694,5 @@ if ( $cuantos == 0 ) { log_debug( "$heading CORTO y SE DESOCUPO estadoboton($interno) = free, sesbot($interno) esta vacio", - 256 ) + 32 ) if DEBUG; $cambiaron{$interno} = 1; @@ -5969,5 +5701,5 @@ else { log_debug( "$heading CORTO y SIGUE OCUPADO estadoboton($interno) = busy, sesbot($interno) tiene algo", - 256 ) + 32 ) if DEBUG; &print_sesbot(3); @@ -5979,12 +5711,14 @@ push @respuestas, "$interno|state|busy"; + # Problems with callerid being cleared while a call is connected + # from a queue using Local channels, so commnet these out + #push @respuestas, "$interno|settext|"; + #push @respuestas, "$interno|setstatus|"; $laststatus{$interno} = "busy|${buttontext}"; log_debug( - "$heading Y es distinto al ultimo estado $laststatus{$interno} ne $estadoboton{$interno}", 256 ) + "$heading Y es distinto al ultimo estado $laststatus{$interno} ne $estadoboton{$interno}", 32 ) if DEBUG; } - - # Conserva el callerid anterior if ( defined( $preestadoboton{$interno} ) ) { $estadoboton{$interno} = $preestadoboton{$interno}; @@ -6003,4 +5737,5 @@ # quehace no es "corto" + # # MAINTAINS SESBOT HASH @@ -6015,5 +5750,5 @@ push @{ $sesbot{$interno} }, "$canalid"; - log_debug( "$heading AGREGO a sesbot($interno) el valor $canalid", 256 ) if DEBUG; + log_debug( "$heading AGREGO a sesbot($interno) el valor $canalid", 32 ) if DEBUG; my @uniq = unique( @{ $sesbot{$interno} } ); @@ -6021,13 +5756,16 @@ foreach my $vavi ( @{ $sesbot{$interno} } ) { - log_debug( "$heading sesbot($interno) tiene $vavi", 256 ) if DEBUG; - log_debug( "$heading --------------------", 256 ) if DEBUG; + log_debug( "$heading sesbot($interno) tiene $vavi", 32 ) if DEBUG; + log_debug( "$heading --------------------", 32 ) if DEBUG; } } if ( $canal =~ /^_/ && $quehace =~ /^ring/ ) { - log_debug( "$heading have a regexp originating a call $canal $quehace $canalid, rename label", 256 ) + log_debug( "$heading TENGO UN WILDCARD ORIGINANDO LLAMADO! $canal $quehace $canalid", 32 ) if DEBUG; - + if ( $quehace eq "ring" ) { + + # $quehace = "ocupado1"; + } if ( $ren_wildcard == 1 ) { push @respuestas, "$interno|changelabel0|$canalid"; @@ -6035,4 +5773,5 @@ } } + if ( $quehace eq "ringing" ) { if ( $laststatus{$interno} ne "ringing|${buttontext}" ) { @@ -6056,10 +5795,19 @@ } - elsif ( $quehace =~ /^ocupado/ || $quehace eq 'ring' ) { + elsif ( $quehace =~ /^ocupado/ ) { if ( defined( $group_count{$interno} ) ) { + my $plural = ""; if ( $group_count{$interno} == 1 ) { - $buttontext = group_count( $interno, $canal ); - push @respuestas, $buttontext; + if ( @{ $sesbot{$interno} } > 1 ) { + $plural = "s"; + } + if ( @{ $sesbot{$interno} } > 0 ) { + my $cuantos = @{ $sesbot{$interno} }; + my ( $text, $textriginal, $buttontext ) = + translate( $canal, "&channels,$cuantos,$plural", "", "" ); + $buttontext = $text; + $dos = "[" . $buttontext . "]"; + } } } @@ -6068,12 +5816,13 @@ } $estadoboton{$interno} = "busy|${buttontext}"; + } } } - log_debug( "$heading Continuo proceso...", 256 ) if DEBUG; + log_debug( "$heading Continuo proceso...", 32 ) if DEBUG; if ( $quehace =~ /changelabel/ ) { - log_debug( "$heading quehace = changelabel", 256 ) if DEBUG; + log_debug( "$heading quehace = changelabel", 32 ) if DEBUG; # Mantains state of label and led @@ -6117,5 +5866,5 @@ elsif ( $quehace eq "park" ) { - log_debug( "$heading quehace = park", 256 ) if DEBUG; + log_debug( "$heading quehace = park", 32 ) if DEBUG; $dos =~ m/(.*)\((.*)\)/; my $texto = $1; @@ -6144,4 +5893,8 @@ $quehace = ""; } + else { + + # print "PERO ES DISTINTO\n$val\n$mcola|$dos\n\n"; + } } else { @@ -6152,24 +5905,12 @@ if ( $estaba == 0 ) { push @{ $botonqueuemember{$interno} }, "$mcola|$dos"; + + #print "NICO botonqueuemember ($interno) = $mcola y $dos\n"; } - } - elsif ( $quehace eq "setclid" ) { - if ( !defined( $group_count{$interno} ) ) { - push @respuestas, "$interno|settext|$dos"; - } - if ( $estadoboton{$interno} eq "" ) { - push @respuestas, "$interno|state|busy"; - $estadoboton{$interno} = "busy"; - } } elsif ( $quehace eq "settext" ) { if ( !defined( $group_count{$interno} ) ) { - $botonpermanenttext{$interno} = $dos; - push @respuestas, "$interno|settext|$dos"; - } - } - elsif ( $quehace eq "settextnopermanente" ) { - if ( !defined( $group_count{$interno} ) ) { + $botonclid{$interno} = $dos; push @respuestas, "$interno|settext|$dos"; } @@ -6217,9 +5958,4 @@ $calleridpop =~ s/\s+//g; push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|$calleridpop"; - if ( defined( $group_count{$interno} ) && $group_count{$interno} == 1 ) { - - # Ignore ringing because of groupcount - $quehace = ""; - } } @@ -6232,9 +5968,6 @@ && ( $quehace !~ /link/ ) ) { - if ( !defined( $cambiaron{$interno} ) ) { - $cambiaron{$interno} = 1; - log_debug( "$heading es distinto de corto,ocupado,link pongo cambiaron=1", 256 ) - if DEBUG; - } + $cambiaron{$interno} = 1; + log_debug( "$heading es distinto de corto,ocupado,link pongo cambiaron=1", 32 ) if DEBUG; } @@ -6245,12 +5978,6 @@ if ( @{ $sesbot{$interno} } > 0 && $quehace eq 'corto' ) { - log_debug( "$heading Still busy...sesbot($interno) is not empty, ignore hangup", 256 ) + log_debug( "$heading Still busy...sesbot($interno) is not empty, ignoring hangup", 32 ) if DEBUG; - if ( defined( $group_count{$interno} ) ) { - if ( $group_count{$interno} == 1 ) { - $buttontext = group_count( $interno, $canal ); - push @respuestas, $buttontext; - } - } } else { @@ -6259,26 +5986,25 @@ my $canalsincontexto = $canal; $canalsincontexto =~ s/(.*)&(.*)/$1/g; - push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|$canalid"; - if ( defined( $group_count{$interno} ) ) { - if ( $group_count{$interno} == 1 ) { - $buttontext = group_count( $interno, $canal ); - push @respuestas, $buttontext; - } - } + push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|corto!"; } my $quehace2 = $quehace; + + if ( $quehace2 eq "ring" ) { + + #$quehace2 = "ocupado"; + } next unless ( $quehace2 ne "setlink" ); next unless ( $quehace2 ne "unsetlink" ); - log_debug( "$heading sigo quehace quehace2", 256 ) if DEBUG; + log_debug( "$heading sigo quehace quehace2", 32 ) if DEBUG; if ( $quehace2 eq "isagent" && $dos == -1 ) { - log_debug( "$heading quehace2 = isagent", 256 ) if DEBUG; + log_debug( "$heading quehace2 = isagent", 32 ) if DEBUG; push @mensajefinal, "$interno|changelabel1|original"; push @mensajefinal, "$interno|settimer|0\@STOP"; push @mensajefinal, "$interno|settext|"; - push @mensajefinal, "$interno|corto|$canalid"; + push @mensajefinal, "$interno|corto|"; } @@ -6286,5 +6012,5 @@ # clear the agent helper hashes. We do it here because we first need to map - log_debug( "$heading quehace2 = agentlogoff", 256 ) if DEBUG; + log_debug( "$heading quehace2 = agentlogoff", 32 ) if DEBUG; my $canalag = $canalid; $canalag = substr( $canalag, 0, -5 ); @@ -6297,5 +6023,5 @@ if ( $val eq $canalag ) { delete $channel_to_agent{$key}; - log_debug( "$heading borro channel_to_agent($key)", 256 ) if DEBUG; + log_debug( "$heading borro channel_to_agent($key)", 64 ) if DEBUG; } } @@ -6304,5 +6030,5 @@ if ( defined( $agent_to_channel{"$server^$canalag"} ) ) { delete $agent_to_channel{"$server^$canalag"}; - log_debug( "$heading borro agent_to_channel($server^$canalag)", 256 ) if DEBUG; + log_debug( "$heading borro agent_to_channel($server^$canalag)", 64 ) if DEBUG; } @@ -6318,27 +6044,19 @@ } - if ( $quehace2 !~ /isagent/ && $quehace2 !~ /^agentlogoff/ && $quehace2 !~ /^setclid/ ) { - - if ( defined( $cambiaron{$interno} ) && $cambiaron{$interno} == 1 ) { - - # Discard events that we dont want to send - # to flash clients - # "isagent". "agentlogoff" - # everything else is pushed - if ( defined( $group_count{$interno} ) && $quehace2 eq "setclid" ) { - log_debug( "$heading skip settext because groupcount is set", 256 ) if DEBUG; - } - else { - if ( $quehace2 ne "" ) { - if ( defined( $group_count{$interno} ) && $group_count{$interno} == 1 ) { - - # $dos = ""; - } - else { - push @respuestas, "$interno|$quehace2|$dos"; - log_debug( "$heading pushing respuestas $interno|$quehace2|$dos", 256 ) - if DEBUG; - } - } + if ( $quehace2 !~ /isagent/ && $quehace2 !~ /^agentlogoff/ ) { + log_debug( "$heading pushing respuestas $interno|$quehace2|$dos", 32 ) if DEBUG; + + # Discard events that we dont want to send + # to flash clients + # "isagent". "agentlogoff" + # everything else is pushed + if ( defined( $group_count{$interno} ) && $quehace2 eq "settext" ) { + log_debug( "$heading skip settext because groupcount is set", 32 ) if DEBUG; + } + else { + if ( $quehace2 ne "" ) { + push @respuestas, "$interno|$quehace2|$dos"; + + # print "pushing $interno $quehace2 $dos\n"; } } @@ -6346,35 +6064,24 @@ if ( $quehace2 =~ /ocupado/ ) { - if ( defined( $group_count{$interno} ) && $group_count{$interno} == 1 ) { - $cambiaron{$interno} = 0; - $quehace2 = ""; - next; + if ( $dos =~ m/(.*)?\[(.*)\].*?/ ) { + my $clidtext = $2; + $botonclid{$interno} = $clidtext; } - else { - if ( $dos =~ m/(.*)?\[(.*)\].*?/ ) { - my $clidtext = $2; - $botonclid{$interno} = $clidtext; - } - - #push @mensajefinal, "$interno|state|busy"; - push @mensajefinal, "$interno|settimer|0\@UP"; - } + + #push @mensajefinal, "$interno|state|busy"; + push @mensajefinal, "$interno|settimer|0\@UP"; } if ( $quehace2 eq "settimer" ) { - if ( !defined($dos) ) { $dos = 1; } - my $tiempo = $dos; - my $timer_type = ""; + my $tiempo = $dos; + my $nada = ""; if ( $tiempo =~ /\@/ ) { - ( $tiempo, $timer_type ) = split( /\@/, $tiempo ); + ( $tiempo, $nada ) = split( /\@/, $tiempo ); } - - if ( $tiempo eq "" ) { $tiempo = 0; } - - if ( $timer_type ne "" ) { - $botontimertype{$interno} = $timer_type; - $timer_type = "\@" . $timer_type; + if ( $nada ne "" ) { + $botontimertype{$interno} = $nada; + $nada = "\@" . $nada; } $botontimer{$interno} = time() - $tiempo; - push @mensajefinal, "$interno|settimer|$tiempo$timer_type"; + push @mensajefinal, "$interno|settimer|$tiempo$nada"; } @@ -6391,7 +6098,9 @@ if ( $quehace2 eq "ring" ) { push @mensajefinal, "$interno|state|busy"; + + #push @mensajefinal, "$interno|settext|$dos"; } if ( $quehace2 =~ /corto/ ) { - log_debug( "$heading quehace2 corto", 256 ) if DEBUG; + log_debug( "$heading quehace2 corto", 32 ) if DEBUG; my $canalsincontexto = $canal; @@ -6417,6 +6126,5 @@ $iniagent = $channel_to_agent{"$server^$canalsincontexto"}; } - log_debug( "$heading quehace2 corto y es agente, pushing settimer y settext to idle", 256 ) - if DEBUG; + log_debug( "$heading quehace2 corto y es agente, pushing settimer y settext to idle", 1 ) if DEBUG; $botontimer{$interno} = time(); $botontimertype{$interno} = "IDLE"; @@ -6431,6 +6139,5 @@ else { my $valip = ""; - log_debug( "$heading quehace2 corto, no es agente, pongo timer en cero", 256 ) - if DEBUG; + log_debug( "$heading quehace2 corto, no es agente, pongo timer en cero", 1 ) if DEBUG; push @mensajefinal, "$interno|settimer|0\@STOP"; @@ -6441,11 +6148,5 @@ } else { - if ( defined( $botonpermanenttext{$interno} ) ) { - push @mensajefinal, "$interno|settext|$botonpermanenttext{$interno}"; - log_debug( "interno $interno tenia permanente $botonpermanenttext{$interno}", 128 ) - if DEBUG; - } $botonclid{$interno} = ""; - } @@ -6458,20 +6159,17 @@ } + if ( $quehace eq "registrado" ) { + if ( defined( $botonalpha{$interno} ) ) { + if ( $botonalpha{$interno} ne "" ) { + push @mensajefinal, "$interno|setalpha|50"; + } + else { + push @mensajefinal, "$interno|setalpha|100"; + } + } + } + if ( $quehace eq "registrado" || $quehace eq "noregistrado" || $quehace eq "unreachable" ) { - if ( $botonregistrado{$interno} ne "$quehace|$dos" ) { - - # changed registration state, do something - if ( $quehace eq "registrado" ) { - if ( defined( $botonalpha{$interno} ) ) { - if ( $botonalpha{$interno} ne "" ) { - push @mensajefinal, "$interno|setalpha|50"; - } - else { - push @mensajefinal, "$interno|setalpha|100"; - } - } - } - $botonregistrado{$interno} = "$quehace|$dos"; - } + $botonregistrado{$interno} = "$quehace|$dos"; } @@ -6479,18 +6177,18 @@ $boton_paused{$interno} = $dos; } - elsif ( $quehace eq "agents_paused" ) { + if ( $quehace eq "agents_paused" ) { $boton_agentpaused{$interno} = $dos; } - elsif ( $quehace eq "agents_ready" ) { + if ( $quehace eq "agents_ready" ) { $boton_agentready{$interno} = $dos; } - elsif ( $quehace eq "agents_busy" ) { + if ( $quehace eq "agents_busy" ) { $boton_agentbusy{$interno} = $dos; } - elsif ( $quehace eq "agents_logedof" ) { + if ( $quehace eq "agents_logedof" ) { $boton_agentlogedof{$interno} = $dos; } - log_debug( "$heading Agrego mensaje final $interno|$quehace2|$dos", 256 ) if DEBUG; + log_debug( "$heading Agrego mensaje final $interno|$quehace2|$dos", 32 ) if DEBUG; #if (defined($mensajefinal) && $interno ne "") @@ -6499,17 +6197,20 @@ if ( exists $cambiaron{$interno} ) { - log_debug( "$heading Existe cambiaron($interno) = $cambiaron{$interno}", 256 ) + log_debug( "$heading Existe cambiaron($interno) = $cambiaron{$interno}", 32 ) if DEBUG; - if ( $cambiaron{$interno} == 1 ) { - foreach (@mensajefinal) { - log_debug( "$heading pushing respuestas $_ because cambiaron($interno)=1", 256 ) - if DEBUG; - push @respuestas, $_; - } + #push(@respuestas, $mensajefinal); + foreach (@mensajefinal) { + push @respuestas, $_; } } else { - log_debug( "$heading No existe cambiaron($interno)", 256 ) if DEBUG; + + log_debug( "$heading No existe cambiaron($interno)", 32 ) if DEBUG; + foreach (@mensajefinal) { + + # If the last status was not modified, avoid sending info + # push @respuestas, $_; + } } if ( $toda ne "" ) { @@ -6523,4 +6224,7 @@ $laststatus{$interno} = $estadoboton{$interno}; } + else { # endif canal distinto de nada + log_debug( "$heading There is no command defined", 32 ) if DEBUG; + } } } @@ -6530,31 +6234,10 @@ @respuestas = unique(@respuestas); $cuantas = $#respuestas + 1; - log_debug( "$heading end, return $cuantas", 256 ) if DEBUG; + log_debug( "$heading end, return $cuantas", 16 ) if DEBUG; foreach my $valor (@respuestas) { - log_debug( "$heading END SUB: returns $valor", 256 ) if DEBUG; + log_debug( "$heading END SUB: returns $valor", 32 ) if DEBUG; } $tab = substr( $tab, 0, -1 ) if DEBUG; return @respuestas; -} - -sub group_count { - my $interno = shift; - my $canal = shift; - my $plural = ""; - my $return = ""; - if ( @{ $sesbot{$interno} } > 1 ) { - $plural = "s"; - } - if ( @{ $sesbot{$interno} } > 0 ) { - my $cuantos = @{ $sesbot{$interno} }; - my ( $text, $textriginal, $buttontext ) = translate( $canal, "&channels,$cuantos,$plural", "", "" ); - $return = "$interno|settext|$text"; - $botonpermanenttext{$interno} = $text; - } - else { - $botonpermanenttext{$interno} = ""; - $return = "$interno|corto|"; - } - return $return; } @@ -6612,6 +6295,15 @@ } +sub nonblock { + my $socket = shift; + my $flags; + + $flags = fcntl( $socket, F_GETFL, 0 ) + or die "Can't get flags for socket: $!\n"; + fcntl( $socket, F_SETFL, $flags | O_NONBLOCK ) + or die "Can't make socket nonblocking: $!\n"; +} + sub clean_inmemory_state_for_server { - my $server = shift; my @botones_a_limpiar; @@ -6669,5 +6361,4 @@ PeerPort => $port, Proto => "tcp", - Timeout => '2', Type => SOCK_STREAM ); @@ -6753,4 +6444,5 @@ # The closed connections belong to an asterisk manager port + my @partes = split( /\|/, $manager_socket{$socket} ); my @pp = (); my $counter = 0; @@ -6789,5 +6481,4 @@ collect_includes( "op_buttons.cfg", "buttons" ); collect_includes( "op_style.cfg", "style" ); -collect_includes( "op_server.cfg", "server" ); read_buttons_config(); read_server_config(); @@ -6797,11 +6488,5 @@ # Tries to open the listening socket -$m = new IO::Socket::INET( - Listen => 1, - LocalAddr => $listen_addr, - LocalPort => $listen_port, - ReuseAddr => 1, - Blocking => 0 - ) +$m = new IO::Socket::INET( Listen => 1, LocalAddr => $listen_addr, LocalPort => $listen_port, ReuseAddr => 1, Blocking => 0 ) or die "\nCan't listen to port $listen_port\n"; $O = new IO::Select(); @@ -6841,5 +6526,5 @@ push( @flash_clients, $C ); $O->add($C); - $C->blocking(0); + nonblock($C); } else { @@ -6959,5 +6644,4 @@ || $bloque_final =~ /Message: Mailbox/ || $bloque_final =~ /SIP-CanReinvite/ - || $bloque_final =~ /ActionID: monitor-/ || $bloque_final =~ /Message: Timeout/ ) { @@ -6970,10 +6654,4 @@ $block_count++; $bloque[$block_count]{Event} = "sippeerentrylong"; - } - elsif ( $p =~ /ActionID: monitor-/ ) { - my ( undef, $quemonitor, $quecana ) = split( /-/, $p, 3 ); - $block_count++; - $bloque[$block_count]{Event} = "response-$quemonitor"; - $bloque[$block_count]{Channel} = $quecana; } my $my_event = ""; @@ -7060,10 +6738,6 @@ send_initial_status($C); } - elsif ( $bloque_final =~ // ) { - send_policy_to_flash($C); - } else { - log_debug( "$heading No 'Event' nor 'End'. Erasing block...", 32 ) if DEBUG; - log_debug( "$bloque_final", 255 ) if DEBUG; + log_debug( "$heading No 'Event' nor 'End'. Erasing block...", 32 ) if DEBUG; # No Event in the block. Lets clear it up... @@ -7133,6 +6807,4 @@ my $largo = length($encriptadofinal); my $res = syswrite( $socket, $encriptadofinal, $largo ); - - # select( undef, undef, undef, 0.01 ); if ( defined $res && $res > 0 ) { @@ -7217,6 +6889,5 @@ @cuales_transferir = extraer_todos_los_enlaces_de_un_canal( $origin_channel, $button_server{$datosflash} ); if ( @cuales_transferir == 0 ) { - log_debug( "** !! REVERSE TRANSFER No reverse available, using regular sesbot to find the linked channels", 16 ) - if DEBUG; + log_debug( "** !! REVERSE TRANSFER No reverse available, using regular sesbot to find the linked channels", 16 ) if DEBUG; if ( $sesbot{$datosflash} ) { if ( @{ $sesbot{$datosflash} } ) { @@ -7306,6 +6977,10 @@ $elementname =~ s/\d//g; - $datosflash =~ s/_level0\.casilla(\d+)/$1/g; - $datosflash =~ s/_level0\.rectangulo(\d+).*/$1/g; + if ( $datosflash =~ /_level0\.casilla/ ) { + $datosflash =~ s/_level0\.casilla(\d+)/$1/g; + } + if ( $datosflash =~ /_level0\.rectangulo/ ) { + $datosflash =~ s/_level0\.rectangulo(\d+).*/$1/g; + } log_debug( "$heading datosflash before context $datosflash", 128 ) if DEBUG; @@ -7337,5 +7012,5 @@ if ( $accion =~ /^contexto\d+/ ) { - my ( undef, $contextoenviado ) = split( /\@/, $datosflash ); + my ( $nada, $contextoenviado ) = split( /\@/, $datosflash ); if ( defined($contextoenviado) ) { @@ -7421,8 +7096,12 @@ @pedazos = split( /&/, $canal ); $origin_context = $pedazos[1]; - ( $origin_server, $origin_channel ) = split( /\^/, $pedazos[0] ); + my @pedazos2 = split( /\^/, $pedazos[0] ); + $origin_server = $pedazos2[0]; + $origin_channel = $pedazos2[1]; } else { - ( $origin_server, $origin_channel ) = split( /\^/, $canal ); + my @pedazos2 = split( /\^/, $canal ); + $origin_server = $pedazos2[0]; + $origin_channel = $pedazos2[1]; } } @@ -7462,5 +7141,5 @@ my $local_channel_for_clid_buttons = $extension_transfer{"$origin_server^$origin_channel$contexto"}; - $local_channel_for_clid_buttons =~ s/-?\d+\^(.*)/$1/g; + $local_channel_for_clid_buttons =~ s/\d+\^(.*)/$1/g; $origin_channel = "Local/" . $local_channel_for_clid_buttons; @@ -7481,6 +7160,5 @@ if ( defined( $buttons{$indice} ) ) { $btn_num = $buttons{$indice}; - - # $btn_num =~ s/(.*)\@(.*)/$1/g; + $btn_num =~ s/(.*)\@(.*)/$1/g; } if ( $btn_num ne "0" ) { @@ -7586,17 +7264,20 @@ if ( $destino ne "0" ) { log_debug( "$heading destino es igual a $destino", 32 ) if DEBUG; - ( $destin_server, $destino ) = split( /\^/, $destino ); - ($destino) = split( /\&/, $destino ); + my @pedazos2 = split( /\^/, $destino ); + $destin_server = $pedazos2[0]; + $destino = $pedazos2[1]; + ( $destino, my $nada ) = split( /\&/, $pedazos2[1] ); log_debug( "$heading El boton de destino es $destino en el server $destin_server", 64 ) if DEBUG; } } - if ( $accion =~ /^tospy/ ) { + if ( $accion =~ /^tovoicemail/ ) { + my @cuales_transferir = get_transfer_channel( $origin_channel, $datosflash ); my $cuantos = @cuales_transferir; - if ( !defined( $tospy{$btn_destino} ) ) { - - # If there is no spy extension defined, change it to a standard + if ( !defined( $tovoicemail{$btn_destino} ) ) { + + # If there is no voicemail extension defined, change it to a standard # trasnfer if ( $cuantos > 0 ) { @@ -7608,6 +7289,7 @@ } else { + my $keyext = "$origin_server^$origin_channel"; - my $exttran = $tospy{$btn_destino}; + my $exttran = $tovoicemail{$btn_destino}; my ( $extx, $contextx ) = split( /\@/, $exttran, 2 ); @@ -7628,78 +7310,18 @@ $comando .= "Priority: 1\r\n\r\n"; } - if ( $button_server{$datosflash} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], - 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); - } + send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], + 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); $tab = substr( $tab, 0, -1 ) if DEBUG; return; - - } - - } - elsif ( $accion =~ /^tovoicemail/ ) { - - my @cuales_transferir = get_transfer_channel( $origin_channel, $datosflash ); - my $cuantos = @cuales_transferir; - - if ( !defined( $tovoicemail{$btn_destino} ) ) { - - # If there is no voicemail extension defined, change it to a standard - # trasnfer - if ( $cuantos > 0 ) { - $accion = "transferir"; - } - else { - $accion = "originate"; - } - } - else { - - my $keyext = "$origin_server^$origin_channel"; - my $exttran = $tovoicemail{$btn_destino}; - my ( $extx, $contextx ) = split( /\@/, $exttran, 2 ); - - if ( $cuantos > 0 ) { - $comando = "Action: Redirect\r\n"; - $comando .= "Channel: $cuales_transferir[0]\r\n"; - $comando .= "Exten: $extx\r\n"; - $comando .= "ActionID: 1234\r\n"; - $comando .= "Context: $contextx\r\n"; - $comando .= "Priority: 1\r\n\r\n"; - } - else { - $comando = "Action: Originate\r\n"; - $comando .= "Channel: $origin_channel\r\n"; - $comando .= "Exten: $extx\r\n"; - $comando .= "ActionID: 1234\r\n"; - $comando .= "Context: $contextx\r\n"; - $comando .= "Priority: 1\r\n\r\n"; - } - if ( $button_server{$datosflash} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], - 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); - } - - $tab = substr( $tab, 0, -1 ) if DEBUG; - return; - } - } - elsif ( $accion =~ /^voicemail/ ) { - my $vext = ""; - my $vmext = ""; - my $vcontext = ""; - my $orichannel = ""; + } + } + if ( $accion =~ /^voicemail/ ) { + my $vext = ""; + my $vcontext = ""; if ( defined( $config->{$panelcontext}{voicemail_extension} ) ) { my $voicemailext = $config->{$panelcontext}{voicemail_extension}; - ( $vmext, $orichannel ) = split( /\^/, $voicemailext ); - ( $vext, $vcontext ) = split( /\@/, $vmext ); + ( $vext, $vcontext ) = split( /\@/, $voicemailext ); } else { @@ -7709,17 +7331,13 @@ } - if ( !defined($orichannel) ) { - $orichannel = $origin_channel; - } - my $keyext = "$origin_server^$origin_channel"; if ( $contexto ne "" ) { $keyext .= "\&$contexto"; } my $vclid = $extension_transfer{$keyext}; - $vclid =~ s/-?\d+\^(.*)/$1/g; + $vclid =~ s/\d+\^(.*)/$1/g; $vclid =~ s/^Local\///g; $vclid =~ s/(.*)\@(.*)/$1/g; $comando = "Action: Originate\r\n"; - $comando .= "Channel: $orichannel\r\n"; + $comando .= "Channel: $origin_channel\r\n"; $comando .= "Callerid: $vclid <$vclid>\r\n"; $comando .= "Async: True\r\n"; @@ -7731,11 +7349,6 @@ $comando .= "\r\n"; - if ( $button_server{$datosflash} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], - 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); - } + send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], + 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); $tab = substr( $tab, 0, -1 ) if DEBUG; return; @@ -7761,38 +7374,5 @@ } - if ( $accion =~ /^startmonitor/ ) { - my $buton_number = $datosflash; - foreach my $ses ( @{ $sesbot{$buton_number} } ) { - my $monaction = ""; - my $extracomand = ""; - if ( !defined( $monitoring{$ses} ) ) { - log_debug( "$heading START MONITOR $ses -- ($origin_server $origin_channel)", 1 ); - my $unique = find_uniqueid( $ses, $origin_server ); - my ( $filename, $format ) = compute_monitoring_filename( $unique, $panelcontext ); - $monaction = "Monitor"; - $monitoring{$ses} = 1; - $extracomand .= "File: $filename\r\n"; - $extracomand .= "Format: $format\r\n"; - $extracomand .= "Mix: 1\r\n"; - } - else { - log_debug( "$heading STOP MONITOR $ses", 1 ); - $monaction = "StopMonitor"; - delete $monitoring{$ses}; - } - $comando = "Action: $monaction\r\n"; - $comando .= "Channel: $ses\r\n"; - $comando .= "ActionID: monitor-$monaction-$ses\r\n"; - $comando .= $extracomand . "\r\n"; - if ( $button_server{$datosflash} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], - 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); - } - } - } - elsif ( $accion eq "cortar" ) { + if ( $accion eq "cortar" ) { my $buton_number = $datosflash; log_debug( "$heading Will try to hangup channel para el boton $buton_number", 16 ) if DEBUG; @@ -7803,12 +7383,10 @@ $comando .= "Channel: $_\r\n\r\n"; log_debug( "-- Command received: $accion chan $_", 32 ) if DEBUG; - - if ( $button_server{$datosflash} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], - 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); - } + send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], + 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); + + # $comando = "Action: Command\r\n"; + # $comando .= "Command: soft hangup $_\r\n\r\n"; + # send_command_to_manager($comando, $p[$button_server{$datosflash}]); } } @@ -7823,12 +7401,6 @@ $comando .= "ActionID: meetmemute$boton_con_contexto\r\n"; $comando .= "Command: meetme mute $conference $meetmemember\r\n\r\n"; - - if ( $button_server{$boton_con_contexto} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $p[ $button_server{$boton_con_contexto} ], - 0, $astmanproxy_servers[ $button_server{$boton_con_contexto} ] ); - } + send_command_to_manager( $comando, $p[ $button_server{$boton_con_contexto} ], + 0, $astmanproxy_servers[ $button_server{$boton_con_contexto} ] ); } elsif ( $accion =~ /^meetmeunmute/ ) { @@ -7842,93 +7414,8 @@ $comando .= "ActionID: meetmeunmute$boton_con_contexto\r\n"; $comando .= "Command: meetme unmute $conference $meetmemember\r\n\r\n"; - - if ( $button_server{$boton_con_contexto} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $p[ $button_server{$boton_con_contexto} ], - 0, $astmanproxy_servers[ $button_server{$boton_con_contexto} ] ); - } - } - - elsif ( $accion =~ /^atxfer/ ) { - log_debug( "$heading ATXFER extension_transfer($origin_channel)", 1 ) if DEBUG; - my $nro_boton_destino = $accion; - $nro_boton_destino =~ s/^atxfer//g; - my $contextoaagregar = ""; - if ( $panelcontext ne "GENERAL" ) { - $contextoaagregar = "&$panelcontext"; - } - my $indice = $origin_server . "^" . $origin_channel . $contextoaagregar; - my $originate = $extension_transfer{$indice}; - my $transfiero_finalmente = ""; - - $originate =~ s/-?\d+\^(.*)/$1/; - foreach ( keys(%buttons) ) { - log_debug( "$heading comparing $buttons{$_} with btn_destino $btn_destino", 1 ) if DEBUG; - if ( $buttons{$_} eq $btn_destino ) { - if ( $canal =~ /^_/ ) { - my @canalarray = @{ $sesbot{$btn_destino} }; - my $canalses = $canalarray[0]; - my ( $newcanal, $newses ) = separate_session_from_channel($canalses); - $canal = $newcanal; - } - $canal =~ s/(.*)=(.*)/$1/g; - log_debug( "$heading match for $btn_destino the channel is $canal", 1 ) - if DEBUG; - my @links = extraer_todos_los_enlaces_de_un_canal( $canal, $button_server{$datosflash} ); - my @canal_transferir = @{ $sesbot{$btn_destino} }; - - foreach my $testchan (@canal_transferir) { - if ( defined( $held_channel{$testchan} ) ) { - log_debug( "$heading skip $testchan because it is on hold", 1 ); - } - else { - $transfiero_finalmente = $testchan; - } - } - - my $cuantos = @links; - if ( $cuantos <= 0 ) { - - $canal_destino = retrieve_extension( $origin_server . "^" . $origin_channel ); - if ( $canal_destino ne "-1" ) { - if ( $canal_destino =~ /\@/ ) { - ( $canal_destino, $contexto ) = split( /\@/, $canal_destino ); - } - } - $comando = "Action: Originate\r\n"; - $comando .= "Channel: $destino\r\n"; - $comando .= "Exten: $canal_destino\r\n"; - $comando .= "Context: $contexto\r\n"; - $comando .= "Priority: 1\r\n\r\n"; - } - else { - - if ( $transfiero_finalmente eq "" ) { - $transfiero_finalmente = $canal_transferir[0]; - } - - log_debug( "** $canal_transferir[0] $links[0] will be transferred to $origin_channel ($originate)", 1 ) - if DEBUG; - - my ( $vmext, $vmctx ) = split( /@/, $originate ); - $comando = "Action: Atxfer\r\n"; - $comando .= "Channel: " . $transfiero_finalmente . "\r\n"; - $comando .= "Exten: $vmext\r\n"; - $comando .= "Context: $vmctx\r\n"; - $comando .= "ActionID: atxfer\r\n"; - } - if ( $button_server{$nro_boton_destino} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $p[ $button_server{$nro_boton_destino} ], - 0, $astmanproxy_servers[ $button_server{$nro_boton_destino} ] ); - } - last; - } - } - } + send_command_to_manager( $comando, $p[ $button_server{$boton_con_contexto} ], + 0, $astmanproxy_servers[ $button_server{$boton_con_contexto} ] ); + } + elsif ( $accion =~ /^conference/ ) { log_debug( "$heading CONFERENCE extension_transfer($origin_channel)", 1 ) if DEBUG; @@ -7936,5 +7423,5 @@ my $indice = $origin_server . "^" . $origin_channel; my $originate = $extension_transfer{$indice}; - $originate =~ s/-?\d+\^(.*)/$1/; + $originate =~ s/\d+\^(.*)/$1/; foreach ( keys(%buttons) ) { log_debug( "$heading comparo $buttons{$_} con btn_destino $btn_destino", 1 ) if DEBUG; @@ -8000,11 +7487,6 @@ } } - if ( $button_server{$datosflash} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], - 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); - } + send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], + 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); last; } @@ -8018,11 +7500,6 @@ $comando .= "Command: database put clid $destino "; $comando .= "\"$clid\"\r\n\r\n"; - if ( $button_server{$datosflash} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], - 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); - } + send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], + 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); } @@ -8038,68 +7515,34 @@ if ( $canal_destino ne "-1" ) { if ( $canal_destino =~ /\@/ ) { - ( $canal_destino, $contexto ) = split( /\@/, $canal_destino ); + @pedazos = split( /\@/, $canal_destino ); + $canal_destino = $pedazos[0]; + $contexto = $pedazos[1]; } my @cuales_transferir = get_transfer_channel( $origin_channel, $datosflash ); - if ( $canal_destino eq $park_exten && $contexto eq "parkedcalls" ) { - log_debug( "$heading Will try to park $valor with announce and bounce to $canal_destino!", 16 ) + + foreach my $valor (@cuales_transferir) { + log_debug( "$heading Will try to transfer $valor to extension number $canal_destino!", 16 ) if DEBUG; - my @links; - my @canal1; - if ( $reverse_transfer == 1 ) { - @links = @{ $sesbot{$datosflash} }; - @canal1 = extraer_todos_los_enlaces_de_un_canal( $links[0], $button_server{$datosflash} ); + $comando = "Action: Redirect\r\n"; + $comando .= "Channel: $valor\r\n"; + $comando .= "Exten: $canal_destino\r\n"; + if ( $contexto ne "" ) { + $comando .= "Context: $contexto\r\n"; } - else { - @canal1 = @{ $sesbot{$datosflash} }; - @links = extraer_todos_los_enlaces_de_un_canal( $canal1[0], $button_server{$datosflash} ); + $comando .= "Priority: 1\r\n\r\n"; + send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], + 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); + + if ( $calltimeout > 0 ) { + $comando = "Action: AbsoluteTimeout\r\n"; + $comando .= "Channel: $valor\r\n"; + $comando .= "Timeout: $calltimeout\r\n"; + $comando .= "ActionID: timeout|$valor|$calltimeout\r\n"; + $comando .= "\r\n"; + send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], + , 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); } - $comando = "Action: Park\r\n"; - $comando .= "Channel: $canal1[0]\r\n"; - $comando .= "Channel2: $links[0]\r\n"; - $comando .= "Timeout: $parktimeout\r\n\r\n"; - if ( $button_server{$datosflash} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], - 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); - } - } - else { - foreach my $valor (@cuales_transferir) { - log_debug( "$heading Will try to transfer $valor to extension number $canal_destino!", 16 ) - if DEBUG; - $comando = "Action: Redirect\r\n"; - $comando .= "Channel: $valor\r\n"; - $comando .= "Exten: $canal_destino\r\n"; - if ( $contexto ne "" ) { - $comando .= "Context: $contexto\r\n"; - } - $comando .= "Priority: 1\r\n\r\n"; - if ( $button_server{$datosflash} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], - 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); - } - - if ( $calltimeout > 0 ) { - $comando = "Action: AbsoluteTimeout\r\n"; - $comando .= "Channel: $valor\r\n"; - $comando .= "Timeout: $calltimeout\r\n"; - $comando .= "ActionID: timeout|$valor|$calltimeout\r\n"; - $comando .= "\r\n"; - if ( $button_server{$datosflash} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], - , 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); - } - } - - } + } } @@ -8120,11 +7563,6 @@ $comando .= "Command: database put clid $destino "; $comando .= "\"$clid\"\r\n\r\n"; - if ( $button_server{$datosflash} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], - 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); - } + send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], + 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); } @@ -8175,9 +7613,10 @@ if ( $extension_destino =~ /\@/ ) { - ( $extension_destino, $contexto ) = split( /\@/, $extension_destino ); + @pedazos = split( /\@/, $extension_destino ); + $extension_destino = $pedazos[0]; + $contexto = $pedazos[1]; } - log_debug( "$heading Originate from $origin_channel to extension $extension_destino!", 16 ) - if DEBUG; + log_debug( "$heading Originate from $origin_channel to extension $extension_destino!", 16 ) if DEBUG; my $keyext = "$origin_server^$origin_channel"; @@ -8185,5 +7624,5 @@ my $dclid = $extension_transfer{$keyext}; - $dclid =~ s/-?\d+\^(.*)/$1/g; + $dclid =~ s/\d+\^(.*)/$1/g; $dclid =~ s/^Local\///g; $dclid =~ s/(.*)\@(.*)/$1/g; @@ -8206,11 +7645,6 @@ $comando .= "\r\n"; } - if ( $button_server{$datosflash} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], - 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); - } + send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], + 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); } elsif ( $accion =~ /^dial/ ) { @@ -8232,10 +7666,5 @@ $comando .= "Priority: 1\r\n"; $comando .= "\r\n"; - if ( $button_server{$datosflash} == -1 ) { - send_command_to_managers($comando); - } - else { - send_command_to_manager( $comando, $servidor_dial, 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); - } + send_command_to_manager( $comando, $servidor_dial, 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); } } @@ -8250,55 +7679,4 @@ } $tab = substr( $tab, 0, -1 ) if DEBUG; -} - -sub compute_monitoring_filename { - my $unique = shift; - my $panelcontext = shift; - my $filename = ""; - my $format = ""; - my @return; - my %hasha; - - if ( !defined( $config->{$panelcontext}{monitor_filename} ) ) { - $filename = $config->{GENERAL}{monitor_filename}; - } - else { - $filename = $config->{$panelcontext}{monitor_filename}; - } - if ( !defined( $config->{$panelcontext}{monitor_format} ) ) { - $format = $config->{GENERAL}{monitor_format}; - } - else { - $format = $config->{$panelcontext}{monitor_format}; - } - - while ( my ( $key, $val ) = each( %{ $datos{$unique} } ) ) { - $key =~ tr/a-z/A-Z/; - if ( $key eq "CALLERID" ) { - $key = "CLID"; - } - elsif ( $key eq "CALLERIDNUM" ) { - $key = "CLIDNUM"; - } - elsif ( $key eq "CALLERIDNAME" ) { - $key = "CLIDNAME"; - } - elsif ( $key eq "UNIQUEID" ) { - my ( $realunique, undef ) = split( /-/, $val, 2 ); - $val = $realunique; - } - $hasha{$key} = $val; - } - $filename =~ s/\${CLIDNAME}/$hasha{CLIDNAME}/gi; - $filename =~ s/\${CLIDNUM}/$hasha{CLIDNUM}/gi; - $filename =~ s/\${CLID}/$hasha{CLID}/gi; - $filename =~ s/\${UNIQUEID}/$hasha{UNIQUEID}/gi; - $filename =~ s/\${CHANNEL}/$hasha{CHANNEL}/gi; - $filename =~ s/\${LINK}/$hasha{LINK}/gi; - $filename = formatdate($filename); - $filename =~ s/\//-/gi; - push @return, $filename; - push @return, $format; - return @return; } @@ -8354,6 +7732,5 @@ log_debug( "$heading canal_destino = $canal_destino", 32 ) if DEBUG; - $canal_destino =~ s/-?\d+\^(.*)/$1/g; - $canal_destino =~ s/^-//g; + $canal_destino =~ s/\d+\^(.*)/$1/g; log_debug( "$heading La extension para $param es $canal_destino", 32 ) if DEBUG; return $canal_destino; @@ -8395,4 +7772,5 @@ my $canalid = shift; my $member = ""; + my $nada = ""; my $showagents = 0; @@ -8404,5 +7782,5 @@ } else { - ( $member, undef ) = separate_session_from_channel($canalid); + ( $member, $nada ) = separate_session_from_channel($canalid); } } @@ -8421,7 +7799,5 @@ if ( $showagents == 1 ) { - - #send_command_to_manager( "Action: Command\r\nActionId: agents\r\nCommand: show agents\r\n\r\n", $socket2 ); - send_command_to_manager( "Action: Agents\r\n\r\n", $socket2 ); + send_command_to_manager( "Action: Command\r\nActionId: agents\r\nCommand: show agents\r\n\r\n", $socket2 ); } if ( defined($member) ) { @@ -8455,5 +7831,5 @@ # If queue_hide is set, hide queue positions for my $key ( keys %buttons ) { - if ( $key =~ m/-?\d+\^QUEUE\/[^=]*=\d/i ) { + if ( $key =~ m/\d+\^QUEUE\/[^=]*=\d/i ) { $interno = $buttons{$key}; send_status_to_flash( $socket, "$interno|setalpha|00", 0 ); @@ -8552,13 +7928,7 @@ } } - if ( keys(%botonpermanenttext) ) { - for $interno ( keys %botonpermanenttext ) { - if ( $botonpermanenttext{$interno} ne "" ) { - send_status_to_flash( $socket, "$interno|settext|$botonpermanenttext{$interno}", 0 ); - } - } - } for $interno ( keys %estadoboton ) { + #if ( $estadoboton{$interno} !~ /^free/ ) { if ( $estadoboton{$interno} =~ /^busy/ ) { send_status_to_flash( $socket, "$interno|state|busy", 0 ); @@ -8571,5 +7941,4 @@ } if ( defined( $botonclid{$interno} ) ) { - my $texti = ""; if ( $botonclid{$interno} ne "" ) { send_status_to_flash( $socket, "$interno|settext|$botonclid{$interno}", 0 ); @@ -8577,4 +7946,5 @@ } + #} } if ( keys(%botonlinked) ) { @@ -8651,9 +8021,9 @@ if ( defined($socket) && $socket ne "" ) { - my ($ipactual) = split( /\|/, $manager_socket{$socket} ); - if ( $ipactual eq $ip_addy{$socket} ) { + my @pedazos = split( /\|/, $manager_socket{$socket} ); + if ( $pedazos[0] eq $ip_addy{$socket} ) { my $contador = 0; foreach my $valor (@manager_host) { - if ( $valor eq $ipactual ) { + if ( $valor eq $pedazos[0] ) { $nro_servidor = $contador; } @@ -8676,8 +8046,9 @@ send_command_to_manager( "Action: Command\r\nActionID: parkedcalls\r\nCommand: show parkedcalls\r\n\r\n", $socket ); - # request_queue_status( $socket, "initialrequest" ); + # request_queue_status( $socket, "initialrequest" ); # Send commands to check the mailbox status for each mailbox defined while ( my ( $key, $val ) = each(%mailbox) ) { - my ($servidormbox) = split( /\^/, $key ); + my @pedacitos = split( /\^/, $key ); + my $servidormbox = $pedacitos[0]; if ( "$servidormbox" eq "$nro_servidor" ) { log_debug( "$heading mailbox $ip_addy{$socket} $key $val", 32 ) if DEBUG; @@ -8707,5 +8078,7 @@ if ( $valor =~ /\^/ ) { - ( $servidormeetme, $meetmeroom ) = split( /\^/, $valor ); + my @pedacitos = split( /\^/, $valor ); + $servidormeetme = $pedacitos[0]; + $meetmeroom = $pedacitos[1]; } else { @@ -8742,4 +8115,5 @@ my $interno = ""; my $estado = ""; + my $nada = ""; my $conference = 0; my $usernum = 0; @@ -8797,59 +8171,58 @@ } } - - #elsif ( $texto =~ "ActionID: agents" ) { - # log_debug( "$heading process agents", 16 ) if DEBUG; - # my $agent_number; - # my $agent_state; - # my $agent_name; - # - # # Show Agents CLI command, generates fake events - # - # foreach (@lineas) { - # $_ =~ s/\s+/ /g; - # /(\d+) \((.*)\) (.*) (\(.*\))/; - # if ( defined($1) ) { - # $agent_number = $1; - # $agent_name = $2; - # $agent_state = $3; - # $agents_name{"$server^$agent_number"} = $agent_name; - # set_queueobject( $server, "AGENT/$agent_number", "name", $agent_name ); - # } - # - # if ( defined($3) ) { - # if ( $agent_state =~ /available at/ ) { - # - # # Agent callback login - # $agent_state =~ s/.*'(.*)'.*/$1/g; - # $bloque[$contador]{"Event"} = "Agentcallbacklogin"; - # $bloque[$contador]{"Loginchan"} = $agent_state; - # $bloque[$contador]{"Agent"} = $agent_number; - # $bloque[$contador]{"Server"} = "$server"; - # $contador++; - # } - # - # if ( $agent_state =~ /logged in on/ ) { - # - # # Agent login - # $agent_state =~ s/\s+/ /g; - # $agent_state =~ s/logged in on //g; - # $agent_state =~ s/([^ ]*).*/$1/g; - # - # $bloque[$contador]{Event} = "Agentlogin"; - # $bloque[$contador]{Channel} = $agent_state; - # $bloque[$contador]{Agent} = $agent_number; - # $bloque[$contador]{Server} = $server; - # $contador++; - # } - # if ( $agent_state =~ /not logged in/ ) { - # $bloque[$contador]{Event} = "Agentlogoff"; - # $bloque[$contador]{Agent} = $agent_number; - # $bloque[$contador]{Server} = $server; - # $bloque[$contador]{Fake} = 1; - # $contador++; - # } - # } - # } - # } + elsif ( $texto =~ "ActionID: agents" ) { + log_debug( "$heading process agents", 16 ) if DEBUG; + my $agent_number; + my $agent_state; + my $agent_name; + + # Show Agents CLI command, generates fake events + + foreach (@lineas) { + $_ =~ s/\s+/ /g; + /(\d+) \((.*)\) (.*) (\(.*\))/; + if ( defined($1) ) { + $agent_number = $1; + $agent_name = $2; + $agent_state = $3; + $agents_name{"$server^$agent_number"} = $agent_name; + set_queueobject( $server, "AGENT/$agent_number", "name", $agent_name ); + } + + if ( defined($3) ) { + if ( $agent_state =~ /available at/ ) { + + # Agent callback login + $agent_state =~ s/.*'(.*)'.*/$1/g; + $bloque[$contador]{"Event"} = "Agentcallbacklogin"; + $bloque[$contador]{"Loginchan"} = $agent_state; + $bloque[$contador]{"Agent"} = $agent_number; + $bloque[$contador]{"Server"} = "$server"; + $contador++; + } + + if ( $agent_state =~ /logged in on/ ) { + + # Agent login + $agent_state =~ s/\s+/ /g; + $agent_state =~ s/logged in on //g; + $agent_state =~ s/([^ ]*).*/$1/g; + + $bloque[$contador]{Event} = "Agentlogin"; + $bloque[$contador]{Channel} = $agent_state; + $bloque[$contador]{Agent} = $agent_number; + $bloque[$contador]{Server} = $server; + $contador++; + } + if ( $agent_state =~ /not logged in/ ) { + $bloque[$contador]{Event} = "Agentlogoff"; + $bloque[$contador]{Agent} = $agent_number; + $bloque[$contador]{Server} = $server; + $bloque[$contador]{Fake} = 1; + $contador++; + } + } + } + } elsif ( $texto =~ /ActionID: astdb-/ ) { log_debug( "$heading process astdb", 16 ) if DEBUG; @@ -8898,5 +8271,6 @@ } my $canal_a_mutear = $buttons_reverse{$quecanal}; - ( undef, $canal_a_mutear ) = split /\^/, $canal_a_mutear; + my @pedazos = split /\^/, $canal_a_mutear; + $canal_a_mutear = $pedazos[1]; $canal_a_mutear =~ s/(.*)\&(.*)/$1/g; $bloque[$contador]{"Event"} = $quecomando; @@ -8921,18 +8295,21 @@ my $estado = substr( $valor, $statPos ); $valor =~ s/\s+/ /g; - my ( $interno, $dirip ) = split( " ", $valor ); + my @parametros = split( " ", $valor ); + my $interno = $parametros[0]; if ( $interno =~ /\// ) { - ($interno) = split( /\//, $interno ); - } + my @partecitas = split( /\//, $interno ); + $interno = $partecitas[0]; + } + my $dirip = $parametros[1]; if ( defined($estado) && $estado ne "" ) { $interno = "IAX2/" . $interno . "-XXXX"; log_debug( "$heading State: $estado Extension: $interno", 32 ) if DEBUG; - $bloque[$contador]{Event} = "Regstatus"; - $bloque[$contador]{Channel} = $interno; - $bloque[$contador]{State} = $estado; - $bloque[$contador]{IP} = $dirip; - $bloque[$contador]{Server} = "$server"; + $bloque[$contador]{"Event"} = "Regstatus"; + $bloque[$contador]{"Channel"} = $interno; + $bloque[$contador]{"State"} = $estado; + $bloque[$contador]{"IP"} = $dirip; + $bloque[$contador]{"Server"} = "$server"; $contador++; } @@ -9012,6 +8389,8 @@ $valor =~ s/\s+/ /g; if ( $valor eq "" ) { next; } - my ( $interno, $dirip ) = split( " ", $valor ); - ( $interno, undef ) = split( /\//, $interno ); + my @parametros = split( " ", $valor ); + my $interno = $parametros[0]; + my $dirip = $parametros[1]; + $interno =~ s/(.*)\/(.*)/$1/g; if ( defined($interno) ) { @@ -9100,5 +8479,5 @@ if ( $canal =~ m/^CLID/ ) { my $extr = $extension_transfer{"$server^$canal"}; - $extr =~ s/-?\d+\^(.*)/$1/g; + $extr =~ s/\d+\^(.*)/$1/g; $canal = "Local/$extr"; } @@ -9155,5 +8534,5 @@ $match++; } - if ( $key eq "Server" && ( $val eq $server || $server eq "-1" ) ) { + if ( $key eq "Server" && $val eq $server ) { $match++; } @@ -9222,10 +8601,10 @@ if ( defined($_) && $_ ne "" ) { log_debug( "$heading Enviando status a " . $ip_addy{$_}, 16 ) if DEBUG; - my ($ip) = split( /\|/, $manager_socket{$_} ); - - if ( $ip eq $ip_addy{$_} ) { + my @pedazos = split( /\|/, $manager_socket{$_} ); + + if ( $pedazos[0] eq $ip_addy{$_} ) { my $contador = 0; foreach my $valor (@manager_host) { - if ( $valor eq $ip ) { + if ( $valor eq $pedazos[0] ) { $nro_servidor = $contador; } @@ -9252,5 +8631,6 @@ # Send commands to check the mailbox status for each mailbox defined while ( my ( $key, $val ) = each(%mailbox) ) { - my ($servidormbox) = split( /\^/, $key ); + my @pedacitos = split( /\^/, $key ); + my $servidormbox = $pedacitos[0]; if ( "$servidormbox" eq "$nro_servidor" ) { log_debug( "$heading mailbox $ip_addy{$_} $key $val", 32 ) if DEBUG; @@ -9262,14 +8642,4 @@ } alarm($poll_interval); -} - -sub send_policy_to_flash { - my $socket = shift; - if ( !defined($socket) ) { - log_debug( "POLICY socket $socket not open!!!", 64 ) if DEBUG; - } - my $policy = -"\r\n\r\n\r\n\r\n\r\n\0"; - actual_syswrite( $socket, $policy, "isclient", "policy enviado\n" ); } @@ -9294,14 +8664,25 @@ if ( $encriptado =~ /key\|0/ ) { $but_no = '0'; - ( $data, $cmd ) = split( /\|/, $encriptado ); + $encriptado =~ m/(.*)\|(.*)\|(.*)/; + $cmd = $2; + $data = $1; + } else { $but_no = $status; - $but_no =~ s/(\d+).*\|.*/$1/g; + $but_no =~ s/(\d+)(.*)\|(.*)/$1/g; $contexto = $status; $contexto =~ s/([^\|]*).*/$1/g; - $contexto =~ m/.*\@(.*)/; - $contexto = $1 ? $1 : ""; - ( undef, $cmd, $data ) = split( /\|/, $status ); + $contexto =~ m/(.*)\@(.*)/; + + if ( defined($2) ) { + $contexto = $2; + } + else { + $contexto = ""; + } + $status =~ m/(.*)\|(.*)\|(.*)/; + $cmd = $2; + $data = $3; if ( $contexto ne "" && $cmd ne "restrict" ) { @@ -9359,11 +8740,4 @@ } -sub send_command_to_managers { - my $comando = shift; - foreach (@p) { - send_command_to_manager( $comando, $_ ); - } -} - sub send_command_to_manager { my $comando = shift; @@ -9373,8 +8747,8 @@ my @todos_sockets = (); - # if ( !defined($socket) && $astmanproxy_server eq "" ) { - # log_debug( "No socket defined nor astmanproxy", 32 ) if DEBUG; - # return; - # } + if ( !defined($socket) && $astmanproxy_server eq "" ) { + log_debug( "No socket defined nor astmanproxy", 32 ) if DEBUG; + return; + } if ( !defined($noneedtoauth) ) { @@ -9395,4 +8769,8 @@ return; } + + # my @partes = split( /\|/, $manager_socket{$socket} ); + + # $comando = ""; if ( $comando eq "" ) { @@ -9419,116 +8797,11 @@ } -sub construct_cmd { - my $cola = shift; +sub recompute_queues { my $canalid = shift; - return $cola->{$canalid}{QUEUE} . "=" - . $cola->{$canalid}{POSITION} - . "|$_[0]|$_[1]|" - . $cola->{$canalid}{QUEUE} . "-" - . $cola->{$canalid}{SERVER} - . "|$canalid"; -} - -sub recompute_queues_onjoin { - my ( $hash_temporal, $server, $canalid ) = @_; - my @return = (); - my @corto = (); - my @ocupado = (); - my $qclidnum = ""; - my $qclidname = ""; - - if ( defined( $hash_temporal->{CallerIDName} ) ) { - $qclidnum = $hash_temporal->{CallerID}; - $qclidname = $hash_temporal->{CallerIDName}; - } - elsif ( defined( $hash_temporal->{CalleridName} ) ) { - $qclidnum = $hash_temporal->{Callerid}; - $qclidname = $hash_temporal->{CalleridName}; - } - else { - ( $qclidnum, $qclidname ) = split_callerid( $hash_temporal->{CallerID} ); - } - my $texto_pos = "[$qclidname $qclidnum]"; - - my $canal = "QUEUE/" . $hash_temporal->{Queue}; - my $position = $hash_temporal->{Position}; - $canal =~ tr/a-z/A-Z/; - my $unico_id = "$canal-$server"; - - # Verify if the position is already taken (by means of QUEUE_PRIO) - my $tengo = 0; - foreach my $id ( keys %{$cola} ) { - unless ( $cola->{$id}{QUEUE} ) { - delete( $cola->{$id} ); - next; - } - - if ( $canal eq $cola->{$id}{QUEUE} ) { - if ( $position eq $cola->{$id}{POSITION} ) { - $tengo = 1; - } - } - } - if ( $tengo == 1 ) { - - # Queue prio! - my $time = time(); - foreach my $id ( keys %{$cola} ) { - unless ( $cola->{$id}{QUEUE} ) { - delete( $cola->{$id} ); - next; - } - - if ( $canal eq $cola->{$id}{QUEUE} ) { - if ( $cola->{$id}{POSITION} >= $position ) { - my $diftime = $time - $cola->{$id}{TIME}; - if ( $queue_hide == 1 ) { - push @corto, construct_cmd( $cola, $id, "setalpha", "000" ); - } - push @corto, construct_cmd( $cola, $id, "corto", "" ); - - $cola->{$id}{POSITION}++; - my $clidtext = $cola->{$id}{CLIDNAME} . " " . $cola->{$id}{CLID}; - push @ocupado, construct_cmd( $cola, $id, "settimer", $diftime ); - push @ocupado, construct_cmd( $cola, $id, "ocupado", "[$clidtext]" ); - } - } - } - @ocupado = unique(@ocupado); - @corto = unique(@corto); - } - - # Normal, add new call at the end of the queue - push @return, "$canal=$position|ocupado2|$texto_pos|$unico_id|$canalid"; - push @return, "$canal=$position|setalpha|100|$unico_id|$canalid"; - - my $tiempo = time(); - if ( defined( $hash_temporal->{Wait} ) ) { - $tiempo = $tiempo - $hash_temporal->{Wait}; - push @return, "$canal=$position|settimer|" . $hash_temporal->{Wait} . "\@UP|$unico_id|$canalid"; - } - $cola->{$canalid}{POSITION} = $position; - $cola->{$canalid}{QUEUE} = $canal; - $cola->{$canalid}{CLID} = $qclidnum; - $cola->{$canalid}{CLIDNAME} = $qclidname; - $cola->{$canalid}{SERVER} = $server; - $cola->{$canalid}{TIME} = $tiempo; - if (@corto) { - return ( @corto, @ocupado, @return ); - } - else { - return @return; - } -} - -sub recompute_queues_onleave { - my $canalid = shift; - my @corto; - my @ocupado; + my @return_corto; + my @return_ocupado; my $maxtime = 0; - my $save_id; - my $time = time(); - - #print_recomputequeues(); + + print_recomputequeues(); my $header = "**RECOMP QUEUE"; @@ -9541,19 +8814,34 @@ if ( $queue_hide == 1 ) { - push @corto, construct_cmd( $cola, $canalid, "setalpha", "000" ); - } - push @corto, construct_cmd( $cola, $canalid, "corto", "" ); - + push @return_corto, + $cola->{$canalid}{QUEUE} . "=" + . $cola->{$canalid}{POSITION} + . "|setalpha|000|" + . $cola->{$canalid}{QUEUE} . "-" + . $cola->{$canalid}{SERVER} + . "|$canalid"; + } + push @return_corto, + $cola->{$canalid}{QUEUE} . "=" + . $cola->{$canalid}{POSITION} + . "|corto||" + . $cola->{$canalid}{QUEUE} . "-" + . $cola->{$canalid}{SERVER} + . "|$canalid"; delete $cola->{$canalid}; + my $save_id; foreach my $id ( keys %{$cola} ) { - unless ( $cola->{$id}{QUEUE} ) { + if ( !defined( $cola->{$id}{QUEUE} ) ) { delete( $cola->{$id} ); next; } + #foreach ( keys %{ $cola->{$id} } ) { + # print "key de cola $_\n"; + #} if ( $queue_to_recompute eq $cola->{$id}{QUEUE} ) { $save_id = $id; - my $diftime = $time - $cola->{$id}{TIME}; + my $diftime = time() - $cola->{$id}{TIME}; if ( $diftime > $maxtime ) { $maxtime = $diftime; @@ -9563,18 +8851,44 @@ my $clidtext = $cola->{$id}{CLIDNAME} . " " . $cola->{$id}{CLID}; if ( $queue_hide == 1 ) { - push @corto, construct_cmd( $cola, $id, "setalpha", "000" ); - } - push @corto, construct_cmd( $cola, $id, "corto", "" ); + push @return_corto, + $cola->{$id}{QUEUE} . "=" + . $cola->{$id}{POSITION} + . "|setalpha|000|" + . $cola->{$id}{QUEUE} . "-" + . $cola->{$id}{SERVER} . "|$id"; + } + push @return_corto, + $cola->{$id}{QUEUE} . "=" + . $cola->{$id}{POSITION} + . "|corto||" + . $cola->{$id}{QUEUE} . "-" + . $cola->{$id}{SERVER} . "|$id"; $cola->{$id}{POSITION}--; - push @ocupado, construct_cmd( $cola, $id, "settimer", $diftime ); - push @ocupado, construct_cmd( $cola, $id, "ocupado", "[$clidtext]" ); - - #push @ocupado, $cola->{$id}{QUEUE} . "|ocupado|[$clidtext]|" . $cola->{$id}{QUEUE} . "-" . $cola->{$id}{SERVER} . "|$id"; - push @ocupado, $cola->{$id}{QUEUE} . "|settimer|0\@STOP|" . $cola->{$id}{QUEUE} . "-" . $cola->{$id}{SERVER} . "|$id"; + push @return_ocupado, + $cola->{$id}{QUEUE} . "=" + . $cola->{$id}{POSITION} + . "|settimer|$diftime|" + . $cola->{$id}{QUEUE} . "-" + . $cola->{$id}{SERVER} . "|$id"; + push @return_ocupado, + $cola->{$id}{QUEUE} . "=" + . $cola->{$id}{POSITION} + . "|state|busy|" + . $cola->{$id}{QUEUE} . "-" + . $cola->{$id}{SERVER} . "|$id"; + push @return_ocupado, $cola->{$id}{QUEUE} . "|state|busy|" . $cola->{$id}{QUEUE} . "-" . $cola->{$id}{SERVER} . "|$id"; + push @return_ocupado, + $cola->{$id}{QUEUE} . "|settimer|0\@STOP|" . $cola->{$id}{QUEUE} . "-" . $cola->{$id}{SERVER} . "|$id"; + push @return_ocupado, + $cola->{$id}{QUEUE} . "=" + . $cola->{$id}{POSITION} + . "|settext|[$clidtext]|" + . $cola->{$id}{QUEUE} . "-" + . $cola->{$id}{SERVER} . "|$id"; } } } if ( defined($save_id) ) { - push @ocupado, + push @return_ocupado, $cola->{$save_id}{QUEUE} . "|settimer|$maxtime\@UP|" . $cola->{$save_id}{QUEUE} . "-" . $cola->{$save_id}{SERVER} . "|$save_id"; } @@ -9584,10 +8898,14 @@ delete $cola->{$canalid}; - @ocupado = unique(@ocupado); - - if (@corto) { - return ( @corto, @ocupado ); - } - + @return_ocupado = unique(@return_ocupado); + + if (@return_corto) { + my @todos = (); + push @todos, @return_corto; + push @todos, @return_ocupado; + return @todos; + } + + # TEST|corto|&waitingonqueue,0,&|TEST-0|SIP/16-ea0c } @@ -9650,4 +8968,14 @@ } +sub inArray { + my $val = shift; + for my $elem (@_) { + if ( $val eq $elem ) { + return 1; + } + } + return 0; +} + sub encode_base64 { my $res = ""; @@ -9681,6 +9009,4 @@ my $devuelve = ""; - if ( !defined($name) ) { $name = "" } - if ( $name eq "" ) { $name = ""; } @@ -9694,5 +9020,7 @@ @chars_number = split( //, $numero ); - @chars_format = reverse split( //, $format ); + @chars_format = split( //, $format ); + + @chars_format = reverse @chars_format; my $parate = 0; @@ -9720,5 +9048,6 @@ } - $devuelve = join( "", reverse @result ); + @result = reverse @result; + $devuelve = join( "", @result ); $devuelve =~ s/\${CLIDNAME}/$name/gi; return $devuelve; @@ -9789,4 +9118,5 @@ if ( !$keys_socket{$socket} ) { + print "nocrypt = 1\n"; $nocrypt = 1; } @@ -10560,25 +9890,4 @@ } -sub formatdate { - my $format = shift; - @_ = localtime( shift || time ); - my $h = sprintf( "%02d", $_[2] ); - my $i = sprintf( "%02d", $_[1] ); - my $s = sprintf( "%02d", $_[0] ); - my $m = sprintf( "%02d", $_[4] + 1 ); - my $d = sprintf( "%02d", $_[3] ); - my $y = sprintf( "%02d", ( $_[5] + 1900 ) % 100 ); - my $Y = sprintf( "%04d", $_[5] + 1900 ); - - $format =~ s/%Y/$Y/g; - $format =~ s/%y/$y/g; - $format =~ s/%h/$h/g; - $format =~ s/%i/$i/g; - $format =~ s/%s/$s/g; - $format =~ s/%m/$m/g; - $format =~ s/%d/$d/g; - return $format; -} - sub add_queueobject { my $server = shift; @@ -10588,4 +9897,5 @@ my @return; + print "add queueobject $server $queue $agent\n"; $queue_object->{$server}{$queue}{$agent}{status} = 1; @return = compute_queueobject($server); @@ -10600,4 +9910,5 @@ my @return; + print "delete queueobject $server $queue $agent\n"; delete( $queue_object->{$server}{$queue}{$agent} ); @return = compute_queueobject($server); @@ -10620,4 +9931,5 @@ if ( $iagent eq $agent ) { $queue_object->{$iserver}{$iqueue}{$iagent}{$property} = $value; + print "property set!\n"; } } Index: /unk/op_lang_ru.cfg =================================================================== --- /trunk/op_lang_ru.cfg (revision 36) +++ (revision ) @@ -1,33 +1,0 @@ -; Language configuration file -dialing=ИЎёт МабПр -calling=НабПр $1 -incoming=Ð’Ñ -ПЎящОй звПМПк Пт $1 -parked=ПаркПваМ Ма $1 -registered=ЗарегОстрОрПваМ -notregistered=Не зарегОстрОрПваМ -reachable=ДПступеМ $1 -unreachable=Не ЎПступеМ $1 -lagged=ЗавОсаМОе $1 -newold=НПвый $1, Старый $2 -waitingonqueue=$1 пПльзПватель$2 ПжОЎает -memberonconference=$1 участМОк$2 -version_mismatch=НесППтветствОе версОй клОеМта О сервера! -; client side -clid_label=ИМфП -detail_title=ППЎрПбМПстО пПслеЎМегП звПМка -detail_from=От: -detail_to=К: -detail_duration=ДлОтельМПсть: -security_code_title=ППжалуйста ввеЎОте кПЎ безПпасМПстО -btn_security_text=Открыть пПле ввПЎа кПЎа безПпасМПстО -btn_restart_text=ПерезапустОть Asterisk -btn_reload_text=ПерезагрузОть кПМфОгурацОю -btn_debug_text=Открыть/Закрыть ОкМП ОтлаЎкО -btn_help_text=Открыть ПкМП пПЌПщО -tab_call_text=ЗвПМПк -tab_queue_text=ОчереЎь -calls_taken_text=ПрОМятП звПМкПв -no_data_text=Нет ÐŽÐ°ÐœÐœÑ‹Ñ - -debug_window_title=ОкМП ОтлаЎкО Index: /unk/op_lang_gl.cfg =================================================================== --- /trunk/op_lang_gl.cfg (revision 68) +++ (revision ) @@ -1,36 +1,0 @@ -; Language configuration file -; Contributed by Roberto Salgado -dialing=A marcar -calling=A chamar a $1 -incoming=A recibir chamada de $1 -parked=Aparcado en $1 -registered=Rexistrado -notregistered=Non rexistrado -reachable =Alcanzable $1 -unreachable=Non alcanzable $1 -lagged=Demorado $1 -newold=Novos $1, Vellos $2 -waitingonqueue=$1 usuario$2 a espera -memberonconference=$1 participante$2 -version_mismatch=Versión incorrecta entre Cliente e Servidor! -; client side -clid_label=CLID -detail_title=Detalles último chamado -detail_from=De: -detail_to=A: -detail_duration=Duración: -security_code_title=Ingrese o código de seguridade -btn_security_text=Abre fiestra de ingreso de código -btn_restart_text=Reinicia Asterisk -btn_reload_text=Recarga a configuración -btn_debug_text=Abre/Pecha fiestra de Debug -btn_help_text=Abre axuda -tab_call_text=Chamada -tab_queue_text=Cola -calls_taken_text=Chamados atendidos -no_data_text=Non hai datos -debug_window_title=Fiestra de Debug -idle=Inactivo -paused=Pausa -channels=$1 chamada$2 en curso -