Thu Oct 9 06:45:03 2008

Asterisk developer's documentation


adsi.h File Reference

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

#include "asterisk/callerid.h"

Include dependency graph for adsi.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define ADSI_BACKSPACE   0x89
#define ADSI_BLANK   0x86
#define ADSI_CLEAR_CALL_B   0x95
#define ADSI_CLEAR_CALL_BUF   145
#define ADSI_CLEAR_CHARS   0x88
#define ADSI_CLEAR_SCREEN   148
#define ADSI_CLEAR_SOFTKEY   136
#define ADSI_CLEAR_TYPE_AHEAD   143
#define ADSI_COMM_PAGE   0x1
#define ADSI_CONNECT_SESSION   142
#define ADSI_DELAY   0x90
#define ADSI_DIAL_PULSE_ONE   0x91
#define ADSI_DIAL_TONE_DETECT   0x84
#define ADSI_DIR_FROM_LEFT   (0)
#define ADSI_DIR_FROM_RIGHT   (1)
#define ADSI_DISC_SESSION   133
#define ADSI_DISP_CALL_BUF   0x94
#define ADSI_DISPLAY_CALL_BUF   144
#define ADSI_DOWNLOAD_CONNECT   131
#define ADSI_DOWNLOAD_DISC   132
#define ADSI_ENCODED_DTMF   0x80
#define ADSI_EXTENDED_DTMF   0x8F
#define ADSI_FLASH   0x83
#define ADSI_GOTO_LINE   0x8B
#define ADSI_GOTO_LINE_REL   0x8C
#define ADSI_INFO_PAGE   0x0
#define ADSI_INFORMATION   132
#define ADSI_INIT_SOFTKEY_LINE   129
#define ADSI_INPUT_CONTROL   137
#define ADSI_INPUT_FORMAT   138
#define ADSI_JUST_CENT   0x0
#define ADSI_JUST_IND   0x3
#define ADSI_JUST_LEFT   0x2
#define ADSI_JUST_RIGHT   0x1
#define ADSI_KEY_APPS   16
#define ADSI_KEY_HILITE   0x40
#define ADSI_KEY_SKT   0x80
#define ADSI_LINE_CONTROL   131
#define ADSI_LINE_NUMBER   0x85
#define ADSI_LOAD_DEFAULT   141
#define ADSI_LOAD_PREDEF_DISP   129
#define ADSI_LOAD_SCRIPT   130
#define ADSI_LOAD_SOFTKEY   128
#define ADSI_LOAD_SOFTKEY_TABLE   128
#define ADSI_LOAD_VIRTUAL_DISP   130
#define ADSI_MOVE_DATA   140
#define ADSI_MSG_DISPLAY   132
#define ADSI_MSG_DOWNLOAD   133
#define ADSI_OFF_HOOK   0x82
#define ADSI_ON_HOOK   0x81
#define ADSI_PAGE_DOWN   0x8E
#define ADSI_PAGE_UP   0x8D
#define ADSI_QUERY_CONFIG   149
#define ADSI_QUERY_CPEID   150
#define ADSI_SEND_CHARS   0x87
#define ADSI_SWITCH_TO_ALT   146
#define ADSI_SWITCH_TO_APP   151
#define ADSI_SWITCH_TO_DATA   134
#define ADSI_SWITCH_TO_DATA2   0x92
#define ADSI_SWITCH_TO_GRAPHICS   147
#define ADSI_SWITCH_TO_PERIPH   139
#define ADSI_SWITCH_TO_VOICE   135
#define ADSI_SWITCH_TO_VOICE2   0x93
#define ADSI_TAB_COLUMN   0x8A

Functions

