Index: src/mod/applications/mod_conference/mod_conference.c =================================================================== --- src/mod/applications/mod_conference/mod_conference.c (revision 14749) +++ src/mod/applications/mod_conference/mod_conference.c (working copy) @@ -41,6 +41,7 @@ static const char global_app_name[] = "conference"; static char *global_cf_name = "conference.conf"; +static char *cf_pin_url_param_name ="X-ConfPin="; static char *api_syntax; static int EC = 0; @@ -5134,61 +5135,79 @@ /* Answer the channel */ switch_channel_answer(channel); - if (!conference->pin_sound) { - conference->pin_sound = switch_core_strdup(conference->pool, "conference/conf-pin.wav"); + /* look for PIN in channel variable first. If not present or invalid revert to prompting user */ + char *supplied_pin_value = switch_core_strdup(conference->pool, switch_channel_get_variable(channel, "supplied_pin")); + if (supplied_pin_value){ + char *supplied_pin_value_start; + if ((supplied_pin_value_start = strcasestr(supplied_pin_value, cf_pin_url_param_name))){ + /* pin supplied as a URL parameter, move pointer to start of actual pin value */ + supplied_pin_value = supplied_pin_value_start + strlen(cf_pin_url_param_name); + } + int i = 0; + while (*supplied_pin_value != 0 && *supplied_pin_value != ';'){ + pin_buf[i++] = *supplied_pin_value++; + } + pin_valid = (strcmp(pin_buf, dpin) == 0); + memset(pin_buf, 0, sizeof(pin_buf)); } - - if (!conference->bad_pin_sound) { - conference->bad_pin_sound = switch_core_strdup(conference->pool, "conference/conf-bad-pin.wav"); - } - - while (!pin_valid && pin_retries && status == SWITCH_STATUS_SUCCESS) { - switch_status_t pstatus = SWITCH_STATUS_FALSE; - - /* be friendly */ - if (conference->pin_sound) { - pstatus = conference_local_play_file(conference, session, conference->pin_sound, 20, pin_buf, sizeof(pin_buf)); - } else if (conference->tts_engine && conference->tts_voice) { - pstatus = switch_ivr_speak_text(session, conference->tts_engine, conference->tts_voice, "please enter the conference pin number", NULL); - } else { - pstatus = switch_ivr_speak_text(session, "flite", "slt", "please enter the conference pin number", NULL); + + if (!pin_valid){ + if (!conference->pin_sound) { + conference->pin_sound = switch_core_strdup(conference->pool, "conference/conf-pin.wav"); } - - if (pstatus != SWITCH_STATUS_SUCCESS && pstatus != SWITCH_STATUS_BREAK) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot ask the user for a pin, ending call"); - switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + + if (!conference->bad_pin_sound) { + conference->bad_pin_sound = switch_core_strdup(conference->pool, "conference/conf-bad-pin.wav"); } - - /* wait for them if neccessary */ - if (strlen(pin_buf) < strlen(dpin)) { - char *buf = pin_buf + strlen(pin_buf); - char term = '\0'; + + while (!pin_valid && pin_retries && status == SWITCH_STATUS_SUCCESS) { + switch_status_t pstatus = SWITCH_STATUS_FALSE; - status = switch_ivr_collect_digits_count(session, - buf, - sizeof(pin_buf) - strlen(pin_buf), - strlen(dpin) - strlen(pin_buf), "#", &term, 10000, 0, 0); - if (status == SWITCH_STATUS_TIMEOUT) { - status = SWITCH_STATUS_SUCCESS; + /* be friendly */ + if (conference->pin_sound) { + pstatus = conference_local_play_file(conference, session, conference->pin_sound, 20, pin_buf, sizeof(pin_buf)); + } else if (conference->tts_engine && conference->tts_voice) { + pstatus = switch_ivr_speak_text(session, conference->tts_engine, conference->tts_voice, "please enter the conference pin number", NULL); + } else { + pstatus = switch_ivr_speak_text(session, "flite", "slt", "please enter the conference pin number", NULL); } + + if (pstatus != SWITCH_STATUS_SUCCESS && pstatus != SWITCH_STATUS_BREAK) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot ask the user for a pin, ending call"); + switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); + } + + /* wait for them if neccessary */ + if (strlen(pin_buf) < strlen(dpin)) { + char *buf = pin_buf + strlen(pin_buf); + char term = '\0'; + + status = switch_ivr_collect_digits_count(session, + buf, + sizeof(pin_buf) - strlen(pin_buf), + strlen(dpin) - strlen(pin_buf), "#", &term, 10000, 0, 0); + if (status == SWITCH_STATUS_TIMEOUT) { + status = SWITCH_STATUS_SUCCESS; + } + } + + pin_valid = (status == SWITCH_STATUS_SUCCESS && strcmp(pin_buf, dpin) == 0); + if (!pin_valid) { + /* zero the collected pin */ + memset(pin_buf, 0, sizeof(pin_buf)); + + /* more friendliness */ + if (conference->bad_pin_sound) { + conference_local_play_file(conference, session, conference->bad_pin_sound, 20, pin_buf, sizeof(pin_buf)); + } + } + pin_retries--; } - - pin_valid = (status == SWITCH_STATUS_SUCCESS && strcmp(pin_buf, dpin) == 0); + if (!pin_valid) { - /* zero the collected pin */ - memset(pin_buf, 0, sizeof(pin_buf)); - - /* more friendliness */ - if (conference->bad_pin_sound) { - conference_local_play_file(conference, session, conference->bad_pin_sound, 20, pin_buf, sizeof(pin_buf)); - } + goto done; } - pin_retries--; } - - if (!pin_valid) { - goto done; - } } if (conference->special_announce) {