Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
d544c065
提交
d544c065
authored
12月 26, 2011
作者:
Marc Olivier Chouinard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mod_voicemail_ivr: Fixed issue in settings system. Added initials settings.
上级
f2cba2aa
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
180 行增加
和
115 行删除
+180
-115
voicemail_ivr.conf.xml
conf/autoload_configs/voicemail_ivr.conf.xml
+12
-8
config.c
src/mod/applications/mod_voicemail_ivr/config.c
+46
-30
config.h
src/mod/applications/mod_voicemail_ivr/config.h
+2
-0
menu.c
src/mod/applications/mod_voicemail_ivr/menu.c
+116
-70
utils.c
src/mod/applications/mod_voicemail_ivr/utils.c
+2
-3
utils.h
src/mod/applications/mod_voicemail_ivr/utils.h
+2
-4
没有找到文件。
conf/autoload_configs/voicemail_ivr.conf.xml
浏览文件 @
d544c065
<configuration
name=
"voicemail_ivr.conf"
description=
"Voicemail IVR"
>
<profiles>
<profile
name=
"default"
>
<!-- Not yet implemented - Open for comments
<settings>
<param name="record-format" value="wav"/>
<param name="record-rate" value="8000"/>
<param
name=
"IVR-Maximum-Attempts"
value=
"3"
/>
<param
name=
"IVR-Entry-Timeout"
value=
"3"
/>
<param
name=
"Record-Format"
value=
"wav"
/>
<!--<param name="Record-Sample-Rate" value="8000" />-->
<param
name=
"Record-Silence-Hits"
value=
"4"
/>
<param
name=
"Record-Silence-Threshold"
value=
"200"
/>
<param
name=
"Record-Maximum-Length"
value=
"30"
/>
<param
name=
"Exit-Purge"
value=
"true"
/>
<param
name=
"Password-Mask"
value=
"XXX."
/>
<param
name=
"User-Mask"
value=
"X."
/>
</settings>
-->
<apis>
<api
name=
"auth_login"
value=
"vm_fsdb_auth_login"
/>
<api
name=
"msg_list"
value=
"vm_fsdb_msg_list"
/>
...
...
@@ -64,12 +71,9 @@
</menu>
<menu
name=
"std_navigator"
>
<!-- Not yet implemented - Open for comments
This will inherit the settings from the top profile settings. So if it global, put it inside the profile <settings>
<settings>
<
param name="playback-order" value="newest-first" /
>
<
!--<param name="Nav-Action-On-Delete" value="next_msg" />--
>
</settings>
-->
<phrases>
<phrase
name=
"msg_count"
value=
"message_count@voicemail_ivr"
/>
<phrase
name=
"say_date"
value=
"say_date_event@voicemail_ivr"
/>
...
...
src/mod/applications/mod_voicemail_ivr/config.c
浏览文件 @
d544c065
...
...
@@ -52,12 +52,14 @@ void menu_init(vmivr_profile_t *profile, vmivr_menu_t *menu) {
goto
end
;
}
if
(
profile
->
event_settings
&&
menu
->
event_settings
)
{
if
(
profile
->
event_settings
)
{
/* TODO Replace this with a switch_event_merge_not_set(...) */
switch_event_t
*
menu_default
;
switch_event_create
(
&
menu_default
,
SWITCH_EVENT_REQUEST_PARAMS
);
switch_event_merge
(
menu_default
,
menu
->
event_settings
);
switch_event_destroy
(
&
menu
->
event_settings
);
if
(
menu
->
event_settings
)
{
switch_event_merge
(
menu_default
,
menu
->
event_settings
);
switch_event_destroy
(
&
menu
->
event_settings
);
}
switch_event_create
(
&
menu
->
event_settings
,
SWITCH_EVENT_REQUEST_PARAMS
);
switch_event_merge
(
menu
->
event_settings
,
profile
->
event_settings
);
...
...
@@ -65,6 +67,12 @@ void menu_init(vmivr_profile_t *profile, vmivr_menu_t *menu) {
switch_event_destroy
(
&
menu_default
);
}
{
const
char
*
s_max_attempts
=
switch_event_get_header
(
menu
->
event_settings
,
"IVR-Maximum-Attempts"
);
const
char
*
s_entry_timeout
=
switch_event_get_header
(
menu
->
event_settings
,
"IVR-Entry-Timeout"
);
menu
->
ivr_maximum_attempts
=
atoi
(
s_max_attempts
);
menu
->
ivr_entry_timeout
=
atoi
(
s_entry_timeout
);
}
if
((
x_profile
=
switch_xml_find_child
(
x_profiles
,
"profile"
,
"name"
,
profile
->
name
)))
{
if
((
x_menus
=
switch_xml_child
(
x_profile
,
"menus"
)))
{
...
...
@@ -127,38 +135,36 @@ void menu_free(vmivr_menu_t *menu) {
static
void
append_event_profile
(
vmivr_menu_t
*
menu
)
{
if
(
!
menu
->
phrase_params
)
{
switch_event_create
(
&
menu
->
phrase_params
,
SWITCH_EVENT_REQUEST_PARAMS
);
}
if
(
!
menu
->
phrase_params
)
{
switch_event_create
(
&
menu
->
phrase_params
,
SWITCH_EVENT_REQUEST_PARAMS
);
}
/* Used for some appending function */
if
(
menu
->
profile
&&
menu
->
profile
->
name
&&
menu
->
profile
->
id
&&
menu
->
profile
->
domain
)
{
switch_event_add_header
(
menu
->
phrase_params
,
SWITCH_STACK_BOTTOM
,
"VM-Profile"
,
"%s"
,
menu
->
profile
->
name
);
switch_event_add_header
(
menu
->
phrase_params
,
SWITCH_STACK_BOTTOM
,
"VM-Account-ID"
,
"%s"
,
menu
->
profile
->
id
);
switch_event_add_header
(
menu
->
phrase_params
,
SWITCH_STACK_BOTTOM
,
"VM-Account-Domain"
,
"%s"
,
menu
->
profile
->
domain
);
}
/* Used for some appending function */
if
(
menu
->
profile
&&
menu
->
profile
->
name
&&
menu
->
profile
->
id
&&
menu
->
profile
->
domain
)
{
switch_event_add_header
(
menu
->
phrase_params
,
SWITCH_STACK_BOTTOM
,
"VM-Profile"
,
"%s"
,
menu
->
profile
->
name
);
switch_event_add_header
(
menu
->
phrase_params
,
SWITCH_STACK_BOTTOM
,
"VM-Account-ID"
,
"%s"
,
menu
->
profile
->
id
);
switch_event_add_header
(
menu
->
phrase_params
,
SWITCH_STACK_BOTTOM
,
"VM-Account-Domain"
,
"%s"
,
menu
->
profile
->
domain
);
}
}
static
void
populate_dtmfa_from_event
(
vmivr_menu_t
*
menu
)
{
int
i
=
0
;
if
(
menu
->
event_keys_dtmf
)
{
switch_event_header_t
*
hp
;
for
(
hp
=
menu
->
event_keys_dtmf
->
headers
;
hp
;
hp
=
hp
->
next
)
{
if
(
strlen
(
hp
->
name
)
<
3
&&
hp
->
value
)
{
/* TODO This is a hack to discard default FS Events ! */
const
char
*
varphrasename
=
switch_event_get_header
(
menu
->
event_keys_varname
,
hp
->
value
);
menu
->
dtmfa
[
i
++
]
=
hp
->
name
;
if
(
varphrasename
&&
!
zstr
(
varphrasename
))
{
switch_event_add_header
(
menu
->
phrase_params
,
SWITCH_STACK_BOTTOM
,
varphrasename
,
"%s"
,
hp
->
name
);
}
}
}
}
menu
->
dtmfa
[
i
++
]
=
'\0'
;
int
i
=
0
;
if
(
menu
->
event_keys_dtmf
)
{
switch_event_header_t
*
hp
;
}
for
(
hp
=
menu
->
event_keys_dtmf
->
headers
;
hp
;
hp
=
hp
->
next
)
{
if
(
strlen
(
hp
->
name
)
<
3
&&
hp
->
value
)
{
/* TODO This is a hack to discard default FS Events ! */
const
char
*
varphrasename
=
switch_event_get_header
(
menu
->
event_keys_varname
,
hp
->
value
);
menu
->
dtmfa
[
i
++
]
=
hp
->
name
;
if
(
varphrasename
&&
!
zstr
(
varphrasename
))
{
switch_event_add_header
(
menu
->
phrase_params
,
SWITCH_STACK_BOTTOM
,
varphrasename
,
"%s"
,
hp
->
name
);
}
}
}
}
menu
->
dtmfa
[
i
++
]
=
'\0'
;
}
vmivr_profile_t
*
get_profile
(
switch_core_session_t
*
session
,
const
char
*
profile_name
)
{
...
...
@@ -193,7 +199,17 @@ vmivr_profile_t *get_profile(switch_core_session_t *session, const char *profile
profile
->
menu_check_main
=
"std_main_menu"
;
profile
->
menu_check_terminate
=
"std_purge"
;
/* TODO Create event_settings and add default settings here */
/* Populate default general settings */
switch_event_create
(
&
profile
->
event_settings
,
SWITCH_EVENT_REQUEST_PARAMS
);
switch_event_add_header
(
profile
->
event_settings
,
SWITCH_STACK_BOTTOM
,
"IVR-Maximum-Attempts"
,
"%d"
,
3
);
switch_event_add_header
(
profile
->
event_settings
,
SWITCH_STACK_BOTTOM
,
"IVR-Entry-Timeout"
,
"%d"
,
3000
);
switch_event_add_header
(
profile
->
event_settings
,
SWITCH_STACK_BOTTOM
,
"Exit-Purge"
,
"%s"
,
"true"
);
switch_event_add_header
(
profile
->
event_settings
,
SWITCH_STACK_BOTTOM
,
"Password-Mask"
,
"%s"
,
"XXX."
);
switch_event_add_header
(
profile
->
event_settings
,
SWITCH_STACK_BOTTOM
,
"User-Mask"
,
"%s"
,
"X."
);
switch_event_add_header
(
profile
->
event_settings
,
SWITCH_STACK_BOTTOM
,
"Record-Format"
,
"%s"
,
"wav"
);
switch_event_add_header
(
profile
->
event_settings
,
SWITCH_STACK_BOTTOM
,
"Record-Silence-Hits"
,
"%d"
,
4
);
switch_event_add_header
(
profile
->
event_settings
,
SWITCH_STACK_BOTTOM
,
"Record-Silence-Threshold"
,
"%d"
,
200
);
switch_event_add_header
(
profile
->
event_settings
,
SWITCH_STACK_BOTTOM
,
"Record-Maximum-Length"
,
"%d"
,
30
);
if
((
x_settings
=
switch_xml_child
(
x_profile
,
"settings"
)))
{
switch_event_import_xml
(
switch_xml_child
(
x_settings
,
"param"
),
"name"
,
"value"
,
&
profile
->
event_settings
);
...
...
src/mod/applications/mod_voicemail_ivr/config.h
浏览文件 @
d544c065
...
...
@@ -91,6 +91,8 @@ struct vmivr_menu {
switch_event_t
*
phrase_params
;
ivre_data_t
ivre_d
;
int
ivr_maximum_attempts
;
int
ivr_entry_timeout
;
};
typedef
struct
vmivr_menu
vmivr_menu_t
;
...
...
src/mod/applications/mod_voicemail_ivr/menu.c
浏览文件 @
d544c065
...
...
@@ -51,16 +51,27 @@ vmivr_menu_function_t menu_list[] = {
{
NULL
,
NULL
}
};
#define MAX_ATTEMPT 3
/* TODO Make these fields configurable */
#define DEFAULT_IVR_TIMEOUT 3000
void
vmivr_menu_purge
(
switch_core_session_t
*
session
,
vmivr_profile_t
*
profile
)
{
vmivr_menu_t
menu
=
{
"std_menu_purge"
};
/* Initialize Menu Configs */
menu_init
(
profile
,
&
menu
);
if
(
!
menu
.
event_keys_dtmf
||
!
menu
.
event_phrases
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Missing Menu Phrases or Keys in menu '%s'
\n
"
,
menu
.
name
);
goto
end
;
}
if
(
profile
->
id
&&
profile
->
authorized
)
{
if
(
1
==
1
/* TODO make Purge email on exit optional ??? */
)
{
const
char
*
exit_purge
=
switch_event_get_header
(
menu
.
event_settings
,
"Exit-Purge"
);
if
(
switch_true
(
exit_purge
))
{
const
char
*
cmd
=
switch_core_session_sprintf
(
session
,
"%s %s %s"
,
profile
->
api_profile
,
profile
->
domain
,
profile
->
id
);
vmivr_api_execute
(
session
,
profile
->
api_msg_purge
,
cmd
);
}
}
end:
menu_free
(
&
menu
);
}
void
vmivr_menu_main
(
switch_core_session_t
*
session
,
vmivr_profile_t
*
profile
)
{
...
...
@@ -72,11 +83,11 @@ void vmivr_menu_main(switch_core_session_t *session, vmivr_profile_t *profile) {
menu_init
(
profile
,
&
menu
);
if
(
!
menu
.
event_keys_dtmf
||
!
menu
.
event_phrases
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Missing Menu Phrases
and Keys
\n
"
);
return
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Missing Menu Phrases
or Keys in menu '%s'
\n
"
,
menu
.
name
);
goto
end
;
}
for
(
retry
=
MAX_ATTEMPT
;
switch_channel_ready
(
channel
)
&&
retry
>
0
;
retry
--
)
{
for
(
retry
=
menu
.
ivr_maximum_attempts
;
switch_channel_ready
(
channel
)
&&
retry
>
0
;
retry
--
)
{
char
*
cmd
=
NULL
;
menu_instance_init
(
&
menu
);
...
...
@@ -88,7 +99,7 @@ void vmivr_menu_main(switch_core_session_t *session, vmivr_profile_t *profile) {
//initial_count_played = SWITCH_TRUE;
ivre_playback
(
session
,
&
menu
.
ivre_d
,
switch_event_get_header
(
menu
.
event_phrases
,
"msg_count"
),
NULL
,
menu
.
phrase_params
,
NULL
,
0
);
ivre_playback
(
session
,
&
menu
.
ivre_d
,
switch_event_get_header
(
menu
.
event_phrases
,
"menu_options"
),
NULL
,
menu
.
phrase_params
,
NULL
,
DEFAULT_IVR_TIMEOUT
);
ivre_playback
(
session
,
&
menu
.
ivre_d
,
switch_event_get_header
(
menu
.
event_phrases
,
"menu_options"
),
NULL
,
menu
.
phrase_params
,
NULL
,
menu
.
ivr_entry_timeout
);
if
(
menu
.
ivre_d
.
result
==
RES_TIMEOUT
)
{
/* TODO Ask for the prompt Again IF retry != 0 */
...
...
@@ -98,7 +109,7 @@ void vmivr_menu_main(switch_core_session_t *session, vmivr_profile_t *profile) {
const
char
*
action
=
switch_event_get_header
(
menu
.
event_keys_dtmf
,
menu
.
ivre_d
.
dtmf_stored
);
/* Reset the try count */
retry
=
MAX_ATTEMPT
;
retry
=
menu
.
ivr_maximum_attempts
;
if
(
action
)
{
if
(
!
strncasecmp
(
action
,
"new_msg:"
,
8
))
{
...
...
@@ -129,6 +140,8 @@ void vmivr_menu_main(switch_core_session_t *session, vmivr_profile_t *profile) {
}
end:
menu_free
(
&
menu
);
}
...
...
@@ -157,8 +170,8 @@ void vmivr_menu_navigator(switch_core_session_t *session, vmivr_profile_t *profi
menu_init
(
profile
,
&
menu
);
if
(
!
menu
.
event_keys_dtmf
||
!
menu
.
event_phrases
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Missing Menu Phrases or Keys
\n
"
);
return
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Missing Menu Phrases or Keys
in menu '%s'
\n
"
,
menu
.
name
);
goto
done
;
}
/* Get VoiceMail List And update msg count */
...
...
@@ -177,7 +190,7 @@ void vmivr_menu_navigator(switch_core_session_t *session, vmivr_profile_t *profi
/* TODO Add Detection of new message and notify the user */
for
(
retry
=
MAX_ATTEMPT
;
switch_channel_ready
(
channel
)
&&
retry
>
0
;
retry
--
)
{
for
(
retry
=
menu
.
ivr_maximum_attempts
;
switch_channel_ready
(
channel
)
&&
retry
>
0
;
retry
--
)
{
switch_core_session_message_t
msg
=
{
0
};
char
cid_buf
[
1024
]
=
""
;
...
...
@@ -185,16 +198,6 @@ void vmivr_menu_navigator(switch_core_session_t *session, vmivr_profile_t *profi
previous_msg
=
current_msg
;
/* Simple Protection to not go out of msg list scope */
/* TODO: Add Prompt to notify they reached the begining or the end */
if
(
next_msg
==
0
)
{
next_msg
=
1
;
}
else
if
(
next_msg
>
msg_count
)
{
next_msg
=
msg_count
;
}
current_msg
=
next_msg
;
ivre_init
(
&
menu
.
ivre_d
,
menu
.
dtmfa
);
/* Prompt related to previous Message here */
...
...
@@ -212,6 +215,18 @@ void vmivr_menu_navigator(switch_core_session_t *session, vmivr_profile_t *profi
ivre_playback
(
session
,
&
menu
.
ivre_d
,
switch_event_get_header
(
menu
.
event_phrases
,
"ack"
),
"saved"
,
menu
.
phrase_params
,
NULL
,
0
);
}
switch_event_del_header
(
menu
.
phrase_params
,
"VM-Message-Flags"
);
/* Simple Protection to not go out of msg list scope */
/* TODO: Add Prompt to notify they reached the begining or the end */
if
(
next_msg
==
0
)
{
next_msg
=
1
;
}
else
if
(
next_msg
>
msg_count
)
{
next_msg
=
msg_count
;
/*ivre_playback_dtmf_buffered(session, switch_event_get_header(menu.event_phrases, "no_more_messages"), NULL, NULL, NULL, 0); */
}
current_msg
=
next_msg
;
/* Prompt related the current message */
append_event_message
(
session
,
profile
,
menu
.
phrase_params
,
msg_list_params
,
current_msg
);
...
...
@@ -250,7 +265,7 @@ void vmivr_menu_navigator(switch_core_session_t *session, vmivr_profile_t *profi
skip_header
=
SWITCH_FALSE
;
skip_playback
=
SWITCH_FALSE
;
ivre_playback
(
session
,
&
menu
.
ivre_d
,
switch_event_get_header
(
menu
.
event_phrases
,
"menu_options"
),
NULL
,
menu
.
phrase_params
,
NULL
,
DEFAULT_IVR_TIMEOUT
);
ivre_playback
(
session
,
&
menu
.
ivre_d
,
switch_event_get_header
(
menu
.
event_phrases
,
"menu_options"
),
NULL
,
menu
.
phrase_params
,
NULL
,
menu
.
ivr_entry_timeout
);
if
(
menu
.
ivre_d
.
result
==
RES_TIMEOUT
)
{
/* TODO Ask for the prompt Again IF retry != 0 */
...
...
@@ -260,30 +275,30 @@ void vmivr_menu_navigator(switch_core_session_t *session, vmivr_profile_t *profi
const
char
*
action
=
switch_event_get_header
(
menu
.
event_keys_dtmf
,
menu
.
ivre_d
.
dtmf_stored
);
/* Reset the try count */
retry
=
MAX_ATTEMPT
;
retry
=
menu
.
ivr_maximum_attempts
;
action:
if
(
action
)
{
if
(
!
strcasecmp
(
action
,
"skip_intro"
))
{
/* Skip Header / Play the recording again */
skip_header
=
SWITCH_TRUE
;
}
else
if
(
!
strcasecmp
(
action
,
"next_msg"
))
{
/* Next Message */
next_msg
++
;
if
(
next_msg
>
msg_count
)
{
//ivre_playback_dtmf_buffered(session, switch_event_get_header(menu.event_phrases, "no_more_messages"), NULL, NULL, NULL, 0);
retry
=
-
1
;
}
}
else
if
(
!
strcasecmp
(
action
,
"prev_msg"
))
{
/* Previous Message */
next_msg
--
;
}
else
if
(
!
strcasecmp
(
action
,
"delete_msg"
))
{
/* Delete / Undelete Message */
const
char
*
msg_flags
=
switch_event_get_header
(
menu
.
phrase_params
,
"VM-Message-Flags"
);
if
(
!
msg_flags
||
strncasecmp
(
msg_flags
,
"delete"
,
6
))
{
const
char
*
action_on_delete
=
switch_event_get_header
(
menu
.
event_settings
,
"Nav-Action-On-Delete"
);
cmd
=
switch_core_session_sprintf
(
session
,
"%s %s %s %s"
,
profile
->
api_profile
,
profile
->
domain
,
profile
->
id
,
switch_event_get_header
(
menu
.
phrase_params
,
"VM-Message-UUID"
));
vmivr_api_execute
(
session
,
profile
->
api_msg_delete
,
cmd
);
msg_deleted
=
SWITCH_TRUE
;
/* TODO Option for auto going to next message or just return to the menu (So user used to do 76 to delete and next message wont be confused) */
//next_msg++;
skip_header
=
skip_playback
=
SWITCH_TRUE
;
if
(
action_on_delete
)
{
action
=
action_on_delete
;
goto
action
;
}
else
{
skip_header
=
skip_playback
=
SWITCH_TRUE
;
}
}
else
{
cmd
=
switch_core_session_sprintf
(
session
,
"%s %s %s %s"
,
profile
->
api_profile
,
profile
->
domain
,
profile
->
id
,
switch_event_get_header
(
menu
.
phrase_params
,
"VM-Message-UUID"
));
vmivr_api_execute
(
session
,
profile
->
api_msg_undelete
,
cmd
);
...
...
@@ -343,17 +358,17 @@ void vmivr_menu_forward(switch_core_session_t *session, vmivr_profile_t *profile
menu_init
(
profile
,
&
menu
);
if
(
!
menu
.
event_keys_dtmf
||
!
menu
.
event_phrases
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Missing Menu Phrases
and Keys
\n
"
);
return
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Missing Menu Phrases
or Keys in menu '%s'
\n
"
,
menu
.
name
);
goto
end
;
}
for
(
retry
=
MAX_ATTEMPT
;
switch_channel_ready
(
channel
)
&&
retry
>
0
;
retry
--
)
{
for
(
retry
=
menu
.
ivr_maximum_attempts
;
switch_channel_ready
(
channel
)
&&
retry
>
0
;
retry
--
)
{
menu_instance_init
(
&
menu
);
ivre_init
(
&
menu
.
ivre_d
,
menu
.
dtmfa
);
ivre_playback
(
session
,
&
menu
.
ivre_d
,
switch_event_get_header
(
menu
.
event_phrases
,
"menu_options"
),
NULL
,
menu
.
phrase_params
,
NULL
,
DEFAULT_IVR_TIMEOUT
);
ivre_playback
(
session
,
&
menu
.
ivre_d
,
switch_event_get_header
(
menu
.
event_phrases
,
"menu_options"
),
NULL
,
menu
.
phrase_params
,
NULL
,
menu
.
ivr_entry_timeout
);
if
(
menu
.
ivre_d
.
result
==
RES_TIMEOUT
)
{
/* TODO Ask for the prompt Again IF retry != 0 */
...
...
@@ -363,7 +378,7 @@ void vmivr_menu_forward(switch_core_session_t *session, vmivr_profile_t *profile
const
char
*
action
=
switch_event_get_header
(
menu
.
event_keys_dtmf
,
menu
.
ivre_d
.
dtmf_stored
);
/* Reset the try count */
retry
=
MAX_ATTEMPT
;
retry
=
menu
.
ivr_maximum_attempts
;
if
(
action
)
{
if
(
!
strcasecmp
(
action
,
"return"
))
{
/* Return to the previous menu */
...
...
@@ -371,11 +386,18 @@ void vmivr_menu_forward(switch_core_session_t *session, vmivr_profile_t *profile
forward_msg
=
SWITCH_FALSE
;
}
else
if
(
!
strcasecmp
(
action
,
"prepend"
))
{
/* Prepend record msg */
vmivr_menu_t
sub_menu
=
{
"std_record_message"
};
char
*
tmp_filepath
=
generate_random_file_name
(
session
,
"voicemail_ivr"
,
"wav"
/* TODO make it configurable */
);
const
char
*
tmp_filepath
=
NULL
;
const
char
*
record_format
=
NULL
;
switch_status_t
status
;
/* Initialize Menu Configs */
menu_init
(
profile
,
&
sub_menu
);
record_format
=
switch_event_get_header
(
sub_menu
.
event_settings
,
"Record-Format"
);
tmp_filepath
=
generate_random_file_name
(
session
,
"voicemail_ivr"
,
record_format
);
status
=
vmivr_menu_record
(
session
,
profile
,
sub_menu
,
tmp_filepath
);
...
...
@@ -409,7 +431,7 @@ void vmivr_menu_forward(switch_core_session_t *session, vmivr_profile_t *profile
}
/* Ask Extension to Forward */
if
(
forward_msg
)
{
for
(
retry
=
MAX_ATTEMPT
;
switch_channel_ready
(
channel
)
&&
retry
>
0
;
retry
--
)
{
for
(
retry
=
menu
.
ivr_maximum_attempts
;
switch_channel_ready
(
channel
)
&&
retry
>
0
;
retry
--
)
{
const
char
*
id
=
NULL
;
vmivr_menu_t
sub_menu
=
{
"std_forward_ask_extension"
};
...
...
@@ -435,6 +457,7 @@ void vmivr_menu_forward(switch_core_session_t *session, vmivr_profile_t *profile
}
end:
menu_free
(
&
menu
);
}
...
...
@@ -443,11 +466,16 @@ void vmivr_menu_record_name(switch_core_session_t *session, vmivr_profile_t *pro
switch_status_t
status
;
vmivr_menu_t
menu
=
{
"std_record_name"
};
char
*
tmp_filepath
=
generate_random_file_name
(
session
,
"voicemail_ivr"
,
"wav"
/* TODO make it configurable */
);
const
char
*
tmp_filepath
=
NULL
;
const
char
*
record_format
=
NULL
;
/* Initialize Menu Configs */
menu_init
(
profile
,
&
menu
);
record_format
=
switch_event_get_header
(
menu
.
event_settings
,
"Record-Format"
);
tmp_filepath
=
generate_random_file_name
(
session
,
"voicemail_ivr"
,
record_format
);
status
=
vmivr_menu_record
(
session
,
profile
,
menu
,
tmp_filepath
);
if
(
status
==
SWITCH_STATUS_SUCCESS
)
{
...
...
@@ -459,11 +487,14 @@ void vmivr_menu_record_name(switch_core_session_t *session, vmivr_profile_t *pro
void
vmivr_menu_set_password
(
switch_core_session_t
*
session
,
vmivr_profile_t
*
profile
)
{
char
*
password
;
vmivr_menu_t
menu
=
{
"std_set_password"
};
const
char
*
password_mask
=
NULL
;
/* Initialize Menu Configs */
menu_init
(
profile
,
&
menu
);
password
=
vmivr_menu_get_input_set
(
session
,
profile
,
menu
,
"XXX."
/* TODO Conf Min 3 Digit */
);
password_mask
=
switch_event_get_header
(
menu
.
event_settings
,
"Password-Mask"
);
password
=
vmivr_menu_get_input_set
(
session
,
profile
,
menu
,
password_mask
);
/* TODO Add Prompts to tell if password was set and if it was not */
if
(
password
)
{
...
...
@@ -487,16 +518,17 @@ void vmivr_menu_authenticate(switch_core_session_t *session, vmivr_profile_t *pr
profile
->
authorized
=
SWITCH_TRUE
;
}
for
(
retry
=
MAX_ATTEMPT
;
switch_channel_ready
(
channel
)
&&
retry
>
0
&&
profile
->
authorized
==
SWITCH_FALSE
;
retry
--
)
{
for
(
retry
=
menu
.
ivr_maximum_attempts
;
switch_channel_ready
(
channel
)
&&
retry
>
0
&&
profile
->
authorized
==
SWITCH_FALSE
;
retry
--
)
{
const
char
*
id
=
profile
->
id
,
*
password
=
NULL
;
char
*
cmd
=
NULL
;
const
char
*
password_mask
=
switch_event_get_header
(
menu
.
event_settings
,
"Password-Mask"
);
const
char
*
user_mask
=
switch_event_get_header
(
menu
.
event_settings
,
"User-Mask"
);
if
(
!
id
)
{
vmivr_menu_t
sub_menu
=
{
"std_authenticate_ask_user"
};
/* Initialize Menu Configs */
menu_init
(
profile
,
&
sub_menu
);
id
=
vmivr_menu_get_input_set
(
session
,
profile
,
sub_menu
,
"X."
/* TODO Conf Min 3 Digit */
);
id
=
vmivr_menu_get_input_set
(
session
,
profile
,
sub_menu
,
user_mask
);
menu_free
(
&
sub_menu
);
}
if
(
!
password
)
{
...
...
@@ -504,7 +536,7 @@ void vmivr_menu_authenticate(switch_core_session_t *session, vmivr_profile_t *pr
/* Initialize Menu Configs */
menu_init
(
profile
,
&
sub_menu
);
password
=
vmivr_menu_get_input_set
(
session
,
profile
,
sub_menu
,
"X."
/* TODO Conf Min 3 Digit */
);
password
=
vmivr_menu_get_input_set
(
session
,
profile
,
sub_menu
,
password_mask
);
menu_free
(
&
sub_menu
);
}
cmd
=
switch_core_session_sprintf
(
session
,
"%s %s %s %s"
,
profile
->
api_profile
,
profile
->
domain
,
id
,
password
);
...
...
@@ -562,12 +594,18 @@ void vmivr_menu_record_greeting_with_slot(switch_core_session_t *session, vmivr_
/* If user entered 0, we don't accept it */
if
(
gnum
>
0
)
{
vmivr_menu_t
sub_menu
=
{
"std_record_greeting"
};
char
*
tmp_filepath
=
generate_random_file_name
(
session
,
"voicemail_ivr"
,
"wav"
/* TODO make it configurable */
);
char
*
tmp_filepath
=
NULL
;
const
char
*
record_format
=
NULL
;
switch_status_t
status
;
/* Initialize Menu Configs */
menu_init
(
profile
,
&
sub_menu
);
record_format
=
switch_event_get_header
(
menu
.
event_settings
,
"Record-Format"
);
tmp_filepath
=
generate_random_file_name
(
session
,
"voicemail_ivr"
,
record_format
);
status
=
vmivr_menu_record
(
session
,
profile
,
sub_menu
,
tmp_filepath
);
if
(
status
==
SWITCH_STATUS_SUCCESS
)
{
...
...
@@ -595,17 +633,17 @@ void vmivr_menu_preference(switch_core_session_t *session, vmivr_profile_t *prof
menu_init
(
profile
,
&
menu
);
if
(
!
menu
.
event_keys_dtmf
||
!
menu
.
event_phrases
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Missing Menu Phrases
and Keys
\n
"
);
return
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Missing Menu Phrases
or Keys in menu '%s'
\n
"
,
menu
.
name
);
goto
end
;
}
for
(
retry
=
MAX_ATTEMPT
;
switch_channel_ready
(
channel
)
&&
retry
>
0
;
retry
--
)
{
for
(
retry
=
menu
.
ivr_maximum_attempts
;
switch_channel_ready
(
channel
)
&&
retry
>
0
;
retry
--
)
{
menu_instance_init
(
&
menu
);
ivre_init
(
&
menu
.
ivre_d
,
menu
.
dtmfa
);
ivre_playback
(
session
,
&
menu
.
ivre_d
,
switch_event_get_header
(
menu
.
event_phrases
,
"menu_options"
),
NULL
,
menu
.
phrase_params
,
NULL
,
DEFAULT_IVR_TIMEOUT
);
ivre_playback
(
session
,
&
menu
.
ivre_d
,
switch_event_get_header
(
menu
.
event_phrases
,
"menu_options"
),
NULL
,
menu
.
phrase_params
,
NULL
,
menu
.
ivr_entry_timeout
);
if
(
menu
.
ivre_d
.
result
==
RES_TIMEOUT
)
{
/* TODO Ask for the prompt Again IF retry != 0 */
...
...
@@ -615,7 +653,7 @@ void vmivr_menu_preference(switch_core_session_t *session, vmivr_profile_t *prof
const
char
*
action
=
switch_event_get_header
(
menu
.
event_keys_dtmf
,
menu
.
ivre_d
.
dtmf_stored
);
/* Reset the try count */
retry
=
MAX_ATTEMPT
;
retry
=
menu
.
ivr_maximum_attempts
;
if
(
action
)
{
if
(
!
strcasecmp
(
action
,
"return"
))
{
/* Return to the previous menu */
...
...
@@ -631,6 +669,7 @@ void vmivr_menu_preference(switch_core_session_t *session, vmivr_profile_t *prof
menu_instance_free
(
&
menu
);
}
end:
menu_free
(
&
menu
);
}
...
...
@@ -641,13 +680,13 @@ char *vmivr_menu_get_input_set(switch_core_session_t *session, vmivr_profile_t *
switch_channel_t
*
channel
=
switch_core_session_get_channel
(
session
);
if
(
!
menu
.
event_keys_dtmf
||
!
menu
.
event_phrases
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Missing Menu Phrases
and Keys : %s
\n
"
,
menu
.
name
);
return
result
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Missing Menu Phrases
or Keys in menu '%s'
\n
"
,
menu
.
name
);
goto
end
;
}
terminate_key
=
switch_event_get_header
(
menu
.
event_keys_action
,
"ivrengine:terminate_entry"
);
for
(
retry
=
MAX_ATTEMPT
;
switch_channel_ready
(
channel
)
&&
retry
>
0
;
retry
--
)
{
for
(
retry
=
menu
.
ivr_maximum_attempts
;
switch_channel_ready
(
channel
)
&&
retry
>
0
;
retry
--
)
{
int
i
;
menu_instance_init
(
&
menu
);
...
...
@@ -661,7 +700,7 @@ char *vmivr_menu_get_input_set(switch_core_session_t *session, vmivr_profile_t *
if
(
terminate_key
)
{
menu
.
ivre_d
.
terminate_key
=
terminate_key
[
0
];
}
ivre_playback
(
session
,
&
menu
.
ivre_d
,
switch_event_get_header
(
menu
.
event_phrases
,
"instructions"
),
NULL
,
menu
.
phrase_params
,
NULL
,
DEFAULT_IVR_TIMEOUT
);
ivre_playback
(
session
,
&
menu
.
ivre_d
,
switch_event_get_header
(
menu
.
event_phrases
,
"instructions"
),
NULL
,
menu
.
phrase_params
,
NULL
,
menu
.
ivr_entry_timeout
);
if
(
menu
.
ivre_d
.
result
==
RES_TIMEOUT
)
{
/* TODO Ask for the prompt Again IF retry != 0 */
...
...
@@ -670,7 +709,7 @@ char *vmivr_menu_get_input_set(switch_core_session_t *session, vmivr_profile_t *
}
else
if
(
menu
.
ivre_d
.
result
==
RES_FOUND
)
{
/* Matching DTMF Key Pressed */
/* Reset the try count */
retry
=
MAX_ATTEMPT
;
retry
=
menu
.
ivr_maximum_attempts
;
if
(
!
strncasecmp
(
menu
.
ivre_d
.
completeMatch
,
input_mask
,
1
))
{
result
=
switch_core_session_strdup
(
session
,
menu
.
ivre_d
.
dtmf_stored
);
...
...
@@ -680,7 +719,7 @@ char *vmivr_menu_get_input_set(switch_core_session_t *session, vmivr_profile_t *
}
menu_instance_free
(
&
menu
);
}
end:
return
result
;
}
...
...
@@ -694,17 +733,22 @@ switch_status_t vmivr_menu_record(switch_core_session_t *session, vmivr_profile_
switch_bool_t
play_instruction
=
SWITCH_TRUE
;
if
(
!
menu
.
event_keys_dtmf
||
!
menu
.
event_phrases
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Missing Menu Phrases
and Keys
\n
"
);
return
status
;
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Missing Menu Phrases
or Keys in menu '%s'
\n
"
,
menu
.
name
);
goto
end
;
}
for
(
retry
=
MAX_ATTEMPT
;
switch_channel_ready
(
channel
)
&&
retry
>
0
;
retry
--
)
{
for
(
retry
=
menu
.
ivr_maximum_attempts
;
switch_channel_ready
(
channel
)
&&
retry
>
0
;
retry
--
)
{
switch_file_handle_t
fh
=
{
0
};
/* TODO Make the following configurable */
fh
.
thresh
=
200
;
fh
.
silence_hits
=
4
;
//fh.samplerate = 8000;
const
char
*
rec_silence_hits
=
switch_event_get_header
(
menu
.
event_settings
,
"Record-Silence-Hits"
);
const
char
*
rec_silence_threshold
=
switch_event_get_header
(
menu
.
event_settings
,
"Record-Silence-Threshold"
);
const
char
*
rec_silence_samplerate
=
switch_event_get_header
(
menu
.
event_settings
,
"Record-Sample-Rate"
);
const
char
*
rec_maximum_length
=
switch_event_get_header
(
menu
.
event_settings
,
"Record-Maximum-Length"
);
fh
.
thresh
=
atoi
(
rec_silence_threshold
);
fh
.
silence_hits
=
atoi
(
rec_silence_hits
);
if
(
rec_silence_samplerate
)
{
fh
.
samplerate
=
atoi
(
rec_silence_samplerate
);
}
menu_instance_init
(
&
menu
);
...
...
@@ -715,7 +759,7 @@ switch_status_t vmivr_menu_record(switch_core_session_t *session, vmivr_profile_
}
play_instruction
=
SWITCH_TRUE
;
ivre_record
(
session
,
&
menu
.
ivre_d
,
menu
.
phrase_params
,
file_name
,
&
fh
,
30
/* TODO Make max recording configurable */
);
ivre_record
(
session
,
&
menu
.
ivre_d
,
menu
.
phrase_params
,
file_name
,
&
fh
,
atoi
(
rec_maximum_length
)
);
}
else
{
if
(
listen_recording
)
{
switch_event_add_header
(
menu
.
phrase_params
,
SWITCH_STACK_BOTTOM
,
"VM-Record-File-Path"
,
"%s"
,
file_name
);
...
...
@@ -723,12 +767,12 @@ switch_status_t vmivr_menu_record(switch_core_session_t *session, vmivr_profile_
listen_recording
=
SWITCH_FALSE
;
}
ivre_playback
(
session
,
&
menu
.
ivre_d
,
switch_event_get_header
(
menu
.
event_phrases
,
"menu_options"
),
NULL
,
menu
.
phrase_params
,
NULL
,
DEFAULT_IVR_TIMEOUT
);
ivre_playback
(
session
,
&
menu
.
ivre_d
,
switch_event_get_header
(
menu
.
event_phrases
,
"menu_options"
),
NULL
,
menu
.
phrase_params
,
NULL
,
menu
.
ivr_entry_timeout
);
}
if
(
menu
.
ivre_d
.
recorded_audio
)
{
/* Reset the try count */
retry
=
MAX_ATTEMPT
;
retry
=
menu
.
ivr_maximum_attempts
;
/* TODO Check if message is too short */
...
...
@@ -742,7 +786,7 @@ switch_status_t vmivr_menu_record(switch_core_session_t *session, vmivr_profile_
const
char
*
action
=
switch_event_get_header
(
menu
.
event_keys_dtmf
,
menu
.
ivre_d
.
dtmf_stored
);
/* Reset the try count */
retry
=
MAX_ATTEMPT
;
retry
=
menu
.
ivr_maximum_attempts
;
if
(
action
)
{
if
(
!
strcasecmp
(
action
,
"listen"
))
{
/* Listen */
...
...
@@ -771,6 +815,8 @@ switch_status_t vmivr_menu_record(switch_core_session_t *session, vmivr_profile_
}
menu_instance_free
(
&
menu
);
}
end:
return
status
;
}
...
...
src/mod/applications/mod_voicemail_ivr/utils.c
浏览文件 @
d544c065
...
...
@@ -33,11 +33,10 @@
#include "utils.h"
switch_status_t
vmivr_merge_media_files
(
const
char
**
inputs
,
const
char
*
output
)
{
switch_status_t
vmivr_merge_media_files
(
const
char
**
inputs
,
const
char
*
output
,
int
rate
)
{
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
switch_file_handle_t
fh_output
=
{
0
};
int
channels
=
1
;
int
rate
=
8000
;
/* TODO Make this configurable */
int
j
=
0
;
if
(
switch_core_file_open
(
&
fh_output
,
output
,
channels
,
rate
,
SWITCH_FILE_FLAG_WRITE
|
SWITCH_FILE_DATA_SHORT
,
NULL
)
!=
SWITCH_STATUS_SUCCESS
)
{
...
...
@@ -99,7 +98,7 @@ switch_event_t *jsonapi2event(switch_core_session_t *session, switch_event_t *ap
return
phrases_event
;
}
char
*
generate_random_file_name
(
switch_core_session_t
*
session
,
const
char
*
mod_name
,
char
*
file_extension
)
{
char
*
generate_random_file_name
(
switch_core_session_t
*
session
,
const
char
*
mod_name
,
c
onst
c
har
*
file_extension
)
{
char
rand_uuid
[
SWITCH_UUID_FORMATTED_LENGTH
+
1
]
=
""
;
switch_uuid_t
srand_uuid
;
...
...
src/mod/applications/mod_voicemail_ivr/utils.h
浏览文件 @
d544c065
...
...
@@ -34,12 +34,10 @@
#include "config.h"
switch_status_t
vmivr_merge_files
(
const
char
**
inputs
,
const
char
*
output
);
void
append_event_message
(
switch_core_session_t
*
session
,
vmivr_profile_t
*
profile
,
switch_event_t
*
phrase_params
,
switch_event_t
*
msg_list_event
,
size_t
current_msg
);
char
*
generate_random_file_name
(
switch_core_session_t
*
session
,
const
char
*
mod_name
,
char
*
file_extension
);
char
*
generate_random_file_name
(
switch_core_session_t
*
session
,
const
char
*
mod_name
,
c
onst
c
har
*
file_extension
);
switch_event_t
*
jsonapi2event
(
switch_core_session_t
*
session
,
switch_event_t
*
apply_event
,
const
char
*
api
,
const
char
*
data
);
switch_status_t
vmivr_merge_media_files
(
const
char
**
inputs
,
const
char
*
output
);
switch_status_t
vmivr_merge_media_files
(
const
char
**
inputs
,
const
char
*
output
,
int
rate
);
switch_status_t
vmivr_api_execute
(
switch_core_session_t
*
session
,
const
char
*
apiname
,
const
char
*
arguments
);
#endif
/* _UTIL_H_ */
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论