switch_ring_ready_t rv,
const char *file, const char *func, int line)
{
- const char *var;
- char *app;
switch_event_t *event;
if (!switch_channel_test_flag(channel, CF_RING_READY) &&
switch_event_fire(&event);
}
- var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE);
- if (var) {
- char *arg = NULL;
- app = switch_core_session_strdup(channel->session, var);
-
- if (strstr(app, "::")) {
- switch_core_session_execute_application_async(channel->session, app, arg);
- } else {
- if ((arg = strchr(app, ' '))) {
- *arg++ = '\0';
- }
-
- switch_core_session_execute_application(channel->session, app, arg);
- }
- }
+ switch_channel_execute_on(channel, SWITCH_CHANNEL_EXECUTE_ON_RING_VARIABLE);
return SWITCH_STATUS_SUCCESS;
}
{
switch_event_t *event;
const char *var = NULL;
- char *app;
if (!switch_channel_test_flag(channel, CF_EARLY_MEDIA) && !switch_channel_test_flag(channel, CF_ANSWERED)) {
const char *uuid;
switch_mutex_unlock(channel->profile_mutex);
}
- if (((var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_PRE_ANSWER_VARIABLE)) ||
- (var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE))) && !zstr(var)) {
- char *arg = NULL;
- app = switch_core_session_strdup(channel->session, var);
-
-
- if (strstr(app, "::")) {
- switch_core_session_execute_application_async(channel->session, app, arg);
- } else {
- if ((arg = strchr(app, ' '))) {
- *arg++ = '\0';
- }
-
- switch_core_session_execute_application(channel->session, app, arg);
+ if (switch_channel_execute_on(channel, SWITCH_CHANNEL_EXECUTE_ON_PRE_ANSWER_VARIABLE) != SWITCH_STATUS_SUCCESS) {
+ if (!switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
+ switch_channel_execute_on(channel, SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE);
}
}
return status;
}
+SWITCH_DECLARE(switch_status_t) switch_channel_execute_on(switch_channel_t *channel, const char *variable_prefix)
+{
+ switch_event_header_t *hi;
+ int x = 0;
+
+ if ((hi = switch_channel_variable_first(channel))) {
+ for (; hi; hi = hi->next) {
+ char *var = hi->name;
+ char *val = hi->value;
+ char *app;
+
+ if (!strncasecmp(var, variable_prefix, strlen(variable_prefix))) {
+ char *arg = NULL;
+ x++;
+
+ app = switch_core_session_strdup(channel->session, val);
+
+ if (strstr(app, "::")) {
+ switch_core_session_execute_application_async(channel->session, app, arg);
+ } else {
+ if ((arg = strchr(app, ' '))) {
+ *arg++ = '\0';
+ }
+
+ switch_core_session_execute_application(channel->session, app, arg);
+ }
+ }
+ }
+ switch_channel_variable_last(channel);
+ }
+
+ return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
+}
+
SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_channel_t *channel, const char *file, const char *func, int line)
{
switch_event_t *event;
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Channel [%s] has been answered\n",
channel->name);
- if (((var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE)) ||
- (!switch_channel_test_flag(channel, CF_EARLY_MEDIA) && (var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE))))
- && !zstr(var)) {
- char *arg = NULL;
-
- app = switch_core_session_strdup(channel->session, var);
- if (strstr(app, "::")) {
- switch_core_session_execute_application_async(channel->session, app, arg);
- } else {
- if ((arg = strchr(app, ' '))) {
- *arg++ = '\0';
- }
-
- switch_core_session_execute_application(channel->session, app, arg);
+ if (switch_channel_execute_on(channel, SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE) != SWITCH_STATUS_SUCCESS) {
+ if (!switch_channel_test_flag(channel, CF_EARLY_MEDIA)) {
+ switch_channel_execute_on(channel, SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE);
}
}
switch_channel_set_variable(originate_status[i].peer_channel, "originating_leg_uuid", switch_core_session_get_uuid(session));
}
- if ((vvar = switch_channel_get_variable_dup(originate_status[i].peer_channel, "execute_on_originate", SWITCH_FALSE))) {
- char *app = switch_core_session_strdup(originate_status[i].peer_session, vvar);
- char *arg = NULL;
-
- if (strstr(app, "::")) {
- switch_core_session_execute_application_async(originate_status[i].peer_session, app, arg);
- } else {
- if ((arg = strchr(app, ' '))) {
- *arg++ = '\0';
- }
-
- switch_core_session_execute_application(originate_status[i].peer_session, app, arg);
- }
-
- }
+ switch_channel_execute_on(originate_status[i].peer_channel, "execute_on_originate");
}
-
+
if (table) {
switch_channel_add_state_handler(originate_status[i].peer_channel, table);
}