]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-5402
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 21 May 2013 18:22:17 +0000 (13:22 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 21 May 2013 18:22:35 +0000 (13:22 -0500)
src/switch_ivr_originate.c

index 13896f7b134047345cd99dba0f3beedeed9358a6..84570263f4392207a3d070f70a71c4cf124e1d93 100644 (file)
@@ -1861,6 +1861,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
        const char *ringback_data = NULL;
        switch_event_t *var_event = NULL;
        int8_t fail_on_single_reject = 0;
+       int8_t hangup_on_single_reject = 0;
        char *fail_on_single_reject_var = NULL;
        char *loop_data = NULL;
        uint32_t progress_timelimit_sec = 0;
@@ -2119,6 +2120,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                        ok = 1;
                                } else if (!strcasecmp((char *) hi->name, "fail_on_single_reject")) {
                                        ok = 1;
+                               } else if (!strcasecmp((char *) hi->name, "hangup_on_single_reject")) {
+                                       ok = 1;
                                } else if (!strcasecmp((char *) hi->name, "ignore_early_media")) {
                                        ok = 1;
                                } else if (!strcasecmp((char *) hi->name, "bridge_early_media")) {
@@ -2216,7 +2219,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
           If the value is set to 'true' any fail cause will end the attempt otherwise it can contain a comma (,) separated
           list of cause names which should be considered fatal
         */
-       if ((var = switch_event_get_header(var_event, "fail_on_single_reject"))) {
+       if ((var = switch_event_get_header(var_event, "hangup_on_single_reject"))) {
+               hangup_on_single_reject = 1;
+       }
+
+       if (hangup_on_single_reject || (var = switch_event_get_header(var_event, "fail_on_single_reject"))) {
                fail_on_single_reject_var = strdup(var);
                if (switch_true(var)) {
                        fail_on_single_reject = 1;
@@ -3807,6 +3814,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
        switch_safe_free(write_frame.data);
        switch_safe_free(fail_on_single_reject_var);
 
+       if (force_reason != SWITCH_CAUSE_NONE) {
+               *cause = force_reason;
+       }
+
        if (caller_channel) {
 
                switch_channel_execute_on(caller_channel, SWITCH_CHANNEL_EXECUTE_ON_POST_ORIGINATE_VARIABLE);
@@ -3814,12 +3825,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
 
                switch_channel_clear_flag(caller_channel, CF_ORIGINATOR);
                switch_channel_clear_flag(caller_channel, CF_XFER_ZOMBIE);
-       }
 
-       if (force_reason != SWITCH_CAUSE_NONE) {
-               *cause = force_reason;
+               if (hangup_on_single_reject) {
+                       switch_channel_hangup(caller_channel, *cause);
+               }
        }
 
+
        switch_core_destroy_memory_pool(&oglobals.pool);
 
        return status;