提交 5cbfbb79 authored 作者: Michael Jerris's avatar Michael Jerris

fix mwi

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12841 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 debe5dae
...@@ -285,6 +285,7 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event) ...@@ -285,6 +285,7 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event)
char *pname = NULL; char *pname = NULL;
const char *call_id; const char *call_id;
const char *sub_call_id; const char *sub_call_id;
int for_everyone = 0;
switch_assert(event != NULL); switch_assert(event != NULL);
...@@ -301,6 +302,11 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event) ...@@ -301,6 +302,11 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event)
call_id = switch_event_get_header(event, "call-id"); call_id = switch_event_get_header(event, "call-id");
sub_call_id = switch_event_get_header(event, "sub-call-id"); sub_call_id = switch_event_get_header(event, "sub-call-id");
if (!call_id && !sub_call_id) {
for_everyone = 1;
}
dup_account = strdup(account); dup_account = strdup(account);
switch_assert(dup_account != NULL); switch_assert(dup_account != NULL);
sofia_glue_get_user_host(dup_account, &user, &host); sofia_glue_get_user_host(dup_account, &user, &host);
...@@ -346,34 +352,45 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event) ...@@ -346,34 +352,45 @@ static void actual_sofia_presence_mwi_event_handler(switch_event_t *event)
sql = NULL; sql = NULL;
if (sub_call_id) { if (for_everyone) {
sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from," sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,"
"full_via,expires,user_agent,accept,profile_name" "full_via,expires,user_agent,accept,profile_name"
",'%q','%q' from sip_subscriptions where event='message-summary' " ",'%q','%q' from sip_subscriptions where event='message-summary' "
"and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%' and call_id='%q')", "and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%')",
stream.data, host, user, host, host, sub_call_id); stream.data, host, user, host, host);
} else if (!call_id) { } else if (sub_call_id) {
sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from," sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,"
"full_via,expires,user_agent,accept,profile_name" "full_via,expires,user_agent,accept,profile_name"
",'%q','%q' from sip_subscriptions where event='message-summary' " ",'%q','%q' from sip_subscriptions where event='message-summary' "
"and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%')", "and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%' and call_id='%q')",
stream.data, host, user, host, host); stream.data, host, user, host, host, sub_call_id);
} }
if (sql) { if (sql) {
sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_mwi_callback, &h); sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_mwi_callback, &h);
switch_safe_free(sql); free(sql);
sql = NULL;
}
if (for_everyone) {
sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q' "
"from sip_registrations where sip_user='%q' and sip_host='%q'",
stream.data, user, host);
} else if (call_id) { } else if (call_id) {
sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q' " sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q' "
"from sip_registrations where sip_user='%q' and sip_host='%q' and call_id='%q'", "from sip_registrations where sip_user='%q' and sip_host='%q' and call_id='%q'",
stream.data, user, host, call_id); stream.data, user, host, call_id);
}
if (sql) {
switch_assert(sql != NULL); switch_assert(sql != NULL);
sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_mwi_callback2, &h); sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, sofia_presence_mwi_callback2, &h);
free(sql);
sql = NULL;
} }
switch_safe_free(sql);
switch_safe_free(stream.data); switch_safe_free(stream.data);
switch_safe_free(dup_account); switch_safe_free(dup_account);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论