Changeset 63

Show
Ignore:
Timestamp:
11/29/07 08:58:38 (1 year ago)
Author:
root
Message:

Make it work with asterisk 1.4 originateresponse change (for attendant transfers)

Files:

Legend:

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

    r62 r63  
    12641264                $buttons{ uc("$tmphash{server}^$chan_trunk") } = $pos; 
    12651265                $textos{$indice_contexto} = $tmphash{label}; 
    1266                 if(!defined($tmphash{no_label_counter})) { $tmphash{no_label_counter} = 0; } 
    1267                 if ( $no_counter == 0 && $tmphash{no_label_counter}==0) { 
     1266                if ( !defined( $tmphash{no_label_counter} ) ) { $tmphash{no_label_counter} = 0; } 
     1267                if ( $no_counter == 0 && $tmphash{no_label_counter} == 0 ) { 
    12681268                    $textos{$indice_contexto} .= " " . $count; 
    12691269                } 
     
    14301430            $tospy{$indicespy} = $tmphash{spyext}; 
    14311431        } 
    1432   
     1432 
    14331433        $/ = "\0"; 
    14341434    } 
     
    28992899        else { 
    29002900            log_debug( "$heading NO LLENO el global datos $unico_id", 64 ) if DEBUG; 
     2901        } 
     2902    } 
     2903 
     2904    # Convert Asterisk 1.4 Originate responses to 1.2 format so attendant transfers work 
     2905    if ( $evento eq "OriginateResponse" ) { 
     2906        if ( $hash_temporal{Response} eq "Success" ) { 
     2907            $evento = "OriginateSuccess"; 
     2908        } 
     2909        else { 
     2910            $evento = "OriginateFailure"; 
    29012911        } 
    29022912    } 
     
    41774187 
    41784188        push @return, "$canal|$estado_final|$texto|$unico_id|$canalid"; 
    4179         my @queue_events = recompute_queues_onjoin(\%hash_temporal,$server,$canalid); 
     4189        my @queue_events = recompute_queues_onjoin( \%hash_temporal, $server, $canalid ); 
    41804190        foreach my $valor (@queue_events) { 
    41814191            push @return, $valor; 
     
    47624772            foreach my $dkey ( keys %datos ) { 
    47634773                my $ignorame = 0; 
    4764                 my (undef, $current_server) = split( /-/, $dkey ); 
     4774                my ( undef, $current_server ) = split( /-/, $dkey ); 
    47654775                if ( "$server" ne "$current_server" ) { 
    47664776                    next; 
     
    51385148 
    51395149        if ( $state eq "Ring" ) { 
    5140             $texto                      = $canalid; 
    5141             $estado_final               = "ring"; 
     5150            $texto        = $canalid; 
     5151            $estado_final = "ring"; 
     5152 
    51425153            #$datos{$unico_id}{'Origin'} = "true"; 
    51435154            #log_debug( "$heading POPULATES datos($unico_id){ Origin } = true", 128 ) if DEBUG; 
     
    59025913                                    if ( defined( $group_count{$interno} ) ) { 
    59035914                                        if ( $group_count{$interno} == 1 ) { 
    5904                                                 $buttontext = group_count($interno,$canal); 
    5905                                                    push @respuestas, $buttontext; 
     5915                                            $buttontext = group_count( $interno, $canal ); 
     5916                                            push @respuestas, $buttontext; 
    59065917                                        } 
    59075918                                    } 
     
    60606071                            push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|$calleridpop"; 
    60616072                            if ( defined( $group_count{$interno} ) && $group_count{$interno} == 1 ) { 
     6073 
    60626074                                # Ignore ringing because of groupcount 
    60636075                                $quehace = ""; 
     
    60886100                            if ( defined( $group_count{$interno} ) ) { 
    60896101                                if ( $group_count{$interno} == 1 ) { 
    6090                                     $buttontext = group_count($interno,$canal); 
     6102                                    $buttontext = group_count( $interno, $canal ); 
    60916103                                    push @respuestas, $buttontext; 
    60926104                                } 
     
    61016113                                if ( defined( $group_count{$interno} ) ) { 
    61026114                                    if ( $group_count{$interno} == 1 ) { 
    6103                                         $buttontext = group_count($interno,$canal); 
     6115                                        $buttontext = group_count( $interno, $canal ); 
    61046116                                        push @respuestas, $buttontext; 
    61056117                                    } 
     
    61716183                                        if ( $quehace2 ne "" ) { 
    61726184                                            if ( defined( $group_count{$interno} ) && $group_count{$interno} == 1 ) { 
     6185 
    61736186                                                # $dos = ""; 
    61746187                                            } 
     
    61996212                            } 
    62006213                            if ( $quehace2 eq "settimer" ) { 
    6201                                 if ( !defined( $dos ) ) { $dos=1; } 
     6214                                if ( !defined($dos) ) { $dos = 1; } 
    62026215                                my $tiempo     = $dos; 
    62036216                                my $timer_type = ""; 
     
    62066219                                } 
    62076220 
    6208                 if ( $tiempo eq "" ) { $tiempo = 0; } 
     6221                                if ( $tiempo eq "" ) { $tiempo = 0; } 
    62096222 
    62106223                                if ( $timer_type ne "" ) { 
     
    63746387    my $interno = shift; 
    63756388    my $canal   = shift; 
    6376     my $plural = ""; 
    6377     my $return = ""; 
     6389    my $plural = ""; 
     6390    my $return = ""; 
    63786391    if ( @{ $sesbot{$interno} } > 1 ) { 
    6379              $plural = "s"; 
     6392        $plural = "s"; 
    63806393    } 
    63816394    if ( @{ $sesbot{$interno} } > 0 ) { 
    6382           my $cuantos = @{ $sesbot{$interno} }; 
    6383           my ( $text, $textriginal, $buttontext ) = translate( $canal, "&channels,$cuantos,$plural", "", "" ); 
    6384           $return = "$interno|settext|$text"; 
    6385           $botonpermanenttext{$interno} = $text; 
    6386     } else { 
    6387           $botonpermanenttext{$interno} = ""; 
    6388           $return ="$interno|corto|"; 
     6395        my $cuantos = @{ $sesbot{$interno} }; 
     6396        my ( $text, $textriginal, $buttontext ) = translate( $canal, "&channels,$cuantos,$plural", "", "" ); 
     6397        $return = "$interno|settext|$text"; 
     6398        $botonpermanenttext{$interno} = $text; 
     6399    } 
     6400    else { 
     6401        $botonpermanenttext{$interno} = ""; 
     6402        $return = "$interno|corto|"; 
    63896403    } 
    63906404    return $return; 
     
    74167430                my $cuantos           = @cuales_transferir; 
    74177431 
    7418                                if ( !defined( $tospy{$btn_destino} ) ) { 
     7432                if ( !defined( $tospy{$btn_destino} ) ) { 
    74197433 
    74207434                    # If there is no spy extension defined, change it to a standard 
     
    74547468                    return; 
    74557469 
    7456                                 } 
    7457  
    7458                         } elsif ( $accion =~ /^tovoicemail/ ) { 
     7470                } 
     7471 
     7472            } 
     7473            elsif ( $accion =~ /^tovoicemail/ ) { 
    74597474 
    74607475                my @cuales_transferir = get_transfer_channel( $origin_channel, $datosflash ); 
     
    75007515                    return; 
    75017516                } 
    7502             } elsif ( $accion =~ /^voicemail/ ) { 
     7517            } 
     7518            elsif ( $accion =~ /^voicemail/ ) { 
    75037519                my $vext     = ""; 
    75047520                my $vcontext = ""; 
     
    90469062 
    90479063sub recompute_queues_onjoin { 
    9048     my ($hash_temporal,$server,$canalid) = @_; 
    9049     my @return        = (); 
    9050     my @corto         = (); 
    9051     my @ocupado       = (); 
     9064    my ( $hash_temporal, $server, $canalid ) = @_; 
     9065    my @return    = (); 
     9066    my @corto     = (); 
     9067    my @ocupado   = (); 
    90529068    my $qclidnum  = ""; 
    90539069    my $qclidname = ""; 
     
    90669082    my $texto_pos = "[$qclidname $qclidnum]"; 
    90679083 
    9068     my $canal = "QUEUE/" . $hash_temporal->{Queue}; 
     9084    my $canal    = "QUEUE/" . $hash_temporal->{Queue}; 
    90699085    my $position = $hash_temporal->{Position}; 
    90709086    $canal =~ tr/a-z/A-Z/; 
     
    90859101        } 
    90869102    } 
    9087     if($tengo==1) { 
     9103    if ( $tengo == 1 ) { 
     9104 
    90889105        # Queue prio! 
    90899106        my $time = time(); 
     
    90959112 
    90969113            if ( $canal eq $cola->{$id}{QUEUE} ) { 
    9097                 if($cola->{$id}{POSITION} >= $position) { 
     9114                if ( $cola->{$id}{POSITION} >= $position ) { 
    90989115                    my $diftime = $time - $cola->{$id}{TIME}; 
    90999116                    if ( $queue_hide == 1 ) { 
     
    91119128        @ocupado = unique(@ocupado); 
    91129129        @corto   = unique(@corto); 
    9113     }  
     9130    } 
     9131 
    91149132    # Normal, add new call at the end of the queue 
    91159133    push @return, "$canal=$position|ocupado2|$texto_pos|$unico_id|$canalid"; 
     
    91199137    if ( defined( $hash_temporal->{Wait} ) ) { 
    91209138        $tiempo = $tiempo - $hash_temporal->{Wait}; 
    9121         push @return, "$canal=$position|settimer|".$hash_temporal->{Wait}."\@UP|$unico_id|$canalid"; 
     9139        push @return, "$canal=$position|settimer|" . $hash_temporal->{Wait} . "\@UP|$unico_id|$canalid"; 
    91229140    } 
    91239141    $cola->{$canalid}{POSITION} = $position; 
     
    91289146    $cola->{$canalid}{TIME}     = $tiempo; 
    91299147    if (@corto) { 
    9130        return ( @corto, @ocupado, @return ); 
    9131     } else { 
    9132        return @return; 
     9148        return ( @corto, @ocupado, @return ); 
     9149    } 
     9150    else { 
     9151        return @return; 
    91339152    } 
    91349153} 
     
    91819200                push @ocupado, construct_cmd( $cola, $id, "settimer", $diftime ); 
    91829201                push @ocupado, construct_cmd( $cola, $id, "ocupado",  "[$clidtext]" ); 
     9202 
    91839203                #push @ocupado, $cola->{$id}{QUEUE} . "|ocupado|[$clidtext]|" . $cola->{$id}{QUEUE} . "-" . $cola->{$id}{SERVER} . "|$id"; 
    91849204                push @ocupado, $cola->{$id}{QUEUE} . "|settimer|0\@STOP|" . $cola->{$id}{QUEUE} . "-" . $cola->{$id}{SERVER} . "|$id";