]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update call_uuid stuff
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 4 Aug 2011 06:04:21 +0000 (01:04 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 4 Aug 2011 06:04:21 +0000 (01:04 -0500)
src/switch_channel.c
src/switch_core_session.c
src/switch_core_sqldb.c
src/switch_core_state_machine.c
src/switch_ivr_bridge.c
src/switch_ivr_originate.c

index 3f96616794208fa57ebe73a09293eb618035535e..bd2f84b77956a927ebd05c56337f0be68d8d448b 100644 (file)
@@ -2121,6 +2121,8 @@ SWITCH_DECLARE(void) switch_channel_event_set_basic_data(switch_channel_t *chann
 
        if ((v = switch_channel_get_variable(channel, "call_uuid"))) {
                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Call-UUID", v);
+       } else {
+               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Call-UUID", switch_core_session_get_uuid(channel->session));
        }
 
        if (switch_channel_down(channel)) {
index 168bec3695f30b413f8606d75dc06d732cf871c8..23aa8bed52da1120cef1ca19be3b09793121deb7 100644 (file)
@@ -1427,6 +1427,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_uuid(switch_core_session
                profile->uuid = switch_core_strdup(profile->pool, use_uuid);
        }
 
+       switch_channel_set_variable(session->channel, "uuid", use_uuid);
+       switch_channel_set_variable(session->channel, "call_uuid", use_uuid);
+
        switch_event_create(&event, SWITCH_EVENT_CHANNEL_UUID);
        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Old-Unique-ID", session->uuid_str);
        switch_core_hash_delete(session_manager.session_table, session->uuid_str);
@@ -1729,6 +1732,7 @@ SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(switch_
        }
 
        switch_channel_set_variable(session->channel, "uuid", session->uuid_str);
+       switch_channel_set_variable(session->channel, "call_uuid", session->uuid_str);
 
        session->endpoint_interface = endpoint_interface;
        session->raw_write_frame.data = session->raw_write_buf;
index ee37c612f907bfef16cdc806646a0c818cd5ac09..897cbe9ebdeab99543b3f4f2b11bf498816b891c 100644 (file)
@@ -1221,6 +1221,11 @@ static void core_event_handler(switch_event_t *event)
                                                                           switch_event_get_header_nil(event, "unique-id"),
                                                                           switch_event_get_header_nil(event, "old-unique-id")
                                                                           );
+
+                       new_sql() = switch_mprintf("update channels set call_uuid='%q' where call_uuid='%q'",
+                                                                          switch_event_get_header_nil(event, "unique-id"),
+                                                                          switch_event_get_header_nil(event, "old-unique-id")
+                                                                          );
                        break;
                }
        case SWITCH_EVENT_CHANNEL_CREATE:
@@ -1402,9 +1407,9 @@ static void core_event_handler(switch_event_t *event)
                                b_uuid = switch_event_get_header_nil(event, "other-leg-unique-id");
                        }
 