int adsi_available (struct ast_channel *chan)
int adsi_begin_download (struct ast_channel *chan, char *service, unsigned char *fdn, unsigned char *sec, int version)
int adsi_channel_init (struct ast_channel *chan)
int adsi_channel_restore (struct ast_channel *chan)
int adsi_clear_screen (unsigned char *buf)
int adsi_clear_soft_keys (unsigned char *buf)
int adsi_connect_session (unsigned char *buf, unsigned char *fdn, int ver)
int adsi_data_mode (unsigned char *buf)
int adsi_disconnect_session (unsigned char *buf)
int adsi_display (unsigned char *buf, int page, int line, int just, int wrap, char *col1, char *col2)
int adsi_download_connect (unsigned char *buf, char *service, unsigned char *fdn, unsigned char *sec, int ver)
int adsi_download_disconnect (unsigned char *buf)
int adsi_end_download (struct ast_channel *chan)
int adsi_get_cpeid (struct ast_channel *chan, unsigned char *cpeid, int voice)
int adsi_get_cpeinfo (struct ast_channel *chan, int *width, int *height, int *buttons, int voice)
int adsi_input_control (unsigned char *buf, int page, int line, int display, int format, int just)
int adsi_input_format (unsigned char *buf, int num, int dir, int wrap, char *format1, char *format2)
int adsi_load_session (struct ast_channel *chan, unsigned char *app, int ver, int data)
int adsi_load_soft_key (unsigned char *buf, int key, char *llabel, char *slabel, char *ret, int data)
int adsi_print (struct ast_channel *chan, char **lines, int *align, int voice)
int adsi_query_cpeid (unsigned char *buf)
int adsi_query_cpeinfo (unsigned char *buf)
int adsi_read_encoded_dtmf (struct ast_channel *chan, unsigned char *buf, int maxlen)
int adsi_set_keys (unsigned char *buf, unsigned char *keys)
int adsi_set_line (unsigned char *buf, int page, int line)
int adsi_transmit_message (struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype)
int adsi_transmit_message_full (struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait)
int adsi_transmit_messages (struct ast_channel *chan, unsigned char **msg, int *msglen, int *msgtype)
int adsi_unload_session (struct ast_channel *chan)
int adsi_voice_mode (unsigned char *buf, int when)


Detailed Description

ADSI Support (built upon Caller*ID).

Definition in file adsi.h.


Define Documentation

#define ADSI_BACKSPACE   0x89

Definition at line 75 of file adsi.h.

#define ADSI_BLANK   0x86

Definition at line 72 of file adsi.h.

#define ADSI_CLEAR_CALL_B   0x95

Definition at line 87 of file adsi.h.

#define ADSI_CLEAR_CALL_BUF   145

Definition at line 50 of file adsi.h.

#define ADSI_CLEAR_CHARS   0x88

Definition at line 74 of file adsi.h.

#define ADSI_CLEAR_SCREEN   148

Definition at line 53 of file adsi.h.

Referenced by adsi_clear_screen().

#define ADSI_CLEAR_SOFTKEY   136

Definition at line 41 of file adsi.h.

Referenced by adsi_clear_soft_keys().

#define ADSI_CLEAR_TYPE_AHEAD   143

Definition at line 48 of file adsi.h.

#define ADSI_COMM_PAGE   0x1

Definition at line 104 of file adsi.h.

Referenced by adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_logo(), adsi_password(), adsi_status(), adsi_status2(), vm_newuser(), vm_options(), and vm_tempgreeting().

#define ADSI_CONNECT_SESSION   142

Definition at line 47 of file adsi.h.

Referenced by adsi_connect_session().

#define ADSI_DELAY   0x90

Definition at line 82 of file adsi.h.

#define ADSI_DIAL_PULSE_ONE   0x91

Definition at line 83 of file adsi.h.

#define ADSI_DIAL_TONE_DETECT   0x84

Definition at line 70 of file adsi.h.

#define ADSI_DIR_FROM_LEFT   (0)

Definition at line 117 of file adsi.h.

Referenced by adsi_login(), and adsi_password().

#define ADSI_DIR_FROM_RIGHT   (1)

Definition at line 118 of file adsi.h.

#define ADSI_DISC_SESSION   133

Definition at line 38 of file adsi.h.

Referenced by adsi_disconnect_session().

