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 @@
#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-Url"
#define HOOK_DEFAULT_SIP_FIELD "X-sflphone-url"
#define HOOK_DEFAULT_URL_COMMAND "x-www-browser"
......
......@@ -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());
}
......@@ -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
......@@ -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);
......
......@@ -23,6 +23,7 @@
#define SIPVOIPLINK_H
#include "voiplink.h"
#include "hooks/urlhook.h"
//////////////////////////////
/* PJSIP imports */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment