From b55d2510802470ae496f15b9fa3c8d881f6e2e24 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 5 Jun 2008 19:36:33 +0000 Subject: [PATCH] honor execute_on_answer on outbound legs too git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8771 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_channel.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/switch_channel.c b/src/switch_channel.c index 7a0d74ad2f..c670e7b9d3 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -1490,6 +1490,8 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan switch_event_t *event; const char *uuid; switch_core_session_t *other_session; + const char *var; + char *app; switch_assert(channel != NULL); @@ -1525,7 +1527,17 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan switch_channel_set_variable(channel, "endpoint_disposition", "ANSWER"); switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_NOTICE, "Channel [%s] has been answered\n", channel->name); + if ((var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE))) { + char *arg = NULL; + app = switch_core_session_strdup(channel->session, var); + + if ((arg = strchr(app, ' '))) { + *arg++ = '\0'; + } + + switch_core_session_execute_application(channel->session, app, arg); + } return SWITCH_STATUS_SUCCESS; } @@ -1549,17 +1561,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t * status = switch_core_session_receive_message(channel->session, &msg); if (status == SWITCH_STATUS_SUCCESS) { - const char *var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE); - char *app; switch_channel_perform_mark_answered(channel, file, func, line); - if (var) { - char *arg = NULL; - app = switch_core_session_strdup(channel->session, var); - if ((arg = strchr(app, ' '))) { - *arg++ = '\0'; - } - switch_core_session_execute_application(channel->session, app, arg); - } } else { switch_channel_hangup(channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION); }