#define ADSI_DISP_CALL_BUF   0x94

Definition at line 86 of file adsi.h.

#define ADSI_DISPLAY_CALL_BUF   144

Definition at line 49 of file adsi.h.

#define ADSI_DOWNLOAD_CONNECT   131

Definition at line 62 of file adsi.h.

Referenced by adsi_download_connect().

#define ADSI_DOWNLOAD_DISC   132

Definition at line 63 of file adsi.h.

Referenced by adsi_download_disconnect().

#define ADSI_ENCODED_DTMF   0x80

Definition at line 66 of file adsi.h.

#define ADSI_EXTENDED_DTMF   0x8F

Definition at line 81 of file adsi.h.

#define ADSI_FLASH   0x83

Definition at line 69 of file adsi.h.

#define ADSI_GOTO_LINE   0x8B

Definition at line 77 of file adsi.h.

#define ADSI_GOTO_LINE_REL   0x8C

Definition at line 78 of file adsi.h.

#define ADSI_INFO_PAGE   0x0

Definition at line 103 of file adsi.h.

Referenced by adsi_channel_restore(), and adsi_print().

#define ADSI_INFORMATION   132

Definition at line 37 of file adsi.h.

#define ADSI_INIT_SOFTKEY_LINE   129

Definition at line 34 of file adsi.h.

Referenced by adsi_set_keys().

#define ADSI_INPUT_CONTROL   137

Definition at line 42 of file adsi.h.

Referenced by adsi_input_control().

#define ADSI_INPUT_FORMAT   138

Definition at line 43 of file adsi.h.

Referenced by adsi_input_format().

#define ADSI_JUST_CENT   0x0

Definition at line 111 of file adsi.h.

Referenced by adsi_announce_park(), adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_logo(), cpeid_setstatus(), init_state(), str2align(), vm_newuser(), vm_options(), and vm_tempgreeting().

#define ADSI_JUST_IND   0x3

Definition at line 112 of file adsi.h.

Referenced by str2align().

#define ADSI_JUST_LEFT   0x2

Definition at line 109 of file adsi.h.

Referenced by adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_password(), adsi_status(), adsi_status2(), cpeid_setstatus(), and str2align().

#define ADSI_JUST_RIGHT   0x1

Definition at line 110 of file adsi.h.

Referenced by str2align().

#define ADSI_KEY_APPS   16

Definition at line 106 of file adsi.h.

Referenced by adsi_delete(), adsi_folders(), adsi_load_vmail(), adsi_login(), adsi_message(), adsi_password(), adsi_status(), and adsi_status2().

#define ADSI_KEY_HILITE   0x40

Definition at line 115 of file adsi.h.

#define ADSI_KEY_SKT   0x80

Definition at line 114 of file adsi.h.

Referenced by adsi_delete(), adsi_folders(), adsi_message(), adsi_status(), and adsi_status2().

#define ADSI_LINE_CONTROL   131

Definition at line 36 of file adsi.h.

Referenced by adsi_set_line().

#define ADSI_LINE_NUMBER   0x85

Definition at line 71 of file adsi.h.

#define ADSI_LOAD_DEFAULT   141

Definition at line 46 of file adsi.h.

#define ADSI_LOAD_PREDEF_DISP   129

Definition at line 60 of file adsi.h.

#define ADSI_LOAD_SCRIPT   130

Definition at line 61 of file adsi.h.

#define ADSI_LOAD_SOFTKEY   128

Definition at line 33 of file adsi.h.

Referenced by adsi_load_soft_key().

#define ADSI_LOAD_SOFTKEY_TABLE   128

Definition at line 59 of file adsi.h.

#define ADSI_LOAD_VIRTUAL_DISP   130

Definition at line 35 of file adsi.h.

Referenced by adsi_display().

#define ADSI_MOVE_DATA   140

Definition at line 45 of file adsi.h.

#define ADSI_MSG_DISPLAY   132

Definition at line 29 of file adsi.h.

