Very boring to do but now properly save and restore mod_portaudio configs.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16167 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
João Mesquita 2010-01-06 03:04:04 +00:00
parent 135360ba58
commit 1ac6ec269e
1 changed files with 105 additions and 18 deletions

View File

@ -3,8 +3,8 @@
#include "prefportaudio.h"
PrefPortaudio::PrefPortaudio(Ui::PrefDialog *ui, QObject *parent) :
QObject(parent),
_ui(ui)
QObject(parent),
_ui(ui)
{
_settings = new QSettings();
}
@ -13,14 +13,101 @@ void PrefPortaudio::writeConfig()
{
_settings->beginGroup("FreeSWITCH/conf");
_settings->beginGroup("portaudio.conf");
_settings->setValue("cid-name", _ui->PaCallerIdNameEdit->text());
_settings->setValue("cid-num", _ui->PaCallerIdNumEdit->text());
_settings->setValue("indev", _ui->PaIndevCombo->currentIndex());
_settings->setValue("outdev", _ui->PaOutdevCombo->currentIndex());
_settings->setValue("ringdev", _ui->PaRingdevCombo->currentIndex());
_settings->setValue("ring-file", _ui->PaRingFileEdit->text());
_settings->setValue("ring-interval", _ui->PaRingIntervalSpin->value());
_settings->setValue("hold-file", _ui->PaHoldFileEdit->text());
QString cid_name = _settings->value("cid-name").toString();
QString ncid_name = _ui->PaCallerIdNameEdit->text();
QString cid_num = _settings->value("cid-num").toString();
QString ncid_num = _ui->PaCallerIdNumEdit->text();
QString hold_file = _settings->value("hold-file").toString();
QString nhold_file = _ui->PaHoldFileEdit->text();
QString ring_file = _settings->value("ring-file").toString();
QString nring_file = _ui->PaRingFileEdit->text();
int ring_interval = _settings->value("ring-interval").toInt();
int nring_interval = _ui->PaRingIntervalSpin->value();
QString result;
if (cid_name != ncid_name ||
cid_num != ncid_num ||
hold_file != nhold_file ||
ring_file != nring_file ||
ring_interval != nring_interval)
{
if (g_FSHost.sendCmd("reload", "mod_portaudio", &result) == SWITCH_STATUS_SUCCESS)
{
_settings->setValue("cid-name", ncid_name);
_settings->setValue("cid-num", ncid_num);
_settings->setValue("ring-file", nring_file);
_settings->setValue("ring-interval", nring_interval);
_settings->setValue("hold-file", nhold_file);
}
else
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error while issuing reload command to mod_portaudio!\n");
QMessageBox::critical(0, tr("Unable to save settings"),
tr("There was an error saving your settings.\nPlease report this bug."),
QMessageBox::Ok);
}
}
int nindev = _ui->PaIndevCombo->currentIndex();
int indev = _settings->value("indev").toInt();
int noutdev = _ui->PaOutdevCombo->currentIndex();
int outdev = _settings->value("outdev").toInt();
int nringdev = _ui->PaRingdevCombo->currentIndex();
int ringdev = _settings->value("ringdev").toInt();
if (nindev != indev)
{
if (g_FSHost.sendCmd("pa", QString("indev #%1").arg(nindev).toAscii().constData(), &result) == SWITCH_STATUS_SUCCESS)
{
_settings->setValue("indev", nindev);
}
else
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting indev from #%d to #%d on mod_portaudio!\n",
indev, nindev);
QMessageBox::critical(0, tr("Unable to save settings"),
tr("There was an error changing the indev.\nPlease report this bug."),
QMessageBox::Ok);
}
}
if (noutdev!= outdev)
{
if (g_FSHost.sendCmd("pa", QString("outdev #%1").arg(noutdev).toAscii().constData(), &result) == SWITCH_STATUS_SUCCESS)
{
_settings->setValue("outdev", noutdev);
}
else
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting outdev from #%d to #%d on mod_portaudio!\n",
outdev, noutdev);
QMessageBox::critical(0, tr("Unable to save settings"),
tr("There was an error changing the outdev.\nPlease report this bug."),
QMessageBox::Ok);
}
}
if (nringdev != ringdev)
{
if (g_FSHost.sendCmd("pa", QString("ringdev #%1").arg(nringdev).toAscii().constData(), &result) == SWITCH_STATUS_SUCCESS)
{
_settings->setValue("ringdev", nringdev);
}
else
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting ringdev from #%d to #%d on mod_portaudio!\n",
nringdev, nringdev);
QMessageBox::critical(0, tr("Unable to save settings"),
tr("There was an error changing the ringdev.\nPlease report this bug."),
QMessageBox::Ok);
}
}
_settings->endGroup();
_settings->endGroup();
}
@ -50,8 +137,8 @@ void PrefPortaudio::getPaDevlist()
if (g_FSHost.sendCmd("pa", "devlist xml", &result) != SWITCH_STATUS_SUCCESS)
{
QMessageBox::critical(0, tr("PortAudio error" ),
tr("Error querying audio devices."),
QMessageBox::Ok);
tr("Error querying audio devices."),
QMessageBox::Ok);
return;
}
@ -61,7 +148,7 @@ void PrefPortaudio::getPaDevlist()
tr("Error parsing output xml from pa devlist.\n%1 (Line:%2, Col:%3).").arg(errorMsg,
errorLine,
errorColumn),
QMessageBox::Ok);
QMessageBox::Ok);
return;
}
QDomElement root = _xmlPaDevList.documentElement();
@ -69,7 +156,7 @@ void PrefPortaudio::getPaDevlist()
{
QMessageBox::critical(0, tr("PortAudio error" ),
tr("Error parsing output xml from pa devlist. Root tag is not <xml>."),
QMessageBox::Ok);
QMessageBox::Ok);
return;
}
QDomElement devices = root.firstChildElement("devices");
@ -77,7 +164,7 @@ void PrefPortaudio::getPaDevlist()
{
QMessageBox::critical(0, tr("PortAudio error" ),
tr("Error parsing output xml from pa devlist. There is no <devices> tag."),
QMessageBox::Ok);
QMessageBox::Ok);
return;
}
@ -86,7 +173,7 @@ void PrefPortaudio::getPaDevlist()
{
QMessageBox::critical(0, tr("PortAudio error" ),
tr("Error parsing output xml from pa devlist. There is no <device> tag."),
QMessageBox::Ok);
QMessageBox::Ok);
return;
}
@ -115,7 +202,7 @@ void PrefPortaudio::getPaDevlist()
{
QMessageBox::critical(0, tr("PortAudio error" ),
tr("Error parsing output xml from pa devlist. There is no <bindings> tag."),
QMessageBox::Ok);
QMessageBox::Ok);
return;
}
@ -124,7 +211,7 @@ void PrefPortaudio::getPaDevlist()
{
QMessageBox::critical(0, tr("PortAudio error" ),
tr("Error parsing output xml from pa devlist. There are no bindings."),
QMessageBox::Ok);
QMessageBox::Ok);
return;
}