]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
return channels to the execute state when hangup_after_bridge is false on a bridge...
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 13 Aug 2008 21:46:06 +0000 (21:46 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 13 Aug 2008 21:46:06 +0000 (21:46 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9288 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_caller.h
src/switch_caller.c
src/switch_channel.c
src/switch_ivr_bridge.c

index cfa05cf6c3443a171d77c04a37e9b7a086a2d115..d06cf2f7b74f4c5edc63d67dd99578d7434643c2 100644 (file)
@@ -142,6 +142,9 @@ struct switch_caller_extension {
 SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(_In_ switch_core_session_t *session,
                                                                                                                                                _In_z_ const char *extension_name, _In_z_ const char *extension_number);
 
+SWITCH_DECLARE(switch_status_t) switch_caller_extension_clone(switch_caller_extension_t **new_ext, switch_caller_extension_t *orig, 
+                                                                                                                         switch_memory_pool_t *pool);
+
 /*!
   \brief Add an application (instruction) to the given extension
   \param session session associated with the extension (bound by scope)
index e7c64f5189a04852275be08144ef7b44a673bce6..1cb6ec517eb59489b14f513e668bda7fc4ed300e 100644 (file)
@@ -282,6 +282,56 @@ SWITCH_DECLARE(void) switch_caller_profile_event_set_data(switch_caller_profile_
        switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "yes" : "no");
 }
 
+SWITCH_DECLARE(switch_status_t) switch_caller_extension_clone(switch_caller_extension_t **new_ext, switch_caller_extension_t *orig, 
+                                                                                                                         switch_memory_pool_t *pool)
+{
+       switch_caller_extension_t *caller_extension = NULL;
+       switch_caller_application_t *caller_application = NULL, *ap = NULL;
+
+       *new_ext = NULL;
+
+       if ((caller_extension = switch_core_alloc(pool, sizeof(switch_caller_extension_t))) != 0) {
+               int match = 0;
+
+        caller_extension->extension_name = switch_core_strdup(pool, orig->extension_name);
+        caller_extension->extension_number = switch_core_strdup(pool, orig->extension_number);
+
+               for(ap = orig->applications; ap; ap = ap->next) {
+
+                       if (!match) {
+                               if (ap == orig->current_application) {
+                                       match++;
+                               } else {
+                                       continue;
+                               }
+                       }
+                       caller_application = switch_core_alloc(pool, sizeof(switch_caller_application_t));
+                       
+                       caller_application->application_name = switch_core_strdup(pool, ap->application_name);
+                       caller_application->application_data = switch_core_strdup(pool, ap->application_data);
+
+                       if (!caller_extension->applications) {
+                               caller_extension->applications = caller_application;
+                       } else if (caller_extension->last_application) {
+                               caller_extension->last_application->next = caller_application;
+                       }
+                       
+                       caller_extension->last_application = caller_application;
+
+                       if (ap == orig->current_application) {
+                               caller_extension->current_application = caller_application;
+                       }
+               }
+
+               *new_ext = caller_extension;
+
+               return SWITCH_STATUS_SUCCESS;
+    }
+       
+
+       return SWITCH_STATUS_MEMERR;
+}
+
 SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(switch_core_session_t *session, const char *extension_name,
                                                                                                                                                const char *extension_number)
 {
index 872e568bf962d30b12bb14964a8d120fc5e27f31..1f6998f58ac63ae4a2b35c3ed69b6347a77c87ae 100644 (file)
@@ -1147,6 +1147,9 @@ SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel_t *channel
                caller_profile->times->progress_media = channel->caller_profile->times->progress_media;
                caller_profile->times->created = channel->caller_profile->times->created;
                caller_profile->times->hungup = channel->caller_profile->times->hungup;
+               if (channel->caller_profile->caller_extension) {
+                       switch_caller_extension_clone(&caller_profile->caller_extension, channel->caller_profile->caller_extension, caller_profile->pool);
+               }
        } else {
                caller_profile->times->created = switch_timestamp_now();
        }
index 2dab0920340e9546a90bc7310fa8e9760db084db..a75249bf31e1a5965f184980e3cbb9c8463b70c6 100644 (file)
@@ -814,13 +814,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
        state = switch_channel_get_state(caller_channel);
 
        if (!switch_channel_test_flag(caller_channel, CF_TRANSFER) && !inner_bridge) {
-               if ((state != CS_EXECUTE && state != CS_PARK && state != CS_ROUTING) ||
+               if ((state != CS_EXECUTE && state != CS_SOFT_EXECUTE && state != CS_PARK && state != CS_ROUTING) ||
                        (switch_channel_test_flag(peer_channel, CF_ANSWERED) && state < CS_HANGUP &&
                         switch_true(switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE)))) {
                        switch_channel_hangup(caller_channel, switch_channel_get_cause(peer_channel));
                }
        }
 
+       state = switch_channel_get_state(caller_channel);
+
+       if (state == CS_SOFT_EXECUTE || state == CS_PARK) {
+               switch_channel_set_state(caller_channel, CS_EXECUTE);
+       }
+
        return status;
 }