Referenced by adsi_channel_restore(), adsi_folders(), adsi_get_cpeid(), adsi_get_cpeinfo(), adsi_goodbye(), adsi_load_session(), adsi_load_vmail(), adsi_login(), adsi_password(), adsi_print(), adsi_status(), adsi_status2(), adsi_unload_session(), vm_newuser(), vm_options(), and vm_tempgreeting().

#define ADSI_MSG_DOWNLOAD   133

Definition at line 30 of file adsi.h.

Referenced by adsi_begin_download(), adsi_end_download(), adsi_load_vmail(), and adsi_prog().

#define ADSI_OFF_HOOK   0x82

Definition at line 68 of file adsi.h.

#define ADSI_ON_HOOK   0x81

Definition at line 67 of file adsi.h.

#define ADSI_PAGE_DOWN   0x8E

Definition at line 80 of file adsi.h.

#define ADSI_PAGE_UP   0x8D

Definition at line 79 of file adsi.h.

#define ADSI_QUERY_CONFIG   149

Definition at line 54 of file adsi.h.

Referenced by adsi_query_cpeinfo().

#define ADSI_QUERY_CPEID   150

Definition at line 55 of file adsi.h.

Referenced by adsi_query_cpeid().

#define ADSI_SEND_CHARS   0x87

Definition at line 73 of file adsi.h.

#define ADSI_SWITCH_TO_ALT   146

Definition at line 51 of file adsi.h.

#define ADSI_SWITCH_TO_APP   151

Definition at line 56 of file adsi.h.

#define ADSI_SWITCH_TO_DATA   134

Definition at line 39 of file adsi.h.

Referenced by adsi_data_mode(), and adsi_transmit_message_full().

#define ADSI_SWITCH_TO_DATA2   0x92

Definition at line 84 of file adsi.h.

Referenced by adsi_load_soft_key().

#define ADSI_SWITCH_TO_GRAPHICS   147

Definition at line 52 of file adsi.h.

#define ADSI_SWITCH_TO_PERIPH   139

Definition at line 44 of file adsi.h.

#define ADSI_SWITCH_TO_VOICE   135

Definition at line 40 of file adsi.h.

Referenced by adsi_transmit_message_full(), and adsi_voice_mode().

#define ADSI_SWITCH_TO_VOICE2   0x93

Definition at line 85 of file adsi.h.

#define ADSI_TAB_COLUMN   0x8A

Definition at line 76 of file adsi.h.


Function Documentation

int adsi_available ( struct ast_channel chan  ) 

Parameters:
chan Channel to check

Definition at line 762 of file res_adsi.c.

References ast_channel::adsicpe, AST_ADSI_AVAILABLE, and AST_ADSI_UNKNOWN.

Referenced by adsi_begin(), adsi_delete(), adsi_exec(), adsi_folders(), adsi_goodbye(), adsi_login(), adsi_message(), adsi_password(), adsi_status(), adsi_status2(), ast_park_call(), vm_newuser(), vm_options(), and vm_tempgreeting().

00763 {
00764    int cpe = chan->adsicpe & 0xff;
00765    if ((cpe == AST_ADSI_AVAILABLE) ||
00766        (cpe == AST_ADSI_UNKNOWN))
00767       return 1;
00768    return 0;
00769 }

int adsi_begin_download ( struct ast_channel chan,
char *  service,
unsigned char *  fdn,
unsigned char *  sec,
int  version 
)

Definition at line 319 of file res_adsi.c.

References adsi_download_connect(), ADSI_MSG_DOWNLOAD, adsi_transmit_message_full(), ast_log(), ast_readstring(), and LOG_DEBUG.

Referenced by adsi_load_vmail(), and adsi_prog().

00320 {
00321    int bytes;
00322    unsigned char buf[256];
00323    char ack[2];
00324    bytes = 0;
00325    /* Setup the resident soft key stuff, a piece at a time */
00326    /* Upload what scripts we can for voicemail ahead of time */
00327    bytes += adsi_download_connect(buf + bytes, service, fdn, sec, version);
00328    if (adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0))
00329       return -1;
00330    if (ast_readstring(chan, ack, 1, 10000, 10000, ""))
00331       return -1;
00332    if (ack[0] == 'B')
00333       return 0;
00334    ast_log(LOG_DEBUG, "Download was denied by CPE\n");
00335    return -1;
00336 }

