Changeset 7751

Show
Ignore:
Timestamp:
05/26/09 14:42:42 (3 years ago)
Author:
p_lindheimer
Message:

closes #3691 added usage of EXTENSION_STATE in dialparties in place of manager connection when present

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.6/core/agi-bin/dialparties.agi

    r7713 r7751  
    5858$cfignore    = strtoupper(trim($cfignore)); 
    5959 
    60 $astman = new AGI_AsteriskManager( );  
    61 if (!$astman->connect("127.0.0.1", $ampmgruser , $ampmgrpass)) { 
    62   exit (1); 
     60$ast_ge_16   = version_compare($ast_version, "1.6", "ge"); 
     61$has_extension_state = (get_var( $AGI, "HAS_EXTENSION_STATE" ) || $ast_ge_16); 
     62// If we are 1.6 then we have the EXTENSION_STATE() function and don't need to use the manager 
     63// 
     64if (!$has_extension_state) { 
     65  $astman = new AGI_AsteriskManager( );  
     66  if (!$astman->connect("127.0.0.1", $ampmgruser , $ampmgrpass)) { 
     67    exit (1); 
     68  } 
    6369} 
    6470 
     
    645651  // Asterisk 1.6 uses , instead of | and 1.4 can't recieve a , in the ds. 
    646652  // 
    647   if (version_compare($ast_version, "1.6", "ge")) {  
     653  if ($ast_ge_16) { 
    648654    $ds_seperator = ','; 
    649655  } else { 
     
    695701} 
    696702 
    697 $astman->disconnect(); 
     703if (!$has_extension_state) { 
     704  $astman->disconnect(); 
     705
    698706 
    699707// EOF dialparties.agi 
     
    767775function is_ext_avail( $extnum ) { 
    768776  global $astman; 
    769    
    770   $status = $astman->ExtensionState( $extnum, 'from-internal' ); 
    771      
    772   $status = $status['Status']; 
    773   debug("ExtensionState: $status", 4); 
     777  global $AGI; 
     778  global $has_extension_state; 
     779 
     780  if ($has_extension_state) { 
     781    $extstate_result  = get_var( $AGI, "EXTENSION_STATE($extnum)" ); 
     782    switch ($extstate_result) { 
     783      case "NOT_INUSE": 
     784        $status = 0; 
     785        break; 
     786      case "INUSE": 
     787        $status = 1; 
     788        break; 
     789      case "BUSY": 
     790        $status = 2; 
     791        break; 
     792      case "UNAVAILABLE": 
     793        $status = 4; 
     794        break; 
     795      case "RINGING": 
     796        $status = 8; 
     797        break; 
     798      case "RINGINUSE": 
     799        $status = 9; 
     800        break; 
     801      case "HOLDINUSE": 
     802        $status = 17; 
     803        break; 
     804      case "ONHOLD": 
     805        $status = 16; 
     806        break; 
     807      case "UNKNOWN": 
     808      default: 
     809        $status = 4; 
     810    } 
     811    debug("EXTENSION_STATE: $status ($extstate_result)", 1); 
     812  } else { 
     813    $status = $astman->ExtensionState( $extnum, 'from-internal' ); 
     814    $status = $status['Status']; 
     815    debug("ExtensionState: $status", 1); 
     816  } 
    774817  return $status; 
    775818} 
  • modules/branches/2.6/core/functions.inc.php

    r7741 r7751  
    658658  global $core_conf; 
    659659  global $chan_dahdi; 
     660  global $astman;; 
    660661 
    661662  $modulename = "core"; 
     
    13211322        $ext->addGlobal('CALLINGPRES_35', 'prohib'); 
    13221323        $ext->addGlobal('CALLINGPRES_67', 'unavailable'); 
     1324      } 
     1325 
     1326      // This checks if we have func_extstate loaded, if so we set the global which dialparties 
     1327      // can use (and any other AGI script) to determine that this function exists and not connect 
     1328      // to the manager to get the information 
     1329      // 
     1330      if (version_compare($version, '1.4', 'ge') && version_compare($version, '1.6', 'lt')) { 
     1331        $response = $astman->send_request('Command', array('Command' => 'module show like func_extstate')); 
     1332        if (preg_match('/1 modules loaded/', $response['data'])) { 
     1333          $ext->addGlobal('HAS_EXTENSION_STATE', 'TRUE'); 
     1334        } 
    13231335      } 
    13241336