Changeset 4263
- Timestamp:
- 06/28/07 14:41:22 (6 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/branches/2.3/amp_conf/htdocs_panel/op_server.pl
r2505 r4263 34 34 use POSIX qw(setsid EWOULDBLOCK); 35 35 36 my $FOP_VERSION = "026.001"; 37 my %datos = (); 38 my %sesbot = (); 39 my %linkbot = (); 40 my %cache_hit = (); 41 my %estadoboton = (); 36 my $FOP_VERSION = "0.27"; 37 my %datos = (); 38 my %sesbot = (); 39 my %linkbot = (); 40 my %cache_hit = (); 41 my %estadoboton = (); 42 my %preestadoboton = (); 43 44 my %boton_paused = (); 45 my %boton_agentready = (); 46 my %boton_agentpaused = (); 47 my %boton_agentbusy = (); 48 my %boton_agentlogedof = (); 42 49 my %botonled = (); 43 50 my %botonalpha = (); 51 my %botonledcolor = (); 44 52 my %botonregistrado = (); 45 53 my %boton_ip = (); … … 52 60 my %botonmeetme = (); 53 61 my %botonclid = (); 62 my %botonpermanenttext = (); 54 63 my %botonqueue = (); 55 64 my %botonqueue_count = (); … … 63 72 my %autenticado = (); 64 73 my %auto_conference = (); 74 my %attendant_transfer = (); 75 my %attendant_pending = (); 76 my %pending_uniqueid_attendant = (); 77 my %mute_other = (); 78 my %autosip = (); 79 my %cnt_auto_pos = (); 80 my $cnt_autosip = 0; 81 my %autosip_detail = (); 65 82 my %buttons = (); 66 83 my %buttons_queue = (); 67 84 my %buttons_queue_reverse = (); 68 85 my %buttons_preserve_case = (); 86 my %buttons_astdbkey = (); 69 87 my %button_server = (); 70 88 my %buttons_reverse = (); … … 72 90 my %iconos = (); 73 91 my %urls = (); 92 my %alarms = (); 74 93 my %targets = (); 75 94 my %remote_callerid = (); … … 92 111 my %client_queue_nocrypt = (); 93 112 my %ip_addy = (); 94 my %count_queue = (); 113 my %agents_available_on_queue = (); 114 my $queue_object = {}; 95 115 my %is_agent = (); 96 116 my %agents_on_queue = (); … … 107 127 my $bloque_final; 108 128 my $todo; 129 my $reload_pending = 0; 109 130 my $regexp_buttons = 0; 131 my $auto_buttons = 0; 132 my @auto_config = (); 110 133 my $queueagent_buttons = 0; 111 134 my $defaultlanguage; … … 161 184 my $clid_privacy; 162 185 my %clid_private; 186 my %group_count; 163 187 my $show_ip; 164 188 my $queue_hide; … … 175 199 my $first_room; 176 200 my $last_room; 177 my $meetme_context;178 201 my $clid_format; 179 202 my $directorio = ""; … … 185 208 my %shapes; 186 209 my %legends; 210 my %images; 187 211 my %no_encryption = (); 188 212 my %total_shapes; 189 213 my %total_legends; 214 my %total_images; 190 215 my @btninclude = (); 191 216 my @styleinclude = (); … … 309 334 } 310 335 311 open STDIN, '/dev/null' or die "Can't read /dev/null: $!";312 313 336 if ( $logdir ne "" ) { 314 337 open( STDOUT, ">>$logdir/output.log" ) … … 316 339 open( STDERR, ">>$logdir/error.log" ) 317 340 or die "Can't open output log $logdir/error.log"; 318 } else {319 open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";320 open STDERR, '>/dev/null' or die "Can't write to /dev/null: $!";321 341 } 322 342 … … 325 345 exit if $pid; 326 346 setsid or die "Can't start a new session: $!"; 327 open MYPIDFILE, ">$pidfile"; 347 open MYPIDFILE, ">$pidfile" 348 or die "Failed to open PID file $pidfile for writing."; 328 349 print MYPIDFILE $$; 329 350 close MYPIDFILE; … … 513 534 %barge_rooms = map { $todos_los_rooms[$_], 0 } 0 .. $#todos_los_rooms; 514 535 515 $meetme_context = $config->{GENERAL}{conference_context}; 516 $clid_format = $config->{GENERAL}{clid_format}; 536 $clid_format = $config->{GENERAL}{clid_format}; 517 537 518 538 $flash_file = $flash_dir . "/variables.txt"; … … 761 781 next unless ( $contador >= 0 ); 762 782 my ( $key, $val ) = split( /=/, $_, 2 ); 783 if ( !defined($val) ) { $val = ""; } 763 784 $key =~ tr/A-Z/a-z/; 764 785 $key =~ s/^\s+//g; … … 781 802 782 803 close(CONFIG); 804 } 805 806 # Read now the auto_sip button config files 807 foreach my $papi ( sort keys %autosip ) { 808 if ( !defined( $autosip{$papi}{channel} ) ) { next; } 809 810 $contador++; 811 log_debug( "-----", 16 ) if DEBUG; 812 $btn_cfg[$contador]{'channel_preserve_case'} = $autosip{$papi}{channel}; 813 $btn_cfg[$contador]{'channel'} = $autosip{$papi}{channel}; 814 if ( defined( $cnt_auto_pos{ $autosip{$papi}{autonumber} } ) ) { 815 $cnt_auto_pos{ $autosip{$papi}{autonumber} }++; 816 } 817 else { 818 $cnt_auto_pos{ $autosip{$papi}{autonumber} } = 0; 819 } 820 821 my $pos = $autosip{$papi}{starting_position} + $cnt_auto_pos{ $autosip{$papi}{autonumber} }; 822 $btn_cfg[$contador]{'position'} = $pos; 823 $btn_cfg[$contador]{'channel'} = $autosip{$papi}{channel}; 824 my $logblock = "\n[" . $autosip{$papi}{channel} . "]\n"; 825 log_debug( $autosip{$papi}{channel} . " at position $pos", 16 ) if DEBUG; 826 827 while ( my ( $key, $val ) = each( %{ $autosip{$papi} } ) ) { 828 if ( $val eq "" ) { 829 log_debug( "** Empty value for autosip for key $key, button $papi", 1 ) if DEBUG; 830 next; 831 } 832 $btn_cfg[$contador]{$key} = $val; 833 $logblock .= "$key=$val\n"; 834 if ( $key eq "panel_context" ) { 835 push @contextos, $val; 836 } 837 } 838 log_debug( "$logblock", 1 ) if DEBUG; 783 839 } 784 840 … … 817 873 my %rectangles_counter; 818 874 my %legends_counter; 819 875 my %images_counter; 876 877 my $cont_auto = 0; 820 878 CONFIG: 821 879 foreach (@btn_cfg) { … … 831 889 } 832 890 } 891 if ( $tmphash{channel} =~ /^AUTO/i ) { 892 $auto_buttons = 1; 893 while ( my ( $key, $val ) = each(%tmphash) ) { 894 $auto_config[$cont_auto]{$key} = $val; 895 } 896 $cont_auto++; 897 next CONFIG; 898 } 899 833 900 if ( $tmphash{channel} =~ /^_/ ) { 834 901 $regexp_buttons = 1; … … 836 903 elsif ( $tmphash{channel} =~ /^QUEUEAGENT\//i ) { 837 904 $queueagent_buttons = 1; 905 } 906 elsif ( $tmphash{channel} =~ /^image$/i ) { 907 908 # Image config primitive 909 910 if ( defined( $tmphash{panel_context} ) ) { 911 $tmphash{panel_context} =~ tr/a-z/A-Z/; 912 $tmphash{panel_context} =~ s/^DEFAULT$//xms; 913 } 914 else { 915 $tmphash{panel_context} = ""; 916 } 917 my $conttemp = $tmphash{panel_context}; 918 if ( $conttemp eq "" ) { $conttemp = "GENERAL"; } 919 920 if ( !defined( $tmphash{src} ) ) { 921 next CONFIG; 922 } 923 if ( !defined( $tmphash{url} ) ) { 924 $tmphash{url} = "no"; 925 } 926 if ( !defined( $tmphash{target} ) ) { 927 $tmphash{target} = "NONTARFOP"; 928 } 929 $images_counter{$conttemp}++; 930 if ( $images_counter{$conttemp} > 1 ) { 931 $images{$conttemp} .= "&"; 932 } 933 $total_images{$conttemp}++; 934 $images{$conttemp} .= "image_$images_counter{$conttemp}=" . $tmphash{x} . ","; 935 $images{$conttemp} .= $tmphash{y} . ","; 936 $images{$conttemp} .= $tmphash{src} . ","; 937 $images{$conttemp} .= $tmphash{url} . ","; 938 $images{$conttemp} .= $tmphash{target}; 939 next CONFIG; 940 838 941 } 839 942 elsif ( $tmphash{channel} =~ /^legend$/i ) { … … 972 1075 } 973 1076 1077 if ( !defined( $tmphash{alarm} ) ) { 1078 $tmphash{alarm} = "0"; 1079 1080 } 974 1081 if ( !defined( $tmphash{url} ) ) { 975 1082 $tmphash{url} = "0"; … … 984 1091 } 985 1092 else { 1093 if ( $tmphash{server} eq "*" ) { $tmphash{server} = 0; } 986 1094 $tmphash{server} = $tmphash{server} - 1; 987 1095 } … … 1101 1209 } 1102 1210 $buttons_preserve_case{"$tmphash{server}^$chan_trunk_case"} = $pos; 1103 $buttons{ uc("$tmphash{server}^$chan_trunk") } = $pos; 1104 $textos{$indice_contexto} = $tmphash{label}; 1211 if ( defined( $tmphash{astdbkey} ) ) { 1212 $buttons_astdbkey{"$tmphash{server}^$chan_trunk_case"} = $tmphash{astdbkey}; 1213 } 1214 $buttons{ uc("$tmphash{server}^$chan_trunk") } = $pos; 1215 $textos{$indice_contexto} = $tmphash{label}; 1105 1216 if ( $no_counter == 0 ) { 1106 1217 $textos{$indice_contexto} .= " " . $count; … … 1108 1219 $iconos{$indice_contexto} = $tmphash{icon}; 1109 1220 $urls{$indice_contexto} = $tmphash{url}; 1221 $alarms{$indice_contexto} = $tmphash{alarm}; 1110 1222 $targets{$indice_contexto} = $tmphash{target}; 1111 1223 $button_server{$pos} = $tmphash{server}; … … 1140 1252 $buttons{"$tmphash{server}^$canal_key"} = $lastpos . "\@" . $tmphash{panel_context}; 1141 1253 $buttons_preserve_case{"$tmphash{server}^$canal_key_case"} = $lastpos . "\@" . $tmphash{panel_context}; 1254 if ( defined( $tmphash{astdbkey} ) ) { 1255 $buttons_astdbkey{"$tmphash{server}^$canal_key_case"} = $tmphash{astdbkey}; 1256 } 1142 1257 1143 1258 $textos{"$lastpos\@$tmphash{panel_context}"} = $tmphash{label}; 1144 1259 $iconos{"$lastpos\@$tmphash{panel_context}"} = $tmphash{icon}; 1145 1260 $urls{"$lastpos\@$tmphash{panel_context}"} = $tmphash{url}; 1261 $alarms{"$lastpos\@$tmphash{panel_context}"} = $tmphash{alarm}; 1146 1262 $targets{"$lastpos\@$tmphash{panel_context}"} = $tmphash{target}; 1147 1263 $button_server{ $buttons{"$tmphash{server}^$canal_key"} } = $tmphash{server}; … … 1157 1273 $buttons{"$tmphash{server}^$canal_key"} = $lastpos; 1158 1274 $buttons_preserve_case{"$tmphash{server}^$canal_key_case"} = $lastpos; 1159 $textos{$lastpos} = $tmphash{label}; 1160 $iconos{$lastpos} = $tmphash{icon}; 1161 $urls{$lastpos} = $tmphash{url}; 1162 $targets{$lastpos} = $tmphash{target}; 1163 $button_server{ $buttons{"$tmphash{server}^$canal_key"} } = $tmphash{server}; 1275 if ( defined( $tmphash{astdbkey} ) ) { 1276 $buttons_astdbkey{"$tmphash{server}^$canal_key_case"} = $tmphash{astdbkey}; 1277 } 1278 $textos{$lastpos} = $tmphash{label}; 1279 $iconos{$lastpos} = $tmphash{icon}; 1280 $urls{$lastpos} = $tmphash{url}; 1281 $alarms{$lastpos} = $tmphash{alarm}; 1282 $targets{$lastpos} = $tmphash{target}; 1283 $button_server{ $buttons{"$tmphash{server}^$canal_key"} } = $tmphash{server}; 1164 1284 } 1165 1285 } 1166 1286 1167 1287 @positions = unique(@positions); 1288 1289 if ( defined( $tmphash{groupcount} ) ) { 1290 my $count = @positions; 1291 if ( $count == 0 ) { 1292 push @positions, $lastposition{ $tmphash{panel_context} }; 1293 } 1294 if ( $tmphash{groupcount} eq "true" || $tmphash{groupcount} eq "1" ) { 1295 my $agre_context = ""; 1296 if ( $tmphash{panel_context} ne "" ) { 1297 $agre_context = "\@" . $tmphash{panel_context}; 1298 } 1299 foreach my $pos (@positions) { 1300 $group_count{"$pos$agre_context"} = 1; 1301 } 1302 } 1303 } 1168 1304 1169 1305 if ( defined( $tmphash{privacy} ) ) { … … 1330 1466 my $flash_context_file = $directorio . "/variables" . $append_filename . ".txt"; 1331 1467 push @all_flash_files, $flash_context_file; 1468 no warnings "io"; 1332 1469 open( VARIABLES, ">$flash_context_file" ) 1333 1470 or die("Could not write configuration data $flash_context_file.\nCheck your file permissions\n"); … … 1381 1518 } 1382 1519 while ( my ( $key, $val ) = each(%legends) ) { 1520 if ( $key eq $contexto_iterate ) { 1521 print VARIABLES "&$val"; 1522 } 1523 } 1524 while ( my ( $key, $val ) = each(%images) ) { 1383 1525 if ( $key eq $contexto_iterate ) { 1384 1526 print VARIABLES "&$val"; … … 1462 1604 } 1463 1605 } 1606 while ( my ( $key, $val ) = each(%alarms) ) { 1607 $val =~ s/\"(.*)\"/$1/g; 1608 if ( $val ne "0" ) { 1609 my $base64_url = encode_base64($val); 1610 my $contextoboton = $key; 1611 if ( $contextoboton =~ m/\@/ ) { 1612 my @parte = split( /\@/, $contextoboton, 2 ); 1613 $contextoboton = $parte[1]; 1614 $contextoboton =~ tr/a-z/A-Z/; 1615 } 1616 else { 1617 $contextoboton = "GENERAL"; 1618 } 1619 1620 if ( $contextoboton eq $contexto_iterate ) { 1621 $key =~ s/(\d+)\@.+/$1/g; 1622 print VARIABLES "&alarm$key=$base64_url\n"; 1623 } 1624 } 1625 } 1626 1464 1627 if ( !defined( $style_variables{$contextlower} ) ) { 1465 1628 $style_variables{$contextlower} = $style_variables{"general"}; … … 1473 1636 $total_legends{$contexto_iterate} = 0; 1474 1637 } 1638 if ( !defined( $total_images{$contexto_iterate} ) ) { 1639 $total_images{$contexto_iterate} = 0; 1640 } 1641 1475 1642 print VARIABLES "&total_legends=" . $total_legends{$contexto_iterate}; 1643 print VARIABLES "&total_images=" . $total_images{$contexto_iterate}; 1476 1644 1477 1645 foreach my $val (@textsclients) { … … 1488 1656 } 1489 1657 $/ = "\0"; 1658 1659 } 1660 1661 sub send_reload_to_flash() { 1662 if ( $reload_pending == 1 ) { 1663 log_debug( "Pending Reload!", 32 ) if DEBUG; 1664 foreach my $socket ( keys %keys_socket ) { 1665 &sends_reload($socket); 1666 } 1667 $reload_pending = 0; 1668 } 1490 1669 } 1491 1670 … … 1533 1712 1534 1713 sub generate_configs_onhup { 1714 1715 %autosip = (); 1716 %autosip_detail = (); 1717 %cnt_auto_pos = (); 1718 $cnt_autosip = 0; 1719 1535 1720 %buttons = (); 1536 1721 %background = (); … … 1555 1740 %botonvoicemailcount = (); 1556 1741 %botonalpha = (); 1742 %botonledcolor = (); 1557 1743 %botonqueue = (); 1558 1744 %botonqueuemember = (); … … 1715 1901 } 1716 1902 if ( $elemento =~ /^mISDN/i ) { 1717 $elemento .= "-XXXX"; 1903 if ( $elemento !~ /XXXY/ ) { 1904 $elemento .= "-XXXY"; 1905 } 1718 1906 1719 1907 # $elemento =~ s/(.*)\/(.*)/\U$1\E\/${2}-${2}/g; 1720 1908 } 1721 if ( $elemento =~ /^SRX/i ) {1909 elsif ( $elemento =~ /^SRX/i ) { 1722 1910 $elemento =~ s/(.*)\/(.*)/\U$1\E\/${2}-1/g; 1723 1911 } 1912 elsif ( $elemento =~ /^CAPI\//i ) { 1913 $elemento =~ s/(CAPI\/)(.*)\/(.*)-(.*)/$1$2-$4/g; 1914 } 1915 1724 1916 $elemento =~ s/(.*)[-\/](.*)/$1\t$2/g; 1725 1917 log_debug( "$heading elemento2 $elemento", 32 ) if DEBUG; … … 1760 1952 1761 1953 sub erase_instances_for_trunk_buttons { 1954 1762 1955 my $canalid = shift; 1763 1956 my $canal = shift; … … 1794 1987 1795 1988 my $sesiontemp = $canalid; 1796 if ( $canalid =~ /^Zap/i && $canal =~ /\*/ ) {1797 1798 # Si es un Zap y ademas wildcard, cambio el canalid para1799 # que tenga la sesion modificada1800 # $sesiontemp =~ s/Zap/ZAP/g;1801 $sesiontemp =~ s/(.*)\/(.*)-(.*)/\U$1\/$2-${2}\E${3}/g;1802 }1803 if ( $canalid =~ /^MGCP/i && $canal =~ /\*/ ) {1804 1805 # Si es un MGCP y ademas wildcard, cambio el canalid para1806 # que tenga la sesion modificada1807 my $sesiontemp2 = $sesiontemp;1808 $sesiontemp2 =~ s/(.*)\@(.*)-(.*)/$2/g;1809 $sesiontemp2 = substr( $sesiontemp2, -3 );1810 $sesiontemp =~ s/(.*)\/(.*)-(.*)/\U$1\E\/${2}-${sesiontemp2}${3}/g;1811 }1812 1989 1813 1990 log_debug( "$heading looking for $canalid on instancias to erase it", 128 ) if DEBUG; … … 1915 2092 my @return; 1916 2093 my $heading = "** ERASE_ALL_SESS_FROM"; 1917 log_debug( "$heading canal $canal canalid $canalid ", 16 ) if DEBUG;2094 log_debug( "$heading canal $canal canalid $canalid server $server", 16 ) if DEBUG; 1918 2095 1919 2096 my $indice_cache = $canalid . "-" . $canal . "-" . $server; … … 2138 2315 $todo .= "$key = $val\n"; 2139 2316 log_debug( "$heading buscando $canal en $key=$val", 128 ) if DEBUG; 2140 if ( ( $val =~ /^$canal-/i || $val =~ /^$canal$/ ) && $key =~ /^Chan/i ) {2317 if ( ( $val =~ /^$canal-/i || $val =~ /^$canal$/i ) && $key =~ /^Chan/i ) { 2141 2318 log_debug( "$heading canal coincide $canal = $val\n", 16 ) if DEBUG; 2142 2319 $canalaqui = 1; … … 2285 2462 @multicanal = ($canal); 2286 2463 } 2287 print_agents();2288 2464 } 2289 2465 } … … 2309 2485 my $indice_cache = ""; 2310 2486 @multicanal = unique(@multicanal); 2487 my $server_original = $server; 2311 2488 2312 2489 foreach my $canal (@multicanal) { … … 2317 2494 log_debug( "$heading CACHE MISS $indice_cache", 32 ) if DEBUG; 2318 2495 for ( keys %buttons ) { 2496 $server = $server_original; 2319 2497 $canalfinal = ""; 2320 2498 my ( $nada, $contexto ) = split( "\&", $_ ); 2321 2499 if ( !defined($contexto) ) { $contexto = ""; } 2322 2500 if ( $contexto ne "" ) { $contexto = "&" . $contexto; } 2501 log_debug( "$heading trying $_", 32 ) if DEBUG; 2502 if ( $_ =~ /^\Q-1^\E/ ) { 2503 log_debug( "$heading IGNORE SERVER! $_", 32 ) if DEBUG; 2504 $server = "-1"; 2505 } 2323 2506 if ( $_ =~ /^\Q$server^$canal\E$/i ) { 2324 2507 … … 2525 2708 if ( $hash_temporal{"Event"} =~ /^UserEvent/ ) { 2526 2709 2710 if ( $hash_temporal{"Event"} eq "UserEvent" ) { 2711 2712 # Asterisk 1.4 Issues a separate header for UserEvent, merge it 2713 # to make it compatible with the way older versions worked 2714 $hash_temporal{"Event"} = "UserEvent" . $hash_temporal{UserEvent}; 2715 } 2716 2527 2717 # This blocks checks if we have an UserEvent 2528 2718 # and splits every key value pair if it haves … … 2553 2743 2554 2744 if ( defined( $hash_temporal{"Uniqueid"} ) ) { 2555 $unico_id = $hash_temporal{"Uniqueid"}; 2556 $fill_datos = 1; 2745 $unico_id = $hash_temporal{"Uniqueid"}; 2746 if ( $hash_temporal{Event} !~ /^Originate/ ) { 2747 $fill_datos = 1; 2748 } 2557 2749 } 2558 2750 else { … … 2619 2811 $val = ""; 2620 2812 } 2621 $datos{$unico_id}{ "$key"} = $val;2813 $datos{$unico_id}{$key} = $val; 2622 2814 log_debug( "$heading POPULATES datos($unico_id){ $key } = $val", 128 ) if DEBUG; 2623 2815 } … … 2644 2836 elsif ( $evento =~ /^Unlink/ ) { $evento = "unlink"; } 2645 2837 elsif ( $evento =~ /QueueParams/ ) { $evento = "queueparams"; } 2838 elsif ( $evento =~ /PeerEntry/ ) { $evento = "peerentry"; } 2646 2839 elsif ( $evento =~ /QueueEntry/ ) { $evento = "queueentry"; } 2647 2840 elsif ( $evento =~ /^QueueMember$/ ) { $evento = "queuemember"; } … … 2677 2870 elsif ( $evento =~ /^ZapShowChannels$/ ) { $evento = "zapdndstate"; } 2678 2871 elsif ( $evento =~ /^ExtensionStatus$/ ) { $evento = "extensionstatus"; } 2872 elsif ( $evento =~ /^OriginateSuccess$/ ) { $evento = "originatesuccess"; } 2873 elsif ( $evento =~ /^OriginateFailure$/ ) { $evento = "originatefailure"; } 2874 elsif ( $evento =~ /^ChannelReload$/ ) { $evento = "channelreload"; } 2679 2875 else { log_debug( "$heading No event match ($evento)", 32 ); } 2680 2876 … … 2695 2891 } 2696 2892 2697 if ( $evento eq "agentcomplete" ) { 2893 if ( $evento eq "channelreload" ) { 2894 2895 # Event: ChannelReload 2896 # Privilege: system,all 2897 # Channel: SIP 2898 # ReloadReason: RELOAD (Channel module reload) 2899 # Registry_Count: 1 2900 # Peer_Count: 19 2901 # User_Count: 7 2902 $reload_pending = 1; 2903 &generate_configs_onhup; 2904 2905 } 2906 elsif ( $evento eq "originatesuccess" ) { 2907 if ( defined( $hash_temporal{ActionID} ) ) { 2908 if ( $hash_temporal{ActionID} =~ /^attendant/ ) { 2909 2910 # Store the uniqueid for OriginateSuccess for attendant transfers 2911 # we need it to find the channel in the next newexten event with 2912 # the same uniqueid 2913 my $indice = $hash_temporal{Uniqueid} . "-" . $hash_temporal{Server}; 2914 if ( exists( $datos{"$indice"} ) ) { 2915 log_debug( "** ATTENDANT we had that uniqueid before, extract the channel from there", 16 ) if DEBUG; 2916 if ( defined( $datos{$indice}{Extension} ) ) { 2917 2918 # if Extension is defined we received the Newexten event before the OriginateSuccess 2919 # if not, then we only had a Ringing state without extension/context, so use the one from 2920 # this event. 2921 $attendant_pending{ $datos{$indice}{Channel} } = $datos{$indice}{Extension} . "@" . $datos{$indice}{Context}; 2922 } 2923 else { 2924 $attendant_pending{ $datos{$indice}{Channel} } = $hash_temporal{Exten} . "@" . $hash_temporal{Context}; 2925 } 2926 } 2927 else { 2928 log_debug( "** ATTENDANT we do not have any event with that uniqueid, save for later", 16 ) if DEBUG; 2929 print_datos(99); 2930 $pending_uniqueid_attendant{ $hash_temporal{Uniqueid} } = $hash_temporal{Exten} . "@" . $hash_temporal{Context}; 2931 } 2932 } 2933 } 2934 $evento = ""; 2935 } 2936 elsif ( $evento eq "originatefailure" ) { 2937 2938 my $contexto = $hash_temporal{ActionID}; 2939 2940 $contexto =~ s/(.*)-(.*)/$2/g; 2941 $contexto = uc($contexto); 2942 $canal = $hash_temporal{Channel}; 2943 2944 my $ext_transf = $extension_transfer{"$server^$canal"}; 2945 $ext_transf =~ s/\d+\^(.*)/$1/g; 2946 my @part_ext = split( /\@/, $ext_transf ); 2947 2948 my $dst_exten = $hash_temporal{Exten}; 2949 my $dst_context = $hash_temporal{Context}; 2950 2951 if ( defined( $config->{$contexto}{'attendant_failure_redirect_to'} ) ) { 2952 2953 # If we define a new extension/context, then disengage the originating button 2954 # from the conference 2955 2956 my @borrar = (); 2957 while ( ( $key, $val ) = each(%attendant_pending) ) { 2958 if ( $val eq "$dst_exten\@$dst_context" ) { 2959 push @borrar, $key; 2960 log_debug( "Hangup pending attendant channel $key on originate failure", 16 ) if DEBUG; 2961 my $comando = "Action: Hangup\r\n"; 2962 $comando .= "Channel: $key\r\n\r\n"; 2963 send_command_to_manager( $comando, $socket, 0, $astmanproxy_server ); 2964 } 2965 } 2966 foreach (@borrar) { 2967 delete $attendant_pending{$_}; 2968 } 2969 2970 while ( ( $key, $val ) = each(%mute_other) ) { 2971 log_debug( "Mute other after originate failure: $key = $val", 16 ) if DEBUG; 2972 } 2973 while ( ( $key, $val ) = each(%pending_uniqueid_attendant) ) { 2974 log_debug( "Pending uniqueid attendant after originate failure: $key = $val", 16 ) if DEBUG; 2975 } 2976 my $tempval = $config->{$contexto}{'attendant_failure_redirect_to'}; 2977 $tempval =~ s/\${CHANNEL}/$hash_temporal{Channel}/g; 2978 $tempval =~ s/\${EXTEN}/$part_ext[0]/g; 2979 $tempval =~ s/\${CONTEXT}/$part_ext[1]/g; 2980 2981 if ( $tempval =~ m/\@/ ) { 2982 my @partes = split( /\@/, $tempval, 2 ); 2983 $dst_exten = $partes[0]; 2984 $dst_context = $partes[1]; 2985 } 2986 else { 2987 $dst_exten = $tempval; 2988 $dst_context = "default"; 2989 } 2990 } 2991 2992 log_debug( "Transfer to $dst_exten @ $dst_context after originate failure", 16 ) if DEBUG; 2993 2994 # Event: OriginateFailure 2995 # Privilege: call,all 2996 # ActionID: attendant-general 2997 # Channel: SIP/17 2998 # Context: conferences 2999 # Exten: 901 3000 # Reason: 5 3001 # Uniqueid: <null> 3002 # Server: 0 3003 3004 if ( $hash_temporal{ActionID} =~ /^attendant/ ) { 3005 my $room = $hash_temporal{Exten} . "@" . $hash_temporal{Context}; 3006 print "Failure pero tengo mute_other($room) = " . $mute_other{$room} . "\n"; 3007 my $comando = "Action: Redirect\r\n"; 3008 $comando .= "Channel: " . $mute_other{$room} . "\r\n"; 3009 $comando .= "Exten: " . $dst_exten . "\r\n"; 3010 $comando .= "Context: " . $dst_context . "\r\n"; 3011 $comando .= "ActionID: 1234attendant\r\n"; 3012 $comando .= "Priority: 1\r\n\r\n"; 3013 send_command_to_manager( $comando, $socket, 0, $astmanproxy_server ); 3014 } 3015 $evento = ""; 3016 3017 } 3018 elsif ( $evento eq "agentcomplete" ) { 2698 3019 2699 3020 # Hook for queue statistics? … … 2708 3029 my ( $canal, $nada ) = separate_session_from_channel( $hash_temporal{Channel} ); 2709 3030 request_queue_status( $socket, $canal ); 2710 } 2711 2712 if ( $evento eq "agentcalled" ) { 3031 my @respuestas = set_queueobject( $server, $canal, "status", 1 ); 3032 foreach (@respuestas) { 3033 push @return, $_; 3034 } 3035 } 3036 elsif ( $evento eq "PeerlistComplete" ) { 3037 3038 foreach (@auto_config) { 3039 my %tmphash = %$_; 3040 my $srv = 1; 3041 if ( defined( $tmphash{server} ) ) { 3042 $srv = $tmphash{server}; 3043 } 3044 $srv--; 3045 3046 if ( $srv == $hash_temporal{Server} ) { 3047 my $match = $tmphash{channel_preserve_case}; 3048 $match =~ s/^AUTO\///g; 3049 while ( ( $key, $val ) = each(%autosip) ) { 3050 my ( $server, $sipp ) = split( /\^/, $key, 2 ); 3051 if ( "SIP/$sipp" =~ m/$match/ && $server == $srv ) { 3052 $cnt_autosip++; 3053 log_debug( "AUTO sip de server $srv $key coincide con $match, envio query detallado autosipentry-$cnt_autosip", 16 ) 3054 if DEBUG; 3055 my $comando = "Action: SIPShowPeer\r\nPeer: $sipp\r\nActionID: autosipentry-$cnt_autosip\r\n\r\n"; 3056 send_command_to_manager( $comando, $socket, 0, $server ); 3057 } 3058 else { 3059 log_debug( "No autosip match $srv $key con $match", 32 ) if DEBUG; 3060 } 3061 } 3062 } 3063 } 3064 $autosip_detail{"autosipentry-$cnt_autosip"} = 1; 3065 send_reload_to_flash(); 3066 } 3067 elsif ( $evento eq "sippeerentrylong" ) { 3068 3069 if ( defined( $hash_temporal{ObjectName} ) ) { 3070 3071 my $calid = $hash_temporal{Callerid}; 3072 my $ctx = $hash_temporal{Context}; 3073 my $chan_name = $hash_temporal{ObjectName}; 3074 my $acid = $hash_temporal{ActionID}; 3075 my $voicemailbox = $hash_temporal{VoiceMailbox} ? $hash_temporal{VoiceMailbox} : ""; 3076 my $accode = $hash_temporal{Accountcode} ? $hash_temporal{Accountcode} : ""; 3077 my $voicemailboxnum = ""; 3078 my $voicemailboxcontext = ""; 3079 3080 my $calidnum = $calid; 3081 my $calidname = $calid; 3082 3083 $calidnum =~ s/([^<]*)<([^>]*)>/$2/g; 3084 $calidname =~ s/([^<]*)<([^>]*)>/$1/g; 3085 3086 if ( $voicemailbox =~ m/\@/ ) { 3087 ( $voicemailboxnum, $voicemailboxcontext ) = split( /\@/, $voicemailbox, 2 ); 3088 } 3089 else { 3090 $voicemailboxnum = $voicemailbox; 3091 $voicemailboxcontext = ""; 3092 } 3093 my $cnt = 0; 3094 3095 foreach my $auto (@auto_config) { 3096 my %tmphash = %$auto; 3097 if ( !defined( $tmphash{server} ) ) { $tmphash{server} = 1; } 3098 my $srv = $tmphash{server}; 3099 $srv--; 3100 my $match = $tmphash{channel_preserve_case}; 3101 $match =~ s/^AUTO\///g; 3102 if ( !defined( $hash_temporal{Server} ) ) { 3103 $hash_temporal{Server} = 1; 3104 } 3105 3106 if ( $srv == $hash_temporal{Server} && "SIP/$chan_name" =~ m/$match/ ) { 3107 while ( ( $key, $val ) = each(%tmphash) ) { 3108 $val =~ s/\${CONTEXT}/$ctx/g; 3109 $val =~ s/\${CALLERID}/$calid/g; 3110 $val =~ s/\${CLIDNUM}/$calidnum/g; 3111 $val =~ s/\${CLIDNAME}/$calidname/g; 3112 $val =~ s/\${VOICEMAILBOX}/$voicemailbox/g; 3113 $val =~ s/\${VOICEMAILBOXNUM}/$voicemailboxnum/g; 3114 $val =~ s/\${VOICEMAILBOXCONTEXT}/$voicemailboxcontext/g; 3115 $val =~ s/\${ACCOUNTCODE}/$accode/g; 3116 $val =~ s/\${CHANNEL}/$chan_name/g; 3117 $autosip{"$server^$chan_name"}{$key} = $val; 3118 } 3119 $autosip{"$server^$chan_name"}{channel} = "SIP/$chan_name"; 3120 $autosip{"$server^$chan_name"}{autonumber} = $cnt; 3121 delete( $autosip{"$server^$chan_name"}{channel_preserve_case} ); 3122 3123 delete( $autosip_detail{$acid} ); 3124 my @quedan = keys(%autosip_detail); 3125 3126 # AUTOSIP SUTOSIP 3127 my $cuantos_quedan = @quedan; 3128 if ( $cuantos_quedan == 0 ) { 3129 3130 # Last autosip for each server, it is time to write variables 3131 # for this kind 3132 read_buttons_config(); 3133 genera_config(); 3134 send_initial_status( '', 1 ); 3135 } 3136 3137 } 3138 $cnt++; 3139 } 3140 } 3141 3142 } 3143 elsif ( $evento eq "peerentry" ) { 3144 3145 #Event: PeerEntry 3146 #ActionID: autosip 3147 #Channeltype: SIP 3148 #ObjectName: nicocasa 3149 #ChanObjectType: peer 3150 #IPaddress: 1.2.3.4 3151 #IPport: 15540 3152 #Dynamic: yes 3153 #Natsupport: yes 3154 #ACL: no 3155 #Status: UNREACHABLE 3156 3157 if ( $hash_temporal{ActionID} eq "autosip" ) { 3158 my $peer = $hash_temporal{ObjectName}; 3159 $autosip{"$server^$peer"}{server} = $server; 3160 } 3161 } 3162 elsif ( $evento eq "agentcalled" ) { 2713 3163 2714 3164 # We use this event to send the ringing state for an Agent … … 2719 3169 $clidnum = $hash_temporal{"CallerID"}; 2720 3170 $clidname = $hash_temporal{"CallerIDName"}; 2721 $texto = "&incoming,[" . format_clid( $clidnum, $clid _format ) . "]";3171 $texto = "&incoming,[" . format_clid( $clidnum, $clidname, $clid_format ) . "]"; 2722 3172 my $base64_clidnum = encode_base64( $clidnum . " " ); 2723 3173 my $base64_clidname = encode_base64( $clidname . " " ); … … 2727 3177 $evento = ""; 2728 3178 } 2729 2730 if ( $evento eq "agentconnect" ) { 3179 elsif ( $evento eq "agentconnect" ) { 2731 3180 2732 3181 # We use this event to fake the ringing state 2733 3182 $estado_final = "ocupado"; 2734 $texto = "Taking call from $hash_temporal{\"Queue\"}";3183 $texto = "Taking call from " . $hash_temporal{Queue}; 2735 3184 $canal = $hash_temporal{"Channel"}; 2736 3185 $canal =~ tr/a-z/A-Z/; 2737 3186 $canalid = $canal . "-XXXX"; 2738 push @return, "$canal|$estado_final|$texto|$canalid-$server|$canalid"; #NEW 3187 push @return, "$canal|$estado_final|$texto|$canalid-$server|$canalid"; #NEW 3188 push @return, "$canal|agentconnect|$hash_temporal{Uniqueid}|$canalid-$server|$canalid"; #NEW 3189 3190 my $member = $hash_temporal{Member}; 3191 my $queue = $hash_temporal{Queue}; 3192 my @respuestas = set_queueobject( $server, $member, "status", 2 ); 3193 foreach (@respuestas) { 3194 push @return, $_; 3195 } 3196 2739 3197 $evento = ""; 2740 3198 } 2741 2742 if ( $evento eq "dial" ) { 3199 elsif ( $evento eq "dial" ) { 2743 3200 2744 3201 # We use this hashes to store the remote callerid for CVS-HEAD … … 2750 3207 $remote_callerid_name{$key} = $hash_temporal{"CallerIDName"}; 2751 3208 2752 # We also look for Dial from Local/XX@context to TECH/XX for 2753 # matching agentcallbacklogins exten@context to real channels 2754 # so we can map outgoing calls to Agent buttons 2755 # It will only work after the agent receives at least one call 2756 ( $dorigen, $dnada ) = separate_session_from_channel( $hash_temporal{'Source'} ); 2757 ( $ddestino, $dnada ) = separate_session_from_channel( $hash_temporal{'Destination'} ); 2758 if ( exists( $channel_to_agent{"$server^$dorigen"} ) ) { 2759 my $agente = $channel_to_agent{"$server^$dorigen"}; 2760 2761 # delete $channel_to_agent{$dorigen}; 2762 $channel_to_agent{"$server^$ddestino"} = $agente; 2763 } 2764 } 2765 2766 if ( $evento eq "zapdndstate" ) { 3209 if ( $hash_temporal{'Source'} =~ m/^Local/i ) { 3210 3211 # We also look for Dial from Local/XX@context to TECH/XX for 3212 # matching agentcallbacklogins exten@context to real channels 3213 # so we can map outgoing calls to Agent buttons 3214 # It will only work after the agent receives at least one call 3215 ( $dorigen, $dnada ) = separate_session_from_channel( $hash_temporal{'Source'} ); 3216 ( $ddestino, $dnada ) = separate_session_from_channel( $hash_temporal{'Destination'} ); 3217 if ( exists( $channel_to_agent{"$server^$dorigen"} ) ) { 3218 my $agente = $channel_to_agent{"$server^$dorigen"}; 3219 3220 # delete $channel_to_agent{$dorigen}; 3221 $channel_to_agent{"$server^$ddestino"} = $agente; 3222 } 3223 } 3224 } 3225 elsif ( $evento eq "zapdndstate" ) { 3226 2767 3227 $canal = $hash_temporal{"Channel"}; 2768 3228 my $zstatus = ""; … … 2791 3251 2792 3252 $evento = ""; 2793 } 2794 2795 if ( $evento eq "astdb" ) { 3253 3254 } 3255 elsif ( $evento eq "astdb" ) { 3256 2796 3257 my $valor = ""; 2797 3258 $estado_final = "astdb"; … … 2799 3260 $canalid = $hash_temporal{"Channel"} . "-XXXX"; 2800 3261 my $clave = $hash_temporal{"Family"}; 2801 if ( !defined( $hash_temporal{" State"} ) ) {3262 if ( !defined( $hash_temporal{"Value"} ) ) { 2802 3263 $valor = ""; 2803 3264 } 2804 3265 else { 2805 $valor = $hash_temporal{" State"};3266 $valor = $hash_temporal{"Value"}; 2806 3267 } 2807 3268 2808 3269 foreach my $item ( @{ $astdbcommands{$clave} } ) { 2809 3270 my $item_temp = $item; 3271 my $datoon = ""; 3272 my $datooff = ""; 2810 3273 $item_temp =~ s/\${value}/$valor/g; 2811 3274 my ( $comando, $datos ) = split( /=/, $item_temp ); 3275 if ( $datos =~ /\|/ ) { 3276 ( $datoon, $datooff ) = split( /\|/, $datos ); 3277 } 3278 else { 3279 $datoon = $datos; 3280 $datooff = ""; 3281 } 3282 2812 3283 if ( $valor ne "" ) { 2813 push @return, "$canal|$comando|$dato s|$canalid-$server|$canalid";3284 push @return, "$canal|$comando|$datoon|$canalid-$server|$canalid"; 2814 3285 } 2815 3286 else { 2816 push @return, "$canal|$comando| |$canalid-$server|$canalid";3287 push @return, "$canal|$comando|$datooff|$canalid-$server|$canalid"; 2817 3288 } 2818 3289 } 2819 3290 $evento = ""; 2820 3291 } 2821 2822 if ( $evento eq "timeout" ) { 3292 elsif ( $evento eq "timeout" ) { 2823 3293 $estado_final = "timeout"; 2824 3294 $texto = $timeout; … … 2830 3300 $evento = ""; 2831 3301 } 2832 2833 if ( $evento eq "regstatus" ) { 3302 elsif ( $evento eq "regstatus" ) { 2834 3303 2835 3304 # Sends the IP address of the peer to the flash client … … 2849 3318 } 2850 3319 } 2851 2852 if ( $evento eq "fopledcolor" ) { 3320 elsif ( $evento eq "fopledcolor" ) { 2853 3321 my $color = ""; 2854 3322 my $state = ""; … … 2860 3328 $evento = ""; 2861 3329 } 2862 2863 if ( $evento eq "foppopup" ) { 3330 elsif ( $evento eq "foppopup" ) { 2864 3331 ( $canal, my $nada ) = separate_session_from_channel( $hash_temporal{"Channel"} ); 2865 3332 my $url = $hash_temporal{"URL"}; … … 2872 3339 $evento = ""; 2873 3340 } 2874 2875 if ( $evento eq "refreshqueue" ) { 3341 elsif ( $evento eq "refreshqueue" ) { 2876 3342 ( $canal, my $nada ) = separate_session_from_channel( $hash_temporal{"Channel"} ); 2877 3343 … … 2884 3350 $evento = ""; 2885 3351 } 2886 2887 if ( $evento eq "agentcblogin" ) { 3352 elsif ( $evento eq "agentcblogin" ) { 2888 3353 my $canal = ""; 2889 3354 my $canallocal = ""; … … 2893 3358 if ( $canalid eq "" ) { 2894 3359 $canalid = "Agent/$texto-XXXX"; 3360 } 3361 my @respuestas = set_queueobject( $server, "AGENT/$texto", "status", 1 ); 3362 foreach (@respuestas) { 3363 push @return, $_; 2895 3364 } 2896 3365 … … 2964 3433 $agent_to_channel{"$server^Agent/$texto"} = $canal; 2965 3434 2966 print_agents();2967 2968 3435 $estado_final = "changelabel" . $change_led; 2969 3436 if ( $ren_cbacklogin == 1 ) { … … 3000 3467 $evento = ""; 3001 3468 } 3002 3003 if ( $evento eq "queuememberpaused" && $agent_status == 1 ) { 3469 elsif ( $evento eq "queuememberpaused" && $agent_status == 1 ) { 3004 3470 my $canal = $hash_temporal{Location}; 3005 my $cola = $hash_temporal{Queue};3006 3471 my $canalid = $canal . "-XXXX"; 3007 3472 … … 3023 3488 3024 3489 my $color = ""; 3025 if ( $hash_temporal{Paused} eq "1" ) {3490 if ( $hash_temporal{Paused} ne "0" ) { 3026 3491 my ( $text, $textriginal, $buttontext ) = translate( $canal, "&paused", "", "" ); 3027 3492 $texto = $text; … … 3034 3499 $texto = "&idle"; 3035 3500 $color = "ledcolor_agent"; 3501 } 3502 my $canset = ""; 3503 $canset = uc($canal); 3504 my @respuestas = set_queueobject( $server, $canset, "paused", $hash_temporal{Paused} ); 3505 foreach my $item (@respuestas) { 3506 push @return, $item; 3036 3507 } 3037 3508 $boton_ip{$canalid} = $texto; … … 3041 3512 push @return, "$canal|fopledcolor|$color^2|$unico_id|$canalid"; 3042 3513 push @return, "$canal|state|free|$unico_id|$canalid"; 3514 push @return, "$canal|paused|$hash_temporal{Paused}|$unico_id|$canalid"; 3043 3515 $evento = ""; 3044 3516 3045 3517 } 3046 3047 if ( $evento eq "queuememberremoved" ) { 3048 my $cola = $hash_temporal{Queue}; 3049 my $canal = $hash_temporal{Location}; 3518 elsif ( $evento eq "queuememberremoved" ) { 3519 my $colar = $hash_temporal{Queue}; 3520 my $canal = $hash_temporal{Location}; 3521 my @respuestas = delete_queueobject( $server, $colar, $canal ); 3522 foreach (@respuestas) { 3523 push @return, $_; 3524 } 3525 3050 3526 $fake_bloque[$fakecounter]{Event} = "Agentlogoff"; 3051 3527 $fake_bloque[$fakecounter]{Channel} = $canal . "-XXXX"; 3052 3528 $fake_bloque[$fakecounter]{Agent} = $canal; 3053 $fake_bloque[$fakecounter]{Queue} = $cola ;3529 $fake_bloque[$fakecounter]{Queue} = $colar; 3054 3530 $fake_bloque[$fakecounter]{Fake} = "removed"; 3055 3531 $fake_bloque[$fakecounter]{Server} = $hash_temporal{Server}; … … 3057 3533 $evento = ""; 3058 3534 } 3059 3060 if ( $evento eq "queuememberadded" ) { 3061 3062 my $cola = $hash_temporal{Queue}; 3063 my $canal = $hash_temporal{Location}; 3535 elsif ( $evento eq "queuememberadded" ) { 3536 3537 my $colar = $hash_temporal{Queue}; 3538 my $canal = $hash_temporal{Location}; 3539 my @respuestas = add_queueobject( $server, $colar, $canal ); 3540 foreach (@respuestas) { 3541 push @return, $_; 3542 } 3064 3543 3065 3544 $fake_bloque[$fakecounter]{Event} = "Agentlogin"; 3066 3545 $fake_bloque[$fakecounter]{Channel} = $canal . "-XXXX"; 3067 3546 $fake_bloque[$fakecounter]{Agent} = $canal; 3068 $fake_bloque[$fakecounter]{Queue} = $cola ;3547 $fake_bloque[$fakecounter]{Queue} = $colar; 3069 3548 $fake_bloque[$fakecounter]{Server} = $hash_temporal{Server}; 3070 3549 $fake_bloque[$fakecounter]{Addhash} = 1; … … 3085 3564 3086 3565 } 3087 3088 if ( $evento eq "agentlogin" ) { 3566 elsif ( $evento eq "agentlogin" ) { 3089 3567 3090 3568 my $labeltext = "."; … … 3099 3577 $agent_to_channel{"$server^Agent/$texto"} = $canalreal; 3100 3578 log_debug( "channel_to_agent($server^$canalreal) = " . $channel_to_agent{"$server^$canalreal"}, 64 ) if DEBUG; 3579 if ( !defined( $hash_temporal{Fake} ) || $hash_temporal{Fake} ne "init" ) { 3580 my @respuestas = set_queueobject( $server, "AGENT/$texto", "status", 1 ); 3581 foreach (@respuestas) { 3582 push @return, $_; 3583 } 3584 } 3101 3585 } 3102 3586 … … 3207 3691 3208 3692 if ( defined( $hash_temporal{Queue} ) ) { 3209 if ( keys(% count_queue) ) {3693 if ( keys(%agents_available_on_queue) ) { 3210 3694 my $contaconta = 0; 3211 3695 my %temp_queue = (); 3212 3696 my $valor = "$server^$hash_temporal{Queue}"; 3213 3697 3214 push @{ $ count_queue{$valor} }, "$server^$texto";3698 push @{ $agents_available_on_queue{$valor} }, "$server^$texto"; 3215 3699 3216 3700 my %count; 3217 my @unique_queues = grep { ++$count{$_} < 2 } @{ $ count_queue{$valor} };3218 @{ $ count_queue{$valor} } = @unique_queues;3219 3220 if ( exists( $ count_queue{$valor} ) && $count_queue{$valor} ne "" ) {3701 my @unique_queues = grep { ++$count{$_} < 2 } @{ $agents_available_on_queue{$valor} }; 3702 @{ $agents_available_on_queue{$valor} } = @unique_queues; 3703 3704 if ( exists( $agents_available_on_queue{$valor} ) && $agents_available_on_queue{$valor} ne "" ) { 3221 3705 my $texto3 = ""; 3222 foreach my $qmem ( @{ $ count_queue{$valor} } ) {3706 foreach my $qmem ( @{ $agents_available_on_queue{$valor} } ) { 3223 3707 $texto3 .= "$qmem\n"; 3224 3708 } 3225 $contaconta = @{ $ count_queue{$valor} };3709 $contaconta = @{ $agents_available_on_queue{$valor} }; 3226 3710 my $texto2 = "Agents Logged: $contaconta\n" . $texto3 . " "; 3227 3711 $texto2 = encode_base64($texto2); … … 3232 3716 } 3233 3717 } 3234 3235 if ( $evento eq "agentlogoff" ) { 3718 elsif ( $evento eq "agentlogoff" ) { 3236 3719 3237 3720 $canal = "Agent/" . $hash_temporal{Agent}; … … 3240 3723 } 3241 3724 3725 if ( !defined( $hash_temporal{Fake} ) || $hash_temporal{Fake} ne "init" ) { 3726 my @respuestas = set_queueobject( $server, "AGENT/$canal", "status", 5 ); 3727 foreach (@respuestas) { 3728 push @return, $_; 3729 } 3730 } 3731 3242 3732 my $texto = $hash_temporal{Agent}; 3243 3733 $canalid = $canal . "-XXXX"; … … 3248 3738 if ( defined( $agent_to_channel{"$server^Agent/$canal"} ) || defined( $channel_to_agent{"$server^$canal"} ) ) { 3249 3739 if ( defined( $agent_to_channel{"$server^Agent/$canal"} ) ) { 3250 3251 # ( $canal, my $nada ) = separate_session_from_channel( $agent_to_channel{"$server^Agent/$canal"} );3252 3740 $canal = $agent_to_channel{"$server^Agent/$canal"}; 3253 3741 } 3254 3742 else { 3255 3256 # ( $canal, my $nada ) = separate_session_from_channel( $channel_to_agent{"$server^$canal"} );3257 3743 $canal = $channel_to_agent{"$server^$canal"}; 3258 3744 } … … 3266 3752 } 3267 3753 3268 #delete $agent_to_channel{"$server^$canal"};3269 #delete $agent_to_channel{"$server^$agente"};3270 3754 delete $reverse_agents{$texto}; 3271 3755 delete $reverse_agents{$canal}; … … 3306 3790 delete( $is_agent{ uc("$server^$texto") } ); 3307 3791 3308 if ( keys(% count_queue) ) {3309 print_countqueue("agentlogoff principio count_queue");3792 if ( keys(%agents_available_on_queue) ) { 3793 print_countqueue("agentlogoff principio agents_available_on_queue"); 3310 3794 my $contaconta = 0; 3311 3795 my %temp_queue = (); 3312 3796 my $valor = ""; 3313 foreach $valor ( sort ( keys(% count_queue) ) ) {3314 foreach my $vvalor ( @{ $ count_queue{$valor} } ) {3797 foreach $valor ( sort ( keys(%agents_available_on_queue) ) ) { 3798 foreach my $vvalor ( @{ $agents_available_on_queue{$valor} } ) { 3315 3799 if ( $vvalor !~ /^$server\^$canal$/i && $vvalor !~ /^$server\^AGENT\/$texto$/i ) { 3316 3800 push @{ $temp_queue{$valor} }, $vvalor; … … 3321 3805 } 3322 3806 } 3323 % count_queue = %temp_queue;3807 %agents_available_on_queue = %temp_queue; 3324 3808 if ( defined( $hash_temporal{Queue} ) ) { 3325 3809 $valor = $hash_temporal{Queue}; 3326 if ( exists( $ count_queue{"$server^$valor"} ) && $count_queue{"$server^$valor"} ne "" ) {3810 if ( exists( $agents_available_on_queue{"$server^$valor"} ) && $agents_available_on_queue{"$server^$valor"} ne "" ) { 3327 3811 my $texto3 = ""; 3328 foreach my $qmem ( @{ $ count_queue{"$server^$valor"} } ) {3812 foreach my $qmem ( @{ $agents_available_on_queue{"$server^$valor"} } ) { 3329 3813 $texto3 .= "$qmem\n"; 3330 3814 } 3331 $contaconta = @{ $ count_queue{"$server^$valor"} };3815 $contaconta = @{ $agents_available_on_queue{"$server^$valor"} }; 3332 3816 my $texto2 = "Agents Logged: $contaconta\n" . $texto3 . " "; 3333 3817 $texto2 = encode_base64($texto2); … … 3339 3823 3340 3824 } 3341 3342 if ( $evento eq "queueentry" ) { 3825 elsif ( $evento eq "queueentry" ) { 3343 3826 3344 3827 if ( defined( $max_queue_waiting_time_for{"$hash_temporal{Queue}-$hash_temporal{Server}"} ) ) { … … 3364 3847 $fakecounter++; 3365 3848 } 3366 3367 if ( $evento eq "queuestatuscomplete" ) { 3849 elsif ( $evento eq "queuestatuscomplete" ) { 3368 3850 for my $cola_server ( keys %max_queue_waiting_time_for ) { 3369 3851 my ( $cola, $server ) = ( $cola_server =~ m/(.*)-(.*)/ ); … … 3377 3859 } 3378 3860 $evento = ""; 3379 } 3380 3381 if ( $evento eq "queuemember" || $evento eq "queuememberstatus" ) { 3861 my @respuestas = compute_queueobject($server); 3862 foreach (@respuestas) { 3863 push @return, $_; 3864 } 3865 } 3866 elsif ( $evento eq "queuemember" || $evento eq "queuememberstatus" ) { 3382 3867 3383 3868 my $canalag = $hash_temporal{"Location"}; … … 3387 3872 $canal = $hash_temporal{"Location"}; 3388 3873 3874 # $agent_status{$hash_temporal{Queue}}{$canalag}=$hash_temporal{Status}; XXXXXXXX NUEVO 3875 3389 3876 ( $server, $canal ) = local_channels_are_driving_me_mad( $server, $canal ); 3390 3877 … … 3400 3887 $fake_bloque[$fakecounter]{Agent} = $temp; 3401 3888 $fake_bloque[$fakecounter]{Server} = $server; 3402 $fake_bloque[$fakecounter]{Fake} = " 1";3889 $fake_bloque[$fakecounter]{Fake} = "init"; 3403 3890 $fakecounter++; 3404 3891 … … 3411 3898 $fake_bloque[$fakecounter]{Channel} = $canal . "-XXXX"; 3412 3899 $fake_bloque[$fakecounter]{Agent} = $canal; 3413 $fake_bloque[$fakecounter]{Fake} = " 1";3900 $fake_bloque[$fakecounter]{Fake} = "init"; 3414 3901 $fake_bloque[$fakecounter]{Server} = $server; 3415 3902 $fakecounter++; … … 3418 3905 } 3419 3906 } 3907 3908 if ( defined( $hash_temporal{Paused} ) ) { 3909 if ( $evento eq "queuemember" ) { 3910 push @return, "$canalag|paused|$hash_temporal{Paused}|$unicoag_id|$canal-XXXX"; 3911 } 3912 } 3913 3420 3914 } 3421 3915 … … 3426 3920 reserve_next_available_agent_button( $server, $canal, $hash_temporal{Queue} ); 3427 3921 $is_agent{ uc("$server^$canalag") } = 1; 3428 3429 #if ( $agent_status == 1 ) {3430 # if ( $hash_temporal{Paused} eq "1" ) {3431 # push @return, "$canal|settext|&paused|$unico_id|$canalid";3432 # push @return, "$canal|settimer|0\@IDLE|$unico_id|$canalid";3433 # }3434 # else {3435 # push @return, "$canal|settext|&idle|$unico_id|$canalid";3436 # push @return, "$canal|settimer|0\@IDLE|$unico_id|$canalid";3437 # }3438 #}3439 3440 3922 } 3441 3923 if ( $canal !~ /^Local/ ) { … … 3451 3933 while ( ( $key, $val ) = each(%hash_temporal) ) { 3452 3934 if ( !defined($val) ) { $val = " "; } 3453 $texto .= "$key = $val\n"; 3935 3936 # Status line changes from 1 to 0 on each ring and not taken call, generating 3937 # an event that we do not really need 3938 $texto .= "$key = $val\n" if ( $key ne "Status" ); 3454 3939 if ( $key eq "Status" && $val != 5 ) { 3455 3940 $estado_final .= $vval; 3456 push @{ $ count_queue{"$server^$vval"} }, "$server^$canal";3941 push @{ $agents_available_on_queue{"$server^$vval"} }, "$server^$canal"; 3457 3942 $has_status_ast_12 = 1; 3943 } 3944 if ( $key eq "Status" ) { 3945 $queue_object->{$server}->{$vval}->{$canal}->{status} = $val; 3946 } 3947 if ( $key eq "Paused" ) { 3948 $queue_object->{$server}->{$vval}->{$canal}->{paused} = $val; 3458 3949 } 3459 3950 } … … 3462 3953 # If there is no status on the events, is asterisk stable, count the agent in 3463 3954 $estado_final .= $vval; 3464 push @{ $ count_queue{"$server^$vval"} }, "$server^$canal";3955 push @{ $agents_available_on_queue{"$server^$vval"} }, "$server^$canal"; 3465 3956 } 3466 3957 my %count; 3467 my @unique_queues = grep { ++$count{$_} < 2 } @{ $ count_queue{"$server^$vval"} };3468 @{ $ count_queue{"$server^$vval"} } = @unique_queues;3469 $contaconta = @{ $ count_queue{"$server^$vval"} };3958 my @unique_queues = grep { ++$count{$_} < 2 } @{ $agents_available_on_queue{"$server^$vval"} }; 3959 @{ $agents_available_on_queue{"$server^$vval"} } = @unique_queues; 3960 $contaconta = @{ $agents_available_on_queue{"$server^$vval"} }; 3470 3961 3471 3962 my $texto3 = ""; 3472 foreach my $qmem ( @{ $ count_queue{"$server^$vval"} } ) {3963 foreach my $qmem ( @{ $agents_available_on_queue{"$server^$vval"} } ) { 3473 3964 $texto3 .= "$qmem\n"; 3474 3965 } … … 3485 3976 push @return, "$canalag|$estado_final|$texto|$unicoag_id|$canalagid"; 3486 3977 } 3487 push @return, "QUEUE/" . uc( $hash_temporal{Queue} ) . "|infoqstat2|$texto2|$unico_id|$canalid"; 3978 if ( $evento eq "queuememberstatus" ) { 3979 3980 # for each member we sent a message to the queue, on initial status it would make 3981 # more sense to send the status at the end and not for every queue member 3982 push @return, "QUEUE/" . uc( $hash_temporal{Queue} ) . "|infoqstat2|$texto2|$unico_id|$canalid"; 3983 3984 # XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 3985 } 3488 3986 3489 3987 if ( $canal !~ /^Local/i && $canal !~ /^Agent/i && $evento eq "queuemember" ) { … … 3515 4013 $evento = ""; 3516 4014 } 3517 3518 if ( $evento eq "queuestatus" ) { 4015 elsif ( $evento eq "queuestatus" ) { 3519 4016 $canal = $hash_temporal{Queue}; 3520 4017 $canalid = $canal . "-XXXX"; … … 3533 4030 $evento = ""; 3534 4031 } 3535 3536 if ( $evento eq "meetmemute" || $evento eq "meetmeunmute" ) { 4032 elsif ( $evento eq "meetmemute" || $evento eq "meetmeunmute" ) { 3537 4033 my ( $canal, $nada ) = separate_session_from_channel($canalid); 3538 4034 $estado_final = $evento; … … 3540 4036 $evento = ""; 3541 4037 } 3542 3543 if ( $evento eq "queueparams" ) { 4038 elsif ( $evento eq "queueparams" ) { 3544 4039 $canal = $hash_temporal{Queue}; 3545 4040 $canal =~ tr/a-z/A-Z/; … … 3566 4061 $evento = ""; 3567 4062 } 3568 3569 if ( $evento eq "join" ) { 4063 elsif ( $evento eq "join" ) { 3570 4064 my $qclidnum = ""; 3571 4065 my $qclidname = ""; … … 3610 4104 3611 4105 } 3612 3613 if ( $evento eq "meetmejoin" ) {3614 my $ originate= "no";3615 my $nada = "";3616 my $contexto = "";4106 elsif ( $evento eq "meetmejoin" ) { 4107 my $originate = "no"; 4108 my $mute_other_party = "no"; 4109 my $nada = ""; 4110 my $contexto = ""; 3617 4111 3618 4112 if ( $hash_temporal{Channel} =~ /^Local/ ) { … … 3632 4126 3633 4127 for $quehay ( keys %auto_conference ) { 3634 3635 4128 if ( $quehay eq $hash_temporal{Channel} ) { 3636 4129 $originate = $auto_conference{"$quehay"}; 3637 4130 $contexto = $barge_context{$canal}; 3638 4131 } 4132 } 4133 4134 for $quehay ( keys %attendant_transfer ) { 4135 if ( $quehay eq $hash_temporal{Channel} ) { 4136 $originate = $attendant_transfer{$quehay}; 4137 $mute_other_party = $mute_other{$quehay}; 4138 $contexto = $barge_context{$canal}; 4139 4140 # delete mute_other($channel) and set it to mute_other(room) 4141 # so we can use that for redirecting when attendant_pending 4142 # hangs up. 4143 delete $mute_other{$quehay}; 4144 my $indice = $canal . "@" . $config->{$contexto}{'conference_context'}; 4145 $mute_other{$indice} = $mute_other_party; 4146 } 4147 } 4148 4149 my $callerid_attendant = ""; 4150 my $callerid_attendant_n = ""; 4151 if ( $mute_other_party ne "no" ) { 4152 my $extendest = $canal; 4153 my $contedest = $config->{$contexto}{'conference_context'}; 4154 4155 if ( defined( $config->{$contexto}{'attendant_hold_extension'} ) ) { 4156 $extendest = $config->{$contexto}{'attendant_hold_extension'}; 4157 } 4158 4159 if ( defined( $config->{$contexto}{'attendant_hold_context'} ) ) { 4160 $contedest = $config->{$contexto}{'attendant_hold_context'}; 4161 } 4162 4163 log_debug( "** ATTENDANT Redirect $mute_other_party to MUSIC on HOLD extension", 16 ) if DEBUG; 4164 for $quehay ( keys %datos ) { 4165 if ( defined( $datos{$quehay}{Channel} ) ) { 4166 if ( $datos{$quehay}{Channel} eq $mute_other_party ) { 4167 $callerid_attendant = $datos{$quehay}{CallerID}; 4168 $callerid_attendant_n = $datos{$quehay}{CallerIDName}; 4169 } 4170 } 4171 } 4172 my $comando = "Action: Redirect\r\n"; 4173 $comando .= "Channel: $mute_other_party\r\n"; 4174 $comando .= "Exten: " . $extendest . "\r\n"; 4175 $comando .= "Context: " . $contedest . "\r\n"; 4176 $comando .= "ActionID: 1234attendant\r\n"; 4177 $comando .= "Priority: 1\r\n\r\n"; 4178 send_command_to_manager( $comando, $socket, 0, $astmanproxy_server ); 3639 4179 } 3640 4180 … … 3646 4186 $comando .= "Context: " . $config->{$contexto}{'conference_context'} . "\r\n"; 3647 4187 $comando .= "Priority: 1\r\n"; 4188 if ( $callerid_attendant ne "" ) { 4189 $comando .= "CallerID: $callerid_attendant_n <$callerid_attendant>\r\n"; 4190 } 4191 if ( $mute_other_party ne "no" ) { 4192 $comando .= "Async: True\r\n"; 4193 $comando .= "ActionID: attendant-$contexto\r\n"; 4194 } 3648 4195 $comando .= "\r\n"; 3649 4196 send_command_to_manager( $comando, $socket, 0, $astmanproxy_server ); 3650 3651 if ($barge_muted) { 4197 if ( $config->{$contexto}{barge_muted} && $mute_other_party eq "no" ) { 3652 4198 $start_muted{"$server^$originate"} = 1; 3653 4199 } … … 3726 4272 else { 3727 4273 print_datos(99); 3728 ( $qclidnum, $qclidname ) = split_callerid( $datos{$realunique}{CallerID} ); 4274 if ( defined( $datos{$realunique}{CallerID} ) ) { 4275 ( $qclidnum, $qclidname ) = split_callerid( $datos{$realunique}{CallerID} ); 4276 } 4277 else { 4278 $qclidnum = ""; 4279 $qclidname = ""; 4280 } 3729 4281 } 3730 4282 my $texto_pos = "[$qclidnum]"; … … 3736 4288 push @return, "$canalfin|meetmeuser|$hash_temporal{Usernum},$hash_temporal{Meetme}|YYYY-$server|$hash_temporal{Channel}"; 3737 4289 } 3738 3739 if ( $evento eq "meetmeleave" ) { 4290 elsif ( $evento eq "meetmeleave" ) { 3740 4291 $canal = $hash_temporal{Meetme}; 3741 4292 $canal =~ tr/a-z/A-Z/; … … 3767 4318 push @return, "$canalfin|corto||$hash_temporal{Uniqueid}-$server|$canaleja"; 3768 4319 } 3769 3770 if ( $evento eq "leave" ) { 4320 elsif ( $evento eq "leave" ) { 3771 4321 $canal = "QUEUE/" . $hash_temporal{"Queue"}; 3772 4322 $canal =~ tr/a-z/A-Z/; … … 3787 4337 print_sesbot(2); 3788 4338 } 3789 3790 if ( $evento eq "voicemail" ) { 4339 elsif ( $evento eq "voicemail" ) { 3791 4340 my @canalesvoicemail = (); 3792 4341 … … 3825 4374 $evento = ""; 3826 4375 } 3827 3828 if ( $evento eq "link" ) { 4376 elsif ( $evento eq "link" ) { 3829 4377 my $uniqueid1 = $hash_temporal{"Uniqueid1"}; 3830 4378 my $uniqueid2 = $hash_temporal{"Uniqueid2"}; … … 3846 4394 3847 4395 my $channel1conses = $channel1; 3848 if ( $channel1 !~ /${sesion1}$/ ) {4396 if ( $channel1 !~ /${sesion1}$/ && $channel1 !~ /^mISDN/i ) { 3849 4397 $channel1conses = "$canal1-$sesion1"; 3850 4398 } 3851 4399 3852 4400 my $channel2conses = $channel2; 3853 if ( $channel2 !~ /${sesion2}$/ ) {4401 if ( $channel2 !~ /${sesion2}$/ && $channel2 !~ /^mISDN/i ) { 3854 4402 my $channel2conses = "$canal2-$sesion2"; 3855 4403 } … … 3899 4447 $clid2 = $datos{$uniqueid1}{"CallerID"}; 3900 4448 } 3901 if ( $clid1 ne "" && $channel2 ne "" ) { 3902 my $clid_with_format = format_clid( $clid1, $clid_format ); 3903 push @return, "$canal1|settext|[$clid_with_format]|$uniqueid1|$channel1conses"; 3904 } 3905 if ( $clid2 ne "" && $channel1 ne "" ) { 3906 my $clid_with_format = format_clid( $clid2, $clid_format ); 3907 push @return, "$canal2|settext|[$clid_with_format]|$uniqueid2|$channel2conses"; 3908 } 4449 my $sclidname1 = ""; 4450 my $sclidname2 = ""; 4451 4452 if ( defined( $hash_temporal{Privilege} ) ) { 4453 4454 # Fake events do not have the Privilege set, so, do not send the settext 4455 # with callerid on fake link events. 4456 if ( $clid1 ne "" && $channel2 ne "" ) { 4457 $sclidname1 = $saved_clidname{"$server^$channel2"}; 4458 my $clid_with_format = format_clid( $clid1, $sclidname1, $clid_format ); 4459 push @return, "$canal1|setclid|$clid_with_format|$uniqueid1|$channel1conses"; 4460 } 4461 if ( $clid2 ne "" && $channel1 ne "" ) { 4462 $sclidname2 = $saved_clidname{"$server^$channel1"}; 4463 my $clid_with_format = format_clid( $clid2, $sclidname2, $clid_format ); 4464 push @return, "$canal2|setclid|$clid_with_format|$uniqueid2|$channel2conses"; 4465 } 4466 } 4467 3909 4468 push @return, "$canal1|setlink|$channel2|$uniqueid1|$channel1conses"; 3910 4469 push @return, "$canal2|setlink|$channel1|$uniqueid2|$channel2conses"; 3911 4470 $evento = ""; #NEW 3912 4471 } 3913 3914 if ( $evento eq "unlink" ) { 4472 elsif ( $evento eq "unlink" ) { 3915 4473 my $uniqueid1 = $hash_temporal{Uniqueid1}; 3916 4474 my $uniqueid2 = $hash_temporal{Uniqueid2}; … … 3956 4514 $evento = ""; #NEW 3957 4515 } 3958 3959 if ( $evento eq "rename" ) { 4516 elsif ( $evento eq "rename" ) { 3960 4517 my $nuevo_nombre = ""; 3961 4518 my $viejo_nombre = ""; … … 3978 4535 } 3979 4536 3980 # Directamente borra la sesion que se debe renombrar3981 #if ( ( $nuevo_nombre !~ /</ ) && ( $viejo_nombre !~ /</ ) ) {3982 4537 my @final = (); 3983 4538 … … 4050 4605 $evento = ""; #NEW 4051 4606 } 4052 4053 if ( $evento eq "peerstatus" ) { 4607 elsif ( $evento eq "peerstatus" ) { 4054 4608 my $tiempo = 0; 4055 4609 $canal = $hash_temporal{Peer}; … … 4081 4635 $evento = ""; 4082 4636 } 4083 4084 if ( $evento eq "extensionstatus" ) { 4637 elsif ( $evento eq "extensionstatus" ) { 4085 4638 $canal = $hash_temporal{"Exten"}; 4086 4639 $canal =~ s/(\d+)/SCCP\/$1/g; … … 4097 4650 $evento = ""; 4098 4651 } 4099 4100 if ( $evento eq "status" ) { 4652 elsif ( $evento eq "status" ) { 4101 4653 $evento = ""; 4102 4654 } 4103 4104 if ( $evento eq "statuscomplete" ) { 4655 elsif ( $evento eq "statuscomplete" ) { 4105 4656 4106 4657 # When done with the status retrieval, generate events to send to … … 4196 4747 $evento = ""; #NEW (estaba comentado) 4197 4748 } 4198 4199 if ( $evento eq "fakeismeetmemember" ) { 4749 elsif ( $evento eq "fakeismeetmemember" ) { 4200 4750 my @bot1 = (); 4201 4751 my $bot2 = 0; 4202 4752 $estado_final = "meetmeuser"; 4203 $texto = $hash_temporal{"Usernum"} . "," . $hash_temporal{"Meetme"}; 4204 my ( $chan1, $nada1 ) = separate_session_from_channel( $hash_temporal{'Channel'} ); 4205 push @return, "$hash_temporal{'Meetme'}|setlink|$hash_temporal{'Channel'}||$hash_temporal{'Channel'}"; 4206 push @return, "$chan1|setlink|$hash_temporal{'Meetme'}||$hash_temporal{'Channel'}"; 4207 $evento = ""; #NEW 4208 } 4209 4210 if ( $evento eq "newexten" ) { 4211 4212 # If its a new extension without state, defaults to 'Up' 4213 if ( !defined( $datos{$unico_id}{'State'} ) && $fill_datos ) { 4753 $texto = $hash_temporal{Usernum} . "," . $hash_temporal{Meetme}; 4754 my ( $chan1, $nada1 ) = separate_session_from_channel( $hash_temporal{Channel} ); 4755 push @return, "$hash_temporal{Meetme}|setlink|$hash_temporal{Channel}||$hash_temporal{Channel}"; 4756 push @return, "$chan1|setlink|$hash_temporal{Meetme}||$hash_temporal{Channel}"; 4757 $evento = ""; 4758 4759 } 4760 elsif ( $evento eq "newexten" ) { 4761 4762 print "newexten\n"; 4763 4764 # If its a new extension without state and priority 1, defaults to 'Up' and set setlid 4765 if ( !defined( $datos{$unico_id}{'State'} ) && $hash_temporal{Priority} == 1 ) { 4214 4766 $datos{$unico_id}{'State'} = "Up"; 4215 4767 log_debug( "$heading POPULATES datos($unico_id){ State } = Up", 128 ) if DEBUG; 4768 ( $canal, $sesion ) = separate_session_from_channel( $hash_temporal{Channel} ); 4769 $texto = $hash_temporal{Extension}; 4770 if($texto ne "s") { 4771 $estado_final = "setclid"; 4772 } 4773 } 4774 else { 4775 print "Newexten pero otro priority?\n"; 4216 4776 } 4217 4777 … … 4226 4786 log_debug( "$heading NO EXISTE parked{$server^$canalid}", 128 ) if DEBUG; 4227 4787 } 4228 } 4229 4230 if ( $evento eq "hangup" ) { 4788 4789 if ( exists( $pending_uniqueid_attendant{ $hash_temporal{Uniqueid} } ) ) { 4790 4791 # This was from an originatesuccess for attendant transfers 4792 # so remove the hash element and add it to attendant_pending hash 4793 # that is used for look for hangups and perform redirects 4794 4795 $attendant_pending{ $hash_temporal{Channel} } = $pending_uniqueid_attendant{ $hash_temporal{Uniqueid} }; 4796 delete $pending_uniqueid_attendant{ $hash_temporal{Uniqueid} }; 4797 log_debug( "Save " . $hash_temporal{Channel} . " as pending", 16 ) if DEBUG; 4798 } 4799 4800 4801 } 4802 elsif ( $evento eq "hangup" ) { 4803 4804 # Look for attendant_pending and perform a redirect of the 4805 # hold channel to the same meetme room to complete the transfer 4806 my $canalid = $hash_temporal{Channel}; 4807 my $room = ""; 4808 my @aborrar = (); 4809 foreach my $key ( keys %attendant_pending ) { 4810 if ( $canalid eq $key ) { 4811 $room = $attendant_pending{$key}; 4812 log_debug( "** ATTENDANT corto y pending coincide con $canalid! es = $room", 16 ) if DEBUG; 4813 last; 4814 } 4815 } 4816 if ( $room ne "" ) { 4817 push @aborrar, $canalid; 4818 while ( my ( $key, $val ) = each(%attendant_pending) ) { 4819 if ( $val eq $room ) { 4820 push @aborrar, $key; 4821 } 4822 } 4823 foreach my $item (@aborrar) { 4824 log_debug( "** ATTENDANT borrando pending $item", 32 ) if DEBUG; 4825 delete $attendant_pending{$item}; 4826 } 4827 log_debug( "transfer " . $mute_other{$room} . " to meetme $room", 32 ) if DEBUG; 4828 my $eext = $room; 4829 my $ccnt = $room; 4830 $eext =~ s/(.*)\@(.*)/$1/g; 4831 $ccnt =~ s/(.*)\@(.*)/$2/g; 4832 my $comando = "Action: Redirect\r\n"; 4833 $comando .= "Channel: $mute_other{$room}\r\n"; 4834 $comando .= "Exten: $eext\r\n"; 4835 $comando .= "Context: $ccnt\r\n"; 4836 $comando .= "Priority: 10\r\n\r\n"; 4837 send_command_to_manager( $comando, $socket, 0, $astmanproxy_server ); 4838 } 4839 else { 4840 log_debug( "** ATTENDANT no room for pending", 32 ) if DEBUG; 4841 } 4842 4843 # End block for attendant pending 4844 4231 4845 if ( exists( $datos{$unico_id} ) ) { 4232 4846 $datos{$unico_id}{'State'} = "Down"; 4847 $hash_temporal{'State'} = "Down"; 4233 4848 log_debug( "$heading POPULATES datos($unico_id){ State } = down", 128 ) if DEBUG; 4234 }4235 else {4236 $hash_temporal{'State'} = "Down";4237 4849 } 4238 4850 … … 4248 4860 } 4249 4861 } 4250 4251 if ( $evento eq "unparkedcall" ) { 4862 elsif ( $evento eq "unparkedcall" ) { 4252 4863 my $channel1 = $hash_temporal{"Channel"}; 4253 4864 … … 4262 4873 } 4263 4874 } 4264 4265 if ( $evento eq "parkedcall" ) { 4875 elsif ( $evento eq "parkedcall" ) { 4266 4876 $texto = "&parked," . $hash_temporal{'Exten'} . "&"; 4267 4877 $estado_final = "ocupado3"; … … 4285 4895 $evento = ""; #NEW 4286 4896 } 4287 4288 if ( $evento eq "newcallerid" ) { 4897 elsif ( $evento eq "newcallerid" ) { 4289 4898 $estado_final = "setstatus"; 4290 4899 $state = "Newcallerid"; … … 4309 4918 # Dont check for $evento bellow this line! 4310 4919 4920 print "AFTER IF ELSE IF evento = $evento\n"; 4921 4311 4922 if ( $evento ne "" ) { 4312 4923 log_debug( "$heading Event $evento, canal '$canal'", 32 ) if DEBUG; … … 4363 4974 } 4364 4975 4365 if ( exists( $datos{$unico_id}{'State'} ) ) {4366 log_debug( "$heading EXISTE datos($unico_id){state}", 32 ) if DEBUG;4367 $state = $datos{$unico_id}{'State'};4368 }4369 4370 4976 if ( exists( $datos{$unico_id}{'Callerid'} ) ) { 4371 4977 $clid = $datos{$unico_id}{'Callerid'}; … … 4395 5001 } 4396 5002 5003 # print "clidnum $clidnum clidname $clidname\n"; 5004 4397 5005 if ( $state eq "" ) { 4398 5006 if ( defined( $hash_temporal{'State'} ) ) { … … 4404 5012 } 4405 5013 4406 my $clid_with_format = format_clid( $clidnum, $clid _format );5014 my $clid_with_format = format_clid( $clidnum, $clidname, $clid_format ); 4407 5015 4408 5016 if ( $state eq "Ringing" ) { … … 4425 5033 4426 5034 if ( $state eq "Ring" ) { 4427 $texto = "&calling"; 5035 print "RING $canalid $texto\n"; 5036 $texto = $canalid; 4428 5037 $estado_final = "ring"; 4429 5038 $datos{$unico_id}{'Origin'} = "true"; … … 4521 5130 my $exten_clid = ""; 4522 5131 if ( $state eq "Up" ) { 5132 5133 if ( defined( $hash_temporal{CallerIDName} ) ) { 5134 $saved_clidname{"$server^$hash_temporal{'Channel'}"} = $hash_temporal{CallerIDName}; 5135 } 5136 4523 5137 if ( $exten ne "" ) { 4524 5138 if ( is_number($exten) ) { 4525 $exten_clid = format_clid( $exten, $clid_format );5139 $exten_clid = format_clid( $exten, '', $clid_format ); 4526 5140 if ( defined( $saved_clidnum{"$server^$canalid"} ) ) { 4527 $exten_clid = format_clid( $saved_clidnum{"$server^$canalid"}, $ clid_format );5141 $exten_clid = format_clid( $saved_clidnum{"$server^$canalid"}, $saved_clidname{"$server^$canalid"}, $clid_format ); 4528 5142 } 4529 5143 if ($clid_privacy) { … … 4533 5147 } 4534 5148 else { 4535 if ( length($exten) == 1 ) { 4536 $conquien = $exten; 4537 $exclude = 1; # We ignore events that have letter extensions 's', 'h', etc 4538 $exclude = 0; # Do we? UserEvent fake events dont work if we ignore them 4539 log_debug( "$heading CLID is not a number! $exten", 32 ) if DEBUG; 5149 if ( defined( $saved_clidname{"$server^$hash_temporal{Channel}"} ) ) { 5150 $clidname = $saved_clidname{"$server^$hash_temporal{Channel}"}; 4540 5151 } 4541 else{4542 $c onquien = $exten;5152 if ( defined( $saved_clidnum{"$server^$hash_temporal{Channel}"} ) ) { 5153 $clidnum = $saved_clidnum{"$server^$hash_temporal{Channel}"}; 4543 5154 } 5155 $conquien = format_clid( $clidnum, $clidname, $clid_format ); 5156 5157 #if ( length($exten) == 1 ) { 5158 # $conquien = $exten; 5159 # $exclude = 1; # We ignore events that have letter extensions 's', 'h', etc 5160 # $exclude = 0; # Do we? UserEvent fake events dont work if we ignore them 5161 # log_debug( "$heading CLID is not a number! $exten", 32 ) if DEBUG; 5162 #} 5163 #else { 5164 # $conquien = $exten; 5165 #} 4544 5166 } 4545 5167 } … … 4562 5184 } 4563 5185 else { 5186 if ( $exten_clid eq "" ) { $exten_clid = $conquien; } 4564 5187 $texto = "&calling,[$exten_clid]"; 4565 5188 } … … 4610 5233 my $local_channel = $canal; 4611 5234 $local_channel =~ s/Local\///gi; 5235 if ( $local_channel =~ m/\/n$/ ) { 5236 $local_channel = substr( $local_channel, 0, -2 ); 5237 } 5238 4612 5239 if ( defined( $extension_transfer_reverse{"$server^$local_channel"} ) ) { 4613 5240 if ( $extension_transfer_reverse{"$server^$local_channel"} !~ /\d+\^CLID/ ) { … … 4656 5283 my @mensajes = (); 4657 5284 my $interno = ""; 4658 my $tod o= "";5285 my $toda = ""; 4659 5286 my @mensajefinal; 4660 5287 my $cuantas; … … 4668 5295 4669 5296 @fake_bloque = (); 4670 delete $datos{""}; 5297 5298 # delete $datos{""}; 4671 5299 foreach my $blaque (@blique) { 4672 5300 … … 4689 5317 log_debug( "$heading GOT $mensaje", 32 ) if DEBUG; 4690 5318 delete $datos{""}; # Erase the hash with no uniqueid 4691 ( $canal, $quehace, $dos, $uniqueid, $canalid ) = 4692 split( /\|/, $mensaje ); 5319 ( $canal, $quehace, $dos, $uniqueid, $canalid ) = split( /\|/, $mensaje ); 5320 5321 $canalid =~ s/(.*),(\d)/$1/g; # discard ,2 on Local channels 4693 5322 4694 5323 if ( !defined($dos) ) { $dos = ""; } … … 4701 5330 4702 5331 if ( $dos eq "skip" ) { 4703 log_debug( "$heading SALTEO $canal tiene skip", 32 ) if DEBUG;5332 log_debug( "$heading skipping $canal $quehace (has skip)", 32 ) if DEBUG; 4704 5333 next; 4705 5334 } 5335 4706 5336 if ( $quehace eq "" ) { 4707 log_debug( "$heading SALTEO $canal no tiene quehace", 32 ) if DEBUG; 5337 log_debug( "$heading skipping $canal (empty quehace)", 32 ) if DEBUG; 5338 print "skip empty\n"; 4708 5339 next; 4709 5340 } … … 4715 5346 log_debug( "$heading canalid: $canalid", 32 ) if DEBUG; 4716 5347 4717 # if ( !defined($canal) ) { $canal = ""; } 4718 # if ( !defined($quehace) ) { $quehace = ""; } 4719 # if ( !defined($dos) ) { $dos = ""; } 4720 4721 $canalid =~ s/\s+//g; # Removes whitespace from CHANNEL-ID 5348 $canalid =~ s/\s+//g; # Removes whitespace from CHANNEL-ID 5349 my $real_canal = $canalid; 4722 5350 my $canalidzombie = $canalid; # Removes whitespace from CHANNEL-ID 4723 5351 $canalid =~ s/(.*)<(.*)>/$1/g; # discards ZOMBIE or MASQ … … 4747 5375 my $cuantos = @canaleja; 4748 5376 5377 # Perform some pre processing... 5378 4749 5379 if ( $quehace eq "corto" || $quehace eq "info" ) { 4750 5380 4751 5381 # We collect the last state of the channel on hangup 5382 $toda = ""; 4752 5383 while ( my ( $key, $val ) = each( %{ $datos{$uniqueid} } ) ) { 4753 $tod o.= "$key = $val\n"5384 $toda .= "$key = $val\n" 4754 5385 if ( $key ne "E" ) && ( defined($val) ); 4755 5386 log_debug( "$heading \tAgrego $key = $val", 128 ) if DEBUG; 4756 5387 } 4757 $todo .= " "; 4758 $todo = encode_base64($todo); 4759 4760 delete $datos{$uniqueid}; 4761 delete $cola->{$canalidzombie}; 5388 $toda .= " "; 5389 $toda = encode_base64($toda); 5390 5391 if ( $quehace eq "corto" ) { 5392 delete $datos{$uniqueid}; 5393 } 5394 4762 5395 log_debug( "$heading erasing datos{$uniqueid}", 128 ) if DEBUG; 4763 5396 … … 4769 5402 erase_all_sessions_from_channel( $canalid, $canal, $server ); 4770 5403 } 4771 } 4772 4773 if ( $quehace eq "queueremoved" ) { 5404 5405 } elsif ( $quehace eq "queueremoved" ) { 4774 5406 4775 5407 # Remove the agent from the agents_on_queue hash … … 4814 5446 } 4815 5447 4816 if ( !defined( $buttons{"$server^$canal"} ) ) { 4817 log_debug( "$heading \tNo tengo botones para $server^$canal, END FUNCTION", 128 ) if DEBUG; 4818 for ( keys %buttons ) { 4819 log_debug( "$heading \t\tKey $_", 128 ) if DEBUG; 5448 if ( !defined( $buttons{"$server^$canal"} ) && !defined( $buttons{"-1^$canal"} ) ) { 5449 log_debug( "$heading \tThere are no buttons for $server^$canal, skipping...", 128 ) if DEBUG; 5450 if (DEBUG) { 5451 for ( keys %buttons ) { 5452 log_debug( "$heading \t\tKey $_", 128 ); 5453 } 4820 5454 } 4821 5455 next; … … 4825 5459 # except ocupado*, corto, setlink and unsetlink 4826 5460 if ( $canal =~ /^_/ ) { 4827 log_debug( "$heading canal $canal es un WILD y quehace vale$quehace", 32 ) if DEBUG;5461 log_debug( "$heading canal $canal is regexp, quehace value = $quehace", 32 ) if DEBUG; 4828 5462 4829 5463 if ( $quehace =~ /registr/ … … 4831 5465 || $quehace =~ /^inf/ ) 4832 5466 { 4833 log_debug( "$heading IGNOR O $quehace porque es un wildcard", 32 ) if DEBUG;5467 log_debug( "$heading IGNORING $quehace because it is a regexp match", 32 ) if DEBUG; 4834 5468 next; 4835 5469 } … … 4839 5473 && $quehace !~ /^state/ 4840 5474 && $quehace !~ /^settext/ 5475 && $quehace !~ /^setclid/ 4841 5476 && $quehace !~ /^setlabel/ 4842 5477 && $quehace !~ /^setlink/ … … 4856 5491 my ( $canalsolo, $nrotrunk ) = split( /=/, $canal ); 4857 5492 $canal = $canalsolo . "=1" . $elcontexto; 4858 log_debug( "$heading quehace=$quehace, elijo el 1ero deltrunk $canal", 32 ) if DEBUG;5493 log_debug( "$heading quehace=$quehace, select 1st from trunk $canal", 32 ) if DEBUG; 4859 5494 4860 5495 #next; … … 4865 5500 # change it so to not change the led color. 4866 5501 if ( $quehace =~ /changelabel1/ ) { 4867 log_debug( "$heading el wildcardtiene changelabel1, lo cambio por changelabel0!", 32 )5502 log_debug( "$heading el regexp tiene changelabel1, lo cambio por changelabel0!", 32 ) 4868 5503 if DEBUG; 4869 5504 $quehace = "changelabel0"; … … 4871 5506 } 4872 5507 4873 if ( $canal ne "" ) { 5508 my $serverindex = $server; # Save the server in another var 5509 5510 if ( $canal eq "" ) { 5511 # No channel? continue... 5512 log_debug( "$heading There is no command defined", 32 ) if DEBUG; 5513 5514 } else { 5515 5516 $interno = $buttons{"$server^$canal"}; 5517 5518 if ( !defined($interno) ) { 5519 $interno = $buttons{"-1^$canal"}; 5520 $serverindex = -1; 5521 if ( $quehace !~ /regist/ ) { 5522 $button_server{$interno} = $server; 5523 } 5524 } 5525 5526 $interno = "" if ( !defined($interno) ); 5527 5528 if ( $interno ne "" ) { 5529 if ( defined( $clid_private{$interno} ) && $clid_private{$interno} == 1 ) { 5530 if ( $dos =~ m/\[/ ) { 5531 $dos =~ s/([^\[]*)?(\[.*\])/$1 \[n\/a\]/g; 5532 } 5533 } 5534 } 5535 5536 # The following block cleans internal op_server states. no matter if we 5537 # have a button defined or not. 4874 5538 4875 5539 if ( $quehace eq 'corto' || $quehace eq 'info' ) { … … 4883 5547 } 4884 5548 else { 4885 $btnorinum = $buttons{"$server ^$canaleje"};5549 $btnorinum = $buttons{"$serverindex^$canaleje"}; 4886 5550 } 4887 5551 log_debug( "$heading call GEN_LINKED 1", 32 ) if DEBUG; … … 4892 5556 delete $datos{$uniqueid}; 4893 5557 log_debug( "$heading REMOVING datos { $uniqueid }", 32 ) if DEBUG; 4894 } 4895 4896 if ( $quehace eq "setlink" ) { 5558 5559 } elsif ( $quehace eq "setlink" ) { 5560 4897 5561 log_debug( "$heading IF quehace = SETLINK", 32 ) if DEBUG; 4898 5562 my ( $nada1, $contexto1 ) = split( /\&/, $canal ); … … 4918 5582 } 4919 5583 4920 #my %seen = ();4921 #my @uniq =4922 # grep { !$seen{$_}++ } @{ $linkbot{"$server^$canal"} };4923 #$linkbot{"$server^$canal"} = \@uniq;4924 5584 my @uniq = unique( @{ $linkbot{"$server^$canal"} } ); 4925 5585 $linkbot{"$server^$canal"} = \@uniq; … … 4928 5588 log_debug( "$heading linkbot ($server^$canal) = $valorad", 32 ) if DEBUG; 4929 5589 } 4930 my $btnorinum = $buttons{"$server ^$canal"};5590 my $btnorinum = $buttons{"$serverindex^$canal"}; 4931 5591 log_debug( "$heading llamo a GENERATE_LINKED", 32 ) if DEBUG; 4932 5592 $listabotones = generate_linked_buttons_list( $canal, $server ); … … 4935 5595 log_debug( "$heading linkeado con $listabotones", 32 ) if DEBUG; 4936 5596 log_debug( "$heading ENDIF quehace = SETLINK", 32 ) if DEBUG; 4937 } 4938 4939 if ( $quehace eq "unsetlink" ) { 5597 5598 } elsif ( $quehace eq "unsetlink" ) { 4940 5599 log_debug( "$heading IF quehace = UNSETLINK", 32 ) if DEBUG; 4941 5600 my @final = (); … … 4947 5606 $linkbot{"$server^$canal"} = [@final]; 4948 5607 log_debug( "$heading ENDIF quehace = UNSETLINK", 32 ) if DEBUG; 4949 } 4950 4951 $interno = $buttons{"$server^$canal"}; 4952 $interno = "" if ( !defined($interno) ); 4953 4954 if ( $interno ne "" ) { 4955 if ( defined( $clid_private{$interno} ) && $clid_private{$interno} == 1 ) { 4956 if ( $dos =~ m/\[/ ) { 4957 $dos =~ s/([^\[]*)?(\[.*\])/$1 \[n\/a\]/g; 4958 } 4959 } 4960 } 4961 4962 if ( $quehace eq "queueremoved" ) { 5608 5609 } elsif ( $quehace eq "queueremoved" ) { 5610 4963 5611 delete $botonvoicemail{$interno}; 4964 5612 delete $botonvoicemailcount{$interno}; … … 4975 5623 } 4976 5624 5625 # Continue after cleaning internal state... 4977 5626 if ( $interno eq "" ) { 4978 log_debug( "$heading NO HAY INTERNO buttons($server^$canal), ABORTO", 32 ) if DEBUG;5627 log_debug( "$heading MISSING buttons($server^$canal), skipping...", 32 ) if DEBUG; 4979 5628 next; 4980 5629 } 4981 log_debug( "$heading EL INTERNO es $interno", 32 ) if DEBUG; 5630 else { 5631 log_debug( "$heading INTERNO = $interno", 32 ) if DEBUG; 5632 } 4982 5633 4983 5634 if ( !defined( $laststatus{$interno} ) ) { … … 5001 5652 # 5002 5653 if ( $canalid eq "" || $canalid =~ /zombie/i || $canalid =~ /(.*)-XXXX$/ ) { 5003 log_debug( "$heading ATEN CION canalid es $canalid, NO PROCESAR?", 32 ) if DEBUG;5654 log_debug( "$heading ATENTION canalid = '$canalid', skipping...", 32 ) if DEBUG; 5004 5655 } 5005 5656 else { … … 5044 5695 if DEBUG; 5045 5696 &print_sesbot(3); 5697 &print_datos(1); 5698 5046 5699 if ( $laststatus{$interno} ne "busy|${buttontext}" ) { 5047 5700 $cambiaron{$interno} = 1; … … 5049 5702 push @respuestas, "$interno|state|busy"; 5050 5703 5051 # Justin from Fry's has prolems with callerid being cleared while a call is connected5052 # from a queue using Local channels, so commnet these out5053 #push @respuestas, "$interno|settext|";5054 #push @respuestas, "$interno|setstatus|";5055 5704 $laststatus{$interno} = "busy|${buttontext}"; 5056 5705 … … 5059 5708 if DEBUG; 5060 5709 } 5061 $estadoboton{$interno} = "busy|${buttontext}"; 5710 5711 # Conserva el callerid anterior 5712 if ( defined( $preestadoboton{$interno} ) ) { 5713 $estadoboton{$interno} = $preestadoboton{$interno}; 5714 delete $preestadoboton{$interno}; 5715 } 5716 else { 5717 $estadoboton{$interno} = "busy|${buttontext}"; 5718 } 5719 my $stringy = $estadoboton{$interno}; 5720 $stringy =~ s/(.*)\|(.*)/$2/g; 5721 push @respuestas, "$interno|settext|$stringy"; 5062 5722 } 5063 5723 … … 5107 5767 $cambiaron{$interno} = 1; 5108 5768 } 5769 if ( $estadoboton{$interno} =~ /^busy/ ) { 5770 5771 # If we were busy before the ringing, save the callerid so we can restore it 5772 # if this call is not answered, discarded, or whatever. 5773 $preestadoboton{$interno} = $estadoboton{$interno}; 5774 } 5109 5775 $estadoboton{$interno} = "ringing|${buttontext}"; 5110 5776 if ( $dos =~ m/(.*)?\[(.*)\].*?/ ) { … … 5115 5781 # We dont want a timer when ringing - Local channels 5116 5782 # generate a previous state and timer 5117 push @mensajefinal, "$interno|settimer|0\@STOP";5783 ## push @mensajefinal, "$interno|settimer|0\@STOP"; 5118 5784 5119 5785 } 5120 5786 elsif ( $quehace =~ /^ocupado/ ) { 5787 5788 if ( defined( $group_count{$interno} ) ) { 5789 my $plural = ""; 5790 if ( $group_count{$interno} == 1 ) { 5791 if ( @{ $sesbot{$interno} } > 1 ) { 5792 $plural = "s"; 5793 } 5794 if ( @{ $sesbot{$interno} } > 0 ) { 5795 my $cuantos = @{ $sesbot{$interno} }; 5796 my ( $text, $textriginal, $buttontext ) = 5797 translate( $canal, "&channels,$cuantos,$plural", "", "" ); 5798 $buttontext = $text; 5799 $dos = "[" . $buttontext . "]"; 5800 } 5801 } 5802 } 5121 5803 if ( $laststatus{$interno} ne "busy|${buttontext}" ) { 5122 5804 $cambiaron{$interno} = 1; 5123 5805 } 5124 5806 $estadoboton{$interno} = "busy|${buttontext}"; 5807 5125 5808 } 5126 5809 } … … 5128 5811 5129 5812 log_debug( "$heading Continuo proceso...", 32 ) if DEBUG; 5813 5130 5814 if ( $quehace =~ /changelabel/ ) { 5131 5815 log_debug( "$heading quehace = changelabel", 32 ) if DEBUG; … … 5157 5841 } 5158 5842 else { 5159 $botonled{$interno} = $cambia_el_led; 5160 $botonlabel{$interno} = $dos; 5161 $agent_label{$canal} = $dos; 5843 $botonled{$interno} = $cambia_el_led; 5844 if ( $ren_agentlogin || $ren_cbacklogin ) { 5845 $botonlabel{$interno} = $dos; 5846 } 5847 else { 5848 $botonlabel{$interno} = "."; 5849 } 5850 5851 $agent_label{$canal} = $dos; 5162 5852 } 5163 5853 5164 } 5165 if ( $quehace eq "park" ) { 5854 } elsif ( $quehace eq "park" ) { 5855 5166 5856 log_debug( "$heading quehace = park", 32 ) if DEBUG; 5167 5857 $dos =~ m/(.*)\((.*)\)/; … … 5170 5860 $timeout = time() + $timeout; 5171 5861 $botonpark{$interno} = "$texto|$timeout"; 5172 } 5173 if ( $quehace eq "meetmeuser" ) { 5862 } elsif ( $quehace eq "meetmeuser" ) { 5174 5863 $botonmeetme{$interno} = $dos; 5175 } 5176 5177 if ( $quehace eq "infoqstat" ) { 5864 } elsif ( $quehace eq "infoqstat" ) { 5178 5865 $botonqueue{$interno} = $dos; 5179 } 5180 elsif ( $quehace eq "infoqstat2" ) { 5866 } elsif ( $quehace eq "infoqstat2" ) { 5181 5867 $botonqueue_count{$interno} = $dos; 5182 } 5183 elsif ( $quehace =~ /info/ ) { 5868 } elsif ( $quehace =~ /info/ ) { 5184 5869 my $mcola = $quehace; 5185 5870 $mcola =~ s/^info//g; 5186 push @{ $botonqueuemember{$interno} }, "$mcola|$dos"; 5187 } 5188 5189 if ( $quehace eq "settext" ) { 5190 $botonclid{$interno} = $dos; 5191 push @respuestas, "$interno|settext|$dos"; 5192 } 5193 if ( $quehace eq "setalpha" ) { 5871 my $estaba = 0; 5872 my @newarray = (); 5873 foreach my $val ( @{ $botonqueuemember{$interno} } ) { 5874 if ( $val =~ /^$mcola\|/ ) { 5875 if ( $val eq "$mcola|$dos" ) { 5876 $estaba = 1; 5877 $quehace = ""; 5878 } 5879 } 5880 else { 5881 push @newarray, $val; 5882 } 5883 } 5884 @{ $botonqueuemember{$interno} } = @newarray; 5885 if ( $estaba == 0 ) { 5886 push @{ $botonqueuemember{$interno} }, "$mcola|$dos"; 5887 } 5888 5889 } elsif ( $quehace eq "setclid" ) { 5890 if ( !defined( $group_count{$interno} ) ) { 5891 push @respuestas, "$interno|settext|$dos"; 5892 } 5893 } elsif ( $quehace eq "settext" ) { 5894 if ( !defined( $group_count{$interno} ) ) { 5895 $botonpermanenttext{$interno} = $dos; 5896 print "vino settext a digest permanent $interno = -$dos-\n"; 5897 push @respuestas, "$interno|settext|$dos"; 5898 } 5899 } elsif ( $quehace eq "fopledcolor" ) { 5900 $botonledcolor{$interno} = $dos; 5901 } elsif ( $quehace eq "setalpha" ) { 5194 5902 $botonalpha{$interno} = $dos; 5195 5903 push @respuestas, "$interno|setalpha|$dos"; 5196 } 5197 if ( $quehace eq "flip" ) { 5904 } elsif ( $quehace eq "flip" ) { 5198 5905 push @respuestas, "$interno|flip|$dos"; 5199 } 5200 if ( $quehace eq "setlabel" ) { 5906 } elsif ( $quehace eq "setlabel" ) { 5201 5907 if ( $dos ne "." 5202 5908 && $dos ne "original" … … 5206 5912 push @respuestas, "$interno|setlabel|$dos"; 5207 5913 } 5208 } 5209 if ( $quehace eq "voicemail" ) { 5914 } elsif ( $quehace eq "voicemail" ) { 5210 5915 $botonvoicemail{$interno} = $dos; 5211 } 5212 if ( $quehace eq "voicemailcount" ) { 5916 } elsif ( $quehace eq "voicemailcount" ) { 5213 5917 $botonvoicemailcount{$interno} = $dos; 5918 } elsif ( $quehace =~ "^voicemail" ) { 5919 5920 # This block is for the voicemail client 5921 my $canalsincontexto = $canal; 5922 $canalsincontexto =~ s/(.*)&(.*)/$1/g; 5923 push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|$dos"; 5924 } elsif ( $quehace =~ "^ringing" ) { 5925 5926 # This block is for the voicemail client, popups 5927 my $canalsincontexto = $canal; 5928 $canalsincontexto =~ s/(.*)&(.*)/$1/g; 5929 my $calleridpop = $dos; 5930 $calleridpop =~ s/(.*)\Q[\E(.*)/$2/g; 5931 $calleridpop =~ s/\]//g; 5932 $calleridpop =~ s/\s+//g; 5933 push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|$calleridpop"; 5214 5934 } 5215 5935 … … 5237 5957 else { 5238 5958 5239 # This block is for the voicemail client5240 if ( $quehace =~ "^voicemail" ) {5241 my $canalsincontexto = $canal;5242 $canalsincontexto =~ s/(.*)&(.*)/$1/g;5243 push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|$dos";5244 }5245 5246 # This block is for the voicemail client, popups5247 if ( $quehace =~ "^ringing" ) {5248 my $canalsincontexto = $canal;5249 $canalsincontexto =~ s/(.*)&(.*)/$1/g;5250 my $calleridpop = $dos;5251 $calleridpop =~ s/(.*)\Q[\E(.*)/$2/g;5252 $calleridpop =~ s/\]//g;5253 $calleridpop =~ s/\s+//g;5254 push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|$calleridpop";5255 }5256 5959 if ( $quehace eq "corto" ) { 5257 5960 my $canalsincontexto = $canal; … … 5289 5992 $canalag = "Agent/" . $canalag; 5290 5993 } 5291 print_agents();5292 5994 5293 5995 my %temp_channel_to_agent = %channel_to_agent; … … 5313 6015 delete $botontimer{$interno}; 5314 6016 delete $botontimertype{$interno}; 6017 delete $sesbot{$interno}; # Delete all sessions for agentlogoff XXXXXXX ???? 5315 6018 } 5316 6019 5317 if ( $quehace2 !~ /isagent/ && $quehace2 !~ /^agentlogoff/ ) {6020 if ( $quehace2 !~ /isagent/ && $quehace2 !~ /^agentlogoff/ && $quehace2 !~ /^setclid/ ) { 5318 6021 log_debug( "$heading pushing respuestas $interno|$quehace2|$dos", 32 ) if DEBUG; 5319 6022 … … 5322 6025 # "isagent". "agentlogoff" 5323 6026 # everything else is pushed 5324 push @respuestas, "$interno|$quehace2|$dos"; 6027 if ( defined( $group_count{$interno} ) && $quehace2 eq "setclid" ) { 6028 log_debug( "$heading skip settext because groupcount is set", 32 ) if DEBUG; 6029 } 6030 else { 6031 if ( $quehace2 ne "" ) { 6032 push @respuestas, "$interno|$quehace2|$dos"; 6033 print "push $quehace2 en $interno quehace2\n"; 6034 } 6035 } 5325 6036 } 5326 6037 … … 5355 6066 } 5356 6067 } 6068 if ( $quehace eq "ocupado1" ) { 6069 push @mensajefinal, "$interno|channel|$canalid"; 6070 } 5357 6071 if ( $quehace2 eq "ring" ) { 5358 6072 push @mensajefinal, "$interno|state|busy"; 5359 5360 #push @mensajefinal, "$interno|settext|$dos";5361 6073 } 5362 6074 if ( $quehace2 =~ /corto/ ) { … … 5399 6111 my $valip = ""; 5400 6112 log_debug( "$heading quehace2 corto, no es agente, pongo timer en cero", 1 ) if DEBUG; 5401 print_agents();5402 6113 5403 6114 push @mensajefinal, "$interno|settimer|0\@STOP"; … … 5408 6119 } 5409 6120 else { 6121 if ( defined( $botonpermanenttext{$interno} ) ) { 6122 push @mensajefinal, "$interno|settext|$botonpermanenttext{$interno}"; 6123 print "corto! permanent $interno = -$dos-\n"; 6124 6125 #$botonpermanenttext{$interno} = $dos; 6126 } 5410 6127 $botonclid{$interno} = ""; 6128 5411 6129 } 5412 6130 … … 5434 6152 } 5435 6153 6154 if ( $quehace eq "paused" ) { 6155 $boton_paused{$interno} = $dos; 6156 } 6157 if ( $quehace eq "agents_paused" ) { 6158 $boton_agentpaused{$interno} = $dos; 6159 } 6160 if ( $quehace eq "agents_ready" ) { 6161 $boton_agentready{$interno} = $dos; 6162 } 6163 if ( $quehace eq "agents_busy" ) { 6164 $boton_agentbusy{$interno} = $dos; 6165 } 6166 if ( $quehace eq "agents_logedof" ) { 6167 $boton_agentlogedof{$interno} = $dos; 6168 } 6169 5436 6170 log_debug( "$heading Agrego mensaje final $interno|$quehace2|$dos", 32 ) if DEBUG; 5437 6171 … … 5458 6192 } 5459 6193 } 5460 if ( $tod one "" ) {5461 my $otromensajefinal = "$interno|info|$tod o";6194 if ( $toda ne "" ) { 6195 my $otromensajefinal = "$interno|info|$toda"; 5462 6196 push( @respuestas, $otromensajefinal ); 6197 $toda = ""; 5463 6198 } 5464 6199 } … … 5466 6201 5467 6202 $laststatus{$interno} = $estadoboton{$interno}; 5468 }5469 else { # endif canal distinto de nada5470 log_debug( "$heading There is no command defined", 32 ) if DEBUG;5471 6203 } 5472 6204 } … … 5549 6281 5550 6282 sub clean_inmemory_state_for_server { 6283 5551 6284 my $server = shift; 5552 6285 my @botones_a_limpiar; … … 5567 6300 delete $botonvoicemailcount{$_}; 5568 6301 delete $botonalpha{$_}; 6302 delete $botonledcolor{$_}; 5569 6303 delete $botonqueue{$_}; 5570 6304 delete $botonqueuemember{$_}; … … 5656 6390 } 5657 6391 5658 # Add sAMI handles into IO::Select6392 # Add AMI handles into IO::Select 5659 6393 foreach (@p) { 5660 6394 if ( defined($_) ) { … … 5885 6619 if ( $bloque_final =~ /Event:/ 5886 6620 || $bloque_final =~ /Message: Mailbox/ 6621 || $bloque_final =~ /SIP-CanReinvite/ 5887 6622 || $bloque_final =~ /Message: Timeout/ ) 5888 6623 { … … 5892 6627 my $block_count = -1; 5893 6628 foreach my $p (@lineas) { 6629 if ( $p =~ /ActionID: autosipentry/ ) { 6630 $block_count++; 6631 $bloque[$block_count]{Event} = "sippeerentrylong"; 6632 } 5894 6633 my $my_event = ""; 5895 if ( $p =~ / Event:/ ) {6634 if ( $p =~ /^Event:/ ) { 5896 6635 $block_count++; 5897 6636 log_debug( "$heading Event detected block_count = $block_count", 128 ) … … 6117 6856 if ( $origin_channel =~ m/^PARK/i || $origin_channel =~ m/^QUEUE/i || $origin_channel =~ m/^\d/ ) { 6118 6857 $local_reverse = 0; 6119 log_debug( "** GET TRANSFER Disable reverse transfer for $origin_channel!",16) if DEBUG;6858 log_debug( "** GET TRANSFER Disable reverse transfer for $origin_channel!", 16 ) if DEBUG; 6120 6859 } 6121 6860 … … 6125 6864 # Transfer the session from the *other* button 6126 6865 @cuales_transferir = extraer_todos_los_enlaces_de_un_canal( $origin_channel, $button_server{$datosflash} ); 6127 if (@cuales_transferir == 0) { 6128 log_debug( "** !! REVERSE TRANSFER No reverse available, using regular sesbot", 16 ) if DEBUG; 6129 if ( @{ $sesbot{$datosflash} } ) { 6130 @cuales_transferir = @{ $sesbot{$datosflash} }; 6131 } 6132 } 6866 if ( @cuales_transferir == 0 ) { 6867 log_debug( "** !! REVERSE TRANSFER No reverse available, using regular sesbot to find the linked channels", 16 ) if DEBUG; 6868 if ( $sesbot{$datosflash} ) { 6869 if ( @{ $sesbot{$datosflash} } ) { 6870 @cuales_transferir = extraer_todos_los_enlaces_de_un_canal( $cuales_transferir[0], $button_server{$datosflash} ); 6871 } 6872 } 6873 } 6133 6874 } 6134 6875 else { … … 6136 6877 6137 6878 # Transfer the session from the same button 6138 if ( @{ $sesbot{$datosflash} } ) { 6139 @cuales_transferir = @{ $sesbot{$datosflash} }; 6879 if ( $sesbot{$datosflash} ) { 6880 if ( @{ $sesbot{$datosflash} } ) { 6881 @cuales_transferir = @{ $sesbot{$datosflash} }; 6882 } 6883 else { 6884 @cuales_transferir = (); 6885 } 6140 6886 } 6141 6887 else { … … 6260 7006 sends_version($socket); 6261 7007 6262 # send_initial_status();6263 7008 first_client_status($socket); 6264 7009 $tab = substr( $tab, 0, -1 ) if DEBUG; … … 6408 7153 log_debug( "$heading origin_channel = $origin_channel", 64 ) if DEBUG; 6409 7154 7155 my $no_security_code = ""; 6410 7156 if ( defined( $config->{$panelcontext}{security_code} ) ) { 6411 7157 $myclave = $config->{$panelcontext}{security_code} . $keys_socket{$socket}; 6412 7158 log_debug( "$heading usando key " . $keys_socket{$socket}, 16 ) if DEBUG; 7159 $no_security_code = $config->{$panelcontext}{security_code}; 6413 7160 } 6414 7161 else { … … 6416 7163 $myclave = $config->{GENERAL}{security_code} . $keys_socket{$socket}; 6417 7164 log_debug( "$heading usando key " . $keys_socket{$socket}, 16 ) if DEBUG; 7165 $no_security_code = $config->{GENERAL}{security_code}; 6418 7166 } 6419 7167 … … 6423 7171 6424 7172 if ( ( "$password" eq "$md5clave" ) 6425 || ( $accion =~ /^dial/ && $cdial_nosecure == 1 ) ) 7173 || ( $accion =~ /^dial/ && $cdial_nosecure == 1 ) 7174 || ( $no_security_code eq "" ) ) 6426 7175 { 6427 7176 sends_correct($socket); … … 6501 7250 if ( $accion =~ /^tovoicemail/ ) { 6502 7251 6503 my $keyext = "$origin_server^$origin_channel";6504 my $exttran = $tovoicemail{$btn_destino};6505 my ( $extx, $contextx ) = split( /\@/, $exttran, 2 );6506 6507 7252 my @cuales_transferir = get_transfer_channel( $origin_channel, $datosflash ); 6508 my $cuantos = @cuales_transferir; 6509 6510 if ( $cuantos > 0 ) { 6511 $comando = "Action: Redirect\r\n"; 6512 $comando .= "Channel: $cuales_transferir[0]\r\n"; 6513 $comando .= "Exten: $extx\r\n"; 6514 $comando .= "ActionID: 1234\r\n"; 6515 $comando .= "Context: $contextx\r\n"; 6516 $comando .= "Priority: 1\r\n\r\n"; 7253 my $cuantos = @cuales_transferir; 7254 7255 if ( !defined( $tovoicemail{$btn_destino} ) ) { 7256 7257 # If there is no voicemail extension defined, change it to a standard 7258 # trasnfer 7259 if ( $cuantos > 0 ) { 7260 $accion = "transferir"; 7261 } 7262 else { 7263 $accion = "originate"; 7264 } 6517 7265 } 6518 7266 else { 6519 $comando = "Action: Originate\r\n"; 6520 $comando .= "Channel: $origin_channel\r\n"; 6521 $comando .= "Exten: $extx\r\n"; 6522 $comando .= "ActionID: 1234\r\n"; 6523 $comando .= "Context: $contextx\r\n"; 6524 $comando .= "Priority: 1\r\n\r\n"; 6525 } 6526 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 6527 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 6528 6529 return; 7267 7268 my $keyext = "$origin_server^$origin_channel"; 7269 my $exttran = $tovoicemail{$btn_destino}; 7270 my ( $extx, $contextx ) = split( /\@/, $exttran, 2 ); 7271 7272 if ( $cuantos > 0 ) { 7273 $comando = "Action: Redirect\r\n"; 7274 $comando .= "Channel: $cuales_transferir[0]\r\n"; 7275 $comando .= "Exten: $extx\r\n"; 7276 $comando .= "ActionID: 1234\r\n"; 7277 $comando .= "Context: $contextx\r\n"; 7278 $comando .= "Priority: 1\r\n\r\n"; 7279 } 7280 else { 7281 $comando = "Action: Originate\r\n"; 7282 $comando .= "Channel: $origin_channel\r\n"; 7283 $comando .= "Exten: $extx\r\n"; 7284 $comando .= "ActionID: 1234\r\n"; 7285 $comando .= "Context: $contextx\r\n"; 7286 $comando .= "Priority: 1\r\n\r\n"; 7287 } 7288 send_command_to_manager( $comando, $p[ $button_server{$datosflash} ], 7289 0, $astmanproxy_servers[ $button_server{$datosflash} ] ); 7290 7291 $tab = substr( $tab, 0, -1 ) if DEBUG; 7292 return; 7293 } 6530 7294 } 6531 7295 if ( $accion =~ /^voicemail/ ) { … … 6629 7393 0, $astmanproxy_servers[ $button_server{$boton_con_contexto} ] ); 6630 7394 } 7395 6631 7396 elsif ( $accion =~ /^conference/ ) { 6632 7397 log_debug( "$heading CONFERENCE extension_transfer($origin_channel)", 1 ) if DEBUG; … … 6647 7412 log_debug( "$heading coincidencia para btn_destino $btn_destino el canal es $canal", 1 ) 6648 7413 if DEBUG; 6649 my @links = extraer_todos_los_enlaces_de_un_canal( $canal, $button_server{$datosflash} ); 6650 7414 my @links = extraer_todos_los_enlaces_de_un_canal( $canal, $button_server{$datosflash} ); 6651 7415 my @canal_transferir = @{ $sesbot{$btn_destino} }; 6652 7416 … … 6684 7448 $comando .= "Context: $conference_context\r\n"; 6685 7449 $comando .= "Priority: 1\r\n\r\n"; 6686 $auto_conference{ $canal_transferir[0] } = $origin_channel; 7450 7451 if ( defined( $config->{$panelcontext}{'attendant_hold_extension'} ) ) { 7452 $attendant_transfer{ $canal_transferir[0] } = $origin_channel; 7453 $mute_other{ $canal_transferir[0] } = $links[0]; 7454 $attendant_pending{ $canal_transferir[0] } = $empty_room . "@" . $conference_context; 7455 } 7456 else { 7457 $auto_conference{ $canal_transferir[0] } = $origin_channel; 7458 } 6687 7459 } 6688 7460 else { … … 6698 7470 } 6699 7471 elsif ( $accion =~ /transferir/ ) { 6700 6701 7472 if ( $accion =~ /^ctransferir/ ) { 6702 7473 … … 6790 7561 6791 7562 my $member = 0; 6792 while ( my ( $key, $val ) = each(% count_queue) ) {7563 while ( my ( $key, $val ) = each(%agents_available_on_queue) ) { 6793 7564 if ( $key eq "$button_server{$datosflash}^$destino" ) { 6794 7565 foreach my $qmember (@$val) { … … 6954 7725 my $canalito = $2; 6955 7726 if ( $canalito !~ m/^_/ && $nro_servidor == $servidor && $canalito !~ m/=/ ) { 6956 my $comando = "Action: Command\r\n"; 6957 $comando .= "ActionID: astdb-$key-$canalito\r\n"; 6958 $comando .= "Command: database get $key $canalito\r\n\r\n"; 6959 if ( defined( $autenticado{$socket} ) ) { 6960 if ( $autenticado{$socket} == 1 ) { 6961 send_command_to_manager( $comando, $socket ); 7727 if ( defined( $buttons_astdbkey{$canal} ) ) { 7728 my $astdbkey = $buttons_astdbkey{$canal}; 7729 my $comando = "Action: Command\r\n"; 7730 $comando .= "ActionID: astdb-$key-$canalito\r\n"; 7731 $comando .= "Command: database get $key $astdbkey\r\n\r\n"; 7732 if ( defined( $autenticado{$socket} ) ) { 7733 if ( $autenticado{$socket} == 1 ) { 7734 send_command_to_manager( $comando, $socket ); 7735 } 6962 7736 } 6963 7737 } … … 6999 7773 foreach my $socket2 (@todos) { 7000 7774 if ( defined($socket2) && $socket2 ne "" ) { 7775 7001 7776 if ( $showagents == 1 ) { 7002 7777 send_command_to_manager( "Action: Command\r\nActionId: agents\r\nCommand: show agents\r\n\r\n", $socket2 ); … … 7016 7791 send_command_to_manager( "Action: QueueStatus\r\nActionID: QueueStatus\r\n", $socket2 ); 7017 7792 } 7018 7019 # if($showagents==1) {7020 # send_command_to_manager( "Action: Command\r\nActionId: agents\r\nCommand: show agents\r\n\r\n", $socket2 );7021 # }7022 7793 } 7023 7794 } … … 7047 7818 if ( $botonled{$interno} == 1 ) { 7048 7819 send_status_to_flash( $socket, "$interno|changelabel1|$botonlabel{$interno}", 0 ); 7820 } 7821 } 7822 for $interno ( keys %botonledcolor ) { 7823 if ( $botonledcolor{$interno} ne "" ) { 7824 send_status_to_flash( $socket, "$interno|fopledcolor|$botonledcolor{$interno}", 0 ); 7825 if ( $estadoboton{$interno} =~ /^free/ || $estadoboton{$interno} eq "" ) { 7826 send_status_to_flash( $socket, "$interno|state|free", 0 ); 7827 } 7049 7828 } 7050 7829 } … … 7087 7866 } 7088 7867 } 7868 7869 if ( keys(%boton_paused) ) { 7870 for $interno ( keys %boton_paused ) { 7871 send_status_to_flash( $socket, "$interno|paused|$boton_paused{$interno}", 0 ); 7872 } 7873 } 7874 if ( keys(%boton_agentpaused) ) { 7875 for $interno ( keys %boton_agentready ) { 7876 send_status_to_flash( $socket, "$interno|agents_paused|$boton_agentpaused{$interno}", 0 ); 7877 } 7878 } 7879 if ( keys(%boton_agentready) ) { 7880 for $interno ( keys %boton_agentready ) { 7881 send_status_to_flash( $socket, "$interno|agents_ready|$boton_agentready{$interno}", 0 ); 7882 } 7883 } 7884 if ( keys(%boton_agentbusy) ) { 7885 for $interno ( keys %boton_agentbusy ) { 7886 send_status_to_flash( $socket, "$interno|agents_busy|$boton_agentbusy{$interno}", 0 ); 7887 } 7888 } 7889 if ( keys(%boton_agentlogedof) ) { 7890 for $interno ( keys %boton_agentlogedof ) { 7891 send_status_to_flash( $socket, "$interno|agents_logedof|$boton_agentlogedof{$interno}", 0 ); 7892 } 7893 } 7894 7089 7895 if ( keys(%botonpark) ) { 7090 7896 for $interno ( keys %botonpark ) { … … 7098 7904 } 7099 7905 } 7906 if ( keys(%botonpermanenttext) ) { 7907 for $interno ( keys %botonpermanenttext ) { 7908 if ( $botonpermanenttext{$interno} ne "" ) { 7909 print "permanente $interno -$botonpermanenttext{$interno}-\n"; 7910 send_status_to_flash( $socket, "$interno|settext|$botonpermanenttext{$interno}", 0 ); 7911 } 7912 } 7913 } 7100 7914 for $interno ( keys %estadoboton ) { 7101 7915 7102 #if ( $estadoboton{$interno} !~ /^free/ ) {7103 7916 if ( $estadoboton{$interno} =~ /^busy/ ) { 7104 7917 send_status_to_flash( $socket, "$interno|state|busy", 0 ); … … 7111 7924 } 7112 7925 if ( defined( $botonclid{$interno} ) ) { 7926 my $texti = ""; 7113 7927 if ( $botonclid{$interno} ne "" ) { 7114 7928 send_status_to_flash( $socket, "$interno|settext|$botonclid{$interno}", 0 ); … … 7116 7930 } 7117 7931 7118 #}7119 7932 } 7120 7933 if ( keys(%botonlinked) ) { … … 7174 7987 my $heading = "** SEND INITIAL STATUS"; 7175 7988 my $cual = shift; 7989 my $skip_autosip = shift; 7176 7990 my @socket_manager; 7177 7991 7178 if ( defined($cual) ) { 7992 if ( !defined($skip_autosip) ) { $skip_autosip = 0; } 7993 7994 if ( defined($cual) && $cual ne "" ) { 7179 7995 push @socket_manager, $cual; 7180 7996 } … … 7184 8000 7185 8001 log_debug( "$heading START SUB", 16 ) if DEBUG; 7186 7187 request_astdb_status();7188 8002 7189 8003 foreach my $socket (@socket_manager) { … … 7209 8023 send_command_to_manager( "Action: ZapShowChannels\r\n\r\n", $socket ); 7210 8024 8025 if ( $skip_autosip == 0 ) { 8026 send_command_to_manager( "Action: SIPPeers\r\nActionID: autosip\r\n\r\n", $socket ); 8027 } 8028 7211 8029 send_command_to_manager( "Action: Command\r\nActionID: parkedcalls\r\nCommand: show parkedcalls\r\n\r\n", $socket ); 7212 8030 … … 7265 8083 } 7266 8084 } 8085 request_astdb_status(); 7267 8086 alarm(2); 7268 8087 } … … 7351 8170 $agent_state = $3; 7352 8171 $agents_name{"$server^$agent_number"} = $agent_name; 8172 set_queueobject( $server, "AGENT/$agent_number", "name", $agent_name ); 7353 8173 } 7354 8174 … … 7966 8786 my $maxtime = 0; 7967 8787 8788 print_recomputequeues(); 8789 7968 8790 my $header = "**RECOMP QUEUE"; 7969 8791 log_debug( "$header canalid $canalid", 1 ) if DEBUG; … … 7994 8816 7995 8817 foreach my $id ( keys %{$cola} ) { 8818 if ( !defined( $cola->{$id}{QUEUE} ) ) { 8819 delete( $cola->{$id} ); 8820 next; 8821 } 8822 8823 #foreach ( keys %{ $cola->{$id} } ) { 8824 # print "key de cola $_\n"; 8825 #} 7996 8826 if ( $queue_to_recompute eq $cola->{$id}{QUEUE} ) { 7997 8827 $save_id = $id; … … 8047 8877 } 8048 8878 8879 # Remove the item from the hash, recompute_queues is only called 8880 # from the Leave event 8881 8882 delete $cola->{$canalid}; 8049 8883 @return_ocupado = unique(@return_ocupado); 8050 8884 … … 8151 8985 8152 8986 my $numero = shift; 8987 my $name = shift; 8153 8988 my $format = shift; 8154 8989 my @chars_number = (); … … 8157 8992 my $devuelve = ""; 8158 8993 8994 if ( $name eq "<unknown>" ) { $name = ""; } 8995 8159 8996 if ( !is_number($numero) ) { 8160 8997 return $numero; … … 8196 9033 @result = reverse @result; 8197 9034 $devuelve = join( "", @result ); 9035 $devuelve =~ s/\${CLIDNAME}/$name/gi; 8198 9036 return $devuelve; 8199 9037 } … … 8244 9082 my $randomkey = generate_random_password($keylen); 8245 9083 my $mandakey = "$randomkey|key|0"; 8246 if ( !$keys_socket{ "$socket"} ) {9084 if ( !$keys_socket{$socket} ) { 8247 9085 $nocrypt = 1; 8248 9086 } … … 8251 9089 } 8252 9090 send_status_to_flash( $socket, $mandakey, $nocrypt ); 9091 } 9092 9093 sub sends_reload { 9094 my $socket = shift; 9095 my $nocrypt = 0; 9096 my $contexto = $flash_contexto{$socket}; 9097 my $boton = "0"; 9098 if ( $contexto ne "" ) { 9099 $boton .= "\@$contexto"; 9100 } 9101 9102 if ( !$keys_socket{$socket} ) { 9103 print "nocrypt = 1\n"; 9104 $nocrypt = 1; 9105 } 9106 my $mensaje = "<response btn=\"0\" cmd=\"reload\" data=\"0\"/>\0"; 9107 log_debug( "Sending reload to flash client at " . $ip_addy{$socket}, 1 ) if DEBUG; 9108 push( @{ $client_queue_nocrypt{$socket} }, $mensaje ); 9109 push( @{ $client_queue{$socket} }, $mensaje ); 8253 9110 } 8254 9111 … … 8860 9717 # End TEA 8861 9718 9719 sub print_recomputequeues { 9720 9721 foreach my $paso1 ( keys %{$cola} ) { 9722 print "-----------------\n"; 9723 foreach my $it ( keys %{ $cola->{$paso1} } ) { 9724 print "cola($paso1)($it) = " . $cola->{$paso1}{$it} . "\n"; 9725 } 9726 } 9727 } 9728 8862 9729 sub print_agentonqueue { 8863 9730 my $valor = shift; … … 8874 9741 sub print_countqueue { 8875 9742 my $valor = shift; 8876 if ( keys(% count_queue) ) {8877 foreach my $valor ( sort ( keys(% count_queue) ) ) {8878 foreach my $vvalor ( @{ $ count_queue{$valor} } ) {8879 log_debug( "\t| count_queue{$valor} = $vvalor", 32 ) if DEBUG;9743 if ( keys(%agents_available_on_queue) ) { 9744 foreach my $valor ( sort ( keys(%agents_available_on_queue) ) ) { 9745 foreach my $vvalor ( @{ $agents_available_on_queue{$valor} } ) { 9746 log_debug( "\t| agents_available_on_queue{$valor} = $vvalor", 32 ) if DEBUG; 8880 9747 } 8881 9748 } … … 9006 9873 } 9007 9874 9875 sub add_queueobject { 9876 my $server = shift; 9877 my $queue = shift; 9878 my $agent = shift; 9879 9880 my @return; 9881 9882 print "add queueobject $server $queue $agent\n"; 9883 $queue_object->{$server}{$queue}{$agent}{status} = 1; 9884 @return = compute_queueobject($server); 9885 return @return; 9886 } 9887 9888 sub delete_queueobject { 9889 my $server = shift; 9890 my $queue = shift; 9891 my $agent = shift; 9892 9893 my @return; 9894 9895 print "delete queueobject $server $queue $agent\n"; 9896 delete( $queue_object->{$server}{$queue}{$agent} ); 9897 @return = compute_queueobject($server); 9898 return @return; 9899 } 9900 9901 sub set_queueobject { 9902 my $server = shift; 9903 my $agent = shift; 9904 my $property = shift; 9905 my $value = shift; 9906 9907 my @return; 9908 9909 foreach my $val ($queue_object) { 9910 foreach my $iserver ( keys %{$val} ) { 9911 if ( $server eq $iserver ) { 9912 foreach my $iqueue ( keys %{ $queue_object->{$iserver} } ) { 9913 foreach my $iagent ( keys %{ $queue_object->{$iserver}{$iqueue} } ) { 9914 if ( $iagent eq $agent ) { 9915 $queue_object->{$iserver}{$iqueue}{$iagent}{$property} = $value; 9916 print "property set!\n"; 9917 } 9918 } 9919 } 9920 } 9921 } 9922 } 9923 @return = compute_queueobject($server); 9924 return @return; 9925 } 9926 9927 sub compute_queueobject { 9928 my $server = shift; 9929 9930 my $head = "** compute queueboject: "; 9931 log_debug( "$head", 16 ); 9932 9933 my $queueagent_counter = {}; 9934 my @return; 9935 my $canalid; 9936 my $ready; 9937 my $busy; 9938 my $logedof; 9939 my $paused; 9940 9941 if ( !defined($server) ) { $server = -1; } 9942 foreach my $val ($queue_object) { 9943 foreach my $iserver ( keys %{$val} ) { 9944 if ( $server eq $iserver || $server == -1 ) { 9945 foreach my $iqueue ( keys %{ $queue_object->{$iserver} } ) { 9946 $queueagent_counter->{$iserver}->{$iqueue}->{ready} = 0; 9947 $queueagent_counter->{$iserver}->{$iqueue}->{logedof} = 0; 9948 $queueagent_counter->{$iserver}->{$iqueue}->{busy} = 0; 9949 $queueagent_counter->{$iserver}->{$iqueue}->{paused} = 0; 9950 foreach my $iagent ( keys %{ $queue_object->{$iserver}{$iqueue} } ) { 9951 if ( $queue_object->{$iserver}{$iqueue}{$iagent}{paused} > 0 ) { 9952 $queueagent_counter->{$iserver}->{$iqueue}->{paused}++; 9953 } 9954 if ( $queue_object->{$iserver}{$iqueue}{$iagent}{status} == 1 ) { 9955 $queueagent_counter->{$iserver}->{$iqueue}->{ready}++; 9956 } 9957 elsif ( $queue_object->{$iserver}{$iqueue}{$iagent}{status} == 5 ) { 9958 $queueagent_counter->{$iserver}->{$iqueue}->{logedof}++; 9959 } 9960 elsif ($queue_object->{$iserver}{$iqueue}{$iagent}{status} == 2 9961 || $queue_object->{$iserver}{$iqueue}{$iagent}{status} == 3 9962 || $queue_object->{$iserver}{$iqueue}{$iagent}{status} == 6 ) 9963 { 9964 $queueagent_counter->{$iserver}->{$iqueue}->{busy}++; 9965 } 9966 } 9967 $canalid = "QUEUE/$iqueue-XXXX"; 9968 $ready = $queueagent_counter->{$server}->{$iqueue}{ready}; 9969 $busy = $queueagent_counter->{$server}->{$iqueue}{busy}; 9970 $logedof = $queueagent_counter->{$server}->{$iqueue}{logedof}; 9971 $paused = $queueagent_counter->{$server}->{$iqueue}{paused}; 9972 9973 push @return, "QUEUE/$iqueue|agents_ready|$ready|$canalid-$server|$canalid"; 9974 push @return, "QUEUE/$iqueue|agents_busy|$busy|$canalid-$server|$canalid"; 9975 push @return, "QUEUE/$iqueue|agents_logedof|$logedof|$canalid-$server|$canalid"; 9976 push @return, "QUEUE/$iqueue|agents_paused|$paused|$canalid-$server|$canalid"; 9977 9978 } 9979 } 9980 } 9981 } 9982 return @return; 9983 } 9984 9008 9985 sub print_cola_write { 9009 9986 my $socket = shift; … … 9013 9990 foreach my $val ( @{ $client_queue{$_} } ) { 9014 9991 $contame++; 9015 print "cola $contame $_ comando $val\n";9016 9992 } 9017 9993 } … … 9021 9997 foreach my $val ( @{ $client_queue{$socket} } ) { 9022 9998 $contame++; 9023 print "cola $contame $socket comando $val\n";9024 9999 } 9025 10000 } … … 9088 10063 } 9089 10064 } 9090 if ( keys(% count_queue) ) {10065 if ( keys(%agents_available_on_queue) ) { 9091 10066 print "Count on queue: \n"; 9092 foreach my $valor ( sort ( keys(%count_queue) ) ) { 9093 print "count_queue{$valor} = $count_queue{$valor}\n"; 10067 foreach my $valor ( sort ( keys(%agents_available_on_queue) ) ) { 10068 foreach ( @{ $agents_available_on_queue{$valor} } ) { 10069 print "agents_available_on_queue{$valor} = $_\n"; 10070 } 9094 10071 } 9095 10072 } … … 9183 10160 =head1 DESCRIPTION 9184 10161 9185 B<This program> will read the given input file(s) and do someting useful with the contents thereof. 10162 B<This program> is a proxy server for the Flash Operator Panel. It reads configuration files and updates the data to display on the panel. 10163 10164 =head1 FILES 10165 10166 =over 8 10167 10168 =item B</etc/op-panel> 10169 10170 The configuration files of the operator panel daemon reside in that directory 10171 (may differ on other distributions). Those include: 10172 10173 =item B<op_server.cfg> 10174 10175 The server's configuration file. See remarks in file for documentation. 10176 10177 =item B<op_buttons.cfg> 10178 10179 Defines the layout of the operator panel, and also which phones to track. 10180 10181 =item B</var/log/op-panel/output.log> 10182 10183 The standard output of the daemon, including debugging prints and dumps. 10184 10185 =item B</var/log/op-panel/error.log> 10186 10187 The standard error of the daemon. Should normally be empty. 9186 10188 9187 10189 =cut
