Changeset 73

Show
Ignore:
Timestamp:
04/10/08 16:44:28 (8 months ago)
Author:
root
Message:

Serve policy file from server to make new flash clients happy. Also formatting fixes using perltidy and line lenght of 140

Files:

Legend:

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

    r72 r73  
    18471847    # a trunk button. 
    18481848 
    1849     log_debug( "$heading START SUB canalid $canalid contexto $contexto server $server canalsesion $canalsesion", 16 ) if DEBUG; 
     1849    log_debug( "$heading START SUB canalid $canalid contexto $contexto server $server canalsesion $canalsesion", 16 ) 
     1850      if DEBUG; 
    18501851 
    18511852    if ( $canalid eq "" ) { 
     
    30353036                my $indice = $hash_temporal{Uniqueid} . "-" . $hash_temporal{Server}; 
    30363037                if ( exists( $datos{"$indice"} ) ) { 
    3037                     log_debug( "** ATTENDANT we had that uniqueid before, extract the channel from there", 16 ) if DEBUG; 
     3038                    log_debug( "** ATTENDANT we had that uniqueid before, extract the channel from there", 16 ) 
     3039                      if DEBUG; 
    30383040                    if ( defined( $datos{$indice}{Extension} ) ) { 
    30393041 
     
    30483050                } 
    30493051                else { 
    3050                     log_debug( "** ATTENDANT we do not have any event with that uniqueid, save for later", 16 ) if DEBUG; 
     3052                    log_debug( "** ATTENDANT we do not have any event with that uniqueid, save for later", 16 ) 
     3053                      if DEBUG; 
    30513054                    print_datos(99); 
    30523055                    $pending_uniqueid_attendant{ $hash_temporal{Uniqueid} } = $hash_temporal{Exten} . "@" . $hash_temporal{Context}; 
     
    37643767            $channel_to_agent{"$server^$canalreal"}   = "Agent/$texto"; 
    37653768            $agent_to_channel{"$server^Agent/$texto"} = $canalreal; 
    3766             log_debug( "channel_to_agent($server^$canalreal) = " . $channel_to_agent{"$server^$canalreal"}, 64 ) if DEBUG; 
     3769            log_debug( "channel_to_agent($server^$canalreal) = " . $channel_to_agent{"$server^$canalreal"}, 64 ) 
     3770              if DEBUG; 
    37673771            if ( !defined( $hash_temporal{Fake} ) || $hash_temporal{Fake} ne "init" ) { 
    37683772                my @respuestas = set_queueobject( $server, "AGENT/$texto", "status", 1 ); 
     
    39243928            $estado_final = "changelabel" . $change_led; 
    39253929 
    3926             if ( defined( $agent_to_channel{"$server^Agent/$canal"} ) || defined( $channel_to_agent{"$server^$canal"} ) ) { 
     3930            if (   defined( $agent_to_channel{"$server^Agent/$canal"} ) 
     3931                || defined( $channel_to_agent{"$server^$canal"} ) ) 
     3932            { 
    39273933                if ( defined( $agent_to_channel{"$server^Agent/$canal"} ) ) { 
    39283934                    $canal = $agent_to_channel{"$server^Agent/$canal"}; 
     
    39964002            if ( defined( $hash_temporal{Queue} ) ) { 
    39974003                $valor = $hash_temporal{Queue}; 
    3998                 if ( exists( $agents_available_on_queue{"$server^$valor"} ) && $agents_available_on_queue{"$server^$valor"} ne "" ) { 
     4004                if ( exists( $agents_available_on_queue{"$server^$valor"} ) 
     4005                    && $agents_available_on_queue{"$server^$valor"} ne "" ) 
     4006                { 
    39994007                    my $texto3 = ""; 
    40004008                    foreach my $qmem ( @{ $agents_available_on_queue{"$server^$valor"} } ) { 
     
    47084716 
    47094717        if ( $nuevo_nombre =~ /<ZOMBIE>/ ) { 
    4710             log_debug( "$heading $nuevo_nombre, asterisk bug, sometimes misses the hangup, so we fake it", 64 ) if DEBUG; 
     4718            log_debug( "$heading $nuevo_nombre, asterisk bug, sometimes misses the hangup, so we fake it", 64 ) 
     4719              if DEBUG; 
    47114720            my ( $canalnuevo, undef ) = separate_session_from_channel($nuevo_nombre); 
    47124721            push @return, "$canalnuevo|corto||$unico_id|$nuevo_nombre"; 
     
    49414950 
    49424951        # If its a new extension without state and priority 1, defaults to 'Up' and set setlid 
     4952        if ( !defined( $hash_temporal{'Priority'} ) ) { 
     4953            $hash_temporal{'Priority'} = 1; 
     4954        } 
    49434955        if ( !defined( $datos{$unico_id}{'State'} ) && $hash_temporal{Priority} == 1 ) { 
    49444956            $datos{$unico_id}{'State'} = "Up"; 
     
    58645876 
    58655877                                log_debug( "$heading CORTO interno $interno canal $canal", 256 ) if DEBUG; 
     5878                                $dos = $canalid; 
    58665879 
    58675880                                delete $botonpark{$interno}; 
     
    61626175                            if ( !defined( $cambiaron{$interno} ) ) { 
    61636176                                $cambiaron{$interno} = 1; 
    6164                                 log_debug( "$heading es distinto de corto,ocupado,link pongo cambiaron=1", 256 ) if DEBUG; 
     6177                                log_debug( "$heading es distinto de corto,ocupado,link pongo cambiaron=1", 256 ) 
     6178                                  if DEBUG; 
    61656179                            } 
    61666180                        } 
     
    61726186 
    61736187                        if ( @{ $sesbot{$interno} } > 0 && $quehace eq 'corto' ) { 
    6174                             log_debug( "$heading Still busy...sesbot($interno) is not empty, ignore hangup", 256 ) if DEBUG; 
     6188                            log_debug( "$heading Still busy...sesbot($interno) is not empty, ignore hangup", 256 ) 
     6189                              if DEBUG; 
    61756190                            if ( defined( $group_count{$interno} ) ) { 
    61766191                                if ( $group_count{$interno} == 1 ) { 
     
    61856200                                my $canalsincontexto = $canal; 
    61866201                                $canalsincontexto =~ s/(.*)&(.*)/$1/g; 
    6187                                 push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|corto!"; 
     6202                                push @mensajefinal, "$canalsincontexto\@$canalsincontexto|$quehace|$canalid"; 
    61886203                                if ( defined( $group_count{$interno} ) ) { 
    61896204                                    if ( $group_count{$interno} == 1 ) { 
     
    62066221                                push @mensajefinal, "$interno|settimer|0\@STOP"; 
    62076222                                push @mensajefinal, "$interno|settext|"; 
    6208                                 push @mensajefinal, "$interno|corto|"; 
     6223                                push @mensajefinal, "$interno|corto|$canalid"; 
    62096224                            } 
    62106225 
     
    62636278                                            else { 
    62646279                                                push @respuestas, "$interno|$quehace2|$dos"; 
    6265                                                 log_debug( "$heading pushing respuestas $interno|$quehace2|$dos", 256 ) if DEBUG; 
     6280                                                log_debug( "$heading pushing respuestas $interno|$quehace2|$dos", 256 ) 
     6281                                                  if DEBUG; 
    62666282                                            } 
    62676283                                        } 
     
    63426358                                        $iniagent = $channel_to_agent{"$server^$canalsincontexto"}; 
    63436359                                    } 
    6344                                     log_debug( "$heading quehace2 corto y es agente, pushing settimer y settext to idle", 256 ) if DEBUG; 
     6360                                    log_debug( "$heading quehace2 corto y es agente, pushing settimer y settext to idle", 256 ) 
     6361                                      if DEBUG; 
    63456362                                    $botontimer{$interno}     = time(); 
    63466363                                    $botontimertype{$interno} = "IDLE"; 
     
    63556372                                else { 
    63566373                                    my $valip = ""; 
    6357                                     log_debug( "$heading quehace2 corto, no es agente, pongo timer en cero", 256 ) if DEBUG; 
     6374                                    log_debug( "$heading quehace2 corto, no es agente, pongo timer en cero", 256 ) 
     6375                                      if DEBUG; 
    63586376 
    63596377                                    push @mensajefinal, "$interno|settimer|0\@STOP"; 
     
    63666384                                        if ( defined( $botonpermanenttext{$interno} ) ) { 
    63676385                                            push @mensajefinal, "$interno|settext|$botonpermanenttext{$interno}"; 
    6368                                             log_debug( "interno $interno tenia permanente $botonpermanenttext{$interno}", 128 ) if DEBUG; 
     6386                                            log_debug( "interno $interno tenia permanente $botonpermanenttext{$interno}", 128 ) 
     6387                                              if DEBUG; 
    63696388                                        } 
    63706389                                        $botonclid{$interno} = ""; 
     
    64266445                                    if ( $cambiaron{$interno} == 1 ) { 
    64276446                                        foreach (@mensajefinal) { 
    6428                                             log_debug( "$heading pushing respuestas $_ because cambiaron($interno)=1", 256 ) if DEBUG; 
     6447                                            log_debug( "$heading pushing respuestas $_ because cambiaron($interno)=1", 256 ) 
     6448                                              if DEBUG; 
    64296449                                            push @respuestas, $_; 
    64306450                                        } 
     
    67176737 
    67186738# Tries to open the listening socket 
    6719 $m = new IO::Socket::INET( Listen => 1, LocalAddr => $listen_addr, LocalPort => $listen_port, ReuseAddr => 1, Blocking => 0 ) 
     6739$m = new IO::Socket::INET( 
     6740    Listen    => 1, 
     6741    LocalAddr => $listen_addr, 
     6742    LocalPort => $listen_port, 
     6743    ReuseAddr => 1, 
     6744    Blocking  => 0 
     6745  ) 
    67206746  or die "\nCan't listen to port $listen_port\n"; 
    67216747$O = new IO::Select(); 
     
    69747000                                        send_initial_status($C); 
    69757001                                    } 
     7002                                    elsif ( $bloque_final =~ /<policy-file-request\/>/ ) { 
     7003                                        send_policy_to_flash($C); 
     7004                                    } 
    69767005                                    else { 
    6977                                         log_debug( "$heading No 'Event' nor 'End'. Erasing block...", 32 ) if DEBUG; 
     7006                                        log_debug( "$heading No 'Event' nor 'End'. Erasing block...", 32 )  if DEBUG; 
     7007                                        log_debug( "$bloque_final",                                   255 ) if DEBUG; 
    69787008 
    69797009                                        # No Event in the block. Lets clear it up... 
     
    71277157        @cuales_transferir = extraer_todos_los_enlaces_de_un_canal( $origin_channel, $button_server{$datosflash} ); 
    71287158        if ( @cuales_transferir == 0 ) { 
    7129             log_debug( "** !! REVERSE TRANSFER No reverse available, using regular sesbot to find the linked channels", 16 ) if DEBUG; 
     7159            log_debug( "** !! REVERSE TRANSFER No reverse available, using regular sesbot to find the linked channels", 16 ) 
     7160              if DEBUG; 
    71307161            if ( $sesbot{$datosflash} ) { 
    71317162                if ( @{ $sesbot{$datosflash} } ) { 
     
    79447975                    } 
    79457976 
    7946                     log_debug( "$heading Originate from $origin_channel to extension $extension_destino!", 16 ) if DEBUG; 
     7977                    log_debug( "$heading Originate from $origin_channel to extension $extension_destino!", 16 ) 
     7978                      if DEBUG; 
    79477979                    my $keyext = "$origin_server^$origin_channel"; 
    79487980 
     
    90189050} 
    90199051 
     9052sub send_policy_to_flash { 
     9053    my $socket = shift; 
     9054    if ( !defined($socket) ) { 
     9055        log_debug( "POLICY socket $socket not open!!!", 64 ) if DEBUG; 
     9056    } 
     9057    my $policy = 
     9058"<?xml version=\"1.0\"?>\r\n<!DOCTYPE cross-domain-policy SYSTEM \"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\">\r\n<cross-domain-policy>\r\n<allow-access-from domain=\"*\" to-ports=\"$listen_port\" />\r\n</cross-domain-policy>\r\n\0"; 
     9059    actual_syswrite( $socket, $policy, "isclient", "policy enviado\n" ); 
     9060} 
     9061 
    90209062sub send_status_to_flash { 
    90219063    my $socket       = shift;