From e0c37c1f6ec06b44bba38a0370c48d7a275898e8 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 5 Nov 2010 18:20:09 -0500 Subject: [PATCH] allow process_import to specify a prefix --- src/include/switch_ivr.h | 2 +- src/mod/applications/mod_fifo/mod_fifo.c | 10 ++++++---- src/switch_ivr_originate.c | 14 ++++++++++---- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index 34c5db8e42..249ac63a58 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -840,7 +840,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say_ip(switch_core_session_t *session SWITCH_DECLARE(switch_status_t) switch_ivr_set_user(switch_core_session_t *session, const char *data); SWITCH_DECLARE(switch_status_t) switch_ivr_sound_test(switch_core_session_t *session); -SWITCH_DECLARE(void) switch_process_import(switch_core_session_t *session, switch_channel_t *peer_channel, const char *varname); +SWITCH_DECLARE(void) switch_process_import(switch_core_session_t *session, switch_channel_t *peer_channel, const char *varname, const char *prefix); SWITCH_DECLARE(switch_bool_t) switch_ivr_uuid_exists(const char *uuid); diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index 520e0628d4..33697a0ca6 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -998,8 +998,10 @@ static switch_status_t messagehook (switch_core_session_t *session, switch_core_ if (caller_channel) { switch_channel_set_variable(caller_channel, "fifo_role", "caller"); - switch_process_import(consumer_session, caller_channel, "fifo_caller_consumer_import"); - switch_process_import(caller_session, consumer_channel, "fifo_consumer_caller_import"); + switch_process_import(consumer_session, caller_channel, "fifo_caller_consumer_import", + switch_channel_get_variable(consumer_channel, "fifo_import_prefix")); + switch_process_import(caller_session, consumer_channel, "fifo_consumer_caller_import", + switch_channel_get_variable(caller_channel, "fifo_import_prefix")); } @@ -2846,8 +2848,8 @@ SWITCH_STANDARD_APP(fifo_function) switch_core_media_bug_resume(session); switch_core_media_bug_resume(other_session); - switch_process_import(session, other_channel, "fifo_caller_consumer_import"); - switch_process_import(other_session, channel, "fifo_consumer_caller_import"); + switch_process_import(session, other_channel, "fifo_caller_consumer_import", switch_channel_get_variable(channel, "fifo_import_prefix")); + switch_process_import(other_session, channel, "fifo_consumer_caller_import", switch_channel_get_variable(other_channel, "fifo_import_prefix")); if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) { switch_channel_event_set_data(channel, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]); diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c index 749f18e1ea..007d7d9fc1 100644 --- a/src/switch_ivr_originate.c +++ b/src/switch_ivr_originate.c @@ -1038,7 +1038,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t return status; } -SWITCH_DECLARE(void) switch_process_import(switch_core_session_t *session, switch_channel_t *peer_channel, const char *varname) +SWITCH_DECLARE(void) switch_process_import(switch_core_session_t *session, switch_channel_t *peer_channel, const char *varname, const char *prefix) { const char *import, *val; switch_channel_t *caller_channel; @@ -1054,7 +1054,13 @@ SWITCH_DECLARE(void) switch_process_import(switch_core_session_t *session, switc if ((argc = switch_separate_string(mydata, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) { for (i = 0; i < argc; i++) { if ((val = switch_channel_get_variable(peer_channel, argv[i]))) { - switch_channel_set_variable(caller_channel, argv[i], val); + if (prefix) { + char *var = switch_mprintf("%s%s", prefix, argv[i]); + switch_channel_set_variable(caller_channel, var, val); + free(var); + } else { + switch_channel_set_variable(caller_channel, argv[i], val); + } } } } @@ -3296,7 +3302,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess } else { status = SWITCH_STATUS_FALSE; if (caller_channel && peer_channel) { - switch_process_import(oglobals.session, peer_channel, "import"); + switch_process_import(oglobals.session, peer_channel, "import", NULL); } peer_channel = NULL; goto done; @@ -3347,7 +3353,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess if (caller_channel) { switch_channel_set_variable(caller_channel, "originate_disposition", "call accepted"); if (peer_channel) { - switch_process_import(oglobals.session, peer_channel, "import"); + switch_process_import(oglobals.session, peer_channel, "import", NULL); } } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oglobals.session), SWITCH_LOG_DEBUG, "Originate Resulted in Success: [%s]\n",