Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
f3e2db23
Commit
f3e2db23
authored
16 years ago
by
Emmanuel Milou
Browse files
Options
Downloads
Patches
Plain Diff
Add functional url hook
parent
0fc88dd5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/hooks/urlhook.cpp
+34
-5
34 additions, 5 deletions
src/hooks/urlhook.cpp
src/hooks/urlhook.h
+7
-1
7 additions, 1 deletion
src/hooks/urlhook.h
src/sipvoiplink.cpp
+4
-2
4 additions, 2 deletions
src/sipvoiplink.cpp
with
45 additions
and
8 deletions
src/hooks/urlhook.cpp
+
34
−
5
View file @
f3e2db23
...
...
@@ -18,21 +18,50 @@
*/
#include
"urlhook.h"
#include
<iostream>
UrlHook
::
UrlHook
()
{
}
UrlHook
::~
UrlHook
()
{
}
void
UrlHook
::
addAction
(
pjsip_msg
*
msg
,
std
::
string
field
,
std
::
string
command
){
bool
UrlHook
::
addAction
(
pjsip_msg
*
msg
,
std
::
string
field
,
std
::
string
command
){
std
::
string
command_bg
;
std
::
string
command_bg
,
value
,
url
;
pjsip_generic_string_hdr
*
hdr
;
size_t
pos
;
std
::
cout
<<
"SIP field: "
<<
field
<<
" - command: "
<<
command
<<
std
::
endl
;;
command_bg
=
command
+
"&"
;
/* Get the URL in the SIP header */
if
(
(
hdr
=
(
pjsip_generic_string_hdr
*
)
this
->
url_hook_fetch_header_value
(
msg
,
field
))
!=
NULL
)
{
value
=
hdr
->
hvalue
.
ptr
;
if
(
(
pos
=
value
.
find
(
"
\n
"
))
!=
std
::
string
::
npos
)
{
url
=
value
.
substr
(
0
,
pos
);
/* Execute the command in the background to not block the application */
command_bg
=
command
+
" "
+
url
+
"&"
;
/* Execute a system call */
RUN_COMMAND
(
command_bg
.
c_str
());
return
true
;
}
else
return
false
;
}
return
false
;
}
void
*
UrlHook
::
url_hook_fetch_header_value
(
pjsip_msg
*
msg
,
std
::
string
field
)
{
pj_str_t
name
;
std
::
cout
<<
"url hook fetch header value"
<<
std
::
endl
;
system
(
command_bg
.
c_str
());
/* Convert the field name into pjsip type */
name
=
pj_str
((
char
*
)
field
.
c_str
());
/* Get the header value and convert into string*/
return
pjsip_msg_find_hdr_by_name
(
msg
,
&
name
,
NULL
);
}
This diff is collapsed.
Click to expand it.
src/hooks/urlhook.h
+
7
−
1
View file @
f3e2db23
...
...
@@ -24,6 +24,8 @@
#include
<pjsip.h>
#define RUN_COMMAND(command) system(command);
class
UrlHook
{
public:
...
...
@@ -37,7 +39,11 @@ class UrlHook {
*/
~
UrlHook
();
void
addAction
(
pjsip_msg
*
msg
,
std
::
string
field
,
std
::
string
command
);
bool
addAction
(
pjsip_msg
*
msg
,
std
::
string
field
,
std
::
string
command
);
private:
void
*
url_hook_fetch_header_value
(
pjsip_msg
*
msg
,
std
::
string
field
);
};
#endif // URL_HOOK_H
This diff is collapsed.
Click to expand it.
src/sipvoiplink.cpp
+
4
−
2
View file @
f3e2db23
...
...
@@ -1951,9 +1951,11 @@ void call_on_tsx_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_e
}
// URL HOOK //
urlhook
->
addAction
(
rdata
->
msg_info
.
msg
,
if
(
!
urlhook
->
addAction
(
rdata
->
msg_info
.
msg
,
Manager
::
instance
().
getConfigString
(
HOOKS
,
URLHOOK_SIP_FIELD
),
Manager
::
instance
().
getConfigString
(
HOOKS
,
URLHOOK_COMMAND
));
Manager
::
instance
().
getConfigString
(
HOOKS
,
URLHOOK_COMMAND
))
)
{
_debug
(
"URL hook failed
\n
"
);
}
// Generate a new call ID for the incoming call!
id
=
Manager
::
instance
().
getNewCallID
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment