]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add xferext command to sendmsg parser so you can send a list of instructions to a...
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 31 Aug 2011 20:33:53 +0000 (15:33 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 1 Sep 2011 00:30:58 +0000 (19:30 -0500)
src/include/switch_channel.h
src/switch_channel.c
src/switch_core_state_machine.c
src/switch_ivr.c

index 8fa0439b473de80b5a03639c7f42514e43d280dc..5481a20c0ad1f772da7fee0e55e87b2dea75e038 100644 (file)
@@ -627,6 +627,9 @@ SWITCH_DECLARE(void) switch_channel_mark_hold(switch_channel_t *channel, switch_
 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:
index 8fd174372c2f02b84cd76984d16955c7cde8a1a7..72bf651e29075bd93eabe87d6cb5fa258cddac49 100644 (file)
@@ -146,6 +146,7 @@ struct switch_channel {
        int profile_index;
        opaque_channel_flag_t opaque_flags;
        switch_originator_type_t last_profile_type;
+       switch_caller_extension_t *queued_extension;
 };
 
 
@@ -2688,6 +2689,27 @@ SWITCH_DECLARE(void) switch_channel_sort_cid(switch_channel_t *channel, switch_b
        
 }
 
+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)
 {
index 1bb97aa03daf6c3f2d0d1b388377a948ea3d527b..4c191249df9ec14fac013f714f9d27bebe691852 100644 (file)
@@ -93,6 +93,12 @@ static void switch_core_standard_on_routing(switch_core_session_t *session)
                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);
index 575dc477010dc08b86b0180dca1508fd8fd4d476..22731c1968fc85c16246a852343a4f8bd80adb61 100644 (file)
@@ -484,6 +484,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
        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");
@@ -623,6 +624,33 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
 
                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;
@@ -1661,7 +1689,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_session_transfer(switch_core_session_
 
                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;