Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
0a980a4f
提交
0a980a4f
authored
10月 12, 2007
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
minor adj
git-svn-id:
http://svn.freeswitch.org/svn/freeswitch/trunk@5851
d0543943-73ff-0310-b7d9-9358b9ac24b2
上级
96628675
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
143 行增加
和
135 行删除
+143
-135
default_context.xml
conf/default_context.xml
+2
-2
switch_utils.h
src/include/switch_utils.h
+1
-0
mod_voicemail.c
src/mod/applications/mod_voicemail/mod_voicemail.c
+2
-132
sofia.c
src/mod/endpoints/mod_sofia/sofia.c
+2
-0
sofia_reg.c
src/mod/endpoints/mod_sofia/sofia_reg.c
+7
-1
switch_utils.c
src/switch_utils.c
+129
-0
没有找到文件。
conf/default_context.xml
浏览文件 @
0a980a4f
...
...
@@ -23,14 +23,14 @@
<condition
field=
"destination_number"
expression=
"^7771$"
>
<action
application=
"answer"
/>
<action
application=
"set"
data=
"voicemail_authorized=${sip_authorized}"
/>
<action
application=
"voicemail"
data=
"check demo $${domain} ${sip_
from_user
}"
/>
<action
application=
"voicemail"
data=
"check demo $${domain} ${sip_
mailbox
}"
/>
</condition>
</extension>
<extension
name=
"7772"
>
<condition
field=
"destination_number"
expression=
"^7772$"
>
<action
application=
"answer"
/>
<action
application=
"voicemail"
data=
"demo $${domain} ${sip_
from_user
}"
/>
<action
application=
"voicemail"
data=
"demo $${domain} ${sip_
mailbox
}"
/>
</condition>
</extension>
...
...
src/include/switch_utils.h
浏览文件 @
0a980a4f
...
...
@@ -328,6 +328,7 @@ SWITCH_DECLARE(switch_status_t) switch_string_match(const char *string, size_t s
#define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK)
SWITCH_DECLARE
(
size_t
)
switch_url_encode
(
char
*
url
,
char
*
buf
,
size_t
len
);
SWITCH_DECLARE
(
char
*
)
switch_url_decode
(
char
*
s
);
SWITCH_DECLARE
(
switch_bool_t
)
switch_simple_email
(
char
*
to
,
char
*
from
,
char
*
headers
,
char
*
body
,
char
*
file
);
/* malloc or DIE macros */
#ifdef NDEBUG
...
...
src/mod/applications/mod_voicemail/mod_voicemail.c
浏览文件 @
0a980a4f
...
...
@@ -83,136 +83,6 @@ struct vm_profile {
};
typedef
struct
vm_profile
vm_profile_t
;
#define B64BUFFLEN 1024
static
const
char
c64
[
65
]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
static
int
write_buf
(
int
fd
,
char
*
buf
)
{
int
len
=
(
int
)
strlen
(
buf
);
if
(
fd
&&
write
(
fd
,
buf
,
len
)
!=
len
)
{
close
(
fd
);
return
0
;
}
return
1
;
}
static
switch_bool_t
vm_email
(
char
*
to
,
char
*
from
,
char
*
headers
,
char
*
body
,
char
*
file
)
{
char
*
bound
=
"XXXX_boundary_XXXX"
;
char
filename
[
80
],
buf
[
B64BUFFLEN
];
int
fd
=
0
,
ifd
=
0
;
int
x
=
0
,
y
=
0
,
bytes
=
0
,
ilen
=
0
;
unsigned
int
b
=
0
,
l
=
0
;
unsigned
char
in
[
B64BUFFLEN
];
unsigned
char
out
[
B64BUFFLEN
+
512
];
char
*
path
=
NULL
;
snprintf
(
filename
,
80
,
"%smail.%ld%04x"
,
SWITCH_GLOBAL_dirs
.
temp_dir
,
time
(
NULL
),
rand
()
&
0xffff
);
if
((
fd
=
open
(
filename
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
0644
)))
{
if
(
file
)
{
path
=
file
;
if
((
ifd
=
open
(
path
,
O_RDONLY
))
<
1
)
{
return
SWITCH_FALSE
;
}
snprintf
(
buf
,
B64BUFFLEN
,
"MIME-Version: 1.0
\n
Content-Type: multipart/mixed; boundary=
\"
%s
\"\n
"
,
bound
);
if
(
!
write_buf
(
fd
,
buf
))
{
return
SWITCH_FALSE
;
}
}
if
(
headers
&&
!
write_buf
(
fd
,
headers
))
return
SWITCH_FALSE
;
if
(
!
write_buf
(
fd
,
"
\n\n
"
))
return
SWITCH_FALSE
;
if
(
file
)
{
snprintf
(
buf
,
B64BUFFLEN
,
"--%s
\n
Content-Type: text/plain
\n\n
"
,
bound
);
if
(
!
write_buf
(
fd
,
buf
))
return
SWITCH_FALSE
;
}
if
(
body
)
{
if
(
!
write_buf
(
fd
,
body
))
{
return
SWITCH_FALSE
;
}
}
if
(
file
)
{
snprintf
(
buf
,
B64BUFFLEN
,
"
\n\n
--%s
\n
Content-Type: application/octet-stream
\n
"
"Content-Transfer-Encoding: base64
\n
"
"Content-Description: Sound attachment.
\n
"
"Content-Disposition: attachment; filename=
\"
%s
\"\n\n
"
,
bound
,
switch_cut_path
(
file
));
if
(
!
write_buf
(
fd
,
buf
))
return
SWITCH_FALSE
;
while
((
ilen
=
read
(
ifd
,
in
,
B64BUFFLEN
)))
{
for
(
x
=
0
;
x
<
ilen
;
x
++
)
{
b
=
(
b
<<
8
)
+
in
[
x
];
l
+=
8
;
while
(
l
>=
6
)
{
out
[
bytes
++
]
=
c64
[(
b
>>
(
l
-=
6
))
%
64
];
if
(
++
y
!=
72
)
continue
;
out
[
bytes
++
]
=
'\n'
;
y
=
0
;
}
}
if
(
write
(
fd
,
&
out
,
bytes
)
!=
bytes
)
{
return
-
1
;
}
else
bytes
=
0
;
}
if
(
l
>
0
)
{
out
[
bytes
++
]
=
c64
[((
b
%
16
)
<<
(
6
-
l
))
%
64
];
}
if
(
l
!=
0
)
while
(
l
<
6
)
{
out
[
bytes
++
]
=
'='
,
l
+=
2
;
}
if
(
write
(
fd
,
&
out
,
bytes
)
!=
bytes
)
{
return
-
1
;
}
}
if
(
file
)
{
snprintf
(
buf
,
B64BUFFLEN
,
"
\n\n
--%s--
\n
.
\n
"
,
bound
);
if
(
!
write_buf
(
fd
,
buf
))
return
SWITCH_FALSE
;
}
}
if
(
fd
)
{
close
(
fd
);
}
if
(
ifd
)
{
close
(
ifd
);
}
snprintf
(
buf
,
B64BUFFLEN
,
"/bin/cat %s | /usr/sbin/sendmail -tf
\"
%s
\"
%s"
,
filename
,
from
,
to
);
if
(
system
(
buf
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Unable to execute command: %s
\n
"
,
buf
);
}
unlink
(
filename
);
if
(
file
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Emailed file [%s] to [%s]
\n
"
,
filename
,
to
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Emailed data to [%s]
\n
"
,
to
);
}
return
SWITCH_TRUE
;
}
static
switch_status_t
vm_execute_sql
(
vm_profile_t
*
profile
,
char
*
sql
,
switch_mutex_t
*
mutex
)
{
switch_core_db_t
*
db
;
...
...
@@ -953,7 +823,7 @@ static switch_status_t listen_file(switch_core_session_t *session, vm_profile_t
}
//TBD add better formatting to the body
vm
_email
(
cbt
->
email
,
from
,
headers
,
body
,
cbt
->
file_path
);
switch_simple
_email
(
cbt
->
email
,
from
,
headers
,
body
,
cbt
->
file_path
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Sending message to %s
\n
"
,
cbt
->
email
);
switch_safe_free
(
body
);
TRY_CODE
(
switch_ivr_phrase_macro
(
session
,
VM_ACK_MACRO
,
"emailed"
,
NULL
,
NULL
));
...
...
@@ -1532,7 +1402,7 @@ static switch_status_t voicemail_leave_main(switch_core_session_t *session, char
}
//TBD add better formatting to the body
vm
_email
(
email_vm
,
from
,
headers
,
body
,
file_path
);
switch_simple
_email
(
email_vm
,
from
,
headers
,
body
,
file_path
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Sending message to %s
\n
"
,
email_vm
);
switch_safe_free
(
body
);
unlink
(
file_path
);
...
...
src/mod/endpoints/mod_sofia/sofia.c
浏览文件 @
0a980a4f
...
...
@@ -1924,6 +1924,8 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
from_host
=
sip
->
sip_from
->
a_url
->
url_host
;
channel_name
=
url_set_chanvars
(
session
,
sip
->
sip_from
->
a_url
,
sip_from
);
switch_channel_set_variable
(
channel
,
"sip_mailbox"
,
from_user
);
if
(
!
switch_strlen_zero
(
from_user
))
{
if
(
*
from_user
==
'+'
)
{
switch_channel_set_variable
(
channel
,
"sip_from_user_stripped"
,
(
const
char
*
)
(
from_user
+
1
));
...
...
src/mod/endpoints/mod_sofia/sofia_reg.c
浏览文件 @
0a980a4f
...
...
@@ -747,6 +747,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
const
char
*
passwd
=
NULL
;
const
char
*
a1_hash
=
NULL
;
char
*
sql
;
char
*
mailbox
=
NULL
;
switch_xml_t
domain
,
xml
=
NULL
,
user
,
param
,
xparams
;
char
hexdigest
[
2
*
SU_MD5_DIGEST_SIZE
+
1
]
=
""
;
char
*
pbuf
=
NULL
;
...
...
@@ -829,7 +830,11 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
ret
=
AUTH_FORBIDDEN
;
goto
end
;
}
if
(
!
(
mailbox
=
(
char
*
)
switch_xml_attr
(
user
,
"mailbox"
)))
{
mailbox
=
username
;
}
for
(
param
=
switch_xml_child
(
xparams
,
"param"
);
param
;
param
=
param
->
next
)
{
const
char
*
var
=
switch_xml_attr_soft
(
param
,
"name"
);
const
char
*
val
=
switch_xml_attr_soft
(
param
,
"value"
);
...
...
@@ -899,6 +904,7 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t co
if
(
first
&&
ret
==
AUTH_OK
)
{
if
(
v_event
&&
(
xparams
=
switch_xml_child
(
user
,
"variables"
)))
{
if
(
switch_event_create
(
v_event
,
SWITCH_EVENT_MESSAGE
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header
(
*
v_event
,
SWITCH_STACK_BOTTOM
,
"sip_mailbox"
,
"%s"
,
mailbox
);
for
(
param
=
switch_xml_child
(
xparams
,
"variable"
);
param
;
param
=
param
->
next
)
{
const
char
*
var
=
switch_xml_attr_soft
(
param
,
"name"
);
const
char
*
val
=
switch_xml_attr_soft
(
param
,
"value"
);
...
...
src/switch_utils.c
浏览文件 @
0a980a4f
...
...
@@ -68,6 +68,135 @@ SWITCH_DECLARE(switch_status_t) switch_b64_encode(unsigned char *in, switch_size
}
static
int
write_buf
(
int
fd
,
char
*
buf
)
{
int
len
=
(
int
)
strlen
(
buf
);
if
(
fd
&&
write
(
fd
,
buf
,
len
)
!=
len
)
{
close
(
fd
);
return
0
;
}
return
1
;
}
SWITCH_DECLARE
(
switch_bool_t
)
switch_simple_email
(
char
*
to
,
char
*
from
,
char
*
headers
,
char
*
body
,
char
*
file
)
{
char
*
bound
=
"XXXX_boundary_XXXX"
;
char
filename
[
80
],
buf
[
B64BUFFLEN
];
int
fd
=
0
,
ifd
=
0
;
int
x
=
0
,
y
=
0
,
bytes
=
0
,
ilen
=
0
;
unsigned
int
b
=
0
,
l
=
0
;
unsigned
char
in
[
B64BUFFLEN
];
unsigned
char
out
[
B64BUFFLEN
+
512
];
char
*
path
=
NULL
;
snprintf
(
filename
,
80
,
"%smail.%ld%04x"
,
SWITCH_GLOBAL_dirs
.
temp_dir
,
time
(
NULL
),
rand
()
&
0xffff
);
if
((
fd
=
open
(
filename
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
0644
)))
{
if
(
file
)
{
path
=
file
;
if
((
ifd
=
open
(
path
,
O_RDONLY
))
<
1
)
{
return
SWITCH_FALSE
;
}
snprintf
(
buf
,
B64BUFFLEN
,
"MIME-Version: 1.0
\n
Content-Type: multipart/mixed; boundary=
\"
%s
\"\n
"
,
bound
);
if
(
!
write_buf
(
fd
,
buf
))
{
return
SWITCH_FALSE
;
}
}
if
(
headers
&&
!
write_buf
(
fd
,
headers
))
return
SWITCH_FALSE
;
if
(
!
write_buf
(
fd
,
"
\n\n
"
))
return
SWITCH_FALSE
;
if
(
file
)
{
snprintf
(
buf
,
B64BUFFLEN
,
"--%s
\n
Content-Type: text/plain
\n\n
"
,
bound
);
if
(
!
write_buf
(
fd
,
buf
))
return
SWITCH_FALSE
;
}
if
(
body
)
{
if
(
!
write_buf
(
fd
,
body
))
{
return
SWITCH_FALSE
;
}
}
if
(
file
)
{
snprintf
(
buf
,
B64BUFFLEN
,
"
\n\n
--%s
\n
Content-Type: application/octet-stream
\n
"
"Content-Transfer-Encoding: base64
\n
"
"Content-Description: Sound attachment.
\n
"
"Content-Disposition: attachment; filename=
\"
%s
\"\n\n
"
,
bound
,
switch_cut_path
(
file
));
if
(
!
write_buf
(
fd
,
buf
))
return
SWITCH_FALSE
;
while
((
ilen
=
read
(
ifd
,
in
,
B64BUFFLEN
)))
{
for
(
x
=
0
;
x
<
ilen
;
x
++
)
{
b
=
(
b
<<
8
)
+
in
[
x
];
l
+=
8
;
while
(
l
>=
6
)
{
out
[
bytes
++
]
=
switch_b64_table
[(
b
>>
(
l
-=
6
))
%
64
];
if
(
++
y
!=
72
)
continue
;
out
[
bytes
++
]
=
'\n'
;
y
=
0
;
}
}
if
(
write
(
fd
,
&
out
,
bytes
)
!=
bytes
)
{
return
-
1
;
}
else
bytes
=
0
;
}
if
(
l
>
0
)
{
out
[
bytes
++
]
=
switch_b64_table
[((
b
%
16
)
<<
(
6
-
l
))
%
64
];
}
if
(
l
!=
0
)
while
(
l
<
6
)
{
out
[
bytes
++
]
=
'='
,
l
+=
2
;
}
if
(
write
(
fd
,
&
out
,
bytes
)
!=
bytes
)
{
return
-
1
;
}
}
if
(
file
)
{
snprintf
(
buf
,
B64BUFFLEN
,
"
\n\n
--%s--
\n
.
\n
"
,
bound
);
if
(
!
write_buf
(
fd
,
buf
))
return
SWITCH_FALSE
;
}
}
if
(
fd
)
{
close
(
fd
);
}
if
(
ifd
)
{
close
(
ifd
);
}
snprintf
(
buf
,
B64BUFFLEN
,
"/bin/cat %s | /usr/sbin/sendmail -tf
\"
%s
\"
%s"
,
filename
,
from
,
to
);
if
(
system
(
buf
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Unable to execute command: %s
\n
"
,
buf
);
}
unlink
(
filename
);
if
(
file
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Emailed file [%s] to [%s]
\n
"
,
filename
,
to
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Emailed data to [%s]
\n
"
,
to
);
}
return
SWITCH_TRUE
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_find_local_ip
(
char
*
buf
,
int
len
,
int
family
)
{
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论