Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
4da5c5cf
提交
4da5c5cf
authored
9月 02, 2010
作者:
Anthony Minessale
提交者:
Brian West
9月 02, 2010
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
presence issues for dialog_info
上级
2002f38b
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
75 行增加
和
30 行删除
+75
-30
sofia_presence.c
src/mod/endpoints/mod_sofia/sofia_presence.c
+20
-16
sofia_reg.c
src/mod/endpoints/mod_sofia/sofia_reg.c
+55
-14
没有找到文件。
src/mod/endpoints/mod_sofia/sofia_presence.c
浏览文件 @
4da5c5cf
...
...
@@ -565,34 +565,32 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
probe_euser
=
(
p
+
1
);
}
if
(
probe_euser
&&
probe_host
&&
(
profile
=
sofia_glue_find_profile
(
probe_host
)))
{
sql
=
switch_mprintf
(
"select status,rpid from sip_dialogs where sip_from_user='%q' and sip_from_host='%q'"
,
probe_euser
,
probe_host
);
sofia_glue_execute_sql_callback
(
profile
,
profile
->
ireg_mutex
,
sql
,
sofia_presence_dialog_callback
,
&
dh
);
switch_safe_free
(
sql
);
sql
=
switch_mprintf
(
"select sip_registrations.sip_user,
'%q'
, sip_registrations.status, "
sql
=
switch_mprintf
(
"select sip_registrations.sip_user,
sip_registrations.orig_server_host
, sip_registrations.status, "
"sip_registrations.rpid,'', sip_dialogs.uuid, sip_dialogs.state, sip_dialogs.direction, "
"sip_dialogs.sip_to_user, sip_dialogs.sip_to_host, sip_presence.status,sip_presence.rpid,sip_presence.open_closed,"
"'%q','%q' "
"from sip_registrations left join sip_dialogs on "
"(sip_dialogs.sip_from_user = sip_registrations.sip_user "
"and sip_dialogs.sip_from_host = sip_registrations.sip_host) "
"and (sip_dialogs.sip_from_host = sip_registrations.orig_server_host or "
"sip_dialogs.sip_from_host = sip_registrations.sip_host) ) "
"left join sip_presence on "
"(sip_registrations.sip_user=sip_presence.sip_user and sip_registrations.
sip
_host=sip_presence.sip_host and "
"(sip_registrations.sip_user=sip_presence.sip_user and sip_registrations.
orig_server
_host=sip_presence.sip_host and "
"sip_registrations.profile_name=sip_presence.profile_name) "
"where sip_registrations.sip_user='%q' and "
"(sip_registrations.sip_host='%q' or sip_registrations.presence_hosts like '%%%q%%')"
,
probe_host
,
dh
.
status
,
dh
.
rpid
,
probe_euser
,
probe_host
,
probe_host
);
"(sip_registrations.orig_server_host='%q' or sip_registrations.sip_host='%q' "
"or sip_registrations.presence_hosts like '%%%q%%')"
,
dh
.
status
,
dh
.
rpid
,
probe_euser
,
probe_host
,
probe_host
,
probe_host
);
switch_assert
(
sql
);
if
(
mod_sofia_globals
.
debug_presence
>
0
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"%s START_PRESENCE_PROBE_SQL
\n
"
,
profile
->
name
);
}
...
...
@@ -622,6 +620,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
sofia_glue_release_profile
(
profile
);
switch_safe_free
(
sql
);
}
switch_safe_free
(
probe_user
);
}
...
...
@@ -961,7 +960,7 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char
switch_event_header_t
*
hp
;
if
(
argc
>
5
)
{
uuid
=
switch_str_nil
(
argv
[
5
])
;
uuid
=
argv
[
5
]
;
state
=
switch_str_nil
(
argv
[
6
]);
direction
=
switch_str_nil
(
argv
[
7
]);
if
(
argc
>
8
)
{
...
...
@@ -998,12 +997,13 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char
}
if
(
zstr
(
state
))
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"unique-id"
,
SOFIA_CHAT_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"channel-state"
,
"CS_HANGUP"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"answer-state"
,
"resubscribe"
);
//
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "resubscribe");
}
else
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"channel-state"
,
"CS_ROUTING"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"unique-id"
,
uuid
);
if
(
uuid
)
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"unique-id"
,
uuid
);
}
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"answer-state"
,
state
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"astate"
,
state
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"presence-call-direction"
,
direction
);
...
...
@@ -1327,10 +1327,11 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
"<dialog-info xmlns=
\"
urn:ietf:params:xml:ns:dialog-info
\"
"
"version=
\"
%s
\"
state=
\"
%s
\"
entity=
\"
%s
\"
>
\n
"
,
version
,
!
strcasecmp
(
answer_state
,
"resubscribe"
)
?
"partial"
:
"full"
,
clean_id
);
zstr
(
uuid
)
?
"partial"
:
"full"
,
clean_id
);
}
if
(
strcasecmp
(
event_status
,
"Registered"
))
{
//if (strcasecmp(event_status, "Registered")) {
if
(
!
zstr
(
uuid
))
{
if
(
!
zstr
(
answer_state
))
{
astate
=
answer_state
;
}
...
...
@@ -2237,8 +2238,11 @@ void sofia_presence_handle_sip_i_subscribe(int status,
if
(
switch_event_create
(
&
pevent
,
SWITCH_EVENT_PRESENCE_PROBE
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
pevent
,
SWITCH_STACK_BOTTOM
,
"proto"
,
SOFIA_CHAT_PROTO
);
switch_event_add_header_string
(
pevent
,
SWITCH_STACK_BOTTOM
,
"login"
,
profile
->
url
);
switch_event_add_header
(
pevent
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
to_user
,
to_host
);
//switch_event_add_header(pevent, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, to_host);
switch_event_add_header
(
pevent
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
from_user
,
from_host
);
switch_event_add_header
(
pevent
,
SWITCH_STACK_BOTTOM
,
"to"
,
"%s@%s"
,
to_user
,
to_host
);
switch_event_add_header_string
(
pevent
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
switch_event_add_header_string
(
pevent
,
SWITCH_STACK_BOTTOM
,
"alt_event_type"
,
"dialog"
);
switch_event_add_header_string
(
pevent
,
SWITCH_STACK_BOTTOM
,
"event_subtype"
,
"probe"
);
switch_event_add_header_string
(
pevent
,
SWITCH_STACK_BOTTOM
,
"proto-specific-event-name"
,
event
);
switch_event_add_header_string
(
pevent
,
SWITCH_STACK_BOTTOM
,
"expires"
,
exp_delta_str
);
...
...
src/mod/endpoints/mod_sofia/sofia_reg.c
浏览文件 @
4da5c5cf
...
...
@@ -787,6 +787,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
const
char
*
from_user
=
NULL
;
const
char
*
from_host
=
NULL
;
const
char
*
reg_host
=
profile
->
reg_db_domain
;
const
char
*
sub_host
=
profile
->
sub_domain
;
char
contact_str
[
1024
]
=
""
;
int
nat_hack
=
0
;
uint8_t
multi_reg
=
0
,
multi_reg_contact
=
0
,
avoid_multi_reg
=
0
;
...
...
@@ -851,6 +852,9 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
if
(
!
reg_host
)
{
reg_host
=
to_host
;
}
if
(
!
sub_host
)
{
sub_host
=
to_host
;
}
if
(
contact
->
m_url
)
{
const
char
*
port
=
contact
->
m_url
->
url_port
;
...
...
@@ -1146,11 +1150,14 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
}
if
(
multi_reg
)
{
#ifdef DEL_SUBS
if
(
reg_count
==
1
)
{
sql
=
switch_mprintf
(
"delete from sip_subscriptions where sip_user='%q' and sip_host='%q' and contact='%q'"
,
to_user
,
reg
_host
,
contact_str
);
to_user
,
sub
_host
,
contact_str
);
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
}
#endif
if
(
multi_reg_contact
)
{
...
...
@@ -1160,14 +1167,35 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
sql
=
switch_mprintf
(
"delete from sip_registrations where call_id='%q'"
,
call_id
);
}
}
else
{
sql
=
switch_mprintf
(
"delete from sip_subscriptions where sip_user='%q' and sip_host='%q'"
,
to_user
,
reg_host
);
#ifdef DEL_SUBS
sql
=
switch_mprintf
(
"delete from sip_subscriptions where sip_user='%q' and sip_host='%q'"
,
to_user
,
sub_host
);
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
#endif
sql
=
switch_mprintf
(
"delete from sip_registrations where sip_user='%q' and sip_host='%q'"
,
to_user
,
reg_host
);
}
switch_mutex_lock
(
profile
->
ireg_mutex
);
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
switch_find_local_ip
(
guess_ip4
,
sizeof
(
guess_ip4
),
NULL
,
AF_INET
);
if
(
profile
->
reg_db_domain
)
{
sofia_profile_t
*
xprofile
;
if
((
xprofile
=
sofia_glue_find_profile
(
to_host
)))
{
sofia_glue_release_profile
(
xprofile
);
}
else
{
if
(
sofia_glue_add_profile
(
switch_core_strdup
(
profile
->
pool
,
to_host
),
profile
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"Auto-Adding Alias [%s] for profile [%s]
\n
"
,
to_host
,
profile
->
name
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"Alias [%s] for profile [%s] (already exists)
\n
"
,
to_host
,
profile
->
name
);
}
}
}
sql
=
switch_mprintf
(
"insert into sip_registrations "
"(call_id,sip_user,sip_host,presence_hosts,contact,status,rpid,expires,"
...
...
@@ -1220,7 +1248,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", profile->url);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "user-agent",
(sip && sip->sip_user_agent) ? sip->sip_user_agent->g_string : "unknown");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user,
reg
_host);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user,
sub
_host);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", "Registered");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_fire(&event);
...
...
@@ -1234,8 +1262,8 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
"sip"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
profile
->
url
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
rpid
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
to_user
,
reg
_host
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"to"
,
"%s@%s"
,
to_user
,
reg
_host
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
to_user
,
sub
_host
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"to"
,
"%s@%s"
,
to_user
,
sub
_host
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"status"
,
"Registered"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"event_subtype"
,
"probe"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
...
...
@@ -1253,7 +1281,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
profile
->
url
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"user-agent"
,
(
sip
&&
sip
->
sip_user_agent
)
?
sip
->
sip_user_agent
->
g_string
:
"unknown"
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
to_user
,
reg
_host
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
to_user
,
sub
_host
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"status"
,
"Unregistered"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
switch_event_fire
(
&
event
);
...
...
@@ -1262,7 +1290,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_OUT) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", "sip");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", profile->url);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s+%s@%s", SOFIA_CHAT_PROTO, to_user,
reg
_host);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s+%s@%s", SOFIA_CHAT_PROTO, to_user,
sub
_host);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", "unavailable");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", rpid);
...
...
@@ -1280,15 +1308,16 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
if
((
p
=
strchr
(
icontact
+
4
,
':'
)))
{
*
p
=
'\0'
;
}
#ifdef DEL_SUBS
if
(
multi_reg_contact
)
{
sql
=
switch_mprintf
(
"delete from sip_subscriptions where sip_user='%q' and sip_host='%q' and contact='%q'"
,
to_user
,
reg
_host
,
contact_str
);
switch_mprintf
(
"delete from sip_subscriptions where sip_user='%q' and sip_host='%q' and contact='%q'"
,
to_user
,
sub
_host
,
contact_str
);
}
else
{
sql
=
switch_mprintf
(
"delete from sip_subscriptions where call_id='%q'"
,
call_id
);
}
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
#endif
if
(
multi_reg_contact
)
{
sql
=
...
...
@@ -1301,10 +1330,11 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
switch_safe_free
(
icontact
);
}
else
{
if
((
sql
=
switch_mprintf
(
"delete from sip_subscriptions where sip_user='%q' and sip_host='%q'"
,
to_user
,
reg_host
)))
{
#ifdef DEL_SUBS
if
((
sql
=
switch_mprintf
(
"delete from sip_subscriptions where sip_user='%q' and sip_host='%q'"
,
to_user
,
sub_host
)))
{
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
}
#endif
if
((
sql
=
switch_mprintf
(
"delete from sip_registrations where sip_user='%q' and sip_host='%q'"
,
to_user
,
reg_host
)))
{
sofia_glue_execute_sql_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
}
...
...
@@ -1333,15 +1363,26 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
}
#if 0
if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "login", profile->name);
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, sub_host);
switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "to", "%s@%s", to_user, sub_host);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
switch_event_fire(&s_event);
}
#else
if
(
switch_event_create
(
&
s_event
,
SWITCH_EVENT_PRESENCE_IN
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
SOFIA_CHAT_PROTO
);
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"login"
,
profile
->
name
);
switch_event_add_header
(
s_event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
to_user
,
reg
_host
);
switch_event_add_header
(
s_event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
to_user
,
sub
_host
);
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
"unknown"
);
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"status"
,
"Registered"
);
switch_event_fire
(
&
s_event
);
}
}
#endif
}
else
{
if
(
switch_event_create_subclass
(
&
s_event
,
SWITCH_EVENT_CUSTOM
,
MY_EVENT_UNREGISTER
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"profile-name"
,
profile
->
name
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论