]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
clean up pin prommpting and make local override stay local
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 1 Apr 2009 14:26:57 +0000 (14:26 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 1 Apr 2009 14:26:57 +0000 (14:26 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12864 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_conference/mod_conference.c

index c2f722ad6b0f903545086acd974769e53b97e782..f653227b0df4604c41fd1b79c66531a85ea4660c 100644 (file)
@@ -4715,11 +4715,6 @@ SWITCH_STANDARD_APP(conference_function)
                /* Set the minimum number of members (once you go above it you cannot go below it) */
                conference->min = 2;
 
-               /* if the dialplan specified a pin, override the profile's value */
-               if (dpin) {
-                       conference->pin = switch_core_strdup(conference->pool, dpin);
-               }
-
                /* Indicate the conference is dynamic */
                switch_set_flag_locked(conference, CFLAG_DYNAMIC);
 
@@ -4743,11 +4738,6 @@ SWITCH_STANDARD_APP(conference_function)
                                goto done;
                        }
 
-                       /* if the dialplan specified a pin, override the profile's value */
-                       if (dpin) {
-                               conference->pin = switch_core_strdup(conference->pool, dpin);
-                       }
-               
                        switch_channel_set_variable(channel, "conference_name", conference->name);
 
                        /* Set the minimum number of members (once you go above it you cannot go below it) */
@@ -4769,8 +4759,14 @@ SWITCH_STANDARD_APP(conference_function)
                }
                rl++;
 
+               if (!dpin && conference->pin) {
+                       dpin = conference->pin;
+               }
+
+
+
                /* if this is not an outbound call, deal with conference pins */
-               if (enforce_security && conference->pin && *(conference->pin)) {
+               if (enforce_security && !switch_strlen_zero(dpin)) {
                        char pin_buf[80] = "";
                        int pin_retries = 3;    /* XXX - this should be configurable - i'm too lazy to do it right now... */
                        int pin_valid = 0;
@@ -4778,28 +4774,47 @@ SWITCH_STANDARD_APP(conference_function)
 
                        /* Answer the channel */
                        switch_channel_answer(channel);
+                       
+                       if (!conference->pin_sound) {
+                               conference->pin_sound = switch_core_strdup(conference->pool, "conference/conf-pin.wav");
+                       }
 
-                       while (!pin_valid && pin_retries && status == SWITCH_STATUS_SUCCESS) {
+                       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) {
-                                       conference_local_play_file(conference, session, conference->pin_sound, 20, pin_buf, sizeof(pin_buf));
+                                       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_LOG, 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(conference->pin)) {
+                               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(conference->pin) - strlen(pin_buf), "#", &term, 10000, 0, 0);
+                                                                                                                        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, conference->pin) == 0);
+                               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));