int adsi_channel_init ( struct ast_channel chan  ) 

Parameters:
chan Channel to initialize for ADSI (if supported)
Returns 0 on success (or adsi unavailable) and -1 on hangup

int adsi_channel_restore ( struct ast_channel chan  ) 

Parameters:
chan Channel to restore
Returns 0 on success (or adsi unavailable) and -1 on hangup

Definition at line 920 of file res_adsi.c.

References ADSI_INFO_PAGE, ADSI_MSG_DISPLAY, adsi_set_keys(), adsi_set_line(), ADSI_SPEED_DIAL, adsi_transmit_message_full(), and dsp.

00921 {
00922    unsigned char dsp[256];
00923    int bytes;
00924    int x;
00925    unsigned char keyd[6];
00926 
00927    memset(dsp, 0, sizeof(dsp));
00928 
00929    /* Start with initial display setup */
00930    bytes = 0;
00931    bytes += adsi_set_line(dsp + bytes, ADSI_INFO_PAGE, 1);
00932 
00933    /* Prepare key setup messages */
00934 
00935    if (speeds) {
00936       memset(keyd, 0, sizeof(keyd));
00937       for (x=0;x<speeds;x++) {
00938          keyd[x] = ADSI_SPEED_DIAL + x;
00939       }
00940       bytes += adsi_set_keys(dsp + bytes, keyd);
00941    }
00942    adsi_transmit_message_full(chan, dsp, bytes, ADSI_MSG_DISPLAY, 0);
00943    return 0;
00944 
00945 }

int adsi_clear_screen ( unsigned char *  buf  ) 

Definition at line 730 of file res_adsi.c.

References ADSI_CLEAR_SCREEN.

00731 {
00732    int bytes=0;
00733 
00734    /* Message type */
00735    buf[bytes++] = ADSI_CLEAR_SCREEN;
00736 
00737    /* Reserve space for length */
00738    bytes++;
00739 
00740    buf[1] = bytes - 2;
00741    return bytes;
00742 
00743 }

int adsi_clear_soft_keys ( unsigned char *  buf  ) 

Definition at line 715 of file res_adsi.c.

References ADSI_CLEAR_SOFTKEY.

00716 {
00717    int bytes=0;
00718 
00719    /* Message type */
00720    buf[bytes++] = ADSI_CLEAR_SOFTKEY;
00721 
00722    /* Reserve space for length */
00723    bytes++;
00724 
00725    buf[1] = bytes - 2;
00726    return bytes;
00727 
00728 }

int adsi_connect_session ( unsigned char *  buf,
unsigned char *  fdn,
int  ver 
)

Parameters:
buf Character buffer to create parameter in (must have at least 256 free)
fdn Optional 4 byte Feature Download Number (for loading soft keys)
ver Optional version number (0-255, or -1 to omit)
Returns number of bytes added to buffer or -1 on error.

Definition at line 480 of file res_adsi.c.

References ADSI_CONNECT_SESSION.

Referenced by adsi_load_session().

00481 {
00482    int bytes=0;
00483    int x;
00484 
00485    /* Message type */
00486    buf[bytes++] = ADSI_CONNECT_SESSION;
00487 
00488    /* Reserve space for length */
00489    bytes++;
00490 
00491    if (fdn) {
00492       for (x=0;x<4;x++)
00493          buf[bytes++] = fdn[x];
00494       if (ver > -1)
00495          buf[bytes++] = ver & 0xff;
00496    }
00497 
00498    buf[1] = bytes - 2;
00499    return bytes;
00500 
00501 }

int adsi_data_mode ( unsigned char *  buf  ) 

Parameters:
buf Character buffer to create parameter in (must have at least 256 free)
Returns number of bytes added to buffer or -1 on error.

