Changeset 8744

Show
Ignore:
Timestamp:
01/31/10 12:51:12 (3 years ago)
Author:
p_lindheimer
Message:

fixes #4019 tries to detect failure modes and reports on them handling graceful termination, also consolidate ext-fax, ext-fax-legacy into one context

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.7/fax/functions.inc.php

    r8700 r8744  
    187187        $exten=$row['user']; 
    188188        $ext->add($context, $exten, '', new ext_noop('Receiving Fax for: '.$row['name'].' ('.$row['user'].'), From: ${CALLERID(all)}')); 
    189         $ext->add($context, $exten, '', new ext_set('TO', '"'.$row['faxemail'].'"'));      
    190         if ($fax['module'] == 'spandsp') { 
    191           $ext->add($context, $exten, 'receivefax', new ext_rxfax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif')); //recive fax, then email it on 
    192         } else { 
    193           $ext->add($context, $exten, 'receivefax', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif')); //recive fax, then email it on 
    194         } 
     189        $ext->add($context, $exten, '', new ext_set('FAX_RX_EMAIL', '"'.$row['faxemail'].'"'));      
     190        $ext->add($context, $exten, '', new ext_goto('receivefax','s')); 
    195191      } 
    196       $ext->add($context, 'h', '', new ext_execif('$["${TO}" != ""]','system','\'${ASTVARLIBDIR}/bin/fax-process.pl --to ${TO} --from "'.$sender_address['0'].'" --dest "${FROM_DID}" --subject "New fax from ${URIENCODE(${CALLERID(all)})}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif\'')); 
    197     } 
    198     $ext->add('ext-did-0001', 'fax', '', new ext_goto('${FAX_DEST}')); 
    199     $ext->add('ext-did-0002', 'fax', '', new ext_goto('${FAX_DEST}')); 
    200  
    201     // Add fax extension to ivr and announcement as inbound controle may be passed quickly to them and still detection is desired 
    202     if (function_exists('ivr_list')) { 
    203       $ivrlist = ivr_list(); 
    204       if(is_array($ivrlist)) foreach($ivrlist as $item) { 
    205         $ext->add("ivr-".$item['ivr_id'], 'fax', '', new ext_goto('${FAX_DEST}')); 
    206       } 
    207     } 
    208     if (function_exists('announcement_list')) foreach (announcement_list() as $row) { 
    209       $ext->add('app-announcement-'.$row['announcement_id'], 'fax', '', new ext_goto('${FAX_DEST}')); 
    210     } 
    211  
    212     //write out res_fax.conf and res_fax_digium.conf 
    213     fax_write_conf(); 
    214     // generate ext-fax-legacy used for both legacy mode and app-fax feature code 
    215     // 
    216     $context='ext-fax-legacy'; 
     192    } 
     193    /* 
     194      FAX Failures are not handled well as of this coding in by ReceiveFAX. If there is a license available then it provides 
     195      information. If not, nothing is provided. FAXSTATUS is supported in 1.4 to handle legacy with RxFax(). In order to create 
     196      dialplan to try and handle all cases, we use FAXSTATUS and set it ourselves as needed. It appears that if a fax fails with 
     197      ReceiveFAX we can always continue execution and if it succeeds, then execution goes to hangup. So using that information 
     198      we try to trap and report on all cases. 
     199    */ 
    217200    $exten = 's'; 
    218201    $ext->add($context, $exten, '', new ext_macro('user-callerid')); // $cmd,n,Macro(user-callerid) 
     
    222205    } else { 
    223206      $ext->add($context, $exten, 'receivefax', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif')); //recive fax, then email it on 
    224     } 
    225     $ext->add($context, 'h', '', new ext_execif('$["${FAX_RX_EMAIL}" != ""]','system','\'${ASTVARLIBDIR}/bin/fax-process.pl --to ${FAX_RX_EMAIL} --from "'.$sender_address['0'].'" --dest "${FROM_DID}" --subject "New fax from ${URIENCODE(${CALLERID(all)})}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif\'')); 
     207      $ext->add($context, $exten, '', new ext_set('FAXSTATUS','${IF($["${FAXOPT(error)}" = ""]?"FAILED LICENSE EXCEEDED":"FAILED FAXOPT: error: ${FAXOPT(error)} status: ${FAXOPT(status)} statusstr: ${FAXOPT(statusstr)}")}')); 
     208    } 
     209    $exten = 'h'; 
     210    $ext->add($context, $exten, '', new ext_gotoif('$["${FAXSTATUS:0:6}" = "FAILED"]', 'failed')); 
     211    $ext->add($context, $exten, 'process', new ext_execif('$["${FAX_RX_EMAIL}" != ""]','system','\'${ASTVARLIBDIR}/bin/fax-process.pl --to ${FAX_RX_EMAIL} --from "'.$sender_address['0'].'" --dest "${FROM_DID}" --subject "New fax from ${URIENCODE(${CALLERID(all)})}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif\'')); 
     212    $ext->add($context, $exten, 'end', new ext_macro('hangupcall')); 
     213    $ext->add($context, $exten, 'failed', new ext_noop('FAX ${FAXSTATUS} for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)}'),'process',101); 
     214    $ext->add($context, $exten, '', new ext_macro('hangupcall')); 
     215 
     216    $ext->add('ext-did-0001', 'fax', '', new ext_goto('${FAX_DEST}')); 
     217    $ext->add('ext-did-0002', 'fax', '', new ext_goto('${FAX_DEST}')); 
     218 
     219    // Add fax extension to ivr and announcement as inbound controle may be passed quickly to them and still detection is desired 
     220    if (function_exists('ivr_list')) { 
     221      $ivrlist = ivr_list(); 
     222      if(is_array($ivrlist)) foreach($ivrlist as $item) { 
     223        $ext->add("ivr-".$item['ivr_id'], 'fax', '', new ext_goto('${FAX_DEST}')); 
     224      } 
     225    } 
     226    if (function_exists('announcement_list')) foreach (announcement_list() as $row) { 
     227      $ext->add('app-announcement-'.$row['announcement_id'], 'fax', '', new ext_goto('${FAX_DEST}')); 
     228    } 
     229 
     230    //write out res_fax.conf and res_fax_digium.conf 
     231    fax_write_conf(); 
    226232   
    227233    $modulename = 'fax'; 
     
    234240      $ext->addInclude('from-internal-additional', 'app-fax'); // Add the include from from-internal 
    235241      $ext->add('app-fax', $fc_simu_fax, '', new ext_setvar('FAX_RX_EMAIL', $default_address[0])); 
    236       $ext->add('app-fax', $fc_simu_fax, '', new ext_goto('1', 's', 'ext-fax-legacy')); 
     242      $ext->add('app-fax', $fc_simu_fax, '', new ext_goto('1', 's', 'ext-fax')); 
    237243      $ext->add('app-fax', 'h', '', new ext_macro('hangupcall')); 
    238244    } 
     
    436442        $ext->splice($context, $extension, 'dest-ext', new ext_setvar('FAX_DEST','"'.$route['destination'].'"')); 
    437443      } else { 
    438         $ext->splice($context, $extension, 'dest-ext', new ext_setvar('FAX_DEST','"ext-fax-legacy,s,1"')); 
     444        $ext->splice($context, $extension, 'dest-ext', new ext_setvar('FAX_DEST','"ext-fax,s,1"')); 
    439445        if ($route['legacy_email']) { 
    440446          $fax_rx_email = $route['legacy_email']; 
  • modules/branches/2.7/fax/module.xml

    r8743 r8744  
    22  <rawname>fax</rawname> 
    33  <name>Fax Configuration</name> 
    4   <version>2.7.0.1</version> 
     4  <version>2.7.0.2</version> 
    55  <publisher>Schmoozecom.com</publisher> 
    66  <license>GPLv2+</license> 
     
    1212  <description>Adds configurations, options and GUI for inbound faxing</description> 
    1313  <changelog> 
     14    *2.7.0.2* #4019 
    1415    *2.7.0.1* #4018 
    1516    *2.7.0.0* Initial reelase: #4007, #4010