提交 054c6458 authored 作者: Travis Cross's avatar Travis Cross

Show initial channel values with `show channels`

Store some initial details about the channel separately so we can
preserve them across e.g. transfers and display them with show
channels.

With this commit, we store the original caller ID (name and number)
and IP address, and the call destination, dialplan, and context.

FS-4296 --resolve

Thanks-to: Mariusz Czułada <manieq.net@gmail.com>
上级 02749917
...@@ -2269,8 +2269,8 @@ static void core_event_handler(switch_event_t *event) ...@@ -2269,8 +2269,8 @@ static void core_event_handler(switch_event_t *event)
break; break;
} }
case SWITCH_EVENT_CHANNEL_CREATE: case SWITCH_EVENT_CHANNEL_CREATE:
new_sql() = switch_mprintf("insert into channels (uuid,direction,created,created_epoch, name,state,callstate,dialplan,context,hostname) " new_sql() = switch_mprintf("insert into channels (uuid,direction,created,created_epoch, name,state,callstate,dialplan,context,hostname,initial_cid_name,initial_cid_num,initial_ip_addr,initial_dest,initial_dialplan,initial_context) "
"values('%q','%q','%q','%ld','%q','%q','%q','%q','%q','%q')", "values('%q','%q','%q','%ld','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
switch_event_get_header_nil(event, "unique-id"), switch_event_get_header_nil(event, "unique-id"),
switch_event_get_header_nil(event, "call-direction"), switch_event_get_header_nil(event, "call-direction"),
switch_event_get_header_nil(event, "event-date-local"), switch_event_get_header_nil(event, "event-date-local"),
...@@ -2279,7 +2279,13 @@ static void core_event_handler(switch_event_t *event) ...@@ -2279,7 +2279,13 @@ static void core_event_handler(switch_event_t *event)
switch_event_get_header_nil(event, "channel-state"), switch_event_get_header_nil(event, "channel-state"),
switch_event_get_header_nil(event, "channel-call-state"), switch_event_get_header_nil(event, "channel-call-state"),
switch_event_get_header_nil(event, "caller-dialplan"), switch_event_get_header_nil(event, "caller-dialplan"),
switch_event_get_header_nil(event, "caller-context"), switch_core_get_switchname() switch_event_get_header_nil(event, "caller-context"), switch_core_get_switchname(),
switch_event_get_header_nil(event, "caller-caller-id-name"),
switch_event_get_header_nil(event, "caller-caller-id-number"),
switch_event_get_header_nil(event, "caller-network-addr"),
switch_event_get_header_nil(event, "caller-destination-number"),
switch_event_get_header_nil(event, "caller-dialplan"),
switch_event_get_header_nil(event, "caller-context")
); );
break; break;
case SWITCH_EVENT_CHANNEL_ANSWER: case SWITCH_EVENT_CHANNEL_ANSWER:
...@@ -2666,7 +2672,13 @@ static char create_channels_sql[] = ...@@ -2666,7 +2672,13 @@ static char create_channels_sql[] =
" callee_direction VARCHAR(5),\n" " callee_direction VARCHAR(5),\n"
" call_uuid VARCHAR(256),\n" " call_uuid VARCHAR(256),\n"
" sent_callee_name VARCHAR(1024),\n" " sent_callee_name VARCHAR(1024),\n"
" sent_callee_num VARCHAR(256)\n" " sent_callee_num VARCHAR(256),\n"
" initial_cid_name VARCHAR(1024),\n"
" initial_cid_num VARCHAR(256),\n"
" initial_ip_addr VARCHAR(256),\n"
" initial_dest VARCHAR(1024),\n"
" initial_dialplan VARCHAR(128),\n"
" initial_context VARCHAR(128)\n"
");\n"; ");\n";
static char create_calls_sql[] = static char create_calls_sql[] =
...@@ -3385,7 +3397,7 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_ ...@@ -3385,7 +3397,7 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
char *err; char *err;
int result = 0; int result = 0;
switch_cache_db_test_reactive(sql_manager.dbh, "select call_uuid, read_bit_rate, sent_callee_name from channels", "DROP TABLE channels", create_channels_sql); switch_cache_db_test_reactive(sql_manager.dbh, "select call_uuid, read_bit_rate, sent_callee_name, initial_cid_name, initial_cid_num, initial_ip_addr, initial_dest, initial_dialplan, initial_context from channels", "DROP TABLE channels", create_channels_sql);
switch_cache_db_test_reactive(sql_manager.dbh, "select * from detailed_calls where sent_callee_name=''", "DROP VIEW detailed_calls", detailed_calls_sql); switch_cache_db_test_reactive(sql_manager.dbh, "select * from detailed_calls where sent_callee_name=''", "DROP VIEW detailed_calls", detailed_calls_sql);
switch_cache_db_test_reactive(sql_manager.dbh, "select * from basic_calls where sent_callee_name=''", "DROP VIEW basic_calls", basic_calls_sql); switch_cache_db_test_reactive(sql_manager.dbh, "select * from basic_calls where sent_callee_name=''", "DROP VIEW basic_calls", basic_calls_sql);
switch_cache_db_test_reactive(sql_manager.dbh, "select call_uuid from calls", "DROP TABLE calls", create_calls_sql); switch_cache_db_test_reactive(sql_manager.dbh, "select call_uuid from calls", "DROP TABLE calls", create_calls_sql);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论