From: Matthew Fredrickson Date: Thu, 1 Dec 2005 18:52:24 +0000 (+0000) Subject: Add app to send pri keypad facility digits during a call X-Git-Tag: 1.4.0-beta1~3236 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39c7f262a05d26d374052f6570a2de2a6fb82c99;p=thirdparty%2Fasterisk.git Add app to send pri keypad facility digits during a call git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7254 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_zap.c b/channels/chan_zap.c index 79ae6c9215..4f729f8aea 100644 --- a/channels/chan_zap.c +++ b/channels/chan_zap.c @@ -58,7 +58,7 @@ #include #ifdef ZAPATA_PRI #include -#ifndef PRI_USER_USER_TX +#ifndef PRI_KEYPAD_FACILITY_TX #error "You need newer libpri" #endif #endif @@ -2211,6 +2211,54 @@ static int destroy_channel(struct zt_pvt *prev, struct zt_pvt *cur, int now) } #ifdef ZAPATA_PRI +static char *zap_send_keypad_facility_app = "ZapSendKeypadFacility"; + +static char *zap_send_keypad_facility_synopsis = "Send digits out of band over a PRI"; + +static char *zap_send_keypad_facility_descrip = +" ZapSendKeypadFacility(): This application will send the given string of digits in a Keypad Facility\n" +" IE over the current channel.\n"; + +static int zap_send_keypad_facility_exec(struct ast_channel *chan, void *data) +{ + /* Data will be our digit string */ + struct zt_pvt *p; + char *digits = (char *) data; + + if (ast_strlen_zero(digits)) { + ast_log(LOG_DEBUG, "No digit string sent to application!\n"); + return -1; + } + + p = (struct zt_pvt *)chan->tech_pvt; + + if (!p) { + ast_log(LOG_DEBUG, "Unable to find technology private\n"); + return -1; + } + + ast_mutex_lock(&p->lock); + + if (!p->pri || !p->call) { + ast_log(LOG_DEBUG, "Unable to find pri or call on channel!\n"); + ast_mutex_unlock(&p->lock); + return -1; + } + + if (!pri_grab(p, p->pri)) { + pri_keypad_facility(p->pri->pri, p->call, digits); + pri_rel(p->pri); + } else { + ast_log(LOG_DEBUG, "Unable to grab pri to send keypad facility!\n"); + ast_mutex_unlock(&p->lock); + return -1; + } + + ast_mutex_unlock(&p->lock); + + return 0; +} + int pri_is_up(struct zt_pri *pri) { int x; @@ -9980,6 +10028,7 @@ static int __unload_module(void) pthread_cancel(pris[i].master); } ast_cli_unregister_multiple(zap_pri_cli, sizeof(zap_pri_cli) / sizeof(zap_pri_cli[0])); + ast_unregister_application(zap_send_keypad_facility_app); #endif #ifdef ZAPATA_R2 ast_cli_unregister_multiple(zap_r2_cli, sizeof(zap_r2_cli) / sizeof(zap_r2_cli[0])); @@ -10869,6 +10918,8 @@ int load_module(void) } pri_set_error(zt_pri_error); pri_set_message(zt_pri_message); + ast_register_application(zap_send_keypad_facility_app, zap_send_keypad_facility_exec, + zap_send_keypad_facility_synopsis, zap_send_keypad_facility_descrip); #endif res = setup_zap(0); /* Make sure we can register our Zap channel type */