diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index d170593b5d..e0b7b7984f 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -398,7 +398,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess const switch_state_handler_table_t *table, const char *cid_name_override, const char *cid_num_override, - switch_caller_profile_t *caller_profile_override, switch_originate_flag_t flags); + switch_caller_profile_t *caller_profile_override, + switch_event_t *ovars, + switch_originate_flag_t flags + ); /*! \brief Bridge Audio from one session to another diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index d15f399c82..af39e97958 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -1902,7 +1902,7 @@ SWITCH_STANDARD_API(originate_function) timeout = atoi(argv[6]); } - if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS + if (switch_ivr_originate(NULL, &caller_session, &cause, aleg, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS || !caller_session) { if (machine) { stream->write_function(stream, "-ERR %s\n", switch_channel_cause2str(cause)); diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 91ae0035ee..8c434a3e40 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -3807,7 +3807,7 @@ static switch_status_t conference_outcall(conference_obj_t *conference, if (conference == NULL) { char *dialstr = switch_mprintf("{ignore_early_media=true}%s", bridgeto); - status = switch_ivr_originate(NULL, &peer_session, cause, dialstr, 60, NULL, cid_name, cid_num, NULL, SOF_NONE); + status = switch_ivr_originate(NULL, &peer_session, cause, dialstr, 60, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE); switch_safe_free(dialstr); if (status != SWITCH_STATUS_SUCCESS) { @@ -3840,7 +3840,7 @@ static switch_status_t conference_outcall(conference_obj_t *conference, /* establish an outbound call leg */ - if (switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) { + if (switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create outgoing channel, cause: %s\n", switch_channel_cause2str(*cause)); if (caller_channel) { switch_channel_hangup(caller_channel, *cause); diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 8e6d122385..de49415c6e 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -1480,7 +1480,8 @@ SWITCH_STANDARD_APP(att_xfer_function) timelimit = atoi(var); } - if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS || !peer_session) { + if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL, NULL, SOF_NONE) + != SWITCH_STATUS_SUCCESS || !peer_session) { goto end; } @@ -1864,7 +1865,7 @@ SWITCH_STANDARD_APP(audio_bridge_function) } } - if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) { + if (switch_ivr_originate(session, &peer_session, &cause, data, timelimit, NULL, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Originate Failed. Cause: %s\n", switch_channel_cause2str(cause)); /* no answer is *always* a reason to continue */ @@ -2097,7 +2098,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session, } if (switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL, - cid_name_override, cid_num_override, NULL, myflags) == SWITCH_STATUS_SUCCESS) { + cid_name_override, cid_num_override, NULL, var_event, myflags) == SWITCH_STATUS_SUCCESS) { const char *context; switch_caller_profile_t *cp; diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index ffd7871f82..bd37c38569 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -450,7 +450,7 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj) switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count+1 where uuid='%s'", h->uuid); fifo_execute_sql(sql, globals.sql_mutex); - if (switch_ivr_originate(NULL, &session, &cause, h->originate_string, h->timeout, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) { + if (switch_ivr_originate(NULL, &session, &cause, h->originate_string, h->timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) { switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count-1, outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%s'", (long)switch_timestamp(NULL), h->uuid); fifo_execute_sql(sql, globals.sql_mutex); diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 05e1ff9253..6076ae1de2 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -3102,7 +3102,7 @@ void *SWITCH_THREAD_FUNC nightmare_xfer_thread_run(switch_thread_t *thread, void private_object_t *tech_pvt = switch_core_session_get_private(session); switch_channel_t *channel_a = switch_core_session_get_channel(session); - status = switch_ivr_originate(a_session, &tsession, &cause, nhelper->exten, timeout, NULL, NULL, NULL, NULL, SOF_NONE); + status = switch_ivr_originate(a_session, &tsession, &cause, nhelper->exten, timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE); if ((switch_channel_get_state(channel_a) < CS_HANGUP)) { diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index b56b7ceffc..db531e7a60 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -2781,7 +2781,7 @@ static JSBool session_construct(JSContext * cx, JSObject * obj, uintN argc, jsva } } if (switch_ivr_originate(old_jss ? old_jss->session : NULL, - &jss->session, &jss->cause, uuid, 60, NULL, NULL, NULL, NULL, SOF_NONE) == SWITCH_STATUS_SUCCESS) { + &jss->session, &jss->cause, uuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE) == SWITCH_STATUS_SUCCESS) { switch_set_flag(jss, S_HUP); switch_channel_set_state(switch_core_session_get_channel(jss->session), CS_SOFT_EXECUTE); *rval = BOOLEAN_TO_JSVAL(JS_TRUE); @@ -2921,7 +2921,7 @@ static JSBool session_originate(JSContext * cx, JSObject * obj, uintN argc, jsva caller_profile = switch_caller_profile_new(pool, username, dialplan, cid_name, cid_num, network_addr, ani, aniii, rdnis, modname, context, dest); saveDepth = JS_SuspendRequest(cx); - status = switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile, SOF_NONE); + status = switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile, NULL, SOF_NONE); JS_ResumeRequest(cx, saveDepth); if (status != SWITCH_STATUS_SUCCESS) { diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index 631f9b0ddf..b4b87eaaa5 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -467,7 +467,8 @@ SWITCH_DECLARE_CONSTRUCTOR CoreSession::CoreSession(char *nuuid, CoreSession *a_ allocated = 1; } else { switch_call_cause_t cause; - if (switch_ivr_originate(a_leg ? a_leg->session : NULL, &session, &cause, nuuid, 60, NULL, NULL, NULL, NULL, SOF_NONE) == SWITCH_STATUS_SUCCESS) { + if (switch_ivr_originate(a_leg ? a_leg->session : NULL, &session, &cause, nuuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE) + == SWITCH_STATUS_SUCCESS) { channel = switch_core_session_get_channel(session); allocated = 1; switch_set_flag(this, S_HUP); @@ -919,6 +920,7 @@ SWITCH_DECLARE(int) CoreSession::originate(CoreSession *a_leg_session, char *des NULL, NULL, &caller_profile, + NULL, SOF_NONE) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Error Creating Outgoing Channel! [%s]\n", dest); goto failed; diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 491bc9b00f..32b5d8a6a2 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -552,7 +552,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess const switch_state_handler_table_t *table, const char *cid_name_override, const char *cid_num_override, - switch_caller_profile_t *caller_profile_override, switch_originate_flag_t flags) + switch_caller_profile_t *caller_profile_override, + switch_event_t *ovars, + switch_originate_flag_t flags + ) { switch_originate_flag_t dftflags = SOF_NONE, myflags = dftflags; char *pipe_names[MAX_PEERS] = { 0 }; @@ -665,8 +668,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess so we will normalize dialstring params and channel variables (when there is an originator) into an event that we will use as a pseudo hash to consult for params as needed. */ - if (switch_event_create(&var_event, SWITCH_EVENT_GENERAL) != SWITCH_STATUS_SUCCESS) { - abort(); + + if (ovars) { + var_event = ovars; + } else { + if (switch_event_create(&var_event, SWITCH_EVENT_GENERAL) != SWITCH_STATUS_SUCCESS) { + abort(); + } } if (session) { @@ -1684,7 +1692,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess switch_ivr_sleep(session, 0, NULL); } - if (var_event) { + if (var_event && var_event != ovars) { switch_event_destroy(&var_event); } switch_safe_free(write_frame.data);