This dialplan was originally based on work by intralanman however I refactored
what he did so that it was more configurable.  Now instead of requiring multiple
different dialplans you have one and channel variables which lets you set
a per user dial mapping very easily.

I originally started working on this for http://fswebpanel.sf.net a web based 
configuration tool I am working on for FreeSWITCH.  Currently fswebpanel supports
this dialplan, and you can create users that set the variables.  This makes
it much easier to deal with.


=-=-=-=-=-=-=-=-=-=-=-=-=-=-
SCOPE AND PURPOSE
=-=-=-=-=-=-=-=-=-=-=-=-=-=-

This directory is designed to provide drop in replacement dialing plans that 
simulate what the PSTN normally provides.  It is not intended to provide a 
black list of numbers, what may be high cost, etc.  With that said, if you 
want to add variables that would define these things I suggest that you add
them at the end of the file instead of mixed throughout.  This makes it 
easier if someone wants a clean dialplan vs someone who wants to implement 
advanced features.

The reason to make a dialplan that matches what the traditional phone company
does is simply so that users feel more comfortable using the phone system.
It is bothersome, to me at least, to have to learn a whole new way to place
calls, especially when it is trivial to map what I dial as a user to what
some foreign system expects.



=-=-=-=-=-=-=-=-=-=-=-=-=-=-
EXPLANATION OF DIALPLAN
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
There are multiple files and it can become a little confusing, so I will attempt
to explain how to use this information should you decide to.  My hope is that it
will eventually be part of the default config, until then you must manually
configure this.

localized.dialplan.xml is a DIALPLAN file.  You must edit your dialplan,
typically in INSTALL/conf/dialplan/default.xml where INSTALL is your
install directory (eg /usr/local/freeswitch on unix like systems).

If you want this to be used *with* your default context you must remove
the lines


<context name="default">
</context>

and place the remainder in the default context tags.  


They have their own context tags so that they may be used seperately
should you opt to do that.  





-=- IMPORTANT -=- IMPORTANT -=- IMPORTANT -=- IMPORTANT -=- IMPORTANT -=- 

dont just leave regexps undefined that may cause matches to occur that 
shouldnt.  Instead use the regexp DONT_MATCH_ME or something similar that will 
never cause a match.  dialplan.es.xml uses this if you need an example 

-=- IMPORTANT -=- IMPORTANT -=- IMPORTANT -=- IMPORTANT -=- IMPORTANT -=- 



=-=-=-=-=-=-=-=-=-=-=-=-=-=-
EXPLANATION OF THE VARIABLE FILES
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
There are several variable files, one for a given region that has been done
so far.  These variables are used by the dialplan to figure out how to
deal with a call.  An attempt is made to query enum, if that fails
then it will use the default gateway that is defined.

You may set these variables globally by setting it for the domain, or you
may set them on a per user basis from the user directory.  Or a mix, user vars
override the domain.  The option is yours.

There are two types of variables, static which are simply strings, 
and regexps.  Due to the way variables are used you should not 
attempt to use a regexp unless it is indicated that it is a regexp.

<!--
TYPE: static
anything that gets sent before the E.164 formatted number to the provider
If you dont need anything leave it blank
-->
<variable name="dial_prefix" value=""/>

<!--
TYPE: static
Whether or not to use enum
-->
<variable name="use_enum" value="true"/>

<!--
TYPE: static
The name for the gateway to send calls to if ENUM fails
This name would be defined in your sip profile.
-->
<variable name="default_gateway" value="telco.com"/>



<!--
TYPE: static
This is the country code, it should be numeric only and static
-->
<variable name="default_country_code" value="31"/>



<!--
TYPE: static
This is the international prefix.  This is static data
-->
<variable name="default_international_prefix" value="00"/>

<!--T
TYPE: regexp
this matches international dialing.  In this example I dial
00 country code & number for international calls. This matches 
everything except the 00 so that an ENUM lookup can be performed
-->
<variable name="default_international_regexp" value="^00(\d+)$"/>


<!--
TYPE: regexp
This matches when I dial out of my 'area'.  For example if I am in Cork, 
Ireland, and I want to call a mobile phone I dial 08...  The leading '0' 
indicates that I am calling outside my local area (Cork is '20') to '8'.
We need to strip off the '0' since it is just a dialing prefix and not 
part of the number itself
-->
<variable name="default_domestic_regexp" value="^0([1-9]\d+)$"/>



<!--
TYPE: static
This is the local prefix.  For example, in Ireland
if I am in Cork my 'city code' is 20.  If I dial
a local number I do not have to dial the '20'.  This is 
used for enum to work on a 'local' call.
-->
<variable name="default_local_prefix" value="20"/>



<!--
TYPE: regexp
This is what would match if I am in Cork and call someone else
who is in Cork.  The default_local_prefix variable is used to
make a full ENUM number.
-->
<variable name="default_local_regexp" value="^([1-9]\d+)$"/>



<!--
TYPE: regexp
This is what matches to route a call to emergency services.
It may optionally be used for more services than that, it is just 
directly routed without enum.  For Europe generally 112 will work, for
North America 911 will work.  This can be a regexp which will allow for
routing of say 611 (repair), 411 (information), 911 (emergency) in
NANPA.
-->
<variable name="default_emergency_number" value="^112$"/>


=-=-=-=-=-=-=-=-=-=-=-=-=-=-
HOW TO MAKE A DIALPLAN
=-=-=-=-=-=-=-=-=-=-=-=-=-=-

This is quite simple, just copy one of the existing dialplan.XX.xml files
to dialplan.YY.xml where YY is the 2 letter country code for the area you
are going to do.  For Europe the NL one will likely be correct for all but
the country code.

The reason to use the 2 letter ISO country code (IE - Ireland, UK - United Kingdom
ES - Spain, etc) is so that everything is standardized and generally a fixed length.
One exception I am aware of is NANPA which is 18 or so countries (all country code '1')
Since there are multiple countries the numbering authority is used instead.

Please keep all filenames in lowercase.  This helps with sorted lists, since
an ASCII sort would split entries that have different cases when they should
otherwise be next to each other.

Now that you have a new file, simply edit the values and you are done.  If you share
this information then others may more easily have a dialing plan that works the way
they expect it to.  

DONT FORGET TO ADD YOUR NAME IN COMMENTS AT THE TOP OF THE FILE.  I cannot
possibly know every dialing plan that exists, and for now since I am maintaining
this, someone may have a question about something that I wont be able to answer.
It would be best if they could get hold of you directly to resolve any issues
that may arise.

Email the file to trixternospam@0xdecafbad.com and I will add it here.  Eventually
there will be a place with fswebpanel to provide this information, and its possible
that this may be merged into FS trunk, when either of those happen I will close this
area down and request that they be filed directly where they can be used by more
people more easily.
