Content
To make use of dynamic information the content of certain elements and attributes are evaluated in order to translate special callback expressions. They have the form $(name) or $(name:arg) and are dynamically replaced by their return values.
Things to consider when writing callbacks:
- Callbacks argument: necessity of an argument, limitations on the argument.
- Extra white space on callbacks name and argument: see Common errors.
- Character case of the callback and its argument
- There are 2 types of callback placeholders, $(...) and $[...]. The difference between them is shown below
- Callbacks can be stacked on top of each other, for example: $(callback2:$(callback1:param))
Common errors
Here are some examples of common errors:
Correct syntax:
$(max_registrations) $(set:vol_speakers)
Examples of errors:
Error Example | Error Description |
---|---|
$ (max_registrations) | whitespace |
$( max_registrations) | whitespace |
$(max_registrations ) | whitespace |
$(max_registrations:argument) | unnecessary argument |
$(set :vol_speaker) | whitespace |
$(set: vol_speaker) | whitespace |
$(set:vol_speaker ) | whitespace |
$(set) | missing argument |
Available callbacks
Each link to the callbacks from the list below contain details and/or examples. Some of the examples use telephone specific settings, thus their results may differ for various Snom phones.
Callback Name | Description |
---|---|
arch_series | Returns the device architecture (Example architectures: snomD3X5, snomD7XX etc) |
bool_eval | Returns the boolean value for true or false value |
checkbox_property | Returns if the checkbox property is available on this phone (available, none). The phones in black and white display with bdf font have this property available, for example: D745, D345 etc. |
condition | Returns "1" if the condition is true, else "0". This is the callback version of the attribute of the same name here. All the rules from the condition attribute from the If tag are also valid here. |
create_url | Creates an URL out of the parameter |
current_input | Returns the current minibrowser input |
current_line | Returns the current line of 1-12 (active user id) |
date | Return the current date |
time | Returns the current time |
display_type | Returns the display type of phone: color_touch, color, greyscale, monochrome, character, none |
edit_mode | Returns the current edit mode of the system. Possible values are: 0 (for mode 123), 1 (for mode abc), 2 (for mode ABC) |
next_edit_mode | Returns the next edit mode of the system. Possible values are: 0 (for mode 123), 1 (for mode abc), 2 (for mode ABC) |
empty | Returns true or false depending if arg is a an empty string |
enum | Returns an enumeration out of parameter start[:end[:step]] . Ex: $(enum:$(max_registrations)) = |1|2|3|4|5|6|7|8|9|10|11|12| |
fragment | Returns the corresponding value for the given key from the current uri fragment |
key_icon_type | Returns the icon used for a key type |
key_setting | Returns the name of the setting which defines a key |
is_context_sensitive_key | Returns true if the given key is a context-sensitive key |
is_dkey | Returns true if the given key is a dedicated key |
lang | Returns the localized gui string for a given language key |
lastsel | Returns the data of the selected list item. (Sometimes it's the id attribute of the last MenuItem) |
sel | Returns the data of the selected list item. (Sometimes it's the id attribute of a MenuItem) |
starts_with | Returns if the given string (first parameter) starts with the value of the second parameter; example: |
lines | Returns number of calls |
list_size | Returns the number of listed items |
cb_math_eval | Evaluate the parameter into a math result |
max_registrations | Returns the number of maximum registrations |
max_pkey_units | Returns the number of function key units |
pkey_unit_name | Returns the key unit name for a given function key unit |
max_pkeys | Returns the number of maximum keys for a given function key unit |
mod_ifc | Return boolean value if module (or module's variable) exists |
on_off | Returns the localized string of an on/off for boolean value |
phone_state | Returns the current phone state |
remove_cmd | Command to remove leading cmd of fkeys setting (Ex: remove the "blf" in "blf 123@1.2.3.4") |
get_cmd | Command to fetch the leading cmd of fkeys setting (Ex: fetch the text "blf" in "blf 123@1.2.3.4") |
set | Returns the value of a setting |
setcache | Returns the corresponding value for the given setting in the settings cache |
show_feature | Return true or false depend if feature is activated or exist |
status_message | Returns the status message |
tbook_entry_data | Returns a non empty string if the given parameter exists in the local TBook, example: $(tbook_entry_data:<PHONENUMBER>) |
urlencode | Returns the argument URL-encoded |
user_displayname | Returns the displayname of given identity |
var | Returns the corresponding value for the given variable in the variables cache |
var_ifc | Ask the value of a variable from telephone modules |
wifiscan | Scans for available WIFI SSIDs and returns them as a list |
wlang | Returns the localized web string for a given language key |
x_o | Returns checked or unchecked character for boolean value |
yes_no | Returns the localized string of yes/no for boolean value |
Differences between placeholders
Callback can be used with two different placeholders, $(...) and $[...]. The main difference between them is the time when the value will be fetched.
In the following example:
<?xml version="1.0" encoding="UTF-8"?> <SnomIPPhoneBatch> <SnomIPPhoneMenu id="menu"> <MenuItem name="mi1" id="mi1"> <Url>http://link_to_this_example.xml#sub=*[@id="text"]&var:text=$[sel]</Url> </MenuItem> <MenuItem name="mi2" id="mi2"> <Url>http://link_to_this_example.xml#sub=*[@id="text"]&var:text=$[sel]</Url> </MenuItem> <MenuItem name="mi3" id="mi3"> <Url>http://link_to_this_example.xml#sub=*[@id="text"]&var:text=$[sel]</Url> </MenuItem> </SnomIPPhoneMenu> <SnomIPPhoneText id="text"> <Text>selected id = $(var:text)</Text> </SnomIPPhoneText> </SnomIPPhoneBatch>
In the first page the sel callback is not yet replaced. But after one of the MenuItem is selected, the sel callback will be replaced with the selected MenuItem id and it will be printed on second page through the var callback.
Result:
Encoding and callbacks
It is important to understand how encoding and callbacks interact. This behavior is relevant for cases when the returned value of the callback would break the URL format or the value might/will change but we still wish to hand over the changed value (for example, when using translation or templates).
We will illustrate this behavior with an example. In this example, we have a callback result that, when used in an URL, would break the URL format. Let's assume that we would like to display a MenuItem which takes its name using the lang callback. The name of the MenuItem should be the translated name of the country"Trinidad & Tobago". The name of this country contains space and '&', which are both not allowed in a URL.
Here is the example code:
<?xml version="1.0" encoding="UTF-8"?> <SnomIPPhoneMenu> <MenuItem name="First example $(var:b)"> <url>phone://mb_nop#var:b=%24(lang:lang_cntry_TTB)</url> </MenuItem> <MenuItem name="Second example $(var:b)"> <url>phone://mb_nop#var:b=$(lang:lang_cntry_TTB)</url> </MenuItem> </SnomIPPhoneMenu>
The code contains two MenuItem examples. The only difference between them is the usage of the dollar sign:
- In the First example, the dollar sign is URL-encoded, which causes the Minibrowser to store the callback in the variable b
- In the Second example, the dollar sign is not encoded, which causes the Minibrowser to store the result of the callback in the variable b
To see the effect of this difference, open first this Minibrowser page, choose the First example and press OK. The phone will show:
Then open the State page and look at the end of the page. You will see:
Selection list: 2 ----------------- ## First example Trinidad & Tobago data: _xpath:/* _url:phone://mb_nop#var:b=%24(lang:lang_cntry_TTB) _track: _id_attr:name _id:First example $(var:b) ## Second example Trinidad & Tobago data: _xpath:/* _url:phone://mb_nop#var:b=Trinidad & Tobago _track: _id_attr:name _id:Second example $(var:b) Callbacks: 2 ------------- $.current_path $.module_id_of_current_line Minibrowser vars: 2 --------------------- cur_pkey: b: $(lang:lang_cntry_TTB)
Look at line 24 above, at the value of variable b. Because we chose the first example, the phone shows the full name of the country, "Trinidad & Tobago". Because the dollar sign for the lang callback is URL-encoded using '%24' (%24(lang:lang_cntry_TTB)), the callback was stored in the variable b, and the callback was parsed later, when the URL was called.
Close the Minibrowser page. Then open it again, choose the Second example and press OK. The phone will show:
Then open again (or refresh) the State page and look at the of the page. You will see:
Selection list: 2 ----------------- ## First example Trinidad data: _xpath:/* _url:phone://mb_nop#var:b=%24(lang:lang_cntry_TTB) _track: _id_attr:name _id:First example $(var:b) ## Second example Trinidad data: _xpath:/* _url:phone://mb_nop#var:b=Trinidad & Tobago _track: _id_attr:name _id:Second example $(var:b) Callbacks: 2 ------------- $.current_path $.module_id_of_current_line Minibrowser vars: 2 --------------------- cur_pkey: b: Trinidad
- Look at line 24 above, at the value of variable b. Because we chose the second example, the phone shows only the first part of the country name, "Trinidad".
- Because the dollar sign for the lang callback is not URL-encoded ($(lang:lang_cntry_TTB)), the result of the callback was stored in the variable b, which was "Trinidad & Tobago".
- And then, when the URL was built using the value of b, the URL was "phone://mb_nop#var:b=Trinidad & Tobago", which was an incorrect URL (broken by the un-encoded space).
- As a result, the URL became "phone://mb_nop#var:b=Trinidad".
Further Information
Related articles