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
35ea93aa
Commit
35ea93aa
authored
Mar 24, 2009
by
Emmanuel Milou
Browse files
Options
Downloads
Patches
Plain Diff
Make hook manager independant from the communication protocol
parent
f3e2db23
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/hooks/urlhook.cpp
+6
-36
6 additions, 36 deletions
src/hooks/urlhook.cpp
src/hooks/urlhook.h
+2
-5
2 additions, 5 deletions
src/hooks/urlhook.h
src/sipvoiplink.cpp
+40
-5
40 additions, 5 deletions
src/sipvoiplink.cpp
with
48 additions
and
46 deletions
src/hooks/urlhook.cpp
+
6
−
36
View file @
35ea93aa
...
@@ -24,44 +24,14 @@ UrlHook::UrlHook () { }
...
@@ -24,44 +24,14 @@ UrlHook::UrlHook () { }
UrlHook
::~
UrlHook
()
{
}
UrlHook
::~
UrlHook
()
{
}
bool
UrlHook
::
addAction
(
pjsip_msg
*
msg
,
std
::
string
field
,
std
::
string
command
){
void
UrlHook
::
addAction
(
std
::
string
field
_value
,
std
::
string
command
){
std
::
string
command_bg
,
value
,
url
;
std
::
string
command_bg
;
pjsip_generic_string_hdr
*
hdr
;
size_t
pos
;
std
::
cout
<<
"SIP field: "
<<
field
<<
" - command: "
<<
command
<<
std
::
endl
;;
/* 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 */
/* Execute the command in the background to not block the application */
command_bg
=
command
+
" "
+
url
+
"&"
;
command_bg
=
command
+
" "
+
field_value
+
"&"
;
/* Execute a system call */
/* Execute a system call */
RUN_COMMAND
(
command_bg
.
c_str
());
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
;
/* 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
+
2
−
5
View file @
35ea93aa
...
@@ -21,8 +21,7 @@
...
@@ -21,8 +21,7 @@
#define URL_HOOK_H
#define URL_HOOK_H
#include
<string>
#include
<string>
#include
<stdlib.h>
#include
<pjsip.h>
#define RUN_COMMAND(command) system(command);
#define RUN_COMMAND(command) system(command);
...
@@ -39,11 +38,9 @@ class UrlHook {
...
@@ -39,11 +38,9 @@ class UrlHook {
*/
*/
~
UrlHook
();
~
UrlHook
();
bool
addAction
(
pjsip_msg
*
msg
,
std
::
string
field
,
std
::
string
command
);
void
addAction
(
std
::
string
,
std
::
string
);
private:
private:
void
*
url_hook_fetch_header_value
(
pjsip_msg
*
msg
,
std
::
string
field
);
};
};
#endif // URL_HOOK_H
#endif // URL_HOOK_H
This diff is collapsed.
Click to expand it.
src/sipvoiplink.cpp
+
40
−
5
View file @
35ea93aa
...
@@ -51,6 +51,8 @@ bool setCallAudioLocal(SIPCall* call, std::string localIP, bool stun, std::strin
...
@@ -51,6 +51,8 @@ bool setCallAudioLocal(SIPCall* call, std::string localIP, bool stun, std::strin
void
handle_incoming_options
(
pjsip_rx_data
*
rxdata
);
void
handle_incoming_options
(
pjsip_rx_data
*
rxdata
);
std
::
string
fetch_header_value
(
pjsip_msg
*
msg
,
std
::
string
field
);
/*
/*
* The global pool factory
* The global pool factory
*/
*/
...
@@ -1950,13 +1952,19 @@ void call_on_tsx_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_e
...
@@ -1950,13 +1952,19 @@ void call_on_tsx_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_e
return
true
;
return
true
;
}
}
// URL HOOK //
/******************************************* URL HOOK *********************************************/
if
(
!
urlhook
->
addAction
(
rdata
->
msg_info
.
msg
,
Manager
::
instance
().
getConfigString
(
HOOKS
,
URLHOOK_SIP_FIELD
),
std
::
string
header_value
;
Manager
::
instance
().
getConfigString
(
HOOKS
,
URLHOOK_COMMAND
))
)
{
_debug
(
"URL hook failed
\n
"
);
header_value
=
fetch_header_value
(
rdata
->
msg_info
.
msg
,
Manager
::
instance
().
getConfigString
(
HOOKS
,
URLHOOK_SIP_FIELD
));
if
(
header_value
!=
""
){
urlhook
->
addAction
(
header_value
,
Manager
::
instance
().
getConfigString
(
HOOKS
,
URLHOOK_COMMAND
));
}
}
/************************************************************************************************/
// Generate a new call ID for the incoming call!
// Generate a new call ID for the incoming call!
id
=
Manager
::
instance
().
getNewCallID
();
id
=
Manager
::
instance
().
getNewCallID
();
call
=
new
SIPCall
(
id
,
Call
::
Incoming
,
_pool
);
call
=
new
SIPCall
(
id
,
Call
::
Incoming
,
_pool
);
...
@@ -2548,4 +2556,31 @@ void call_on_tsx_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_e
...
@@ -2548,4 +2556,31 @@ void call_on_tsx_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_e
return
true
;
return
true
;
}
}
std
::
string
fetch_header_value
(
pjsip_msg
*
msg
,
std
::
string
field
)
{
pj_str_t
name
;
pjsip_generic_string_hdr
*
hdr
;
std
::
string
value
,
url
;
size_t
pos
;
std
::
cout
<<
"fetch header value"
<<
std
::
endl
;
/* Convert the field name into pjsip type */
name
=
pj_str
((
char
*
)
field
.
c_str
());
/* Get the header value and convert into string*/
hdr
=
(
pjsip_generic_string_hdr
*
)
pjsip_msg_find_hdr_by_name
(
msg
,
&
name
,
NULL
);
if
(
!
hdr
)
return
""
;
value
=
hdr
->
hvalue
.
ptr
;
if
(
(
pos
=
value
.
find
(
"
\n
"
))
==
std
::
string
::
npos
)
{
return
""
;
}
url
=
value
.
substr
(
0
,
pos
);
return
url
;
}
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
sign in
to comment