add channel events to message when its in-dialog

This commit is contained in:
Anthony Minessale 2012-08-30 16:38:31 -05:00 committed by Ken Rice
parent 53e22518ea
commit 62ce2970c5
3 changed files with 16 additions and 3 deletions

View File

@ -983,7 +983,7 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n
sofia_dispatch_event_t *de,
tagi_t tags[]);
void sofia_presence_handle_sip_i_message(int status, char const *phrase, nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh,
sofia_private_t *sofia_private, sip_t const *sip,
switch_core_session_t *session, sofia_private_t *sofia_private, sip_t const *sip,
sofia_dispatch_event_t *de, tagi_t tags[]);
void sofia_presence_handle_sip_r_subscribe(int status, char const *phrase, nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh,
sofia_private_t *sofia_private, sip_t const *sip,

View File

@ -1185,7 +1185,7 @@ static void our_sofia_event_callback(nua_event_t event,
sofia_handle_sip_i_state(session, status, phrase, nua, profile, nh, sofia_private, sip, de, tags);
break;
case nua_i_message:
sofia_presence_handle_sip_i_message(status, phrase, nua, profile, nh, sofia_private, sip, de, tags);
sofia_presence_handle_sip_i_message(status, phrase, nua, profile, nh, session, sofia_private, sip, de, tags);
break;
case nua_i_info:
sofia_handle_sip_i_info(nua, profile, nh, session, sip, de, tags);

View File

@ -4268,7 +4268,9 @@ void sofia_presence_set_hash_key(char *hash_key, int32_t len, sip_t const *sip)
void sofia_presence_handle_sip_i_message(int status,
char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh,
switch_core_session_t *session,
sofia_private_t *sofia_private, sip_t const *sip,
sofia_dispatch_event_t *de,
tagi_t tags[])
{
@ -4284,6 +4286,12 @@ void sofia_presence_handle_sip_i_message(int status,
const char *us;
char network_ip[80];
int network_port = 0;
switch_channel_t *channel = NULL;
if (session) {
channel = switch_core_session_get_channel(session);
}
if ((us = sofia_glue_get_unknown_header(sip, "X-FS-Sending-Message")) && !strcmp(us, switch_core_get_uuid())) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Not sending message to ourselves!\n");
@ -4380,6 +4388,11 @@ void sofia_presence_handle_sip_i_message(int status,
switch_event_add_body(event, "%s", msg);
}
if (channel) {
switch_channel_event_set_data(channel, event);
}
if (sofia_test_pflag(profile, PFLAG_FIRE_MESSAGE_EVENTS)) {
if (switch_event_dup(&event_dup, event) == SWITCH_STATUS_SUCCESS) {
event_dup->event_id = SWITCH_EVENT_RECV_MESSAGE;