Changeset 5816
- Timestamp:
- 06/19/08 00:11:00 (5 years ago)
- Files:
-
- freepbx/branches/2.4 (modified) (1 prop)
- freepbx/branches/2.4/amp_conf/htdocs_panel/op_server.cfg (modified) (1 diff)
- freepbx/branches/2.4/amp_conf/htdocs_panel/op_server.pl (modified) (212 diffs)
- freepbx/branches/2.4/amp_conf/htdocs_panel/operator_panel.swf (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/branches/2.4
- Property svnmerge-integrated changed from /freepbx/branches/2.3:1-4129,4131,4133-4134,4136-4995,5088,5135,5140,5194 /freepbx/trunk:1-5453,5736,5739,5748,5750,5758,5760,5765,5771,5773,5782 to /freepbx/branches/2.3:1-4129,4131,4133-4134,4136-4995,5088,5135,5140,5194 /freepbx/trunk:1-5453,5736,5739,5748,5750,5758,5760,5765,5771,5773,5779,5782
freepbx/branches/2.4/amp_conf/htdocs_panel/op_server.cfg
r2505 r5816 8 8 9 9 [general] 10 use_amportal_conf=1 10 11 ; host or ip address of asterisk 11 12 manager_host=127.0.0.1 freepbx/branches/2.4/amp_conf/htdocs_panel/op_server.pl
r4993 r5816 1 #!/usr/bin/perl -w1 #!/usr/bin/perl 2 2 3 3 # Flash Operator Panel. http://www.asternic.org … … 22 22 23 23 use strict; 24 use warnings; 24 25 use integer; 25 26 26 use constant DEBUG => 1;27 use constant DEBUG => 0; 27 28 use constant BYTES_TO_READ => 256; 28 29 … … 34 35 use POSIX qw(setsid EWOULDBLOCK); 35 36 36 my $FOP_VERSION = " 0.27";37 my $FOP_VERSION = "SVNVERSION"; 37 38 my %datos = (); 39 my %chanvar = (); 40 my %monitoring = (); 41 my %passvar = (); 38 42 my %sesbot = (); 39 43 my %linkbot = (); … … 143 147 my %mailbox; 144 148 my %tovoicemail; 149 my %tospy; 145 150 my %instancias; 146 151 my %agent_to_channel; … … 167 172 my $web_hostname; 168 173 my $listen_port; 174 my $park_exten; 175 my $parktimeout; 169 176 my $listen_addr; 170 177 my $security_code; … … 188 195 my $queue_hide; 189 196 my $enable_restart; 197 my $passvars = ""; 190 198 my $change_led; 191 199 my $cdial_nosecure; … … 213 221 my %total_legends; 214 222 my %total_images; 215 my @btninclude = (); 216 my @styleinclude = (); 217 my $command = ""; 218 my $daemonized = 0; 219 my $pidfile = "/var/run/op_panel.pid"; 220 my $logdir = ""; 221 my $confdir = ""; 222 my $tab = ""; 223 my @serverinclude = (); 224 my @btninclude = (); 225 my @styleinclude = (); 226 my $command = ""; 227 my $daemonized = 0; 228 my $pidfile = "/var/run/op_panel.pid"; 229 my $logdir = ""; 230 my $confdir = ""; 231 my $tab = ""; 223 232 224 233 my $PADDING = join( … … 393 402 } 394 403 395 sub parse_amportal_config ($){396 my $filename = $_[0];404 sub parse_amportal_config { 405 my $filename = shift; 397 406 my %ampconf; 398 407 399 open(AMPCONF, $filename) || die "Cannot open $filename"; 400 401 while (<AMPCONF>) 402 { 403 if ($_ =~ /^\s*([a-zA-Z0-9]+)\s*=\s*(.*)\s*([;#].*)?/) { 404 $ampconf{$1} = $2; 405 } 406 } 408 open( AMPCONF, $filename ) || die "Cannot open $filename"; 409 410 while (<AMPCONF>) { 411 if ( $_ =~ /^\s*([a-zA-Z0-9]+)\s*=\s*(.*)\s*([;#].*)?/ ) { 412 $ampconf{$1} = $2; 413 } 414 } 407 415 408 416 close(AMPCONF); … … 412 420 sub read_server_config() { 413 421 my $context = ""; 422 my @distinct_files; 414 423 $counter_servers = -1; 415 424 416 425 $/ = "\n"; 417 426 418 # get some variables from the amportal config 419 my %ampconf; 420 %ampconf = parse_amportal_config("/etc/amportal.conf"); 421 422 open( CONFIG, "<$directorio/op_server.cfg" ) 423 or die("Could not open op_server.cfg. Aborting..."); 424 425 while (<CONFIG>) { 426 chomp; 427 $_ =~ s/^\s+//g; 428 $_ =~ s/([^;]*)[;](.*)/$1/g; 429 $_ =~ s/\s+$//g; 430 431 if ( /^#/ || /^;/ || /^$/ ) { 432 next; 433 } # Ignores comments and empty lines 434 435 if (/^\Q[\E/) { 436 s/\[(.*)\]/$1/g; 437 tr/a-z/A-Z/; 438 $context = $_; 439 } 440 else { 441 if ( $context ne "" ) { 442 my ( $variable_name, $value ) = split( /=/, $_ ); 443 $variable_name =~ tr/A-Z/a-z/; 444 $variable_name =~ s/\s+//g; 445 $value =~ s/^\s+//g; 446 $value =~ s/\s+$//g; 447 $value =~ s/\"//g; 448 $config->{$context}{$variable_name} = $value; 449 450 if ( $variable_name eq "manager_host" ) { 451 $counter_servers++; 452 $manager_host[$counter_servers] = $value; 453 } 454 455 if ( $variable_name eq "manager_user" ) { 456 $manager_user[$counter_servers] = $ampconf{"AMPMGRUSER"}; 457 } 458 459 if ( $variable_name eq "manager_secret" ) { 460 $manager_secret[$counter_servers] = $ampconf{"AMPMGRPASS"}; 461 } 462 463 if ( $variable_name eq "manager_port" ) { 464 $manager_port[$counter_servers] = $value; 465 } 466 467 if ( $variable_name eq "event_mask" ) { 468 $event_mask[$counter_servers] = $value; 469 } 470 471 if ( $variable_name eq "astmanproxy_server" ) { 472 push @astmanproxy_servers, $value; 473 } 474 475 } 476 } 477 } 478 close(CONFIG); 479 480 # replace some config values by the corresponding ones from amportal 481 if ( exists $ampconf{"FOPWEBADDRESS"} ) { 482 $config->{"GENERAL"}{"web_hostname"} = $ampconf{"FOPWEBADDRESS"}; 483 } else { 484 $config->{"GENERAL"}{"web_hostname"} = $ampconf{"AMPWEBADDRESS"}; 485 } 486 $config->{"GENERAL"}{"security_code"} = $ampconf{"FOPPASSWORD"}; 487 $config->{"GENERAL"}{"flash_dir"} = $ampconf{"FOPWEBROOT"}; 427 @distinct_files = unique(@serverinclude); 428 429 foreach my $archivo (@distinct_files) { 430 431 open( CONFIG, "<$directorio/$archivo" ) 432 or die("Could not open op_server.cfg. Aborting..."); 433 434 while (<CONFIG>) { 435 chomp; 436 $_ =~ s/^\s+//g; 437 $_ =~ s/([^;]*)[;](.*)/$1/g; 438 $_ =~ s/\s+$//g; 439 440 if ( /^#/ || /^;/ || /^$/ ) { 441 next; 442 } # Ignores comments and empty lines 443 444 if (/^\Q[\E/) { 445 s/\[(.*)\]/$1/g; 446 tr/a-z/A-Z/; 447 $context = $_; 448 } 449 else { 450 if ( $context ne "" ) { 451 my ( $variable_name, $value ) = split( /=/, $_ ); 452 $variable_name =~ tr/A-Z/a-z/; 453 $variable_name =~ s/\s+//g; 454 $value =~ s/^\s+//g; 455 $value =~ s/\s+$//g; 456 $value =~ s/\"//g; 457 $config->{$context}{$variable_name} = $value; 458 459 if ( $variable_name eq "manager_host" ) { 460 $counter_servers++; 461 $manager_host[$counter_servers] = $value; 462 } 463 464 if ( $variable_name eq "manager_user" ) { 465 $manager_user[$counter_servers] = $value; 466 } 467 468 if ( $variable_name eq "manager_secret" ) { 469 $manager_secret[$counter_servers] = $value; 470 } 471 472 if ( $variable_name eq "manager_port" ) { 473 $manager_port[$counter_servers] = $value; 474 } 475 476 if ( $variable_name eq "event_mask" ) { 477 $event_mask[$counter_servers] = $value; 478 } 479 480 if ( $variable_name eq "astmanproxy_server" ) { 481 push @astmanproxy_servers, $value; 482 } 483 484 } 485 } 486 } 487 close(CONFIG); 488 } 489 490 if ( defined( $config->{GENERAL}{use_amportal_conf} ) ) { 491 if ( $config->{GENERAL}{use_amportal_conf} == 1 ) { 492 my $freepbx_config = "/etc/amportal.conf"; 493 my %ampconf; 494 495 if ( -e $freepbx_config ) { 496 %ampconf = parse_amportal_config($freepbx_config); 497 $config->{"GENERAL"}{"web_hostname"} = $ampconf{"AMPWEBADDRESS"}; 498 $config->{"GENERAL"}{"security_code"} = $ampconf{"FOPPASSWORD"}; 499 $config->{"GENERAL"}{"flash_dir"} = $ampconf{"FOPWEBROOT"}; 500 $manager_user[0] = $ampconf{"AMPMGRUSER"}; 501 $manager_secret[0] = $ampconf{"AMPMGRPASS"}; 502 } 503 } 504 } 488 505 489 506 $web_hostname = $config->{GENERAL}{web_hostname}; … … 513 530 $enable_restart = $config->{GENERAL}{enable_restart}; 514 531 $defaultlanguage = $config->{GENERAL}{language}; 532 $passvars = $config->{GENERAL}{passvars}; 533 $park_exten = $config->{GENERAL}{parkexten}; 534 $parktimeout = $config->{GENERAL}{parktimeout}; 515 535 516 536 if ( $debuglevel == -1 ) { … … 539 559 540 560 $clid_format = $config->{GENERAL}{clid_format}; 541 561 if ( !defined($flash_dir) ) { $flash_dir = '/var/www/html' } 542 562 $flash_file = $flash_dir . "/variables.txt"; 543 563 push @all_flash_files, $flash_file; … … 588 608 } 589 609 610 if ( !defined $config->{GENERAL}{monitor_filename} ) { 611 $config->{GENERAL}{monitor_filename} = "\${UNIQUEID}"; 612 } 613 614 if ( !defined $config->{GENERAL}{monitor_format} ) { 615 $config->{GENERAL}{monitor_format} = "wav"; 616 } 617 590 618 if ( !defined $clid_privacy ) { 591 619 $clid_privacy = 0; … … 650 678 if ( !defined $clid_format ) { 651 679 $clid_format = "(xxx) xxx-xxxx"; 680 } 681 682 if ( !defined $passvars ) { 683 $passvars = ""; 684 } 685 686 if ( !defined $park_exten ) { 687 $park_exten = "700"; 688 } 689 690 if ( !defined $parktimeout ) { 691 $parktimeout = 45000; 692 } 693 else { 694 $parktimeout = $parktimeout * 1000; 652 695 } 653 696 … … 674 717 675 718 if ( $tipo eq "buttons" ) { 676 if ( ! inArray( $filename, @btninclude )) {719 if ( !grep { $filename eq $_ } @btninclude ) { 677 720 push( @btninclude, $filename ); 678 721 } … … 683 726 } 684 727 if ( $tipo eq "style" ) { 685 if ( ! inArray( $filename, @styleinclude )) {728 if ( !grep { $filename eq $_ } @styleinclude ) { 686 729 push( @styleinclude, $filename ); 730 } 731 else { 732 log_debug( "** $filename already included", 16 ) if DEBUG; 733 return; 734 } 735 } 736 if ( $tipo eq "server" ) { 737 if ( !grep { $filename eq $_ } @serverinclude ) { 738 push( @serverinclude, $filename ); 687 739 } 688 740 else { … … 1153 1205 my $pos = $tmphash{position}; 1154 1206 $pos =~ s/(\d+),(\d+)/$1/g; 1155 $tmphash{position} = "$pos,$pos"; 1207 my $countpos = 2; 1208 $tmphash{position} = ""; 1209 if ( defined( $tmphash{count} ) ) { 1210 $countpos = $tmphash{count}; 1211 } 1212 my $a = 0; 1213 for ( $a = 0 ; $a < $countpos ; $a++ ) { 1214 $tmphash{position} .= "$pos,"; 1215 } 1216 $tmphash{position} = substr( $tmphash{position}, 0, -1 ); 1156 1217 $no_counter = 1; 1157 1218 } … … 1218 1279 $buttons{ uc("$tmphash{server}^$chan_trunk") } = $pos; 1219 1280 $textos{$indice_contexto} = $tmphash{label}; 1220 if ( $no_counter == 0 ) { 1281 if ( !defined( $tmphash{no_label_counter} ) ) { $tmphash{no_label_counter} = 0; } 1282 if ( $no_counter == 0 && $tmphash{no_label_counter} == 0 ) { 1221 1283 $textos{$indice_contexto} .= " " . $count; 1222 1284 } … … 1376 1438 $tovoicemail{$indicevm} = $tmphash{voicemailext}; 1377 1439 } 1440 if ( defined( $tmphash{spyext} ) ) { 1441 my $indicespy = $lastposition{ $tmphash{panel_context} }; 1442 if ( $tmphash{panel_context} ne "" ) { 1443 $indicespy .= "\@$tmphash{panel_context}"; 1444 } 1445 $tospy{$indicespy} = $tmphash{spyext}; 1446 } 1447 1378 1448 $/ = "\0"; 1379 1449 } … … 1536 1606 my $contextoboton = $key; 1537 1607 if ( $contextoboton =~ m/\@/ ) { 1538 my @parte = split( /\@/, $contextoboton, 2 ); 1539 $contextoboton = $parte[1]; 1608 ( undef, $contextoboton ) = split( /\@/, $contextoboton, 2 ); 1540 1609 $contextoboton =~ tr/a-z/A-Z/; 1541 1610 } … … 1555 1624 my $contextoboton = $key; 1556 1625 if ( $contextoboton =~ m/\@/ ) { 1557 my @parte = split( /\@/, $contextoboton, 2 ); 1558 $contextoboton = $parte[1]; 1626 ( undef, $contextoboton ) = split( /\@/, $contextoboton, 2 ); 1559 1627 $contextoboton =~ tr/a-z/A-Z/; 1560 1628 } … … 1574 1642 my $contextoboton = $key; 1575 1643 if ( $contextoboton =~ m/\@/ ) { 1576 my @parte = split( /\@/, $contextoboton, 2 ); 1577 $contextoboton = $parte[1]; 1644 ($contextoboton) = split( /\@/, $contextoboton, 2 ); 1578 1645 $contextoboton =~ tr/a-z/A-Z/; 1579 1646 } … … 1594 1661 my $contextoboton = $key; 1595 1662 if ( $contextoboton =~ m/\@/ ) { 1596 my @parte = split( /\@/, $contextoboton, 2 ); 1597 $contextoboton = $parte[1]; 1663 ( undef, $contextoboton ) = split( /\@/, $contextoboton, 2 ); 1598 1664 $contextoboton =~ tr/a-z/A-Z/; 1599 1665 } … … 1614 1680 my $contextoboton = $key; 1615 1681 if ( $contextoboton =~ m/\@/ ) { 1616 my @parte = split( /\@/, $contextoboton, 2 ); 1617 $contextoboton = $parte[1]; 1682 ( undef, $contextoboton ) = split( /\@/, $contextoboton, 2 ); 1618 1683 $contextoboton =~ tr/a-z/A-Z/; 1619 1684 } … … 1782 1847 # a trunk button. 1783 1848 1784 log_debug( "$heading START SUB canalid $canalid contexto $contexto server $server canalsesion $canalsesion", 16 ) if DEBUG; 1849 log_debug( "$heading START SUB canalid $canalid contexto $contexto server $server canalsesion $canalsesion", 16 ) 1850 if DEBUG; 1785 1851 1786 1852 if ( $canalid eq "" ) { … … 1831 1897 } 1832 1898 log_debug( "$heading contexto $contexto", 32 ) if DEBUG; 1833 my ( $nada, $ses ) = separate_session_from_channel($canalsesion);1899 my ( undef, $ses ) = separate_session_from_channel($canalsesion); 1834 1900 $sesion = $ses; 1835 1901 } … … 1853 1919 } 1854 1920 1855 my $canalconcontextosinserver = $canalconcontexto;1856 $canalconcontextosinserver =~ s/(\d+)\^(.*)/$2/g;1857 1921 if ( $canalconcontexto !~ /\^/ ) { 1858 1922 $canalconcontexto = $server . "^" . $canalconcontexto; … … 1904 1968 } 1905 1969 } 1906 if ( $elemento =~ /^mISDN/i ) { 1907 if ( $elemento !~ /XXXY/ ) { 1908 $elemento .= "-XXXY"; 1909 } 1910 1911 # $elemento =~ s/(.*)\/(.*)/\U$1\E\/${2}-${2}/g; 1970 if ( $elemento =~ /^(?i:mISDN)(?!.*XXXY)/ ) { 1971 $elemento .= "-XXXY"; 1912 1972 } 1913 1973 elsif ( $elemento =~ /^SRX/i ) { … … 1915 1975 } 1916 1976 elsif ( $elemento =~ /^CAPI\//i ) { 1917 $elemento =~ s/(CAPI\/)(.*)\/(.*)-(.*)/$1$2-$4/g; 1918 } 1919 1977 $elemento =~ s/(CAPI\/)(.*)\/.*-(.*)/$1$2-$3/g; 1978 } 1979 1980 $elemento =~ s/^asyncgoto\///gi; 1920 1981 $elemento =~ s/(.*)[-\/](.*)/$1\t$2/g; 1921 1982 log_debug( "$heading elemento2 $elemento", 32 ) if DEBUG; 1922 1983 my $canal = $1; 1923 1984 my $sesion = $2; 1924 log_debug( "$heading canal $canal sesion $sesion", 32 ) if DEBUG;1925 1985 1926 1986 if ( defined($canal) && defined($sesion) ) { 1927 1987 $canal =~ tr/a-z/A-Z/; 1928 1988 $elemento = $canal . "\t" . $sesion; 1989 log_debug( "$heading canal $canal sesion $sesion", 32 ) if DEBUG; 1929 1990 } 1930 1991 $elemento =~ s/IAX2\[(.*)@(.*)\]\t(.*)/IAX2\[$1\]\t$3/; 1931 1992 $elemento =~ s/IAX2\/(.*)@(.*)\t(.*)/IAX2\/$1\t$3/; 1932 1993 1933 my @partes = split( /\t/, $elemento ); 1934 return @partes; 1994 return split( /\t/, $elemento ); 1935 1995 } 1936 1996 … … 1957 2017 sub erase_instances_for_trunk_buttons { 1958 2018 1959 my $canalid = shift; 1960 my $canal = shift; 1961 my $server = shift; 1962 my $canalidsinserver = ""; 2019 my $canalid = shift; 2020 my $canal = shift; 2021 my $server = shift; 1963 2022 my $canalglobal; 1964 my $valor;1965 my @new = ();1966 2023 my $heading = "** ERASE_INSTANCE_TRUNK"; 1967 2024 1968 $canalidsinserver = $canalid; 1969 $canalid = "$server^$canalid"; 2025 my $solocanal = $canalid; 2026 $solocanal =~ s/[^\w]//g; 2027 2028 $canalid = "$server^$canalid"; 1970 2029 $canalid =~ s/(.*)<(.*)>/$1/g; #discards ZOMBIE or MASQ 1971 2030 … … 1977 2036 $canalglobal =~ s/IAX2\[(.*)@(.*)\]/IAX2\[$1\]/g; 1978 2037 1979 my ( $nada, $contexto ) = split( /\&/, $canal ); 1980 if ( !defined($contexto) ) { $contexto = ""; } 1981 1982 my $canalconcontexto = ""; 1983 if ( $contexto ne "" ) { 1984 $canalconcontexto = "$canalglobal&$contexto"; 1985 $contexto = "&$contexto"; 1986 } 1987 else { 1988 $canalconcontexto = $canalglobal; 1989 $contexto = ""; 1990 } 2038 my ( undef, $contexto ) = split( /\&/, $canal ); 2039 $contexto = $contexto ? "&$contexto" : ""; 1991 2040 1992 2041 my $sesiontemp = $canalid; … … 1994 2043 log_debug( "$heading looking for $canalid on instancias to erase it", 128 ) if DEBUG; 1995 2044 1996 foreach my $key1 ( sort ( keys(%instancias) )) {1997 foreach my $key2 ( sort ( keys( %{ $instancias{$key1} } ) ) ) {1998 if ( $key2 eq $canalid ) {1999 delete $instancias{$key1}{$key2};2000 log_debug( "$heading Erasing $canalid from instanacias!", 128 ) if DEBUG;2001 }2002 }2045 if ( $canal =~ m/^DID|^CLID/ ) { 2046 $canal =~ s/(.*)=.*/$1/g; 2047 $canalid = $server . "^" . $canal . "-" . $solocanal; 2048 } 2049 foreach my $key1 ( keys(%instancias) ) { 2050 delete $instancias{$key1}{$canalid}; 2051 log_debug( "$heading Erasing $canalid from instanacias!", 128 ) if DEBUG; 2003 2052 } 2004 2053 } … … 2017 2066 } 2018 2067 2019 my ( $nada1, $contexto1 ) = split( /\&/, $nroboton );2068 my ( undef, $contexto1 ) = split( /\&/, $nroboton ); 2020 2069 if ( !defined($contexto1) ) { $contexto1 = ""; } 2021 2070 … … 2033 2082 my @linkbotones = find_panel_buttons( $canal1, $canalsesion, $server ); 2034 2083 foreach my $cual (@linkbotones) { 2035 my ( $nada2, $contexto2 ) = split( /\&/, $cual );2084 my ( undef, $contexto2 ) = split( /\&/, $cual ); 2036 2085 if ( !defined($contexto2) ) { $contexto2 = ""; } 2037 2086 if ( $contexto1 eq $contexto2 ) { … … 2101 2150 log_debug( "$heading borro cache_hit($indice_cache)", 128 ) if DEBUG; 2102 2151 delete $cache_hit{$indice_cache}; 2152 delete $monitoring{$canalsesion}; 2103 2153 if ( keys(%cache_hit) ) { 2104 2154 for ( keys %cache_hit ) { … … 2176 2226 log_debug( "** Found a match $canalid=$val ($quehay) - Cleared!", 16 ) if DEBUG; 2177 2227 delete $datos{$quehay}; 2228 delete $chanvar{$quehay}; 2229 delete $passvar{$quehay}; 2178 2230 } 2179 2231 } … … 2201 2253 # Removes the context if its set 2202 2254 2203 my @pedazos = split( /&/, $canal ); 2204 $canal = $pedazos[0]; 2255 ($canal) = split( /&/, $canal ); 2205 2256 2206 2257 # Checks if the channel name has an equal sign … … 2253 2304 my $server = ""; 2254 2305 2255 my @pedazos = split( /&/, $canal ); 2256 $canal = $pedazos[0]; 2306 ($canal) = split( /&/, $canal ); 2257 2307 2258 2308 if ( $canal =~ /\^/ ) { 2259 @pedazos = split( /\^/, $canal ); 2260 $server = $pedazos[0]; 2261 $canal = $pedazos[1]; 2309 ( $server, $canal ) = split( /\^/, $canal ); 2262 2310 } 2263 2311 … … 2296 2344 print_datos(1); 2297 2345 2298 my @pedazos = split( /&/, $canal ); 2299 $canal = $pedazos[0]; 2346 ($canal) = split( /&/, $canal ); 2300 2347 2301 2348 if ( $canal =~ /\^/ ) { 2302 @pedazos = split( /\^/, $canal ); 2303 $server = $pedazos[0]; 2304 $canal = $pedazos[1]; 2349 ( $server, $canal ) = split( /\^/, $canal ); 2305 2350 } 2306 2351 … … 2323 2368 $canalaqui = 1; 2324 2369 } 2325 if ( $key =~ /^Server/i && $val eq $server) {2370 if ( $key =~ /^Server/i && ( $val eq $server || $server eq "-1" ) ) { 2326 2371 $serveraqui = 1; 2327 2372 log_debug( "$heading server coincide $server = $val\n", 16 ) if DEBUG; … … 2364 2409 my $heading = "** FIND_PANEL_BUT"; 2365 2410 my $calleridnum = "noexiste"; 2411 my $didnum = "noexiste"; 2366 2412 my %trunk_matched = (); 2367 2413 … … 2375 2421 2376 2422 my $uniqueid = find_uniqueid( $canalsesion, $server ); 2377 if ( $uniqueid ne "" ) { 2378 if ( defined( $datos{$uniqueid}{"CallerID"} ) ) { 2379 $calleridnum = $datos{$uniqueid}{"CallerID"}; 2423 if ($uniqueid) { 2424 if ( defined( $datos{$uniqueid}{CallerID} ) ) { 2425 $calleridnum = $datos{$uniqueid}{CallerID}; 2426 } 2427 if ( defined( $datos{$uniqueid}{Extension} ) 2428 && defined( $datos{$uniqueid}{AppData} ) 2429 && $datos{$uniqueid}{AppData} =~ m/^FROM_DID/ ) 2430 { 2431 $didnum = $datos{$uniqueid}{"Extension"}; 2380 2432 } 2381 2433 } … … 2495 2547 # Attemp to match a button from cache 2496 2548 $indice_cache = $canalsesion . "-" . $canal . "-" . $server; 2497 if ( !defined( $cache_hit{$indice_cache} ) ) {2549 if ( !defined( $cache_hit{$indice_cache} ) || $didnum ne "noexiste" ) { 2498 2550 log_debug( "$heading CACHE MISS $indice_cache", 32 ) if DEBUG; 2499 2551 for ( keys %buttons ) { 2500 2552 $server = $server_original; 2501 2553 $canalfinal = ""; 2502 my ( $nada, $contexto ) = split( "\&", $_ );2554 my ( undef, $contexto ) = split( "\&", $_ ); 2503 2555 if ( !defined($contexto) ) { $contexto = ""; } 2504 2556 if ( $contexto ne "" ) { $contexto = "&" . $contexto; } … … 2528 2580 } 2529 2581 } 2582 elsif ( $_ =~ /^$server\^CLID\/\Q$calleridnum\E=/ ) { 2583 my $solocanal = $canalsesion; 2584 $solocanal =~ s/[^\w]//g; 2585 my $tcanal = "CLID/" . $calleridnum . "-" . $solocanal; 2586 if ( !exists( $trunk_matched{"$server^CLID/$calleridnum"} ) ) { 2587 $canalfinal = get_next_trunk_button( $tcanal, $contexto, $server, $tcanal ); 2588 if ( $canalfinal ne "" ) { 2589 log_debug( "$heading clid match trunk ( $_ ) $canal $contexto", 32 ) if DEBUG; 2590 $trunk_matched{"$server^CLID/$calleridnum"} = 1; 2591 $canalfinal =~ s/(.*)\^(.*)/$2/g; 2592 } 2593 } 2594 } 2530 2595 elsif ( $_ =~ /^$server\^CLID\/\Q$calleridnum\E\&?/ ) { 2531 2532 2596 log_debug( "$heading clid match ( $_ ) $canal $contexto", 32 ) if DEBUG; 2533 2597 $canalfinal = "CLID/$calleridnum"; 2598 } 2599 elsif ( $_ =~ /^$server\^DID\/\Q$didnum\E=/ ) { 2600 my $solocanal = $canalsesion; 2601 $solocanal =~ s/[^\w]//g; 2602 my $tcanal = "DID/" . $didnum . "-" . $solocanal; 2603 if ( !exists( $trunk_matched{"$server^DID/$didnum"} ) ) { 2604 $canalfinal = get_next_trunk_button( $tcanal, $contexto, $server, $tcanal ); 2605 if ( $canalfinal ne "" ) { 2606 log_debug( "$heading did match trunk ( $_ ) $canal $contexto", 32 ) if DEBUG; 2607 $trunk_matched{"$server^DID/$didnum"} = 1; 2608 $canalfinal =~ s/(.*)\^(.*)/$2/g; 2609 } 2610 } 2611 } 2612 elsif ( $_ =~ /^$server\^DID\/\Q$didnum\E\&?/ ) { 2613 log_debug( "$heading did match ( $_ ) $canal $contexto", 32 ) if DEBUG; 2614 $canalfinal = "DID/$didnum"; 2534 2615 } 2535 2616 … … 2559 2640 $canalfinal = ""; 2560 2641 2561 my $nada1 = "";2562 2642 my $contextemp = ""; 2563 2643 my %contextosencontrados; 2564 2644 for my $val (@canales) { 2565 ( $nada1, $contextemp ) = split( "&", $val );2645 ( undef, $contextemp ) = split( "&", $val ); 2566 2646 if ( !defined($contextemp) ) { $contextemp = ""; } 2567 2647 $contextosencontrados{"&$contextemp"} = 1; … … 2677 2757 while ( my ( $key, $val ) = each(%bloque) ) { 2678 2758 if ( defined($val) ) { 2679 $val =~ s/ (.*)\s+$/$1/g;2759 $val =~ s/\s+$//; 2680 2760 } 2681 2761 else { … … 2685 2765 } 2686 2766 2767 if ( defined( $hash_temporal{Application} ) ) { 2768 2769 # Chanvar hash stores the complete list of channel variables 2770 # that are "SET" in the dialplan for a given Uniqueid 2771 if ( $hash_temporal{Application} eq "Set" ) { 2772 my @vardata = split( /\|/, $hash_temporal{AppData} ); 2773 foreach my $vara (@vardata) { 2774 my ( $vari, $valu ) = split( /=/, $vara ); 2775 $vari =~ s/^_.?//g; 2776 $chanvar{ $hash_temporal{Uniqueid} }{$vari} = $valu; 2777 } 2778 } 2779 } 2687 2780 if ( defined( $hash_temporal{Channel} ) ) { 2688 2781 if ( $hash_temporal{Channel} =~ /^Agent/ ) { … … 2724 2817 while ( my ( $key, $val ) = each(%hash_temporal) ) { 2725 2818 if ( defined($val) && $val =~ /\^/ ) { 2726 my @partes = split( /\^/, $val, 2 ); 2727 $hash_temporal{$key} = $partes[0]; 2728 my $resto_de_parametros = $partes[1]; 2729 @partes = split( /\^/, $resto_de_parametros ); 2819 2820 #my @partes = split( /\^/, $val, 2 ); 2821 #$hash_temporal{$key} = $partes[0]; 2822 #my $resto_de_parametros = $partes[1]; 2823 ( $hash_temporal{$key}, my $resto ) = split( /\^/, $val, 2 ); 2824 my @partes = split( /\^/, $resto ); 2730 2825 foreach my $value (@partes) { 2731 2826 my @partes2 = split( /: /, $value ); … … 2787 2882 if ( defined( $hash_temporal{"ActionID"} ) ) { 2788 2883 if ( $hash_temporal{"ActionID"} =~ /^timeout/i ) { 2789 my @partes = split( /\|/, $hash_temporal{"ActionID"} ); 2790 $canalid = $partes[1]; 2791 $timeout = $partes[2]; 2884 ( $canalid, $timeout ) = split( /\|/, $hash_temporal{"ActionID"} ); 2792 2885 $evento = "Timeout"; 2793 2886 $unico_id = "YYYY-$server"; … … 2825 2918 } 2826 2919 2920 # Convert Asterisk 1.4 Originate responses to 1.2 format so attendant transfers work 2921 if ( $evento eq "OriginateResponse" ) { 2922 if ( $hash_temporal{Response} eq "Success" ) { 2923 $evento = "OriginateSuccess"; 2924 } 2925 else { 2926 $evento = "OriginateFailure"; 2927 } 2928 } 2929 2930 # Convert Asterisk 1.4 ParkedCalltimeout to UnParkedCall 2931 if ( $evento eq "ParkedCallTimeOut" ) { 2932 $evento = "UnParkedCall"; 2933 } 2934 2827 2935 $evento =~ s/UserEvent//g; 2828 if ( $evento =~ /Newchannel/ ) { $evento = "newchannel"; } 2829 elsif ( $evento =~ /Newcallerid/ ) { $evento = "newcallerid"; } 2830 elsif ( $evento =~ /^Status$/ ) { $evento = "status"; } 2831 elsif ( $evento =~ /^StatusComplete/ ) { $evento = "statuscomplete"; } 2832 elsif ( $evento =~ /Newexten/ ) { $evento = "newexten"; } 2833 elsif ( $evento =~ /^ParkedCall$/ ) { $evento = "parkedcall"; } 2834 elsif ( $evento =~ /^UnParkedCall$/ ) { $evento = "unparkedcall"; } 2835 elsif ( $evento =~ /Newstate/ ) { $evento = "newstate"; } 2836 elsif ( $evento =~ /Hangup/ ) { $evento = "hangup"; } 2837 elsif ( $evento =~ /Rename/ ) { $evento = "rename"; } 2838 elsif ( $evento =~ /MessageWaiting/ ) { $evento = "voicemail"; } 2839 elsif ( $evento =~ /Regstatus/ ) { $evento = "regstatus"; } 2840 elsif ( $evento =~ /^Unlink/ ) { $evento = "unlink"; } 2841 elsif ( $evento =~ /QueueParams/ ) { $evento = "queueparams"; } 2842 elsif ( $evento =~ /PeerEntry/ ) { $evento = "peerentry"; } 2843 elsif ( $evento =~ /QueueEntry/ ) { $evento = "queueentry"; } 2844 elsif ( $evento =~ /^QueueMember$/ ) { $evento = "queuemember"; } 2845 elsif ( $evento =~ /^QueueMemberStatus$/ ) { $evento = "queuememberstatus"; } 2846 elsif ( $evento =~ /QueueMemberAdded/ ) { $evento = "queuememberadded"; } 2847 elsif ( $evento =~ /QueueMemberRemoved/ ) { $evento = "queuememberremoved"; } 2848 elsif ( $evento =~ /QueueMemberPaused/ ) { $evento = "queuememberpaused"; } 2849 elsif ( $evento =~ /QueueStatus$/ ) { $evento = "queuestatus"; } 2850 elsif ( $evento =~ /QueueStatusComplete/ ) { $evento = "queuestatuscomplete"; } 2851 elsif ( $evento =~ /^Link/ ) { $evento = "link"; } 2852 elsif ( $evento =~ /^Join/ ) { $evento = "join"; } 2853 elsif ( $evento =~ /^MeetmeJoin/ ) { $evento = "meetmejoin"; } 2854 elsif ( $evento =~ /^MeetmeLeave/ ) { $evento = "meetmeleave"; } 2855 elsif ( $evento =~ /^meetmemute/ ) { $evento = "meetmemute"; } 2856 elsif ( $evento =~ /^meetmeunmute/ ) { $evento = "meetmeunmute"; } 2857 elsif ( $evento =~ /^Agentlogin/ ) { $evento = "agentlogin"; } 2858 elsif ( $evento =~ /^RefreshQueue/ ) { $evento = "refreshqueue"; } 2859 elsif ( $evento =~ /^Timeout/ ) { $evento = "timeout"; } 2860 elsif ( $evento =~ /^AgentCalled/ ) { $evento = "agentcalled"; } 2861 elsif ( $evento =~ /^AgentConnect/ ) { $evento = "agentconnect"; } 2862 elsif ( $evento =~ /^AgentComplete/ ) { $evento = "agentcomplete"; } 2863 elsif ( $evento =~ /^Agentcallbacklogin/ ) { $evento = "agentcblogin"; } 2864 elsif ( $evento =~ /^Agentcallbacklogoff/ ) { $evento = "agentlogoff"; } 2865 elsif ( $evento =~ /^Agentlogoff/ ) { $evento = "agentlogoff"; } 2866 elsif ( $evento =~ /^IsMeetmeMember/ ) { $evento = "fakeismeetmemember"; } 2867 elsif ( $evento =~ /^PeerStatus/ ) { $evento = "peerstatus"; } 2868 elsif ( $evento =~ /^Leave/ ) { $evento = "leave"; } 2869 elsif ( $evento =~ /^FOP_Popup/i ) { $evento = "foppopup"; } 2870 elsif ( $evento =~ /^FOP_LedColor/i ) { $evento = "fopledcolor"; } 2871 elsif ( $evento =~ /^Dial/ ) { $evento = "dial"; } 2872 elsif ( $evento =~ /^ASTDB/ ) { $evento = "astdb"; } 2873 elsif ( $evento =~ /^DNDState/ ) { $evento = "zapdndstate"; } 2874 elsif ( $evento =~ /^ZapShowChannels$/ ) { $evento = "zapdndstate"; } 2875 elsif ( $evento =~ /^ExtensionStatus$/ ) { $evento = "extensionstatus"; } 2876 elsif ( $evento =~ /^OriginateSuccess$/ ) { $evento = "originatesuccess"; } 2877 elsif ( $evento =~ /^OriginateFailure$/ ) { $evento = "originatefailure"; } 2878 elsif ( $evento =~ /^ChannelReload$/ ) { $evento = "channelreload"; } 2936 if ( $evento =~ /Newchannel/ ) { $evento = "newchannel"; } 2937 elsif ( $evento =~ /Newcallerid/ ) { $evento = "newcallerid"; } 2938 elsif ( $evento =~ /^Status$/ ) { $evento = "status"; } 2939 elsif ( $evento =~ /^StatusComplete/ ) { $evento = "statuscomplete"; } 2940 elsif ( $evento =~ /Newexten/ ) { $evento = "newexten"; } 2941 elsif ( $evento =~ /^ParkedCall$/ ) { $evento = "parkedcall"; } 2942 elsif ( $evento =~ /^UnParkedCall$/ ) { $evento = "unparkedcall"; } 2943 elsif ( $evento =~ /^virtualvaletparkedcall/i ) { $evento = "parkedcall"; } 2944 elsif ( $evento =~ /^virtualvaletunparkedcall$/i ) { $evento = "unparkedcall"; } 2945 elsif ( $evento =~ /Newstate/ ) { $evento = "newstate"; } 2946 elsif ( $evento =~ /Hangup/ ) { $evento = "hangup"; } 2947 elsif ( $evento =~ /Rename/ ) { $evento = "rename"; } 2948 elsif ( $evento =~ /MessageWaiting/ ) { $evento = "voicemail"; } 2949 elsif ( $evento =~ /Regstatus/ ) { $evento = "regstatus"; } 2950 elsif ( $evento =~ /^Unlink/ ) { $evento = "unlink"; } 2951 elsif ( $evento =~ /QueueParams/ ) { $evento = "queueparams"; } 2952 elsif ( $evento =~ /PeerEntry/ ) { $evento = "peerentry"; } 2953 elsif ( $evento =~ /QueueEntry/ ) { $evento = "queueentry"; } 2954 elsif ( $evento =~ /^QueueMember$/ ) { $evento = "queuemember"; } 2955 elsif ( $evento =~ /^QueueMemberStatus$/ ) { $evento = "queuememberstatus"; } 2956 elsif ( $evento =~ /QueueMemberAdded/ ) { $evento = "queuememberadded"; } 2957 elsif ( $evento =~ /QueueMemberRemoved/ ) { $evento = "queuememberremoved"; } 2958 elsif ( $evento =~ /QueueMemberPaused/ ) { $evento = "queuememberpaused"; } 2959 elsif ( $evento =~ /QueueStatus$/ ) { $evento = "queuestatus"; } 2960 elsif ( $evento =~ /QueueStatusComplete/ ) { $evento = "queuestatuscomplete"; } 2961 elsif ( $evento =~ /^Link/ ) { $evento = "link"; } 2962 elsif ( $evento =~ /^Join/ ) { $evento = "join"; } 2963 elsif ( $evento =~ /^MeetmeJoin/ ) { $evento = "meetmejoin"; } 2964 elsif ( $evento =~ /^MeetmeLeave/ ) { $evento = "meetmeleave"; } 2965 elsif ( $evento =~ /^meetmemute/ ) { $evento = "meetmemute"; } 2966 elsif ( $evento =~ /^meetmeunmute/ ) { $evento = "meetmeunmute"; } 2967 elsif ( $evento =~ /^Agentlogin/ ) { $evento = "agentlogin"; } 2968 elsif ( $evento =~ /^Agents$/ ) { $evento = "agents"; } 2969 elsif ( $evento =~ /^RefreshQueue/ ) { $evento = "refreshqueue"; } 2970 elsif ( $evento =~ /^Timeout/ ) { $evento = "timeout"; } 2971 elsif ( $evento =~ /^AgentCalled/ ) { $evento = "agentcalled"; } 2972 elsif ( $evento =~ /^AgentConnect/ ) { $evento = "agentconnect"; } 2973 elsif ( $evento =~ /^AgentComplete/ ) { $evento = "agentcomplete"; } 2974 elsif ( $evento =~ /^Agentcallbacklogin/ ) { $evento = "agentcblogin"; } 2975 elsif ( $evento =~ /^Agentcallbacklogoff/ ) { $evento = "agentlogoff"; } 2976 elsif ( $evento =~ /^Agentlogoff/ ) { $evento = "agentlogoff"; } 2977 elsif ( $evento =~ /^IsMeetmeMember/ ) { $evento = "fakeismeetmemember"; } 2978 elsif ( $evento =~ /^PeerStatus/ ) { $evento = "peerstatus"; } 2979 elsif ( $evento =~ /^Leave/ ) { $evento = "leave"; } 2980 elsif ( $evento =~ /^FOP_Popup/i ) { $evento = "foppopup"; } 2981 elsif ( $evento =~ /^FOP_LedColor/i ) { $evento = "fopledcolor"; } 2982 elsif ( $evento =~ /^Dial/ ) { $evento = "dial"; } 2983 elsif ( $evento =~ /^ASTDB/ ) { $evento = "astdb"; } 2984 elsif ( $evento =~ /^DNDState/ ) { $evento = "zapdndstate"; } 2985 elsif ( $evento =~ /^ZapShowChannels$/ ) { $evento = "zapdndstate"; } 2986 elsif ( $evento =~ /^ExtensionStatus$/ ) { $evento = "extensionstatus"; } 2987 elsif ( $evento =~ /^OriginateSuccess$/ ) { $evento = "originatesuccess"; } 2988 elsif ( $evento =~ /^OriginateFailure$/ ) { $evento = "originatefailure"; } 2989 elsif ( $evento =~ /^ChannelReload$/ ) { $evento = "channelreload"; } 2990 elsif ( $evento =~ /^response-/ ) { $evento = "monitor"; } 2879 2991 else { log_debug( "$heading No event match ($evento)", 32 ); } 2880 2992 … … 2895 3007 } 2896 3008 2897 if ( $evento eq "channelreload" ) { 3009 if ( $evento eq "monitor" ) { 3010 my $botinro = ""; 3011 ( undef, $estado_final, undef ) = split( /-/, $hash_temporal{ActionID}, 3 ); 3012 ( $canal, undef ) = separate_session_from_channel( $hash_temporal{Channel} ); 3013 $canalid = $hash_temporal{Channel}; 3014 $estado_final =~ tr/A-Z/a-z/; 3015 } 3016 elsif ( $evento eq "channelreload" ) { 2898 3017 2899 3018 # Event: ChannelReload … … 2917 3036 my $indice = $hash_temporal{Uniqueid} . "-" . $hash_temporal{Server}; 2918 3037 if ( exists( $datos{"$indice"} ) ) { 2919 log_debug( "** ATTENDANT we had that uniqueid before, extract the channel from there", 16 ) if DEBUG; 3038 log_debug( "** ATTENDANT we had that uniqueid before, extract the channel from there", 16 ) 3039 if DEBUG; 2920 3040 if ( defined( $datos{$indice}{Extension} ) ) { 2921 3041 … … 2930 3050 } 2931 3051 else { 2932 log_debug( "** ATTENDANT we do not have any event with that uniqueid, save for later", 16 ) if DEBUG; 3052 log_debug( "** ATTENDANT we do not have any event with that uniqueid, save for later", 16 ) 3053 if DEBUG; 2933 3054 print_datos(99); 2934 3055 $pending_uniqueid_attendant{ $hash_temporal{Uniqueid} } = $hash_temporal{Exten} . "@" . $hash_temporal{Context}; … … 2972 3093 } 2973 3094 2974 while ( ( $key, $val ) = each(%mute_other) ) { 2975 log_debug( "Mute other after originate failure: $key = $val", 16 ) if DEBUG; 2976 } 2977 while ( ( $key, $val ) = each(%pending_uniqueid_attendant) ) { 2978 log_debug( "Pending uniqueid attendant after originate failure: $key = $val", 16 ) if DEBUG; 2979 } 3095 if (DEBUG) { 3096 while ( ( $key, $val ) = each(%mute_other) ) { 3097 log_debug( "Mute other after originate failure: $key = $val", 16 ); 3098 } 3099 while ( ( $key, $val ) = each(%pending_uniqueid_attendant) ) { 3100 log_debug( "Pending uniqueid attendant after originate failure: $key = $val", 16 ); 3101 } 3102 } 3103 2980 3104 my $tempval = $config->{$contexto}{'attendant_failure_redirect_to'}; 2981 3105 $tempval =~ s/\${CHANNEL}/$hash_temporal{Channel}/g; … … 2984 3108 2985 3109 if ( $tempval =~ m/\@/ ) { 2986 my @partes = split( /\@/, $tempval, 2 ); 2987 $dst_exten = $partes[0]; 2988 $dst_context = $partes[1]; 3110 ( $dst_exten, $dst_context ) = split( /\@/, $tempval, 2 ); 2989 3111 } 2990 3112 else { … … 3031 3153 #TalkTime: 557 3032 3154 #Reason: agent 3033 my ( $canal, $nada) = separate_session_from_channel( $hash_temporal{Channel} );3155 my ( $canal, undef ) = separate_session_from_channel( $hash_temporal{Channel} ); 3034 3156 request_queue_status( $socket, $canal ); 3035 3157 my @respuestas = set_queueobject( $server, $canal, "status", 1 ); … … 3169 3291 $estado_final = "ringing"; 3170 3292 $canal = $hash_temporal{"AgentCalled"}; 3171 $canal =~ tr/a-z/A-Z/; 3293 my $unique = find_uniqueid( $hash_temporal{ChannelCalling}, $server ); 3294 $unique =~ s/(.*)-.*/$1/g; 3295 $canal =~ tr/a-z/A-Z/; 3172 3296 $canalid = $canal . "-XXXX"; 3173 3297 $clidnum = $hash_temporal{"CallerID"}; … … 3176 3300 my $base64_clidnum = encode_base64( $clidnum . " " ); 3177 3301 my $base64_clidname = encode_base64( $clidname . " " ); 3302 3303 foreach my $var ( split( /\|/, $passvars ) ) { 3304 if ( defined( $chanvar{$unique}{$var} ) ) { 3305 my $base64_var = encode_base64( $chanvar{$unique}{$var} ); 3306 push @return, "$canal|setvar|$var=$base64_var|$canalid-$server|$canalid"; 3307 } 3308 } 3178 3309 push @return, "$canal|clidnum|$base64_clidnum|$canalid-$server|$canalid"; 3179 3310 push @return, "$canal|clidname|$base64_clidname|$canalid-$server|$canalid"; … … 3207 3338 my $dorigen = ""; 3208 3339 my $ddestino = ""; 3209 my $dnada = "";3210 3340 $remote_callerid{$key} = $hash_temporal{"CallerID"}; 3211 3341 $remote_callerid_name{$key} = $hash_temporal{"CallerIDName"}; 3342 3343 foreach my $var ( split( /\|/, $passvars ) ) { 3344 if ( defined( $chanvar{ $hash_temporal{"SrcUniqueID"} }{$var} ) ) { 3345 $passvar{ $hash_temporal{"DestUniqueID"} }{$var} = $chanvar{ $hash_temporal{"SrcUniqueID"} }{$var}; 3346 } 3347 } 3212 3348 3213 3349 if ( $hash_temporal{'Source'} =~ m/^Local/i ) { … … 3217 3353 # so we can map outgoing calls to Agent buttons 3218 3354 # It will only work after the agent receives at least one call 3219 ( $dorigen, $dnada) = separate_session_from_channel( $hash_temporal{'Source'} );3220 ( $ddestino, $dnada) = separate_session_from_channel( $hash_temporal{'Destination'} );3355 ( $dorigen, undef ) = separate_session_from_channel( $hash_temporal{'Source'} ); 3356 ( $ddestino, undef ) = separate_session_from_channel( $hash_temporal{'Destination'} ); 3221 3357 if ( exists( $channel_to_agent{"$server^$dorigen"} ) ) { 3222 3358 my $agente = $channel_to_agent{"$server^$dorigen"}; … … 3261 3397 my $valor = ""; 3262 3398 $estado_final = "astdb"; 3263 ( $canal, my $nada) = separate_session_from_channel( $hash_temporal{"Channel"} );3399 ( $canal, undef ) = separate_session_from_channel( $hash_temporal{"Channel"} ); 3264 3400 $canalid = $hash_temporal{"Channel"} . "-XXXX"; 3265 3401 my $clave = $hash_temporal{"Family"}; … … 3309 3445 # XXXX It will have to store this value internally in future version 3310 3446 # to avoid polling asterisk every time 3311 ( $canal, my $nada) = separate_session_from_channel( $hash_temporal{"Channel"} );3447 ( $canal, undef ) = separate_session_from_channel( $hash_temporal{"Channel"} ); 3312 3448 $texto = $hash_temporal{"IP"}; 3313 3449 my $serv = $hash_temporal{"Server"}; … … 3325 3461 my $color = ""; 3326 3462 my $state = ""; 3327 ( $canal, my $nada) = separate_session_from_channel( $hash_temporal{"Channel"} );3463 ( $canal, undef ) = separate_session_from_channel( $hash_temporal{"Channel"} ); 3328 3464 $color = $hash_temporal{"Color"}; 3329 3465 $state = $hash_temporal{"State"}; … … 3333 3469 } 3334 3470 elsif ( $evento eq "foppopup" ) { 3335 ( $canal, my $nada) = separate_session_from_channel( $hash_temporal{"Channel"} );3471 ( $canal, undef ) = separate_session_from_channel( $hash_temporal{"Channel"} ); 3336 3472 my $url = $hash_temporal{"URL"}; 3337 3473 my $target = $hash_temporal{"Target"}; … … 3344 3480 } 3345 3481 elsif ( $evento eq "refreshqueue" ) { 3346 ( $canal, my $nada) = separate_session_from_channel( $hash_temporal{"Channel"} );3482 ( $canal, undef ) = separate_session_from_channel( $hash_temporal{"Channel"} ); 3347 3483 3348 3484 # Turns off led of the agent that generated the refresh … … 3394 3530 # so we populate some internal structures. If not, its a fake 3395 3531 # callbacklogin from the show agents cli command 3396 ( $canal, my $nada) = separate_session_from_channel( $datos{$unico_id}{Channel} );3532 ( $canal, undef ) = separate_session_from_channel( $datos{$unico_id}{Channel} ); 3397 3533 $canal =~ tr/a-z/A-Z/; 3398 3534 } … … 3414 3550 # in op_buttons.cfg. 3415 3551 $canal = $extension_transfer_reverse{$ext_transf_key}; 3416 $canal =~ s/(.*)&(.*)/$1/g;3552 ( $canal, undef ) = split( /&/, $canal ); 3417 3553 if ( $canal =~ /\^/ ) { 3418 my @pedacete = split( /\^/, $canal ); 3419 $canal = $pedacete[1]; 3554 ( undef, $canal ) = split( /\^/, $canal ); 3420 3555 } 3421 3556 } … … 3568 3703 3569 3704 } 3705 elsif ( $evento eq "agents" ) { 3706 3707 #Event: Agents 3708 #Agent: 609 3709 #Name: Nicolas 3710 #Status: AGENT_LOGGEDOFF 3711 #LoggedInChan: n/a 3712 #LoggedInTime: 0 3713 #TalkingTo: n/a 3714 my $agent_number = $hash_temporal{Agent}; 3715 my $agent_name = $hash_temporal{Name}; 3716 my $agent_status = $hash_temporal{Status}; 3717 my $agent_logchan = $hash_temporal{LoggedInChan}; 3718 3719 $agents_name{"$server^$agent_number"} = $agent_name; 3720 set_queueobject( $server, "AGENT/$agent_number", "name", $agent_name ); 3721 3722 if ( $agent_status eq "AGENT_IDLE" ) { 3723 3724 # Agent callback login, idle 3725 my $agevent = ""; 3726 if ( $agent_logchan =~ /.*\/.*-.*/ ) { 3727 $fake_bloque[$fakecounter]{"Event"} = "Agentlogin"; 3728 $fake_bloque[$fakecounter]{"Channel"} = $agent_logchan; 3729 } 3730 else { 3731 $fake_bloque[$fakecounter]{"Event"} = "Agentcallbacklogin"; 3732 $fake_bloque[$fakecounter]{"Loginchan"} = $agent_logchan; 3733 } 3734 $fake_bloque[$fakecounter]{"Agent"} = $agent_number; 3735 $fake_bloque[$fakecounter]{"Name"} = $agent_name; 3736 $fake_bloque[$fakecounter]{"Server"} = "$server"; 3737 $fakecounter++; 3738 } 3739 elsif ( $agent_status eq "AGENT_ONCALL" ) { 3740 3741 # Agent login 3742 $fake_bloque[$fakecounter]{Event} = "Agentlogin"; 3743 $fake_bloque[$fakecounter]{Channel} = $agent_logchan; 3744 $fake_bloque[$fakecounter]{Agent} = $agent_number; 3745 $fake_bloque[$fakecounter]{Server} = $server; 3746 $fakecounter++; 3747 } 3748 elsif ( $agent_status eq "AGENT_LOGEDOFF" ) { 3749 $fake_bloque[$fakecounter]{Event} = "Agentlogoff"; 3750 $fake_bloque[$fakecounter]{Agent} = $agent_number; 3751 $fake_bloque[$fakecounter]{Server} = $server; 3752 $fake_bloque[$fakecounter]{Fake} = 1; 3753 $fakecounter++; 3754 } 3755 3756 } 3570 3757 elsif ( $evento eq "agentlogin" ) { 3571 3758 … … 3576 3763 3577 3764 # This catches a live real Agentlogin event 3578 ( my $canalreal, my $nada) = separate_session_from_channel( $datos{$unico_id}{Channel} );3765 ( my $canalreal, undef ) = separate_session_from_channel( $datos{$unico_id}{Channel} ); 3579 3766 $canalreal =~ tr/a-z/A-Z/; 3580 3767 $channel_to_agent{"$server^$canalreal"} = "Agent/$texto"; 3581 3768 $agent_to_channel{"$server^Agent/$texto"} = $canalreal; 3582 log_debug( "channel_to_agent($server^$canalreal) = " . $channel_to_agent{"$server^$canalreal"}, 64 ) if DEBUG; 3769 log_debug( "channel_to_agent($server^$canalreal) = " . $channel_to_agent{"$server^$canalreal"}, 64 ) 3770 if DEBUG; 3583 3771 if ( !defined( $hash_temporal{Fake} ) || $hash_temporal{Fake} ne "init" ) { 3584 3772 my @respuestas = set_queueobject( $server, "AGENT/$texto", "status", 1 ); … … 3740 3928 $estado_final = "changelabel" . $change_led; 3741 3929 3742 if ( defined( $agent_to_channel{"$server^Agent/$canal"} ) || defined( $channel_to_agent{"$server^$canal"} ) ) { 3930 if ( defined( $agent_to_channel{"$server^Agent/$canal"} ) 3931 || defined( $channel_to_agent{"$server^$canal"} ) ) 3932 { 3743 3933 if ( defined( $agent_to_channel{"$server^Agent/$canal"} ) ) { 3744 3934 $canal = $agent_to_channel{"$server^Agent/$canal"}; … … 3812 4002 if ( defined( $hash_temporal{Queue} ) ) { 3813 4003 $valor = $hash_temporal{Queue}; 3814 if ( exists( $agents_available_on_queue{"$server^$valor"} ) && $agents_available_on_queue{"$server^$valor"} ne "" ) { 4004 if ( exists( $agents_available_on_queue{"$server^$valor"} ) 4005 && $agents_available_on_queue{"$server^$valor"} ne "" ) 4006 { 3815 4007 my $texto3 = ""; 3816 4008 foreach my $qmem ( @{ $agents_available_on_queue{"$server^$valor"} } ) { … … 4035 4227 } 4036 4228 elsif ( $evento eq "meetmemute" || $evento eq "meetmeunmute" ) { 4037 my ( $canal, $nada) = separate_session_from_channel($canalid);4229 my ( $canal, undef ) = separate_session_from_channel($canalid); 4038 4230 $estado_final = $evento; 4039 4231 push @return, "$canal|$evento||$unico_id|$canalid"; … … 4066 4258 } 4067 4259 elsif ( $evento eq "join" ) { 4068 my $qclidnum = "";4069 my $qclidname = "";4070 4260 $canal = "QUEUE/" . $hash_temporal{Queue}; 4071 4261 my $position = $hash_temporal{Position}; … … 4077 4267 $unico_id = "$canal-$server"; 4078 4268 4079 if ( defined( $hash_temporal{CallerIDName} ) ) {4080 $qclidnum = $hash_temporal{CallerID};4081 $qclidname = $hash_temporal{CallerIDName};4082 }4083 elsif ( defined( $hash_temporal{CalleridName} ) ) {4084 $qclidnum = $hash_temporal{Callerid};4085 $qclidname = $hash_temporal{CalleridName};4086 }4087 else {4088 ( $qclidnum, $qclidname ) = split_callerid( $hash_temporal{CallerID} );4089 }4090 my $texto_pos = "[$qclidname $qclidnum]";4091 4092 4269 push @return, "$canal|$estado_final|$texto|$unico_id|$canalid"; 4093 push @return, "$canal=$position|$estado_final|$texto_pos|$unico_id|$canalid"; 4094 push @return, "$canal=$position|setalpha|100|$unico_id|$canalid"; 4270 my @queue_events = recompute_queues_onjoin( \%hash_temporal, $server, $canalid ); 4271 foreach my $valor (@queue_events) { 4272 push @return, $valor; 4273 } 4095 4274 $evento = ""; 4096 4097 my $tiempo = time(); 4098 if ( defined( $hash_temporal{Wait} ) ) { 4099 $tiempo = $tiempo - $hash_temporal{Wait}; 4100 push @return, "$canal=$position|settimer|$hash_temporal{Wait}\@UP|$unico_id|$canalid"; 4101 } 4102 $cola->{$canalid}{POSITION} = $position; 4103 $cola->{$canalid}{QUEUE} = $canal; 4104 $cola->{$canalid}{CLID} = $qclidnum; 4105 $cola->{$canalid}{CLIDNAME} = $qclidname; 4106 $cola->{$canalid}{SERVER} = $server; 4107 $cola->{$canalid}{TIME} = $tiempo; 4108 4275 } 4276 elsif ( $evento eq "leave" ) { 4277 $canal = "QUEUE/" . $hash_temporal{"Queue"}; 4278 $canal =~ tr/a-z/A-Z/; 4279 $estado_final = "ocupado"; 4280 my $plural = ""; 4281 if ( $hash_temporal{"Count"} > 1 ) { $plural = "s"; } 4282 if ( $hash_temporal{"Count"} == 0 ) { $estado_final = "corto"; } 4283 $texto = "&waitingonqueue," . $hash_temporal{"Count"} . ",$plural&"; 4284 $unico_id = "$canal-$server"; 4285 push @return, "$canal|$estado_final|$texto|$unico_id|$canalid"; 4286 $evento = ""; 4287 4288 print_sesbot(1); 4289 my @queue_events = recompute_queues_onleave($canalid); 4290 foreach my $valor (@queue_events) { 4291 push @return, $valor; 4292 } 4293 print_sesbot(2); 4109 4294 } 4110 4295 elsif ( $evento eq "meetmejoin" ) { 4111 4296 my $originate = "no"; 4112 4297 my $mute_other_party = "no"; 4113 my $nada = "";4114 4298 my $contexto = ""; 4115 4299 … … 4289 4473 } 4290 4474 my $canalfin = get_meetme_pos( $server, $canal, $position ); 4475 my ( $ca1, $se1 ) = separate_session_from_channel( $hash_temporal{Channel} ); 4476 push @return, "$ca1|$estado_final|$texto_pos|YYYY-$server|$hash_temporal{Channel}"; 4291 4477 push @return, "$canalfin|$estado_final|$texto_pos|YYYY-$server|$hash_temporal{Channel}"; 4292 4478 push @return, "$canalfin|meetmeuser|$hash_temporal{Usernum},$hash_temporal{Meetme}|YYYY-$server|$hash_temporal{Channel}"; … … 4314 4500 } 4315 4501 4316 my ( $canal1, $nada1) = separate_session_from_channel($canaleja);4502 my ( $canal1, undef ) = separate_session_from_channel($canaleja); 4317 4503 push @return, "$canal1|unsetlink|$canal|$unico_id|$canalid"; 4318 4504 $evento = ""; … … 4321 4507 delete $meetme_pos{"$server^$canal"}{ $hash_temporal{Usernum} }; 4322 4508 push @return, "$canalfin|corto||$hash_temporal{Uniqueid}-$server|$canaleja"; 4323 }4324 elsif ( $evento eq "leave" ) {4325 $canal = "QUEUE/" . $hash_temporal{"Queue"};4326 $canal =~ tr/a-z/A-Z/;4327 $estado_final = "ocupado";4328 my $plural = "";4329 if ( $hash_temporal{"Count"} > 1 ) { $plural = "s"; }4330 if ( $hash_temporal{"Count"} == 0 ) { $estado_final = "corto"; }4331 $texto = "&waitingonqueue," . $hash_temporal{"Count"} . ",$plural&";4332 $unico_id = "$canal-$server";4333 push @return, "$canal|$estado_final|$texto|$unico_id|$canalid";4334 $evento = "";4335 4336 print_sesbot(1);4337 my @queue_events = recompute_queues($canalid);4338 foreach my $valor (@queue_events) {4339 push @return, $valor;4340 }4341 print_sesbot(2);4342 4509 } 4343 4510 elsif ( $evento eq "voicemail" ) { … … 4355 4522 $unico_id = $canal; 4356 4523 $canalid = $canal . "-XXXX"; 4357 if ( defined( $hash_temporal{"Waiting"} ) ) { 4524 if ( defined( $hash_temporal{Waiting} ) ) { 4525 4358 4526 $estado_final = "voicemail"; 4359 $texto = $hash_temporal{"Waiting"}; 4360 4361 #$texto = 1; 4362 if ( $texto eq "1" ) { 4363 4364 # If it has new voicemail, ask for mailboxcount 4527 $texto = $hash_temporal{Waiting}; 4528 4529 if ( $texto eq "0" ) { 4530 4531 # If it does not have new voicemail, ask for mailboxcount to get old mails 4365 4532 send_command_to_manager( "Action: MailboxCount\r\nMailbox: $hash_temporal{Mailbox}\r\n\r\n", 4366 4533 $socket, 0, $astmanproxy_server ); 4367 4534 } 4535 else { 4536 4537 # If it has new voicemail, look for the New and Old headers 4538 if ( defined( $hash_temporal{New} ) ) { 4539 my $nuevos = $hash_temporal{"New"}; 4540 my $viejos = $hash_temporal{"Old"}; 4541 push @return, "$canal|voicemailcount|&newold,$nuevos,$viejos|$unico_id-$server|$canal-XXXX"; 4542 } 4543 else { 4544 send_command_to_manager( "Action: MailboxCount\r\nMailbox: $hash_temporal{Mailbox}\r\n\r\n", 4545 $socket, 0, $astmanproxy_server ); 4546 } 4547 } 4368 4548 } 4369 4549 else { 4550 4551 # This is the actual message count event 4370 4552 $estado_final = "voicemailcount"; 4371 4553 my $nuevos = $hash_temporal{"NewMessages"}; … … 4534 4716 4535 4717 if ( $nuevo_nombre =~ /<ZOMBIE>/ ) { 4536 log_debug( "$heading $nuevo_nombre, asterisk bug, sometimes misses the hangup, so we fake it", 64 ) if DEBUG; 4537 my ( $canalnuevo, $nada ) = separate_session_from_channel($nuevo_nombre); 4718 log_debug( "$heading $nuevo_nombre, asterisk bug, sometimes misses the hangup, so we fake it", 64 ) 4719 if DEBUG; 4720 my ( $canalnuevo, undef ) = separate_session_from_channel($nuevo_nombre); 4538 4721 push @return, "$canalnuevo|corto||$unico_id|$nuevo_nombre"; 4539 4722 } … … 4579 4762 4580 4763 if ( defined($canalcambiado) ) { 4581 my ( $canalito, $nada) = separate_session_from_channel($canalcambiado);4764 my ( $canalito, undef ) = separate_session_from_channel($canalcambiado); 4582 4765 push @return, "$canalito|$estado_final|$nuevo_nombre|$unico_id|$canalcambiado"; 4583 ( $canalito, $nada) = separate_session_from_channel($nuevo_nombre);4766 ( $canalito, undef ) = separate_session_from_channel($nuevo_nombre); 4584 4767 push @return, "$canalito|$estado_final|$canalcambiado|$unico_id|$nuevo_nombre"; 4585 4768 $canal = $canalito; … … 4631 4814 $texto = "&unreachable,$tiempo"; 4632 4815 } 4816 elsif ( $state eq "Unregistered" ) { 4817 $estado_final = "noregistrado"; 4818 $texto = "¬registered"; 4819 } 4633 4820 elsif ( $state eq "Lagged" ) { 4634 4821 $estado_final = "noregistrado"; … … 4667 4854 my $hay_activos = 0; 4668 4855 4669 for ( keys %datos ) { 4670 my $ignorame = 0; 4671 my @pedazote = split( /-/, $_ ); 4672 my $current_server = $pedazote[1]; 4856 foreach my $dkey ( keys %datos ) { 4857 my $ignorame = 0; 4858 my ( undef, $current_server ) = split( /-/, $dkey ); 4673 4859 if ( "$server" ne "$current_server" ) { 4674 4860 next; 4675 4861 } 4676 4862 4677 log_debug( "$heading STATUSCOMPLETE datos { $ _}", 128 ) if DEBUG;4678 push @ids, $ _;4863 log_debug( "$heading STATUSCOMPLETE datos { $dkey }", 128 ) if DEBUG; 4864 push @ids, $dkey; 4679 4865 my $myevent = "Newexten"; 4680 while ( my ( $key, $val ) = each( %{ $datos{$ _} } ) ) {4866 while ( my ( $key, $val ) = each( %{ $datos{$dkey} } ) ) { 4681 4867 log_debug( "$heading STATUSCOMPLETE datos { $key } = $val", 128 ) if DEBUG; 4682 4683 4868 if ( defined($val) ) { 4684 4869 $hay_activos = 1; … … 4756 4941 $estado_final = "meetmeuser"; 4757 4942 $texto = $hash_temporal{Usernum} . "," . $hash_temporal{Meetme}; 4758 my ( $chan1, $nada1) = separate_session_from_channel( $hash_temporal{Channel} );4943 my ( $chan1, undef ) = separate_session_from_channel( $hash_temporal{Channel} ); 4759 4944 push @return, "$hash_temporal{Meetme}|setlink|$hash_temporal{Channel}||$hash_temporal{Channel}"; 4760 4945 push @return, "$chan1|setlink|$hash_temporal{Meetme}||$hash_temporal{Channel}"; … … 4764 4949 elsif ( $evento eq "newexten" ) { 4765 4950 4766 # print "newexten\n";4767 4768 4951 # If its a new extension without state and priority 1, defaults to 'Up' and set setlid 4952 if ( !defined( $hash_temporal{'Priority'} ) ) { 4953 $hash_temporal{'Priority'} = 1; 4954 } 4769 4955 if ( !defined( $datos{$unico_id}{'State'} ) && $hash_temporal{Priority} == 1 ) { 4770 4956 $datos{$unico_id}{'State'} = "Up"; 4771 4957 log_debug( "$heading POPULATES datos($unico_id){ State } = Up", 128 ) if DEBUG; 4772 4958 ( $canal, $sesion ) = separate_session_from_channel( $hash_temporal{Channel} ); 4773 $texto = $hash_temporal{Extension}; 4774 if($texto ne "s") { 4775 $estado_final = "setclid"; 4776 } 4777 } 4778 else { 4779 # print "Newexten pero otro priority?\n"; 4959 $texto = $hash_temporal{Extension}; 4960 if ( $texto ne "s" ) { 4961 $estado_final = "setclid"; 4962 } 4780 4963 } 4781 4964 … … 4801 4984 log_debug( "Save " . $hash_temporal{Channel} . " as pending", 16 ) if DEBUG; 4802 4985 } 4803 4804 4986 4805 4987 } … … 4878 5060 } 4879 5061 elsif ( $evento eq "parkedcall" ) { 4880 $texto = "&parked," . $hash_temporal{'Exten'} . "&"; 5062 my $parksl = ""; 5063 if ( defined( $hash_temporal{LotName} ) ) { 5064 $parksl = $hash_temporal{LotName} . "-" . $hash_temporal{Exten}; 5065 } 5066 else { 5067 $parksl = $hash_temporal{Exten}; 5068 } 5069 $texto = "&parked," . $parksl . "&"; 4881 5070 $estado_final = "ocupado3"; 4882 my ( $canal, $nada) = separate_session_from_channel( $hash_temporal{'Channel'} );5071 my ( $canal, undef ) = separate_session_from_channel( $hash_temporal{'Channel'} ); 4883 5072 my $textid = ""; 4884 5073 my $timeout = ""; 4885 5074 my $unidchan = find_uniqueid( $hash_temporal{'Channel'}, $server ); 4886 $textid = $datos{$unidchan}{'Callerid'} 4887 if ( defined( $datos{$unidchan}{'Callerid'} ) ); 4888 $textid = $datos{$unidchan}{'CallerID'} 4889 if ( defined( $datos{$unidchan}{'CallerID'} ) ); 4890 $timeout = "(" . $hash_temporal{'Timeout'} . ")"; 5075 if ( defined( $hash_temporal{CallerID} ) ) { 5076 $textid = $hash_temporal{CallerID} . " " . $hash_temporal{CallerIDName}; 5077 } 5078 else { 5079 $textid = $datos{$unidchan}{Callerid} 5080 if ( defined( $datos{$unidchan}{Callerid} ) ); 5081 $textid = $datos{$unidchan}{CallerID} 5082 if ( defined( $datos{$unidchan}{CallerID} ) ); 5083 } 5084 $timeout = "(" . $hash_temporal{Timeout} . ")"; 4891 5085 $textid =~ s/\"//g; 4892 5086 $textid =~ s/\<//g; 4893 5087 $textid =~ s/\>//g; 4894 5088 push @return, "$canal|ocupado3|$texto|$unidchan|$canalid"; 4895 push @return, "PARK/$ hash_temporal{'Exten'}|park|[$textid]$timeout|$hash_temporal{'Timeout'}-$server|$hash_temporal{'Channel'}";4896 4897 log_debug( "$heading pongo parked($server^$hash_temporal{'Channel'}) en $ hash_temporal{'Exten'}", 64 ) if DEBUG;4898 $parked{"$server^$hash_temporal{'Channel'}"} = $ hash_temporal{'Exten'};5089 push @return, "PARK/$parksl|park|[$textid]$timeout|$hash_temporal{'Timeout'}-$server|$hash_temporal{'Channel'}"; 5090 5091 log_debug( "$heading pongo parked($server^$hash_temporal{'Channel'}) en $parksl", 64 ) if DEBUG; 5092 $parked{"$server^$hash_temporal{'Channel'}"} = $parksl; 4899 5093 $evento = ""; #NEW 4900 5094 } … … 4922 5116 # Dont check for $evento bellow this line! 4923 5117 4924 # print "AFTER IF ELSE IF evento = $evento\n";4925 4926 5118 if ( $evento ne "" ) { 4927 log_debug( "$heading Event $evento, canal '$canal' ", 32 ) if DEBUG;5119 log_debug( "$heading Event $evento, canal '$canal', estadofinal $estado_final", 32 ) if DEBUG; 4928 5120 4929 5121 # De acuerdo a los datos de la extension genera … … 5022 5214 if ( $clidnum ne "" ) { 5023 5215 my $base64_clidnum = encode_base64( $clidnum . " " ); 5024 $ret = "$canal|clidnum|$base64_clidnum|$unico_id|$hash_temporal{ 'Channel'}";5216 $ret = "$canal|clidnum|$base64_clidnum|$unico_id|$hash_temporal{Channel}"; 5025 5217 push @return, $ret; 5026 5218 } 5027 5219 if ( defined($clidname) ) { 5028 5220 my $base64_clidname = encode_base64( $clidname . " " ); 5029 $ret = "$canal|clidname|$base64_clidname|$unico_id|$hash_temporal{ 'Channel'}";5221 $ret = "$canal|clidname|$base64_clidname|$unico_id|$hash_temporal{Channel}"; 5030 5222 push @return, $ret; 5031 5223 } 5224 foreach my $var ( keys %{ $passvar{ $hash_temporal{Uniqueid} } } ) { 5225 my $base64_var = encode_base64( $passvar{ $hash_temporal{Uniqueid} }{$var} ); 5226 $ret = "$canal|setvar|$var=$base64_var|$unico_id|$hash_temporal{Channel}"; 5227 push @return, $ret; 5228 } 5229 delete $passvar{ $hash_temporal{Uniqueid} }; 5032 5230 } 5033 5231 … … 5037 5235 5038 5236 if ( $state eq "Ring" ) { 5039 # print "RING $canalid $texto\n";5040 $ texto = $canalid;5041 $estado_final = "ring"; 5042 $datos{$unico_id}{'Origin'} = "true";5043 log_debug( "$heading POPULATES datos($unico_id){ Origin } = true", 128 ) if DEBUG;5237 $texto = $canalid; 5238 $estado_final = "ring"; 5239 5240 #$datos{$unico_id}{'Origin'} = "true"; 5241 #log_debug( "$heading POPULATES datos($unico_id){ Origin } = true", 128 ) if DEBUG; 5044 5242 } 5045 5243 … … 5214 5412 5215 5413 my $cuantos = $#return + 1; 5216 log_debug( "$heading returns $cuantos", 16 ) if DEBUG;5217 foreach (@return) {5218 log_debug( "$heading END SUB returns $_", 32 ) if DEBUG;5414 if (DEBUG) { 5415 log_debug( "$heading returns $cuantos", 16 ); 5416 log_debug( "$heading END SUB returns $_", 32 ) foreach (@return); 5219 5417 } 5220 5418 $tab = substr( $tab, 0, -1 ); … … 5260 5458 $canal =~ s/(.*)&(.*)/$1/g; 5261 5459 5262 # if( $canal =~ m/^CLID/ ) {5263 # my $extr = $extension_transfer{"$server^$canal"};5264 # $extr =~ s/\d+\^(.*)/$1/g;5265 # $canal = "Local/$extr";5266 # }5267 5268 5460 log_debug( "** LOCAL_CHANNELS devuelvo $server canal $canal", 32 ) if DEBUG; 5461 5462 # If channel has a pipe due to REGEXP button, replace it with something else because 5463 # procesa_bloque use pipes to return data to digest_event_block 5464 $canal =~ s/\|/~/g; 5269 5465 push @return, $server; 5270 5466 push @return, $canal; … … 5296 5492 $tab = $tab . "\t" if DEBUG; 5297 5493 5298 log_debug( "$heading start", 16 ) if DEBUG;5494 log_debug( "$heading start", 256 ) if DEBUG; 5299 5495 5300 5496 @fake_bloque = (); 5301 5497 5302 # delete $datos{""};5303 5498 foreach my $blaque (@blique) { 5304 5499 … … 5317 5512 } 5318 5513 @mensajes = procesa_bloque( $blaque, $socket, $astmanproxy_server ); 5514 5319 5515 foreach my $mensaje (@mensajes) { 5320 5516 if ( defined($mensaje) && $mensaje ne "" ) { 5321 log_debug( "$heading GOT $mensaje", 32) if DEBUG;5517 log_debug( "$heading GOT $mensaje", 256 ) if DEBUG; 5322 5518 delete $datos{""}; # Erase the hash with no uniqueid 5323 5519 ( $canal, $quehace, $dos, $uniqueid, $canalid ) = split( /\|/, $mensaje ); 5324 5520 5521 # change back newflo into pipes 5522 $canal =~ s/~/\|/g; 5523 $canalid =~ s/~/\|/g; 5325 5524 $canalid =~ s/(.*),(\d)/$1/g; # discard ,2 on Local channels 5326 5525 … … 5329 5528 5330 5529 if ( $canal =~ /\/PSEUDO/ ) { 5331 log_debug( "$heading Ignoring pseudo channel $canal", 32) if DEBUG;5530 log_debug( "$heading Ignoring pseudo channel $canal", 256 ) if DEBUG; 5332 5531 next; 5333 5532 } 5334 5533 5335 5534 if ( $dos eq "skip" ) { 5336 log_debug( "$heading skipping $canal $quehace (has skip)", 32) if DEBUG;5535 log_debug( "$heading skipping $canal $quehace (has skip)", 256 ) if DEBUG; 5337 5536 next; 5338 5537 } 5339 5538 5340 5539 if ( $quehace eq "" ) { 5341 log_debug( "$heading skipping $canal (empty quehace)", 32 ) if DEBUG; 5342 # print "skip empty\n"; 5540 log_debug( "$heading skipping $canal (empty quehace)", 256 ) if DEBUG; 5343 5541 next; 5344 5542 } 5345 5543 5346 log_debug( "$heading canal: $canal", 32 ) if DEBUG; 5347 log_debug( "$heading quehace: $quehace", 32 ) if DEBUG; 5348 log_debug( "$heading dos: $dos", 32 ) if DEBUG; 5349 log_debug( "$heading uniqueid: $uniqueid", 32 ) if DEBUG; 5350 log_debug( "$heading canalid: $canalid", 32 ) if DEBUG; 5351 5352 $canalid =~ s/\s+//g; # Removes whitespace from CHANNEL-ID 5353 my $real_canal = $canalid; 5354 my $canalidzombie = $canalid; # Removes whitespace from CHANNEL-ID 5355 $canalid =~ s/(.*)<(.*)>/$1/g; # discards ZOMBIE or MASQ 5544 log_debug( "$heading canal: $canal", 256 ) if DEBUG; 5545 log_debug( "$heading quehace: $quehace", 256 ) if DEBUG; 5546 log_debug( "$heading dos: $dos", 256 ) if DEBUG; 5547 log_debug( "$heading uniqueid: $uniqueid", 256 ) if DEBUG; 5548 log_debug( "$heading canalid: $canalid", 256 ) if DEBUG; 5549 5550 $canalid =~ s/\s+//g; # Removes whitespace from CHANNEL-ID 5551 $canalid =~ s/(.*)<(.*)>/$1/g; # discards ZOMBIE or MASQ 5356 5552 5357 5553 if ( $canal =~ /^vpb\//i ) { … … 5366 5562 $server =~ s/(.*)-(.*)/$2/g; 5367 5563 5368 log_debug( "$heading Quehace $quehace", 64 ) if DEBUG;5369 5370 5564 my $buttontext = $dos; 5371 5565 if ( $buttontext =~ /\Q[\E/ ) { … … 5379 5573 my $cuantos = @canaleja; 5380 5574 5381 # Perform some pre processing...5575 # Perform some pre processing... 5382 5576 5383 5577 if ( $quehace eq "corto" || $quehace eq "info" ) { … … 5388 5582 $toda .= "$key = $val\n" 5389 5583 if ( $key ne "E" ) && ( defined($val) ); 5390 log_debug( "$heading \tAgrego $key = $val", 128) if DEBUG;5584 log_debug( "$heading \tAgrego $key = $val", 256 ) if DEBUG; 5391 5585 } 5392 5586 $toda .= " "; … … 5394 5588 5395 5589 if ( $quehace eq "corto" ) { 5590 log_debug( "$heading erasing datos{$uniqueid}", 256 ) if DEBUG; 5396 5591 delete $datos{$uniqueid}; 5397 } 5398 5399 log_debug( "$heading erasing datos{$uniqueid}", 128 ) if DEBUG; 5400 5401 if ( $cuantos == 0 ) { 5402 5403 # We delete all appeareance in sesbot because the channel without 5404 # a button might occupy one slot in sesbot. If we have a button 5405 # match then skip this step for later 5406 erase_all_sessions_from_channel( $canalid, $canal, $server ); 5407 } 5408 5409 } elsif ( $quehace eq "queueremoved" ) { 5592 delete $chanvar{$uniqueid}; 5593 delete $passvar{$uniqueid}; 5594 5595 if ( $cuantos == 0 ) { 5596 5597 # We need to call it here because a channel with no buttons defined 5598 # might count for other button that exists, like meetmes, queues, etc. 5599 # So we only call it when there is NO match for buttons (because 5600 # we will call it again for existing matches) 5601 erase_all_sessions_from_channel( $canalid, $canal, $server ); 5602 } 5603 } 5604 } 5605 elsif ( $quehace eq "queueremoved" ) { 5410 5606 5411 5607 # Remove the agent from the agents_on_queue hash … … 5438 5634 5439 5635 foreach $canal (@canaleja) { 5440 log_debug( "", 32) if DEBUG;5441 log_debug( "$heading canaleja LOOP; is $canal turn", 32) if DEBUG;5636 log_debug( "", 256 ) if DEBUG; 5637 log_debug( "$heading canaleja LOOP; is $canal turn", 256 ) if DEBUG; 5442 5638 5443 5639 if ( $dosoriginal ne "" ) { … … 5451 5647 5452 5648 if ( !defined( $buttons{"$server^$canal"} ) && !defined( $buttons{"-1^$canal"} ) ) { 5453 log_debug( "$heading \tThere are no buttons for $server^$canal, skipping...", 128) if DEBUG;5649 log_debug( "$heading \tThere are no buttons for $server^$canal, skipping...", 256 ) if DEBUG; 5454 5650 if (DEBUG) { 5455 5651 for ( keys %buttons ) { 5456 log_debug( "$heading \t\tKey $_", 128);5652 log_debug( "$heading \t\tKey $_", 256 ); 5457 5653 } 5458 5654 } … … 5463 5659 # except ocupado*, corto, setlink and unsetlink 5464 5660 if ( $canal =~ /^_/ ) { 5465 log_debug( "$heading canal $canal is regexp, quehace value = $quehace", 32) if DEBUG;5661 log_debug( "$heading canal $canal is regexp, quehace value = $quehace", 256 ) if DEBUG; 5466 5662 5467 5663 if ( $quehace =~ /registr/ … … 5469 5665 || $quehace =~ /^inf/ ) 5470 5666 { 5471 log_debug( "$heading IGNORING $quehace because it is a regexp match", 32) if DEBUG;5667 log_debug( "$heading IGNORING $quehace because it is a regexp match", 256 ) if DEBUG; 5472 5668 next; 5473 5669 } … … 5488 5684 && $quehace !~ /^unsetlink/ ) 5489 5685 { 5490 my ( $nada, $elcontexto ) = split( /\&/, $canal );5686 my ( undef, $elcontexto ) = split( /\&/, $canal ); 5491 5687 if ( !defined($elcontexto) ) { $elcontexto = ""; } 5492 5688 if ( $elcontexto ne "" ) { … … 5495 5691 my ( $canalsolo, $nrotrunk ) = split( /=/, $canal ); 5496 5692 $canal = $canalsolo . "=1" . $elcontexto; 5497 log_debug( "$heading quehace=$quehace, select 1st from trunk $canal", 32) if DEBUG;5693 log_debug( "$heading quehace=$quehace, select 1st from trunk $canal", 256 ) if DEBUG; 5498 5694 5499 5695 #next; 5500 5696 } 5501 5697 5502 # If we have a wildcardbutton with changelabel5698 # If we have a regexp button with changelabel 5503 5699 # and change led_color (the 1 after changelabel) 5504 5700 # change it so to not change the led color. 5505 5701 if ( $quehace =~ /changelabel1/ ) { 5506 log_debug( "$heading el regexp tiene changelabel1, lo cambio por changelabel0!", 32)5702 log_debug( "$heading regexp has changelabel1, lets change it to changelabel0!", 256 ) 5507 5703 if DEBUG; 5508 5704 $quehace = "changelabel0"; … … 5513 5709 5514 5710 if ( $canal eq "" ) { 5515 # No channel? continue... 5516 log_debug( "$heading There is no command defined", 32 ) if DEBUG; 5517 5518 } else { 5711 5712 # No channel? continue... 5713 log_debug( "$heading There is no command defined", 256 ) if DEBUG; 5714 5715 } 5716 else { 5519 5717 5520 5718 $interno = $buttons{"$server^$canal"}; 5521 5522 5719 if ( !defined($interno) ) { 5523 5720 $interno = $buttons{"-1^$canal"}; … … 5538 5735 } 5539 5736 5540 # The following block cleans internal op_server states. no matter if we5541 # have a button defined or not.5737 # The following block cleans internal op_server states. no matter if we 5738 # have a button defined or not. 5542 5739 5543 5740 if ( $quehace eq 'corto' || $quehace eq 'info' ) { 5544 5545 5741 my @linked = erase_all_sessions_from_channel( $canalid, $canal, $server ); 5742 5546 5743 push @linked, $canal; 5547 5744 my $btnorinum = ""; … … 5553 5750 $btnorinum = $buttons{"$serverindex^$canaleje"}; 5554 5751 } 5555 log_debug( "$heading call GEN_LINKED 1", 32) if DEBUG;5752 log_debug( "$heading call GEN_LINKED 1", 256 ) if DEBUG; 5556 5753 my $listabotones = generate_linked_buttons_list( $canaleje, $server ); 5557 5754 push @respuestas, "$btnorinum|linked|$listabotones"; … … 5559 5756 5560 5757 delete $datos{$uniqueid}; 5561 log_debug( "$heading REMOVING datos { $uniqueid }", 32 ) if DEBUG; 5562 5563 } elsif ( $quehace eq "setlink" ) { 5564 5565 log_debug( "$heading IF quehace = SETLINK", 32 ) if DEBUG; 5566 my ( $nada1, $contexto1 ) = split( /\&/, $canal ); 5758 delete $chanvar{$uniqueid}; 5759 delete $passvar{$uniqueid}; 5760 log_debug( "$heading REMOVING datos { $uniqueid }", 256 ) if DEBUG; 5761 5762 } 5763 elsif ( $quehace eq "setlink" ) { 5764 5765 log_debug( "$heading IF quehace = SETLINK", 256 ) if DEBUG; 5766 my ( undef, $contexto1 ) = split( /\&/, $canal ); 5567 5767 if ( !defined($contexto1) ) { $contexto1 = ""; } 5568 5768 my $listabotones = ""; … … 5571 5771 push @{ $linkbot{"$server^$canal"} }, ""; 5572 5772 pop @{ $linkbot{"$server^$canal"} }; 5573 log_debug( "$heading DEFINIENDO linkbot ($server^$canal)", 32) if DEBUG;5773 log_debug( "$heading DEFINIENDO linkbot ($server^$canal)", 256 ) if DEBUG; 5574 5774 } 5575 5775 … … 5577 5777 my @linkbotones = find_panel_buttons( $canal1, $dos, $server ); 5578 5778 foreach (@linkbotones) { 5579 my ( $nada2, $contexto2 ) = split( /\&/, $_ );5779 my ( undef, $contexto2 ) = split( /\&/, $_ ); 5580 5780 if ( !defined($contexto2) ) { $contexto2 = ""; } 5581 5781 if ( $contexto1 eq $contexto2 ) { 5582 5782 push @{ $linkbot{"$server^$canal"} }, $dos; 5583 log_debug( "$heading AGREGO a linkbot{ $server^$canal} el valor $dos", 32)5783 log_debug( "$heading AGREGO a linkbot{ $server^$canal} el valor $dos", 256 ) 5584 5784 if DEBUG; 5585 5785 } … … 5590 5790 5591 5791 foreach my $valorad (@uniq) { 5592 log_debug( "$heading linkbot ($server^$canal) = $valorad", 32) if DEBUG;5792 log_debug( "$heading linkbot ($server^$canal) = $valorad", 256 ) if DEBUG; 5593 5793 } 5594 5794 my $btnorinum = $buttons{"$serverindex^$canal"}; 5595 log_debug( "$heading llamo a GENERATE_LINKED", 32) if DEBUG;5795 log_debug( "$heading llamo a GENERATE_LINKED", 256 ) if DEBUG; 5596 5796 $listabotones = generate_linked_buttons_list( $canal, $server ); 5597 5797 push @respuestas, "$btnorinum|linked|$listabotones"; 5798 push @respuestas, "$btnorinum|bridgepeer|$dos"; 5598 5799 $botonlinked{$btnorinum} = $listabotones; 5599 log_debug( "$heading linkeado con $listabotones", 32 ) if DEBUG; 5600 log_debug( "$heading ENDIF quehace = SETLINK", 32 ) if DEBUG; 5601 5602 } elsif ( $quehace eq "unsetlink" ) { 5603 log_debug( "$heading IF quehace = UNSETLINK", 32 ) if DEBUG; 5800 log_debug( "$heading linkeado con $listabotones", 256 ) if DEBUG; 5801 log_debug( "$heading ENDIF quehace = SETLINK", 256 ) if DEBUG; 5802 5803 } 5804 elsif ( $quehace eq "unsetlink" ) { 5805 log_debug( "$heading IF quehace = UNSETLINK", 256 ) if DEBUG; 5604 5806 my @final = (); 5605 5807 foreach my $msesion ( @{ $linkbot{"$server^$canal"} } ) { … … 5609 5811 } 5610 5812 $linkbot{"$server^$canal"} = [@final]; 5611 log_debug( "$heading ENDIF quehace = UNSETLINK", 32 ) if DEBUG; 5612 5613 } elsif ( $quehace eq "queueremoved" ) { 5813 log_debug( "$heading ENDIF quehace = UNSETLINK", 256 ) if DEBUG; 5814 5815 } 5816 elsif ( $quehace eq "queueremoved" ) { 5614 5817 5615 5818 delete $botonvoicemail{$interno}; … … 5627 5830 } 5628 5831 5629 # Continue after cleaning internal state...5832 # Continue after cleaning internal state... 5630 5833 if ( $interno eq "" ) { 5631 log_debug( "$heading MISSING buttons($server^$canal), skipping...", 32) if DEBUG;5834 log_debug( "$heading MISSING buttons($server^$canal), skipping...", 256 ) if DEBUG; 5632 5835 next; 5633 5836 } 5634 5837 else { 5635 log_debug( "$heading INTERNO = $interno", 32) if DEBUG;5838 log_debug( "$heading INTERNO = $interno", 256 ) if DEBUG; 5636 5839 } 5637 5840 … … 5656 5859 # 5657 5860 if ( $canalid eq "" || $canalid =~ /zombie/i || $canalid =~ /(.*)-XXXX$/ ) { 5658 log_debug( "$heading ATENTION canalid = '$canalid', skipping...", 32 ) if DEBUG; 5861 log_debug( "$heading ATENTION canalid = '$canalid', skipping...", 256 ) if DEBUG; 5862 if ( $quehace eq "registrado" || $quehace eq "noregistrado" || $quehace eq "unreachable" ) { 5863 if ( defined( $botonregistrado{$interno} ) ) { 5864 if ( $botonregistrado{$interno} eq "$quehace|$dos" ) { 5865 $cambiaron{$interno} = 0; 5866 } 5867 } 5868 else { 5869 $botonregistrado{$interno} = "$quehace|$dos"; 5870 $cambiaron{$interno} = 1; 5871 } 5872 } 5659 5873 } 5660 5874 else { … … 5662 5876 if ( $quehace eq "corto" ) { 5663 5877 5664 log_debug( "$heading CORTO interno $interno canal $canal", 32 ) if DEBUG; 5878 log_debug( "$heading CORTO interno $interno canal $canal", 256 ) if DEBUG; 5879 $dos = $canalid; 5665 5880 5666 5881 delete $botonpark{$interno}; … … 5689 5904 if ( $cuantos == 0 ) { 5690 5905 log_debug( "$heading CORTO y SE DESOCUPO estadoboton($interno) = free, sesbot($interno) esta vacio", 5691 32)5906 256 ) 5692 5907 if DEBUG; 5693 5908 $cambiaron{$interno} = 1; … … 5696 5911 else { 5697 5912 log_debug( "$heading CORTO y SIGUE OCUPADO estadoboton($interno) = busy, sesbot($interno) tiene algo", 5698 32)5913 256 ) 5699 5914 if DEBUG; 5700 5915 &print_sesbot(3); … … 5709 5924 5710 5925 log_debug( 5711 "$heading Y es distinto al ultimo estado $laststatus{$interno} ne $estadoboton{$interno}", 32)5926 "$heading Y es distinto al ultimo estado $laststatus{$interno} ne $estadoboton{$interno}", 256 ) 5712 5927 if DEBUG; 5713 5928 } … … 5730 5945 5731 5946 # quehace no es "corto" 5732 #5733 5947 5734 5948 # MAINTAINS SESBOT HASH … … 5743 5957 push @{ $sesbot{$interno} }, "$canalid"; 5744 5958 5745 log_debug( "$heading AGREGO a sesbot($interno) el valor $canalid", 32) if DEBUG;5959 log_debug( "$heading AGREGO a sesbot($interno) el valor $canalid", 256 ) if DEBUG; 5746 5960 5747 5961 my @uniq = unique( @{ $sesbot{$interno} } ); … … 5749 5963 5750 5964 foreach my $vavi ( @{ $sesbot{$interno} } ) { 5751 log_debug( "$heading sesbot($interno) tiene $vavi", 32) if DEBUG;5752 log_debug( "$heading --------------------", 32) if DEBUG;5965 log_debug( "$heading sesbot($interno) tiene $vavi", 256 ) if DEBUG; 5966 log_debug( "$heading --------------------", 256 ) if DEBUG; 5753 5967 } 5754 5968 } 5755 5969 5756 5970 if ( $canal =~ /^_/ && $quehace =~ /^ring/ ) { 5757 log_debug( "$heading TENGO UN WILDCARD ORIGINANDO LLAMADO! $canal $quehace $canalid", 32)5971 log_debug( "$heading have a regexp originating a call $canal $quehace $canalid, rename label", 256 ) 5758 5972 if DEBUG; 5759 if ( $quehace eq "ring" ) { 5760 5761 # $quehace = "ocupado1"; 5762 } 5973 5763 5974 if ( $ren_wildcard == 1 ) { 5764 5975 push @respuestas, "$interno|changelabel0|$canalid"; … … 5766 5977 } 5767 5978 } 5768 5769 5979 if ( $quehace eq "ringing" ) { 5770 5980 if ( $laststatus{$interno} ne "ringing|${buttontext}" ) { … … 5788 5998 5789 5999 } 5790 elsif ( $quehace =~ /^ocupado/ ) {6000 elsif ( $quehace =~ /^ocupado/ || $quehace eq 'ring' ) { 5791 6001 5792 6002 if ( defined( $group_count{$interno} ) ) { 5793 my $plural = "";5794 6003 if ( $group_count{$interno} == 1 ) { 5795 if ( @{ $sesbot{$interno} } > 1 ) { 5796 $plural = "s"; 5797 } 5798 if ( @{ $sesbot{$interno} } > 0 ) { 5799 my $cuantos = @{ $sesbot{$interno} }; 5800 my ( $text, $textriginal, $buttontext ) = 5801 translate( $canal, "&channels,$cuantos,$plural", "", "" ); 5802 $buttontext = $text; 5803 $dos = "[" . $buttontext . "]"; 5804 } 6004 $buttontext = group_count( $interno, $canal ); 6005 push @respuestas, $buttontext; 5805 6006 } 5806 6007 } … … 5809 6010 } 5810 6011 $estadoboton{$interno} = "busy|${buttontext}"; 5811 5812 6012 } 5813 6013 } 5814 6014 } 5815 6015 5816 log_debug( "$heading Continuo proceso...", 32) if DEBUG;5817 6016 log_debug( "$heading Continuo proceso...", 256 ) if DEBUG; 6017 5818 6018 if ( $quehace =~ /changelabel/ ) { 5819 log_debug( "$heading quehace = changelabel", 32) if DEBUG;6019 log_debug( "$heading quehace = changelabel", 256 ) if DEBUG; 5820 6020 5821 6021 # Mantains state of label and led … … 5856 6056 } 5857 6057 5858 } elsif ( $quehace eq "park" ) { 5859 5860 log_debug( "$heading quehace = park", 32 ) if DEBUG; 6058 } 6059 elsif ( $quehace eq "park" ) { 6060 6061 log_debug( "$heading quehace = park", 256 ) if DEBUG; 5861 6062 $dos =~ m/(.*)\((.*)\)/; 5862 6063 my $texto = $1; … … 5864 6065 $timeout = time() + $timeout; 5865 6066 $botonpark{$interno} = "$texto|$timeout"; 5866 } elsif ( $quehace eq "meetmeuser" ) { 6067 } 6068 elsif ( $quehace eq "meetmeuser" ) { 5867 6069 $botonmeetme{$interno} = $dos; 5868 } elsif ( $quehace eq "infoqstat" ) { 6070 } 6071 elsif ( $quehace eq "infoqstat" ) { 5869 6072 $botonqueue{$interno} = $dos; 5870 } elsif ( $quehace eq "infoqstat2" ) { 6073 } 6074 elsif ( $quehace eq "infoqstat2" ) { 5871 6075 $botonqueue_count{$interno} = $dos; 5872 } elsif ( $quehace =~ /info/ ) { 6076 } 6077 elsif ( $quehace =~ /info/ ) { 5873 6078 my $mcola = $quehace; 5874 6079 $mcola =~ s/^info//g; … … 5891 6096 } 5892 6097 5893 } elsif ( $quehace eq "setclid" ) { 6098 } 6099 elsif ( $quehace eq "setclid" ) { 5894 6100 if ( !defined( $group_count{$interno} ) ) { 5895 6101 push @respuestas, "$interno|settext|$dos"; 5896 6102 } 5897 } elsif ( $quehace eq "settext" ) { 6103 if ( $estadoboton{$interno} eq "" ) { 6104 push @respuestas, "$interno|state|busy"; 6105 $estadoboton{$interno} = "busy"; 6106 } 6107 } 6108 elsif ( $quehace eq "settext" ) { 5898 6109 if ( !defined( $group_count{$interno} ) ) { 5899 6110 $botonpermanenttext{$interno} = $dos; 5900 # print "vino settext a digest permanent $interno = -$dos-\n";5901 6111 push @respuestas, "$interno|settext|$dos"; 5902 6112 } 5903 } elsif ( $quehace eq "fopledcolor" ) { 6113 } 6114 elsif ( $quehace eq "settextnopermanente" ) { 6115 if ( !defined( $group_count{$interno} ) ) { 6116 push @respuestas, "$interno|settext|$dos"; 6117 } 6118 } 6119 elsif ( $quehace eq "fopledcolor" ) { 5904 6120 $botonledcolor{$interno} = $dos; 5905 } elsif ( $quehace eq "setalpha" ) { 6121 } 6122 elsif ( $quehace eq "setalpha" ) { 5906 6123 $botonalpha{$interno} = $dos; 5907 6124 push @respuestas, "$interno|setalpha|$dos"; 5908 } elsif ( $quehace eq "flip" ) { 6125 } 6126 elsif ( $quehace eq "flip" ) { 5909 6127 push @respuestas, "$interno|flip|$dos"; 5910 } elsif ( $quehace eq "setlabel" ) { 6128 } 6129 elsif ( $quehace eq "setlabel" ) { 5911 6130 if ( $dos ne "." 5912 6131 && $dos ne "original" … … 5916 6135 push @respuestas, "$interno|setlabel|$dos"; 5917 6136 } 5918 } elsif ( $quehace eq "voicemail" ) { 6137 } 6138 elsif ( $quehace eq "voicemail" ) { 5919 6139 $botonvoicemail{$interno} = $dos; 5920 } elsif ( $quehace eq "voicemailcount" ) { 6140 } 6141 elsif ( $quehace eq "voicemailcount" ) { 5921 6142 $botonvoicemailcount{$interno} = $dos; 5922 } elsif ( $quehace =~ "^voicemail" ) { 6143 } 6144 elsif ( $quehace =~ "^voicemail" ) { 5923 6145 5924 6146 # This block is for the voicemail client … … 5926 6148 $canalsincontexto =~ s/(.*)&(.*)/$1/g; 5927 6149 push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|$dos"; 5928 } elsif ( $quehace =~ "^ringing" ) { 6150 } 6151 elsif ( $quehace =~ "^ringing" ) { 5929 6152 5930 6153 # This block is for the voicemail client, popups … … 5936 6159 $calleridpop =~ s/\s+//g; 5937 6160 push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|$calleridpop"; 6161 if ( defined( $group_count{$interno} ) && $group_count{$interno} == 1 ) { 6162 6163 # Ignore ringing because of groupcount 6164 $quehace = ""; 6165 } 5938 6166 } 5939 6167 … … 5946 6174 && ( $quehace !~ /link/ ) ) 5947 6175 { 5948 $cambiaron{$interno} = 1; 5949 log_debug( "$heading es distinto de corto,ocupado,link pongo cambiaron=1", 32 ) if DEBUG; 6176 if ( !defined( $cambiaron{$interno} ) ) { 6177 $cambiaron{$interno} = 1; 6178 log_debug( "$heading es distinto de corto,ocupado,link pongo cambiaron=1", 256 ) 6179 if DEBUG; 6180 } 5950 6181 } 5951 6182 … … 5956 6187 5957 6188 if ( @{ $sesbot{$interno} } > 0 && $quehace eq 'corto' ) { 5958 log_debug( "$heading Still busy...sesbot($interno) is not empty, ignoring hangup", 32)6189 log_debug( "$heading Still busy...sesbot($interno) is not empty, ignore hangup", 256 ) 5959 6190 if DEBUG; 6191 if ( defined( $group_count{$interno} ) ) { 6192 if ( $group_count{$interno} == 1 ) { 6193 $buttontext = group_count( $interno, $canal ); 6194 push @respuestas, $buttontext; 6195 } 6196 } 5960 6197 } 5961 6198 else { … … 5964 6201 my $canalsincontexto = $canal; 5965 6202 $canalsincontexto =~ s/(.*)&(.*)/$1/g; 5966 push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|corto!"; 6203 push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|$canalid"; 6204 if ( defined( $group_count{$interno} ) ) { 6205 if ( $group_count{$interno} == 1 ) { 6206 $buttontext = group_count( $interno, $canal ); 6207 push @respuestas, $buttontext; 6208 } 6209 } 5967 6210 } 5968 6211 5969 6212 my $quehace2 = $quehace; 5970 5971 if ( $quehace2 eq "ring" ) {5972 5973 #$quehace2 = "ocupado";5974 }5975 6213 5976 6214 next unless ( $quehace2 ne "setlink" ); 5977 6215 next unless ( $quehace2 ne "unsetlink" ); 5978 6216 5979 log_debug( "$heading sigo quehace quehace2", 32) if DEBUG;6217 log_debug( "$heading sigo quehace quehace2", 256 ) if DEBUG; 5980 6218 5981 6219 if ( $quehace2 eq "isagent" && $dos == -1 ) { 5982 log_debug( "$heading quehace2 = isagent", 32) if DEBUG;6220 log_debug( "$heading quehace2 = isagent", 256 ) if DEBUG; 5983 6221 push @mensajefinal, "$interno|changelabel1|original"; 5984 6222 push @mensajefinal, "$interno|settimer|0\@STOP"; 5985 6223 push @mensajefinal, "$interno|settext|"; 5986 push @mensajefinal, "$interno|corto| ";6224 push @mensajefinal, "$interno|corto|$canalid"; 5987 6225 } 5988 6226 … … 5990 6228 5991 6229 # clear the agent helper hashes. We do it here because we first need to map 5992 log_debug( "$heading quehace2 = agentlogoff", 32) if DEBUG;6230 log_debug( "$heading quehace2 = agentlogoff", 256 ) if DEBUG; 5993 6231 my $canalag = $canalid; 5994 6232 $canalag = substr( $canalag, 0, -5 ); … … 6001 6239 if ( $val eq $canalag ) { 6002 6240 delete $channel_to_agent{$key}; 6003 log_debug( "$heading borro channel_to_agent($key)", 64) if DEBUG;6241 log_debug( "$heading borro channel_to_agent($key)", 256 ) if DEBUG; 6004 6242 } 6005 6243 } … … 6008 6246 if ( defined( $agent_to_channel{"$server^$canalag"} ) ) { 6009 6247 delete $agent_to_channel{"$server^$canalag"}; 6010 log_debug( "$heading borro agent_to_channel($server^$canalag)", 64) if DEBUG;6248 log_debug( "$heading borro agent_to_channel($server^$canalag)", 256 ) if DEBUG; 6011 6249 } 6012 6250 … … 6023 6261 6024 6262 if ( $quehace2 !~ /isagent/ && $quehace2 !~ /^agentlogoff/ && $quehace2 !~ /^setclid/ ) { 6025 log_debug( "$heading pushing respuestas $interno|$quehace2|$dos", 32 ) if DEBUG; 6026 6027 # Discard events that we dont want to send 6028 # to flash clients 6029 # "isagent". "agentlogoff" 6030 # everything else is pushed 6031 if ( defined( $group_count{$interno} ) && $quehace2 eq "setclid" ) { 6032 log_debug( "$heading skip settext because groupcount is set", 32 ) if DEBUG; 6033 } 6034 else { 6035 if ( $quehace2 ne "" ) { 6036 push @respuestas, "$interno|$quehace2|$dos"; 6037 # print "push $quehace2 en $interno quehace2\n"; 6263 6264 if ( defined( $cambiaron{$interno} ) && $cambiaron{$interno} == 1 ) { 6265 6266 # Discard events that we dont want to send 6267 # to flash clients 6268 # "isagent". "agentlogoff" 6269 # everything else is pushed 6270 if ( defined( $group_count{$interno} ) && $quehace2 eq "setclid" ) { 6271 log_debug( "$heading skip settext because groupcount is set", 256 ) if DEBUG; 6272 } 6273 else { 6274 if ( $quehace2 ne "" ) { 6275 if ( defined( $group_count{$interno} ) && $group_count{$interno} == 1 ) { 6276 6277 # $dos = ""; 6278 } 6279 else { 6280 push @respuestas, "$interno|$quehace2|$dos"; 6281 log_debug( "$heading pushing respuestas $interno|$quehace2|$dos", 256 ) 6282 if DEBUG; 6283 } 6284 } 6038 6285 } 6039 6286 } … … 6041 6288 6042 6289 if ( $quehace2 =~ /ocupado/ ) { 6043 if ( $dos =~ m/(.*)?\[(.*)\].*?/ ) { 6044 my $clidtext = $2; 6045 $botonclid{$interno} = $clidtext; 6290 if ( defined( $group_count{$interno} ) && $group_count{$interno} == 1 ) { 6291 $cambiaron{$interno} = 0; 6292 $quehace2 = ""; 6293 next; 6046 6294 } 6047 6048 #push @mensajefinal, "$interno|state|busy"; 6049 push @mensajefinal, "$interno|settimer|0\@UP"; 6295 else { 6296 if ( $dos =~ m/(.*)?\[(.*)\].*?/ ) { 6297 my $clidtext = $2; 6298 $botonclid{$interno} = $clidtext; 6299 } 6300 6301 #push @mensajefinal, "$interno|state|busy"; 6302 push @mensajefinal, "$interno|settimer|0\@UP"; 6303 } 6050 6304 } 6051 6305 if ( $quehace2 eq "settimer" ) { 6052 my $tiempo = $dos; 6053 my $nada = ""; 6306 if ( !defined($dos) ) { $dos = 1; } 6307 my $tiempo = $dos; 6308 my $timer_type = ""; 6054 6309 if ( $tiempo =~ /\@/ ) { 6055 ( $tiempo, $ nada) = split( /\@/, $tiempo );6310 ( $tiempo, $timer_type ) = split( /\@/, $tiempo ); 6056 6311 } 6057 if ( $nada ne "" ) { 6058 $botontimertype{$interno} = $nada; 6059 $nada = "\@" . $nada; 6312 6313 if ( $tiempo eq "" ) { $tiempo = 0; } 6314 6315 if ( $timer_type ne "" ) { 6316 $botontimertype{$interno} = $timer_type; 6317 $timer_type = "\@" . $timer_type; 6060 6318 } 6061 6319 $botontimer{$interno} = time() - $tiempo; 6062 push @mensajefinal, "$interno|settimer|$tiempo$ nada";6320 push @mensajefinal, "$interno|settimer|$tiempo$timer_type"; 6063 6321 } 6064 6322 … … 6077 6335 } 6078 6336 if ( $quehace2 =~ /corto/ ) { 6079 log_debug( "$heading quehace2 corto", 32) if DEBUG;6337 log_debug( "$heading quehace2 corto", 256 ) if DEBUG; 6080 6338 6081 6339 my $canalsincontexto = $canal; … … 6101 6359 $iniagent = $channel_to_agent{"$server^$canalsincontexto"}; 6102 6360 } 6103 log_debug( "$heading quehace2 corto y es agente, pushing settimer y settext to idle", 1 ) if DEBUG; 6361 log_debug( "$heading quehace2 corto y es agente, pushing settimer y settext to idle", 256 ) 6362 if DEBUG; 6104 6363 $botontimer{$interno} = time(); 6105 6364 $botontimertype{$interno} = "IDLE"; … … 6114 6373 else { 6115 6374 my $valip = ""; 6116 log_debug( "$heading quehace2 corto, no es agente, pongo timer en cero", 1 ) if DEBUG; 6375 log_debug( "$heading quehace2 corto, no es agente, pongo timer en cero", 256 ) 6376 if DEBUG; 6117 6377 6118 6378 push @mensajefinal, "$interno|settimer|0\@STOP"; … … 6125 6385 if ( defined( $botonpermanenttext{$interno} ) ) { 6126 6386 push @mensajefinal, "$interno|settext|$botonpermanenttext{$interno}"; 6127 # print "corto! permanent $interno = -$dos-\n"; 6128 6129 #$botonpermanenttext{$interno} = $dos; 6387 log_debug( "interno $interno tenia permanente $botonpermanenttext{$interno}", 128 ) 6388 if DEBUG; 6130 6389 } 6131 6390 $botonclid{$interno} = ""; … … 6141 6400 } 6142 6401 6143 if ( $quehace eq "registrado" ) { 6144 if ( defined( $botonalpha{$interno} ) ) { 6145 if ( $botonalpha{$interno} ne "" ) { 6146 push @mensajefinal, "$interno|setalpha|50"; 6402 if ( $quehace eq "registrado" || $quehace eq "noregistrado" || $quehace eq "unreachable" ) { 6403 if ( $botonregistrado{$interno} ne "$quehace|$dos" ) { 6404 6405 # changed registration state, do something 6406 if ( $quehace eq "registrado" ) { 6407 if ( defined( $botonalpha{$interno} ) ) { 6408 if ( $botonalpha{$interno} ne "" ) { 6409 push @mensajefinal, "$interno|setalpha|50"; 6410 } 6411 else { 6412 push @mensajefinal, "$interno|setalpha|100"; 6413 } 6414 } 6147 6415 } 6148 else { 6149 push @mensajefinal, "$interno|setalpha|100"; 6150 } 6416 $botonregistrado{$interno} = "$quehace|$dos"; 6151 6417 } 6152 }6153 6154 if ( $quehace eq "registrado" || $quehace eq "noregistrado" || $quehace eq "unreachable" ) {6155 $botonregistrado{$interno} = "$quehace|$dos";6156 6418 } 6157 6419 … … 6159 6421 $boton_paused{$interno} = $dos; 6160 6422 } 6161 if ( $quehace eq "agents_paused" ) {6423 elsif ( $quehace eq "agents_paused" ) { 6162 6424 $boton_agentpaused{$interno} = $dos; 6163 6425 } 6164 if ( $quehace eq "agents_ready" ) {6426 elsif ( $quehace eq "agents_ready" ) { 6165 6427 $boton_agentready{$interno} = $dos; 6166 6428 } 6167 if ( $quehace eq "agents_busy" ) {6429 elsif ( $quehace eq "agents_busy" ) { 6168 6430 $boton_agentbusy{$interno} = $dos; 6169 6431 } 6170 if ( $quehace eq "agents_logedof" ) {6432 elsif ( $quehace eq "agents_logedof" ) { 6171 6433 $boton_agentlogedof{$interno} = $dos; 6172 6434 } 6173 6435 6174 log_debug( "$heading Agrego mensaje final $interno|$quehace2|$dos", 32) if DEBUG;6436 log_debug( "$heading Agrego mensaje final $interno|$quehace2|$dos", 256 ) if DEBUG; 6175 6437 6176 6438 #if (defined($mensajefinal) && $interno ne "") … … 6179 6441 if ( exists $cambiaron{$interno} ) { 6180 6442 6181 log_debug( "$heading Existe cambiaron($interno) = $cambiaron{$interno}", 32)6443 log_debug( "$heading Existe cambiaron($interno) = $cambiaron{$interno}", 256 ) 6182 6444 if DEBUG; 6183 6445 6184 #push(@respuestas, $mensajefinal); 6185 foreach (@mensajefinal) { 6186 push @respuestas, $_; 6446 if ( $cambiaron{$interno} == 1 ) { 6447 foreach (@mensajefinal) { 6448 log_debug( "$heading pushing respuestas $_ because cambiaron($interno)=1", 256 ) 6449 if DEBUG; 6450 push @respuestas, $_; 6451 } 6187 6452 } 6188 6453 } 6189 6454 else { 6190 6191 log_debug( "$heading No existe cambiaron($interno)", 32 ) if DEBUG; 6192 foreach (@mensajefinal) { 6193 6194 # If the last status was not modified, avoid sending info 6195 # push @respuestas, $_; 6196 } 6455 log_debug( "$heading No existe cambiaron($interno)", 256 ) if DEBUG; 6197 6456 } 6198 6457 if ( $toda ne "" ) { … … 6213 6472 @respuestas = unique(@respuestas); 6214 6473 $cuantas = $#respuestas + 1; 6215 log_debug( "$heading end, return $cuantas", 16 ) if DEBUG;6474 log_debug( "$heading end, return $cuantas", 256 ) if DEBUG; 6216 6475 foreach my $valor (@respuestas) { 6217 log_debug( "$heading END SUB: returns $valor", 32) if DEBUG;6476 log_debug( "$heading END SUB: returns $valor", 256 ) if DEBUG; 6218 6477 } 6219 6478 $tab = substr( $tab, 0, -1 ) if DEBUG; 6220 6479 return @respuestas; 6480 } 6481 6482 sub group_count { 6483 my $interno = shift; 6484 my $canal = shift; 6485 my $plural = ""; 6486 my $return = ""; 6487 if ( @{ $sesbot{$interno} } > 1 ) { 6488 $plural = "s"; 6489 } 6490 if ( @{ $sesbot{$interno} } > 0 ) { 6491 my $cuantos = @{ $sesbot{$interno} }; 6492 my ( $text, $textriginal, $buttontext ) = translate( $canal, "&channels,$cuantos,$plural", "", "" ); 6493 $return = "$interno|settext|$text"; 6494 $botonpermanenttext{$interno} = $text; 6495 } 6496 else { 6497 $botonpermanenttext{$interno} = ""; 6498 $return = "$interno|corto|"; 6499 } 6500 return $return; 6221 6501 } 6222 6502 … … 6274 6554 } 6275 6555 6276 sub nonblock {6277 my $socket = shift;6278 my $flags;6279 6280 $flags = fcntl( $socket, F_GETFL, 0 )6281 or die "Can't get flags for socket: $!\n";6282 fcntl( $socket, F_SETFL, $flags | O_NONBLOCK )6283 or die "Can't make socket nonblocking: $!\n";6284 }6285 6286 6556 sub clean_inmemory_state_for_server { 6287 6557 … … 6424 6694 6425 6695 # The closed connections belong to an asterisk manager port 6426 my @partes = split( /\|/, $manager_socket{$socket} );6427 6696 my @pp = (); 6428 6697 my $counter = 0; … … 6461 6730 collect_includes( "op_buttons.cfg", "buttons" ); 6462 6731 collect_includes( "op_style.cfg", "style" ); 6732 collect_includes( "op_server.cfg", "server" ); 6463 6733 read_buttons_config(); 6464 6734 read_server_config(); … … 6468 6738 6469 6739 # Tries to open the listening socket 6470 $m = new IO::Socket::INET( Listen => 1, LocalAddr => $listen_addr, LocalPort => $listen_port, ReuseAddr => 1, Blocking => 0 ) 6740 $m = new IO::Socket::INET( 6741 Listen => 1, 6742 LocalAddr => $listen_addr, 6743 LocalPort => $listen_port, 6744 ReuseAddr => 1, 6745 Blocking => 0 6746 ) 6471 6747 or die "\nCan't listen to port $listen_port\n"; 6472 6748 $O = new IO::Select(); … … 6506 6782 push( @flash_clients, $C ); 6507 6783 $O->add($C); 6508 nonblock($C);6784 $C->blocking(0); 6509 6785 } 6510 6786 else { … … 6624 6900 || $bloque_final =~ /Message: Mailbox/ 6625 6901 || $bloque_final =~ /SIP-CanReinvite/ 6902 || $bloque_final =~ /ActionID: monitor-/ 6626 6903 || $bloque_final =~ /Message: Timeout/ ) 6627 6904 { … … 6634 6911 $block_count++; 6635 6912 $bloque[$block_count]{Event} = "sippeerentrylong"; 6913 } 6914 elsif ( $p =~ /ActionID: monitor-/ ) { 6915 my ( undef, $quemonitor, $quecana ) = split( /-/, $p, 3 ); 6916 $block_count++; 6917 $bloque[$block_count]{Event} = "response-$quemonitor"; 6918 $bloque[$block_count]{Channel} = $quecana; 6636 6919 } 6637 6920 my $my_event = ""; … … 6718 7001 send_initial_status($C); 6719 7002 } 7003 elsif ( $bloque_final =~ /<policy-file-request\/>/ ) { 7004 send_policy_to_flash($C); 7005 } 6720 7006 else { 6721 log_debug( "$heading No 'Event' nor 'End'. Erasing block...", 32 ) if DEBUG; 7007 log_debug( "$heading No 'Event' nor 'End'. Erasing block...", 32 ) if DEBUG; 7008 log_debug( "$bloque_final", 255 ) if DEBUG; 6722 7009 6723 7010 # No Event in the block. Lets clear it up... … … 6788 7075 my $res = syswrite( $socket, $encriptadofinal, $largo ); 6789 7076 7077 # select( undef, undef, undef, 0.01 ); 7078 6790 7079 if ( defined $res && $res > 0 ) { 6791 7080 if ( $res != $largo ) { … … 6869 7158 @cuales_transferir = extraer_todos_los_enlaces_de_un_canal( $origin_channel, $button_server{$datosflash} ); 6870 7159 if ( @cuales_transferir == 0 ) { 6871 log_debug( "** !! REVERSE TRANSFER No reverse available, using regular sesbot to find the linked channels", 16 ) if DEBUG; 7160 log_debug( "** !! REVERSE TRANSFER No reverse available, using regular sesbot to find the linked channels", 16 ) 7161 if DEBUG; 6872 7162 if ( $sesbot{$datosflash} ) { 6873 7163 if ( @{ $sesbot{$datosflash} } ) { … … 6957 7247 $elementname =~ s/\d//g; 6958 7248 6959 if ( $datosflash =~ /_level0\.casilla/ ) { 6960 $datosflash =~ s/_level0\.casilla(\d+)/$1/g; 6961 } 6962 if ( $datosflash =~ /_level0\.rectangulo/ ) { 6963 $datosflash =~ s/_level0\.rectangulo(\d+).*/$1/g; 6964 } 7249 $datosflash =~ s/_level0\.casilla(\d+)/$1/g; 7250 $datosflash =~ s/_level0\.rectangulo(\d+).*/$1/g; 6965 7251 6966 7252 log_debug( "$heading datosflash before context $datosflash", 128 ) if DEBUG; … … 6992 7278 if ( $accion =~ /^contexto\d+/ ) { 6993 7279 6994 my ( $nada, $contextoenviado ) = split( /\@/, $datosflash );7280 my ( undef, $contextoenviado ) = split( /\@/, $datosflash ); 6995 7281 6996 7282 if ( defined($contextoenviado) ) { … … 7076 7362 @pedazos = split( /&/, $canal ); 7077 7363 $origin_context = $pedazos[1]; 7078 my @pedazos2 = split( /\^/, $pedazos[0] ); 7079 $origin_server = $pedazos2[0]; 7080 $origin_channel = $pedazos2[1]; 7364 ( $origin_server, $origin_channel ) = split( /\^/, $pedazos[0] ); 7081 7365 } 7082 7366 else { 7083 my @pedazos2 = split( /\^/, $canal ); 7084 $origin_server = $pedazos2[0]; 7085 $origin_channel = $pedazos2[1]; 7367 ( $origin_server, $origin_channel ) = split( /\^/, $canal ); 7086 7368 } 7087 7369 } … … 7140 7422 if ( defined( $buttons{$indice} ) ) { 7141 7423 $btn_num = $buttons{$indice}; 7142 $btn_num =~ s/(.*)\@(.*)/$1/g; 7424 7425 # $btn_num =~ s/(.*)\@(.*)/$1/g; 7143 7426 } 7144 7427 if ( $btn_num ne "0" ) { … … 7244 7527 if ( $destino ne "0" ) { 7245 7528 log_debug( "$heading destino es igual a $destino", 32 ) if DEBUG; 7246 my @pedazos2 = split( /\^/, $destino ); 7247 $destin_server = $pedazos2[0]; 7248 $destino = $pedazos2[1]; 7249 ( $destino, my $nada ) = split( /\&/, $pedazos2[1] ); 7529 ( $destin_server, $destino ) = split( /\^/, $destino ); 7530 ($destino) = split( /\&/, $destino ); 7250 7531 log_debug( "$heading El boton de destino es $destino en el server $destin_server", 64 ) if DEBUG; 7251 7532 } 7252 7533 } 7253 7534 7254 if ( $accion =~ /^tovoicemail/ ) { 7255 7535 if ( $accion =~ /^tospy/ ) { 7256 7536 my @cuales_transferir = get_transfer_channel( $origin_channel, $datosflash ); 7257 7537 my $cuantos = @cuales_transferir; 7258 7538 7259 if ( !defined( $to voicemail{$btn_destino} ) ) {7260 7261 # If there is no voicemailextension defined, change it to a standard7539 if ( !defined( $tospy{$btn_destino} ) ) { 7540 7541 # If there is no spy extension defined, change it to a standard 7262 7542 # trasnfer 7263 7543 if ( $cuantos > 0 ) { … … 7269 7549 } 7270 7550 else { 7271 7272 7551 my $keyext = "$origin_server^$origin_channel"; 7273 my $exttran = $to voicemail{$btn_destino};7552 my $exttran = $tospy{$btn_destino}; 7274 7553 my ( $extx, $contextx ) = split( /\@/, $exttran, 2 ); 7275 7554 … … 7290 7569 $comando .= "Priority: 1\r\n\r\n"; 7291 7570 } 7292 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7293 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 7571 if ( $button_server{$datosflash} == -1 ) { 7572 send_command_to_managers($comando); 7573 } 7574 else { 7575 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7576 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 7577 } 7294 7578 7295 7579 $tab = substr( $tab, 0, -1 ) if DEBUG; 7296 7580 return; 7297 } 7298 } 7299 if ( $accion =~ /^voicemail/ ) { 7300 my $vext = ""; 7301 my $vcontext = ""; 7581 7582 } 7583 7584 } 7585 elsif ( $accion =~ /^tovoicemail/ ) { 7586 7587 my @cuales_transferir = get_transfer_channel( $origin_channel, $datosflash ); 7588 my $cuantos = @cuales_transferir; 7589 7590 if ( !defined( $tovoicemail{$btn_destino} ) ) { 7591 7592 # If there is no voicemail extension defined, change it to a standard 7593 # trasnfer 7594 if ( $cuantos > 0 ) { 7595 $accion = "transferir"; 7596 } 7597 else { 7598 $accion = "originate"; 7599 } 7600 } 7601 else { 7602 7603 my $keyext = "$origin_server^$origin_channel"; 7604 my $exttran = $tovoicemail{$btn_destino}; 7605 my ( $extx, $contextx ) = split( /\@/, $exttran, 2 ); 7606 7607 if ( $cuantos > 0 ) { 7608 $comando = "Action: Redirect\r\n"; 7609 $comando .= "Channel: $cuales_transferir[0]\r\n"; 7610 $comando .= "Exten: $extx\r\n"; 7611 $comando .= "ActionID: 1234\r\n"; 7612 $comando .= "Context: $contextx\r\n"; 7613 $comando .= "Priority: 1\r\n\r\n"; 7614 } 7615 else { 7616 $comando = "Action: Originate\r\n"; 7617 $comando .= "Channel: $origin_channel\r\n"; 7618 $comando .= "Exten: $extx\r\n"; 7619 $comando .= "ActionID: 1234\r\n"; 7620 $comando .= "Context: $contextx\r\n"; 7621 $comando .= "Priority: 1\r\n\r\n"; 7622 } 7623 if ( $button_server{$datosflash} == -1 ) { 7624 send_command_to_managers($comando); 7625 } 7626 else { 7627 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7628 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 7629 } 7630 7631 $tab = substr( $tab, 0, -1 ) if DEBUG; 7632 return; 7633 } 7634 } 7635 elsif ( $accion =~ /^voicemail/ ) { 7636 my $vext = ""; 7637 my $vmext = ""; 7638 my $vcontext = ""; 7639 my $orichannel = ""; 7302 7640 7303 7641 if ( defined( $config->{$panelcontext}{voicemail_extension} ) ) { 7304 7642 my $voicemailext = $config->{$panelcontext}{voicemail_extension}; 7305 ( $vext, $vcontext ) = split( /\@/, $voicemailext ); 7643 ( $vmext, $orichannel ) = split( /\^/, $voicemailext ); 7644 ( $vext, $vcontext ) = split( /\@/, $vmext ); 7306 7645 } 7307 7646 else { … … 7309 7648 $tab = substr( $tab, 0, -1 ) if DEBUG; 7310 7649 return; 7650 } 7651 7652 if ( !defined($orichannel) ) { 7653 $orichannel = $origin_channel; 7311 7654 } 7312 7655 … … 7319 7662 7320 7663 $comando = "Action: Originate\r\n"; 7321 $comando .= "Channel: $ori gin_channel\r\n";7664 $comando .= "Channel: $orichannel\r\n"; 7322 7665 $comando .= "Callerid: $vclid <$vclid>\r\n"; 7323 7666 $comando .= "Async: True\r\n"; … … 7329 7672 $comando .= "\r\n"; 7330 7673 7331 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7332 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 7674 if ( $button_server{$datosflash} == -1 ) { 7675 send_command_to_managers($comando); 7676 } 7677 else { 7678 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7679 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 7680 } 7333 7681 $tab = substr( $tab, 0, -1 ) if DEBUG; 7334 7682 return; … … 7354 7702 } 7355 7703 7356 if ( $accion eq "cortar" ) { 7704 if ( $accion =~ /^startmonitor/ ) { 7705 my $buton_number = $datosflash; 7706 foreach my $ses ( @{ $sesbot{$buton_number} } ) { 7707 my $monaction = ""; 7708 my $extracomand = ""; 7709 if ( !defined( $monitoring{$ses} ) ) { 7710 log_debug( "$heading START MONITOR $ses -- ($origin_server $origin_channel)", 1 ); 7711 my $unique = find_uniqueid( $ses, $origin_server ); 7712 my ( $filename, $format ) = compute_monitoring_filename( $unique, $panelcontext ); 7713 $monaction = "Monitor"; 7714 $monitoring{$ses} = 1; 7715 $extracomand .= "File: $filename\r\n"; 7716 $extracomand .= "Format: $format\r\n"; 7717 $extracomand .= "Mix: 1\r\n"; 7718 } 7719 else { 7720 log_debug( "$heading STOP MONITOR $ses", 1 ); 7721 $monaction = "StopMonitor"; 7722 delete $monitoring{$ses}; 7723 } 7724 $comando = "Action: $monaction\r\n"; 7725 $comando .= "Channel: $ses\r\n"; 7726 $comando .= "ActionID: monitor-$monaction-$ses\r\n"; 7727 $comando .= $extracomand . "\r\n"; 7728 if ( $button_server{$datosflash} == -1 ) { 7729 send_command_to_managers($comando); 7730 } 7731 else { 7732 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7733 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 7734 } 7735 } 7736 } 7737 elsif ( $accion eq "cortar" ) { 7357 7738 my $buton_number = $datosflash; 7358 7739 log_debug( "$heading Will try to hangup channel para el boton $buton_number", 16 ) if DEBUG; … … 7363 7744 $comando .= "Channel: $_\r\n\r\n"; 7364 7745 log_debug( "-- Command received: $accion chan $_", 32 ) if DEBUG; 7365 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7366 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 7367 7368 # $comando = "Action: Command\r\n"; 7369 # $comando .= "Command: soft hangup $_\r\n\r\n"; 7370 # send_command_to_manager($comando, $p[$button_server{$datosflash}]); 7746 7747 if ( $button_server{$datosflash} == -1 ) { 7748 send_command_to_managers($comando); 7749 } 7750 else { 7751 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7752 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 7753 } 7371 7754 } 7372 7755 } … … 7381 7764 $comando .= "ActionID: meetmemute$boton_con_contexto\r\n"; 7382 7765 $comando .= "Command: meetme mute $conference $meetmemember\r\n\r\n"; 7383 send_command_to_manager( $comando, $p[ $button_server{$boton_con_contexto} ], 7384 0, $astmanproxy_servers[ $button_server{$boton_con_contexto} ] ); 7766 7767 if ( $button_server{$boton_con_contexto} == -1 ) { 7768 send_command_to_managers($comando); 7769 } 7770 else { 7771 send_command_to_manager( $comando, $p[ $button_server{$boton_con_contexto} ], 7772 0, $astmanproxy_servers[ $button_server{$boton_con_contexto} ] ); 7773 } 7385 7774 } 7386 7775 elsif ( $accion =~ /^meetmeunmute/ ) { … … 7394 7783 $comando .= "ActionID: meetmeunmute$boton_con_contexto\r\n"; 7395 7784 $comando .= "Command: meetme unmute $conference $meetmemember\r\n\r\n"; 7396 send_command_to_manager( $comando, $p[ $button_server{$boton_con_contexto} ], 7397 0, $astmanproxy_servers[ $button_server{$boton_con_contexto} ] ); 7398 } 7399 7785 7786 if ( $button_server{$boton_con_contexto} == -1 ) { 7787 send_command_to_managers($comando); 7788 } 7789 else { 7790 send_command_to_manager( $comando, $p[ $button_server{$boton_con_contexto} ], 7791 0, $astmanproxy_servers[ $button_server{$boton_con_contexto} ] ); 7792 } 7793 } 7794 7795 elsif ( $accion =~ /^atxfer/ ) { 7796 log_debug( "$heading ATXFER extension_transfer($origin_channel)", 1 ) if DEBUG; 7797 my $nro_boton_destino = $accion; 7798 $nro_boton_destino =~ s/^atxfer//g; 7799 my $contextoaagregar = ""; 7800 if ( $panelcontext ne "GENERAL" ) { 7801 $contextoaagregar = "&$panelcontext"; 7802 } 7803 my $indice = $origin_server . "^" . $origin_channel . $contextoaagregar; 7804 my $originate = $extension_transfer{$indice}; 7805 $originate =~ s/-?\d+\^(.*)/$1/; 7806 foreach ( keys(%buttons) ) { 7807 log_debug( "$heading comparing $buttons{$_} with btn_destino $btn_destino", 1 ) if DEBUG; 7808 if ( $buttons{$_} eq $btn_destino ) { 7809 if ( $canal =~ /^_/ ) { 7810 my @canalarray = @{ $sesbot{$btn_destino} }; 7811 my $canalses = $canalarray[0]; 7812 my ( $newcanal, $newses ) = separate_session_from_channel($canalses); 7813 $canal = $newcanal; 7814 } 7815 $canal =~ s/(.*)=(.*)/$1/g; 7816 log_debug( "$heading match for $btn_destino the channel is $canal", 1 ) 7817 if DEBUG; 7818 my @links = extraer_todos_los_enlaces_de_un_canal( $canal, $button_server{$datosflash} ); 7819 my @canal_transferir = @{ $sesbot{$btn_destino} }; 7820 7821 my $cuantos = @links; 7822 if ( $cuantos <= 0 ) { 7823 7824 $canal_destino = retrieve_extension($origin_server . "^" . $origin_channel); 7825 if ( $canal_destino ne "-1" ) { 7826 if ( $canal_destino =~ /\@/ ) { 7827 ( $canal_destino, $contexto ) = split( /\@/, $canal_destino ); 7828 } 7829 } 7830 $comando = "Action: Originate\r\n"; 7831 $comando .= "Channel: $destino\r\n"; 7832 $comando .= "Exten: $canal_destino\r\n"; 7833 $comando .= "Context: $contexto\r\n"; 7834 $comando .= "Priority: 1\r\n\r\n"; 7835 } 7836 else { 7837 7838 log_debug( "** $canal_transferir[0] $links[0] will be transferred to $origin_channel ($originate)", 1 ) 7839 if DEBUG; 7840 7841 my ( $vmext, $vmctx ) = split( /@/, $originate ); 7842 $comando = "Action: Atxfer\r\n"; 7843 $comando .= "Channel: " . $canal_transferir[0] . "\r\n"; 7844 $comando .= "Exten: $vmext\r\n"; 7845 $comando .= "Context: $vmctx\r\n"; 7846 $comando .= "ActionID: atxfer\r\n"; 7847 } 7848 if ( $button_server{$nro_boton_destino} == -1 ) { 7849 send_command_to_managers($comando); 7850 } 7851 else { 7852 send_command_to_manager( $comando, $p[ $button_server{$nro_boton_destino} ], 7853 0, $astmanproxy_servers[ $button_server{$nro_boton_destino} ] ); 7854 } 7855 last; 7856 } 7857 } 7858 } 7400 7859 elsif ( $accion =~ /^conference/ ) { 7401 7860 log_debug( "$heading CONFERENCE extension_transfer($origin_channel)", 1 ) if DEBUG; … … 7403 7862 my $indice = $origin_server . "^" . $origin_channel; 7404 7863 my $originate = $extension_transfer{$indice}; 7405 $originate =~ s/ \d+\^(.*)/$1/;7864 $originate =~ s/-?\d+\^(.*)/$1/; 7406 7865 foreach ( keys(%buttons) ) { 7407 7866 log_debug( "$heading comparo $buttons{$_} con btn_destino $btn_destino", 1 ) if DEBUG; … … 7467 7926 } 7468 7927 } 7469 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7470 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 7928 if ( $button_server{$datosflash} == -1 ) { 7929 send_command_to_managers($comando); 7930 } 7931 else { 7932 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7933 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 7934 } 7471 7935 last; 7472 7936 } … … 7480 7944 $comando .= "Command: database put clid $destino "; 7481 7945 $comando .= "\"$clid\"\r\n\r\n"; 7482 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7483 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 7946 if ( $button_server{$datosflash} == -1 ) { 7947 send_command_to_managers($comando); 7948 } 7949 else { 7950 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7951 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 7952 } 7484 7953 } 7485 7954 … … 7495 7964 if ( $canal_destino ne "-1" ) { 7496 7965 if ( $canal_destino =~ /\@/ ) { 7497 @pedazos = split( /\@/, $canal_destino ); 7498 $canal_destino = $pedazos[0]; 7499 $contexto = $pedazos[1]; 7966 ( $canal_destino, $contexto ) = split( /\@/, $canal_destino ); 7500 7967 } 7501 7968 7502 7969 my @cuales_transferir = get_transfer_channel( $origin_channel, $datosflash ); 7503 7504 foreach my $valor (@cuales_transferir) { 7505 log_debug( "$heading Will try to transfer $valor to extension number $canal_destino!", 16 ) 7970 if ( $canal_destino eq $park_exten && $contexto eq "parkedcalls" ) { 7971 log_debug( "$heading Will try to park $valor with announce and bounce to $canal_destino!", 16 ) 7506 7972 if DEBUG; 7507 $comando = "Action: Redirect\r\n";7508 $comando .= "Channel: $valor\r\n";7509 $comando .= "Exten: $canal_destino\r\n";7510 if ( $contexto ne "" ) {7511 $comando .= "Context: $contexto\r\n";7973 my @links; 7974 my @canal1; 7975 if ( $reverse_transfer == 1 ) { 7976 @links = @{ $sesbot{$datosflash} }; 7977 @canal1 = extraer_todos_los_enlaces_de_un_canal( $links[0], $button_server{$datosflash} ); 7512 7978 } 7513 $comando .= "Priority: 1\r\n\r\n"; 7514 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7515 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 7516 7517 if ( $calltimeout > 0 ) { 7518 $comando = "Action: AbsoluteTimeout\r\n"; 7979 else { 7980 @canal1 = @{ $sesbot{$datosflash} }; 7981 @links = extraer_todos_los_enlaces_de_un_canal( $canal1[0], $button_server{$datosflash} ); 7982 } 7983 $comando = "Action: Park\r\n"; 7984 $comando .= "Channel: $canal1[0]\r\n"; 7985 $comando .= "Channel2: $links[0]\r\n"; 7986 $comando .= "Timeout: $parktimeout\r\n\r\n"; 7987 if ( $button_server{$datosflash} == -1 ) { 7988 send_command_to_managers($comando); 7989 } 7990 else { 7991 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7992 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 7993 } 7994 } 7995 else { 7996 foreach my $valor (@cuales_transferir) { 7997 log_debug( "$heading Will try to transfer $valor to extension number $canal_destino!", 16 ) 7998 if DEBUG; 7999 $comando = "Action: Redirect\r\n"; 7519 8000 $comando .= "Channel: $valor\r\n"; 7520 $comando .= "Timeout: $calltimeout\r\n"; 7521 $comando .= "ActionID: timeout|$valor|$calltimeout\r\n"; 7522 $comando .= "\r\n"; 7523 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7524 , 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 8001 $comando .= "Exten: $canal_destino\r\n"; 8002 if ( $contexto ne "" ) { 8003 $comando .= "Context: $contexto\r\n"; 8004 } 8005 $comando .= "Priority: 1\r\n\r\n"; 8006 if ( $button_server{$datosflash} == -1 ) { 8007 send_command_to_managers($comando); 8008 } 8009 else { 8010 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 8011 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 8012 } 8013 8014 if ( $calltimeout > 0 ) { 8015 $comando = "Action: AbsoluteTimeout\r\n"; 8016 $comando .= "Channel: $valor\r\n"; 8017 $comando .= "Timeout: $calltimeout\r\n"; 8018 $comando .= "ActionID: timeout|$valor|$calltimeout\r\n"; 8019 $comando .= "\r\n"; 8020 if ( $button_server{$datosflash} == -1 ) { 8021 send_command_to_managers($comando); 8022 } 8023 else { 8024 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 8025 , 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 8026 } 8027 } 8028 7525 8029 } 7526 7527 8030 } 7528 8031 } … … 7543 8046 $comando .= "Command: database put clid $destino "; 7544 8047 $comando .= "\"$clid\"\r\n\r\n"; 7545 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7546 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 8048 if ( $button_server{$datosflash} == -1 ) { 8049 send_command_to_managers($comando); 8050 } 8051 else { 8052 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 8053 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 8054 } 7547 8055 } 7548 8056 … … 7593 8101 7594 8102 if ( $extension_destino =~ /\@/ ) { 7595 @pedazos = split( /\@/, $extension_destino ); 7596 $extension_destino = $pedazos[0]; 7597 $contexto = $pedazos[1]; 7598 } 7599 7600 log_debug( "$heading Originate from $origin_channel to extension $extension_destino!", 16 ) if DEBUG; 8103 ( $extension_destino, $contexto ) = split( /\@/, $extension_destino ); 8104 } 8105 8106 log_debug( "$heading Originate from $origin_channel to extension $extension_destino!", 16 ) 8107 if DEBUG; 7601 8108 my $keyext = "$origin_server^$origin_channel"; 7602 8109 … … 7625 8132 $comando .= "\r\n"; 7626 8133 } 7627 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7628 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 8134 if ( $button_server{$datosflash} == -1 ) { 8135 send_command_to_managers($comando); 8136 } 8137 else { 8138 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 8139 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 8140 } 7629 8141 } 7630 8142 elsif ( $accion =~ /^dial/ ) { … … 7646 8158 $comando .= "Priority: 1\r\n"; 7647 8159 $comando .= "\r\n"; 7648 send_command_to_manager( $comando, $servidor_dial, 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 8160 if ( $button_server{$datosflash} == -1 ) { 8161 send_command_to_managers($comando); 8162 } 8163 else { 8164 send_command_to_manager( $comando, $servidor_dial, 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 8165 } 7649 8166 } 7650 8167 } … … 7659 8176 } 7660 8177 $tab = substr( $tab, 0, -1 ) if DEBUG; 8178 } 8179 8180 sub compute_monitoring_filename { 8181 my $unique = shift; 8182 my $panelcontext = shift; 8183 my $filename = ""; 8184 my $format = ""; 8185 my @return; 8186 my %hasha; 8187 8188 if ( !defined( $config->{$panelcontext}{monitor_filename} ) ) { 8189 $filename = $config->{GENERAL}{monitor_filename}; 8190 } 8191 else { 8192 $filename = $config->{$panelcontext}{monitor_filename}; 8193 } 8194 if ( !defined( $config->{$panelcontext}{monitor_format} ) ) { 8195 $format = $config->{GENERAL}{monitor_format}; 8196 } 8197 else { 8198 $format = $config->{$panelcontext}{monitor_format}; 8199 } 8200 8201 while ( my ( $key, $val ) = each( %{ $datos{$unique} } ) ) { 8202 $key =~ tr/a-z/A-Z/; 8203 if ( $key eq "CALLERID" ) { 8204 $key = "CLID"; 8205 } 8206 elsif ( $key eq "CALLERIDNUM" ) { 8207 $key = "CLIDNUM"; 8208 } 8209 elsif ( $key eq "CALLERIDNAME" ) { 8210 $key = "CLIDNAME"; 8211 } 8212 elsif ( $key eq "UNIQUEID" ) { 8213 my ( $realunique, undef ) = split( /-/, $val, 2 ); 8214 $val = $realunique; 8215 } 8216 $hasha{$key} = $val; 8217 } 8218 $filename =~ s/\${CLIDNAME}/$hasha{CLIDNAME}/gi; 8219 $filename =~ s/\${CLIDNUM}/$hasha{CLIDNUM}/gi; 8220 $filename =~ s/\${CLID}/$hasha{CLID}/gi; 8221 $filename =~ s/\${UNIQUEID}/$hasha{UNIQUEID}/gi; 8222 $filename =~ s/\${CHANNEL}/$hasha{CHANNEL}/gi; 8223 $filename =~ s/\${LINK}/$hasha{LINK}/gi; 8224 $filename = formatdate($filename); 8225 $filename =~ s/\//-/gi; 8226 push @return, $filename; 8227 push @return, $format; 8228 return @return; 7661 8229 } 7662 8230 … … 7713 8281 log_debug( "$heading canal_destino = $canal_destino", 32 ) if DEBUG; 7714 8282 $canal_destino =~ s/\d+\^(.*)/$1/g; 8283 $canal_destino =~ s/^-//g; 7715 8284 log_debug( "$heading La extension para $param es $canal_destino", 32 ) if DEBUG; 7716 8285 return $canal_destino; … … 7752 8321 my $canalid = shift; 7753 8322 my $member = ""; 7754 my $nada = "";7755 8323 my $showagents = 0; 7756 8324 … … 7762 8330 } 7763 8331 else { 7764 ( $member, $nada) = separate_session_from_channel($canalid);8332 ( $member, undef ) = separate_session_from_channel($canalid); 7765 8333 } 7766 8334 } … … 7779 8347 7780 8348 if ( $showagents == 1 ) { 7781 send_command_to_manager( "Action: Command\r\nActionId: agents\r\nCommand: show agents\r\n\r\n", $socket2 ); 8349 8350 #send_command_to_manager( "Action: Command\r\nActionId: agents\r\nCommand: show agents\r\n\r\n", $socket2 ); 8351 send_command_to_manager( "Action: Agents\r\n\r\n", $socket2 ); 7782 8352 } 7783 8353 if ( defined($member) ) { … … 7911 8481 for $interno ( keys %botonpermanenttext ) { 7912 8482 if ( $botonpermanenttext{$interno} ne "" ) { 7913 print "permanente $interno -$botonpermanenttext{$interno}-\n";7914 8483 send_status_to_flash( $socket, "$interno|settext|$botonpermanenttext{$interno}", 0 ); 7915 8484 } … … 8008 8577 8009 8578 if ( defined($socket) && $socket ne "" ) { 8010 my @pedazos= split( /\|/, $manager_socket{$socket} );8011 if ( $ pedazos[0]eq $ip_addy{$socket} ) {8579 my ($ipactual) = split( /\|/, $manager_socket{$socket} ); 8580 if ( $ipactual eq $ip_addy{$socket} ) { 8012 8581 my $contador = 0; 8013 8582 foreach my $valor (@manager_host) { 8014 if ( $valor eq $ pedazos[0]) {8583 if ( $valor eq $ipactual ) { 8015 8584 $nro_servidor = $contador; 8016 8585 } … … 8033 8602 send_command_to_manager( "Action: Command\r\nActionID: parkedcalls\r\nCommand: show parkedcalls\r\n\r\n", $socket ); 8034 8603 8035 # request_queue_status( $socket, "initialrequest" );8604 # request_queue_status( $socket, "initialrequest" ); 8036 8605 # Send commands to check the mailbox status for each mailbox defined 8037 8606 while ( my ( $key, $val ) = each(%mailbox) ) { 8038 my @pedacitos = split( /\^/, $key ); 8039 my $servidormbox = $pedacitos[0]; 8607 my ($servidormbox) = split( /\^/, $key ); 8040 8608 if ( "$servidormbox" eq "$nro_servidor" ) { 8041 8609 log_debug( "$heading mailbox $ip_addy{$socket} $key $val", 32 ) if DEBUG; … … 8065 8633 8066 8634 if ( $valor =~ /\^/ ) { 8067 my @pedacitos = split( /\^/, $valor ); 8068 $servidormeetme = $pedacitos[0]; 8069 $meetmeroom = $pedacitos[1]; 8635 ( $servidormeetme, $meetmeroom ) = split( /\^/, $valor ); 8070 8636 } 8071 8637 else { … … 8102 8668 my $interno = ""; 8103 8669 my $estado = ""; 8104 my $nada = "";8105 8670 my $conference = 0; 8106 8671 my $usernum = 0; … … 8158 8723 } 8159 8724 } 8160 elsif ( $texto =~ "ActionID: agents" ) { 8161 log_debug( "$heading process agents", 16 ) if DEBUG; 8162 my $agent_number; 8163 my $agent_state; 8164 my $agent_name; 8165 8166 # Show Agents CLI command, generates fake events 8167 8168 foreach (@lineas) { 8169 $_ =~ s/\s+/ /g; 8170 /(\d+) \((.*)\) (.*) (\(.*\))/; 8171 if ( defined($1) ) { 8172 $agent_number = $1; 8173 $agent_name = $2; 8174 $agent_state = $3; 8175 $agents_name{"$server^$agent_number"} = $agent_name; 8176 set_queueobject( $server, "AGENT/$agent_number", "name", $agent_name ); 8177 } 8178 8179 if ( defined($3) ) { 8180 if ( $agent_state =~ /available at/ ) { 8181 8182 # Agent callback login 8183 $agent_state =~ s/.*'(.*)'.*/$1/g; 8184 $bloque[$contador]{"Event"} = "Agentcallbacklogin"; 8185 $bloque[$contador]{"Loginchan"} = $agent_state; 8186 $bloque[$contador]{"Agent"} = $agent_number; 8187 $bloque[$contador]{"Server"} = "$server"; 8188 $contador++; 8189 } 8190 8191 if ( $agent_state =~ /logged in on/ ) { 8192 8193 # Agent login 8194 $agent_state =~ s/\s+/ /g; 8195 $agent_state =~ s/logged in on //g; 8196 $agent_state =~ s/([^ ]*).*/$1/g; 8197 8198 $bloque[$contador]{Event} = "Agentlogin"; 8199 $bloque[$contador]{Channel} = $agent_state; 8200 $bloque[$contador]{Agent} = $agent_number; 8201 $bloque[$contador]{Server} = $server; 8202 $contador++; 8203 } 8204 if ( $agent_state =~ /not logged in/ ) { 8205 $bloque[$contador]{Event} = "Agentlogoff"; 8206 $bloque[$contador]{Agent} = $agent_number; 8207 $bloque[$contador]{Server} = $server; 8208 $bloque[$contador]{Fake} = 1; 8209 $contador++; 8210 } 8211 } 8212 } 8213 } 8725 8726 #elsif ( $texto =~ "ActionID: agents" ) { 8727 # log_debug( "$heading process agents", 16 ) if DEBUG; 8728 # my $agent_number; 8729 # my $agent_state; 8730 # my $agent_name; 8731 # 8732 # # Show Agents CLI command, generates fake events 8733 # 8734 # foreach (@lineas) { 8735 # $_ =~ s/\s+/ /g; 8736 # /(\d+) \((.*)\) (.*) (\(.*\))/; 8737 # if ( defined($1) ) { 8738 # $agent_number = $1; 8739 # $agent_name = $2; 8740 # $agent_state = $3; 8741 # $agents_name{"$server^$agent_number"} = $agent_name; 8742 # set_queueobject( $server, "AGENT/$agent_number", "name", $agent_name ); 8743 # } 8744 # 8745 # if ( defined($3) ) { 8746 # if ( $agent_state =~ /available at/ ) { 8747 # 8748 # # Agent callback login 8749 # $agent_state =~ s/.*'(.*)'.*/$1/g; 8750 # $bloque[$contador]{"Event"} = "Agentcallbacklogin"; 8751 # $bloque[$contador]{"Loginchan"} = $agent_state; 8752 # $bloque[$contador]{"Agent"} = $agent_number; 8753 # $bloque[$contador]{"Server"} = "$server"; 8754 # $contador++; 8755 # } 8756 # 8757 # if ( $agent_state =~ /logged in on/ ) { 8758 # 8759 # # Agent login 8760 # $agent_state =~ s/\s+/ /g; 8761 # $agent_state =~ s/logged in on //g; 8762 # $agent_state =~ s/([^ ]*).*/$1/g; 8763 # 8764 # $bloque[$contador]{Event} = "Agentlogin"; 8765 # $bloque[$contador]{Channel} = $agent_state; 8766 # $bloque[$contador]{Agent} = $agent_number; 8767 # $bloque[$contador]{Server} = $server; 8768 # $contador++; 8769 # } 8770 # if ( $agent_state =~ /not logged in/ ) { 8771 # $bloque[$contador]{Event} = "Agentlogoff"; 8772 # $bloque[$contador]{Agent} = $agent_number; 8773 # $bloque[$contador]{Server} = $server; 8774 # $bloque[$contador]{Fake} = 1; 8775 # $contador++; 8776 # } 8777 # } 8778 # } 8779 # } 8214 8780 elsif ( $texto =~ /ActionID: astdb-/ ) { 8215 8781 log_debug( "$heading process astdb", 16 ) if DEBUG; … … 8258 8824 } 8259 8825 my $canal_a_mutear = $buttons_reverse{$quecanal}; 8260 my @pedazos = split /\^/, $canal_a_mutear; 8261 $canal_a_mutear = $pedazos[1]; 8826 ( undef, $canal_a_mutear ) = split /\^/, $canal_a_mutear; 8262 8827 $canal_a_mutear =~ s/(.*)\&(.*)/$1/g; 8263 8828 $bloque[$contador]{"Event"} = $quecomando; … … 8282 8847 my $estado = substr( $valor, $statPos ); 8283 8848 $valor =~ s/\s+/ /g; 8284 my @parametros = split( " ", $valor ); 8285 my $interno = $parametros[0]; 8849 my ( $interno, $dirip ) = split( " ", $valor ); 8286 8850 8287 8851 if ( $interno =~ /\// ) { 8288 my @partecitas = split( /\//, $interno ); 8289 $interno = $partecitas[0]; 8290 } 8291 my $dirip = $parametros[1]; 8852 ($interno) = split( /\//, $interno ); 8853 } 8292 8854 8293 8855 if ( defined($estado) && $estado ne "" ) { … … 8376 8938 $valor =~ s/\s+/ /g; 8377 8939 if ( $valor eq "" ) { next; } 8378 my @parametros = split( " ", $valor ); 8379 my $interno = $parametros[0]; 8380 my $dirip = $parametros[1]; 8381 $interno =~ s/(.*)\/(.*)/$1/g; 8940 my ( $interno, $dirip ) = split( " ", $valor ); 8941 ( $interno, undef ) = split( /\//, $interno ); 8382 8942 8383 8943 if ( defined($interno) ) { … … 8521 9081 $match++; 8522 9082 } 8523 if ( $key eq "Server" && $val eq $server) {9083 if ( $key eq "Server" && ( $val eq $server || $server eq "-1" ) ) { 8524 9084 $match++; 8525 9085 } … … 8588 9148 if ( defined($_) && $_ ne "" ) { 8589 9149 log_debug( "$heading Enviando status a " . $ip_addy{$_}, 16 ) if DEBUG; 8590 my @pedazos= split( /\|/, $manager_socket{$_} );8591 8592 if ( $ pedazos[0]eq $ip_addy{$_} ) {9150 my ($ip) = split( /\|/, $manager_socket{$_} ); 9151 9152 if ( $ip eq $ip_addy{$_} ) { 8593 9153 my $contador = 0; 8594 9154 foreach my $valor (@manager_host) { 8595 if ( $valor eq $ pedazos[0]) {9155 if ( $valor eq $ip ) { 8596 9156 $nro_servidor = $contador; 8597 9157 } … … 8618 9178 # Send commands to check the mailbox status for each mailbox defined 8619 9179 while ( my ( $key, $val ) = each(%mailbox) ) { 8620 my @pedacitos = split( /\^/, $key ); 8621 my $servidormbox = $pedacitos[0]; 9180 my ($servidormbox) = split( /\^/, $key ); 8622 9181 if ( "$servidormbox" eq "$nro_servidor" ) { 8623 9182 log_debug( "$heading mailbox $ip_addy{$_} $key $val", 32 ) if DEBUG; … … 8629 9188 } 8630 9189 alarm($poll_interval); 9190 } 9191 9192 sub send_policy_to_flash { 9193 my $socket = shift; 9194 if ( !defined($socket) ) { 9195 log_debug( "POLICY socket $socket not open!!!", 64 ) if DEBUG; 9196 } 9197 my $policy = 9198 "<?xml version=\"1.0\"?>\r\n<!DOCTYPE cross-domain-policy SYSTEM \"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\">\r\n<cross-domain-policy>\r\n<allow-access-from domain=\"*\" to-ports=\"$listen_port\" />\r\n</cross-domain-policy>\r\n\0"; 9199 actual_syswrite( $socket, $policy, "isclient", "policy enviado\n" ); 8631 9200 } 8632 9201 … … 8651 9220 if ( $encriptado =~ /key\|0/ ) { 8652 9221 $but_no = '0'; 8653 $encriptado =~ m/(.*)\|(.*)\|(.*)/; 8654 $cmd = $2; 8655 $data = $1; 8656 9222 ( $data, $cmd ) = split( /\|/, $encriptado ); 8657 9223 } 8658 9224 else { 8659 9225 $but_no = $status; 8660 $but_no =~ s/(\d+) (.*)\|(.*)/$1/g;9226 $but_no =~ s/(\d+).*\|.*/$1/g; 8661 9227 $contexto = $status; 8662 9228 $contexto =~ s/([^\|]*).*/$1/g; 8663 $contexto =~ m/(.*)\@(.*)/; 8664 8665 if ( defined($2) ) { 8666 $contexto = $2; 8667 } 8668 else { 8669 $contexto = ""; 8670 } 8671 $status =~ m/(.*)\|(.*)\|(.*)/; 8672 $cmd = $2; 8673 $data = $3; 9229 $contexto =~ m/.*\@(.*)/; 9230 $contexto = $1 ? $1 : ""; 9231 ( undef, $cmd, $data ) = split( /\|/, $status ); 8674 9232 8675 9233 if ( $contexto ne "" && $cmd ne "restrict" ) { … … 8727 9285 } 8728 9286 9287 sub send_command_to_managers { 9288 my $comando = shift; 9289 foreach (@p) { 9290 send_command_to_manager( $comando, $_ ); 9291 } 9292 } 9293 8729 9294 sub send_command_to_manager { 8730 9295 my $comando = shift; … … 8734 9299 my @todos_sockets = (); 8735 9300 8736 if ( !defined($socket) && $astmanproxy_server eq "" ) {8737 log_debug( "No socket defined nor astmanproxy", 32 ) if DEBUG;8738 return;8739 }9301 # if ( !defined($socket) && $astmanproxy_server eq "" ) { 9302 # log_debug( "No socket defined nor astmanproxy", 32 ) if DEBUG; 9303 # return; 9304 # } 8740 9305 8741 9306 if ( !defined($noneedtoauth) ) { … … 8756 9321 return; 8757 9322 } 8758 8759 # my @partes = split( /\|/, $manager_socket{$socket} );8760 8761 # $comando = "";8762 9323 8763 9324 if ( $comando eq "" ) { … … 8784 9345 } 8785 9346 8786 sub recompute_queues { 9347 sub construct_cmd { 9348 my $cola = shift; 8787 9349 my $canalid = shift; 8788 my @return_corto; 8789 my @return_ocupado; 9350 return $cola->{$canalid}{QUEUE} . "=" 9351 . $cola->{$canalid}{POSITION} 9352 . "|$_[0]|$_[1]|" 9353 . $cola->{$canalid}{QUEUE} . "-" 9354 . $cola->{$canalid}{SERVER} 9355 . "|$canalid"; 9356 } 9357 9358 sub recompute_queues_onjoin { 9359 my ( $hash_temporal, $server, $canalid ) = @_; 9360 my @return = (); 9361 my @corto = (); 9362 my @ocupado = (); 9363 my $qclidnum = ""; 9364 my $qclidname = ""; 9365 9366 if ( defined( $hash_temporal->{CallerIDName} ) ) { 9367 $qclidnum = $hash_temporal->{CallerID}; 9368 $qclidname = $hash_temporal->{CallerIDName}; 9369 } 9370 elsif ( defined( $hash_temporal->{CalleridName} ) ) { 9371 $qclidnum = $hash_temporal->{Callerid}; 9372 $qclidname = $hash_temporal->{CalleridName}; 9373 } 9374 else { 9375 ( $qclidnum, $qclidname ) = split_callerid( $hash_temporal->{CallerID} ); 9376 } 9377 my $texto_pos = "[$qclidname $qclidnum]"; 9378 9379 my $canal = "QUEUE/" . $hash_temporal->{Queue}; 9380 my $position = $hash_temporal->{Position}; 9381 $canal =~ tr/a-z/A-Z/; 9382 my $unico_id = "$canal-$server"; 9383 9384 # Verify if the position is already taken (by means of QUEUE_PRIO) 9385 my $tengo = 0; 9386 foreach my $id ( keys %{$cola} ) { 9387 unless ( $cola->{$id}{QUEUE} ) { 9388 delete( $cola->{$id} ); 9389 next; 9390 } 9391 9392 if ( $canal eq $cola->{$id}{QUEUE} ) { 9393 if ( $position eq $cola->{$id}{POSITION} ) { 9394 $tengo = 1; 9395 } 9396 } 9397 } 9398 if ( $tengo == 1 ) { 9399 9400 # Queue prio! 9401 my $time = time(); 9402 foreach my $id ( keys %{$cola} ) { 9403 unless ( $cola->{$id}{QUEUE} ) { 9404 delete( $cola->{$id} ); 9405 next; 9406 } 9407 9408 if ( $canal eq $cola->{$id}{QUEUE} ) { 9409 if ( $cola->{$id}{POSITION} >= $position ) { 9410 my $diftime = $time - $cola->{$id}{TIME}; 9411 if ( $queue_hide == 1 ) { 9412 push @corto, construct_cmd( $cola, $id, "setalpha", "000" ); 9413 } 9414 push @corto, construct_cmd( $cola, $id, "corto", "" ); 9415 9416 $cola->{$id}{POSITION}++; 9417 my $clidtext = $cola->{$id}{CLIDNAME} . " " . $cola->{$id}{CLID}; 9418 push @ocupado, construct_cmd( $cola, $id, "settimer", $diftime ); 9419 push @ocupado, construct_cmd( $cola, $id, "ocupado", "[$clidtext]" ); 9420 } 9421 } 9422 } 9423 @ocupado = unique(@ocupado); 9424 @corto = unique(@corto); 9425 } 9426 9427 # Normal, add new call at the end of the queue 9428 push @return, "$canal=$position|ocupado2|$texto_pos|$unico_id|$canalid"; 9429 push @return, "$canal=$position|setalpha|100|$unico_id|$canalid"; 9430 9431 my $tiempo = time(); 9432 if ( defined( $hash_temporal->{Wait} ) ) { 9433 $tiempo = $tiempo - $hash_temporal->{Wait}; 9434 push @return, "$canal=$position|settimer|" . $hash_temporal->{Wait} . "\@UP|$unico_id|$canalid"; 9435 } 9436 $cola->{$canalid}{POSITION} = $position; 9437 $cola->{$canalid}{QUEUE} = $canal; 9438 $cola->{$canalid}{CLID} = $qclidnum; 9439 $cola->{$canalid}{CLIDNAME} = $qclidname; 9440 $cola->{$canalid}{SERVER} = $server; 9441 $cola->{$canalid}{TIME} = $tiempo; 9442 if (@corto) { 9443 return ( @corto, @ocupado, @return ); 9444 } 9445 else { 9446 return @return; 9447 } 9448 } 9449 9450 sub recompute_queues_onleave { 9451 my $canalid = shift; 9452 my @corto; 9453 my @ocupado; 8790 9454 my $maxtime = 0; 8791 8792 print_recomputequeues(); 9455 my $save_id; 9456 my $time = time(); 9457 9458 #print_recomputequeues(); 8793 9459 8794 9460 my $header = "**RECOMP QUEUE"; … … 8801 9467 8802 9468 if ( $queue_hide == 1 ) { 8803 push @return_corto, 8804 $cola->{$canalid}{QUEUE} . "=" 8805 . $cola->{$canalid}{POSITION} 8806 . "|setalpha|000|" 8807 . $cola->{$canalid}{QUEUE} . "-" 8808 . $cola->{$canalid}{SERVER} 8809 . "|$canalid"; 8810 } 8811 push @return_corto, 8812 $cola->{$canalid}{QUEUE} . "=" 8813 . $cola->{$canalid}{POSITION} 8814 . "|corto||" 8815 . $cola->{$canalid}{QUEUE} . "-" 8816 . $cola->{$canalid}{SERVER} 8817 . "|$canalid"; 9469 push @corto, construct_cmd( $cola, $canalid, "setalpha", "000" ); 9470 } 9471 push @corto, construct_cmd( $cola, $canalid, "corto", "" ); 9472 8818 9473 delete $cola->{$canalid}; 8819 my $save_id;8820 9474 8821 9475 foreach my $id ( keys %{$cola} ) { 8822 if ( !defined( $cola->{$id}{QUEUE} )) {9476 unless ( $cola->{$id}{QUEUE} ) { 8823 9477 delete( $cola->{$id} ); 8824 9478 next; 8825 9479 } 8826 9480 8827 #foreach ( keys %{ $cola->{$id} } ) {8828 # print "key de cola $_\n";8829 #}8830 9481 if ( $queue_to_recompute eq $cola->{$id}{QUEUE} ) { 8831 9482 $save_id = $id; 8832 my $diftime = time()- $cola->{$id}{TIME};9483 my $diftime = $time - $cola->{$id}{TIME}; 8833 9484 if ( $diftime > $maxtime ) { 8834 9485 $maxtime = $diftime; … … 8838 9489 my $clidtext = $cola->{$id}{CLIDNAME} . " " . $cola->{$id}{CLID}; 8839 9490 if ( $queue_hide == 1 ) { 8840 push @return_corto, 8841 $cola->{$id}{QUEUE} . "=" 8842 . $cola->{$id}{POSITION} 8843 . "|setalpha|000|" 8844 . $cola->{$id}{QUEUE} . "-" 8845 . $cola->{$id}{SERVER} . "|$id"; 8846 } 8847 push @return_corto, 8848 $cola->{$id}{QUEUE} . "=" 8849 . $cola->{$id}{POSITION} 8850 . "|corto||" 8851 . $cola->{$id}{QUEUE} . "-" 8852 . $cola->{$id}{SERVER} . "|$id"; 9491 push @corto, construct_cmd( $cola, $id, "setalpha", "000" ); 9492 } 9493 push @corto, construct_cmd( $cola, $id, "corto", "" ); 8853 9494 $cola->{$id}{POSITION}--; 8854 push @return_ocupado, 8855 $cola->{$id}{QUEUE} . "=" 8856 . $cola->{$id}{POSITION} 8857 . "|settimer|$diftime|" 8858 . $cola->{$id}{QUEUE} . "-" 8859 . $cola->{$id}{SERVER} . "|$id"; 8860 push @return_ocupado, 8861 $cola->{$id}{QUEUE} . "=" 8862 . $cola->{$id}{POSITION} 8863 . "|state|busy|" 8864 . $cola->{$id}{QUEUE} . "-" 8865 . $cola->{$id}{SERVER} . "|$id"; 8866 push @return_ocupado, $cola->{$id}{QUEUE} . "|state|busy|" . $cola->{$id}{QUEUE} . "-" . $cola->{$id}{SERVER} . "|$id"; 8867 push @return_ocupado, 8868 $cola->{$id}{QUEUE} . "|settimer|0\@STOP|" . $cola->{$id}{QUEUE} . "-" . $cola->{$id}{SERVER} . "|$id"; 8869 push @return_ocupado, 8870 $cola->{$id}{QUEUE} . "=" 8871 . $cola->{$id}{POSITION} 8872 . "|settext|[$clidtext]|" 8873 . $cola->{$id}{QUEUE} . "-" 8874 . $cola->{$id}{SERVER} . "|$id"; 9495 push @ocupado, construct_cmd( $cola, $id, "settimer", $diftime ); 9496 push @ocupado, construct_cmd( $cola, $id, "ocupado", "[$clidtext]" ); 9497 9498 #push @ocupado, $cola->{$id}{QUEUE} . "|ocupado|[$clidtext]|" . $cola->{$id}{QUEUE} . "-" . $cola->{$id}{SERVER} . "|$id"; 9499 push @ocupado, $cola->{$id}{QUEUE} . "|settimer|0\@STOP|" . $cola->{$id}{QUEUE} . "-" . $cola->{$id}{SERVER} . "|$id"; 8875 9500 } 8876 9501 } 8877 9502 } 8878 9503 if ( defined($save_id) ) { 8879 push @ return_ocupado,9504 push @ocupado, 8880 9505 $cola->{$save_id}{QUEUE} . "|settimer|$maxtime\@UP|" . $cola->{$save_id}{QUEUE} . "-" . $cola->{$save_id}{SERVER} . "|$save_id"; 8881 9506 } … … 8885 9510 8886 9511 delete $cola->{$canalid}; 8887 @return_ocupado = unique(@return_ocupado); 8888 8889 if (@return_corto) { 8890 my @todos = (); 8891 push @todos, @return_corto; 8892 push @todos, @return_ocupado; 8893 return @todos; 8894 } 8895 8896 # TEST|corto|&waitingonqueue,0,&|TEST-0|SIP/16-ea0c 9512 @ocupado = unique(@ocupado); 9513 9514 if (@corto) { 9515 return ( @corto, @ocupado ); 9516 } 9517 8897 9518 } 8898 9519 … … 8955 9576 } 8956 9577 8957 sub inArray {8958 my $val = shift;8959 for my $elem (@_) {8960 if ( $val eq $elem ) {8961 return 1;8962 }8963 }8964 return 0;8965 }8966 8967 9578 sub encode_base64 { 8968 9579 my $res = ""; … … 8996 9607 my $devuelve = ""; 8997 9608 9609 if ( !defined($name) ) { $name = "" } 9610 8998 9611 if ( $name eq "<unknown>" ) { $name = ""; } 8999 9612 … … 9007 9620 9008 9621 @chars_number = split( //, $numero ); 9009 @chars_format = split( //, $format ); 9010 9011 @chars_format = reverse @chars_format; 9622 @chars_format = reverse split( //, $format ); 9012 9623 9013 9624 my $parate = 0; … … 9035 9646 } 9036 9647 9037 @result = reverse @result; 9038 $devuelve = join( "", @result ); 9648 $devuelve = join( "", reverse @result ); 9039 9649 $devuelve =~ s/\${CLIDNAME}/$name/gi; 9040 9650 return $devuelve; … … 9105 9715 9106 9716 if ( !$keys_socket{$socket} ) { 9107 print "nocrypt = 1\n";9108 9717 $nocrypt = 1; 9109 9718 } … … 9877 10486 } 9878 10487 10488 sub formatdate { 10489 my $format = shift; 10490 @_ = localtime( shift || time ); 10491 my $h = sprintf( "%02d", $_[2] ); 10492 my $i = sprintf( "%02d", $_[1] ); 10493 my $s = sprintf( "%02d", $_[0] ); 10494 my $m = sprintf( "%02d", $_[4] + 1 ); 10495 my $d = sprintf( "%02d", $_[3] ); 10496 my $y = sprintf( "%02d", ( $_[5] + 1900 ) % 100 ); 10497 my $Y = sprintf( "%04d", $_[5] + 1900 ); 10498 10499 $format =~ s/%Y/$Y/g; 10500 $format =~ s/%y/$y/g; 10501 $format =~ s/%h/$h/g; 10502 $format =~ s/%i/$i/g; 10503 $format =~ s/%s/$s/g; 10504 $format =~ s/%m/$m/g; 10505 $format =~ s/%d/$d/g; 10506 return $format; 10507 } 10508 9879 10509 sub add_queueobject { 9880 10510 my $server = shift; … … 9884 10514 my @return; 9885 10515 9886 print "add queueobject $server $queue $agent\n";9887 10516 $queue_object->{$server}{$queue}{$agent}{status} = 1; 9888 10517 @return = compute_queueobject($server); … … 9897 10526 my @return; 9898 10527 9899 print "delete queueobject $server $queue $agent\n";9900 10528 delete( $queue_object->{$server}{$queue}{$agent} ); 9901 10529 @return = compute_queueobject($server); … … 9918 10546 if ( $iagent eq $agent ) { 9919 10547 $queue_object->{$iserver}{$iqueue}{$iagent}{$property} = $value; 9920 print "property set!\n";9921 10548 } 9922 10549 }
