update callstate in sql event handler

This commit is contained in:
Anthony Minessale 2010-06-24 10:32:45 -05:00
parent 10b8cfa18e
commit 3240a6f395
1 changed files with 12 additions and 6 deletions

View File

@ -1009,9 +1009,8 @@ static void core_event_handler(switch_event_t *event)
case SWITCH_EVENT_CHANNEL_HOLD: case SWITCH_EVENT_CHANNEL_HOLD:
case SWITCH_EVENT_CHANNEL_UNHOLD: case SWITCH_EVENT_CHANNEL_UNHOLD:
case SWITCH_EVENT_CHANNEL_EXECUTE: case SWITCH_EVENT_CHANNEL_EXECUTE:
sql = switch_mprintf("update channels set callstate='%q',application='%q',application_data='%q'," sql = switch_mprintf("update channels set application='%q',application_data='%q',"
"presence_id='%q',presence_data='%q' where uuid='%q' and hostname='%q'", "presence_id='%q',presence_data='%q' where uuid='%q' and hostname='%q'",
switch_event_get_header_nil(event, "channel-call-state"),
switch_event_get_header_nil(event, "application"), switch_event_get_header_nil(event, "application"),
switch_event_get_header_nil(event, "application-data"), switch_event_get_header_nil(event, "application-data"),
switch_event_get_header_nil(event, "channel-presence-id"), switch_event_get_header_nil(event, "channel-presence-id"),
@ -1045,6 +1044,15 @@ static void core_event_handler(switch_event_t *event)
} }
} }
break; break;
case SWITCH_EVENT_CHANNEL_CALLSTATE:
{
sql = switch_mprintf("update channels set callstate='%q' where uuid='%q' and hostname='%q'",
switch_event_get_header_nil(event, "channel-call-state"),
switch_event_get_header_nil(event, "unique-id"),
switch_core_get_variable("hostname"));
}
break;
case SWITCH_EVENT_CHANNEL_STATE: case SWITCH_EVENT_CHANNEL_STATE:
{ {
char *state = switch_event_get_header_nil(event, "channel-state-number"); char *state = switch_event_get_header_nil(event, "channel-state-number");
@ -1059,11 +1067,10 @@ static void core_event_handler(switch_event_t *event)
case CS_DESTROY: case CS_DESTROY:
break; break;
case CS_ROUTING: case CS_ROUTING:
sql = switch_mprintf("update channels set state='%s',callstate='%q',cid_name='%q',cid_num='%q'," sql = switch_mprintf("update channels set state='%s',cid_name='%q',cid_num='%q',"
"ip_addr='%s',dest='%q',dialplan='%q',context='%q',presence_id='%q',presence_data='%q' " "ip_addr='%s',dest='%q',dialplan='%q',context='%q',presence_id='%q',presence_data='%q' "
"where uuid='%s' and hostname='%q'", "where uuid='%s' and hostname='%q'",
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, "caller-caller-id-name"), 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-caller-id-number"),
switch_event_get_header_nil(event, "caller-network-addr"), switch_event_get_header_nil(event, "caller-network-addr"),
@ -1075,9 +1082,8 @@ static void core_event_handler(switch_event_t *event)
switch_event_get_header_nil(event, "unique-id"), switch_core_get_variable("hostname")); switch_event_get_header_nil(event, "unique-id"), switch_core_get_variable("hostname"));
break; break;
default: default:
sql = switch_mprintf("update channels set state='%s',callstate='%s' where uuid='%s' and hostname='%q'", sql = switch_mprintf("update channels set state='%s' where uuid='%s' and hostname='%q'",
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, "unique-id"), switch_core_get_variable("hostname")); switch_event_get_header_nil(event, "unique-id"), switch_core_get_variable("hostname"));
break; break;
} }