mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-23 04:31:50 +00:00
Refactor configuration storage/read.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16165 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
+13
-123
@@ -1,6 +1,7 @@
|
||||
#include <QtGui>
|
||||
#include "prefdialog.h"
|
||||
#include "ui_prefdialog.h"
|
||||
#include "prefportaudio.h"
|
||||
|
||||
PrefDialog::PrefDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
@@ -8,8 +9,10 @@ PrefDialog::PrefDialog(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
_settings = new QSettings();
|
||||
connect(this, SIGNAL(accepted()), this, SLOT(configAccepted()));
|
||||
getPaDevlist();
|
||||
connect(this, SIGNAL(accepted()), this, SLOT(writeConfig()));
|
||||
|
||||
_mod_portaudio = new PrefPortaudio(ui, this);
|
||||
readConfig();
|
||||
}
|
||||
|
||||
PrefDialog::~PrefDialog()
|
||||
@@ -17,127 +20,9 @@ PrefDialog::~PrefDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void PrefDialog::configAccepted()
|
||||
{
|
||||
_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());
|
||||
_settings->endGroup();
|
||||
|
||||
_settings->endGroup();
|
||||
|
||||
}
|
||||
|
||||
void PrefDialog::getPaDevlist()
|
||||
{
|
||||
QString result;
|
||||
int errorLine, errorColumn;
|
||||
QString errorMsg;
|
||||
|
||||
if (g_FSHost.sendCmd("pa", "devlist xml", &result) != SWITCH_STATUS_SUCCESS)
|
||||
{
|
||||
QMessageBox::critical(this, tr("PortAudio error" ),
|
||||
tr("Error querying audio devices."),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_xmlPaDevList.setContent(result, &errorMsg, &errorLine, &errorColumn))
|
||||
{
|
||||
QMessageBox::critical(this, tr("PortAudio error" ),
|
||||
tr("Error parsing output xml from pa devlist.\n%1 (Line:%2, Col:%3).").arg(errorMsg,
|
||||
errorLine,
|
||||
errorColumn),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
QDomElement root = _xmlPaDevList.documentElement();
|
||||
if (root.tagName() != "xml")
|
||||
{
|
||||
QMessageBox::critical(this, tr("PortAudio error" ),
|
||||
tr("Error parsing output xml from pa devlist. Root tag is not <xml>."),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
QDomElement devices = root.firstChildElement("devices");
|
||||
if (devices.isNull())
|
||||
{
|
||||
QMessageBox::critical(this, tr("PortAudio error" ),
|
||||
tr("Error parsing output xml from pa devlist. There is no <devices> tag."),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
QDomElement child = devices.firstChildElement();
|
||||
if (child.isNull())
|
||||
{
|
||||
QMessageBox::critical(this, tr("PortAudio error" ),
|
||||
tr("Error parsing output xml from pa devlist. There is no <device> tag."),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
while (!child.isNull())
|
||||
{
|
||||
if (child.tagName() == "device")
|
||||
{
|
||||
QString id, name, inputs, outputs;
|
||||
id = child.attribute("id","-1");
|
||||
name = child.attribute("name","Null");
|
||||
inputs = child.attribute("inputs","0");
|
||||
outputs = child.attribute("outputs","0");
|
||||
if (inputs.toInt() != 0)
|
||||
ui->PaIndevCombo->addItem(name,inputs.toInt());
|
||||
if (outputs.toInt() != 0)
|
||||
{
|
||||
ui->PaOutdevCombo->addItem(name,inputs.toInt());
|
||||
ui->PaRingdevCombo->addItem(name,inputs.toInt());
|
||||
}
|
||||
}
|
||||
child = child.nextSiblingElement();
|
||||
}
|
||||
|
||||
QDomElement bindings = root.firstChildElement("bindings");
|
||||
if (bindings.isNull())
|
||||
{
|
||||
QMessageBox::critical(this, tr("PortAudio error" ),
|
||||
tr("Error parsing output xml from pa devlist. There is no <bindings> tag."),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
child = devices.firstChildElement();
|
||||
if (child.isNull())
|
||||
{
|
||||
QMessageBox::critical(this, tr("PortAudio error" ),
|
||||
tr("Error parsing output xml from pa devlist. There are no bindings."),
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
while (!child.isNull())
|
||||
{
|
||||
QString id;
|
||||
id = child.attribute("device","-1");
|
||||
|
||||
if (child.tagName() == "ring")
|
||||
ui->PaRingdevCombo->setCurrentIndex(id.toInt());
|
||||
else if (child.tagName() == "input")
|
||||
ui->PaIndevCombo->setCurrentIndex(id.toInt());
|
||||
else if (child.tagName() == "ring")
|
||||
ui->PaOutdevCombo->setCurrentIndex(id.toInt());
|
||||
|
||||
child = child.nextSiblingElement();
|
||||
}
|
||||
|
||||
void PrefDialog::writeConfig()
|
||||
{
|
||||
_mod_portaudio->writeConfig();
|
||||
}
|
||||
|
||||
void PrefDialog::changeEvent(QEvent *e)
|
||||
@@ -151,3 +36,8 @@ void PrefDialog::changeEvent(QEvent *e)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PrefDialog::readConfig()
|
||||
{
|
||||
_mod_portaudio->readConfig();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user