conf_dir.absolutePath(),
QDateTime::currentDateTime().toString("yyyyMMddhhmmss"),
getCidNumber());
- status = g_FSHost.sendCmd("uuid_record", QString("%1 start %2").arg(getUuid(), _recording_filename).toAscii().data(),&result);
+ status = g_FSHost->sendCmd("uuid_record", QString("%1 start %2").arg(getUuid(), _recording_filename).toAscii().data(),&result);
}
else
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Stopping call recording on call [%s]\n",
getUuid().toAscii().data());
- status = g_FSHost.sendCmd("uuid_record", QString("%1 stop %2").arg(getUuid(), _recording_filename).toAscii().data(),&result);
+ status = g_FSHost->sendCmd("uuid_record", QString("%1 stop %2").arg(getUuid(), _recording_filename).toAscii().data(),&result);
}
return status;
{
QString result;
QString dtmf_string = QString("dtmf %1").arg(digit);
- if (g_FSHost.sendCmd("pa", dtmf_string.toAscii(), &result) == SWITCH_STATUS_FALSE) {
+ if (g_FSHost->sendCmd("pa", dtmf_string.toAscii(), &result) == SWITCH_STATUS_FALSE) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not send DTMF digit %s on call[%s]", digit.toAscii().data(), getUuid().toAscii().data());
QMessageBox::critical(0, QWidget::tr("DTMF Error"), QWidget::tr("There was an error sending DTMF, please report this bug."), QMessageBox::Ok);
}
connect(ui->filterReverseCheckBox, SIGNAL(toggled(bool)),
this, SLOT(reverseFilterChecked()));
- connect(&g_FSHost, SIGNAL(eventLog(QSharedPointer<switch_log_node_t>,switch_log_level_t)), this, SLOT(loggerHandler(QSharedPointer<switch_log_node_t>,switch_log_level_t)));
+ connect(g_FSHost, SIGNAL(eventLog(QSharedPointer<switch_log_node_t>,switch_log_level_t)), this, SLOT(loggerHandler(QSharedPointer<switch_log_node_t>,switch_log_level_t)));
}
}
QString res;
- g_FSHost.sendCmd(cmd.toAscii().data(), args.toAscii().data(), &res);
+ g_FSHost->sendCmd(cmd.toAscii().data(), args.toAscii().data(), &res);
if (!res.isEmpty())
{
/* Remove \r\n */
ui(new Ui::StateDebugDialog)
{
ui->setupUi(this);
- connect(&g_FSHost, SIGNAL(newEvent(QSharedPointer<switch_event_t>)), this, SLOT(newEvent(QSharedPointer<switch_event_t>)));
+ connect(g_FSHost, SIGNAL(newEvent(QSharedPointer<switch_event_t>)), this, SLOT(newEvent(QSharedPointer<switch_event_t>)));
connect(ui->listUUID, SIGNAL(itemSelectionChanged()), this, SLOT(currentUuidChanged()));
connect(ui->listEvents, SIGNAL(itemSelectionChanged()), this, SLOT(currentEventsChanged()));
}
#include "mod_qsettings/mod_qsettings.h"
/* Declare it globally */
-FSHost g_FSHost;
+FSHost *g_FSHost;
FSHost::FSHost(QObject *parent) :
QThread(parent)
connect(this, SIGNAL(delAccount(QSharedPointer<Account>)), this, SLOT(accountReloadSlot(QSharedPointer<Account>)));
- if (g_FSHost.sendCmd("sofia", arg.toAscii().data() , &res) != SWITCH_STATUS_SUCCESS)
+ if (g_FSHost->sendCmd("sofia", arg.toAscii().data() , &res) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not killgw %s from profile softphone.\n",
acc.data()->getName().toAscii().data());
{
_reloading_Accounts.takeAt(_reloading_Accounts.indexOf(acc.data()->getName(), 0));
QString res;
- if (g_FSHost.sendCmd("sofia", "profile softphone rescan", &res) != SWITCH_STATUS_SUCCESS)
+ if (g_FSHost->sendCmd("sofia", "profile softphone rescan", &res) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not rescan the softphone profile.\n");
return;
QList<QString> _loadedModules;
};
-extern FSHost g_FSHost;
+extern FSHost *g_FSHost;
/*
Used to match callback from fs core. We dup the event and call the class
switch_event_t *clone = NULL;
if (switch_event_dup(&clone, event) == SWITCH_STATUS_SUCCESS) {
QSharedPointer<switch_event_t> e(clone);
- g_FSHost.generalEventHandler(e);
+ g_FSHost->generalEventHandler(e);
}
}
{
switch_log_node_t *clone = switch_log_node_dup(node);
QSharedPointer<switch_log_node_t> l(clone);
- g_FSHost.generalLoggerHandler(l, level);
+ g_FSHost->generalLoggerHandler(l, level);
return SWITCH_STATUS_SUCCESS;
}
splash->show();
splash->showMessage("Loading core, please wait...", Qt::AlignRight|Qt::AlignBottom, Qt::blue);
- QObject::connect(&g_FSHost, SIGNAL(loadingModules(QString,int,QColor)), splash, SLOT(showMessage(QString,int,QColor)));
+ g_FSHost = new FSHost();
- QObject::connect(&g_FSHost, SIGNAL(ready()), splash, SLOT(close()));
+ QObject::connect(g_FSHost, SIGNAL(loadingModules(QString,int,QColor)), splash, SLOT(showMessage(QString,int,QColor)));
+
+ QObject::connect(g_FSHost, SIGNAL(ready()), splash, SLOT(close()));
MainWindow w;
- QObject::connect(&g_FSHost, SIGNAL(ready()), &w, SLOT(show()));
- g_FSHost.start();
+ QObject::connect(g_FSHost, SIGNAL(ready()), &w, SLOT(show()));
+ g_FSHost->start();
return a.exec();
}
connect(dialpadMapper, SIGNAL(mapped(QString)), this, SLOT(sendDTMF(QString)));
/* Connect events related to FreeSWITCH */
- connect(&g_FSHost, SIGNAL(ready()),this, SLOT(fshostReady()));
- connect(&g_FSHost, SIGNAL(ringing(QSharedPointer<Call>)), this, SLOT(ringing(QSharedPointer<Call>)));
- connect(&g_FSHost, SIGNAL(answered(QSharedPointer<Call>)), this, SLOT(answered(QSharedPointer<Call>)));
- connect(&g_FSHost, SIGNAL(hungup(QSharedPointer<Call>)), this, SLOT(hungup(QSharedPointer<Call>)));
- connect(&g_FSHost, SIGNAL(newOutgoingCall(QSharedPointer<Call>)), this, SLOT(newOutgoingCall(QSharedPointer<Call>)));
- connect(&g_FSHost, SIGNAL(callFailed(QSharedPointer<Call>)), this, SLOT(callFailed(QSharedPointer<Call>)));
- connect(&g_FSHost, SIGNAL(accountStateChange(QSharedPointer<Account>)), this, SLOT(accountStateChanged(QSharedPointer<Account>)));
- connect(&g_FSHost, SIGNAL(newAccount(QSharedPointer<Account>)), this, SLOT(accountAdd(QSharedPointer<Account>)));
- connect(&g_FSHost, SIGNAL(delAccount(QSharedPointer<Account>)), this, SLOT(accountDel(QSharedPointer<Account>)));
- connect(&g_FSHost, SIGNAL(coreLoadingError(QString)), this, SLOT(coreLoadingError(QString)));
+ connect(g_FSHost, SIGNAL(ready()),this, SLOT(fshostReady()));
+ connect(g_FSHost, SIGNAL(ringing(QSharedPointer<Call>)), this, SLOT(ringing(QSharedPointer<Call>)));
+ connect(g_FSHost, SIGNAL(answered(QSharedPointer<Call>)), this, SLOT(answered(QSharedPointer<Call>)));
+ connect(g_FSHost, SIGNAL(hungup(QSharedPointer<Call>)), this, SLOT(hungup(QSharedPointer<Call>)));
+ connect(g_FSHost, SIGNAL(newOutgoingCall(QSharedPointer<Call>)), this, SLOT(newOutgoingCall(QSharedPointer<Call>)));
+ connect(g_FSHost, SIGNAL(callFailed(QSharedPointer<Call>)), this, SLOT(callFailed(QSharedPointer<Call>)));
+ connect(g_FSHost, SIGNAL(accountStateChange(QSharedPointer<Account>)), this, SLOT(accountStateChanged(QSharedPointer<Account>)));
+ connect(g_FSHost, SIGNAL(newAccount(QSharedPointer<Account>)), this, SLOT(accountAdd(QSharedPointer<Account>)));
+ connect(g_FSHost, SIGNAL(delAccount(QSharedPointer<Account>)), this, SLOT(accountDel(QSharedPointer<Account>)));
+ connect(g_FSHost, SIGNAL(coreLoadingError(QString)), this, SLOT(coreLoadingError(QString)));
/* Connect call commands */
connect(ui->newCallBtn, SIGNAL(clicked()), this, SLOT(makeCall()));
{
delete ui;
QString res;
- g_FSHost.sendCmd("fsctl", "shutdown", &res);
- g_FSHost.wait();
+ g_FSHost->sendCmd("fsctl", "shutdown", &res);
+ g_FSHost->wait();
}
void MainWindow::updateCallTimers()
for(int row=0; row<ui->tableCalls->rowCount(); row++)
{
QTableWidgetItem* item = ui->tableCalls->item(row, 2);
- QSharedPointer<Call> call = g_FSHost.getCallByUUID(item->data(Qt::UserRole).toString());
+ QSharedPointer<Call> call = g_FSHost->getCallByUUID(item->data(Qt::UserRole).toString());
QTime time = call.data()->getCurrentStateTime();
item->setText(time.toString("hh:mm:ss"));
item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
void MainWindow::applyPreprocessors(QStringList cmds)
{
- if (g_FSHost.getCurrentActiveCall().isNull()) return;
- QString uuid = g_FSHost.getCurrentActiveCall().data()->getUuid();
+ if (g_FSHost->getCurrentActiveCall().isNull()) return;
+ QString uuid = g_FSHost->getCurrentActiveCall().data()->getUuid();
foreach(QString cmd, cmds)
{
switch_stream_handle_t stream = { 0 };
void MainWindow::sendDTMF(QString dtmf)
{
- g_FSHost.getCurrentActiveCall().data()->sendDTMF(dtmf);
+ g_FSHost->getCurrentActiveCall().data()->sendDTMF(dtmf);
}
void MainWindow::callTableDoubleClick(QTableWidgetItem *item)
{
- QSharedPointer<Call> lastCall = g_FSHost.getCurrentActiveCall();
- QSharedPointer<Call> call = g_FSHost.getCallByUUID(item->data(Qt::UserRole).toString());
+ QSharedPointer<Call> lastCall = g_FSHost->getCurrentActiveCall();
+ QSharedPointer<Call> call = g_FSHost->getCallByUUID(item->data(Qt::UserRole).toString());
QString switch_str = QString("switch %1").arg(call.data()->getCallID());
QString result;
- if (g_FSHost.sendCmd("pa", switch_str.toAscii(), &result) == SWITCH_STATUS_FALSE) {
+ if (g_FSHost->sendCmd("pa", switch_str.toAscii(), &result) == SWITCH_STATUS_FALSE) {
ui->textEdit->setText(QString("Error switching to call %1").arg(call.data()->getCallID()));
return;
}
QString dialstring = QInputDialog::getText(this, tr("Make new call"),
tr("Number to dial:"), QLineEdit::Normal, NULL,&ok);
- QSharedPointer<Account> acc = g_FSHost.getCurrentDefaultAccount();
+ QSharedPointer<Account> acc = g_FSHost->getCurrentDefaultAccount();
if (!acc.isNull()) {
QSettings settings;
settings.beginGroup("FreeSWITCH/conf/sofia.conf/profiles/profile/gateways/");
sysTray->show();
sysTray->showMessage(tr("Status"), tr("FSComm has initialized!"), QSystemTrayIcon::Information, 5000);
- if (!g_FSHost.isModuleLoaded("mod_sofia"))
+ if (!g_FSHost->isModuleLoaded("mod_sofia"))
{
QMessageBox::warning(this, tr("SIP not available"),
tr("Sofia could not be loaded, therefore, SIP will not be available."),
QMessageBox::Ok);
}
- if (!g_FSHost.isModuleLoaded("mod_portaudio"))
+ if (!g_FSHost->isModuleLoaded("mod_portaudio"))
{
QMessageBox::warning(this, tr("Audio not available"),
tr("Portaudio could not be loaded. Please check if mod_portaudio is properly compiled."),
void MainWindow::paAnswer()
{
QString result;
- if (g_FSHost.sendCmd("pa", "answer", &result) == SWITCH_STATUS_FALSE) {
+ if (g_FSHost->sendCmd("pa", "answer", &result) == SWITCH_STATUS_FALSE) {
ui->textEdit->setText("Error sending that command");
}
QString callstring = QString("call %1").arg(dialstring);
- if (g_FSHost.sendCmd("pa", callstring.toAscii(), &result) == SWITCH_STATUS_FALSE) {
+ if (g_FSHost->sendCmd("pa", callstring.toAscii(), &result) == SWITCH_STATUS_FALSE) {
ui->textEdit->setText("Error sending that command");
}
void MainWindow::paHangup()
{
QString result;
- if (g_FSHost.sendCmd("pa", "hangup", &result) == SWITCH_STATUS_FALSE) {
+ if (g_FSHost->sendCmd("pa", "hangup", &result) == SWITCH_STATUS_FALSE) {
ui->textEdit->setText("Error sending that command");
}
void MainWindow::holdCall(bool pressed)
{
- QSharedPointer<Call> call = g_FSHost.getCurrentActiveCall();
+ QSharedPointer<Call> call = g_FSHost->getCurrentActiveCall();
if (call.isNull())
{
void MainWindow::recordCall(bool pressed)
{
- QSharedPointer<Call> call = g_FSHost.getCurrentActiveCall();
+ QSharedPointer<Call> call = g_FSHost->getCurrentActiveCall();
if (call.isNull())
{
void MainWindow::showAbout()
{
QString result;
- g_FSHost.sendCmd("version", "", &result);
+ g_FSHost->sendCmd("version", "", &result);
QMessageBox::about(this, tr("About FSComm"),
tr("<h2>FSComm</h2>"
void AccountDialog::writeConfig()
{
- QSharedPointer<Account> acc = g_FSHost.getAccountByUUID(_accId);
+ QSharedPointer<Account> acc = g_FSHost->getAccountByUUID(_accId);
if (!acc.isNull())
{
- g_FSHost.accountReloadCmd(acc);
+ g_FSHost->accountReloadCmd(acc);
}
_settings->beginGroup("FreeSWITCH/conf/sofia.conf/profiles/profile/gateways");
if (!_accDlg)
{
QString uuid;
- if (g_FSHost.sendCmd("create_uuid", "", &uuid) != SWITCH_STATUS_SUCCESS)
+ if (g_FSHost->sendCmd("create_uuid", "", &uuid) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not create UUID for account. Reason: %s\n", uuid.toAscii().constData());
return;
else
{
QString uuid;
- if (g_FSHost.sendCmd("create_uuid", "", &uuid) != SWITCH_STATUS_SUCCESS)
+ if (g_FSHost->sendCmd("create_uuid", "", &uuid) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not create UUID for account. Reason: %s\n", uuid.toAscii().constData());
return;
/* Fire event to remove account */
switch_event_t *event;
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FSCOMM_EVENT_ACC_REMOVED) == SWITCH_STATUS_SUCCESS) {
- QSharedPointer<Account> acc = g_FSHost.getAccountByUUID(item->data(Qt::UserRole).toString());
+ QSharedPointer<Account> acc = g_FSHost->getAccountByUUID(item->data(Qt::UserRole).toString());
if (!acc.isNull())
{
QString res;
QString arg = QString("profile softphone killgw %1").arg(acc.data()->getName());
- if (g_FSHost.sendCmd("sofia", arg.toAscii().data() , &res) != SWITCH_STATUS_SUCCESS)
+ if (g_FSHost->sendCmd("sofia", arg.toAscii().data() , &res) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not killgw %s from profile softphone.\n",
acc.data()->getName().toAscii().data());
if (reload)
{
QString res;
- if (g_FSHost.sendCmd("sofia", "profile softphone rescan", &res) != SWITCH_STATUS_SUCCESS)
+ if (g_FSHost->sendCmd("sofia", "profile softphone rescan", &res) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not rescan the softphone profile.\n");
return;
void PrefPortaudio::ringdevTest()
{
QString result;
- if (g_FSHost.sendCmd("pa", QString("play %1/.fscomm/sounds/test.wav 0").arg(QDir::homePath()).toAscii().constData(), &result) != SWITCH_STATUS_SUCCESS)
+ if (g_FSHost->sendCmd("pa", QString("play %1/.fscomm/sounds/test.wav 0").arg(QDir::homePath()).toAscii().constData(), &result) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error testing ringdev on mod_portaudio! %s\n",
result.toAscii().constData());
{
QString result;
_ui->PaLoopTestBtn->setEnabled(false);
- if (g_FSHost.sendCmd("pa", "looptest", &result) != SWITCH_STATUS_SUCCESS)
+ if (g_FSHost->sendCmd("pa", "looptest", &result) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error running looptest on mod_portaudio! %s\n",
result.toAscii().constData());
void PrefPortaudio::refreshDevList()
{
QString result;
- if (g_FSHost.sendCmd("pa", "rescan", &result) != SWITCH_STATUS_SUCCESS)
+ if (g_FSHost->sendCmd("pa", "rescan", &result) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error rescaning sound device on mod_portaudio! %s\n",
result.toAscii().constData());
{
QString result;
int dev = _ui->PaIndevCombo->itemData(index, Qt::UserRole).toInt();
- if (g_FSHost.sendCmd("pa", QString("indev #%1").arg(dev).toAscii().constData(), &result) != SWITCH_STATUS_SUCCESS)
+ if (g_FSHost->sendCmd("pa", QString("indev #%1").arg(dev).toAscii().constData(), &result) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting ringdev to #%d on mod_portaudio!\n", dev);
QMessageBox::critical(0, tr("Unable to change device."),
{
QString result;
int dev = _ui->PaRingdevCombo->itemData(index, Qt::UserRole).toInt();
- if (g_FSHost.sendCmd("pa", QString("ringdev #%1").arg(dev).toAscii().constData(), &result) != SWITCH_STATUS_SUCCESS)
+ if (g_FSHost->sendCmd("pa", QString("ringdev #%1").arg(dev).toAscii().constData(), &result) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting ringdev to #%d on mod_portaudio!\n", dev);
QMessageBox::critical(0, tr("Unable to change device."),
{
QString result;
int dev = _ui->PaRingdevCombo->itemData(index, Qt::UserRole).toInt();
- if (g_FSHost.sendCmd("pa", QString("outdev #%1").arg(dev).toAscii().constData(), &result) != SWITCH_STATUS_SUCCESS)
+ if (g_FSHost->sendCmd("pa", QString("outdev #%1").arg(dev).toAscii().constData(), &result) != SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting outdev to #%d on mod_portaudio!\n", dev);
QMessageBox::critical(0, tr("Unable to change device."),
sample_rate != nsample_rate||
codec_ms != ncodec_ms)
{
- if (g_FSHost.sendCmd("reload", "mod_portaudio", &result) == SWITCH_STATUS_SUCCESS)
+ if (g_FSHost->sendCmd("reload", "mod_portaudio", &result) == SWITCH_STATUS_SUCCESS)
{
_settings->setValue("cid-name", ncid_name);
_settings->setValue("cid-num", ncid_num);
if (nindev != indev)
{
- if (g_FSHost.sendCmd("pa", QString("indev #%1").arg(nindev).toAscii().constData(), &result) == SWITCH_STATUS_SUCCESS)
+ if (g_FSHost->sendCmd("pa", QString("indev #%1").arg(nindev).toAscii().constData(), &result) == SWITCH_STATUS_SUCCESS)
{
_settings->setValue("indev", nindev);
}
int errorLine, errorColumn;
QString errorMsg;
- if (g_FSHost.sendCmd("pa", "devlist xml", &result) != SWITCH_STATUS_SUCCESS)
+ if (g_FSHost->sendCmd("pa", "devlist xml", &result) != SWITCH_STATUS_SUCCESS)
{
QMessageBox::critical(0, tr("PortAudio error" ),
tr("Error querying audio devices."),