2010-01-07 19:41:10 -05:00
|
|
|
#include <QSettings>
|
2010-01-10 23:40:39 -05:00
|
|
|
#include <QtGui>
|
2010-01-07 18:00:34 -05:00
|
|
|
#include "accountdialog.h"
|
|
|
|
#include "ui_accountdialog.h"
|
2010-01-13 21:32:20 -05:00
|
|
|
#include "fshost.h"
|
2010-01-07 18:00:34 -05:00
|
|
|
|
2010-01-13 21:32:20 -05:00
|
|
|
AccountDialog::AccountDialog(int accId, QWidget *parent) :
|
2010-01-07 18:00:34 -05:00
|
|
|
QDialog(parent),
|
2010-01-13 21:32:20 -05:00
|
|
|
_accId(accId),
|
2010-01-07 18:00:34 -05:00
|
|
|
ui(new Ui::AccountDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2010-01-07 19:41:10 -05:00
|
|
|
_settings = new QSettings;
|
|
|
|
connect(this, SIGNAL(accepted()), this, SLOT(writeConfig()));
|
2010-01-10 23:40:39 -05:00
|
|
|
connect(ui->sofiaExtraParamAddBtn, SIGNAL(clicked()), this, SLOT(addExtraParam()));
|
|
|
|
connect(ui->sofiaExtraParamRemBtn, SIGNAL(clicked()), this, SLOT(remExtraParam()));
|
2010-01-07 18:00:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
AccountDialog::~AccountDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2010-01-10 23:40:39 -05:00
|
|
|
void AccountDialog::remExtraParam()
|
|
|
|
{
|
|
|
|
QList<QTableWidgetSelectionRange> sel = ui->sofiaExtraParamTable->selectedRanges();
|
|
|
|
|
|
|
|
foreach(QTableWidgetSelectionRange range, sel)
|
|
|
|
{
|
|
|
|
int offset =0;
|
|
|
|
for(int row = range.topRow(); row<=range.bottomRow(); row++)
|
|
|
|
{
|
|
|
|
ui->sofiaExtraParamTable->removeRow(row-offset);
|
|
|
|
offset++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AccountDialog::addExtraParam()
|
|
|
|
{
|
|
|
|
bool ok;
|
|
|
|
QString paramName = QInputDialog::getText(this, tr("Add parameter."),
|
|
|
|
tr("New parameter name:"), QLineEdit::Normal,
|
|
|
|
NULL, &ok);
|
|
|
|
if (!ok)
|
|
|
|
return;
|
|
|
|
QString paramVal = QInputDialog::getText(this, tr("Add parameter."),
|
|
|
|
tr("New parameter value:"), QLineEdit::Normal,
|
|
|
|
NULL, &ok);
|
|
|
|
if (!ok)
|
|
|
|
return;
|
|
|
|
|
|
|
|
QTableWidgetItem* paramNameItem = new QTableWidgetItem(paramName);
|
|
|
|
QTableWidgetItem* paramValItem = new QTableWidgetItem(paramVal);
|
|
|
|
ui->sofiaExtraParamTable->setRowCount(ui->sofiaExtraParamTable->rowCount()+1);
|
|
|
|
ui->sofiaExtraParamTable->setItem(ui->sofiaExtraParamTable->rowCount()-1,0,paramNameItem);
|
|
|
|
ui->sofiaExtraParamTable->setItem(ui->sofiaExtraParamTable->rowCount()-1,1,paramValItem);
|
|
|
|
}
|
|
|
|
|
2010-01-07 19:12:54 -05:00
|
|
|
void AccountDialog::writeConfig()
|
|
|
|
{
|
2010-01-13 21:32:20 -05:00
|
|
|
_settings->beginGroup("FreeSWITCH/conf/sofia.conf/profiles/profile/gateways");
|
2010-01-07 19:12:54 -05:00
|
|
|
|
2010-01-13 21:32:20 -05:00
|
|
|
_settings->beginGroup(QString::number(_accId));
|
|
|
|
|
|
|
|
_settings->beginGroup("gateway/attrs");
|
|
|
|
_settings->setValue("name", ui->sofiaGwNameEdit->text());
|
|
|
|
_settings->endGroup();
|
|
|
|
|
|
|
|
|
|
|
|
_settings->beginGroup("gateway/params");
|
2010-01-07 19:41:10 -05:00
|
|
|
_settings->setValue("username", ui->sofiaGwUsernameEdit->text());
|
|
|
|
_settings->setValue("realm", ui->sofiaGwRealmEdit->text());
|
|
|
|
_settings->setValue("password", ui->sofiaGwPasswordEdit->text());
|
|
|
|
_settings->setValue("extension", ui->sofiaGwExtensionEdit->text());
|
|
|
|
_settings->setValue("expire-seconds", ui->sofiaGwExpireSecondsSpin->value());
|
|
|
|
_settings->setValue("register", ui->sofiaGwRegisterCombo->currentText());
|
|
|
|
_settings->setValue("register-transport", ui->sofiaGwRegisterTransportCombo->currentText());
|
2010-01-13 21:32:20 -05:00
|
|
|
_settings->setValue("retry-seconds", ui->sofiaGwRetrySecondsSpin->value());
|
2010-01-10 23:40:39 -05:00
|
|
|
for (int i = 0; i< ui->sofiaExtraParamTable->rowCount(); i++)
|
|
|
|
{
|
|
|
|
_settings->setValue(ui->sofiaExtraParamTable->item(i, 0)->text(),
|
|
|
|
ui->sofiaExtraParamTable->item(i, 1)->text());
|
|
|
|
}
|
|
|
|
_settings->endGroup();
|
|
|
|
|
2010-01-07 19:41:10 -05:00
|
|
|
_settings->endGroup();
|
|
|
|
|
|
|
|
_settings->endGroup();
|
2010-01-13 21:32:20 -05:00
|
|
|
|
|
|
|
QString res;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
emit gwAdded();
|
2010-01-07 19:12:54 -05:00
|
|
|
}
|
|
|
|
|
2010-01-07 18:00:34 -05:00
|
|
|
void AccountDialog::changeEvent(QEvent *e)
|
|
|
|
{
|
|
|
|
QDialog::changeEvent(e);
|
|
|
|
switch (e->type()) {
|
|
|
|
case QEvent::LanguageChange:
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|