Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
638c28d0
提交
638c28d0
authored
7月 28, 2010
作者:
Brian West
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update pidf relates presence code
上级
d146b15a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
68 行增加
和
48 行删除
+68
-48
sofia_presence.c
src/mod/endpoints/mod_sofia/sofia_presence.c
+54
-45
sofia_reg.c
src/mod/endpoints/mod_sofia/sofia_reg.c
+14
-3
没有找到文件。
src/mod/endpoints/mod_sofia/sofia_presence.c
浏览文件 @
638c28d0
...
...
@@ -55,6 +55,7 @@ static void sync_sla(sofia_profile_t *profile, const char *to_user, const char *
struct
resub_helper
{
sofia_profile_t
*
profile
;
switch_event_t
*
event
;
int
rowcount
;
};
struct
presence_helper
{
...
...
@@ -549,7 +550,7 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
"(sip_registrations.sip_host='%q' or sip_registrations.presence_hosts like '%%%q%%')"
,
probe_host
,
probe_euser
,
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
);
...
...
@@ -565,6 +566,18 @@ static void actual_sofia_presence_event_handler(switch_event_t *event)
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"%s END_PRESENCE_PROBE_SQL
\n\n
"
,
profile
->
name
);
}
if
(
!
h
.
rowcount
)
{
switch_event_t
*
sevent
;
if
(
switch_event_create
(
&
sevent
,
SWITCH_EVENT_PRESENCE_IN
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"proto"
,
SOFIA_CHAT_PROTO
);
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"login"
,
profile
->
name
);
switch_event_add_header
(
sevent
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
probe_euser
,
probe_host
);
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"status"
,
"Unregistered"
);
switch_event_fire
(
&
sevent
);
}
}
sofia_glue_release_profile
(
profile
);
switch_safe_free
(
sql
);
}
...
...
@@ -953,6 +966,7 @@ static int sofia_presence_resub_callback(void *pArg, int argc, char **argv, char
switch_event_fire
(
&
event
);
}
h
->
rowcount
++
;
return
0
;
}
...
...
@@ -1018,11 +1032,17 @@ static char *gen_pidf(char *user_agent, char *id, char *url, char *open, char *r
}
else
{
*
ct
=
"application/pidf+xml"
;
if
(
!
strncasecmp
(
status
,
"Registered
("
,
11
))
{
if
(
!
strncasecmp
(
status
,
"Registered
"
,
10
))
{
prpid
=
NULL
;
status
=
"Available"
;
}
if
(
!
strcasecmp
(
status
,
"Unregistered"
))
{
prpid
=
NULL
;
open
=
"closed"
;
}
if
(
prpid
)
{
ret
=
switch_mprintf
(
"<?xml version=
\"
1.0
\"
encoding=
\"
ISO-8859-1
\"
?>
\n
"
"<presence xmlns='urn:ietf:params:xml:ns:pidf'
\n
"
...
...
@@ -1346,8 +1366,6 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
open
=
"closed"
;
}
printf
(
"WTF %s
\n
%s
\n
"
,
ct
,
content
);
if
(
content
)
{
pl
=
strdup
(
content
);
}
else
{
...
...
@@ -1363,8 +1381,6 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
open
=
"closed"
;
}
printf
(
"WTF2 %s
\n
%s
\n
"
,
ct
,
content
);
if
(
content
)
{
pl
=
strdup
(
content
);
}
else
{
...
...
@@ -1897,36 +1913,6 @@ void sofia_presence_handle_sip_i_subscribe(int status,
switch_snprintf
(
exp_delta_str
,
sizeof
(
exp_delta_str
),
"%ld"
,
exp_delta
);
if
(
to_user
&&
(
strstr
(
to_user
,
"ext+"
)
||
strstr
(
to_user
,
"user+"
)))
{
char
protocol
[
80
];
char
*
p
;
switch_copy_string
(
protocol
,
to_user
,
sizeof
(
protocol
));
if
((
p
=
strchr
(
protocol
,
'+'
)))
{
*
p
=
'\0'
;
}
if
(
switch_event_create
(
&
sevent
,
SWITCH_EVENT_PRESENCE_IN
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"proto"
,
protocol
);
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"login"
,
profile
->
name
);
switch_event_add_header
(
sevent
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
to_user
,
to_host
);
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
"active"
);
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"status"
,
"Click To Call"
);
switch_event_fire
(
&
sevent
);
}
}
else
{
if
(
switch_event_create
(
&
sevent
,
SWITCH_EVENT_PRESENCE_PROBE
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"proto"
,
SOFIA_CHAT_PROTO
);
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"login"
,
profile
->
name
);
switch_event_add_header
(
sevent
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
from_user
,
from_host
);
switch_event_add_header
(
sevent
,
SWITCH_STACK_BOTTOM
,
"to"
,
"%s@%s"
,
to_user
,
to_host
);
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"proto-specific-event-name"
,
event
);
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"expires"
,
exp_delta_str
);
switch_event_fire
(
&
sevent
);
}
}
if
(
to_user
&&
strchr
(
to_user
,
'+'
))
{
char
*
h
;
if
((
proto
=
(
d_user
=
strdup
(
to_user
))))
{
...
...
@@ -2174,19 +2160,42 @@ void sofia_presence_handle_sip_i_subscribe(int status,
switch_safe_free
(
sql
);
}
}
else
{
if
((
sql
=
switch_mprintf
(
"select proto,sip_user,'%q',sub_to_user,sub_to_host,event,contact,call_id,full_from,"
"full_via,expires,user_agent,accept,profile_name,network_ip"
" from sip_subscriptions where expires > -1 and event='%s' and sip_user='%q' "
"and (sip_host='%q' or presence_hosts like '%%%q%%')"
,
to_host
,
event
,
to_user
,
to_host
,
to_host
)))
{
sofia_glue_execute_sql_callback
(
profile
,
profile
->
ireg_mutex
,
sql
,
sofia_presence_sub_callback
,
profile
);
switch_safe_free
(
sql
);
}
}
end:
if
(
to_user
&&
(
strstr
(
to_user
,
"ext+"
)
||
strstr
(
to_user
,
"user+"
)))
{
char
protocol
[
80
];
char
*
p
;
switch_copy_string
(
protocol
,
to_user
,
sizeof
(
protocol
));
if
((
p
=
strchr
(
protocol
,
'+'
)))
{
*
p
=
'\0'
;
}
if
(
switch_event_create
(
&
sevent
,
SWITCH_EVENT_PRESENCE_IN
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"proto"
,
protocol
);
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"login"
,
profile
->
name
);
switch_event_add_header
(
sevent
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
to_user
,
to_host
);
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
"active"
);
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"status"
,
"Click To Call"
);
switch_event_fire
(
&
sevent
);
}
}
else
{
if
(
switch_event_create
(
&
sevent
,
SWITCH_EVENT_PRESENCE_PROBE
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"proto"
,
SOFIA_CHAT_PROTO
);
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"login"
,
profile
->
name
);
switch_event_add_header
(
sevent
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
from_user
,
from_host
);
switch_event_add_header
(
sevent
,
SWITCH_STACK_BOTTOM
,
"to"
,
"%s@%s"
,
to_user
,
to_host
);
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"proto-specific-event-name"
,
event
);
switch_event_add_header_string
(
sevent
,
SWITCH_STACK_BOTTOM
,
"expires"
,
exp_delta_str
);
switch_event_fire
(
&
sevent
);
}
}
if
(
event
)
{
su_free
(
profile
->
home
,
event
);
}
...
...
src/mod/endpoints/mod_sofia/sofia_reg.c
浏览文件 @
638c28d0
...
...
@@ -1124,7 +1124,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
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
(
profile
,
&
sql
,
SWITCH_TRUE
);
sofia_glue_execute_sql
_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
switch_find_local_ip
(
guess_ip4
,
sizeof
(
guess_ip4
),
NULL
,
AF_INET
);
sql
=
switch_mprintf
(
"insert into sip_registrations "
...
...
@@ -1138,7 +1138,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
mwi_user
,
mwi_host
,
guess_ip4
,
mod_sofia_globals
.
hostname
);
if
(
sql
)
{
sofia_glue_execute_sql
(
profile
,
&
sql
,
SWITCH_TRUE
);
sofia_glue_execute_sql
_now
(
profile
,
&
sql
,
SWITCH_TRUE
);
}
switch_mutex_unlock
(
profile
->
ireg_mutex
);
...
...
@@ -1204,7 +1204,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
}
else
{
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_
OUT
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_
IN
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
SOFIA_CHAT_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
rpid
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
profile
->
url
);
...
...
@@ -1287,6 +1287,17 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"VM-Call-ID"
,
call_id
);
}
}
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_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
"closed"
);
switch_event_add_header_string
(
s_event
,
SWITCH_STACK_BOTTOM
,
"status"
,
"Registered"
);
switch_event_fire
(
&
s_event
);
}
}
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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论