Merge branch 'master' of git.freeswitch.org:freeswitch

This commit is contained in:
Anthony Minessale 2010-04-08 11:51:37 -05:00
commit e39e3842b0
14 changed files with 476 additions and 251 deletions

View File

@ -36,6 +36,27 @@ Call::Call()
_answeredEpoch = 0; _answeredEpoch = 0;
} }
switch_status_t Call::toggleHold(bool holdPressed)
{
if (_state != FSCOMM_CALL_STATE_ANSWERED) return SWITCH_STATUS_FALSE;
switch_stream_handle_t stream = { 0 };
SWITCH_STANDARD_STREAM(stream);
QString holdStr;
if (holdPressed)
{
holdStr = _channel.data()->getUuid();
}
else
{
holdStr = "off " + _channel.data()->getUuid();
}
switch_status_t st = switch_api_execute("uuid_hold", holdStr.toAscii().data(), NULL, &stream);
switch_safe_free(stream.data);
return st;
}
switch_status_t Call::toggleRecord(bool startRecord) switch_status_t Call::toggleRecord(bool startRecord)
{ {
QDir conf_dir = QDir::home(); QDir conf_dir = QDir::home();
@ -82,8 +103,7 @@ QTime Call::getCurrentStateTime()
{ {
if (_direction == FSCOMM_CALL_DIRECTION_INBOUND) if (_direction == FSCOMM_CALL_DIRECTION_INBOUND)
{ {
/* TODO: DOESNT WORK - How do I get what time it started to ring? */ time = _channel.data()->getCreatedEpoch();
_channel.data()->getProgressEpoch() == 0 ? time = _channel.data()->getProgressMediaEpoch() : time = _channel.data()->getProgressEpoch();
} }
else else
_otherLegChannel.data()->getProgressEpoch() == 0 ? time = _otherLegChannel.data()->getProgressMediaEpoch() : time = _otherLegChannel.data()->getProgressEpoch(); _otherLegChannel.data()->getProgressEpoch() == 0 ? time = _otherLegChannel.data()->getProgressMediaEpoch() : time = _otherLegChannel.data()->getProgressEpoch();

View File

@ -50,8 +50,8 @@ class Call {
public: public:
Call(); Call();
/* Needs rework */ /* Needs rework */
QString getCidName(void) { return _channel.data()->getCidName(); } QString getCidName(void) { return (_direction == FSCOMM_CALL_DIRECTION_INBOUND) ? _otherLegChannel.data()->getCidName() : _channel.data()->getCidName(); }
QString getCidNumber(void) { return _channel.data()->getCidNumber(); } QString getCidNumber(void) { return (_direction == FSCOMM_CALL_DIRECTION_INBOUND) ? _otherLegChannel.data()->getCidNumber() : _channel.data()->getCidNumber(); }
QString getDestinationNumber(void) { return _otherLegChannel.data()->getDestinationNumber(); } QString getDestinationNumber(void) { return _otherLegChannel.data()->getDestinationNumber(); }
void setChannel(QSharedPointer<Channel> channel) { _channel = channel; } void setChannel(QSharedPointer<Channel> channel) { _channel = channel; }
@ -66,11 +66,12 @@ public:
fscomm_call_direction_t getDirection() { return _direction; } fscomm_call_direction_t getDirection() { return _direction; }
fscomm_call_state_t getState() { return _state; } fscomm_call_state_t getState() { return _state; }
void setState(fscomm_call_state_t state) { _state = state; } void setState(fscomm_call_state_t state) { _state = state; }
void setCause(QString cause) { _cause = cause; } void setCause(QString cause) { _cause = cause; qDebug()<<cause; }
QString getCause() { return _cause; } QString getCause() { return _cause; qDebug() << _cause; }
void setActive(bool isActive) { _isActive = isActive; } void setActive(bool isActive) { _isActive = isActive; }
bool isActive() { return _isActive == true; } bool isActive() { return _isActive == true; }
switch_status_t toggleRecord(bool); switch_status_t toggleRecord(bool);
switch_status_t toggleHold(bool);
void sendDTMF(QString digit); void sendDTMF(QString digit);
void setAnsweredEpoch(qulonglong time) { _answeredEpoch = time/1000000; } void setAnsweredEpoch(qulonglong time) { _answeredEpoch = time/1000000; }
QTime getCurrentStateTime(); QTime getCurrentStateTime();

View File

@ -5,4 +5,5 @@ Channel::Channel(QString uuid):
{ {
_progressEpoch = 0; _progressEpoch = 0;
_progressMediaEpoch = 0; _progressMediaEpoch = 0;
_createdEpoch = 0;
} }

View File

@ -23,6 +23,8 @@ public:
qulonglong getProgressEpoch() { return _progressEpoch; } qulonglong getProgressEpoch() { return _progressEpoch; }
void setProgressMediaEpoch(qulonglong time) { _progressMediaEpoch = time/1000000; } void setProgressMediaEpoch(qulonglong time) { _progressMediaEpoch = time/1000000; }
qulonglong getProgressMediaEpoch() { return _progressMediaEpoch; } qulonglong getProgressMediaEpoch() { return _progressMediaEpoch; }
void setCreatedEpoch(qulonglong time) { _createdEpoch = time/1000000; }
qulonglong getCreatedEpoch() { return _createdEpoch; }
private: private:
QString _uuid; QString _uuid;
@ -32,6 +34,7 @@ private:
int _paCallId; int _paCallId;
qulonglong _progressEpoch; qulonglong _progressEpoch;
qulonglong _progressMediaEpoch; qulonglong _progressMediaEpoch;
qulonglong _createdEpoch;
}; };
Q_DECLARE_METATYPE(Channel) Q_DECLARE_METATYPE(Channel)

View File

@ -66,6 +66,7 @@ void StateDebugDialog::currentEventsChanged()
{ {
ui->listDetails->clear(); ui->listDetails->clear();
int r = ui->listEvents->currentRow(); int r = ui->listEvents->currentRow();
if (r == -1) return;
QString uuid = ui->listUUID->currentItem()->text(); QString uuid = ui->listUUID->currentItem()->text();
QList<QSharedPointer<switch_event_t> > tmpListEvents = _events.value(uuid); QList<QSharedPointer<switch_event_t> > tmpListEvents = _events.value(uuid);
QSharedPointer<switch_event_t> e = tmpListEvents.at(r); QSharedPointer<switch_event_t> e = tmpListEvents.at(r);

View File

@ -394,13 +394,13 @@ void FSHost::eventChannelOutgoing(QSharedPointer<switch_event_t>event, QString u
else else
{ {
Call *callPtr = new Call(); Call *callPtr = new Call();
callPtr->setCallDirection(FSCOMM_CALL_DIRECTION_INBOUND); callPtr->setCallDirection(FSCOMM_CALL_DIRECTION_INBOUND);
callPtr->setChannel(_channels.value(switch_event_get_header_nil(event.data(), "Other-Leg-Unique-ID"))); callPtr->setChannel(_channels.value(uuid));
callPtr->setOtherLegChannel(_channels.value(uuid)); callPtr->setOtherLegChannel(_channels.value(switch_event_get_header_nil(event.data(), "Other-Leg-Unique-ID")));
QSharedPointer<Call> call(callPtr); QSharedPointer<Call> call(callPtr);
_active_calls.insert(switch_event_get_header_nil(event.data(), "Other-Leg-Unique-ID"), call); _active_calls.insert(uuid, call);
call.data()->setState(FSCOMM_CALL_STATE_RINGING); call.data()->setState(FSCOMM_CALL_STATE_RINGING);
_channels.value(uuid).data()->setCreatedEpoch(QString(switch_event_get_header_nil(event.data(), "Caller-Channel-Created-Time")).toULongLong());
emit ringing(call); emit ringing(call);
} }
} }
@ -426,16 +426,23 @@ void FSHost::eventChannelBridge(QSharedPointer<switch_event_t>event, QString uui
if (time.toULongLong() > 0) _channels.value(uuid).data()->setProgressMediaEpoch(time.toULongLong()); if (time.toULongLong() > 0) _channels.value(uuid).data()->setProgressMediaEpoch(time.toULongLong());
} }
void FSHost::eventChannelHangup(QSharedPointer<switch_event_t>event, QString uuid) void FSHost::eventChannelHangup(QSharedPointer<switch_event_t>event, QString uuid)
{ {}
if (_active_calls.contains(uuid))
{
emit hungup(_active_calls.take(uuid));
}
}
void FSHost::eventChannelUnbridge(QSharedPointer<switch_event_t>event, QString uuid) void FSHost::eventChannelUnbridge(QSharedPointer<switch_event_t>event, QString uuid)
{} {}
void FSHost::eventChannelHangupComplete(QSharedPointer<switch_event_t>event, QString uuid) void FSHost::eventChannelHangupComplete(QSharedPointer<switch_event_t>event, QString uuid)
{} {
if (_active_calls.contains(uuid))
{
if (_active_calls.value(uuid).data()->getState() != FSCOMM_CALL_STATE_ANSWERED)
{
_active_calls.value(uuid).data()->setState(FSCOMM_CALL_STATE_FAILED);
_active_calls.value(uuid).data()->setCause(switch_event_get_header_nil(event.data(), "variable_originate_disposition"));
emit callFailed(_active_calls.value(uuid));
return;
}
emit hungup(_active_calls.take(uuid));
}
}
void FSHost::eventChannelDestroy(QSharedPointer<switch_event_t>event, QString uuid) void FSHost::eventChannelDestroy(QSharedPointer<switch_event_t>event, QString uuid)
{ {
_channels.take(uuid); _channels.take(uuid);

View File

@ -100,6 +100,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(ui->answerBtn, SIGNAL(clicked()), this, SLOT(paAnswer())); connect(ui->answerBtn, SIGNAL(clicked()), this, SLOT(paAnswer()));
connect(ui->hangupBtn, SIGNAL(clicked()), this, SLOT(paHangup())); connect(ui->hangupBtn, SIGNAL(clicked()), this, SLOT(paHangup()));
connect(ui->recoredCallBtn, SIGNAL(toggled(bool)), SLOT(recordCall(bool))); connect(ui->recoredCallBtn, SIGNAL(toggled(bool)), SLOT(recordCall(bool)));
connect(ui->btnHold, SIGNAL(toggled(bool)), this, SLOT(holdCall(bool)));
connect(ui->tableCalls, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(callTableDoubleClick(QTableWidgetItem*))); connect(ui->tableCalls, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(callTableDoubleClick(QTableWidgetItem*)));
connect(ui->action_Preferences, SIGNAL(triggered()), this, SLOT(prefTriggered())); connect(ui->action_Preferences, SIGNAL(triggered()), this, SLOT(prefTriggered()));
connect(ui->action_Exit, SIGNAL(triggered()), this, SLOT(close())); connect(ui->action_Exit, SIGNAL(triggered()), this, SLOT(close()));
@ -363,16 +364,35 @@ void MainWindow::paHangup()
ui->hangupBtn->setEnabled(false); ui->hangupBtn->setEnabled(false);
} }
void MainWindow::holdCall(bool pressed)
{
QSharedPointer<Call> call = g_FSHost.getCurrentActiveCall();
if (call.isNull())
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not hold call because there is not current active call!.\n");
return;
}
if (call.data()->toggleHold(pressed) != SWITCH_STATUS_SUCCESS)
{
QMessageBox::warning(this,tr("Hold call"),
tr("<p>Could not get active call to hold/unhold."
"<p>Please report this bug."),
QMessageBox::Ok);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not hold/unhold call [%s].\n", call.data()->getUuid().toAscii().data());
return;
}
}
void MainWindow::recordCall(bool pressed) void MainWindow::recordCall(bool pressed)
{ {
QSharedPointer<Call> call = g_FSHost.getCurrentActiveCall(); QSharedPointer<Call> call = g_FSHost.getCurrentActiveCall();
if (call.isNull()) if (call.isNull())
{ {
QMessageBox::warning(this,tr("Record call"),
tr("<p>FSComm reports that there are no active calls to be recorded."
"<p>Please report this bug."),
QMessageBox::Ok);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not record call because there is not current active call!.\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not record call because there is not current active call!.\n");
return; return;
} }
@ -472,6 +492,9 @@ void MainWindow::answered(QSharedPointer<Call> call)
} }
ui->recoredCallBtn->setEnabled(true); ui->recoredCallBtn->setEnabled(true);
ui->recoredCallBtn->setChecked(false); ui->recoredCallBtn->setChecked(false);
ui->btnHold->setEnabled(true);
ui->btnHold->setChecked(false);
ui->btnTransfer->setEnabled(true);
ui->dtmf0Btn->setEnabled(true); ui->dtmf0Btn->setEnabled(true);
ui->dtmf1Btn->setEnabled(true); ui->dtmf1Btn->setEnabled(true);
ui->dtmf2Btn->setEnabled(true); ui->dtmf2Btn->setEnabled(true);
@ -504,13 +527,26 @@ void MainWindow::callFailed(QSharedPointer<Call> call)
break; break;
} }
} }
ui->textEdit->setText(tr("Call with %1 (%2) failed with reason %3.").arg(call.data()->getCidName(), if (call.data()->getDirection() == FSCOMM_CALL_DIRECTION_INBOUND)
{
ui->textEdit->setText(tr("Call from %1 (%2) failed with reason %3.").arg(call.data()->getCidName(),
call.data()->getCidNumber(), call.data()->getCidNumber(),
call.data()->getCause())); call.data()->getCause()));
}
else
{
ui->textEdit->setText(tr("Call to %1 failed with reason %3.").arg(call.data()->getCidName(),
call.data()->getCidNumber(),
call.data()->getCause()));
}
call.data()->setActive(false); call.data()->setActive(false);
/* TODO: Will cause problems if 2 calls are received at the same time */ /* TODO: Will cause problems if 2 calls are received at the same time */
ui->recoredCallBtn->setEnabled(false); ui->recoredCallBtn->setEnabled(false);
ui->recoredCallBtn->setChecked(false); ui->recoredCallBtn->setChecked(false);
ui->btnHold->setEnabled(false);
ui->btnHold->setChecked(false);
ui->btnTransfer->setEnabled(false);
ui->answerBtn->setEnabled(false); ui->answerBtn->setEnabled(false);
ui->hangupBtn->setEnabled(false); ui->hangupBtn->setEnabled(false);
ui->dtmf0Btn->setEnabled(false); ui->dtmf0Btn->setEnabled(false);
@ -558,6 +594,9 @@ void MainWindow::hungup(QSharedPointer<Call> call)
/* TODO: Will cause problems if 2 calls are received at the same time */ /* TODO: Will cause problems if 2 calls are received at the same time */
ui->recoredCallBtn->setEnabled(false); ui->recoredCallBtn->setEnabled(false);
ui->recoredCallBtn->setChecked(false); ui->recoredCallBtn->setChecked(false);
ui->btnHold->setEnabled(false);
ui->btnHold->setChecked(false);
ui->btnTransfer->setEnabled(false);
ui->answerBtn->setEnabled(false); ui->answerBtn->setEnabled(false);
ui->hangupBtn->setEnabled(false); ui->hangupBtn->setEnabled(false);
ui->dtmf0Btn->setEnabled(false); ui->dtmf0Btn->setEnabled(false);