-                       new_sql() = switch_mprintf("update channels set call_uuid='%q' where uuid='%s'",
-                                                                          switch_event_get_header_nil(event, "channel-call-uuid"),
-                                                                          switch_event_get_header_nil(event, "unique-id"));
+                       new_sql() = switch_mprintf("update channels set call_uuid='%q' where uuid='%s' or uuid='%s'",
+                                                                          switch_event_get_header_nil(event, "channel-call-uuid"), a_uuid, b_uuid);
+                                                                          
 
                        new_sql() = switch_mprintf("insert into calls (call_uuid,call_created,call_created_epoch,"
                                                                           "caller_uuid,callee_uuid,hostname) "
@@ -1422,6 +1427,9 @@ static void core_event_handler(switch_event_t *event)
                {
                        char *uuid = switch_event_get_header_nil(event, "caller-unique-id");
 
+                       new_sql() = switch_mprintf("update channels set call_uuid=uuid where call_uuid='%s'",
+                                                                          switch_event_get_header_nil(event, "channel-call-uuid"));
+
                        new_sql() = switch_mprintf("delete from calls where (caller_uuid='%q' or callee_uuid='%q')",
                                                                           uuid, uuid);
                        break;
index 2e45dde559c5f4dc3b7226db3e12c24a7c059c61..1ab9af91a9297d182c0467a5bc7497625dff66be 100644 (file)
@@ -62,6 +62,7 @@ static void switch_core_standard_on_destroy(switch_core_session_t *session)
 
 static void switch_core_standard_on_reset(switch_core_session_t *session)
 {
+       switch_channel_set_variable(session->channel, "call_uuid", switch_core_session_get_uuid(session));
 
        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Standard RESET\n", switch_channel_get_name(session->channel));
 }
@@ -76,6 +77,8 @@ static void switch_core_standard_on_routing(switch_core_session_t *session)
 
        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Standard ROUTING\n", switch_channel_get_name(session->channel));
 
+       switch_channel_set_variable(session->channel, "call_uuid", switch_core_session_get_uuid(session));
+               
        if ((switch_channel_test_flag(session->channel, CF_ANSWERED) ||
                 switch_channel_test_flag(session->channel, CF_EARLY_MEDIA) ||
                 switch_channel_test_flag(session->channel, CF_SIGNAL_BRIDGE_TTL)) && switch_channel_test_flag(session->channel, CF_PROXY_MODE)) {
@@ -156,6 +159,8 @@ static void switch_core_standard_on_execute(switch_core_session_t *session)
 
        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Standard EXECUTE\n", switch_channel_get_name(session->channel));
 
+       switch_channel_set_variable(session->channel, "call_uuid", switch_core_session_get_uuid(session));
+
        if (switch_channel_get_variable(session->channel, "recovered") && !switch_channel_test_flag(session->channel, CF_RECOVERED)) {
                switch_channel_set_flag(session->channel, CF_RECOVERED);
        }
index 32d1451a6eb2e03bcfb20b079f467ae1f5fde0aa..9dbd4aecab9ec1c44d52602ac8dd6c3befe84c15 100644 (file)
@@ -968,6 +968,7 @@ static switch_status_t signal_bridge_on_hangup(switch_core_session_t *session)
 
                        switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
                        switch_channel_set_variable(other_channel, SWITCH_BRIDGE_VARIABLE, NULL);
+                       switch_channel_set_variable(other_channel, "call_uuid", switch_core_session_get_uuid(other_session));
 
                        if (switch_channel_up(other_channel)) {
 
@@ -1044,6 +1045,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_signal_bridge(switch_core_session_t *
 
        switch_channel_set_variable(caller_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, switch_core_session_get_uuid(peer_session));
        switch_channel_set_variable(peer_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, switch_core_session_get_uuid(session));
+       switch_channel_set_variable(peer_channel, "call_uuid", switch_core_session_get_uuid(session));
 
        switch_channel_set_flag_recursive(caller_channel, CF_BRIDGE_ORIGINATOR);
        switch_channel_clear_flag(peer_channel, CF_BRIDGE_ORIGINATOR);
@@ -1152,6 +1154,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
                
                switch_channel_set_state(peer_channel, CS_CONSUME_MEDIA);
 
+               switch_channel_set_variable(peer_channel, "call_uuid", switch_core_session_get_uuid(session));
+
                if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", switch_core_session_get_uuid(peer_session));
@@ -1303,6 +1307,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
 
   done:
 
+       switch_channel_set_variable(peer_channel, "call_uuid", switch_core_session_get_uuid(peer_session));
+
        if (br && switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
                switch_channel_event_set_data(caller_channel, event);
                switch_event_fire(&event);
index cf0fca1d9db5da1db50d5a906c829ac1c8c4fc22..6df4f40782e2858ad08700f01bbf1e7827b48cbb 100644 (file)
@@ -1843,33 +1843,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                }
        }
 
-       if (var_event) {
-               switch_uuid_t uuid;
-               char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
-               char *use_uuid;
-
-               if (caller_channel) {
-                       use_uuid = switch_core_session_get_uuid(session);
-               } else {
-                       switch_uuid_get(&uuid);
-                       switch_uuid_format(uuid_str, &uuid);
-                       use_uuid = uuid_str;
-               }
-
-               switch_event_del_header(var_event, "call_uuid");
-               switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "call_uuid", use_uuid);
-
-               if (caller_channel) {
-                       switch_channel_set_variable(caller_channel, "call_uuid", use_uuid);
-               }
-       }
-
-       if (caller_channel) {
-               switch_channel_process_export(caller_channel, NULL, var_event, SWITCH_EXPORT_VARS_VARIABLE);
-       }
-
-
-
        /* strip leading spaces */
        while (data && *data && *data == ' ') {
                data++;
@@ -2478,6 +2451,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                originate_status[i].peer_session = new_session;
 
                                switch_channel_set_flag(originate_status[i].peer_channel, CF_ORIGINATING);
+                               
+                               if (caller_channel) {
+                                       switch_channel_set_variable(originate_status[i].peer_channel, "call_uuid", switch_channel_get_variable(caller_channel, "call_uuid"));
+                               }
+                               
 
                                if ((lc = switch_event_get_header(var_event, "local_var_clobber"))) {
                                        local_clobber = switch_true(lc);