Changeset 20

Show
Ignore:
Timestamp:
03/20/07 18:58:22 (2 years ago)
Author:
root
Message:

Fix Did/Trunk free routine and remove debug lines

Files:

Legend:

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

    r19 r20  
    19361936    my $heading = "** ERASE_INSTANCE_TRUNK"; 
    19371937 
     1938    my $solocanal = $canalid; 
     1939    $solocanal =~ s/[^\w]//g; 
     1940 
    19381941    $canalidsinserver = $canalid; 
    19391942    $canalid          = "$server^$canalid"; 
     
    19641967    log_debug( "$heading looking for $canalid on instancias to erase it", 128 ) if DEBUG; 
    19651968 
     1969    my $trymatch = $canalid; 
     1970 
     1971    if ( $canal =~ m/^DID|^CLID/ ) { 
     1972        $canal =~ s/(.*)=(.*)/$1/g; 
     1973        $trymatch = $server . "^" . $canal . "-" . $solocanal; 
     1974    } 
    19661975    foreach my $key1 ( sort ( keys(%instancias) ) ) { 
    19671976        foreach my $key2 ( sort ( keys( %{ $instancias{$key1} } ) ) ) { 
    1968             if ( $key2 eq $canalid ) { 
     1977            if ( $key2 eq $trymatch ) { 
    19691978                delete $instancias{$key1}{$key2}; 
    1970                 log_debug( "$heading Erasing $canalid from instanacias!", 128 ) if DEBUG; 
    1971             } 
    1972         } 
    1973     } 
     1979                log_debug( "$heading Erasing $trymatch from instanacias!", 128 ) if DEBUG; 
     1980            } 
     1981        } 
     1982    } 
     1983 
    19741984} 
    19751985 
     
    20952105 
    20962106        if ( $canal =~ /=/ ) { 
    2097  
    20982107            # If its a trunk button, erase instances 
    20992108            erase_instances_for_trunk_buttons( $canalsesion, $canal, $server ); 
     
    23502359            $calleridnum = $datos{$uniqueid}{CallerID}; 
    23512360        } 
    2352         if ( defined( $datos{$uniqueid}{Extension} ) &&  
    2353                          defined( $datos{$uniqueid}{AppData}   ) && 
    2354                          $datos{$uniqueid}{AppData} =~ m/^FROM_DID/  
    2355             )
     2361        if (   defined( $datos{$uniqueid}{Extension} ) 
     2362            && defined( $datos{$uniqueid}{AppData} ) 
     2363            && $datos{$uniqueid}{AppData} =~ m/^FROM_DID/ ) 
     2364       
    23562365            $didnum = $datos{$uniqueid}{"Extension"}; 
    2357                         print "set did $didnum\n"; 
    23582366        } 
    23592367    } 
     
    25072515                } 
    25082516                elsif ( $_ =~ /^$server\^CLID\/\Q$calleridnum\E=/ ) { 
    2509                                        my $solocanal = $canalsesion; 
    2510                                        $solocanal =~ s/[^\w]//g; 
    2511                                        my $tcanal = "CLID/".$calleridnum."-".$solocanal; 
    2512                                        if ( !exists( $trunk_matched{"$server^CLID/$calleridnum"} ) ) { 
     2517                    my $solocanal = $canalsesion; 
     2518                    $solocanal =~ s/[^\w]//g; 
     2519                    my $tcanal = "CLID/" . $calleridnum . "-" . $solocanal; 
     2520                    if ( !exists( $trunk_matched{"$server^CLID/$calleridnum"} ) ) { 
    25132521                        $canalfinal = get_next_trunk_button( $tcanal, $contexto, $server, $tcanal ); 
    25142522                        if ( $canalfinal ne "" ) { 
    2515                                log_debug( "$heading clid match trunk ( $_ )  $canal $contexto", 32 ) if DEBUG; 
     2523                            log_debug( "$heading clid match trunk ( $_ )  $canal $contexto", 32 ) if DEBUG; 
    25162524                            $trunk_matched{"$server^CLID/$calleridnum"} = 1; 
    25172525                            $canalfinal =~ s/(.*)\^(.*)/$2/g; 
    25182526                        } 
    25192527                    } 
    2520                                
     2528               
    25212529                elsif ( $_ =~ /^$server\^CLID\/\Q$calleridnum\E\&?/ ) { 
    25222530                    log_debug( "$heading clid match ( $_ )  $canal $contexto", 32 ) if DEBUG; 
     
    25242532                } 
    25252533                elsif ( $_ =~ /^$server\^DID\/\Q$didnum\E=/ ) { 
    2526                                         print "did num match $didnum\n"; 
    2527                                         my $solocanal = $canalsesion; 
    2528                                         $solocanal =~ s/[^\w]//g; 
    2529                                         my $tcanal = "DID/".$didnum."-".$solocanal; 
    2530                                         if ( !exists( $trunk_matched{"$server^DID/$didnum"} ) ) { 
     2534                    my $solocanal = $canalsesion; 
     2535                    $solocanal =~ s/[^\w]//g; 
     2536                    my $tcanal = "DID/" . $didnum . "-" . $solocanal; 
     2537                    if ( !exists( $trunk_matched{"$server^DID/$didnum"} ) ) { 
    25312538                        $canalfinal = get_next_trunk_button( $tcanal, $contexto, $server, $tcanal ); 
    25322539                        if ( $canalfinal ne "" ) { 
    2533                                                         print "canalfinal $canalfinal\n"; 
    2534                                 log_debug( "$heading did match trunk ( $_ )  $canal $contexto", 32 ) if DEBUG; 
     2540                            log_debug( "$heading did match trunk ( $_ )  $canal $contexto", 32 ) if DEBUG; 
    25352541                            $trunk_matched{"$server^DID/$didnum"} = 1; 
    25362542                            $canalfinal =~ s/(.*)\^(.*)/$2/g; 
    25372543                        } 
    25382544                    } 
    2539                                
     2545               
    25402546                elsif ( $_ =~ /^$server\^DID\/\Q$didnum\E\&?/ ) { 
    25412547                    log_debug( "$heading did match ( $_ )  $canal $contexto", 32 ) if DEBUG; 
    25422548                    $canalfinal = "DID/$didnum"; 
    25432549                } 
    2544  
    25452550 
    25462551                if ( $canalfinal ne "" ) { 
     
    47744779    elsif ( $evento eq "newexten" ) { 
    47754780 
    4776         print "newexten\n"; 
    4777  
    47784781        # If its a new extension without state and priority 1, defaults to 'Up' and set setlid 
    47794782        if ( !defined( $datos{$unico_id}{'State'} ) && $hash_temporal{Priority} == 1 ) { 
     
    47814784            log_debug( "$heading POPULATES datos($unico_id){ State } = Up", 128 ) if DEBUG; 
    47824785            ( $canal, $sesion ) = separate_session_from_channel( $hash_temporal{Channel} ); 
    4783             $texto        = $hash_temporal{Extension}; 
    4784                         if($texto ne "s") { 
    4785                 $estado_final = "setclid"; 
    4786                         } 
    4787         } 
    4788         else { 
    4789             print "Newexten pero otro priority?\n"; 
     4786            $texto = $hash_temporal{Extension}; 
     4787            if ( $texto ne "s" ) { 
     4788                $estado_final = "setclid"; 
     4789            } 
    47904790        } 
    47914791 
     
    48114811            log_debug( "Save " . $hash_temporal{Channel} . " as pending", 16 ) if DEBUG; 
    48124812        } 
    4813  
    48144813 
    48154814    } 
     
    50455044 
    50465045        if ( $state eq "Ring" ) { 
    5047             print "RING $canalid $texto\n"; 
    50485046            $texto                      = $canalid; 
    50495047            $estado_final               = "ring"; 
     
    52675265    # Remove &context from $canal 
    52685266    $canal =~ s/(.*)&(.*)/$1/g; 
    5269  
    5270     #   if( $canal =~ m/^CLID/ ) { 
    5271     #                   my $extr = $extension_transfer{"$server^$canal"}; 
    5272     #           $extr =~ s/\d+\^(.*)/$1/g; 
    5273     #           $canal = "Local/$extr"; 
    5274     #   } 
    52755267 
    52765268    log_debug( "** LOCAL_CHANNELS devuelvo $server canal $canal", 32 ) if DEBUG; 
     
    53575349                log_debug( "$heading canalid:  $canalid",  32 ) if DEBUG; 
    53585350 
    5359                 $canalid =~ s/\s+//g;            # Removes whitespace from CHANNEL-ID 
     5351                $canalid =~ s/\s+//g;    # Removes whitespace from CHANNEL-ID 
    53605352                my $real_canal    = $canalid; 
    53615353                my $canalidzombie = $canalid;    # Removes whitespace from CHANNEL-ID 
     
    53865378                my $cuantos  = @canaleja; 
    53875379 
    5388                                # Perform some pre processing... 
     5380                # Perform some pre processing... 
    53895381 
    53905382                if ( $quehace eq "corto" || $quehace eq "info" ) { 
     
    54145406                    } 
    54155407 
    5416                 } elsif ( $quehace eq "queueremoved" ) { 
     5408                } 
     5409                elsif ( $quehace eq "queueremoved" ) { 
    54175410 
    54185411                    # Remove the agent from the agents_on_queue hash 
     
    55205513 
    55215514                    if ( $canal eq "" ) { 
    5522                                                 # No channel? continue... 
     5515 
     5516                        # No channel? continue... 
    55235517                        log_debug( "$heading There is no command defined", 32 ) if DEBUG; 
    55245518 
    5525                                         } else { 
     5519                    } 
     5520                    else { 
    55265521 
    55275522                        $interno = $buttons{"$server^$canal"}; 
     
    55455540                        } 
    55465541 
    5547                                                # The following block cleans internal op_server states. no matter if we 
    5548                                                # have a button defined or not. 
     5542                        # The following block cleans internal op_server states. no matter if we 
     5543                        # have a button defined or not. 
    55495544 
    55505545                        if ( $quehace eq 'corto' || $quehace eq 'info' ) { 
    5551  
    55525546                            my @linked = erase_all_sessions_from_channel( $canalid, $canal, $server ); 
     5547 
    55535548                            push @linked, $canal; 
    55545549                            my $btnorinum = ""; 
     
    55685563                            log_debug( "$heading REMOVING datos { $uniqueid }", 32 ) if DEBUG; 
    55695564 
    5570                         } elsif ( $quehace eq "setlink" ) { 
     5565                        } 
     5566                        elsif ( $quehace eq "setlink" ) { 
    55715567 
    55725568                            log_debug( "$heading IF quehace = SETLINK", 32 ) if DEBUG; 
     
    56075603                            log_debug( "$heading ENDIF quehace = SETLINK",    32 ) if DEBUG; 
    56085604 
    5609                         } elsif ( $quehace eq "unsetlink" ) { 
     5605                        } 
     5606                        elsif ( $quehace eq "unsetlink" ) { 
    56105607                            log_debug( "$heading IF quehace = UNSETLINK", 32 ) if DEBUG; 
    56115608                            my @final = (); 
     
    56185615                            log_debug( "$heading ENDIF quehace = UNSETLINK", 32 ) if DEBUG; 
    56195616 
    5620                         } elsif ( $quehace eq "queueremoved" ) { 
     5617                        } 
     5618                        elsif ( $quehace eq "queueremoved" ) { 
    56215619 
    56225620                            delete $botonvoicemail{$interno}; 
     
    56345632                        } 
    56355633 
    5636                                                # Continue after cleaning internal state... 
     5634                        # Continue after cleaning internal state... 
    56375635                        if ( $interno eq "" ) { 
    56385636                            log_debug( "$heading MISSING buttons($server^$canal), skipping...", 32 ) if DEBUG; 
     
    58225820 
    58235821                        log_debug( "$heading Continuo proceso...", 32 ) if DEBUG; 
    5824                                                  
     5822 
    58255823                        if ( $quehace =~ /changelabel/ ) { 
    58265824                            log_debug( "$heading quehace = changelabel", 32 ) if DEBUG; 
     
    58635861                            } 
    58645862 
    5865                         } elsif ( $quehace eq "park" ) { 
     5863                        } 
     5864                        elsif ( $quehace eq "park" ) { 
    58665865 
    58675866                            log_debug( "$heading quehace = park", 32 ) if DEBUG; 
     
    58715870                            $timeout = time() + $timeout; 
    58725871                            $botonpark{$interno} = "$texto|$timeout"; 
    5873                         } elsif ( $quehace eq "meetmeuser" ) { 
     5872                        } 
     5873                        elsif ( $quehace eq "meetmeuser" ) { 
    58745874                            $botonmeetme{$interno} = $dos; 
    5875                         } elsif ( $quehace eq "infoqstat" ) { 
     5875                        } 
     5876                        elsif ( $quehace eq "infoqstat" ) { 
    58765877                            $botonqueue{$interno} = $dos; 
    5877                         } elsif ( $quehace eq "infoqstat2" ) { 
     5878                        } 
     5879                        elsif ( $quehace eq "infoqstat2" ) { 
    58785880                            $botonqueue_count{$interno} = $dos; 
    5879                         } elsif ( $quehace =~ /info/ ) { 
     5881                        } 
     5882                        elsif ( $quehace =~ /info/ ) { 
    58805883                            my $mcola = $quehace; 
    58815884                            $mcola =~ s/^info//g; 
     
    58985901                            } 
    58995902 
    5900                         } elsif ( $quehace eq "setclid" ) { 
     5903                        } 
     5904                        elsif ( $quehace eq "setclid" ) { 
    59015905                            if ( !defined( $group_count{$interno} ) ) { 
    59025906                                push @respuestas, "$interno|settext|$dos"; 
     
    59045908                            if ( $estadoboton{$interno} eq "" ) { 
    59055909                                push @respuestas, "$interno|state|busy"; 
    5906                                                                 $estadoboton{$interno}="busy"; 
    5907                                                         } 
    5908                         } elsif ( $quehace eq "settext" ) { 
     5910                                $estadoboton{$interno} = "busy"; 
     5911                            } 
     5912                        } 
     5913                        elsif ( $quehace eq "settext" ) { 
    59095914                            if ( !defined( $group_count{$interno} ) ) { 
    59105915                                $botonpermanenttext{$interno} = $dos; 
     
    59125917                                push @respuestas, "$interno|settext|$dos"; 
    59135918                            } 
    5914                         } elsif ( $quehace eq "fopledcolor" ) { 
     5919                        } 
     5920                        elsif ( $quehace eq "fopledcolor" ) { 
    59155921                            $botonledcolor{$interno} = $dos; 
    5916                         } elsif ( $quehace eq "setalpha" ) { 
     5922                        } 
     5923                        elsif ( $quehace eq "setalpha" ) { 
    59175924                            $botonalpha{$interno} = $dos; 
    59185925                            push @respuestas, "$interno|setalpha|$dos"; 
    5919                         } elsif ( $quehace eq "flip" ) { 
     5926                        } 
     5927                        elsif ( $quehace eq "flip" ) { 
    59205928                            push @respuestas, "$interno|flip|$dos"; 
    5921                         } elsif ( $quehace eq "setlabel" ) { 
     5929                        } 
     5930                        elsif ( $quehace eq "setlabel" ) { 
    59225931                            if (   $dos ne "." 
    59235932                                && $dos ne "original" 
     
    59275936                                push @respuestas, "$interno|setlabel|$dos"; 
    59285937                            } 
    5929                         } elsif ( $quehace eq "voicemail" ) { 
     5938                        } 
     5939                        elsif ( $quehace eq "voicemail" ) { 
    59305940                            $botonvoicemail{$interno} = $dos; 
    5931                         } elsif ( $quehace eq "voicemailcount" ) { 
     5941                        } 
     5942                        elsif ( $quehace eq "voicemailcount" ) { 
    59325943                            $botonvoicemailcount{$interno} = $dos; 
    5933                         } elsif ( $quehace =~ "^voicemail" ) { 
     5944                        } 
     5945                        elsif ( $quehace =~ "^voicemail" ) { 
    59345946 
    59355947                            # This block is for the voicemail client 
     
    59375949                            $canalsincontexto =~ s/(.*)&(.*)/$1/g; 
    59385950                            push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|$dos"; 
    5939                         } elsif ( $quehace =~ "^ringing" ) { 
     5951                        } 
     5952                        elsif ( $quehace =~ "^ringing" ) { 
    59405953 
    59415954                            # This block is for the voicemail client, popups 
     
    60466059                                    if ( $quehace2 ne "" ) { 
    60476060                                        push @respuestas, "$interno|$quehace2|$dos"; 
    6048                                                                                 #print "push $quehace2 en $interno quehace2\n"; 
     6061 
     6062                                        #print "push $quehace2 en $interno quehace2\n"; 
    60496063                                    } 
    60506064                                }