Sponsor: VoiceMeUp - Corporate & Wholesale VoIP Services

VoIP Mailing List Archives
Mailing list archives for the VoIP community
 SearchSearch 

[asterisk-users] Conditional include=> ?


 
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> Asterisk Users
View previous topic :: View next topic  
Author Message
davies147 at gmail.com
Guest





PostPosted: Tue Apr 22, 2008 3:55 am    Post subject: [asterisk-users] Conditional include=> ? Reply with quote

Hi,

Does anyone have a clever method of doing a conditional "include =>"
line in the dialplan?

I want to include a bunch of standard contexts, but in the middle of
the bunch have one or more conditionally included, a bit like:

[default]
include => start-here
include => then-here
if $[{COMPANY} = A]
include => company-A
endif
if $[{COMPANY} = B]
include => company-B
endif
if $[{COMPANY} = C]
include => company-C
endif
include => end-here
The list of conditional variables, and of static includes is
potentially large, so I do not want to create several separate sets of
contexts with lots of repetition as it is likely to get out-of-control
very quickly.

Help?
Steve
Back to top
tzafrir.cohen at xorco...
Guest





PostPosted: Tue Apr 22, 2008 4:06 am    Post subject: [asterisk-users] Conditional include=> ? Reply with quote

On Tue, Apr 22, 2008 at 09:55:37AM +0100, Steve Davies wrote:
Quote:
Hi,

Does anyone have a clever method of doing a conditional "include =>"
line in the dialplan?

I want to include a bunch of standard contexts, but in the middle of
the bunch have one or more conditionally included, a bit like:

[default]
include => start-here
include => then-here
if $[{COMPANY} = A]
include => company-A
endif
if $[{COMPANY} = B]
include => company-B
endif
if $[{COMPANY} = C]
include => company-C
endif
include => end-here


The list of conditional variables, and of static includes is
potentially large, so I do not want to create several separate sets of
contexts with lots of repetition as it is likely to get out-of-control
very quickly.

A different approach:

[company-base](!)
; common settings

[company-A](company-base)
; specific for company A

[company-B](company-base)
; specific for company B

[company-C](company-base)
; specific for company C
Keep in mind you can also use:

[sub-template](!,base-template)

And:

[context](template1,template2)

But one limitation is that you can only add: no way to remove line added
by a template your context uses.

--
Tzafrir Cohen
icq#16849755 jabber:tzafrir.cohen at xorcom.com
+972-50-7952406 mailto:tzafrir.cohen at xorcom.com
http://www.xorcom.com iax:guest at local.xorcom.com/tzafrir
Back to top
philipp.kempgen at amo...
Guest





PostPosted: Tue Apr 22, 2008 4:55 am    Post subject: [asterisk-users] Conditional include=> ? Reply with quote

Steve Davies schrieb:

Quote:
Does anyone have a clever method of doing a conditional "include =>"
line in the dialplan?

I want to include a bunch of standard contexts, but in the middle of
the bunch have one or more conditionally included, a bit like:

[default]
include => start-here
include => then-here
if $[{COMPANY} = A]
include => company-A
endif
if $[{COMPANY} = B]
include => company-B
endif
if $[{COMPANY} = C]
include => company-C
endif
include => end-here


The list of conditional variables, and of static includes is
potentially large, so I do not want to create several separate sets of
contexts with lots of repetition as it is likely to get out-of-control
very quickly.

I suppose #ifdefs and a preprocessor like cpp is not what you're
looking for? You didn't make clear at what stage you want these
includes to be replaced / evaluated. I guess you want Asterisk to
do it.

Regards,
Philipp Kempgen

--
amooma GmbH - Bachstr. 126 - 56566 Neuwied - http://www.amooma.de
Let's use IT to solve problems and not to create new ones.
Asterisk? -> http://www.das-asterisk-buch.de

Gesch?ftsf?hrer: Stefan Wintermeyer
Handelsregister: Neuwied B 14998
Back to top
davies147 at gmail.com
Guest





PostPosted: Tue Apr 22, 2008 9:50 am    Post subject: [asterisk-users] Conditional include=> ? Reply with quote