View File

@ -76,6 +76,7 @@ private slots:
void hungup(QSharedPointer<Call>); void hungup(QSharedPointer<Call>);
void callFailed(QSharedPointer<Call>); void callFailed(QSharedPointer<Call>);
void recordCall(bool); void recordCall(bool);
void holdCall(bool);
void setDefaultAccount(); void setDefaultAccount();
void accountAdd(QSharedPointer<Account>); void accountAdd(QSharedPointer<Account>);
void accountDel(QSharedPointer<Account>); void accountDel(QSharedPointer<Account>);

View File

@ -14,7 +14,9 @@
<string>FSComm - A FreeSWITCH Communicator</string> <string>FSComm - A FreeSWITCH Communicator</string>
</property> </property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
@ -40,12 +42,12 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="recoredCallBtn"> <widget class="QPushButton" name="btnHold">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Record</string> <string>Hold</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
@ -247,6 +249,32 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="btnTransfer">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Transfer</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="recoredCallBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Record</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>

View File

@ -60,6 +60,9 @@ static time_t congestion_timeouts[MAX_TRUNK_GROUPS];
static ftdm_sangoma_boost_trunkgroup_t *g_trunkgroups[MAX_TRUNK_GROUPS]; static ftdm_sangoma_boost_trunkgroup_t *g_trunkgroups[MAX_TRUNK_GROUPS];
static ftdm_io_interface_t ftdm_sangoma_boost_interface;
static ftdm_status_t ftdm_sangoma_boost_list_sigmods(ftdm_stream_handle_t *stream);
#define BOOST_QUEUE_SIZE 500 #define BOOST_QUEUE_SIZE 500
/* get freetdm span and chan depending on the span mode */ /* get freetdm span and chan depending on the span mode */
@ -1762,6 +1765,81 @@ end:
return NULL; return NULL;
} }
#define FTDM_BOOST_SYNTAX "list sigmods | <sigmod_name> <command>"
/**
* \brief API function to kill or debug a sangoma_boost span
* \param stream API stream handler
* \param data String containing argurments
* \return Flags
*/
static FIO_API_FUNCTION(ftdm_sangoma_boost_api)
{
char *mycmd = NULL, *argv[10] = { 0 };
int argc = 0;
if (data) {
mycmd = ftdm_strdup(data);
argc = ftdm_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (argc > 1) {
if (!strcasecmp(argv[0], "list")) {
if (!strcasecmp(argv[1], "sigmods")) {
if (ftdm_sangoma_boost_list_sigmods(stream) != FTDM_SUCCESS) {
stream->write_function(stream, "%s: -ERR failed to execute cmd\n", __FILE__);
goto done;
}
goto done;
}
} else {
boost_sigmod_interface_t *sigmod_iface = NULL;
sigmod_iface = hashtable_search(g_boost_modules_hash, argv[0]);
if (sigmod_iface) {
char *p = strchr(data, ' ');
if (++p) {
char* mydup = strdup(p);
if(sigmod_iface->exec_api == NULL) {
stream->write_function(stream, "%s does not support api functions\n", sigmod_iface->name);
goto done;
}
//stream->write_function(stream, "sigmod:%s command:%s\n", sigmod_iface->name, mydup);
if (sigmod_iface->exec_api(stream, mydup) != FTDM_SUCCESS) {
stream->write_function(stream, "-ERR:failed to execute command:%s\n", mydup);
}
free(mydup);
}
goto done;
} else {
stream->write_function(stream, "-ERR: Could not find sigmod %s\n", argv[0]);
}
}
}
stream->write_function(stream, "-ERR: Usage: %s\n", FTDM_BOOST_SYNTAX);
done:
ftdm_safe_free(mycmd);
return FTDM_SUCCESS;
}
/**
* \brief Loads sangoma_boost IO module
* \param fio FreeTDM IO interface
* \return Success
*/
static FIO_IO_LOAD_FUNCTION(ftdm_sangoma_boost_io_init)
{
assert(fio != NULL);
memset(&ftdm_sangoma_boost_interface, 0, sizeof(ftdm_sangoma_boost_interface));
ftdm_sangoma_boost_interface.name = "boost";
ftdm_sangoma_boost_interface.api = ftdm_sangoma_boost_api;
*fio = &ftdm_sangoma_boost_interface;
return FTDM_SUCCESS;
}
/** /**
* \brief Loads sangoma boost signaling module * \brief Loads sangoma boost signaling module
* \param fio FreeTDM IO interface * \param fio FreeTDM IO interface
@ -2250,12 +2328,31 @@ static FIO_CONFIGURE_SPAN_SIGNALING_FUNCTION(ftdm_sangoma_boost_configure_span)
return FTDM_SUCCESS; return FTDM_SUCCESS;
} }
static ftdm_status_t ftdm_sangoma_boost_list_sigmods(ftdm_stream_handle_t *stream)
{
ftdm_hash_iterator_t *i = NULL;
boost_sigmod_interface_t *sigmod_iface = NULL;
const void *key = NULL;
void *val = NULL;
stream->write_function(stream, "List of loaded sigmod modules:\n");
for (i = hashtable_first(g_boost_modules_hash); i; i = hashtable_next(i)) {
hashtable_this(i, &key, NULL, &val);
if (key && val) {
sigmod_iface = val;
stream->write_function(stream, " %s\n", sigmod_iface->name);
}
}
stream->write_function(stream, "\n");
return FTDM_SUCCESS;
}
/** /**
* \brief FreeTDM sangoma boost signaling module definition * \brief FreeTDM sangoma boost signaling module definition
*/ */
EX_DECLARE_DATA ftdm_module_t ftdm_module = { EX_DECLARE_DATA ftdm_module_t ftdm_module = {
/*.name =*/ "sangoma_boost", /*.name =*/ "sangoma_boost",
/*.io_load =*/ NULL, /*.io_load =*/ ftdm_sangoma_boost_io_init,
/*.io_unload =*/ NULL, /*.io_unload =*/ NULL,
/*.sig_load = */ ftdm_sangoma_boost_init, /*.sig_load = */ ftdm_sangoma_boost_init,
/*.sig_configure =*/ NULL, /*.sig_configure =*/ NULL,

View File

@ -37,7 +37,6 @@
#include "freetdm.h" #include "freetdm.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -180,6 +179,15 @@ typedef ftdm_status_t (*boost_on_load_func_t) BOOST_ON_LOAD_ARGS;
typedef ftdm_status_t (*boost_on_unload_func_t) BOOST_ON_UNLOAD_ARGS; typedef ftdm_status_t (*boost_on_unload_func_t) BOOST_ON_UNLOAD_ARGS;
#define BOOST_ON_UNLOAD_FUNCTION(name) ftdm_status_t name BOOST_ON_UNLOAD_ARGS #define BOOST_ON_UNLOAD_FUNCTION(name) ftdm_status_t name BOOST_ON_UNLOAD_ARGS
/*!
\brief Called when user wants to execute sigmod api function
\return FTDM_SUCCESS or FTDM_FAIL
*/
#define BOOST_API_ARGS (ftdm_stream_handle_t *stream, char *cmd)
typedef ftdm_status_t (*boost_api_func_t) BOOST_API_ARGS;
#define BOOST_API_FUNCTION(name) ftdm_status_t name BOOST_API_ARGS
/*! /*!
\brief The boost signaling module interface \brief The boost signaling module interface
*/ */
@ -212,6 +220,8 @@ typedef struct boost_sigmod_interface_s {
boost_on_load_func_t on_load; boost_on_load_func_t on_load;
/*! \brief the module is about to be unloaded */ /*! \brief the module is about to be unloaded */
boost_on_unload_func_t on_unload; boost_on_unload_func_t on_unload;
/*! \brief module api function */
boost_api_func_t exec_api;
/*! \brief private pointer for the interface user */ /*! \brief private pointer for the interface user */
void *pvt; void *pvt;
} boost_sigmod_interface_t; } boost_sigmod_interface_t;

View File

@ -425,7 +425,7 @@ OZ_DECLARE(zap_status_t) zap_interrupt_multiple_wait(zap_interrupt_t *interrupts
return ZAP_TIMEOUT; return ZAP_TIMEOUT;
} }
for (i = size; i < zap_array_len(ints); i++) { for (i = 0; i < size; i++) {
if (ints[i].revents & POLLIN) { if (ints[i].revents & POLLIN) {
res = read(ints[0].fd, pipebuf, sizeof(pipebuf)); res = read(ints[0].fd, pipebuf, sizeof(pipebuf));
if (res == -1) { if (res == -1) {

View File

@ -246,9 +246,11 @@ SWITCH_DECLARE(const char *) switch_channel_get_variable_partner(switch_channel_
#define switch_channel_set_variable_partner(_channel, _var, _val) switch_channel_set_variable_partner_var_check(_channel, _var, _val, SWITCH_TRUE) #define switch_channel_set_variable_partner(_channel, _var, _val) switch_channel_set_variable_partner_var_check(_channel, _var, _val, SWITCH_TRUE)
SWITCH_DECLARE(switch_status_t) switch_channel_export_variable_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check, switch_bool_t nolocal); SWITCH_DECLARE(switch_status_t) switch_channel_export_variable_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check);
#define switch_channel_export_variable(_channel, _varname, _value) switch_channel_export_variable_var_check(_channel, _varname, _value, SWITCH_TRUE)
SWITCH_DECLARE(switch_status_t) switch_channel_export_variable_printf(switch_channel_t *channel, const char *varname, const char *fmt, ...);
#define switch_channel_export_variable(_channel, _varname, _value, _nolocal) switch_channel_export_variable_var_check(_channel, _varname, _value, SWITCH_TRUE, _nolocal)
/*! /*!
\brief Retrieve a variable from a given channel \brief Retrieve a variable from a given channel

View File

@ -737,34 +737,49 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_profile_var(switch_channel_t
return status; return status;
} }
SWITCH_DECLARE(switch_status_t) switch_channel_export_variable_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check, switch_bool_t nolocal) SWITCH_DECLARE(switch_status_t) switch_channel_export_variable_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check)
{ {
const char *exports, *exports_varname = varname; const char *exports;
switch_status_t status; switch_status_t status = SWITCH_STATUS_FALSE;
exports = switch_channel_get_variable(channel, SWITCH_EXPORT_VARS_VARIABLE); exports = switch_channel_get_variable(channel, SWITCH_EXPORT_VARS_VARIABLE);
if (nolocal) { if ((status = switch_channel_set_variable_var_check(channel, varname, value, var_check)) != SWITCH_STATUS_SUCCESS) {
exports_varname = switch_mprintf("nolocal:%s", varname); return status;
}
if ((status = switch_channel_set_variable_var_check(channel, exports_varname, value, var_check)) != SWITCH_STATUS_SUCCESS) {
goto done;
} }
if (varname && value) { if (varname && value) {
if (exports) { if (exports) {
switch_channel_set_variable_printf(channel, SWITCH_EXPORT_VARS_VARIABLE, "%s,%s", exports, exports_varname); switch_channel_set_variable_printf(channel, SWITCH_EXPORT_VARS_VARIABLE, "%s,%s", exports, varname);
} else { } else {
switch_channel_set_variable(channel, SWITCH_EXPORT_VARS_VARIABLE, exports_varname); switch_channel_set_variable(channel, SWITCH_EXPORT_VARS_VARIABLE, varname);
} }
} }
done: return status;
if (exports_varname != varname) { }
free((char*)exports_varname);
SWITCH_DECLARE(switch_status_t) switch_channel_export_variable_printf(switch_channel_t *channel, const char *varname, const char *fmt, ...)
{
switch_status_t status = SWITCH_STATUS_FALSE;
char *data = NULL;
va_list ap;
int ret;
switch_assert(channel != NULL);
va_start(ap, fmt);
ret = switch_vasprintf(&data, fmt, ap);
va_end(ap);
if (ret == -1) {
return SWITCH_STATUS_FALSE;
} }
status = switch_channel_export_variable(channel, varname, data);
free(data);
return status; return status;
} }