Definition at line 700 of file res_adsi.c.

References ADSI_SWITCH_TO_DATA.

Referenced by adsi_get_cpeid(), adsi_get_cpeinfo(), adsi_load_session(), and adsi_load_vmail().

00701 {
00702    int bytes=0;
00703 
00704    /* Message type */
00705    buf[bytes++] = ADSI_SWITCH_TO_DATA;
00706 
00707    /* Reserve space for length */
00708    bytes++;
00709 
00710    buf[1] = bytes - 2;
00711    return bytes;
00712 
00713 }

int adsi_disconnect_session ( unsigned char *  buf  ) 

Parameters:
buf Character buffer to create parameter in (must have at least 256 free)
Returns number of bytes added to buffer or -1 on error.

Definition at line 533 of file res_adsi.c.

References ADSI_DISC_SESSION.

Referenced by adsi_unload_session().

00534 {
00535    int bytes=0;
00536 
00537    /* Message type */
00538    buf[bytes++] = ADSI_DISC_SESSION;
00539 
00540    /* Reserve space for length */
00541    bytes++;
00542 
00543    buf[1] = bytes - 2;
00544    return bytes;
00545 
00546 }

int adsi_display ( unsigned char *  buf,
int  page,
int  line,
int  just,
int  wrap,
char *  col1,
char *  col2 
)

Parameters:
buf Character buffer to create parameter in (must have at least 256 free)
page Page to load (ADSI_COMM_PAGE or ADSI_INFO_PAGE)
line Line number to load (1-4 for Comm page, 1-33 for info page)
just Line justification (ADSI_JUST_LEFT, ADSI_JUST_RIGHT, ADSI_JUST_CENT, ADSI_JUST_IND)
wrap Wrap (1 = yes, 0 = no)
col1 Text to place in first column
col2 Text to place in second column
Returns number of bytes added to buffer or -1 on error.

Definition at line 786 of file res_adsi.c.

References ADSI_LOAD_VIRTUAL_DISP, and ccopy().

Referenced by adsi_folders(), adsi_goodbye(), adsi_load_vmail(), adsi_login(), adsi_logo(), adsi_print(), adsi_status(), adsi_status2(), vm_newuser(), vm_options(), and vm_tempgreeting().

00788 {
00789    int bytes=0;
00790 
00791    /* Sanity check line number */
00792 
00793    if (page) {
00794       if (line > 4) return -1;
00795    } else {
00796       if (line > 33) return -1;
00797    }
00798 
00799    if (line < 1)
00800       return -1;
00801    /* Parameter type */
00802    buf[bytes++] = ADSI_LOAD_VIRTUAL_DISP;
00803    
00804    /* Reserve space for size */
00805    bytes++;
00806 
00807    /* Page and wrap indicator */
00808    buf[bytes++] = ((page & 0x1) << 7) | ((wrap & 0x1) << 6) | (line & 0x3f);
00809 
00810    /* Justification */
00811    buf[bytes++] = (just & 0x3) << 5;
00812 
00813    /* Omit highlight mode definition */
00814    buf[bytes++] = 0xff;
00815 
00816    /* Primary column */
00817    bytes+= ccopy(buf + bytes, (unsigned char *)col1, 20);
00818 
00819    /* Delimiter */
00820    buf[bytes++] = 0xff;
00821    
00822    /* Secondary column */
00823    bytes += ccopy(buf + bytes, (unsigned char *)col2, 20);
00824 
00825    /* Update length */
00826    buf[1] = bytes - 2;
00827    
00828    return bytes;
00829 
00830 }

int adsi_download_connect ( unsigned char *  buf,
char *  service,
unsigned char *  fdn,
unsigned char *  sec,
int  ver 
)

Parameters:
buf Character buffer to create parameter in (must have at least 256 free)
service a 1-18 byte name of the feature
fdn 4 byte Feature Download Number (for loading soft keys)
sec 4 byte vendor security code
ver version number (0-255, or -1 to omit)
Returns number of bytes added to buffer or -1 on error.

