SWITCH_DECLARE(switch_status_t) switch_channel_execute_on(switch_channel_t *channel, const char *variable_prefix);
SWITCH_DECLARE(switch_status_t) switch_channel_api_on(switch_channel_t *channel, const char *variable_prefix);
+SWITCH_DECLARE(switch_caller_extension_t *) switch_channel_get_queued_extension(switch_channel_t *channel);
+SWITCH_DECLARE(void) switch_channel_transfer_to_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension);
+
SWITCH_END_EXTERN_C
#endif
/* For Emacs:
int profile_index;
opaque_channel_flag_t opaque_flags;
switch_originator_type_t last_profile_type;
+ switch_caller_extension_t *queued_extension;
};
}
+SWITCH_DECLARE(switch_caller_extension_t *) switch_channel_get_queued_extension(switch_channel_t *channel)
+{
+ switch_caller_extension_t *caller_extension;
+
+ switch_mutex_lock(channel->profile_mutex);
+ caller_extension = channel->queued_extension;
+ channel->queued_extension = NULL;
+ switch_mutex_unlock(channel->profile_mutex);
+
+ return caller_extension;
+}
+
+SWITCH_DECLARE(void) switch_channel_transfer_to_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension)
+{
+ switch_mutex_lock(channel->profile_mutex);
+ channel->queued_extension = caller_extension;
+ switch_mutex_unlock(channel->profile_mutex);
+
+ switch_channel_set_flag(channel, CF_TRANSFER);
+ switch_channel_set_state(channel, CS_ROUTING);
+}
SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension)
{
char *dp[25];
int argc, x, count = 0;
+ if ((extension = switch_channel_get_queued_extension(session->channel))) {
+ switch_channel_set_caller_extension(session->channel, extension);
+ switch_channel_set_state(session->channel, CS_EXECUTE);
+ goto end;
+ }
+
if (!zstr(caller_profile->dialplan)) {
if ((dpstr = switch_core_session_strdup(session, caller_profile->dialplan))) {
expanded = switch_channel_expand_variables(session->channel, dpstr);
unsigned long CMD_HANGUP = switch_hashfunc_default("hangup", &hlen);
unsigned long CMD_NOMEDIA = switch_hashfunc_default("nomedia", &hlen);
unsigned long CMD_UNICAST = switch_hashfunc_default("unicast", &hlen);
+ unsigned long CMD_XFEREXT = switch_hashfunc_default("xferext", &hlen);
char *lead_frames = switch_event_get_header(event, "lead-frames");
char *event_lock = switch_event_get_header(event, "event-lock");
char *event_lock_pri = switch_event_get_header(event, "event-lock-pri");
switch_ivr_activate_unicast(session, local_ip, (switch_port_t) atoi(local_port), remote_ip, (switch_port_t) atoi(remote_port), transport, flags);
+ } else if (cmd_hash == CMD_XFEREXT) {
+ switch_event_header_t *hp;
+ switch_caller_extension_t *extension = NULL;
+
+
+ if ((extension = switch_caller_extension_new(session, "xferext", "xferext")) == 0) {
+ abort();
+ }
+
+ for (hp = event->headers; hp; hp = hp->next) {
+ char *app;
+ char *data;
+
+ if (!strcasecmp(hp->name, "application")) {
+ app = strdup(hp->value);
+ data = strchr(app, ':');
+
+ if (data) {
+ *data++ = '\0';
+ }
+
+ switch_caller_extension_add_application(session, extension, app, data);
+ }
+ }
+
+ switch_channel_transfer_to_extension(channel, extension);
+
} else if (cmd_hash == CMD_HANGUP) {
char *cause_name = switch_event_get_header(event, "hangup-cause");
switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
switch_channel_set_caller_profile(channel, new_profile);
switch_channel_set_flag(channel, CF_TRANSFER);
-
+
switch_channel_set_state(channel, CS_ROUTING);
msg.message_id = SWITCH_MESSAGE_INDICATE_TRANSFER;