Asterisk - The Open Source Telephony Project  21.4.1
Functions | Variables
adsi.c File Reference

ADSI Support (built upon Caller*ID) More...

#include "asterisk.h"
#include "asterisk/adsi.h"
#include "asterisk/lock.h"

Go to the source code of this file.

Functions

int ast_adsi_available (struct ast_channel *chan)
 Returns non-zero if Channel does or might support ADSI. More...
 
int ast_adsi_begin_download (struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version)
 
int ast_adsi_channel_restore (struct ast_channel *chan)
 
int ast_adsi_clear_screen (unsigned char *buf)
 
int ast_adsi_clear_soft_keys (unsigned char *buf)
 
int ast_adsi_connect_session (unsigned char *buf, unsigned char *fdn, int ver)
 Connects an ADSI Display Session. More...
 
int ast_adsi_data_mode (unsigned char *buf)
 Puts CPE in data mode. More...
 
int ast_adsi_disconnect_session (unsigned char *buf)
 Disconnects a running session. More...
 
int ast_adsi_display (unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2)
 Loads a line of info into the display. More...
 
int ast_adsi_download_connect (unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver)
 Begin an ADSI script download. More...
 
int ast_adsi_download_disconnect (unsigned char *buf)
 Disconnects (and hopefully saves) a downloaded script. More...
 
int ast_adsi_end_download (struct ast_channel *chan)
 
int ast_adsi_get_cpeid (struct ast_channel *chan, unsigned char *cpeid, int voice)
 
int ast_adsi_get_cpeinfo (struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
 
int ast_adsi_input_control (unsigned char *buf, int page, int line, int display, int format, int just)
 Set input information. More...
 
int ast_adsi_input_format (unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2)
 Set input format. More...
 
void ast_adsi_install_funcs (const struct adsi_funcs *funcs)
 
int ast_adsi_load_session (struct ast_channel *chan, unsigned char *app, int ver, int data)
 Check if scripts for a given app are already loaded. Version may be -1, if any version is okay, or 0-255 for a specific version. More...
 
int ast_adsi_load_soft_key (unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data)
 Creates "load soft key" parameters. More...
 
int ast_adsi_print (struct ast_channel *chan, char **lines, int *align, int voice)
 Display some stuff on the screen. More...
 
int ast_adsi_query_cpeid (unsigned char *buf)
 
int ast_adsi_query_cpeinfo (unsigned char *buf)
 
int ast_adsi_read_encoded_dtmf (struct ast_channel *chan, unsigned char *buf, int maxlen)
 
int ast_adsi_set_keys (unsigned char *buf, unsigned char *keys)
 Set which soft keys should be displayed. More...
 
int ast_adsi_set_line (unsigned char *buf, int page, int line)
 Sets the current line and page. More...
 
int ast_adsi_transmit_message (struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
 
int ast_adsi_transmit_message_full (struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait)
 
int ast_adsi_unload_session (struct ast_channel *chan)
 
int ast_adsi_voice_mode (unsigned char *buf, int when)
 Puts CPE in voice mode. More...
 

Variables

static const int current_adsi_version = AST_ADSI_VERSION
 
static ast_rwlock_t func_lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} }
 
static const struct adsi_funcsinstalled_funcs
 

Detailed Description

ADSI Support (built upon Caller*ID)

Definition in file adsi.c.

Function Documentation

int ast_adsi_available ( struct ast_channel chan)

Returns non-zero if Channel does or might support ADSI.

Parameters
chanChannel to check

Definition at line 263 of file adsi.c.

Referenced by vm_tempgreeting().

264 {
265  int res = 0;
266  ast_rwlock_rdlock(&func_lock);
267  if (installed_funcs && installed_funcs->available) {
268  res = installed_funcs->available(chan);
269  }
270  ast_rwlock_unlock(&func_lock);
271  return res;
272 }
int ast_adsi_channel_restore ( struct ast_channel chan)

