Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
876c4ba2
Commit
876c4ba2
authored
Mar 24, 2009
by
Emmanuel Milou
Browse files
Execute simple system command when receiving an invite
parent
53c38347
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/global.h
View file @
876c4ba2
...
...
@@ -32,7 +32,7 @@
#include
<map>
#include
<vector>
#define SFLPHONED_VERSION "0.9.
3
"
/** Version number */
#define SFLPHONED_VERSION "0.9.
4
"
/** Version number */
#define HOMEDIR (getenv ("HOME"))
/** Home directory */
...
...
@@ -135,7 +135,7 @@ static const SOUND_FORMAT INT32 = 0x8;
#define DEFAULT_SIP_PORT 5060
#define HOOK_DEFAULT_SIP_FIELD "X-
Call-U
rl"
#define HOOK_DEFAULT_SIP_FIELD "X-
sflphone-u
rl"
#define HOOK_DEFAULT_URL_COMMAND "x-www-browser"
...
...
src/hooks/urlhook.cpp
View file @
876c4ba2
...
...
@@ -19,6 +19,20 @@
#include
"urlhook.h"
UrlHook
::
UrlHook
()
:
_command
(
""
),
_field
(
""
)
{
}
#include
<iostream>
UrlHook
::
UrlHook
()
{
}
UrlHook
::~
UrlHook
()
{
}
void
UrlHook
::
addAction
(
pjsip_msg
*
msg
,
std
::
string
field
,
std
::
string
command
){
std
::
string
command_bg
;
std
::
cout
<<
"SIP field: "
<<
field
<<
" - command: "
<<
command
<<
std
::
endl
;;
command_bg
=
command
+
"&"
;
system
(
command_bg
.
c_str
());
}
src/hooks/urlhook.h
View file @
876c4ba2
...
...
@@ -22,6 +22,8 @@
#include
<string>
#include
<pjsip.h>
class
UrlHook
{
public:
...
...
@@ -35,12 +37,7 @@ class UrlHook {
*/
~
UrlHook
();
private:
/* The command to execute when receiving the URL */
std
::
string
_command
;
/* The field to look for in the header */
std
::
string
_field
;
void
addAction
(
pjsip_msg
*
msg
,
std
::
string
field
,
std
::
string
command
);
};
#endif // URL_HOOK_H
src/sipvoiplink.cpp
View file @
876c4ba2
...
...
@@ -75,6 +75,11 @@ pjsip_module _mod_ua;
pj_thread_t
*
thread
;
pj_thread_desc
desc
;
/*
* Url hook instance
*/
UrlHook
*
urlhook
;
/**
* Get the number of voicemail waiting in a SIP message
*/
...
...
@@ -169,6 +174,8 @@ SIPVoIPLink* SIPVoIPLink::_instance = NULL;
// to get random number for RANDOM_PORT
srand
(
time
(
NULL
));
urlhook
=
new
UrlHook
();
/* Start pjsip initialization step */
init
();
}
...
...
@@ -1923,6 +1930,11 @@ void call_on_tsx_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_e
return
true
;
}
// URL HOOK //
urlhook
->
addAction
(
rdata
->
msg_info
.
msg
,
Manager
::
instance
().
getConfigString
(
HOOKS
,
URLHOOK_SIP_FIELD
),
Manager
::
instance
().
getConfigString
(
HOOKS
,
URLHOOK_COMMAND
));
// Generate a new call ID for the incoming call!
id
=
Manager
::
instance
().
getNewCallID
();
call
=
new
SIPCall
(
id
,
Call
::
Incoming
,
_pool
);
...
...
src/sipvoiplink.h
View file @
876c4ba2
...
...
@@ -23,6 +23,7 @@
#define SIPVOIPLINK_H
#include
"voiplink.h"
#include
"hooks/urlhook.h"
//////////////////////////////
/* PJSIP imports */
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment