Changeset 51

Show
Ignore:
Timestamp:
08/02/07 16:04:07 (1 year ago)
Author:
root
Message:

no_label_counter in op_buttons.cfg (prevents counting on multiple position labels). Fixes on groupcount. Added count to op_buttons.cfg to set number of sessions for group_count buttons

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/op_server.pl

    r50 r51  
    3535use POSIX qw(setsid EWOULDBLOCK); 
    3636 
    37 my $FOP_VERSION    = "SVNVERSION"; 
     37my $FOP_VERSION    = "027.001"; 
    3838my %datos          = (); 
    3939my %chanvar        = (); 
     
    192192my $queue_hide; 
    193193my $enable_restart; 
    194 my $passvars
     194my $passvars = ""
    195195my $change_led; 
    196196my $cdial_nosecure; 
     
    675675    } 
    676676 
     677    if ( !defined $passvars ) { 
     678        $passvars = ""; 
     679    } 
     680 
    677681    if ( !defined $debuglevel ) { 
    678682        $debuglevel = 0; 
     
    11851189            my $pos = $tmphash{position}; 
    11861190            $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 ); 
    11881201            $no_counter = 1; 
    11891202        } 
     
    12501263                $buttons{ uc("$tmphash{server}^$chan_trunk") } = $pos; 
    12511264                $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) { 
    12531267                    $textos{$indice_contexto} .= " " . $count; 
    12541268                } 
     
    19441958    my $canal  = $1; 
    19451959    my $sesion = $2; 
    1946     log_debug( "$heading canal $canal sesion $sesion", 32 ) if DEBUG; 
    19471960 
    19481961    if ( defined($canal) && defined($sesion) ) { 
    19491962        $canal =~ tr/a-z/A-Z/; 
    19501963        $elemento = $canal . "\t" . $sesion; 
     1964        log_debug( "$heading canal $canal sesion $sesion", 32 ) if DEBUG; 
    19511965    } 
    19521966    $elemento =~ s/IAX2\[(.*)@(.*)\]\t(.*)/IAX2\[$1\]\t$3/; 
     
    32343248        $estado_final = "ringing"; 
    32353249        $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/; 
    32373253        $canalid  = $canal . "-XXXX"; 
    32383254        $clidnum  = $hash_temporal{"CallerID"}; 
     
    32413257        my $base64_clidnum  = encode_base64( $clidnum . " " ); 
    32423258        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        } 
    32433266        push @return, "$canal|clidnum|$base64_clidnum|$canalid-$server|$canalid"; 
    32443267        push @return, "$canal|clidname|$base64_clidname|$canalid-$server|$canalid"; 
     
    47544777            my $hay_activos = 0; 
    47554778 
    4756             for ( keys %datos ) { 
     4779            foreach my $dkey ( keys %datos ) { 
    47574780                my $ignorame = 0; 
    4758                 my ($current_server) = split( /-/, $_ ); 
     4781                my (undef, $current_server) = split( /-/, $dkey ); 
    47594782                if ( "$server" ne "$current_server" ) { 
    47604783                    next; 
    47614784                } 
    47624785 
    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
    47654788                my $myevent = "Newexten"; 
    4766                 while ( my ( $key, $val ) = each( %{ $datos{$_} } ) ) { 
     4789                while ( my ( $key, $val ) = each( %{ $datos{$dkey} } ) ) { 
    47674790                    log_debug( "$heading STATUSCOMPLETE datos { $key } = $val", 128 ) if DEBUG; 
    4768  
    47694791                    if ( defined($val) ) { 
    47704792                        $hay_activos = 1; 
     
    58725894                                    } 
    58735895                                } 
    5874  
    58755896                                if ( $quehace eq "ringing" ) { 
    58765897                                    if ( $laststatus{$interno} ne "ringing|${buttontext}" ) { 
     
    58945915 
    58955916                                } 
    5896                                 elsif ( $quehace =~ /^ocupado/ ) { 
     5917                                elsif ( $quehace =~ /^ocupado/ || $quehace eq 'ring' ) { 
    58975918 
    58985919                                    if ( defined( $group_count{$interno} ) ) { 
    5899                                         my $plural = ""; 
    59005920                                        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; 
    59115923                                        } 
    59125924                                    } 
     
    60646076                            $calleridpop =~ s/\s+//g; 
    60656077                            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                            } 
    60666082                        } 
    60676083 
     
    60866102 
    60876103                        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                            } 
    60906111                        } 
    60916112                        else { 
     
    60956116                                $canalsincontexto =~ s/(.*)&(.*)/$1/g; 
    60966117                                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                                } 
    60976124                            } 
    60986125 
     
    61606187                                    else { 
    61616188                                        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                                            } 
    61646196                                        } 
    61656197                                    } 
     
    61686200 
    61696201                            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; 
    61736206                                } 
    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                                } 
    61776216                            } 
    61786217                            if ( $quehace2 eq "settimer" ) { 
    6179                                 my $tiempo     = $dos; 
     6218                                my $tiempo     = defined $dos; 
    61806219                                my $timer_type = ""; 
    61816220                                if ( $tiempo =~ /\@/ ) { 
    61826221                                    ( $tiempo, $timer_type ) = split( /\@/, $tiempo ); 
    61836222                                } 
     6223 
     6224                                if ( $tiempo eq "" ) { $tiempo = 0; } 
     6225 
    61846226                                if ( $timer_type ne "" ) { 
    61856227                                    $botontimertype{$interno} = $timer_type; 
     
    63436385    $tab = substr( $tab, 0, -1 ) if DEBUG; 
    63446386    return @respuestas; 
     6387} 
     6388 
     6389sub 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; 
    63456407} 
    63466408 
     
    72557317        if ( defined( $buttons{$indice} ) ) { 
    72567318            $btn_num = $buttons{$indice}; 
     7319 
    72577320            # $btn_num =~ s/(.*)\@(.*)/$1/g; 
    72587321        } 
     
    91069169 
    91079170    my $numero       = shift; 
    9108     my $name         = shift; 
    9109     my $format       = shift; 
     9171    my $name         = defined shift; 
     9172    my $format       = defined shift; 
    91109173    my @chars_number = (); 
    91119174    my @chars_format = ();