Index: amp_conf/astetc/chan_dahdi.conf.template =================================================================== --- amp_conf/astetc/chan_dahdi.conf.template (revision 0) +++ amp_conf/astetc/chan_dahdi.conf.template (revision 0) @@ -0,0 +1,34 @@ +;# Flash Operator Panel will parse this file for dahdi trunk buttons +;# AMPLABEL will be used for the display labels on the buttons + +;# %c Dahdi Channel number +;# %n Line number +;# %N Line number, but restart counter +;# Example: +;# ;AMPLABEL:Channel %c - Button %n + +;# For Dahdi/* buttons use the following +;# (where x=number of buttons to dislpay) +;# ;AMPWILDCARDLABEL(x):MyLabel + + +[channels] +language=en + +; include dahdi extensions defined in FreePBX +#include chan_dahdi_additional.conf + +; XTDM20B Port #1,2 plugged into PSTN +;AMPLABEL:Channel %c - Button %n +context=from-pstn +signalling=fxs_ks +faxdetect=incoming +usecallerid=yes +echocancel=yes +echocancelwhenbridged=no +echotraining=800 +group=0 +channel=1-2 + + + Index: amp_conf/htdocs/recordings/includes/main.conf.php =================================================================== --- amp_conf/htdocs/recordings/includes/main.conf.php (revision 6588) +++ amp_conf/htdocs/recordings/includes/main.conf.php (arbetskopia) @@ -262,7 +262,7 @@ $ASTERISK_PROTOCOLS['sip']['table'] = "sip"; $ASTERISK_PROTOCOLS['sip']['config_files'] = "/etc/asterisk/sip.conf;/etc/asterisk/sip_additional.conf"; $ASTERISK_PROTOCOLS['zap']['table'] = "zap"; -$ASTERISK_PROTOCOLS['zap']['config_files'] = "/etc/asterisk/zapata.conf;/etc/asterisk/zapata_additional.conf"; +$ASTERISK_PROTOCOLS['zap']['config_files'] = "/etc/asterisk/zapata.conf;/etc/asterisk/zapata_additional.conf;/etc/asterisk/chan_dahdi.conf;/etc/asterisk/chan_dahdi_additional.conf"; # Settings for Follow-Me Select Boxes in seconds # Index: amp_conf/htdocs/admin/extensions.class.php =================================================================== --- amp_conf/htdocs/admin/extensions.class.php (revision 6588) +++ amp_conf/htdocs/admin/extensions.class.php (arbetskopia) @@ -928,7 +928,14 @@ } class ext_zapbarge extends extension { function output() { - return "ZapBarge(".$this->data.")"; + global $chan_dahdi; + + $command = 'ZapBarge'; + if ($chan_dahdi) { + $command = 'DAHDIBarge'; + } + + return "$command(".$this->data.")"; } } class ext_sayalpha extends extension { Index: amp_conf/htdocs/admin/functions.inc.php =================================================================== --- amp_conf/htdocs/admin/functions.inc.php (revision 6588) +++ amp_conf/htdocs/admin/functions.inc.php (arbetskopia) @@ -728,6 +728,7 @@ 'AMPDISABLELOG' => array('bool' , true), 'AMPENABLEDEVELDEBUG'=> array('bool' , false), 'AMPMPG123' => array('bool' , true), + 'ZAP2DAHDICOMPAT' => array('bool' , false), ); function parse_amportal_conf($filename) { @@ -1274,6 +1275,36 @@ return false; } +/** + * returns true if asterisk is running with chan_dahdi + * + * @return bool + */ +function ast_with_dahdi() { + global $version; + global $astman; + global $amp_conf; + + if (!$amp_conf['ZAP2DAHDICOMPAT']) { + return false; + } + + if (empty($version)) { + $engine_info = engine_getinfo(); + $version = $engine_info['version']; + } + + if (version_compare($version, '1.4', 'ge') && $amp_conf['AMPENGINE'] == 'asterisk') { + if (isset($astman) && $astman->connected()) { + $response = $astman->send_request('Command', array('Command' => 'module show like chan_dahdi')); + if (preg_match('/1 modules loaded/', $response['data'])) { + return true; + } + } + } + return false; +} + function engine_getinfo() { global $amp_conf; global $astman; Index: amp_conf/htdocs/admin/modules/core/functions.inc.php =================================================================== --- amp_conf/htdocs/admin/modules/core/functions.inc.php (revision 6588) +++ amp_conf/htdocs/admin/modules/core/functions.inc.php (arbetskopia) @@ -8,18 +8,26 @@ var $_applicationmap = array(); // return an array of filenames to write function get_filename() { + global $chan_dahdi; + $files = array( 'sip_additional.conf', 'sip_registrations.conf', 'iax_additional.conf', 'iax_registrations.conf', - 'zapata_additional.conf', 'sip_general_additional.conf', 'iax_general_additional.conf', 'features_general_additional.conf', 'features_applicationmap_additional.conf', 'features_featuremap_additional.conf', - ); + ); + + if ($chan_dahdi) { + $files[] = 'chan_dahdi_additional.conf'; + } else { + $files[] = 'zapata_additional.conf'; + } + return $files; } @@ -46,6 +54,9 @@ case 'iax_registrations.conf': return $this->generate_iax_registrations($version); break; + case 'chan_dahdi_additional.conf': + return $this->generate_zapata_additional($version); + break; case 'zapata_additional.conf': return $this->generate_zapata_additional($version); break; @@ -617,6 +628,7 @@ global $engineinfo; global $amp_conf; global $core_conf; + global $chan_dahdi; $modulename = "core"; @@ -1144,7 +1156,11 @@ $sql = "SELECT * FROM globals"; $globals = sql($sql,"getAll",DB_FETCHMODE_ASSOC); foreach($globals as $global) { - $ext->addGlobal($global['variable'],$global['value']); + $value = $global['value']; + if ($chan_dahdi && substr($value, 0, 4) === 'ZAP/') { + $value = 'DAHDI/' . substr($value, 4); + } + $ext->addGlobal($global['variable'],$value); // now if for some reason we have a variable in the global table // that is in our $amp_conf_globals list, then remove it so we @@ -1172,7 +1188,9 @@ } // Put the asterisk version in a global for agi etc. $ext->addGlobal('ASTVERSION', $version); - + // Put the use of chan_dahdi in a global for dialparties + $ext->addGlobal('ASTCHANDAHDI', $chan_dahdi ? '1' : '0'); + // Create CallingPresTable to deal with difference that ${CALINGPRES} returns vs. what // SetCallerPres() accepts. This is a workaround that gets resolved in 1.6 where // function CALLINGPRES() is consistent. @@ -1764,7 +1782,42 @@ $ext->add($context, 'i', '', new ext_goto(1, 'confmenu')); $ext->add($context, 'h', '', new ext_hangup()); + + $context = 'from-zaptel'; + $exten = '_X.'; + + $ext->add($context, $exten, '', new ext_set('DID', '${EXTEN}')); + $ext->add($context, $exten, '', new ext_goto(1, 's')); + + $exten = 's'; + $ext->add($context, $exten, '', new ext_noop('Entering from-zaptel with DID == ${DID}')); + // Some trunks _require_ a RINGING be sent before an Answer. + $ext->add($context, $exten, '', new ext_ringing()); + // If ($did == "") { $did = "s"; } + $ext->add($context, $exten, '', new ext_set('DID', '${IF($["${DID}"= ""]?s:${DID})}')); + $ext->add($context, $exten, '', new ext_noop('DID is now ${DID}')); + if ($chan_dahdi) { + $ext->add($context, $exten, '', new ext_gotoif('$["${CHANNEL:0:5}"="DAHDI"]', 'zapok', 'notzap')); + } else { + $ext->add($context, $exten, '', new ext_gotoif('$["${CHANNEL:0:3}"="Zap"]', 'zapok', 'notzap')); + } + $ext->add($context, $exten, 'notzap', new ext_goto('1', '${DID}', 'from-pstn')); + // If there's no ext-did,s,1, that means there's not a no did/no cid route. Hangup. + $ext->add($context, $exten, '', new ext_macro('Hangupcall', 'dummy')); + $ext->add($context, $exten, 'zapok', new ext_noop('Is a Zaptel Channel')); + if ($chan_dahdi) { + $ext->add($context, $exten, '', new ext_set('CHAN', '${CHANNEL:6}')); + } else { + $ext->add($context, $exten, '', new ext_set('CHAN', '${CHANNEL:4}')); + } + $ext->add($context, $exten, '', new ext_set('CHAN', '${CUT(CHAN,-,1)}')); + $ext->add($context, $exten, '', new ext_macro('from-zaptel-${CHAN}', '${DID},1')); + // If nothing there, then treat it as a DID + $ext->add($context, $exten, '', new ext_noop('Returned from Macro from-zaptel-${CHAN}')); + $ext->add($context, $exten, '', new ext_goto(1, '${DID}', 'from-pstn')); + $ext->add($context, 'fax', '', new ext_goto(1, 'in_fax', 'ext-fax')); + break; } } @@ -1931,7 +1984,7 @@ global $currentFile; global $astman; global $db; - + $display = isset($_REQUEST['display'])?$_REQUEST['display']:''; if (trim($id) == '' ) { @@ -2366,7 +2419,7 @@ function core_devices_addzap($account) { global $db; global $currentFile; - + foreach ($_REQUEST as $req=>$data) { if ( substr($req, 0, 8) == 'devinfo_' ) { $keyword = substr($req, 8); @@ -2448,6 +2501,7 @@ function core_hint_get($account){ global $astman; + $chan_dahdi = ast_with_dahdi(); // We should always check the AMPUSER in case they logged into a device // but we will fall back to the old methond if $astman not open although // I'm pretty sure everything else will puke anyhow if not running @@ -2464,7 +2518,11 @@ //create an array of strings if (is_array($results)){ foreach ($results as $result) { - $dial[] = $result['dial']; + if ($chan_dahdi) { + $dial[] = str_replace('ZAP', 'DAHDI', $result['dial']); + } else { + $dial[] = $result['dial']; + } } } @@ -3037,6 +3095,7 @@ $techtemp = ((strtolower($tech) == "iax") ? "iax2" : $tech); $outval = (($techtemp == "custom") ? "AMP:".$channelid : strtoupper($techtemp).'/'.$channelid); + $glofields = array( array('OUT_'.$trunknum, $outval), array('OUTPREFIX_'.$trunknum, $dialoutprefix), Index: amp_conf/htdocs/admin/modules/core/agi-bin/dialparties.agi =================================================================== --- amp_conf/htdocs/admin/modules/core/agi-bin/dialparties.agi (revision 6588) +++ amp_conf/htdocs/admin/modules/core/agi-bin/dialparties.agi (arbetskopia) @@ -50,6 +50,7 @@ $ampmgrpass = get_var( $AGI, "AMPMGRPASS" ); $cwinusebusy = get_var( $AGI, "CWINUSEBUSY" ); $ast_version = get_var( $AGI, "ASTVERSION" ); +$chan_dahdi = get_var( $AGI, "ASTCHANDAHDI" ); $cwignore = get_var( $AGI, "CWIGNORE" ); $cwignore = strtoupper(trim($cwignore)); @@ -705,6 +706,7 @@ } function get_dial_string( $agi, $extnum, $use_confirmation, $ringgroup_index ) { + global $chan_dahdi; $dialstring = ''; if (strpos($extnum,'#') != 0) { @@ -732,7 +734,11 @@ foreach ($device_array as $adevice) { if (trim($use_confirmation) == "FALSE") { $dds = $agi->database_get('DEVICE',$adevice.'/dial'); - $dialstring .= $dds['data']; + if ($chan_dahdi) { + $dialstring .= str_replace('ZAP', 'DAHDI', $dds['data']); + } else { + $dialstring .= $dds['data']; + } $dialstring .= '&'; } else { $dialstring .= 'Local/LC-'.$adevice.'@from-internal&'; Index: amp_conf/htdocs/admin/modules/core/etc/extensions.conf =================================================================== --- amp_conf/htdocs/admin/modules/core/etc/extensions.conf (revision 6588) +++ amp_conf/htdocs/admin/modules/core/etc/extensions.conf (arbetskopia) @@ -905,28 +905,6 @@ include => from-internal-xfer include => bad-number -[from-zaptel] -exten => _X.,1,Set(DID=${EXTEN}) -exten => _X.,n,Goto(s,1) -exten => s,1,NoOp(Entering from-zaptel with DID == ${DID}) -; Some trunks _require_ a RINGING be sent before an Answer. -exten => s,n,Ringing() -; If ($did == "") { $did = "s"; } -exten => s,n,Set(DID=${IF($["${DID}"= ""]?s:${DID})}) -exten => s,n,NoOp(DID is now ${DID}) -exten => s,n,GotoIf($["${CHANNEL:0:3}"="Zap"]?zapok:notzap) -exten => s,n(notzap),Goto(from-pstn,${DID},1) -; If there's no ext-did,s,1, that means there's not a no did/no cid route. Hangup. -exten => s,n,Macro(hangup) -exten => s,n(zapok),NoOp(Is a Zaptel Channel) -exten => s,n,Set(CHAN=${CHANNEL:4}) -exten => s,n,Set(CHAN=${CUT(CHAN,-,1)}) -exten => s,n,Macro(from-zaptel-${CHAN},${DID},1) -; If nothing there, then treat it as a DID -exten => s,n,NoOp(Returned from Macro from-zaptel-${CHAN}) -exten => s,n,Goto(from-pstn,${DID},1) -exten => fax,1,Goto(ext-fax,in_fax,1) - ;------------------------------------------------------------------------ ; [macro-setmusic] ;------------------------------------------------------------------------ Index: amp_conf/htdocs/admin/modules/asteriskinfo/page.asteriskinfo.php =================================================================== --- amp_conf/htdocs/admin/modules/asteriskinfo/page.asteriskinfo.php (revision 6588) +++ amp_conf/htdocs/admin/modules/asteriskinfo/page.asteriskinfo.php (arbetskopia) @@ -1,4 +1,4 @@ - Index: amp_conf/htdocs/admin/modules/backup/bin/ampbackup.pl =================================================================== --- amp_conf/htdocs/admin/modules/backup/bin/ampbackup.pl (revision 6588) +++ amp_conf/htdocs/admin/modules/backup/bin/ampbackup.pl (arbetskopia) @@ -191,7 +191,7 @@ } if ( $Backup_Configurations eq "yes" ){ system ($ast{'astvarlibdir'}."/bin/dumpastdb.php $Stamp > /dev/null"); - system ("/bin/tar -Pcz -f /tmp/ampbackups.$Stamp/configurations.tar.gz ".$ast{'astvarlibdir'}."/agi-bin/ ".$ast{'astvarlibdir'}."/bin/ /etc/asterisk $webroot/admin /etc/amportal.conf /etc/zaptel.conf /tmp/ampbackups.$Stamp/astdb.dump "); + system ("/bin/tar -Pcz -f /tmp/ampbackups.$Stamp/configurations.tar.gz ".$ast{'astvarlibdir'}."/agi-bin/ ".$ast{'astvarlibdir'}."/bin/ /etc/asterisk $webroot/admin /etc/amportal.conf /etc/zaptel.conf /etc/dahdi /tmp/ampbackups.$Stamp/astdb.dump "); if ($provroot ne "") { $excludearg = ""; Index: amp_conf/bin/freepbx_engine =================================================================== --- amp_conf/bin/freepbx_engine (revision 6588) +++ amp_conf/bin/freepbx_engine (arbetskopia) @@ -95,6 +95,7 @@ # Ensure that various hardware devices are owned correctly. [ -e /dev/zap ] && chown -R $AMPDEVUSER:$AMPDEVGROUP /dev/zap + [ -e /dev/dahdi ] && chown -R $AMPDEVUSER:$AMPDEVGROUP /dev/dahdi [ -e /dev/capi20 ] && chown -R $AMPDEVUSER:$AMPDEVGROUP /dev/capi20 [ -e /dev/misdn ] && chown -R $AMPDEVUSER:$AMPDEVGROUP /dev/misdn [ -e /dev/mISDN ] && chown -R $AMPDEVUSER:$AMPDEVGROUP /dev/mISDN Index: amp_conf/bin/libfreepbx.confgen.php =================================================================== --- amp_conf/bin/libfreepbx.confgen.php (revision 6588) +++ amp_conf/bin/libfreepbx.confgen.php (arbetskopia) @@ -169,13 +169,18 @@ } function generate_configurations_zap($ast_version) { - + global $chan_dahdi; global $amp_conf; global $db; $additional = ""; $zap_conf = $amp_conf['ASTETCDIR']."/zapata_additional.conf"; + $channel_name = 'ZAP'; + if ($chan_dahdi) { + $zap_conf = $amp_conf['ASTETCDIR']."/chan_dahdi_additional.conf"; + $channel_name = 'DAHDI'; + } $table_name = "zap"; @@ -183,7 +188,7 @@ $zap_conf_fh = fopen($zap_conf,"w"); if ($zap_conf_fh === false) { - fatal(_("Cannot write ZAP configurations"),sprintf(_("Failed creating/overwriting Zapata extensions file: %s"),$zap_conf)); + fatal(_("Cannot write $channel_name configurations"),sprintf(_("Failed creating/overwriting $channel_name extensions file: %s"),$zap_conf)); } fwrite($zap_conf_fh, $warning_banner); Index: amp_conf/bin/retrieve_conf =================================================================== --- amp_conf/bin/retrieve_conf (revision 6588) +++ amp_conf/bin/retrieve_conf (arbetskopia) @@ -369,6 +369,7 @@ // was setting these variables before, assume we still need them $engine = $engineinfo['engine']; $version = $engineinfo['version']; +$chan_dahdi = ast_with_dahdi(); // Check for and report any extension conflicts //