2008/4/22 Philipp Kempgen <philipp.kempgen at amooma.de>:
Quote:
Steve Davies schrieb:



Quote:
Does anyone have a clever method of doing a conditional "include =>"
line in the dialplan?

I want to include a bunch of standard contexts, but in the middle of
the bunch have one or more conditionally included, a bit like:

[default]
include => start-here
include => then-here
if $[{COMPANY} = A]
include => company-A
endif
if $[{COMPANY} = B]
include => company-B
endif
if $[{COMPANY} = C]
include => company-C
endif
include => end-here


The list of conditional variables, and of static includes is
potentially large, so I do not want to create several separate sets of
contexts with lots of repetition as it is likely to get out-of-control
very quickly.

I suppose #ifdefs and a preprocessor like cpp is not what you're
looking for? You didn't make clear at what stage you want these
includes to be replaced / evaluated. I guess you want Asterisk to
do it.

Regards,
Philipp Kempgen

I would be looking for a runtime evaluation based on a variable. I'll
take a look at Tzafrir's suggestion and try to undesrstand it Smile

Steve
Back to top
davies147 at gmail.com
Guest





PostPosted: Tue Apr 22, 2008 9:51 am    Post subject: [asterisk-users] Conditional include=> ? Reply with quote

2008/4/22 Tzafrir Cohen <tzafrir.cohen at xorcom.com>:
Quote:

On Tue, Apr 22, 2008 at 09:55:37AM +0100, Steve Davies wrote:
Quote:
Hi,

Does anyone have a clever method of doing a conditional "include =>"
line in the dialplan?

I want to include a bunch of standard contexts, but in the middle of
the bunch have one or more conditionally included, a bit like:

[default]
include => start-here
include => then-here
if $[{COMPANY} = A]
include => company-A
endif
if $[{COMPANY} = B]
include => company-B
endif
if $[{COMPANY} = C]
include => company-C
endif
include => end-here


The list of conditional variables, and of static includes is
potentially large, so I do not want to create several separate sets of
contexts with lots of repetition as it is likely to get out-of-control
very quickly.

A different approach:

[company-base](!)
; common settings

[company-A](company-base)
; specific for company A

[company-B](company-base)
; specific for company B

[company-C](company-base)
; specific for company C


Keep in mind you can also use:

[sub-template](!,base-template)

And:

[context](template1,template2)

But one limitation is that you can only add: no way to remove line added
by a template your context uses.


That sounds interesting, though I am not aware of that format - Guess
I'll go look it up in the WiKi Smile

Thanks,
Steve
Back to top
raanders at acm.org
Guest





PostPosted: Tue Apr 22, 2008 10:57 am    Post subject: [asterisk-users] Conditional include=> ? Reply with quote

Steve Davies wrote:
Quote:
2008/4/22 Tzafrir Cohen <tzafrir.cohen at xorcom.com>:
Quote:
On Tue, Apr 22, 2008 at 09:55:37AM +0100, Steve Davies wrote:
Quote:
Hi,

Does anyone have a clever method of doing a conditional "include =>"
line in the dialplan?

I want to include a bunch of standard contexts, but in the middle of
the bunch have one or more conditionally included, a bit like:

[default]
include => start-here
include => then-here
if $[{COMPANY} = A]
include => company-A
endif
if $[{COMPANY} = B]
include => company-B
endif
if $[{COMPANY} = C]
include => company-C
endif
include => end-here


The list of conditional variables, and of static includes is
potentially large, so I do not want to create several separate sets of
contexts with lots of repetition as it is likely to get out-of-control
very quickly.

A different approach:

[company-base](!)
; common settings

[company-A](company-base)
; specific for company A

[company-B](company-base)
; specific for company B

[company-C](company-base)
; specific for company C


Keep in mind you can also use:

[sub-template](!,base-template)

And:

[context](template1,template2)

But one limitation is that you can only add: no way to remove line added
by a template your context uses.


That sounds interesting, though I am not aware of that format - Guess
I'll go look it up in the WiKi Smile

