[Home]

Summary:ASTERISK-11063: [patch] Add a new function to check if a extension[,priority] exits in a context
Reporter:Gregory Hinton Nietsky (irroot)Labels:
Date Opened:2007-12-17 09:11:36.000-0600Date Closed:2007-12-26 12:50:57.000-0600
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Functions/NewFeature
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) func_dialplan.c
( 1) func_dialplan2.c
Description:this is a wrapper to ast_exists_extension and/or ast_findlabel_extension

this will be used to avoid goto falling off the map/hanging up ... if there is no extension

ie

exten =>t,n,
GotoIf(${ISEXTEN(ivr-${IVRCONT},${NEWUEXTEN})}?ivr-${IVRCONT},${NEWUEXTEN},1)

will work or continue on to next priority or alternate

****** ADDITIONAL INFORMATION ******

personally i dont like it one bit ;) as it can be hit on the system if there many contexts however i find it invaluable when dealing with realtime ivr menu's that users add on the fly.

it may not be everyone's cup a tea but i see it as somthing lacking in asterisk.

id like to add some more bits to this func such as spawning a extension ...
Comments:By: Gregory Hinton Nietsky (irroot) 2007-12-17 10:51:41.000-0600

here is a much improved cleaned up version that checks labels or priority numbers properly.

would be useful to have a ast_exists_context function to check just the context will submit it if wanted ...

By: Gregory Hinton Nietsky (irroot) 2007-12-17 11:16:24.000-0600

here is a piece of dialplan that listens for a single key and when a match is found dispatches it a dialplan replacement for WaitExten used with background/playtones

exten => _X,1,GotoIf(${EXISTS(${UEXTEN})}?add)
exten => _X,n,SET(UEXTEN=${EXTEN})
exten => _X,n,Goto(tryivr)
exten => _X,n+1(add),SET(UEXTEN=${UEXTEN}${EXTEN})
exten => _X,n,Goto(tryivr)
exten => _X,n+1(tryivr),GotoIf(${ISEXTEN(ivr-${IVRCONT},${UEXTEN})}?gotoivr)
exten => _X,n+1(gotoivr),SET(NEWUEXTEN=${UEXTEN})
exten => _X,n,SET(UEXTEN=)
exten => _X,n,Goto(ivr-${IVRCONT},${NEWUEXTEN},1)

By: Tilghman Lesher (tilghman) 2007-12-17 11:26:42.000-0600

I would suggest the following changes:

1) Name it "DP_EXISTS" or "DIALPLAN_EXISTS".
2) Make the second argument optional, too.  If you only have a single argument, use the API functions to traverse the context list, comparing each name.  You can view the code in apps/app_while.c for an example of how to do this.

By: Olle Johansson (oej) 2007-12-18 02:21:23.000-0600

Add context too, so we adhere to the labels used in goto commands.

We should be able to use

priority
exten,priority
context,exten,priority

This function is a bti interesting in combinations with switches like the IAX2 switch or dundi.

By: Tilghman Lesher (tilghman) 2007-12-18 09:05:05.000-0600

oej:  I disagree.  The purpose here is to be able to see if something exists, so you may want to find out only if a context exists, so DIALPLAN_EXISTS(context) is a logical command.  You do not want to have to specify extension and priority for that.

By: Olle Johansson (oej) 2007-12-18 09:14:18.000-0600

I agree with you and disagree with myself.

I just copied the current syntax of goto() etc labels without turning on my poor brain.

By: Gregory Hinton Nietsky (irroot) 2007-12-19 01:56:55.000-0600

id like to propose

ast_exists_context function in pbx.c unless there alternatives doing this will allow access to the cache and ast_context that are exposed.

im not arround much at the moment silly season and all will do this tommorow unless there objections.

i vote for DP_EXISTS shorter and the letters are worn off my keyboard already ;)

another use of this function is to circumvent users pressing duplicates in the IVR thinking there first press did not go through. check and if there proceed with double otherwise if exits proceed with single press ....

thx for the intrest

By: Tilghman Lesher (tilghman) 2007-12-19 11:40:17.000-0600

Just use ast_context_find().  It returns a non-NULL pointer if the named context exists.

By: Digium Subversion (svnbot) 2007-12-26 12:50:57.000-0600

Repository: asterisk
Revision: 94799

U   trunk/CHANGES
A   trunk/funcs/func_dialplan.c

------------------------------------------------------------------------
r94799 | russell | 2007-12-26 12:50:56 -0600 (Wed, 26 Dec 2007) | 9 lines

Add a new dialplan function, DIALPLAN_EXISTS(), which allows you to check for
the existence of a dialplan target.

(closes issue ASTERISK-11063)
Reported by: irroot
Patches:
     func_dialplan2.c uploaded by irroot (license 52)
 -- Additional changes by me.

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=94799