Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
caa360b6
提交
caa360b6
authored
10月 22, 2011
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
presence tweaks for conference/fifo/parking
上级
ea359d89
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
135 行增加
和
129 行删除
+135
-129
mod_conference.c
src/mod/applications/mod_conference/mod_conference.c
+57
-66
mod_fifo.c
src/mod/applications/mod_fifo/mod_fifo.c
+35
-7
mod_valet_parking.c
src/mod/applications/mod_valet_parking/mod_valet_parking.c
+43
-56
没有找到文件。
src/mod/applications/mod_conference/mod_conference.c
浏览文件 @
caa360b6
...
@@ -430,6 +430,7 @@ static switch_status_t conference_say(conference_obj_t *conference, const char *
...
@@ -430,6 +430,7 @@ static switch_status_t conference_say(conference_obj_t *conference, const char *
static
void
conference_list
(
conference_obj_t
*
conference
,
switch_stream_handle_t
*
stream
,
char
*
delim
);
static
void
conference_list
(
conference_obj_t
*
conference
,
switch_stream_handle_t
*
stream
,
char
*
delim
);
static
conference_obj_t
*
conference_find
(
char
*
name
);
static
conference_obj_t
*
conference_find
(
char
*
name
);
static
void
member_bind_controls
(
conference_member_t
*
member
,
const
char
*
controls
);
static
void
member_bind_controls
(
conference_member_t
*
member
,
const
char
*
controls
);
static
void
conference_send_presence
(
conference_obj_t
*
conference
);
SWITCH_STANDARD_API
(
conf_api_main
);
SWITCH_STANDARD_API
(
conf_api_main
);
...
@@ -893,25 +894,7 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe
...
@@ -893,25 +894,7 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe
if
(
conference
->
end_count
++
);
if
(
conference
->
end_count
++
);
}
}
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_IN
)
==
SWITCH_STATUS_SUCCESS
)
{
conference_send_presence
(
conference
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
CONF_CHAT_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
conference
->
name
);
if
(
strchr
(
conference
->
name
,
'@'
))
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
conference
->
name
);
}
else
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
conference
->
name
,
conference
->
domain
);
}
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Active (%d caller%s)"
,
conference
->
count
,
conference
->
count
==
1
?
""
:
"s"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"alt_event_type"
,
"dialog"
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"event_count"
,
"%d"
,
EC
++
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"unique-id"
,
conference
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"channel-state"
,
"CS_ROUTING"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"answer-state"
,
conference
->
count
==
1
?
"early"
:
"confirmed"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"presence-call-direction"
,
conference
->
count
==
1
?
"outbound"
:
"inbound"
);
switch_event_fire
(
&
event
);
}
channel
=
switch_core_session_get_channel
(
member
->
session
);
channel
=
switch_core_session_get_channel
(
member
->
session
);
switch_channel_set_variable_printf
(
channel
,
"conference_member_id"
,
"%d"
,
member
->
id
);
switch_channel_set_variable_printf
(
channel
,
"conference_member_id"
,
"%d"
,
member
->
id
);
...
@@ -1119,25 +1102,7 @@ static switch_status_t conference_del_member(conference_obj_t *conference, confe
...
@@ -1119,25 +1102,7 @@ static switch_status_t conference_del_member(conference_obj_t *conference, confe
}
}
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_IN
)
==
SWITCH_STATUS_SUCCESS
)
{
conference_send_presence
(
conference
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
CONF_CHAT_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
conference
->
name
);
if
(
strchr
(
conference
->
name
,
'@'
))
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
conference
->
name
);
}
else
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
conference
->
name
,
conference
->
domain
);
}
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Active (%d caller%s)"
,
conference
->
count
,
conference
->
count
==
1
?
""
:
"s"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"alt_event_type"
,
"dialog"
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"event_count"
,
"%d"
,
EC
++
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"unique-id"
,
conference
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"channel-state"
,
"CS_ROUTING"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"answer-state"
,
conference
->
count
==
1
?
"early"
:
"confirmed"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"call-direction"
,
conference
->
count
==
1
?
"outbound"
:
"inbound"
);
switch_event_fire
(
&
event
);
}
if
((
conference
->
min
&&
switch_test_flag
(
conference
,
CFLAG_ENFORCE_MIN
)
&&
conference
->
count
<
conference
->
min
)
if
((
conference
->
min
&&
switch_test_flag
(
conference
,
CFLAG_ENFORCE_MIN
)
&&
conference
->
count
<
conference
->
min
)
||
(
switch_test_flag
(
conference
,
CFLAG_DYNAMIC
)
&&
conference
->
count
==
0
))
{
||
(
switch_test_flag
(
conference
,
CFLAG_DYNAMIC
)
&&
conference
->
count
==
0
))
{
...
@@ -1718,26 +1683,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
...
@@ -1718,26 +1683,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
}
}
}
}
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_IN
)
==
SWITCH_STATUS_SUCCESS
)
{
conference_send_presence
(
conference
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
CONF_CHAT_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
conference
->
name
);
if
(
strchr
(
conference
->
name
,
'@'
))
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
conference
->
name
);
}
else
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
conference
->
name
,
conference
->
domain
);
}
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Inactive"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
"unknown"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"alt_event_type"
,
"dialog"
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"event_count"
,
"%d"
,
EC
++
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"unique-id"
,
conference
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"channel-state"
,
"CS_HANGUP"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"answer-state"
,
"terminated"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"call-direction"
,
"inbound"
);
switch_event_fire
(
&
event
);
}
switch_mutex_lock
(
conference
->
mutex
);
switch_mutex_lock
(
conference
->
mutex
);
conference_stop_file
(
conference
,
FILE_STOP_ASYNC
);
conference_stop_file
(
conference
,
FILE_STOP_ASYNC
);
...
@@ -7205,31 +7151,75 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c
...
@@ -7205,31 +7151,75 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_c
return
conference
;
return
conference
;
}
}
static
void
conference_send_presence
(
conference_obj_t
*
conference
)
{
switch_event_t
*
event
;
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_IN
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
CONF_CHAT_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
conference
->
name
);
if
(
strchr
(
conference
->
name
,
'@'
))
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
conference
->
name
);
}
else
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
conference
->
name
,
conference
->
domain
);
}
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"alt_event_type"
,
"dialog"
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"event_count"
,
"%d"
,
EC
++
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"unique-id"
,
conference
->
name
);
if
(
conference
->
count
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Active (%d caller%s)"
,
conference
->
count
,
conference
->
count
==
1
?
""
:
"s"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"channel-state"
,
"CS_ROUTING"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"answer-state"
,
conference
->
count
==
1
?
"early"
:
"confirmed"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"presence-call-direction"
,
conference
->
count
==
1
?
"outbound"
:
"inbound"
);
}
else
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Inactive"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"channel-state"
,
"CS_HANGUP"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"answer-state"
,
"terminated"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"call-direction"
,
"inbound"
);
}
switch_event_fire
(
&
event
);
}
}
static
void
pres_event_handler
(
switch_event_t
*
event
)
static
void
pres_event_handler
(
switch_event_t
*
event
)
{
{
char
*
to
=
switch_event_get_header
(
event
,
"to"
);
char
*
to
=
switch_event_get_header
(
event
,
"to"
);
char
*
dup_to
=
NULL
,
*
conf_name
;
char
*
domain_name
=
NULL
;
char
*
dup_to
=
NULL
,
*
conf_name
,
*
dup_conf_name
=
NULL
;
conference_obj_t
*
conference
;
conference_obj_t
*
conference
;
if
(
!
to
||
strncasecmp
(
to
,
"conf+"
,
5
))
{
if
(
!
to
||
strncasecmp
(
to
,
"conf+"
,
5
)
||
!
strchr
(
to
,
'@'
)
)
{
return
;
return
;
}
}
if
(
!
(
dup_to
=
strdup
(
to
)))
{
if
(
!
(
dup_to
=
strdup
(
to
)))
{
return
;
return
;
}
}
conf_name
=
dup_to
+
5
;
conf_name
=
dup_to
+
5
;
if
((
conference
=
conference_find
(
conf_name
)))
{
if
((
domain_name
=
strchr
(
conf_name
,
'@'
)))
{
*
domain_name
++
=
'\0'
;
}
dup_conf_name
=
switch_mprintf
(
"%q@%q"
,
conf_name
,
domain_name
);
if
((
conference
=
conference_find
(
conf_name
))
||
(
conference
=
conference_find
(
dup_conf_name
)))
{
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_IN
)
==
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"
,
CONF_CHAT_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
CONF_CHAT_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
conference
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
conference
->
name
);
if
(
strchr
(
conference
->
name
,
'@'
))
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
conference
->
name
,
conference
->
domain
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
conference
->
name
);
}
else
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
conference
->
name
,
conference
->
domain
);
}
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Active (%d caller%s)"
,
conference
->
count
,
conference
->
count
==
1
?
""
:
"s"
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Active (%d caller%s)"
,
conference
->
count
,
conference
->
count
==
1
?
""
:
"s"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
...
@@ -7258,6 +7248,7 @@ static void pres_event_handler(switch_event_t *event)
...
@@ -7258,6 +7248,7 @@ static void pres_event_handler(switch_event_t *event)
}
}
switch_safe_free
(
dup_to
);
switch_safe_free
(
dup_to
);
switch_safe_free
(
dup_conf_name
);
}
}
static
void
send_presence
(
switch_event_types_t
id
)
static
void
send_presence
(
switch_event_types_t
id
)
...
...
src/mod/applications/mod_fifo/mod_fifo.c
浏览文件 @
caa360b6
...
@@ -311,6 +311,7 @@ struct fifo_node {
...
@@ -311,6 +311,7 @@ struct fifo_node {
outbound_strategy_t
outbound_strategy
;
outbound_strategy_t
outbound_strategy
;
int
ring_timeout
;
int
ring_timeout
;
int
default_lag
;
int
default_lag
;
char
*
domain_name
;
};
};
typedef
struct
fifo_node
fifo_node_t
;
typedef
struct
fifo_node
fifo_node_t
;
...
@@ -814,7 +815,8 @@ static fifo_node_t *create_node(const char *name, uint32_t importance, switch_mu
...
@@ -814,7 +815,8 @@ static fifo_node_t *create_node(const char *name, uint32_t importance, switch_mu
char
outbound_count
[
80
]
=
""
;
char
outbound_count
[
80
]
=
""
;
callback_t
cbt
=
{
0
};
callback_t
cbt
=
{
0
};
char
*
sql
=
NULL
;
char
*
sql
=
NULL
;
char
*
domain_name
=
NULL
;
if
(
!
globals
.
running
)
{
if
(
!
globals
.
running
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -826,6 +828,12 @@ static fifo_node_t *create_node(const char *name, uint32_t importance, switch_mu
...
@@ -826,6 +828,12 @@ static fifo_node_t *create_node(const char *name, uint32_t importance, switch_mu
node
->
pool
=
pool
;
node
->
pool
=
pool
;
node
->
outbound_strategy
=
default_strategy
;
node
->
outbound_strategy
=
default_strategy
;
node
->
name
=
switch_core_strdup
(
node
->
pool
,
name
);
node
->
name
=
switch_core_strdup
(
node
->
pool
,
name
);
if
(
!
strchr
(
name
,
'@'
))
{
domain_name
=
switch_core_get_variable_dup
(
"domain"
);
node
->
domain_name
=
switch_core_strdup
(
node
->
pool
,
domain_name
);
}
for
(
x
=
0
;
x
<
MAX_PRI
;
x
++
)
{
for
(
x
=
0
;
x
<
MAX_PRI
;
x
++
)
{
fifo_queue_create
(
&
node
->
fifo_list
[
x
],
1000
,
node
->
pool
);
fifo_queue_create
(
&
node
->
fifo_list
[
x
],
1000
,
node
->
pool
);
switch_assert
(
node
->
fifo_list
[
x
]);
switch_assert
(
node
->
fifo_list
[
x
]);
...
@@ -849,6 +857,9 @@ static fifo_node_t *create_node(const char *name, uint32_t importance, switch_mu
...
@@ -849,6 +857,9 @@ static fifo_node_t *create_node(const char *name, uint32_t importance, switch_mu
switch_mutex_lock
(
globals
.
mutex
);
switch_mutex_lock
(
globals
.
mutex
);
switch_core_hash_insert
(
globals
.
fifo_hash
,
name
,
node
);
switch_core_hash_insert
(
globals
.
fifo_hash
,
name
,
node
);
switch_mutex_unlock
(
globals
.
mutex
);
switch_mutex_unlock
(
globals
.
mutex
);
switch_safe_free
(
domain_name
);
return
node
;
return
node
;
}
}
...
@@ -1929,8 +1940,15 @@ static void send_presence(fifo_node_t *node)
...
@@ -1929,8 +1940,15 @@ static void send_presence(fifo_node_t *node)
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_IN
)
==
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"
,
"queue"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
"queue"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
node
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
node
->
name
);
if
(
node
->
domain_name
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
"%s@%s"
,
node
->
name
,
node
->
domain_name
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
node
->
name
,
node
->
domain_name
);
}
else
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
node
->
name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
node
->
name
);
}
if
((
wait_count
=
node_caller_count
(
node
))
>
0
)
{
if
((
wait_count
=
node_caller_count
(
node
))
>
0
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"status"
,
"Active (%d waiting)"
,
wait_count
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"status"
,
"Active (%d waiting)"
,
wait_count
);
}
else
{
}
else
{
...
@@ -1952,25 +1970,34 @@ static void send_presence(fifo_node_t *node)
...
@@ -1952,25 +1970,34 @@ static void send_presence(fifo_node_t *node)
static
void
pres_event_handler
(
switch_event_t
*
event
)
static
void
pres_event_handler
(
switch_event_t
*
event
)
{
{
char
*
to
=
switch_event_get_header
(
event
,
"to"
);
char
*
to
=
switch_event_get_header
(
event
,
"to"
);
char
*
dup_to
=
NULL
,
*
node_name
;
char
*
domain_name
=
NULL
;
char
*
dup_to
=
NULL
,
*
node_name
,
*
dup_node_name
;
fifo_node_t
*
node
;
fifo_node_t
*
node
;
if
(
!
globals
.
running
)
{
if
(
!
globals
.
running
)
{
return
;
return
;
}
}
if
(
!
to
||
strncasecmp
(
to
,
"queue+"
,
5
))
{
if
(
!
to
||
strncasecmp
(
to
,
"queue+"
,
6
)
||
!
strchr
(
to
,
'@'
))
{
return
;
return
;
}
}
dup_to
=
strdup
(
to
);
dup_to
=
strdup
(
to
);
switch_assert
(
dup_to
);
switch_assert
(
dup_to
);
node_name
=
dup_to
+
5
;
node_name
=
dup_to
+
6
;
if
((
domain_name
=
strchr
(
node_name
,
'@'
)))
{
*
domain_name
++
=
'\0'
;
}
dup_node_name
=
switch_mprintf
(
"%q@%q"
,
node_name
,
domain_name
);
switch_mutex_lock
(
globals
.
mutex
);
switch_mutex_lock
(
globals
.
mutex
);
if
(
!
(
node
=
switch_core_hash_find
(
globals
.
fifo_hash
,
node_name
)))
{
if
(
!
(
node
=
switch_core_hash_find
(
globals
.
fifo_hash
,
node_name
))
&&
!
(
node
=
switch_core_hash_find
(
globals
.
fifo_hash
,
dup_node_name
))
)
{
node
=
create_node
(
node_name
,
0
,
globals
.
sql_mutex
);
node
=
create_node
(
node_name
,
0
,
globals
.
sql_mutex
);
node
->
domain_name
=
switch_core_strdup
(
node
->
pool
,
domain_name
);
node
->
ready
=
1
;
node
->
ready
=
1
;
}
}
...
@@ -1979,6 +2006,7 @@ static void pres_event_handler(switch_event_t *event)
...
@@ -1979,6 +2006,7 @@ static void pres_event_handler(switch_event_t *event)
switch_mutex_unlock
(
globals
.
mutex
);
switch_mutex_unlock
(
globals
.
mutex
);
switch_safe_free
(
dup_to
);
switch_safe_free
(
dup_to
);
switch_safe_free
(
dup_node_name
);
}
}
static
uint32_t
fifo_add_outbound
(
const
char
*
node_name
,
const
char
*
url
,
uint32_t
priority
)
static
uint32_t
fifo_add_outbound
(
const
char
*
node_name
,
const
char
*
url
,
uint32_t
priority
)
...
...
src/mod/applications/mod_valet_parking/mod_valet_parking.c
浏览文件 @
caa360b6
...
@@ -53,6 +53,7 @@ typedef struct {
...
@@ -53,6 +53,7 @@ typedef struct {
switch_mutex_t
*
mutex
;
switch_mutex_t
*
mutex
;
switch_memory_pool_t
*
pool
;
switch_memory_pool_t
*
pool
;
time_t
last_timeout_check
;
time_t
last_timeout_check
;
char
*
name
;
}
valet_lot_t
;
}
valet_lot_t
;
static
valet_lot_t
globals
=
{
0
};
static
valet_lot_t
globals
=
{
0
};
...
@@ -66,6 +67,7 @@ static valet_lot_t *valet_find_lot(const char *name, switch_bool_t create)
...
@@ -66,6 +67,7 @@ static valet_lot_t *valet_find_lot(const char *name, switch_bool_t create)
lot
=
switch_core_hash_find
(
globals
.
hash
,
name
);
lot
=
switch_core_hash_find
(
globals
.
hash
,
name
);
if
(
!
lot
&&
create
)
{
if
(
!
lot
&&
create
)
{
switch_zmalloc
(
lot
,
sizeof
(
*
lot
));
switch_zmalloc
(
lot
,
sizeof
(
*
lot
));
lot
->
name
=
strdup
(
name
);
switch_mutex_init
(
&
lot
->
mutex
,
SWITCH_MUTEX_NESTED
,
globals
.
pool
);
switch_mutex_init
(
&
lot
->
mutex
,
SWITCH_MUTEX_NESTED
,
globals
.
pool
);
switch_core_hash_init
(
&
lot
->
hash
,
NULL
);
switch_core_hash_init
(
&
lot
->
hash
,
NULL
);
switch_core_hash_insert
(
globals
.
hash
,
name
,
lot
);
switch_core_hash_insert
(
globals
.
hash
,
name
,
lot
);
...
@@ -222,12 +224,16 @@ static int EC = 0;
...
@@ -222,12 +224,16 @@ static int EC = 0;
static
void
valet_send_presence
(
const
char
*
lot_name
,
valet_lot_t
*
lot
,
valet_token_t
*
token
,
switch_bool_t
in
)
static
void
valet_send_presence
(
const
char
*
lot_name
,
valet_lot_t
*
lot
,
valet_token_t
*
token
,
switch_bool_t
in
)
{
{
char
*
domain_name
,
*
dup_domain_name
=
NULL
;
char
*
domain_name
,
*
dup_
lot_name
=
NULL
,
*
dup_
domain_name
=
NULL
;
switch_event_t
*
event
;
switch_event_t
*
event
;
int
count
;
int
count
;
if
((
domain_name
=
strchr
(
lot_name
,
'@'
)))
{
domain_name
++
;
dup_lot_name
=
strdup
(
lot_name
);
lot_name
=
dup_lot_name
;
if
((
domain_name
=
strchr
(
dup_lot_name
,
'@'
)))
{
*
domain_name
++
=
'\0'
;
}
}
if
(
zstr
(
domain_name
))
{
if
(
zstr
(
domain_name
))
{
...
@@ -245,11 +251,8 @@ static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_to
...
@@ -245,11 +251,8 @@ static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_to
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_IN
)
==
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"
,
VALET_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
VALET_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
lot_name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
lot_name
);
if
(
strchr
(
lot_name
,
'@'
))
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
lot_name
,
domain_name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
lot_name
);
}
else
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
lot_name
,
domain_name
);
}
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Active (%d caller%s)"
,
count
,
count
==
1
?
""
:
"s"
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Active (%d caller%s)"
,
count
,
count
==
1
?
""
:
"s"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
"active"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
"active"
);
...
@@ -266,11 +269,8 @@ static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_to
...
@@ -266,11 +269,8 @@ static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_to
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_IN
)
==
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"
,
VALET_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
VALET_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
lot_name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
lot_name
);
if
(
strchr
(
lot_name
,
'@'
))
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
lot_name
,
domain_name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
lot_name
);
}
else
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
lot_name
,
domain_name
);
}
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Empty"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Empty"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
"unknown"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
"unknown"
);
...
@@ -322,6 +322,7 @@ static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_to
...
@@ -322,6 +322,7 @@ static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_to
}
}
switch_safe_free
(
dup_domain_name
);
switch_safe_free
(
dup_domain_name
);
switch_safe_free
(
dup_lot_name
);
}
}
...
@@ -639,11 +640,11 @@ SWITCH_STANDARD_API(valet_info_function)
...
@@ -639,11 +640,11 @@ SWITCH_STANDARD_API(valet_info_function)
static
void
pres_event_handler
(
switch_event_t
*
event
)
static
void
pres_event_handler
(
switch_event_t
*
event
)
{
{
char
*
to
=
switch_event_get_header
(
event
,
"to"
);
char
*
to
=
switch_event_get_header
(
event
,
"to"
);
char
*
dup_to
=
NULL
,
*
lot_name
,
*
d
omain_name
,
*
dup_domain_name
=
NULL
;
char
*
dup_to
=
NULL
,
*
lot_name
,
*
d
up_lot_name
=
NULL
,
*
domain_name
;
valet_lot_t
*
lot
;
valet_lot_t
*
lot
;
int
found
=
0
;
if
(
!
to
||
strncasecmp
(
to
,
"park+"
,
5
))
{
if
(
!
to
||
strncasecmp
(
to
,
"park+"
,
5
)
||
!
strchr
(
to
,
'@'
)
)
{
return
;
return
;
}
}
...
@@ -654,31 +655,21 @@ static void pres_event_handler(switch_event_t *event)
...
@@ -654,31 +655,21 @@ static void pres_event_handler(switch_event_t *event)
lot_name
=
dup_to
+
5
;
lot_name
=
dup_to
+
5
;
if
((
domain_name
=
strchr
(
lot_name
,
'@'
)))
{
if
((
domain_name
=
strchr
(
lot_name
,
'@'
)))
{
domain_name
++
;
*
domain_name
++
=
'\0'
;
}
}
if
(
zstr
(
domain_name
))
{
dup_lot_name
=
switch_mprintf
(
"%q@%q"
,
lot_name
,
domain_name
);
dup_domain_name
=
switch_core_get_variable_dup
(
"domain"
);
domain_name
=
dup_domain_name
;
}
if
(
zstr
(
domain_name
))
{
if
((
lot
=
valet_find_lot
(
lot_name
,
SWITCH_FALSE
))
||
(
dup_lot_name
&&
(
lot
=
valet_find_lot
(
dup_lot_name
,
SWITCH_FALSE
))))
{
domain_name
=
"cluecon.com"
;
}
if
((
lot
=
valet_find_lot
(
lot_name
,
SWITCH_FALSE
)))
{
int
count
=
valet_lot_count
(
lot
);
int
count
=
valet_lot_count
(
lot
);
if
(
count
)
{
if
(
count
)
{
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_IN
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_IN
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_IN
)
==
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"
,
VALET_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
VALET_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
lot_name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
lot_name
);
if
(
strchr
(
lot_name
,
'@'
))
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
lot_name
,
domain_name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
lot_name
);
}
else
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
lot_name
,
domain_name
);
}
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Active (%d caller%s)"
,
count
,
count
==
1
?
""
:
"s"
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Active (%d caller%s)"
,
count
,
count
==
1
?
""
:
"s"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
"active"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
"active"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
...
@@ -690,15 +681,12 @@ static void pres_event_handler(switch_event_t *event)
...
@@ -690,15 +681,12 @@ static void pres_event_handler(switch_event_t *event)
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"call-direction"
,
"inbound"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"call-direction"
,
"inbound"
);
switch_event_fire
(
&
event
);
switch_event_fire
(
&
event
);
}
}
found
++
;
}
}
}
else
{
}
else
{
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_IN
)
==
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"
,
VALET_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
VALET_PROTO
);
if
(
strchr
(
lot_name
,
'@'
))
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
lot_name
,
domain_name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
lot_name
);
}
else
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
lot_name
,
domain_name
);
}
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Empty"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Empty"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
"unknown"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
"unknown"
);
...
@@ -718,32 +706,35 @@ static void pres_event_handler(switch_event_t *event)
...
@@ -718,32 +706,35 @@ static void pres_event_handler(switch_event_t *event)
switch_hash_index_t
*
hi
;
switch_hash_index_t
*
hi
;
const
void
*
var
;
const
void
*
var
;
void
*
val
;
void
*
val
;
const
char
*
nvar
;
switch_mutex_lock
(
globals
.
mutex
);
switch_mutex_lock
(
globals
.
mutex
);
for
(
hi
=
switch_hash_first
(
NULL
,
globals
.
hash
);
hi
;
hi
=
switch_hash_next
(
hi
))
{
for
(
hi
=
switch_hash_first
(
NULL
,
globals
.
hash
);
hi
;
hi
=
switch_hash_next
(
hi
))
{
switch_hash_this
(
hi
,
&
var
,
NULL
,
&
val
);
switch_hash_this
(
hi
,
&
var
,
NULL
,
&
val
);
switch_console_push_match
(
&
matches
,
(
const
char
*
)
var
);
nvar
=
(
const
char
*
)
var
;
if
(
!
strchr
(
nvar
,
'@'
)
||
switch_stristr
(
domain_name
,
nvar
))
{
switch_console_push_match
(
&
matches
,
nvar
);
}
}
}
switch_mutex_unlock
(
globals
.
mutex
);
switch_mutex_unlock
(
globals
.
mutex
);
if
(
matches
)
{
if
(
matches
)
{
valet_token_t
*
token
;
valet_token_t
*
token
;
for
(
m
=
matches
->
head
;
m
;
m
=
m
->
next
)
{
for
(
m
=
matches
->
head
;
!
found
&&
m
;
m
=
m
->
next
)
{
lot
=
valet_find_lot
(
m
->
val
,
SWITCH_FALSE
);
lot
=
valet_find_lot
(
m
->
val
,
SWITCH_FALSE
);
switch_mutex_lock
(
lot
->
mutex
);
switch_mutex_lock
(
lot
->
mutex
);
if
((
token
=
(
valet_token_t
*
)
switch_core_hash_find
(
lot
->
hash
,
lot_name
)))
{
if
((
token
=
(
valet_token_t
*
)
switch_core_hash_find
(
lot
->
hash
,
lot_name
))
&&
!
token
->
timeout
)
{
found
++
;
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_IN
)
==
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"
,
VALET_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
VALET_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
lot_name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
lot_name
);
if
(
strchr
(
lot_name
,
'@'
))
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
lot_name
,
domain_name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
lot_name
);
}
else
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
lot_name
,
domain_name
);
}
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Active"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
token
->
bridged
==
0
?
"Holding"
:
"Active"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"alt_event_type"
,
"dialog"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"alt_event_type"
,
"dialog"
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"event_count"
,
"%d"
,
EC
++
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"event_count"
,
"%d"
,
EC
++
);
...
@@ -758,18 +749,14 @@ static void pres_event_handler(switch_event_t *event)
...
@@ -758,18 +749,14 @@ static void pres_event_handler(switch_event_t *event)
switch_mutex_unlock
(
lot
->
mutex
);
switch_mutex_unlock
(
lot
->
mutex
);
}
}
}
}
}
}
if
(
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_IN
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
!
found
&&
switch_event_create
(
&
event
,
SWITCH_EVENT_PRESENCE_IN
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
VALET_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"proto"
,
VALET_PROTO
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
lot_name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"login"
,
lot_name
);
if
(
strchr
(
lot_name
,
'@'
))
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
lot_name
,
domain_name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
lot_name
);
}
else
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"from"
,
"%s@%s"
,
lot_name
,
domain_name
);
}
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Empty"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"force-status"
,
"Empty"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
"unknown"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"rpid"
,
"unknown"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"event_type"
,
"presence"
);
...
@@ -783,7 +770,7 @@ static void pres_event_handler(switch_event_t *event)
...
@@ -783,7 +770,7 @@ static void pres_event_handler(switch_event_t *event)
}
}
switch_safe_free
(
dup_to
);
switch_safe_free
(
dup_to
);
switch_safe_free
(
dup_
domain
_name
);
switch_safe_free
(
dup_
lot
_name
);
}
}
/* Macro expands to: switch_status_t mod_valet_parking_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */
/* Macro expands to: switch_status_t mod_valet_parking_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论