Changeset 51
- Timestamp:
- 08/02/07 16:04:07 (1 year ago)
- Files:
-
- trunk/op_server.pl (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/op_server.pl
r50 r51 35 35 use POSIX qw(setsid EWOULDBLOCK); 36 36 37 my $FOP_VERSION = " SVNVERSION";37 my $FOP_VERSION = "027.001"; 38 38 my %datos = (); 39 39 my %chanvar = (); … … 192 192 my $queue_hide; 193 193 my $enable_restart; 194 my $passvars ;194 my $passvars = ""; 195 195 my $change_led; 196 196 my $cdial_nosecure; … … 675 675 } 676 676 677 if ( !defined $passvars ) { 678 $passvars = ""; 679 } 680 677 681 if ( !defined $debuglevel ) { 678 682 $debuglevel = 0; … … 1185 1189 my $pos = $tmphash{position}; 1186 1190 $pos =~ s/(\d+),(\d+)/$1/g; 1187 $tmphash{position} = "$pos,$pos"; 1191 my $countpos = 2; 1192 $tmphash{position} = ""; 1193 if ( defined( $tmphash{count} ) ) { 1194 $countpos = $tmphash{count}; 1195 } 1196 my $a = 0; 1197 for ( $a = 0 ; $a < $countpos ; $a++ ) { 1198 $tmphash{position} .= "$pos,"; 1199 } 1200 $tmphash{position} = substr( $tmphash{position}, 0, -1 ); 1188 1201 $no_counter = 1; 1189 1202 } … … 1250 1263 $buttons{ uc("$tmphash{server}^$chan_trunk") } = $pos; 1251 1264 $textos{$indice_contexto} = $tmphash{label}; 1252 if ( $no_counter == 0 ) { 1265 if(!defined($tmphash{no_label_counter})) { $tmphash{no_label_counter} = 0; } 1266 if ( $no_counter == 0 && $tmphash{no_label_counter}==0) { 1253 1267 $textos{$indice_contexto} .= " " . $count; 1254 1268 } … … 1944 1958 my $canal = $1; 1945 1959 my $sesion = $2; 1946 log_debug( "$heading canal $canal sesion $sesion", 32 ) if DEBUG;1947 1960 1948 1961 if ( defined($canal) && defined($sesion) ) { 1949 1962 $canal =~ tr/a-z/A-Z/; 1950 1963 $elemento = $canal . "\t" . $sesion; 1964 log_debug( "$heading canal $canal sesion $sesion", 32 ) if DEBUG; 1951 1965 } 1952 1966 $elemento =~ s/IAX2\[(.*)@(.*)\]\t(.*)/IAX2\[$1\]\t$3/; … … 3234 3248 $estado_final = "ringing"; 3235 3249 $canal = $hash_temporal{"AgentCalled"}; 3236 $canal =~ tr/a-z/A-Z/; 3250 my $unique = find_uniqueid( $hash_temporal{ChannelCalling}, $server ); 3251 $unique =~ s/(.*)-.*/$1/g; 3252 $canal =~ tr/a-z/A-Z/; 3237 3253 $canalid = $canal . "-XXXX"; 3238 3254 $clidnum = $hash_temporal{"CallerID"}; … … 3241 3257 my $base64_clidnum = encode_base64( $clidnum . " " ); 3242 3258 my $base64_clidname = encode_base64( $clidname . " " ); 3259 3260 foreach my $var ( split( /\|/, $passvars ) ) { 3261 if ( defined( $chanvar{$unique}{$var} ) ) { 3262 my $base64_var = encode_base64( $chanvar{$unique}{$var} ); 3263 push @return, "$canal|setvar|$var=$base64_var|$canalid-$server|$canalid"; 3264 } 3265 } 3243 3266 push @return, "$canal|clidnum|$base64_clidnum|$canalid-$server|$canalid"; 3244 3267 push @return, "$canal|clidname|$base64_clidname|$canalid-$server|$canalid"; … … 4754 4777 my $hay_activos = 0; 4755 4778 4756 for ( keys %datos ) {4779 foreach my $dkey ( keys %datos ) { 4757 4780 my $ignorame = 0; 4758 my ( $current_server) = split( /-/, $_);4781 my (undef, $current_server) = split( /-/, $dkey ); 4759 4782 if ( "$server" ne "$current_server" ) { 4760 4783 next; 4761 4784 } 4762 4785 4763 log_debug( "$heading STATUSCOMPLETE datos { $ _}", 128 ) if DEBUG;4764 push @ids, $ _;4786 log_debug( "$heading STATUSCOMPLETE datos { $dkey }", 128 ) if DEBUG; 4787 push @ids, $dkey; 4765 4788 my $myevent = "Newexten"; 4766 while ( my ( $key, $val ) = each( %{ $datos{$ _} } ) ) {4789 while ( my ( $key, $val ) = each( %{ $datos{$dkey} } ) ) { 4767 4790 log_debug( "$heading STATUSCOMPLETE datos { $key } = $val", 128 ) if DEBUG; 4768 4769 4791 if ( defined($val) ) { 4770 4792 $hay_activos = 1; … … 5872 5894 } 5873 5895 } 5874 5875 5896 if ( $quehace eq "ringing" ) { 5876 5897 if ( $laststatus{$interno} ne "ringing|${buttontext}" ) { … … 5894 5915 5895 5916 } 5896 elsif ( $quehace =~ /^ocupado/ ) {5917 elsif ( $quehace =~ /^ocupado/ || $quehace eq 'ring' ) { 5897 5918 5898 5919 if ( defined( $group_count{$interno} ) ) { 5899 my $plural = "";5900 5920 if ( $group_count{$interno} == 1 ) { 5901 if ( @{ $sesbot{$interno} } > 1 ) { 5902 $plural = "s"; 5903 } 5904 if ( @{ $sesbot{$interno} } > 0 ) { 5905 my $cuantos = @{ $sesbot{$interno} }; 5906 my ( $text, $textriginal, $buttontext ) = 5907 translate( $canal, "&channels,$cuantos,$plural", "", "" ); 5908 $buttontext = $text; 5909 $dos = "[" . $buttontext . "]"; 5910 } 5921 $buttontext = group_count($interno,$canal); 5922 push @respuestas, $buttontext; 5911 5923 } 5912 5924 } … … 6064 6076 $calleridpop =~ s/\s+//g; 6065 6077 push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|$calleridpop"; 6078 if ( defined( $group_count{$interno} ) && $group_count{$interno} == 1 ) { 6079 # Ignore ringing because of groupcount 6080 $quehace = ""; 6081 } 6066 6082 } 6067 6083 … … 6086 6102 6087 6103 if ( @{ $sesbot{$interno} } > 0 && $quehace eq 'corto' ) { 6088 log_debug( "$heading Still busy...sesbot($interno) is not empty, ignoring hangup", 256 ) 6089 if DEBUG; 6104 log_debug( "$heading Still busy...sesbot($interno) is not empty, ignore hangup", 256 ) if DEBUG; 6105 if ( defined( $group_count{$interno} ) ) { 6106 if ( $group_count{$interno} == 1 ) { 6107 $buttontext = group_count($interno,$canal); 6108 push @respuestas, $buttontext; 6109 } 6110 } 6090 6111 } 6091 6112 else { … … 6095 6116 $canalsincontexto =~ s/(.*)&(.*)/$1/g; 6096 6117 push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|corto!"; 6118 if ( defined( $group_count{$interno} ) ) { 6119 if ( $group_count{$interno} == 1 ) { 6120 $buttontext = group_count($interno,$canal); 6121 push @respuestas, $buttontext; 6122 } 6123 } 6097 6124 } 6098 6125 … … 6160 6187 else { 6161 6188 if ( $quehace2 ne "" ) { 6162 push @respuestas, "$interno|$quehace2|$dos"; 6163 log_debug( "$heading pushing respuestas $interno|$quehace2|$dos", 256 ) if DEBUG; 6189 if ( defined( $group_count{$interno} ) && $group_count{$interno} == 1 ) { 6190 $dos = ""; 6191 } 6192 else { 6193 push @respuestas, "$interno|$quehace2|$dos"; 6194 log_debug( "$heading pushing respuestas $interno|$quehace2|$dos", 256 ) if DEBUG; 6195 } 6164 6196 } 6165 6197 } … … 6168 6200 6169 6201 if ( $quehace2 =~ /ocupado/ ) { 6170 if ( $dos =~ m/(.*)?\[(.*)\].*?/ ) { 6171 my $clidtext = $2; 6172 $botonclid{$interno} = $clidtext; 6202 if ( defined( $group_count{$interno} ) && $group_count{$interno} == 1 ) { 6203 $cambiaron{$interno} = 0; 6204 $quehace2 = ""; 6205 next; 6173 6206 } 6174 6175 #push @mensajefinal, "$interno|state|busy"; 6176 push @mensajefinal, "$interno|settimer|0\@UP"; 6207 else { 6208 if ( $dos =~ m/(.*)?\[(.*)\].*?/ ) { 6209 my $clidtext = $2; 6210 $botonclid{$interno} = $clidtext; 6211 } 6212 6213 #push @mensajefinal, "$interno|state|busy"; 6214 push @mensajefinal, "$interno|settimer|0\@UP"; 6215 } 6177 6216 } 6178 6217 if ( $quehace2 eq "settimer" ) { 6179 my $tiempo = $dos;6218 my $tiempo = defined $dos; 6180 6219 my $timer_type = ""; 6181 6220 if ( $tiempo =~ /\@/ ) { 6182 6221 ( $tiempo, $timer_type ) = split( /\@/, $tiempo ); 6183 6222 } 6223 6224 if ( $tiempo eq "" ) { $tiempo = 0; } 6225 6184 6226 if ( $timer_type ne "" ) { 6185 6227 $botontimertype{$interno} = $timer_type; … … 6343 6385 $tab = substr( $tab, 0, -1 ) if DEBUG; 6344 6386 return @respuestas; 6387 } 6388 6389 sub group_count { 6390 my $interno = shift; 6391 my $canal = shift; 6392 my $plural = ""; 6393 my $return = ""; 6394 if ( @{ $sesbot{$interno} } > 1 ) { 6395 $plural = "s"; 6396 } 6397 if ( @{ $sesbot{$interno} } > 0 ) { 6398 my $cuantos = @{ $sesbot{$interno} }; 6399 my ( $text, $textriginal, $buttontext ) = translate( $canal, "&channels,$cuantos,$plural", "", "" ); 6400 $return = "$interno|settext|$text"; 6401 $botonpermanenttext{$interno} = $text; 6402 } else { 6403 $botonpermanenttext{$interno} = ""; 6404 $return ="$interno|corto|"; 6405 } 6406 return $return; 6345 6407 } 6346 6408 … … 7255 7317 if ( defined( $buttons{$indice} ) ) { 7256 7318 $btn_num = $buttons{$indice}; 7319 7257 7320 # $btn_num =~ s/(.*)\@(.*)/$1/g; 7258 7321 } … … 9106 9169 9107 9170 my $numero = shift; 9108 my $name = shift;9109 my $format = shift;9171 my $name = defined shift; 9172 my $format = defined shift; 9110 9173 my @chars_number = (); 9111 9174 my @chars_format = ();
