mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-29 05:30:14 +00:00
Configuration is more mature now. We can add and remove several accounts. Still have to edit account and start doing some work on the events to treat them right.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16298 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
0b4a7b63a5
commit
18d33240b8
@ -91,7 +91,7 @@ void XMLBinding::parseGroup(QXmlStreamWriter *streamWriter, QString group)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (group == "params")
|
if (group == "params" || group == "customParams")
|
||||||
{
|
{
|
||||||
_settings->beginGroup(group);
|
_settings->beginGroup(group);
|
||||||
foreach(QString param, _settings->childKeys())
|
foreach(QString param, _settings->childKeys())
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "ui_accountdialog.h"
|
#include "ui_accountdialog.h"
|
||||||
#include "fshost.h"
|
#include "fshost.h"
|
||||||
|
|
||||||
AccountDialog::AccountDialog(int accId, QWidget *parent) :
|
AccountDialog::AccountDialog(QString accId, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
_accId(accId),
|
_accId(accId),
|
||||||
ui(new Ui::AccountDialog)
|
ui(new Ui::AccountDialog)
|
||||||
@ -61,7 +61,7 @@ void AccountDialog::writeConfig()
|
|||||||
{
|
{
|
||||||
_settings->beginGroup("FreeSWITCH/conf/sofia.conf/profiles/profile/gateways");
|
_settings->beginGroup("FreeSWITCH/conf/sofia.conf/profiles/profile/gateways");
|
||||||
|
|
||||||
_settings->beginGroup(QString::number(_accId));
|
_settings->beginGroup(_accId);
|
||||||
|
|
||||||
_settings->beginGroup("gateway/attrs");
|
_settings->beginGroup("gateway/attrs");
|
||||||
_settings->setValue("name", ui->sofiaGwNameEdit->text());
|
_settings->setValue("name", ui->sofiaGwNameEdit->text());
|
||||||
@ -77,6 +77,9 @@ void AccountDialog::writeConfig()
|
|||||||
_settings->setValue("register", ui->sofiaGwRegisterCombo->currentText());
|
_settings->setValue("register", ui->sofiaGwRegisterCombo->currentText());
|
||||||
_settings->setValue("register-transport", ui->sofiaGwRegisterTransportCombo->currentText());
|
_settings->setValue("register-transport", ui->sofiaGwRegisterTransportCombo->currentText());
|
||||||
_settings->setValue("retry-seconds", ui->sofiaGwRetrySecondsSpin->value());
|
_settings->setValue("retry-seconds", ui->sofiaGwRetrySecondsSpin->value());
|
||||||
|
_settings->endGroup();
|
||||||
|
|
||||||
|
_settings->beginGroup("gateway/customParams");
|
||||||
for (int i = 0; i< ui->sofiaExtraParamTable->rowCount(); i++)
|
for (int i = 0; i< ui->sofiaExtraParamTable->rowCount(); i++)
|
||||||
{
|
{
|
||||||
_settings->setValue(ui->sofiaExtraParamTable->item(i, 0)->text(),
|
_settings->setValue(ui->sofiaExtraParamTable->item(i, 0)->text(),
|
||||||
@ -97,6 +100,27 @@ void AccountDialog::writeConfig()
|
|||||||
emit gwAdded();
|
emit gwAdded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AccountDialog::clear()
|
||||||
|
{
|
||||||
|
ui->sofiaExtraParamTable->clearContents();
|
||||||
|
ui->sofiaExtraParamTable->setRowCount(0);
|
||||||
|
|
||||||
|
ui->sofiaGwNameEdit->clear();
|
||||||
|
ui->sofiaGwUsernameEdit->clear();
|
||||||
|
ui->sofiaGwRealmEdit->clear();
|
||||||
|
ui->sofiaGwPasswordEdit->clear();
|
||||||
|
ui->sofiaGwExtensionEdit->clear();
|
||||||
|
ui->sofiaGwExpireSecondsSpin->setValue(60);
|
||||||
|
ui->sofiaGwRegisterCombo->setCurrentIndex(0);
|
||||||
|
ui->sofiaGwRegisterTransportCombo->setCurrentIndex(0);
|
||||||
|
ui->sofiaGwRetrySecondsSpin->setValue(30);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AccountDialog::setAccId(QString accId)
|
||||||
|
{
|
||||||
|
_accId = accId;
|
||||||
|
}
|
||||||
|
|
||||||
void AccountDialog::changeEvent(QEvent *e)
|
void AccountDialog::changeEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
QDialog::changeEvent(e);
|
QDialog::changeEvent(e);
|
||||||
|
@ -12,8 +12,10 @@ class QSettings;
|
|||||||
class AccountDialog : public QDialog {
|
class AccountDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AccountDialog(int accId, QWidget *parent = 0);
|
AccountDialog(QString accId, QWidget *parent = 0);
|
||||||
~AccountDialog();
|
~AccountDialog();
|
||||||
|
void clear();
|
||||||
|
void setAccId(QString);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void gwAdded();
|
void gwAdded();
|
||||||
@ -27,7 +29,7 @@ protected:
|
|||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _accId;
|
QString _accId;
|
||||||
Ui::AccountDialog *ui;
|
Ui::AccountDialog *ui;
|
||||||
QSettings *_settings;
|
QSettings *_settings;
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "prefaccounts.h"
|
#include "prefaccounts.h"
|
||||||
#include "accountdialog.h"
|
#include "accountdialog.h"
|
||||||
|
#include "fshost.h"
|
||||||
|
|
||||||
PrefAccounts::PrefAccounts(Ui::PrefDialog *ui) :
|
PrefAccounts::PrefAccounts(Ui::PrefDialog *ui) :
|
||||||
_ui(ui)
|
_ui(ui)
|
||||||
@ -8,21 +9,70 @@ PrefAccounts::PrefAccounts(Ui::PrefDialog *ui) :
|
|||||||
_settings = new QSettings();
|
_settings = new QSettings();
|
||||||
_accDlg = NULL;
|
_accDlg = NULL;
|
||||||
connect(_ui->sofiaGwAddBtn, SIGNAL(clicked()), this, SLOT(addAccountBtnClicked()));
|
connect(_ui->sofiaGwAddBtn, SIGNAL(clicked()), this, SLOT(addAccountBtnClicked()));
|
||||||
|
connect(_ui->sofiaGwRemBtn, SIGNAL(clicked()), this, SLOT(remAccountBtnClicked()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrefAccounts::addAccountBtnClicked()
|
void PrefAccounts::addAccountBtnClicked()
|
||||||
{
|
{
|
||||||
if (!_accDlg)
|
if (!_accDlg)
|
||||||
{
|
{
|
||||||
_accDlg = new AccountDialog(_ui->accountsTable->rowCount());
|
QString uuid;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
_accDlg = new AccountDialog(uuid);
|
||||||
connect(_accDlg, SIGNAL(gwAdded()), this, SLOT(readConfig()));
|
connect(_accDlg, SIGNAL(gwAdded()), this, SLOT(readConfig()));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QString uuid;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
_accDlg->setAccId(uuid);
|
||||||
|
_accDlg->clear();
|
||||||
|
}
|
||||||
|
|
||||||
_accDlg->show();
|
_accDlg->show();
|
||||||
_accDlg->raise();
|
_accDlg->raise();
|
||||||
_accDlg->activateWindow();
|
_accDlg->activateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrefAccounts::remAccountBtnClicked()
|
||||||
|
{
|
||||||
|
QList<QTableWidgetSelectionRange> sel = _ui->accountsTable->selectedRanges();
|
||||||
|
int offset =0;
|
||||||
|
|
||||||
|
foreach(QTableWidgetSelectionRange range, sel)
|
||||||
|
{
|
||||||
|
for(int row = range.topRow(); row<=range.bottomRow(); row++)
|
||||||
|
{
|
||||||
|
QTableWidgetItem *item = _ui->accountsTable->item(row-offset,0);
|
||||||
|
|
||||||
|
_settings->beginGroup("FreeSWITCH/conf/sofia.conf/profiles/profile/gateways");
|
||||||
|
_settings->remove(item->data(Qt::UserRole).toString());
|
||||||
|
_settings->endGroup();
|
||||||
|
_ui->accountsTable->removeRow(row-offset);
|
||||||
|
offset++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offset > 0)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
readConfig();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PrefAccounts::writeConfig()
|
void PrefAccounts::writeConfig()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -41,9 +91,11 @@ void PrefAccounts::readConfig()
|
|||||||
_settings->beginGroup(accId);
|
_settings->beginGroup(accId);
|
||||||
_settings->beginGroup("gateway/attrs");
|
_settings->beginGroup("gateway/attrs");
|
||||||
QTableWidgetItem *item0 = new QTableWidgetItem(_settings->value("name").toString());
|
QTableWidgetItem *item0 = new QTableWidgetItem(_settings->value("name").toString());
|
||||||
|
item0->setData(Qt::UserRole, accId);
|
||||||
_settings->endGroup();
|
_settings->endGroup();
|
||||||
_settings->beginGroup("gateway/params");
|
_settings->beginGroup("gateway/params");
|
||||||
QTableWidgetItem *item1 = new QTableWidgetItem(_settings->value("username").toString());
|
QTableWidgetItem *item1 = new QTableWidgetItem(_settings->value("username").toString());
|
||||||
|
item1->setData(Qt::UserRole, accId);
|
||||||
_settings->endGroup();
|
_settings->endGroup();
|
||||||
_settings->endGroup();
|
_settings->endGroup();
|
||||||
_ui->accountsTable->setRowCount(_ui->accountsTable->rowCount()+1);
|
_ui->accountsTable->setRowCount(_ui->accountsTable->rowCount()+1);
|
||||||
|
@ -18,6 +18,8 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void addAccountBtnClicked();
|
void addAccountBtnClicked();
|
||||||
|
void editAccountBtnClicked();
|
||||||
|
void remAccountBtnClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::PrefDialog *_ui;
|
Ui::PrefDialog *_ui;
|
||||||
|
@ -96,7 +96,7 @@
|
|||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QStackedWidget" name="stackedWidget">
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="generalPage">
|
<widget class="QWidget" name="generalPage">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
@ -168,6 +168,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="sofiaGwEditBtn">
|
<widget class="QPushButton" name="sofiaGwEditBtn">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Edit</string>
|
<string>Edit</string>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user