Content

Page tree



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 ExampleError 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 NameDescription
arch_seriesReturns the device architecture (Example architectures: snomD3X5, snomD7XX etc)
bool_evalReturns the boolean value for true or false value
checkbox_propertyReturns 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.
conditionReturns "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_urlCreates an URL out of the parameter
current_inputReturns the current minibrowser input
current_lineReturns the current line of 1-12 (active user id)
dateReturn the current date
timeReturns the current time
display_typeReturns the display type of phone: color_touch, color, greyscale, monochrome, character, none
edit_modeReturns the current edit mode of the system. Possible values are: 0 (for mode 123), 1 (for mode abc), 2 (for mode ABC)
next_edit_modeReturns the next edit mode of the system. Possible values are: 0 (for mode 123), 1 (for mode abc), 2 (for mode ABC)
emptyReturns true or false depending if arg is a an empty string
enumReturns an enumeration out of parameter start[:end[:step]]. Ex: $(enum:$(max_registrations)) = |1|2|3|4|5|6|7|8|9|10|11|12|
fragmentReturns the corresponding value for the given key from the current uri fragment
key_icon_type

Returns the icon used for a key type

key_settingReturns the name of the setting which defines a key
is_context_sensitive_keyReturns true if the given key is a context-sensitive key
is_dkeyReturns true if the given key is a dedicated key
langReturns the localized gui string for a given language key
lastselReturns the data of the selected list item. (Sometimes it's the id attribute of the last MenuItem)
selReturns 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:
$(starts_with:<SUBJECT>:<PIECE>)

linesReturns number of calls
list_sizeReturns the number of listed items
cb_math_evalEvaluate the parameter into a math result
max_registrationsReturns the number of maximum registrations
max_pkey_unitsReturns the number of function key units
pkey_unit_nameReturns the key unit name for a given function key unit
max_pkeysReturns the number of maximum keys for a given function key unit
mod_ifcReturn boolean value if module (or module's variable) exists
on_offReturns the localized string of an on/off for boolean value
phone_stateReturns the current phone state
remove_cmdCommand to remove leading cmd of fkeys setting (Ex: remove the "blf" in "blf 123@1.2.3.4")
get_cmdCommand to fetch the leading cmd of fkeys setting (Ex: fetch the text "blf" in "blf 123@1.2.3.4")
setReturns the value of a setting
setcacheReturns the corresponding value for the given setting in the settings cache
show_featureReturn true or false depend if feature is activated or exist
status_messageReturns the status message
tbook_entry_dataReturns a non empty string if the given parameter exists in the local TBook, example: $(tbook_entry_data:<PHONENUMBER>)
urlencodeReturns the argument URL-encoded
user_displaynameReturns the displayname of given identity
varReturns the corresponding value for the given variable in the variables cache
var_ifcAsk the value of a variable from telephone modules
wifiscanScans for available WIFI SSIDs and returns them as a list
wlangReturns the localized web string for a given language key
x_oReturns checked or unchecked character for boolean value
yes_noReturns 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"]&amp;var:text=$[sel]</Url>
        </MenuItem>
        <MenuItem name="mi2" id="mi2">
            <Url>http://link_to_this_example.xml#sub=*[@id="text"]&amp;var:text=$[sel]</Url>
        </MenuItem>
        <MenuItem name="mi3" id="mi3">
            <Url>http://link_to_this_example.xml#sub=*[@id="text"]&amp;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".