Definition at line 503 of file res_adsi.c.

References ADSI_DOWNLOAD_CONNECT, and ccopy().

Referenced by adsi_begin_download().

00504 {
00505    int bytes=0;
00506    int x;
00507 
00508    /* Message type */
00509    buf[bytes++] = ADSI_DOWNLOAD_CONNECT;
00510 
00511    /* Reserve space for length */
00512    bytes++;
00513 
00514    /* Primary column */
00515    bytes+= ccopy(buf + bytes, (unsigned char *)service, 18);
00516 
00517    /* Delimiter */
00518    buf[bytes++] = 0xff;
00519    
00520    for (x=0;x<4;x++) {
00521       buf[bytes++] = fdn[x];
00522    }
00523    for (x=0;x<4;x++)
00524       buf[bytes++] = sec[x];
00525    buf[bytes++] = ver & 0xff;
00526 
00527    buf[1] = bytes - 2;
00528 
00529    return bytes;
00530 
00531 }

int adsi_download_disconnect ( unsigned char *  buf  ) 

Parameters:
buf Character buffer to create parameter in (must have at least 256 free)
Returns number of bytes added to buffer or -1 on error.

Definition at line 771 of file res_adsi.c.

References ADSI_DOWNLOAD_DISC.

Referenced by adsi_end_download(), and adsi_load_vmail().

00772 {
00773    int bytes=0;
00774 
00775    /* Message type */
00776    buf[bytes++] = ADSI_DOWNLOAD_DISC;
00777 
00778    /* Reserve space for length */
00779    bytes++;
00780 
00781    buf[1] = bytes - 2;
00782    return bytes;
00783 
00784 }

int adsi_end_download ( struct ast_channel chan  ) 

Definition at line 338 of file res_adsi.c.

References adsi_download_disconnect(), ADSI_MSG_DOWNLOAD, and adsi_transmit_message_full().

Referenced by adsi_load_vmail().

00339 {
00340    int bytes;
00341    unsigned char buf[256];
00342         bytes = 0;
00343         /* Setup the resident soft key stuff, a piece at a time */
00344         /* Upload what scripts we can for voicemail ahead of time */
00345         bytes += adsi_download_disconnect(buf + bytes);
00346    if (adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DOWNLOAD, 0))
00347       return -1;
00348    return 0;
00349 }

int adsi_get_cpeid ( struct ast_channel chan,
unsigned char *  cpeid,
int  voice 
)

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 603 of file res_adsi.c.

References adsi_data_mode(), ADSI_MSG_DISPLAY, adsi_query_cpeid(), adsi_read_encoded_dtmf(), adsi_transmit_message_full(), adsi_voice_mode(), ast_log(), ast_waitfordigit(), and LOG_WARNING.

Referenced by cpeid_exec().

00604 {
00605    unsigned char buf[256];
00606    int bytes = 0;
00607    int res;
00608    bytes += adsi_data_mode(buf);
00609    adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
00610 
00611    bytes = 0;
00612    bytes += adsi_query_cpeid(buf);
00613    adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
00614 
00615    /* Get response */
00616    memset(buf, 0, sizeof(buf));
00617    res = adsi_read_encoded_dtmf(chan, cpeid, 4);
00618    if (res != 4) {
00619       ast_log(LOG_WARNING, "Got %d bytes back of encoded DTMF, expecting 4\n", res);
00620       res = 0;
00621    } else {
00622       res = 1;
00623    }
00624 
00625    if (voice) {
00626       bytes = 0;
00627       bytes += adsi_voice_mode(buf, 0);
00628       adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
00629       /* Ignore the resulting DTMF B announcing it's in voice mode */
00630       ast_waitfordigit(chan, 1000);
00631    }
00632    return res;
00633 }

int adsi_get_cpeinfo ( struct ast_channel chan,
int *  width,
int *  height,
int *  buttons,
int  voice 
)

Definition at line 635 of file res_adsi.c.

