--- chan_dahdi.c 2009-02-06 12:29:41.000000000 -0700 +++ chan_dahdi.c.new 2009-02-24 16:16:14.000000000 -0700 @@ -3228,6 +3228,69 @@ } #ifdef HAVE_PRI +static int dahdi_send_mwi_act_facility_exec(struct ast_channel *chan, void *data) +{ + /* Data will be the extension number */ + struct dahdi_pvt *p; + char *digits = (char *) data; + + if (ast_strlen_zero(digits)) { + ast_log(LOG_WARNING, "No digit string sent to application!\n"); + return -1; + } + + p = (struct dahdi_pvt *)chan->tech_pvt; + + ast_mutex_lock(&p->lock); + + if ((p->call = pri_new_call(p->pri->pri))) { + pri_mwi_activate(p->pri->pri, p->call, "274", PRI_UNKNOWN, "Asterisk MWI", PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, digits, PRI_UNKNOWN); + pri_rel(p->pri); + } else { + ast_debug(1, "Unable to setup new call via pri_new_call.\n"); + return -1; + } + + ast_mutex_unlock(&p->lock); + + return 0; +} + +static char *dahdi_send_mwi_deact_facility_app = "DAHDISendMWIDeactFacility"; + +static char *dahdi_send_mwi_deact_facility_synopsis = "Send MWI deactivate via CISC"; + +static char *dahdi_send_mwi_deact_facility_descrip = +" DAHDISendMWIDeactFacility(): This application will send an MWI Facility message over the ISDN D-channel.\n"; + +static int dahdi_send_mwi_deact_facility_exec(struct ast_channel *chan, void *data) +{ + /* Data will be the extension number */ + struct dahdi_pvt *p; + char *digits = (char *) data; + + if (ast_strlen_zero(digits)) { + ast_log(LOG_WARNING, "No digit string sent to application!\n"); + return -1; + } + + p = (struct dahdi_pvt *)chan->tech_pvt; + + ast_mutex_lock(&p->lock); + + if ((p->call = pri_new_call(p->pri->pri))) { + pri_mwi_deactivate(p->pri->pri, p->call, "274", PRI_UNKNOWN, "Asterisk MWI", PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, digits, PRI_UNKNOWN); + pri_rel(p->pri); + } else { + ast_debug(1, "Unable to setup new call via pri_new_call.\n"); + return -1; + } + + ast_mutex_unlock(&p->lock); + + return 0; +} + static char *dahdi_send_keypad_facility_app = "DAHDISendKeypadFacility"; static char *dahdi_send_keypad_facility_synopsis = "Send digits out of band over a PRI"; @@ -13688,6 +13751,9 @@ pthread_cancel(pris[i].master); } ast_cli_unregister_multiple(dahdi_pri_cli, ARRAY_LEN(dahdi_pri_cli)); + + ast_unregister_application(dahdi_send_mwi_act_facility_app); + ast_unregister_application(dahdi_send_mwi_deact_facility_app); ast_unregister_application(dahdi_send_keypad_facility_app); #endif #if defined(HAVE_SS7) @@ -14899,6 +14965,11 @@ } pri_set_error(dahdi_pri_error); pri_set_message(dahdi_pri_message); + + ast_register_application(dahdi_send_mwi_act_facility_app, dahdi_send_mwi_act_facility_exec, + dahdi_send_mwi_act_facility_synopsis, dahdi_send_mwi_act_facility_descrip); + ast_register_application(dahdi_send_mwi_deact_facility_app, dahdi_send_mwi_deact_facility_exec, + dahdi_send_mwi_deact_facility_synopsis, dahdi_send_mwi_deact_facility_descrip); ast_register_application(dahdi_send_keypad_facility_app, dahdi_send_keypad_facility_exec, dahdi_send_keypad_facility_synopsis, dahdi_send_keypad_facility_descrip); #endif