Properly play a holdtime message if the announce-holdtime option is
[asterisk-bristuff.git] / include / asterisk / adsi.h
blob0c894b8f344e67187ef31488d3aeea5acf709d7d
1 /*
2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
19 /*! \file
20 * \brief ADSI Support (built upon Caller*ID)
23 #ifndef _ASTERISK_ADSI_H
24 #define _ASTERISK_ADSI_H
26 #include "asterisk/callerid.h"
28 /* ADSI Message types */
29 #define ADSI_MSG_DISPLAY 132
30 #define ADSI_MSG_DOWNLOAD 133
32 /* ADSI Parameters (display) */
33 #define ADSI_LOAD_SOFTKEY 128
34 #define ADSI_INIT_SOFTKEY_LINE 129
35 #define ADSI_LOAD_VIRTUAL_DISP 130
36 #define ADSI_LINE_CONTROL 131
37 #define ADSI_INFORMATION 132
38 #define ADSI_DISC_SESSION 133
39 #define ADSI_SWITCH_TO_DATA 134
40 #define ADSI_SWITCH_TO_VOICE 135
41 #define ADSI_CLEAR_SOFTKEY 136
42 #define ADSI_INPUT_CONTROL 137
43 #define ADSI_INPUT_FORMAT 138
44 #define ADSI_SWITCH_TO_PERIPH 139
45 #define ADSI_MOVE_DATA 140
46 #define ADSI_LOAD_DEFAULT 141
47 #define ADSI_CONNECT_SESSION 142
48 #define ADSI_CLEAR_TYPE_AHEAD 143
49 #define ADSI_DISPLAY_CALL_BUF 144
50 #define ADSI_CLEAR_CALL_BUF 145
51 #define ADSI_SWITCH_TO_ALT 146
52 #define ADSI_SWITCH_TO_GRAPHICS 147
53 #define ADSI_CLEAR_SCREEN 148
54 #define ADSI_QUERY_CONFIG 149
55 #define ADSI_QUERY_CPEID 150
56 #define ADSI_SWITCH_TO_APP 151
58 /* Feature download messages */
59 #define ADSI_LOAD_SOFTKEY_TABLE 128 /* Conveniently identical to the soft version */
60 #define ADSI_LOAD_PREDEF_DISP 129 /* Load predefined display */
61 #define ADSI_LOAD_SCRIPT 130
62 #define ADSI_DOWNLOAD_CONNECT 131
63 #define ADSI_DOWNLOAD_DISC 132
65 /* Special return string codes */
66 #define ADSI_ENCODED_DTMF 0x80 /* Transmit following chars with encoded dtmf */
67 #define ADSI_ON_HOOK 0x81 /* Open switch-hook */
68 #define ADSI_OFF_HOOK 0x82 /* Close switch-hook */
69 #define ADSI_FLASH 0x83 /* Flash switch-hook */
70 #define ADSI_DIAL_TONE_DETECT 0x84 /* Wait for dialtone */
71 #define ADSI_LINE_NUMBER 0x85 /* Send current line number using DTMF/encoded DTMF */
72 #define ADSI_BLANK 0x86 /* Blank (does nothing) */
73 #define ADSI_SEND_CHARS 0x87 /* Send collected digits/characters */
74 #define ADSI_CLEAR_CHARS 0x88 /* Clear characters/digits collected */
75 #define ADSI_BACKSPACE 0x89 /* Erase last collected digit */
76 #define ADSI_TAB_COLUMN 0x8A /* Display specified display column of current line */
77 #define ADSI_GOTO_LINE 0x8B /* Go to given page and line number */
78 #define ADSI_GOTO_LINE_REL 0x8C /* Go to given line (relative to current) */
79 #define ADSI_PAGE_UP 0x8D /* Go up one page */
80 #define ADSI_PAGE_DOWN 0x8E /* Go down one page */
81 #define ADSI_EXTENDED_DTMF 0x8F /* Send DTMF tones for 250ms instead of 60 ms */
82 #define ADSI_DELAY 0x90 /* Delay for given # (times 10) of ms */
83 #define ADSI_DIAL_PULSE_ONE 0x91 /* Send a dial pulse "1" */
84 #define ADSI_SWITCH_TO_DATA2 0x92 /* Switch CPE to data mode */
85 #define ADSI_SWITCH_TO_VOICE2 0x93 /* Switch CPE to voice mode */
86 #define ADSI_DISP_CALL_BUF 0x94 /* Display specified call buffer */
87 #define ADSI_CLEAR_CALL_B 0x95 /* Clear specified call buffer */
89 #ifdef __ADSI_CPE
90 /* These messages are reserved for the ADSI CPE only */
91 #define ADSI_DISPLAY_CONTROL 0x98 /* Store predefined display identified next / Display status display page */
92 #define ADSI_DISPLAY_SOFT_KEYS 0x99 /* Display the script soft keys identified next */
93 #define ADSI_CHANGE_STATE 0x9A /* Change state of service script */
94 #define ADSI_START_CLEAR_TIMER 0x9B /* Start / Clear timer */
95 #define ADSI_SET_SCRIPT_FLAG 0x9C /* Set / clear a script flag */
96 #define ADSI_JUMP_TO_SUBSCRIPT 0x9D /* Jump to specified subscript */
97 #define ADSI_EVENT_22_TRIGGER 0x9E /* Trigger an occurance of event 22 */
98 #define ADSI_EVENT_23_TRIGGER 0x9f /* Trigger an occurance of event 23 */
99 #define ADSI_EXIT 0xA0 /* Exit the service script interpreter */
100 #endif
102 /* Display pages */
103 #define ADSI_INFO_PAGE 0x0
104 #define ADSI_COMM_PAGE 0x1
106 #define ADSI_KEY_APPS 16 /* 16 to 33 reserved for applications */
108 /* Justification */
109 #define ADSI_JUST_LEFT 0x2
110 #define ADSI_JUST_RIGHT 0x1
111 #define ADSI_JUST_CENT 0x0 /* Center */
112 #define ADSI_JUST_IND 0x3 /* Indent */
114 #define ADSI_KEY_SKT 0x80 /* Load from SKT */
115 #define ADSI_KEY_HILITE 0x40 /* Highlight key */
117 #define ADSI_DIR_FROM_LEFT (0)
118 #define ADSI_DIR_FROM_RIGHT (1)
120 /*! Perform Asterisk ADSI initialization (for channel drivers that want */
121 /* to support ADSI when the handset is first lifted) */
123 * \param chan Channel to initialize for ADSI (if supported)
125 * Returns 0 on success (or adsi unavailable) and -1 on hangup
128 int ast_adsi_channel_init(struct ast_channel *chan);
130 int ast_adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version);
132 int ast_adsi_end_download(struct ast_channel *chan);
134 /*! Restore ADSI initialization (for applications that play with ADSI */
135 /* and want to restore it to normal. If you touch "INFO" then you */
136 /* have to use the ast_adsi_channel_init again instead. */
138 * \param chan Channel to restore
140 * Returns 0 on success (or adsi unavailable) and -1 on hangup
143 int ast_adsi_channel_restore(struct ast_channel *chan);
145 /*! Display some stuff on the screen */
147 * \param chan Channel to display on
148 * \param lines NULL-terminated list of things to print (no more than 4 recommended)
149 * \param align list of alignments to use (ADSI_JUST_LEFT, ADSI_JUST_RIGHT, ADSI_JUST_CEN, etc..)
150 * \param voice whether to jump into voice mode when finished
152 * Return 0 on success (or adsi unavailable) and -1 on hangup
155 int ast_adsi_print(struct ast_channel *chan, char **lines, int *align, int voice);
157 /*! Check if scripts for a given app are already loaded. Version may be -1 */
158 /* if any version is okay, or 0-255 for a specific version. */
160 * \param chan Channel to test for loaded app
161 * \param app Four character app name (must be unique to your application)
162 * \param ver optional version number
163 * \param data Non-zero if you want to be put in data mode
165 * Returns 0 if scripts is not loaded or not an ADSI CPE. Returns -1
166 * on hangup. Returns 1 if script already loaded.
168 int ast_adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data);
169 int ast_adsi_unload_session(struct ast_channel *chan);
171 /* ADSI Layer 2 transmission functions */
172 int ast_adsi_transmit_messages(struct ast_channel *chan, unsigned char **msg, int *msglen, int *msgtype);
173 int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype);
174 int ast_adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait);
175 /*! Read some encoded DTMF data. */
177 * Returns number of bytes received
179 int ast_adsi_read_encoded_dtmf(struct ast_channel *chan, unsigned char *buf, int maxlen);
181 /* ADSI Layer 3 creation functions */
183 /*! Connects an ADSI Display Session */
185 * \param buf Character buffer to create parameter in (must have at least 256 free)
186 * \param fdn Optional 4 byte Feature Download Number (for loading soft keys)
187 * \param ver Optional version number (0-255, or -1 to omit)
189 * Returns number of bytes added to buffer or -1 on error.
193 int ast_adsi_connect_session(unsigned char *buf, unsigned char *fdn, int ver);
195 /*! Build Query CPE ID of equipment */
197 * Returns number of bytes added to message
199 int ast_adsi_query_cpeid(unsigned char *buf);
200 int ast_adsi_query_cpeinfo(unsigned char *buf);
202 /*! Get CPE ID from an attached ADSI compatible CPE. */
204 * Returns 1 on success, storing 4 bytes of CPE ID at buf
205 * or -1 on hangup, or 0 if there was no hangup but it failed to find the
206 * device ID. Returns to voice mode if "voice" is non-zero.
208 int ast_adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice);
210 int ast_adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice);
212 /*! Begin an ADSI script download */
214 * \param buf Character buffer to create parameter in (must have at least 256 free)
215 * \param service a 1-18 byte name of the feature
216 * \param fdn 4 byte Feature Download Number (for loading soft keys)
217 * \param sec 4 byte vendor security code
218 * \param ver version number (0-255, or -1 to omit)
220 * Returns number of bytes added to buffer or -1 on error.
224 int ast_adsi_download_connect(unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver);
226 /*! Disconnects a running session */
228 * \param buf Character buffer to create parameter in (must have at least 256 free)
230 * Returns number of bytes added to buffer or -1 on error.
233 int ast_adsi_disconnect_session(unsigned char *buf);
235 /*! Disconnects (and hopefully saves) a downloaded script */
237 * \param buf Character buffer to create parameter in (must have at least 256 free)
239 * Returns number of bytes added to buffer or -1 on error.
242 int ast_adsi_download_disconnect(unsigned char *buf);
244 /*! Puts CPE in data mode... */
246 * \param buf Character buffer to create parameter in (must have at least 256 free)
248 * Returns number of bytes added to buffer or -1 on error.
251 int ast_adsi_data_mode(unsigned char *buf);
252 int ast_adsi_clear_soft_keys(unsigned char *buf);
253 int ast_adsi_clear_screen(unsigned char *buf);
255 /*! Puts CPE in voice mode... */
257 * \param buf Character buffer to create parameter in (must have at least 256 free)
258 * \param when (a time in seconds) to make the switch
260 * Returns number of bytes added to buffer or -1 on error.
263 int ast_adsi_voice_mode(unsigned char *buf, int when);
265 /*! Returns non-zero if Channel does or might support ADSI */
267 * \param chan Channel to check
270 int ast_adsi_available(struct ast_channel *chan);
272 /*! Loads a line of info into the display */
274 * \param buf Character buffer to create parameter in (must have at least 256 free)
275 * \param page Page to load (ADSI_COMM_PAGE or ADSI_INFO_PAGE)
276 * \param line Line number to load (1-4 for Comm page, 1-33 for info page)
277 * \param just Line justification (ADSI_JUST_LEFT, ADSI_JUST_RIGHT, ADSI_JUST_CENT, ADSI_JUST_IND)
278 * \param wrap Wrap (1 = yes, 0 = no)
279 * \param col1 Text to place in first column
280 * \param col2 Text to place in second column
282 * Returns number of bytes added to buffer or -1 on error.
286 int ast_adsi_display(unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2);
288 /*! Sets the current line and page */
290 * \param buf Character buffer to create parameter in (must have at least 256 free)
291 * \param page Which page (ADSI_COMM_PAGE or ADSI_INFO_PAGE)
292 * \param line Line number (1-33 for info page, 1-4 for comm page)
294 * Returns number of bytes added to buffer or -1 on error.
298 int ast_adsi_set_line(unsigned char *buf, int page, int line);
300 /*! Creates "load soft key" parameters */
302 * \param buf Character buffer to create parameter in (must have at least 256 free)
303 * \param key Key code from 2 to 33, for which key we are loading
304 * \param llabel Long label for key (1-18 bytes)
305 * \param slabel Short label for key (1-7 bytes)
306 * \param ret Optional return sequence (NULL for none)
307 * \param data whether to put CPE in data mode before sending digits
309 * Returns number of bytes added to buffer or -1 on error.
312 int ast_adsi_load_soft_key(unsigned char *buf, int key, const char *llabel, const char *slabel, const char *ret, int data);
314 /*! Set which soft keys should be displayed */
316 * \param buf Character buffer to create parameter in (must have at least 256 free)
317 * \param keys Array of 8 unsigned chars with the key numbers, may be OR'd with ADSI_KEY_HILITE
318 * But remember, the last two keys aren't real keys, they're for scrolling
320 * Returns number of bytes added to buffer or -1 on error.
323 int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys);
325 /*! Set input information */
327 * \param buf Character buffer to create parameter in (must have at least 256 free)
328 * \param page Which page to input on (ADSI_COMM_PAGE or ADSI_INFO_PAGE)
329 * \param line Line number to input on
330 * \param display Set to zero to obscure input, or 1 to leave visible
331 * \param format Format number to use (0-7)
332 * \param just Justification (left, right center, indent)
334 * Returns number of bytes added to buffer or -1 on error.
337 int ast_adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just);
339 /*! Set input format */
341 * \param buf Character buffer to create parameter in (must have at least 256 free)
342 * \param num Which format we are setting
343 * \param dir Which direction (ADSI_DIR_FROM_LEFT or ADSI_DIR_FROM_RIGHT)
344 * \param wrap Set to 1 to permit line wrap, or 0 if not
345 * \param format1 Format for column 1
346 * \param format2 Format for column 2
348 * Returns number of bytes added to buffer or -1 on error.
351 int ast_adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2);
353 #endif /* _ASTERISK_ADSI_H */