Summary:ASTERISK-04737: [patch] Func_tonezone: COUNTRY
Reporter:Olle Johansson (oej)Labels:
Date Opened:2005-07-30 09:43:45Date Closed:2011-06-07 14:02:35
Versions:Frequency of
Environment:Attachments:( 0) func_tonezone.c
Description:This function sets or reads the channels default country for indications. If you use Asterisk for serving many countries, you want to be able to set the country in order to play the proper dial tone in disa etc.
Comments:By: Tilghman Lesher (tilghman) 2005-07-30 16:03:39

1.  Since it's func_tonezone, why not call the function TONEZONE ?
2.  Your description says that that the function can both retrieve and set the tonezone, but your implementation lacks code to set it.

By: Olle Johansson (oej) 2005-07-31 04:29:07

1. Due to the fact that the setting in indications conf is country=
2. Have you tested? Running COUNTRY(se) sets the tonezone, running COUNTRY() retrieves the tonezone. Actually, we always return the current tonezone.

By: Tilghman Lesher (tilghman) 2005-07-31 10:13:18

There's a separate routine for that.  You have not populated the .write portion of the ast_custom_function structure, which is the routine called when you do this:


I think it just sounds better to do:


because we could be using tonezones outside of a specific country.

By: Olle Johansson (oej) 2005-07-31 10:30:43

Seems like we need to set a syntax here, since other function work the same way - I copied from existing code.

If we change to tonezone, we need to change indications.conf as well... It's the same setting, can't use two different names for it.

By: Tilghman Lesher (tilghman) 2005-07-31 10:59:10

Which functions did you copy from, because they need to be fixed.  The "write" element of the ast_custom_function is used when functions are used as an lvalue, which is how we set values to functions.  The arguments to the functions are to be used as parameters, not as settable values, e.g.:


Come to think of it, we should probably do


for this function.  As an extension to this, we could have a COUNTRY function that allows us to reset certain things about a country's tonezone, e.g.:

${COUNTRY(us,ringcadence)} ; Retrieves the ringcadence for the US.

By: Olle Johansson (oej) 2005-07-31 11:29:44

Why tonzone(country)=se ? That syntax seems awfully complex. What other values could the tonezone function have?

(Already, assigning values to functions like function()= doesn't look like any other language I can think of and will be hard to teach... But that's too late to discuss, I guess).

DO you agree that we need to change indications.conf as well?

By: Tilghman Lesher (tilghman) 2005-07-31 16:24:37

1.  I don't know offhand, but I'm sure somebody will think of something.
2.  I teach others, myself, and I don't think it's hard to teach someone that a function can be an lvalue, any more than it's hard to teach that a variable may be both an lvalue as well as an rvalue.
3.  I don't agree that indications.conf necessarily needs to be changed.

By: Kevin P. Fleming (kpfleming) 2005-08-22 18:56:43

What is the status of this one? I agree with Corydon on the recommended syntax changes for the function (but not for indications.conf until after 1.2 is released).

I think using TONEZONE(country) makes the most sense, since it allows us to extend the syntax in the future as suggested.

By: Michael Jerris (mikej) 2005-09-02 20:18:56

Suspended due to no response.  Re-open when you have updates ready.  Thanks.