- Notifies the pre_answer

- Dialplan examples
- New version of commons
- Priority of contexts
- New K3L install script - getk3l.sh
- CLI return in XML
- More options in GET and SET commands
- Events (ESL) to send/receive SMS.
- fax-adjustment-timeout implemented
- accountcode and language
- Owner destroy
- Destroy wait for resources release
- static const expression
- Hangup cause
This commit is contained in:
Geovani Ricardo Wiedenhoft committed 2010-12-01 16:40:35 -02:00
1 parent 6b52a43314
commit 5df1683c38
98 files changed
+7491 -6153

No files matched your search

@@ -268,7 +268,7 @@ struct Transfer
if (!(_call->_flags.check(Kflags::XFER_DIALING)))
{
_call->_flags.set(Kflags::XFER_DIALING);
_idx_xfer_dial = Board::board(_pvt->target().device)->_timers.add(Opt::_transferdigittimeout, &userXferTimer, _pvt, TM_VAL_CALL);
_idx_xfer_dial = Board::board(_pvt->target().device)->_timers.add(Opt::_options._transferdigittimeout(), &userXferTimer, _pvt, TM_VAL_CALL);
}
else
{
@@ -280,7 +280,7 @@ struct Transfer
}
}
catch (K3LAPI::invalid_device & err)
catch (K3LAPITraits::invalid_device & err)
{
LOG(ERROR, PVT_FMT(_pvt->target(), "Unable to get device: %d!") % err.device);
}
@@ -506,7 +506,7 @@ struct Transfer<T, false>
if (!(_call->_flags.check(Kflags::XFER_DIALING) || _call->_flags.check(Kflags::XFER_QSIG_DIALING)))
{
_call->_flags.set(Kflags::XFER_DIALING);
_idx_xfer_dial = Board::board(_pvt->target().device)->_timers.add(Opt::_transferdigittimeout, &userXferTimer, _pvt, TM_VAL_CALL);
_idx_xfer_dial = Board::board(_pvt->target().device)->_timers.add(Opt::_options._transferdigittimeout(), &userXferTimer, _pvt, TM_VAL_CALL);
}
else
{
@@ -530,7 +530,7 @@ struct Transfer<T, false>
}
}
catch (K3LAPI::invalid_device & err)
catch (K3LAPITraits::invalid_device & err)
{
LOG(ERROR, PVT_FMT(_pvt->target(), "Unable to get device: %d!") % err.device);
}
@@ -735,6 +735,9 @@ struct Transfer<T, false>
};
/*************************** SMS **********************************************/
#define ESL_SMS_RECEIVED "khomp::sms_received"
#define ESL_SMS_SENT "khomp::sms_sent"
struct SMS : public Application
{
typedef std::list< switch_core_session_t *> OwnersList;
@@ -889,6 +892,78 @@ struct SMS : public Application
bool _conf;
};
static struct _SMSEvent : public ESL
{
_SMSEvent() : ESL("khomp::sms")
{
if(_events)
{
_events->push_back(ESL_SMS_RECEIVED);
_events->push_back(ESL_SMS_SENT);
}
}
~_SMSEvent()
{
if(_events)
{
//Remove two from vector
_events->pop_back();
_events->pop_back();
}
}
bool operator()(Board::KhompPvt * pvt, ReceiveData & data)
{
switch_event_t *event = create(ESL_SMS_RECEIVED);
if(!event)
{
LOG(ERROR, "Cannot create SMS ESL");
return false;
}
add(event, pvt->target());
add(event, "Type", data._type);
add(event, "From", data._from);
add(event, "Date", data._date);
add(event, "Size", data._size);
add(event, "Coding", data._coding);
add(event, "Serial", data._serial);
add(event, "Id", data._id);
add(event, "Page", data._page);
add(event, "Pages", data._pages);
add(event, "Sc_date", data._sc_date);
add(event, "Status", data._status);
add(event, "Body", data._body);
return fire(&event);
}
bool operator()(Board::KhompPvt * pvt, SendData & data)
{
switch_event_t *event = create(ESL_SMS_SENT);
if(!event)
{
LOG(ERROR, "Cannot create SMS ESL");
return false;
}
add(event, pvt->target());
add(event, "Dest", data._dest);
add(event, "Body", data._body);
add(event, "Confirmation?", (data._conf ? "Yes" : "No"));
return fire(&event);
}
} SMSEvent;
struct Request
{
/* "empty" constructor */
+173 -81
View File
@@ -99,12 +99,52 @@ struct Command
std::string usage; /* usage of the command, a help */
};
struct CommandXMLOutput : public Command
{
void createRoot(const char *name)
{
root = switch_xml_new(name);
}
void insertXML(switch_xml_t xml)
{
switch_xml_insert(xml,root,0);
}
void clearRoot()
{
if(root)
{
switch_xml_free(root);
root = NULL;
}
}
void printXMLOutput(switch_stream_handle_t *stream)
{
K::Logger::Logg2(C_CLI,stream,switch_xml_toxml(root,SWITCH_FALSE));
}
CommandXMLOutput() : root(NULL) {};
switch_xml_t root; /* for commands that ouput as xml */
};
struct Cli
{
/* Useful definitions --------------------------------------------------- */
typedef switch_status_t (APIFunc)(const char*, switch_core_session_t*, switch_stream_handle_t*);
typedef std::vector<Command*> Commands;
/* Define the output types form commands */
typedef enum
{
VERBOSE = 1,
CONCISE,
DETAILED,
XML
} OutputType;
/* register our commands, but you must create the command function */
static void registerCommands(APIFunc func,switch_loadable_module_interface_t **mod_int);
@@ -145,27 +185,31 @@ struct Cli
/* The Commands --------------------------------------------------------- */
/* khomp summary */
static struct _KhompSummary : public Command
static struct _KhompSummary : public CommandXMLOutput
{
_KhompSummary(bool on_cli_term = true):
_on_cli_term(on_cli_term)
CommandXMLOutput(),
_on_cli_term(on_cli_term),
xdevs(NULL)
{
complete_name = "summary";
options.push_back("verbose");
options.push_back("concise");
options.push_back("xml");
brief = "Print system info.";
usage = \
"Prints detailed info about the system like API version and \n" \
"boards characteristics like DSPs version.\n\n" \
"Usage: khomp summary [concise]";
"Usage: khomp summary [concise|verbose|xml]";
_commands.push_back(this);
};
bool execute(int argc, char *argv[]);
bool _on_cli_term; /* indicates if message is sent to fs_cli */
bool _on_cli_term; /* indicates if message is sent to fs_cli */
switch_xml_t xdevs; /* support xml needed to help the interation */
} KhompSummary;
/* khomp show calls */
@@ -239,21 +283,22 @@ struct Cli
} KhompChannelsUnblock;
/* khomp show statistics */
static struct _KhompShowStatistics : public Command
static struct _KhompShowStatistics : public CommandXMLOutput
{
_KhompShowStatistics()
_KhompShowStatistics() : CommandXMLOutput(), xdevs(NULL)
{
complete_name = "show statistics";
options.push_back("verbose");
options.push_back("detailed");
options.push_back("xml");
brief = "Shows statistics of the channels.";
usage = \
"Shows statistics of the channels, like number of calls incoming \n" \
"and outgoing, status, status time.\n\n" \
"Usage: khomp show statistics [{verbose [<board> [<channel>]]} | \n" \
"Usage: khomp show statistics [{{verbose|xml} [<board> [<channel>]]} | \n" \
" {detailed <board> <channel>}]\n" \
"\tboard -- Number of the board (start from 0).\n" \
"\tchannel -- Number of the channel (start from 0).\n" \
@@ -274,20 +319,22 @@ struct Cli
bool execute(int argc, char *argv[]);
/* support functions */
void cliStatistics(unsigned int device);
void cliDetailedStatistics(unsigned int device, unsigned int channel);
void cliStatistics(unsigned int device, OutputType output_type);
void cliDetailedStatistics(unsigned int device, unsigned int channel, OutputType output_type);
switch_xml_t xdevs; /* support xml needed to help the interation */
} KhompShowStatistics;
/* khomp show channels */
static struct _KhompShowChannels: public Command
static struct _KhompShowChannels: public CommandXMLOutput
{
_KhompShowChannels()
_KhompShowChannels() : CommandXMLOutput(), xdev(NULL)
{
complete_name = "show channels";
options.push_back("verbose");
options.push_back("concise");
options.push_back("xml");
brief = "Show all channels status.";
usage = \
@@ -295,34 +342,40 @@ struct Cli
"khomp API point of view.\n\n" \
"Usage: \n" \
"khomp show channels [{<board> [<channel>]} | \n" \
"{{concise|verbose} [<board> [<channel>]]}]\n" \
"{{concise|verbose|xml} [<board> [<channel>]]}]\n" \
"\tboard -- Number of the board (start from 0).\n" \
"e.g. khomp show channels - List status of all channels of all boards.\n" \
"e.g. khomp show channels concise 0 - List status of all channels of \n" \
" board 0 in a concise way.";
" board 0 in a concise way.\n" \
"e.g. khomp show channels xml 0 - List status of all channels of \n" \
" board 0 in a xml structure.";
_commands.push_back(this);
};
/* support function for _KhompShowChannels */
void showChannel(unsigned int device, bool concise, unsigned int channel);
void showChannels(unsigned int device, bool concise);
void showChannel(unsigned int device, unsigned int channel, OutputType output_type = Cli::VERBOSE);
void showChannels(unsigned int device, OutputType output_type = Cli::VERBOSE);
bool execute(int argc, char *argv[]);
switch_xml_t xdev; /* support xml needed to help the interation */
} KhompShowChannels;
/* khomp show links */
static struct _KhompShowLinks: public Command
static struct _KhompShowLinks: public CommandXMLOutput
{
_KhompShowLinks()
_KhompShowLinks() : CommandXMLOutput(), xdev(NULL)
{
complete_name = "show links";
options.push_back("verbose");
options.push_back("concise");
options.push_back("xml");
options.push_back("errors");
options.push_back("errors verbose");
options.push_back("errors concise");
options.push_back("errors xml");
brief = "Show E1 link(s) status/errors counters in a concise \n" \
"way or not.";
@@ -332,8 +385,9 @@ struct Cli
"status/the error counters of each link on the board. It prints in \n" \
"a concise way for parsing facilities.\n\n" \
"Usage: \n" \
"khomp show links [[errors] [{<board>} | {{concise|verbose} [<board>]}]]\n" \
"khomp show links [[errors] [{<board>} | {{concise|verbose|xml} [<board>]}]]\n"\
"e.g. khomp show links - Show all links of all boards.\n" \
"e.g. khomp show links xml - Show all links of all boards in xml.\n" \
"e.g. khomp show links errors - Show error counters of all links of \n" \
" all boards.\n" \
"e.g. khomp show links errors 0 - Show error counters of all links of \n" \
@@ -343,10 +397,12 @@ struct Cli
};
/* support function for _KhompShowLinks */
void showLinks(unsigned int device, bool concise);
void showErrors(unsigned int device, bool concise);
void showLinks(unsigned int device, OutputType output_type = Cli::VERBOSE);
void showErrors(unsigned int device, OutputType output_type = Cli::VERBOSE);
std::string getLinkStatus(int dev, int obj, Verbose::Presentation fmt);
bool execute(int argc, char *argv[]);
switch_xml_t xdev; /* support xml needed to help the interation */
} KhompShowLinks;
/* khomp clear links */
@@ -653,24 +709,41 @@ struct Cli
{
complete_name = "get";
options.push_back("dialplan");
options.push_back("echo-canceller");
options.push_back("auto-gain-control");
options.push_back("out-of-band-dtmfs");
options.push_back("suppression-delay");
options.push_back("auto-fax-adjustment");
options.push_back("fax-adjustment-timeout");
options.push_back("pulse-forwarding");
options.push_back("r2-strict-behaviour");
options.push_back("r2-preconnect-wait");
options.push_back("native-bridge");
options.push_back("suppression-delay");
options.push_back("context-fxo");
options.push_back("context-fxo-alt");
options.push_back("context-fxs");
options.push_back("context-fxs-alt");
options.push_back("context-gsm-call");
options.push_back("context-gsm-call-alt");
options.push_back("context-gsm-sms");
options.push_back("context-digital");
options.push_back("context-fxs");
options.push_back("context-fxo");
options.push_back("context-gsm-call");
options.push_back("context-gsm-sms");
options.push_back("context-pr");
options.push_back("log-to-console");
options.push_back("log-to-disk");
options.push_back("trace");
options.push_back("output-volume");
options.push_back("input-volume");
options.push_back("fxs-global-orig");
options.push_back("fxs-co-dialtone");
options.push_back("fxs-bina");
options.push_back("disconnect-delay");
options.push_back("delay-ringback-co");
options.push_back("delay-ringback-pbx");
options.push_back("ignore-letter-dtmfs");
options.push_back("fxo-send-pre-audio");
options.push_back("fxs-digit-timeout");
options.push_back("drop-collect-call");
options.push_back("kommuter-activation");
options.push_back("kommuter-timeout");
options.push_back("user-transfer-digits");
options.push_back("flash-to-digits");
brief = "Get configuration options in the Khomp channel.";
@@ -678,36 +751,37 @@ struct Cli
"Usage: khomp get <option>\n" \
"<option> -- Shown below, with a short description each.\n\n" \
"Option Description\n" \
"dialplan Gets the Name of the dialplan module in use.\n" \
"echo-canceller Gets the echo cancellation procedures if they are \n" \
" avaliable.\n" \
" avaliable.\n" \
"auto-gain-control Gets the AGC procedures if they are avaliable.\n" \
"out-of-band-dtmfs Gets DTMFs to be sent out-of-band (using ast_frames) \n" \
" instead of in-band (audio).\n" \
" instead of in-band (audio).\n" \
"suppression-delay Enable/disable the internal buffer for DTMF \n" \
" suppression.\n" \
"auto-fax-adjustment Gets the automatic adjustment for FAX (mainly, \n" \
" disables the echo canceller).\n" \
" disables the echo canceller).\n" \
//"fax-adjustment-timeout"
"pulse-forwarding Gets the forwarding of detected pulses as DTMF tones.\n" \
"r2-strict-behaviour Gets the R2 protocol behavior while answering lines.\n" \
"r2-preconnect-wait Sets the R2 protocol delay to pre-connect after \n" \
" sending ringback signal.\n" \
"native-bridge Enable/disable the native bridge mode for the channel.\n"\
"suppression-delay Enable/disable the internal buffer for DTMF \n" \
" suppression.\n" \
"context-fxo Context (may be a template) for receiving FXO calls.\n" \
"context-fxo-alt Alternative context (may be a template) for \n" \
" receiving FXO calls.\n" \
"context-fxs Context (may be a template) for receiving FXS calls.\n" \
"context-fxs-alt Alternative context (may be a template) for \n" \
" receiving FXS calls.\n" \
"context-gsm-call Context (may be a template) for receiving GSM calls.\n" \
"context-gsm-call-alt Alternative context (may be a template) for \n" \
" receiving GSM calls.\n" \
"context-gsm-sms Context (may be a template) for receiving GSM \n" \
" messages.\n" \
"r2-preconnect-wait Gets the R2 protocol delay to pre-connect after \n" \
" sending ringback signal.\n" \
"context-digital Context (may be a template) for receiving digital \n" \
" (E1) calls.\n" \
" (E1) calls.\n" \
"context-fxs Context (may be a template) for receiving FXS calls.\n" \
"context-fxo Context (may be a template) for receiving FXO calls.\n" \
"context-gsm-call Context (may be a template) for receiving GSM calls.\n" \
"context-gsm-sms Context (may be a template) for receiving GSM \n" \
" messages.\n" \
"context-pr Context (may be a template) for receiving calls on \n" \
" Passive Record boards.\n" \
"log-to-console Gets the logging of messages to console.\n" \
"log-to-disk Gets the logging of messages to disk.\n" \
"trace Gets the low level tracing.\n" \
"output-volume Gets the volume multiplier to be applied by the \n" \
" board over the output audio.\n" \
" board over the output audio.\n" \
"input-volume Gets the volume multiplier to be applied by the \n" \
" board over the input audio.\n\n" \
" board over the input audio.\n\n" \
"FOR ALL COMMANDS, CHECK THE DOCUMENTATION.";
_commands.push_back(this);
@@ -723,24 +797,42 @@ struct Cli
{
complete_name = "set";
options.push_back("dialplan");
options.push_back("echo-canceller");
options.push_back("auto-gain-control");
options.push_back("out-of-band-dtmfs");
options.push_back("suppression-delay");
options.push_back("auto-fax-adjustment");
options.push_back("fax-adjustment-timeout");
options.push_back("pulse-forwarding");
options.push_back("r2-strict-behaviour");
options.push_back("r2-preconnect-wait");
options.push_back("native-bridge");
options.push_back("suppression-delay");
options.push_back("context-fxo");
options.push_back("context-fxo-alt");
options.push_back("context-fxs");
options.push_back("context-fxs-alt");
options.push_back("context-gsm-call");
options.push_back("context-gsm-call-alt");
options.push_back("context-gsm-sms");
options.push_back("context-digital");
options.push_back("context-fxs");
options.push_back("context-fxo");
options.push_back("context-gsm-call");
options.push_back("context-gsm-sms");
options.push_back("context-pr");
options.push_back("log-to-console");
options.push_back("log-to-disk");
options.push_back("trace");
options.push_back("output-volume");
options.push_back("input-volume");
options.push_back("fxs-global-orig");
options.push_back("fxs-co-dialtone");
options.push_back("fxs-bina");
options.push_back("disconnect-delay");
options.push_back("delay-ringback-co");
options.push_back("delay-ringback-pbx");
options.push_back("ignore-letter-dtmfs");
options.push_back("fxo-send-pre-audio");
options.push_back("fxs-digit-timeout");
options.push_back("drop-collect-call");
options.push_back("kommuter-activation");
options.push_back("kommuter-timeout");
options.push_back("user-transfer-digits");
options.push_back("flash-to-digits");
brief = "Ajust configuration options in the Khomp channel.";
usage = \
@@ -749,36 +841,36 @@ struct Cli
"\t<value> -- Depends on the option. Check the documentation for \n" \
"\t more info.\n\n" \
"Option Description\n" \
"dialplan Sets the Name of the dialplan module in use.\n" \
"echo-canceller Sets the echo cancellation procedures if they are \n" \
" avaliable.\n" \
" avaliable.\n" \
"auto-gain-control Sets the AGC procedures if they are avaliable.\n" \
"out-of-band-dtmfs Sets DTMFs to be sent out-of-band (using ast_frames) \n" \
" instead of in-band (audio).\n" \
" instead of in-band (audio).\n" \
"suppression-delay Enable/disable the internal buffer for DTMF \n" \
" suppression.\n" \
"auto-fax-adjustment Sets the automatic adjustment for FAX (mainly, \n" \
" disables the echo canceller).\n" \
" disables the echo canceller).\n" \
"pulse-forwarding Sets the forwarding of detected pulses as DTMF tones.\n" \
"r2-strict-behaviour Sets the R2 protocol behavior while answering lines.\n" \
"r2-preconnect-wait Sets the R2 protocol delay to pre-connect after \n" \
" sending ringback signal.\n" \
"native-bridge Enable/disable the native bridge mode for the channel.\n"\
"suppression-delay Enable/disable the internal buffer for DTMF \n" \
" suppression.\n" \
"context-fxo Context (may be a template) for receiving FXO calls.\n" \
"context-fxo-alt Alternative context (may be a template) for \n" \
" receiving FXO calls.\n" \
"context-fxs Context (may be a template) for receiving FXS calls.\n" \
"context-fxs-alt Alternative context (may be a template) for \n" \
" receiving FXS calls.\n" \
"context-gsm-call Context (may be a template) for receiving GSM calls.\n" \
"context-gsm-call-alt Alternative context (may be a template) for \n" \
" receiving GSM calls.\n" \
"context-gsm-sms Context (may be a template) for receiving GSM \n" \
" messages.\n" \
" sending ringback signal.\n" \
"context-digital Context (may be a template) for receiving digital \n" \
" (E1) calls.\n" \
" (E1) calls.\n" \
"context-fxs Context (may be a template) for receiving FXS calls.\n" \
"context-fxo Context (may be a template) for receiving FXO calls.\n" \
"context-gsm-call Context (may be a template) for receiving GSM calls.\n" \
"context-gsm-sms Context (may be a template) for receiving GSM \n" \
" messages.\n" \
"context-pr Context (may be a template) for receiving calls on \n" \
" Passive Record boards.\n" \
"log-to-console Sets the logging of messages to console.\n" \
"log-to-disk Sets the logging of messages to disk.\n" \
"trace Sets the low level tracing.\n" \
"output-volume Sets the volume multiplier to be applied by the \n" \
" board over the output audio.\n" \
" board over the output audio.\n" \
"input-volume Sets the volume multiplier to be applied by the \n" \
" board over the input audio.\n\n" \
" board over the input audio.\n\n" \
"FOR ALL COMMANDS, CHECK THE DOCUMENTATION.";
_commands.push_back(this);
+2 -2
View File
@@ -58,10 +58,10 @@
"%s (d=%02d,c=%03d) " msg, __SWITCH_FUNC__, dev, obj
#define PVT_FMT(tgt,msg) \
FMT("%s (d=%02hu,c=%03hu) " msg) % __SWITCH_FUNC__ % tgt.device % tgt.object
FMT("%s (d=%02d,c=%03d) " msg) % __SWITCH_FUNC__ % tgt.device % tgt.object
#define PVT_MSG(tgt,msg) \
"%s (d=%02hu,c=%03hu) " msg, __SWITCH_FUNC__, tgt.device, tgt.object
"%s (d=%02d,c=%03d) " msg, __SWITCH_FUNC__, tgt.device, tgt.object
#define D(x) ( FMT( "%s: " x ) % __func__ )
+1 -1
View File
@@ -97,7 +97,7 @@ struct FrameStorage
template < int S >
struct FrameManager: protected FrameStorage
{
typedef char Packet[ S ];
typedef const char Packet[ S ];
typedef Ringbuffer < Packet > AudioBuffer;
@@ -98,7 +98,9 @@ struct Globals
static Mutex khomp_alloc_mutex;
/* Config options class */
static ConfigOptions options;
static Config::Options options;
static const Regex::Expression regex_allocation;
/* FreeSWITCH Articular Ligaments */
static switch_endpoint_interface_t * khomp_endpoint_interface;
+55 -11
View File
@@ -221,6 +221,37 @@ struct KhompPvt
return strBuffer;
}
switch_xml_t getDetailedXML()
{
/* very very important yet! */
idle();
std::string str_incoming_time = timeToString(_total_time_incoming);
std::string str_outgoing_time = timeToString(_total_time_outgoing);
std::string str_idle_time = timeToString(_total_idle_time);
/* total */
switch_xml_t xtotal = switch_xml_new("total");
/* total/incoming_time */
switch_xml_t xin_time = switch_xml_add_child_d(xtotal,"incoming_time",0);
switch_xml_set_txt_d(xin_time, str_incoming_time.c_str());
/* total/outgoing_time */
switch_xml_t xout_time = switch_xml_add_child_d(xtotal,"outgoing_time",0);
switch_xml_set_txt_d(xout_time, str_outgoing_time.c_str());
/* total/idle_time */
switch_xml_t xidle_time = switch_xml_add_child_d(xtotal,"idle_time",0);
switch_xml_set_txt_d(xidle_time, str_idle_time.c_str());
/* total/channel_fails */
switch_xml_t xchannel_fails = switch_xml_add_child_d(xtotal,"channel_fails",0);
switch_xml_set_txt_d(xchannel_fails, STR(FMT("%d") % _channel_fails));
return xtotal;
}
void clear()
{
time(&_base_time);
@@ -373,7 +404,7 @@ struct KhompPvt
public:
/* KhompPvt constructor */
KhompPvt(K3LAPI::target & target);
KhompPvt(K3LAPIBase::GenericTarget & target);
/* KhompPvt destructor */
virtual ~KhompPvt()
@@ -388,8 +419,14 @@ public:
_pvt(pvt) {}
std::string getDetailedRates();
switch_xml_t getDetailedRatesXML();
std::string getDetailed();
switch_xml_t getDetailedXML();
std::string getRow();
switch_xml_t getNode();
void clear()
{
@@ -569,6 +606,7 @@ public:
/* statistics functions */
virtual std::string getStatistics(Statistics::Type type);
virtual switch_xml_t getStatisticsXML(Statistics::Type type);
virtual void clearStatistics()
{
_pvt_statistics->clear();
@@ -649,7 +687,7 @@ public:
return pvt_locked;
}
K3LAPI::target & target()
K3LAPIBase::GenericTarget & target()
{
return _target;
}
@@ -996,18 +1034,20 @@ public:
{
DBG(FUNC,PVT_FMT(_target,"c"));
/*
if(!_group_context.empty())
{
contexts.insert(contexts.begin(), _group_context);
//contexts.push_back(_group_context);
}
*/
for (MatchExtension::ContextListType::iterator i = contexts.begin(); i != contexts.end(); i++)
replaceTemplate((*i), "DD", _target.device);
BEGIN_CONTEXT
{
K3L_DEVICE_CONFIG & dev_cfg = Globals::k3lapi.device_config(_target.device);
const K3L_DEVICE_CONFIG & dev_cfg = Globals::k3lapi.device_config(_target);
for (MatchExtension::ContextListType::iterator i = contexts.begin(); i != contexts.end(); i++)
replaceTemplate((*i), "SSSS", atoi(dev_cfg.SerialNumber));
@@ -1048,7 +1088,7 @@ public:
Call * call() { return _call; }
K3LAPI::target _target; /*!< The device/channel pair to bind this pvt to */
K3LAPIBase::GenericTarget _target; /*!< The device/channel pair to bind this pvt to */
ChanLockType _mutex; /*!< Used for *our* internal locking */
Call *_call;
switch_core_session_t *_session; /*!< The session to which this pvt is associated with */
@@ -1066,6 +1106,10 @@ public:
std::string _group_context;
PvtStatistics *_pvt_statistics;
std::string _mohclass;
std::string _language;
std::string _accountcode;
};
/******************************************************************************/
@@ -1115,7 +1159,7 @@ public:
}
catch (...)
{
throw K3LAPI::invalid_channel(_device_id, obj);
throw K3LAPITraits::invalid_channel(_device_id, obj);
}
}
@@ -1141,7 +1185,7 @@ public:
{
ret = channel(obj)->eventHandler(e);
}
catch (K3LAPI::invalid_channel & invalid)
catch (K3LAPITraits::invalid_channel & invalid)
{
LOG(ERROR, OBJ_FMT(_device_id,obj,"(Generic Board) r (invalid channel on event '%s')")
% Verbose::eventName(e->Code).c_str());
@@ -1191,7 +1235,7 @@ public:
\return KhompPvt to be used on the call.
*/
static KhompPvt * find_channel(char* allocation_string, switch_core_session_t * new_session, switch_call_cause_t * cause);
static void khomp_add_event_board_data(const K3LAPI::target target, switch_event_t *event);
static void khomp_add_event_board_data(const K3LAPIBase::GenericTarget target, switch_event_t *event);
static Board * board(int dev)
{
@@ -1208,7 +1252,7 @@ public:
}
catch(...)
{
throw K3LAPI::invalid_device(dev);
throw K3LAPITraits::invalid_device(dev);
}
}
@@ -1223,11 +1267,11 @@ public:
}
catch(...)
{
throw K3LAPI::invalid_channel(device, object);
throw K3LAPITraits::invalid_channel(device, object);
}
}
static KhompPvt * get(K3LAPI::target & target)
static KhompPvt * get(K3LAPIBase::GenericTarget & target)
{
//if (!Globals::k3lapi.valid_channel(target.device, target.object))
// throw K3LAPI::invalid_channel(target.device, target.object);
@@ -1252,7 +1296,7 @@ public:
{
stats = Globals::k3lapi.channel_stats(device, object, index);
}
catch(K3LAPI::invalid_channel & err)
catch(K3LAPITraits::invalid_channel & err)
{
//K::logger::logg(C_WARNING, B(dev,channel, "Command get_stats has failed with error '%s'.") %
// Verbose::status((KLibraryStatus) stt_res));
@@ -114,7 +114,7 @@ struct KhompPvtFXO: public KhompPvt
_call_info_report = false;
_call_info_drop = 0;
_user_xfer_digits = Opt::_user_xfer;
_user_xfer_digits = Opt::_options._user_xfer_digits();
_user_xfer_buffer.clear();
_digits_buffer.clear();
@@ -141,7 +141,7 @@ struct KhompPvtFXO: public KhompPvt
//ChanTimer::Index _idx_disconnect;
};
/******************************************************************************/
KhompPvtFXO(K3LAPI::target & target) : KhompPvt(target)
KhompPvtFXO(K3LAPIBase::GenericTarget & target) : KhompPvt(target)
{
_fax = new Fax(this);
_transfer = new Transfer<CallFXO>(this);
@@ -323,7 +323,7 @@ struct KhompPvtFXO: public KhompPvt
for (unsigned obj = 0; obj < Globals::k3lapi.channel_count(_device_id); obj++)
{
K3LAPI::target tgt(Globals::k3lapi, K3LAPI::target::CHANNEL, _device_id, obj);
K3LAPIBase::GenericTarget tgt(Globals::k3lapi, K3LAPIBase::GenericTarget::CHANNEL, _device_id, obj);
KhompPvt * pvt;
switch(Globals::k3lapi.channel_config(_device_id, obj).Signaling)
@@ -115,7 +115,7 @@ struct KhompPvtGSM: public KhompPvt
};
/******************************************************************************/
KhompPvtGSM(K3LAPI::target & target) : KhompPvt(target)
KhompPvtGSM(K3LAPIBase::GenericTarget & target) : KhompPvt(target)
{
_sms = new SMS(this);
command(KHOMP_LOG, CM_ENABLE_CALL_ANSWER_INFO);
@@ -278,7 +278,7 @@ struct KhompPvtGSM: public KhompPvt
for (unsigned obj = 0; obj < Globals::k3lapi.channel_count(_device_id); obj++)
{
K3LAPI::target tgt(Globals::k3lapi, K3LAPI::target::CHANNEL, _device_id, obj);
K3LAPIBase::GenericTarget tgt(Globals::k3lapi, K3LAPIBase::GenericTarget::CHANNEL, _device_id, obj);
KhompPvt * pvt;
switch(Globals::k3lapi.channel_config(_device_id, obj).Signaling)
@@ -122,7 +122,7 @@ struct KhompPvtE1: public KhompPvt
};
/******************************************************************************/
KhompPvtE1(K3LAPI::target & target) : KhompPvt(target)
KhompPvtE1(K3LAPIBase::GenericTarget & target) : KhompPvt(target)
{
_fax = new Fax(this);
command(KHOMP_LOG,CM_ENABLE_CALL_ANSWER_INFO);
@@ -219,7 +219,7 @@ struct KhompPvtE1: public KhompPvt
{
Board::board(_target.device)->_timers.del(callE1()->_idx_disconnect);
}
catch (K3LAPI::invalid_device & err)
catch (K3LAPITraits::invalid_device & err)
{
LOG(ERROR, PVT_FMT(target(), "Unable to get device: %d!") % err.device);
}
@@ -310,7 +310,7 @@ struct KhompPvtISDN: public KhompPvtE1
_uui_information.clear();
_isdn_cause = -1;
_user_xfer_digits = Opt::_user_xfer;
_user_xfer_digits = Opt::_options._user_xfer_digits();
_user_xfer_buffer.clear();
_digits_buffer.clear();
_qsig_number.clear();
@@ -332,7 +332,7 @@ struct KhompPvtISDN: public KhompPvtE1
};
/******************************************************************************/
KhompPvtISDN(K3LAPI::target & target) : KhompPvtE1(target)
KhompPvtISDN(K3LAPIBase::GenericTarget & target) : KhompPvtE1(target)
{
_transfer = new Transfer<CallISDN, false>(this);
}
@@ -496,7 +496,7 @@ struct KhompPvtR2: public KhompPvtE1
std::string _incoming_exten;
};
/******************************************************************************/
KhompPvtR2(K3LAPI::target & target) : KhompPvtE1(target)
KhompPvtR2(K3LAPIBase::GenericTarget & target) : KhompPvtE1(target)
{
K3L_E1600A_FW_CONFIG dspAcfg;
@@ -672,7 +672,7 @@ struct KhompPvtFlash: public KhompPvtR2
bool clear()
{
_user_xfer_digits = Opt::_user_xfer;
_user_xfer_digits = Opt::_options._user_xfer_digits();
_user_xfer_buffer.clear();
_digits_buffer.clear();
@@ -686,7 +686,7 @@ struct KhompPvtFlash: public KhompPvtR2
};
/******************************************************************************/
KhompPvtFlash(K3LAPI::target & target) : KhompPvtR2(target)
KhompPvtFlash(K3LAPIBase::GenericTarget & target) : KhompPvtR2(target)
{
_transfer = new Transfer<CallFlash>(this);
}
@@ -796,7 +796,7 @@ struct KhompPvtFXS: public KhompPvt
}
else if (name == "ring_cadence")
{
Opt::CadencesMapType::iterator i = Opt::_cadences.find(value);
CadencesMapType::iterator i = Opt::_cadences.find(value);
if (i != Opt::_cadences.end())
{
@@ -858,11 +858,11 @@ struct KhompPvtFXS: public KhompPvt
};
/******************************************************************************/
KhompPvtFXS(K3LAPI::target & target) : KhompPvt(target)
KhompPvtFXS(K3LAPIBase::GenericTarget & target) : KhompPvt(target)
{
//command(KHOMP_LOG,CM_ENABLE_CALL_ANSWER_INFO);
/* sequence numbers on FXS */
static Opt::OrigToNseqMapType fxs_nseq = generateNseqMap();
static OrigToNseqMapType fxs_nseq = generateNseqMap();
load(fxs_nseq);
}
@@ -926,7 +926,7 @@ struct KhompPvtFXS: public KhompPvt
}
bool setupConnection();
void load(Opt::OrigToNseqMapType & fxs_nseq);
void load(OrigToNseqMapType & fxs_nseq);
void loadOptions();
bool parseBranchOptions(std::string options_str);
bool alloc();
@@ -991,13 +991,10 @@ struct KhompPvtFXS: public KhompPvt
std::string _context;
int _input_volume;
int _output_volume;
std::string _mohclass;
std::string _language;
std::string _accountcode;
std::string _mailbox;
std::string _flash;
static Opt::OrigToNseqMapType generateNseqMap();
static OrigToNseqMapType generateNseqMap();
static void dialTimer(KhompPvt * pvt);
static void transferTimer(KhompPvt * pvt);
@@ -1044,7 +1041,7 @@ struct KhompPvtFXS: public KhompPvt
for (unsigned obj = 0; obj < Globals::k3lapi.channel_count(_device_id); obj++)
{
K3LAPI::target tgt(Globals::k3lapi, K3LAPI::target::CHANNEL, _device_id, obj);
K3LAPIBase::GenericTarget tgt(Globals::k3lapi, K3LAPIBase::GenericTarget::CHANNEL, _device_id, obj);
KhompPvt * pvt;
switch(Globals::k3lapi.channel_config(_device_id, obj).Signaling)
@@ -81,7 +81,7 @@ struct KhompPvtPassive: public KhompPvt
};
*/
/******************************************************************************/
KhompPvtPassive(K3LAPI::target & target) : KhompPvt(target)
KhompPvtPassive(K3LAPIBase::GenericTarget & target) : KhompPvt(target)
{
}
@@ -150,7 +150,7 @@ struct KhompPvtPassive: public KhompPvt
/********************************** HI Channel ********************************/
struct KhompPvtHI: public KhompPvtPassive
{
KhompPvtHI(K3LAPI::target & target) : KhompPvtPassive(target)
KhompPvtHI(K3LAPIBase::GenericTarget & target) : KhompPvtPassive(target)
{
}
@@ -189,7 +189,7 @@ struct KhompPvtHI: public KhompPvtPassive
/********************************* KPR Channel ********************************/
struct KhompPvtKPR: public KhompPvtPassive
{
KhompPvtKPR(K3LAPI::target & target) : KhompPvtPassive(target)
KhompPvtKPR(K3LAPIBase::GenericTarget & target) : KhompPvtPassive(target)
{
}
@@ -243,7 +243,7 @@ struct KhompPvtKPR: public KhompPvtPassive
for (unsigned obj = 0; obj < Globals::k3lapi.channel_count(_device_id); obj++)
{
K3LAPI::target tgt(Globals::k3lapi, K3LAPI::target::CHANNEL, _device_id, obj);
K3LAPIBase::GenericTarget tgt(Globals::k3lapi, K3LAPIBase::GenericTarget::CHANNEL, _device_id, obj);
KhompPvt * pvt;
switch(Globals::k3lapi.channel_config(_device_id, obj).Signaling)
+164 -152
View File
@@ -47,9 +47,32 @@
#include <string>
#include <map>
#include <vector>
#include <config_options.hpp>
#include "switch.h"
#include "utils.h"
typedef std::map < std::string, std::string > OrigToDestMapType;
typedef std::pair < std::string, std::string > OrigToDestPairType;
typedef std::vector < std::string > DestVectorType;
typedef std::map < unsigned int, std::string > BoardToOrigMapType;
typedef std::pair < unsigned int, std::string > BoardToOrigPairType;
typedef std::map < std::string, unsigned int > OrigToNseqMapType;
typedef std::pair < std::string, unsigned int > OrigToNseqPairType;
typedef std::pair < unsigned int,unsigned int > ObjectIdType;
typedef std::pair < std::string, ObjectIdType > BranchToObjectPairType;
typedef std::map < std::string, ObjectIdType > BranchToObjectMapType;
typedef std::map < std::string, std::string > BranchToOptMapType;
typedef std::pair < std::string, std::string > BranchToOptPairType;
typedef std::map < std::string, std::string > GroupToDestMapType;
typedef std::pair < std::string, std::string > GroupToDestPairType;
struct CadenceType
{
CadenceType(void)
@@ -67,182 +90,171 @@ struct CadenceType
unsigned int ring_ext_s;
};
struct CSpan {
std::string _dialplan;
std::string _context;
std::string _dialstring;
typedef std::pair < std::string, CadenceType > CadencesPairType;
typedef std::map < std::string, CadenceType > CadencesMapType;
struct Options
{
Config::Value< bool > _debug;
Config::Value< std::string > _dialplan;
Config::Value< std::string > _context;
Config::Value< bool > _echo_canceller;
Config::Value< bool > _auto_gain_control;
Config::Value< bool > _out_of_band_dtmfs;
Config::Value< bool > _suppression_delay;
Config::Value< bool > _pulse_forwarding;
Config::Value< bool > _native_bridge;
Config::Value< bool > _recording;
Config::Value< bool > _has_ctbus;
Config::Value< bool > _fxs_bina;
Config::Value< bool > _fxo_send_pre_audio;
Config::Value< bool > _drop_collect_call;
Config::Value< bool > _ignore_letter_dtmfs;
Config::Value< bool > _optimize_audio_path;
Config::Value< bool > _auto_fax_adjustment;
Config::Value< unsigned int > _fax_adjustment_timeout;
Config::Value< bool > _r2_strict_behaviour;
Config::Value< unsigned int > _r2_preconnect_wait;
Config::Value< unsigned int > _fxs_digit_timeout;
Config::Value< unsigned int > _transferdigittimeout;
Config::Value< std::string > _flash;
Config::Value< std::string > _blindxfer;
Config::Value< std::string > _atxfer;
Config::Value< unsigned int > _ringback_co_delay;
Config::Value< unsigned int > _ringback_pbx_delay;
Config::Value< unsigned int > _disconnect_delay;
Config::Value< int > _input_volume;
Config::Value< int > _output_volume;
struct CentralOfficeDialtone : public Config::FunctionValue
{
void operator ()(const Config::StringType &);
const DestVectorType & operator()(void) const { return _value; };
void clear(void)
{
_value.clear();
}
protected:
DestVectorType _value;
} _fxs_co_dialtone;
struct LogDiskOption : public Config::FunctionValue
{
void operator ()(const Config::StringType &);
} _log_disk_option;
/*
struct CallGroupOption: public Config::FunctionValue
{
void operator ()(const Config::StringType &);
const std::string operator()(void) const { return _groups; };
protected:
std::string _groups;
} _callgroup;
struct PickupGroupOption: public Config::FunctionValue
{
void operator ()(const Config::StringType &);
const std::string operator()(void) const { return _groups; };
protected:
std::string _groups;
} _pickupgroup; // or intercept
*/
struct LogConsoleOption : public Config::FunctionValue
{
void operator ()(const Config::StringType &);
} _log_console_option;
struct LogTraceOption : public Config::FunctionValue
{
void operator ()(const Config::StringType &);
} _log_trace_option;
struct RecordPrefixOption: public Config::FunctionValue
{
void operator ()(const Config::StringType &);
const std::string & operator()(void) const { return _value; };
protected:
std::string _value;
} _record_prefix;
Config::Value< std::string > _user_xfer_digits;
Config::Value< std::string > _fxs_global_orig_base;
Config::Value< std::string > _global_mohclass;
Config::Value< std::string > _global_language;
Config::Value< std::string > _context_gsm_call;
Config::Value< std::string > _context2_gsm_call;
Config::Value< std::string > _context_gsm_sms;
Config::Value< std::string > _context_fxo;
Config::Value< std::string > _context2_fxo;
Config::Value< std::string > _context_fxs;
Config::Value< std::string > _context2_fxs;
Config::Value< std::string > _context_digital;
Config::Value< std::string > _context_pr;
Config::Value< std::string > _callgroup;
Config::Value< std::string > _pickupgroup; /* or intercept */
Config::Value< std::string > _accountcode;
Config::Value< unsigned int > _kommuter_timeout;
Config::Value< std::string > _kommuter_activation;
Config::Value< unsigned int > _audio_packet_size;
};
struct Opt
{
typedef std::pair < std::string, CadenceType > CadencesPairType;
typedef std::map < std::string, CadenceType > CadencesMapType;
/* here we load [cadences] */
static CadencesMapType _cadences;
typedef std::map < std::string, std::string > OrigToDestMapType;
typedef std::pair < std::string, std::string > OrigToDestPairType;
typedef std::vector < std::string > DestVectorType;
/* here we load [groups] */
static GroupToDestMapType _groups;
typedef std::map < unsigned int, std::string > BoardToOrigMapType;
typedef std::pair < unsigned int, std::string > BoardToOrigPairType;
/* here we load [fxs-hotlines] */
static OrigToDestMapType _fxs_hotline;
typedef std::map < std::string, unsigned int > OrigToNseqMapType;
typedef std::pair < std::string, unsigned int > OrigToNseqPairType;
/* here we load [fxs-branches] */
static BoardToOrigMapType _fxs_orig_base;
typedef std::pair < unsigned int,unsigned int > ObjectIdType;
typedef std::pair < std::string, ObjectIdType > BranchToObjectPairType;
typedef std::map < std::string, ObjectIdType > BranchToObjectMapType;
/* here we load [fxs-options] */
static BranchToOptMapType _branch_options;
typedef std::map < std::string, std::string > BranchToOptMapType;
typedef std::pair < std::string, std::string > BranchToOptPairType;
typedef std::map < std::string, std::string > GroupToDestMapType;
typedef std::pair < std::string, std::string > GroupToDestPairType;
/* here we load ... hannnn */
static BranchToObjectMapType _fxs_branch_map;
typedef std::pair < std::string, CSpan > SpanPairType;
typedef enum
{
GFLAG_MY_CODEC_PREFS = (1 << 0)
}
GFLAGS;
static Options _options;
/* Member functions */
static void initialize(void);
static void obtain(void);
static void commit(void);
static void printConfiguration(switch_stream_handle_t*);
protected:
//TODO: reload options at reloadxml ?
static void reload(void);
protected:
static void loadConfiguration(const char *, const char **, bool show_errors = true);
static void cleanConfiguration(void);
static switch_xml_t processSimpleXML(switch_xml_t &xml, const std::string& child_name);
static void processGroupXML(switch_xml_t &xml);
static void processCadenceXML(switch_xml_t &xml);
static void processFXSBranchesXML(switch_xml_t &xml);
static void processFXSHotlines(switch_xml_t &xml);
static void processFXSOptions(switch_xml_t &xml);
public:
static bool _debug;
static std::string _dialplan;
static std::string _context;
static std::map < std::string, CSpan > _spans;
static GroupToDestMapType _groups;
static CadencesMapType _cadences;
static bool _echo_canceller;
static bool _auto_gain_control;
static bool _out_of_band_dtmfs;
static bool _suppression_delay;
static bool _pulse_forwarding;
static bool _native_bridge;
static bool _recording;
static bool _has_ctbus;
static bool _fxs_bina;
static bool _fxo_send_pre_audio;
static bool _drop_collect_call;
static bool _ignore_letter_dtmfs;
static bool _optimize_audio_path;
static bool _auto_fax_adjustment;
static unsigned int _fax_adjustment_timeout;
static bool _r2_strict_behaviour;
static unsigned int _r2_preconnect_wait;
static unsigned int _fxs_digit_timeout;
static unsigned int _transferdigittimeout;
static std::string _flash;
static std::string _blindxfer;
static std::string _atxfer;
static unsigned int _ringback_co_delay;
static unsigned int _ringback_pbx_delay;
static unsigned int _disconnect_delay;
static int _input_volume;
static int _output_volume;
static DestVectorType _fxs_co_dialtone;
static OrigToDestMapType _fxs_hotline;
static std::string _fxs_global_orig_base;
static BoardToOrigMapType _fxs_orig_base;
static BranchToObjectMapType _fxs_branch_map;
static BranchToOptMapType _branch_options;
static std::string _global_mohclass;
static std::string _global_language;
static std::string _record_prefix;
static std::string _context_gsm_call;
static std::string _context2_gsm_call;
static std::string _context_gsm_sms;
static std::string _context_fxo;
static std::string _context2_fxo;
static std::string _context_fxs;
static std::string _context2_fxs;
static std::string _context_digital;
static std::string _context_pr;
static std::string _user_xfer;
static int _amaflags;
static std::string _callgroup;
static std::string _pickupgroup; /* or intercept */
static std::string _accountcode;
static unsigned int _kommuter_timeout;
static std::string _kommuter_activation;
static unsigned int _audio_packet_size;
protected:
struct ProcessFXSCODialtone
{
void operator()(std::string options);
};
struct ProcessRecordPrefix
{
void operator()(std::string path);
};
struct ProcessAMAFlags
{
void operator()(std::string options);
};
struct ProcessCallGroup
{
void operator()(std::string options);
};
struct ProcessPickupGroup
{
void operator()(std::string options);
};
struct ProcessLogOptions
{
ProcessLogOptions(output_type output): _output(output) {};
void operator()(std::string options);
protected:
output_type _output;
};
struct ProcessTraceOptions
{
void operator()(std::string options);
};
};
@@ -1 +1 @@
#define MOD_KHOMP_VERSION "1.0 - (rev: 5841)"
#define MOD_KHOMP_VERSION "1.0 - (rev: 5891)"
@@ -63,15 +63,8 @@ typedef enum
SpecFlagType;
typedef unsigned int SpecFlagsType;
typedef Function::Function3 < bool, unsigned int, unsigned int, SpecFlagsType & > SpecFunType;
//SpecRetType processSpecAtom(std::string &, SpecFlagsType &, SpecFunType &);
//SpecRetType processSpecAtoms(std::string &, SpecFlagsType &, SpecFunType &);
//bool processCallChannelString(std::string &, Board::KhompPvt *&, int *, bool need_free = true);
/* Request a Board::KhompPvt based on dialplan string.
-- Format of dialplan string. --
@@ -687,7 +687,97 @@ struct Statistics
virtual std::string getDetailed() { return ""; }
virtual void clear() {}
};
/******************************************************************************/
/****************************** ESL - Events **********************************/
struct ESL
{
typedef std::vector <std::string> VectorEvents;
ESL(std::string type);
~ESL();
switch_event_t * create(const std::string type)
{
switch_event_t *event;
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, type.c_str()) != SWITCH_STATUS_SUCCESS)
{
return NULL;
}
return event;
}
switch_event_t * create()
{
return create(_type);
}
bool add(switch_event_t *event, const std::string key,
const std::string value) const
{
if(!event) return false;
switch_status_t res = switch_event_add_header_string(event,
SWITCH_STACK_BOTTOM,
key.c_str(),
value.c_str());
return (res == SWITCH_STATUS_SUCCESS ? true : false);
}
bool add(switch_event_t *event, K3LAPIBase::GenericTarget & target)
{
bool ok = add(event, "Device", STR(FMT("%d") % target.device));
if(!ok)
return ok;
std::string type;
switch(target.type)
{
case K3LAPIBase::GenericTarget::CHANNEL:
type = "Channel";
break;
case K3LAPIBase::GenericTarget::MIXER:
type = "Mixer";
break;
case K3LAPIBase::GenericTarget::LINK:
type = "Link";
break;
default:
type = "Other";
break;
}
return add(event, type, STR(FMT("%d") % target.object));
}
bool fire(switch_event_t **event) const
{
if(!event || !*event) return false;
switch_status_t res = switch_event_fire(event);
*event = NULL;
return (res == SWITCH_STATUS_SUCCESS ? true : false);
}
static bool registerEvents();
static bool unregisterEvents();
protected:
const std::string _type;
static VectorEvents * _events;
};
/******************************************************************************/
/******************************************************************************/
#endif /* _UTILS_H_ */