Asterisk - The Open Source Telephony Project GIT-master-0bf3178
adsi.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2012, Digium, Inc.
5 *
6 * Mark Michelson <mmichelson@digium.com>
7 *
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.
13 *
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.
17 */
18
19/*! \file
20 * \brief ADSI Support (built upon Caller*ID)
21 */
22
23#include "asterisk.h"
24
25#include "asterisk/adsi.h"
26#include "asterisk/lock.h"
27
28static const struct adsi_funcs *installed_funcs;
31
32int ast_adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version)
33{
34 int res = 0;
37 res = installed_funcs->begin_download(chan, service, fdn, sec, version);
38 }
40 return res;
41}
42
44{
45 int res = 0;
48 res = installed_funcs->end_download(chan);
49 }
51 return res;
52}
53
55{
56 int res = 0;
60 }
62 return res;
63}
64
65int ast_adsi_print(struct ast_channel *chan, char **lines, int *align, int voice)
66{
67 int res = 0;
70 res = installed_funcs->print(chan, lines, align, voice);
71 }
73 return res;
74}
75
76int ast_adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver, int data)
77{
78 int res = 0;
81 res = installed_funcs->load_session(chan, app, ver, data);
82 }
84 return res;
85}
86
88{
89 int res = 0;
93 }
95 return res;
96}
97
98int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
99{
100 int res = 0;
103 res = installed_funcs->transmit_message(chan, msg, msglen, msgtype);
104 }
106 return res;
107}
108
109int ast_adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait)
110{
111 int res = 0;
114 res = installed_funcs->transmit_message_full(chan, msg, msglen, msgtype, dowait);
115 }
117 return res;
118}
119
120int ast_adsi_read_encoded_dtmf(struct ast_channel *chan, unsigned char *buf, int maxlen)
121{
122 int res = 0;
125 res = installed_funcs->read_encoded_dtmf(chan, buf, maxlen);
126 }
128 return res;
129}
130
131int ast_adsi_connect_session(unsigned char *buf, unsigned char *fdn, int ver)
132{
133 int res = 0;
136 res = installed_funcs->connect_session(buf, fdn, ver);
137 }
139 return res;
140}
141
142int ast_adsi_query_cpeid(unsigned char *buf)
143{
144 int res = 0;
148 }
150 return res;
151}
152
153int ast_adsi_query_cpeinfo(unsigned char *buf)
154{
155 int res = 0;
159 }
161 return res;
162}
163
164int ast_adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice)
165{
166 int res = 0;
169 res = installed_funcs->get_cpeid(chan, cpeid, voice);
170 }
172 return res;
173}
174
175int ast_adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
176{
177 int res = 0;
180 res = installed_funcs->get_cpeinfo(chan, width, height, buttons, voice);
181 }
183 return res;
184}
185
186int ast_adsi_download_connect(unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver)
187{
188 int res = 0;
191 res = installed_funcs->download_connect(buf, service, fdn, sec, ver);
192 }
194 return res;
195}
196
198{
199 int res = 0;
203 }
205 return res;
206}
207
209{
210 int res = 0;
214 }
216 return res;
217}
218
219int ast_adsi_data_mode(unsigned char *buf)
220{
221 int res = 0;
225 }
227 return res;
228}
229
230int ast_adsi_clear_soft_keys(unsigned char *buf)
231{
232 int res = 0;
236 }
238 return res;
239}
240
241int ast_adsi_clear_screen(unsigned char *buf)
242{
243 int res = 0;
247 }
249 return res;
250}
251
252int ast_adsi_voice_mode(unsigned char *buf, int when)
253{
254 int res = 0;
257 res = installed_funcs->voice_mode(buf, when);
258 }
260 return res;
261}
262
264{
265 int res = 0;
268 res = installed_funcs->available(chan);
269 }
271 return res;
272}
273
274int ast_adsi_display(unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2)
275{
276 int res = 0;
279 res = installed_funcs->display(buf, page, line, just, wrap, col1, col2);
280 }
282 return res;
283}
284
285int ast_adsi_set_line(unsigned char *buf, int page, int line)
286{
287 int res = 0;
290 res = installed_funcs->set_line(buf, page, line);
291 }
293 return res;
294}
295
296int ast_adsi_load_soft_key(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data)
297{
298 int res = 0;
301 res = installed_funcs->load_soft_key(buf, key, llabel, slabel, ret, data);
302 }
304 return res;
305}
306
307int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys)
308{
309 int res = 0;
313 }
315 return res;
316}
317
318int ast_adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just)
319{
320 int res = 0;
323 res = installed_funcs->input_control(buf, page, line, display, format, just);
324 }
326 return res;
327}
328
329int ast_adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2)
330{
331 int res = 0;
334 res = installed_funcs->input_format(buf, num, dir, wrap, format1, format2);
335 }
337 return res;
338}
339
340void ast_adsi_install_funcs(const struct adsi_funcs *funcs)
341{
342 if (funcs && funcs->version < current_adsi_version) {
343 ast_log(LOG_WARNING, "Cannot install ADSI function pointers due to version mismatch."
344 "Ours: %d, Theirs: %u\n", current_adsi_version, funcs->version);
345 return;
346 }
347
349 installed_funcs = funcs;
351}
int ast_adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait)
Definition: adsi.c:109
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.
Definition: adsi.c:274
int ast_adsi_download_connect(unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver)
Begin an ADSI script download.
Definition: adsi.c:186
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.
Definition: adsi.c:296
int ast_adsi_channel_restore(struct ast_channel *chan)
Definition: adsi.c:54
int ast_adsi_data_mode(unsigned char *buf)
Puts CPE in data mode.
Definition: adsi.c:219
int ast_adsi_unload_session(struct ast_channel *chan)
Definition: adsi.c:87
int ast_adsi_print(struct ast_channel *chan, char **lines, int *align, int voice)
Display some stuff on the screen.
Definition: adsi.c:65
int ast_adsi_query_cpeinfo(unsigned char *buf)
Definition: adsi.c:153
int ast_adsi_begin_download(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version)
Definition: adsi.c:32
static ast_rwlock_t func_lock
Definition: adsi.c:30
int ast_adsi_query_cpeid(unsigned char *buf)
Definition: adsi.c:142
static const int current_adsi_version
Definition: adsi.c:29
int ast_adsi_connect_session(unsigned char *buf, unsigned char *fdn, int ver)
Connects an ADSI Display Session.
Definition: adsi.c:131
int ast_adsi_clear_screen(unsigned char *buf)
Definition: adsi.c:241
int ast_adsi_set_line(unsigned char *buf, int page, int line)
Sets the current line and page.
Definition: adsi.c:285
void ast_adsi_install_funcs(const struct adsi_funcs *funcs)
Definition: adsi.c:340
static const struct adsi_funcs * installed_funcs
Definition: adsi.c:28
int ast_adsi_input_control(unsigned char *buf, int page, int line, int display, int format, int just)
Set input information.
Definition: adsi.c:318
int ast_adsi_input_format(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2)
Set input format.
Definition: adsi.c:329
int ast_adsi_get_cpeid(struct ast_channel *chan, unsigned char *cpeid, int voice)
Definition: adsi.c:164
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,...
Definition: adsi.c:76
int ast_adsi_end_download(struct ast_channel *chan)
Definition: adsi.c:43
int ast_adsi_get_cpeinfo(struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
Definition: adsi.c:175
int ast_adsi_download_disconnect(unsigned char *buf)
Disconnects (and hopefully saves) a downloaded script.
Definition: adsi.c:208
int ast_adsi_available(struct ast_channel *chan)
Returns non-zero if Channel does or might support ADSI.
Definition: adsi.c:263
int ast_adsi_clear_soft_keys(unsigned char *buf)
Definition: adsi.c:230
int ast_adsi_transmit_message(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
Definition: adsi.c:98
int ast_adsi_read_encoded_dtmf(struct ast_channel *chan, unsigned char *buf, int maxlen)
Definition: adsi.c:120
int ast_adsi_disconnect_session(unsigned char *buf)
Disconnects a running session.
Definition: adsi.c:197
int ast_adsi_set_keys(unsigned char *buf, unsigned char *keys)
Set which soft keys should be displayed.
Definition: adsi.c:307
int ast_adsi_voice_mode(unsigned char *buf, int when)
Puts CPE in voice mode.
Definition: adsi.c:252
ADSI Support (built upon Caller*ID)
#define AST_ADSI_VERSION
Definition: adsi.h:123
static const char app[]
Definition: app_adsiprog.c:56
Asterisk main include file. File version handling, generic pbx functions.
#define ast_log
Definition: astobj2.c:42
enum ast_cc_service_type service
Definition: ccss.c:383
static char version[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:391
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define LOG_WARNING
Asterisk locking-related definitions:
#define ast_rwlock_wrlock(a)
Definition: lock.h:236
#define ast_rwlock_rdlock(a)
Definition: lock.h:235
#define AST_RWLOCK_DEFINE_STATIC(rwlock)
Definition: lock.h:543
#define ast_rwlock_unlock(a)
Definition: lock.h:234
int(* query_cpeid)(unsigned char *buf)
Definition: adsi.h:357
int(* clear_screen)(unsigned char *buf)
Definition: adsi.h:366
int(* load_session)(struct ast_channel *chan, unsigned char *app, int ver, int data)
Definition: adsi.h:351
int(* query_cpeinfo)(unsigned char *buf)
Definition: adsi.h:358
int(* channel_restore)(struct ast_channel *chan)
Definition: adsi.h:349
int(* clear_soft_keys)(unsigned char *buf)
Definition: adsi.h:365
int(* disconnect_session)(unsigned char *buf)
Definition: adsi.h:362
int(* unload_session)(struct ast_channel *chan)
Definition: adsi.h:352
int(* read_encoded_dtmf)(struct ast_channel *chan, unsigned char *buf, int maxlen)
Definition: adsi.h:355
unsigned int version
Definition: adsi.h:346
int(* begin_download)(struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version)
Definition: adsi.h:347
int(* transmit_message_full)(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait)
Definition: adsi.h:354
int(* download_disconnect)(unsigned char *buf)
Definition: adsi.h:363
int(* display)(unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2)
Definition: adsi.h:369
int(* download_connect)(unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver)
Definition: adsi.h:361
int(* connect_session)(unsigned char *buf, unsigned char *fdn, int ver)
Definition: adsi.h:356
int(* print)(struct ast_channel *chan, char **lines, int *align, int voice)
Definition: adsi.h:350
int(* get_cpeinfo)(struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
Definition: adsi.h:360
int(* end_download)(struct ast_channel *chan)
Definition: adsi.h:348
int(* get_cpeid)(struct ast_channel *chan, unsigned char *cpeid, int voice)
Definition: adsi.h:359
int(* data_mode)(unsigned char *buf)
Definition: adsi.h:364
int(* set_line)(unsigned char *buf, int page, int line)
Definition: adsi.h:370
int(* input_format)(unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2)
Definition: adsi.h:374
int(* set_keys)(unsigned char *buf, unsigned char *keys)
Definition: adsi.h:372
int(* load_soft_key)(unsigned char *buf, int key, const char *llabel, const char *slabel, char *ret, int data)
Definition: adsi.h:371
int(* available)(struct ast_channel *chan)
Definition: adsi.h:368
int(* input_control)(unsigned char *buf, int page, int line, int display, int format, int just)
Definition: adsi.h:373
int(* voice_mode)(unsigned char *buf, int when)
Definition: adsi.h:367
int(* transmit_message)(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
Definition: adsi.h:353
Main Channel structure associated with a channel.