References adsi_data_mode(), ADSI_MSG_DISPLAY, adsi_query_cpeinfo(), adsi_transmit_message_full(), adsi_voice_mode(), ast_log(), ast_readstring(), ast_waitfordigit(), and LOG_WARNING.

Referenced by cpeid_exec().

00636 {
00637    unsigned char buf[256];
00638    int bytes = 0;
00639    int res;
00640    bytes += adsi_data_mode(buf);
00641    adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
00642 
00643    bytes = 0;
00644    bytes += adsi_query_cpeinfo(buf);
00645    adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
00646 
00647    /* Get width */
00648    memset(buf, 0, sizeof(buf));
00649    res = ast_readstring(chan, (char *)buf, 2, 1000, 500, "");
00650    if (res < 0)
00651       return res;
00652    if (strlen((char *)buf) != 2) {
00653       ast_log(LOG_WARNING, "Got %d bytes of width, expecting 2\n", res);
00654       res = 0;
00655    } else {
00656       res = 1;
00657    }
00658    if (width)
00659       *width = atoi((char *)buf);
00660    /* Get height */
00661    memset(buf, 0, sizeof(buf));
00662    if (res) {
00663       res = ast_readstring(chan, (char *)buf, 2, 1000, 500, "");
00664       if (res < 0)
00665          return res;
00666       if (strlen((char *)buf) != 2) {
00667          ast_log(LOG_WARNING, "Got %d bytes of height, expecting 2\n", res);
00668          res = 0;
00669       } else {
00670          res = 1;
00671       }  
00672       if (height)
00673          *height= atoi((char *)buf);
00674    }
00675    /* Get buttons */
00676    memset(buf, 0, sizeof(buf));
00677    if (res) {
00678       res = ast_readstring(chan, (char *)buf, 1, 1000, 500, "");
00679       if (res < 0)
00680          return res;
00681       if (strlen((char *)buf) != 1) {
00682          ast_log(LOG_WARNING, "Got %d bytes of buttons, expecting 1\n", res);
00683          res = 0;
00684       } else {
00685          res = 1;
00686       }  
00687       if (buttons)
00688          *buttons = atoi((char *)buf);
00689    }
00690    if (voice) {
00691       bytes = 0;
00692       bytes += adsi_voice_mode(buf, 0);
00693       adsi_transmit_message_full(chan, buf, bytes, ADSI_MSG_DISPLAY, 0);
00694       /* Ignore the resulting DTMF B announcing it's in voice mode */
00695       ast_waitfordigit(chan, 1000);
00696    }
00697    return res;
00698 }

int adsi_input_control ( unsigned char *  buf,
int  page,
int  line,
int  display,
int  format,
int  just 
)

Parameters:
buf Character buffer to create parameter in (must have at least 256 free)
page Which page to input on (ADSI_COMM_PAGE or ADSI_INFO_PAGE)
line Line number to input on
display Set to zero to obscure input, or 1 to leave visible
format Format number to use (0-7)
just Justification (left, right center, indent)
Returns number of bytes added to buffer or -1 on error.

Definition at line 832 of file res_adsi.c.

References ADSI_INPUT_CONTROL.

Referenced by adsi_login(), and adsi_password().

00833 {
00834    int bytes=0;
00835 
00836    if (page) {
00837       if (line > 4) return -1;
00838    } else {
00839       if (line > 33) return -1;
00840    }
00841 
00842    if (line < 1)
00843       return -1;
00844 
00845    buf[bytes++] = ADSI_INPUT_CONTROL;
00846    bytes++;
00847    buf[bytes++] = ((page & 1) << 7) | (line & 0x3f);
00848    buf[bytes++] = ((display & 1) << 7) | ((just & 0x3) << 4) | (format & 0x7);
00849    
00850    buf[1] = bytes - 2;
00851    return bytes;
00852 
00853 }

int adsi_input_format ( unsigned char *  buf,
int  num,
int  dir,
int  wrap,
char *  format1,
char *  format2</