Robert Joly wrote:
> Hi,
> I need to modify the Freeswitch default context generated by sipXconfig
> to include a line that is going to assist in entering conferences
> without being prompted by a PIN.  Ultimately, I want the generated
> output to contain a line of the form:
> 
>       <action application="set" data="supplied_pin=${sip_h_X-ConfPin}"/>
> 
> I thought that doing this would be a simple matter of modifying the
> .../neoconf/etc/freeswitch/default_context.xml.vm to include that line
> until I realized that the line I want ot add contains a
> "${sip_h_X-ConfPin}" string which collides with the syntax that Velocity
> employs for variables. For the reference, "${sip_h_X-ConfPin}" is a
> construct that is useful to freeswitch and therefore needs to appear
> verbatim in the generated output.
> 
> I started looking at character escaping in Velocity and saw that the '\'
> is used for escaping reserved characters.  In that spirit, I modified
> the default_context.xml.vm file to include the following line:
> 
>       <action application="set"
> data="supplied_pin=\$\{sip_h_X-ConfPin\}"/>
> 
> ...but to my surprise, the generated output didn't escape anything:
> 
>       <action application="set"
> data="supplied_pin=\$\{sip_h_X-ConfPin\}"/>
> 
> I then took out all escaping in the default_context.xml.vm and was left
> with the following line:
> 
>       <action application="set" data="supplied_pin=${sip_h_X-ConfPin}"/>
> 
> ...and to my surprise, the generated output was exactly what I need:
> 
>       <action application="set" data="supplied_pin=${sip_h_X-ConfPin}"/>
> 
> After consulting with Huijun, the best exaplaination is that Velocity
> didn't see ${sip_h_X-ConfPin} as a defined variable for the context and
> therefore left it unsustituted.  Although this is producing the output I
> ultimately want, I have a feeling that this is not the best way to
> achieve this for a person 'skilled in the art' and is why I'm turning to
> the list.  What is the correct way of creating a Velocity template such
> the the generated output will be <action application="set"
> data="supplied_pin=${sip_h_X-ConfPin}"/>?
> 


Escaping in VTL is not really implemented correctly and relying on variable
not being in the context is kind of scary.
So after many attempts to find a more elegant solution we ended up using
$dolar variable. It's available automatically in the context (sipXconfig
adds it).

You should use:
<action application="set" data="supplied_pin=${dollar}{sip_h_X-ConfPin}"/>

BTW: I am pretty sure this technique is used in default_context.xml.vm

D.

_______________________________________________
sipx-dev mailing list [email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-dev
Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-dev
sipXecs IP PBX -- http://www.sipfoundry.org/

Reply via email to