Changeset 4055

Show
Ignore:
Timestamp:
01/17/09 00:10:18 (4 years ago)
Author:
frogonwheels
Message:

Allow specifying the target type together with the target in the dialplan extension (rather than having a sep variable)..
Move incoming_context functions here from sipiaxconf.
Allow incoming target to have different formats for the type/target, and convert it to TYPE/target.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/contrib/package/asterisk-xip/files/uci/dialplanconf

    r4031 r4055  
    218218        eval "dialz=\${dzone_match_use_${zonename}-}" 
    219219 
     220        logdebug 3 "Find international options for zone ${zonename} from ${dialz}" 
    220221        for v in prefix internationalprefix alwaysinternational countrycode ; do 
    221222            eval "local $v=\${target_${v}_${dialz}:-}" 
     
    252253                cur="${diallist%%,*}" 
    253254                nvar="${diallist#*,}" 
     255                logdebug 4 "Adding international ${cur}" 
    254256 
    255257                local curlen=`expr length "${cur}"` 
     
    638640    if [ ! -z "${dial_exten_dialplan}" -a ! -z "${dial_exten_extension}" ] ; then 
    639641 
    640         local dialtarget=${dial_exten_type}/${dial_exten_dialextension+@}${dial_exten_dialextension}${dial_exten_target} 
     642        local dialext_type= 
     643        local dialext_ext= 
     644        if ! split_targettype dialext_type dialext_ext "${dial_exten_target}" ; then 
     645            if [ -z "${dial_exten_type}" ] ; then 
     646                logerror "No extension type specified for ${dial_exten_dialplan} ${dial_exten_extension}" 
     647                return 1 
     648            fi 
     649            dialext_type="${dial_exten_type}" 
     650            dialext_ext="${dial_exten_target}" 
     651        fi 
     652 
     653 
     654        local dialtarget="${dialext_type}/${dialexten_ext}${dial_exten_dialextension+/}${dial_exten_dialextension}" 
    641655 
    642656        check_add_context ${dial_exten_dialplan} 
     
    692706        case $1  in 
    693707            uses) 
    694                 local areatype=${2%[-/]*} 
    695                 local areaname=${2#*[-/]} 
     708                local areatype= 
     709                local areaname= 
     710                split_targettype areatype areaname "$2" 
    696711                logdebug 3 "Added: $areatype $areaname" 
    697712                eval "local isadded=\"\${dzone_${areatype}_${areaname}-0}\"" 
     
    769784} 
    770785 
     786add_incoming_context() { 
     787    local context=$1 
     788    eval "local added=\${dialplan_incoming_${context}_added}" 
     789    if [ "${added}" != "1" ] ; then 
     790        append dialplan_extensions_incoming "${context}" " " 
     791        eval "dialplan_incoming_${context}_added=1" 
     792    fi 
     793 
     794} 
     795 
     796# Add to incoming ringing 
     797add_incoming() { 
     798    local rhs="$3" 
     799     
     800    while [ ! -z "$rhs" ] ; do 
     801        cur=${rhs%%,*} 
     802        nvar=${rhs#*,} 
     803        add_incoming_context ${cur} 
     804        append dialplan_incoming_${cur} "$1/$2" "&"  
     805        [ "$nvar" == "$rhs" ] && break 
     806        rhs=${nvar} 
     807    done 
     808} 
     809 
     810to_upper() { 
     811    eval "$1=`echo \"$2\"|tr [a-z] [A-Z]`" 
     812} 
     813to_lower() { 
     814    eval "$1=`echo \"$2\"|tr [A-Z] [a-z]`" 
     815} 
     816 
     817split_targettype() { # TYPE target inputEntry 
     818    local l_targettype="${3%[-_/]*}" 
     819    if [ "${l_targettype}" == "$3" ] ; then 
     820        return 1 
     821    fi 
     822    local l_targetname="${3#*[-_/]}" 
     823    to_upper "$1" "${l_targettype}" 
     824    eval "$2=\"${l_targetname}\"" 
     825    return 0 
     826} 
     827 
     828 
    771829handle_incoming() { 
    772830    incoming_context=$1 
     
    786844                ;; 
    787845            target|target_ITEM*) 
    788                 append dialplan_incoming_${incoming_context} "$2" "&" 
     846                local targettype= 
     847                local targetname= 
     848                if split_targettype targettype targetname "${2}" ; then 
     849                    append dialplan_incoming_${incoming_context} "${targettype}/${targetname}" "&" 
     850                else 
     851                    logerror "No target type specified for target=$2 in ${incoming_context}" 
     852                fi 
    789853                ;; 
    790             target_COUNT) ;; 
     854            target_COUNT|member_COUNT) ;; 
    791855            *) logerror "Invalid option $1 in incoming" ;; 
    792856        esac