Restore ADSI initialization (for applications that play with ADSI and want to restore it to normal. If you touch "INFO" then you have to use the ast_adsi_channel_init again instead.

Parameters
chanChannel to restore
Return values
0on success (or adsi unavailable)
-1on hangup

Definition at line 54 of file adsi.c.

55 {
56  int res = 0;
57  ast_rwlock_rdlock(&func_lock);
58  if (installed_funcs && installed_funcs->channel_restore) {
59  res = installed_funcs->channel_restore(chan);
60  }
61  ast_rwlock_unlock(&func_lock);
62  return res;
63 }
int ast_adsi_connect_session ( unsigned char *  buf,
unsigned char *  fdn,
int  ver 
)

Connects an ADSI Display Session.

Parameters
bufCharacter buffer to create parameter in (must have at least 256 free)
fdnOptional 4 byte Feature Download Number (for loading soft keys)
verOptional version number (0-255, or -1 to omit)
Return values
numberof bytes added to buffer
-1on error.

Definition at line 131 of file adsi.c.

132 {
133  int res = 0;
134  ast_rwlock_rdlock(&func_lock);
135  if (installed_funcs && installed_funcs->connect_session) {
136  res = installed_funcs->connect_session(buf, fdn, ver);
137  }
138  ast_rwlock_unlock(&func_lock);
139  return res;
140 }
int ast_adsi_data_mode ( unsigned char *  buf)

Puts CPE in data mode.

Parameters
bufCharacter buffer to create parameter in (must have at least 256 free)
Return values
numberof bytes added to buffer
-1on error.

Definition at line 219 of file adsi.c.

220 {
221  int res = 0;
222  ast_rwlock_rdlock(&func_lock);
223  if (installed_funcs && installed_funcs->data_mode) {
224  res = installed_funcs->data_mode(buf);
225  }
226  ast_rwlock_unlock(&func_lock);
227  return res;
228 }
int ast_adsi_disconnect_session ( unsigned char *  buf)

Disconnects a running session.

Parameters
bufCharacter buffer to create parameter in (must have at least 256 free)
Return values
numberof bytes added to buffer
-1on error.

Definition at line 197 of file adsi.c.

198 {
199  int res = 0;
200  ast_rwlock_rdlock(&func_lock);
201  if (installed_funcs && installed_funcs->disconnect_session) {
202  res = installed_funcs->disconnect_session(buf);
203  }
204  ast_rwlock_unlock(&func_lock);
205  return res;
206 }
int ast_adsi_display ( unsigned char *  buf,
int  page,
int  line,
int  just,
int  wrap,
char *  col1,
char *  col2 
)

Loads a line of info into the display.

Parameters
bufCharacter buffer to create parameter in (must have at least 256 free)
pagePage to load (ADSI_COMM_PAGE or ADSI_INFO_PAGE)
lineLine number to load (1-4 for Comm page, 1-33 for info page)
justLine justification (ADSI_JUST_LEFT, ADSI_JUST_RIGHT, ADSI_JUST_CENT, ADSI_JUST_IND)
wrapWrap (1 = yes, 0 = no)
col1Text to place in first column
col2Text to place in second column
Return values
numberof bytes added to buffer
-1on error.

Definition at line 274 of file adsi.c.

Referenced by vm_tempgreeting().

275 {
276  int res = 0;
277  ast_rwlock_rdlock(&func_lock);
278  if (installed_funcs && installed_funcs->display) {
279  res = installed_funcs->display(buf, page, line, just, wrap, col1, col2);
280  }
281  ast_rwlock_unlock(&func_lock);
282  return res;
283 }
int ast_adsi_download_connect ( unsigned char *  buf,
char *  service,
unsigned char *  fdn,
unsigned char *  sec,
int  ver 
)

Begin an ADSI script download.

Parameters
bufCharacter buffer to create parameter in (must have at least 256 free)
servicea 1-18 byte name of the feature
fdn4 byte Feature Download Number (for loading soft keys)
sec4 byte vendor security code
verversion number (0-255, or -1 to omit)
Return values
numberof bytes added to buffer
-1on error.

Definition at line 186 of file adsi.c.

187 {
188  int res = 0;
189  ast_rwlock_rdlock(&func_lock);
190  if (installed_funcs && installed_funcs->download_connect) {
191  res = installed_funcs->download_connect(buf, service, fdn, sec, ver);
192  }
193  ast_rwlock_unlock(&func_lock);
194  return res;
195 }
int ast_adsi_download_disconnect ( unsigned char *  buf)

Disconnects (and hopefully saves) a downloaded script.

Parameters
bufCharacter buffer to create parameter in (must have at least 256 free)
Return values
numberof bytes added to buffer
-1on error.

Definition at line 208 of file adsi.c.

209 {
210  int res = 0;
211  ast_rwlock_rdlock(&func_lock);
212  if (installed_funcs && installed_funcs->download_disconnect) {
213  res = installed_funcs->download_disconnect(buf);
214  }
215  ast_rwlock_unlock(&func_lock);
216  return res;
217 }
int ast_adsi_get_cpeid ( struct ast_channel chan,
unsigned char *  cpeid,
int  voice 
)

Get CPE ID from an attached ADSI compatible CPE. Returns 1 on success, storing 4 bytes of CPE ID at buf or -1 on hangup, or 0 if there was no hangup but it failed to find the device ID. Returns to voice mode if "voice" is non-zero.

Definition at line 164 of file adsi.c.

165 {
166  int res = 0;
167  ast_rwlock_rdlock(&func_lock);
168  if (installed_funcs && installed_funcs->get_cpeid) {
169  res = installed_funcs->get_cpeid(chan, cpeid, voice);
170  }
171  ast_rwlock_unlock(&func_lock);
172  return res;
173 }
int ast_adsi_input_control ( unsigned char *  buf,
int  page,
int  line,
int  display,
int  format,
int  just 
)

Set input information.

Parameters
bufCharacter buffer to create parameter in (must have at least 256 free)
pageWhich page to input on (ADSI_COMM_PAGE or ADSI_INFO_PAGE)
lineLine number to input on
displaySet to zero to obscure input, or 1 to leave visible
formatFormat number to use (0-7)
justJustification (left, right center, indent)
Return values
numberof bytes added to buffer
-1on error.

Definition at line 318 of file adsi.c.

319 {
320  int res = 0;
321  ast_rwlock_rdlock(&func_lock);
322  if (installed_funcs && installed_funcs->input_control) {
323  res = installed_funcs->input_control(buf, page, line, display, format, just);
324  }
325  ast_rwlock_unlock(&func_lock);
326  return res;
327 }
int ast_adsi_input_format ( unsigned char *  buf,
int  num,
int  dir,
int  wrap,
char *  format1,
char *  format2 
)

Set input format.

Parameters
bufCharacter buffer to create parameter in (must have at least 256 free)
numWhich format we are setting
dirWhich direction (ADSI_DIR_FROM_LEFT or ADSI_DIR_FROM_RIGHT)
wrapSet to 1 to permit line wrap, or 0 if not
format1Format for column 1
format2Format for column 2
Return values
numberof bytes added to buffer
-1on error.

Definition at line 329 of file adsi.c.

330 {
331  int res = 0;
332  ast_rwlock_rdlock(&func_lock);
333  if (installed_funcs && installed_funcs->input_format) {
334  res = installed_funcs->input_format(buf, num, dir, wrap, format1, format2);
335  }
336  ast_rwlock_unlock(&func_lock);
337  return res;
338 }
int ast_adsi_load_session ( struct ast_channel chan,
unsigned char *  app,
int  ver,
int  data 
)

Check if scripts for a given app are already loaded. Version may be -1, if any version is okay, or 0-255 for a specific version.

Parameters
chanChannel to test for loaded app
appFour character app name (must be unique to your application)
veroptional version number
dataNon-zero if you want to be put in data mode
Return values
0if scripts is not loaded or not an ADSI CPE
-1on hangup
1if script already loaded.

Definition at line 76 of file adsi.c.

77 {
78  int res = 0;
79  ast_rwlock_rdlock(&func_lock);
80  if (installed_funcs && installed_funcs->load_session) {
81  res = installed_funcs->load_session(chan, app, ver, data);
82  }
83  ast_rwlock_unlock(&func_lock);
84  return res;
85 }
int ast_adsi_load_soft_key ( unsigned char *  buf,
int  key,
const char *  llabel,
const char *  slabel,
char *  ret,
int  data 
)

Creates "load soft key" parameters.

Parameters
bufCharacter buffer to create parameter in (must have at least 256 free)
keyKey code from 2 to 33, for which key we are loading
llabelLong label for key (1-18 bytes)
slabelShort label for key (1-7 bytes)
retOptional return sequence (NULL for none)
datawhether to put CPE in data mode before sending digits
Return values
numberof bytes added to buffer
-1on error.

Definition at line 296 of file adsi.c.

297 {
298  int res = 0;
299  ast_rwlock_rdlock(&func_lock);
300  if (installed_funcs && installed_funcs->load_soft_key) {
301  res = installed_funcs->load_soft_key(buf, key, llabel, slabel, ret, data);
302  }
303  ast_rwlock_unlock(&func_lock);
304  return res;
305 }
int ast_adsi_print ( struct ast_channel chan,
char **  lines,
int *  align,
int  voice 
)

Display some stuff on the screen.

Parameters
chanChannel to display on
linesNULL-terminated list of things to print (no more than 4 recommended)
alignlist of alignments to use (ADSI_JUST_LEFT, ADSI_JUST_RIGHT, ADSI_JUST_CEN, etc..)
voicewhether to jump into voice mode when finished
Return values
0on success (or adsi unavailable)
-1on hangup

Definition at line 65 of file adsi.c.

66 {
67  int res = 0;
68  ast_rwlock_rdlock(&func_lock);
69  if (installed_funcs && installed_funcs->print) {
70  res = installed_funcs->print(chan, lines, align, voice);
71  }
72  ast_rwlock_unlock(&func_lock);
73  return res;
74 }
int ast_adsi_query_cpeid ( unsigned char *  buf)

Build Query CPE ID of equipment. Returns number of bytes added to message

Definition at line 142 of file adsi.c.

143 {
144  int res = 0;
145  ast_rwlock_rdlock(&func_lock);
146  if (installed_funcs && installed_funcs->query_cpeid) {
147  res = installed_funcs->query_cpeid(buf);
148  }
149  ast_rwlock_unlock(&func_lock);
150  return res;
151 }
int ast_adsi_read_encoded_dtmf ( struct ast_channel chan,
unsigned char *  buf,
int  maxlen 
)

Read some encoded DTMF data. Returns number of bytes received

Definition at line 120 of file adsi.c.

121 {
122  int res = 0;
123  ast_rwlock_rdlock(&func_lock);
124  if (installed_funcs && installed_funcs->read_encoded_dtmf) {
125  res = installed_funcs->read_encoded_dtmf(chan, buf, maxlen);
126  }
127  ast_rwlock_unlock(&func_lock);
128  return res;
129 }
int ast_adsi_set_keys ( unsigned char *  buf,
unsigned char *  keys 
)

Set which soft keys should be displayed.

Parameters
bufCharacter buffer to create parameter in (must have at least 256 free)
keysArray of 8 unsigned chars with the key numbers, may be OR'd with ADSI_KEY_HILITE But remember, the last two keys aren't real keys, they're for scrolling
Return values
numberof bytes added to buffer
-1on error.

Definition at line 307 of file adsi.c.

308 {
309  int res = 0;
310  ast_rwlock_rdlock(&func_lock);
311  if (installed_funcs && installed_funcs->set_keys) {
312  res = installed_funcs->set_keys(buf, keys);
313  }
314  ast_rwlock_unlock(&func_lock);
315  return res;
316 }
int ast_adsi_set_line ( unsigned char *  buf,
int  page,
int  line 
)

Sets the current line and page.

Parameters
bufCharacter buffer to create parameter in (must have at least 256 free)
pageWhich page (ADSI_COMM_PAGE or ADSI_INFO_PAGE)
lineLine number (1-33 for info page, 1-4 for comm page)
Return values
numberof bytes added to buffer
-1on error.

Definition at line 285 of file adsi.c.

Referenced by vm_tempgreeting().

286 {
287  int res = 0;
288  ast_rwlock_rdlock(&func_lock);
289  if (installed_funcs && installed_funcs->set_line) {
290  res = installed_funcs->set_line(buf, page, line);
291  }
292  ast_rwlock_unlock(&func_lock);
293  return res;
294 }
int ast_adsi_voice_mode ( unsigned char *  buf,
int  when 
)

Puts CPE in voice mode.

Parameters
bufCharacter buffer to create parameter in (must have at least 256 free)
when(a time in seconds) to make the switch
Return values
numberof bytes added to buffer
-1on error.

Definition at line 252 of file adsi.c.

Referenced by vm_tempgreeting().

253 {
254  int res = 0;
255  ast_rwlock_rdlock(&func_lock);
256  if (installed_funcs && installed_funcs->voice_mode) {
257  res = installed_funcs->voice_mode(buf, when);
258  }
259  ast_rwlock_unlock(&func_lock);
260  return res;
261 }