diff --git a/fscomm/conf/freeswitch.xml b/fscomm/conf/freeswitch.xml index 60d3190b78..0d1d5c0d63 100644 --- a/fscomm/conf/freeswitch.xml +++ b/fscomm/conf/freeswitch.xml @@ -7,7 +7,6 @@ - @@ -255,6 +254,7 @@ + diff --git a/fscomm/preferences/accountdialog.cpp b/fscomm/preferences/accountdialog.cpp index 819514ac96..aa8cddbecc 100644 --- a/fscomm/preferences/accountdialog.cpp +++ b/fscomm/preferences/accountdialog.cpp @@ -130,13 +130,7 @@ void AccountDialog::writeConfig() _settings->endGroup(); - 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(); + emit gwAdded(_accId); } void AccountDialog::clear() diff --git a/fscomm/preferences/accountdialog.h b/fscomm/preferences/accountdialog.h index 1a9504180c..9be1b6e26f 100644 --- a/fscomm/preferences/accountdialog.h +++ b/fscomm/preferences/accountdialog.h @@ -19,7 +19,7 @@ public: void readConfig(); signals: - void gwAdded(); + void gwAdded(QString); private slots: void writeConfig(); diff --git a/fscomm/preferences/prefaccounts.cpp b/fscomm/preferences/prefaccounts.cpp index 3694963234..ce70dd83ed 100644 --- a/fscomm/preferences/prefaccounts.cpp +++ b/fscomm/preferences/prefaccounts.cpp @@ -24,7 +24,8 @@ void PrefAccounts::addAccountBtnClicked() return; } _accDlg = new AccountDialog(uuid); - connect(_accDlg, SIGNAL(gwAdded()), this, SLOT(readConfig())); + connect(_accDlg, SIGNAL(gwAdded(QString)), this, SLOT(readConfig())); + connect(_accDlg, SIGNAL(gwAdded(QString)), this, SLOT(applyNewGw(QString))); } else { @@ -43,6 +44,26 @@ void PrefAccounts::addAccountBtnClicked() _accDlg->activateWindow(); } +void PrefAccounts::applyNewGw(QString accId) +{ + 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; + } + + if (_ui->accountsTable->rowCount() == 1) + { + _settings->beginGroup("FreeSWITCH/conf/globals"); + _settings->setValue("default_gateway",_settings->value("/attrs/name")); + _settings->endGroup(); + _settings->beginGroup(QString("FreeSWITCH/conf/sofia.conf/profiles/profile/gateways/%1/gateway").arg(accId)); + switch_core_set_variable("default_gateway",_settings->value("/attrs/name").toByteArray().data()); + _settings->endGroup(); + } +} + void PrefAccounts::editAccountBtnClicked() { QList selList = _ui->accountsTable->selectedRanges(); @@ -56,7 +77,7 @@ void PrefAccounts::editAccountBtnClicked() if (!_accDlg) { _accDlg = new AccountDialog(uuid); - connect(_accDlg, SIGNAL(gwAdded()), this, SLOT(readConfig())); + connect(_accDlg, SIGNAL(gwAdded(QString)), this, SLOT(readConfig())); } else { diff --git a/fscomm/preferences/prefaccounts.h b/fscomm/preferences/prefaccounts.h index 08ec5c18da..2a78c654d9 100644 --- a/fscomm/preferences/prefaccounts.h +++ b/fscomm/preferences/prefaccounts.h @@ -20,6 +20,7 @@ private slots: void addAccountBtnClicked(); void editAccountBtnClicked(); void remAccountBtnClicked(); + void applyNewGw(QString); private: Ui::PrefDialog *_ui; diff --git a/fscomm/preferences/prefdialog.cpp b/fscomm/preferences/prefdialog.cpp index 3edb4c8bdf..c615411591 100644 --- a/fscomm/preferences/prefdialog.cpp +++ b/fscomm/preferences/prefdialog.cpp @@ -28,6 +28,7 @@ void PrefDialog::writeConfig() { _mod_portaudio->writeConfig(); _mod_sofia->writeConfig(); + } void PrefDialog::changeEvent(QEvent *e)