It was a nice surprise I got while reading the downloaded version of
"Asterisk: The Future of Telephony." Not sure if it is in the Wiki as
the PDF version works fine until my dead-tree version arrives. I didn't
even look.
Rod
--
Quote:

Thanks,
Steve

_______________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
Back to top
davies147 at gmail.com
Guest





PostPosted: Wed Apr 23, 2008 4:25 am    Post subject: [asterisk-users] Conditional include=> ? Reply with quote

2008/4/22 Tzafrir Cohen <tzafrir.cohen at xorcom.com>:
[snip]
Quote:

A different approach:

[company-base](!)
; common settings

[company-A](company-base)
; specific for company A

[company-B](company-base)
; specific for company B

[company-C](company-base)
; specific for company C


Keep in mind you can also use:

[sub-template](!,base-template)

And:

[context](template1,template2)

But one limitation is that you can only add: no way to remove line added
by a template your context uses.

Wow! That took some finding, as it is little more than a footnote
(page 115-116 of "Asterisk: The Future of Telephony") but is a
fantastic feature...

Given that I am using "include =>" statements, and the order of the
includes is significant, do you know what order lines from templates
are included? I will check the code, but can I assume that

[template1](!)
include => template1-patterns

[template2](!)
include => template2-patterns

[context](template1,template2)
include => context-patterns
It the same as:
[context]
include => template1-patterns
include => template2-patterns
include => context-patterns

and always in that order? Is this feature well used and well tested???

Thanks,
Steve
Back to top
asterisk.org at sedwar...
Guest





PostPosted: Wed Apr 23, 2008 9:44 am    Post subject: [asterisk-users] Conditional include=> ? Reply with quote

On Wed, 23 Apr 2008, Steve Davies wrote:

Quote:
Wow! That took some finding, as it is little more than a footnote
(page 115-116 of "Asterisk: The Future of Telephony") but is a
fantastic feature...

and always in that order? Is this feature well used and well tested???

If you are referring to templates, I have been making heavy use of them
for years.

I just checked one of my production dialplans -- EVERY context used
templates except [general] and [globals].

Here's a snippet:

; templates
[digit-timeout](!)
exten = t,1, goto(${CONTEXT},s,1)
[h](!)
exten = h,1, goto(finish-call,h,1)
[i](!)
exten = i,1, goto(${CONTEXT},s,1)
[max-timeout](!)
exten = T,1, goto(max-time,s,1)
[pound-hangup](!)
exten = #,1, hangup()
[pound-main](!)
exten = #,1, goto(main-menu,s,1)
[s](!)
exten = s,1, verbose(1,${CONTEXT}:${EXTEN}:${PRIORITY})
[x](!)
exten = _x.,1, verbose(1,${CONTEXT}:${EXTEN}:${PRIORITY})

; the main menu
[main-menu](digit-timeout,h,i,max-timeout,pound-main,s)

The templates define the common "1 priority" steps that get included
everywhere. The "real" templates always use the "n priority."

The "order of processing" is as you would expect and is the same between
1.2 and 1.4. Just be careful of using "uninitialized n" priorities. For
example:

[foo]
exten = x,100, this is foo
[t2](!)
exten = x,n, this is t2
[t1](!)
exten = x,n, this is t1
[t3](t1,t2)
exten = x,1, this is t3
exten = x,n, this is also t3

results in:

dt*CLI> show dialplan t3
[ Context 't3' created by 'pbx_config' ]
'x' => 1. this is t3() [pbx_config]
2. this is also t3() [pbx_config]
101. this is t1() [pbx_config]
102. this is t2() [pbx_config]

The "n" priority in [t2] is based on the last seen priority -- the
priority in the unrelated context [foo].

Thanks in advance,
------------------------------------------------------------------------
Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
Back to top
davies147 at gmail.com
Guest





PostPosted: Wed Apr 23, 2008 11:04 am    Post subject: [asterisk-users] Conditional include=> ? Reply with quote

2008/4/23 Steve Edwards <asterisk.org at sedwards.com>:
[big snip]

Steve,

Fantastic examples. Many thanks for the feedback Smile

Regards,
Steve
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> Asterisk Users All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

VoiceMeUp - Corporate & Wholesale VoIP Services