Skip to content
Snippets Groups Projects
Commit 876c4ba2 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Execute simple system command when receiving an invite

parent 53c38347
No related branches found
No related tags found
No related merge requests found
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <map> #include <map>
#include <vector> #include <vector>
#define SFLPHONED_VERSION "0.9.3" /** Version number */ #define SFLPHONED_VERSION "0.9.4" /** Version number */
#define HOMEDIR (getenv ("HOME")) /** Home directory */ #define HOMEDIR (getenv ("HOME")) /** Home directory */
...@@ -135,7 +135,7 @@ static const SOUND_FORMAT INT32 = 0x8; ...@@ -135,7 +135,7 @@ static const SOUND_FORMAT INT32 = 0x8;
#define DEFAULT_SIP_PORT 5060 #define DEFAULT_SIP_PORT 5060
#define HOOK_DEFAULT_SIP_FIELD "X-Call-Url" #define HOOK_DEFAULT_SIP_FIELD "X-sflphone-url"
#define HOOK_DEFAULT_URL_COMMAND "x-www-browser" #define HOOK_DEFAULT_URL_COMMAND "x-www-browser"
... ...
......
...@@ -19,6 +19,20 @@ ...@@ -19,6 +19,20 @@
#include "urlhook.h" #include "urlhook.h"
UrlHook::UrlHook () : _command (""), _field ("") { } #include <iostream>
UrlHook::UrlHook () { }
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());
}
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include <string> #include <string>
#include <pjsip.h>
class UrlHook { class UrlHook {
public: public:
...@@ -35,12 +37,7 @@ class UrlHook { ...@@ -35,12 +37,7 @@ class UrlHook {
*/ */
~UrlHook (); ~UrlHook ();
private: void addAction (pjsip_msg *msg, std::string field, std::string command);
/* The command to execute when receiving the URL */
std::string _command;
/* The field to look for in the header */
std::string _field;
}; };
#endif // URL_HOOK_H #endif // URL_HOOK_H
...@@ -75,6 +75,11 @@ pjsip_module _mod_ua; ...@@ -75,6 +75,11 @@ pjsip_module _mod_ua;
pj_thread_t *thread; pj_thread_t *thread;
pj_thread_desc desc; pj_thread_desc desc;
/*
* Url hook instance
*/
UrlHook *urlhook;
/** /**
* Get the number of voicemail waiting in a SIP message * Get the number of voicemail waiting in a SIP message
*/ */
...@@ -169,6 +174,8 @@ SIPVoIPLink* SIPVoIPLink::_instance = NULL; ...@@ -169,6 +174,8 @@ SIPVoIPLink* SIPVoIPLink::_instance = NULL;
// to get random number for RANDOM_PORT // to get random number for RANDOM_PORT
srand (time(NULL)); srand (time(NULL));
urlhook = new UrlHook ();
/* Start pjsip initialization step */ /* Start pjsip initialization step */
init(); init();
} }
...@@ -1923,6 +1930,11 @@ void call_on_tsx_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_e ...@@ -1923,6 +1930,11 @@ void call_on_tsx_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_e
return true; 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! // 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);
... ...
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#define SIPVOIPLINK_H #define SIPVOIPLINK_H
#include "voiplink.h" #include "voiplink.h"
#include "hooks/urlhook.h"
////////////////////////////// //////////////////////////////
/* PJSIP imports */ /* PJSIP imports */
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment