Properly remove account. Requires http://jira.freeswitch.org/browse/MODENDP-284
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16476 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
07de75014a
commit
a9f33bc1a6
|
@ -12,6 +12,7 @@
|
||||||
#define FSCOMM_GW_STATE_FAIL_WAIT 6
|
#define FSCOMM_GW_STATE_FAIL_WAIT 6
|
||||||
#define FSCOMM_GW_STATE_EXPIRED 7
|
#define FSCOMM_GW_STATE_EXPIRED 7
|
||||||
#define FSCOMM_GW_STATE_NOREG 8
|
#define FSCOMM_GW_STATE_NOREG 8
|
||||||
|
#define FSCOMM_GW_STATE_NOAVAIL 9
|
||||||
|
|
||||||
|
|
||||||
static QString fscomm_gw_state_names[] = {
|
static QString fscomm_gw_state_names[] = {
|
||||||
|
@ -23,7 +24,8 @@ static QString fscomm_gw_state_names[] = {
|
||||||
QString("Failed"),
|
QString("Failed"),
|
||||||
QString("Failed"),
|
QString("Failed"),
|
||||||
QString("Expired"),
|
QString("Expired"),
|
||||||
QString("Not applicable")
|
QString("Not applicable"),
|
||||||
|
QString("Not available")
|
||||||
};
|
};
|
||||||
|
|
||||||
class Account {
|
class Account {
|
||||||
|
|
|
@ -341,16 +341,9 @@ void FSHost::generalEventHandler(switch_event_t *event)
|
||||||
{
|
{
|
||||||
QString state = switch_event_get_header_nil(event, "State");
|
QString state = switch_event_get_header_nil(event, "State");
|
||||||
QString gw = switch_event_get_header_nil(event, "Gateway");
|
QString gw = switch_event_get_header_nil(event, "Gateway");
|
||||||
QSharedPointer<Account> acc;
|
QSharedPointer<Account> acc = _accounts.value(gw);
|
||||||
if (!_accounts.contains(gw))
|
if (acc.isNull())
|
||||||
{
|
return;
|
||||||
Account * accPtr = new Account(gw);
|
|
||||||
acc = QSharedPointer<Account>(accPtr);
|
|
||||||
_accounts.insert(gw, acc);
|
|
||||||
emit newAccount(acc);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
acc = _accounts.value(gw);
|
|
||||||
|
|
||||||
if (state == "TRYING") {
|
if (state == "TRYING") {
|
||||||
acc.data()->setState(FSCOMM_GW_STATE_TRYING);
|
acc.data()->setState(FSCOMM_GW_STATE_TRYING);
|
||||||
|
@ -381,9 +374,19 @@ void FSHost::generalEventHandler(switch_event_t *event)
|
||||||
emit accountStateChange(acc);
|
emit accountStateChange(acc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (strcmp(event->subclass_name, "fscomm::acc_removed") == 0)
|
else if (strcmp(event->subclass_name, "sofia::gateway_add") == 0)
|
||||||
{
|
{
|
||||||
QSharedPointer<Account> acc = _accounts.take(switch_event_get_header_nil(event, "acc_name"));
|
QString gw = switch_event_get_header_nil(event, "Gateway");
|
||||||
|
Account * accPtr = new Account(gw);
|
||||||
|
QSharedPointer<Account> acc = QSharedPointer<Account>(accPtr);
|
||||||
|
acc.data()->setState(FSCOMM_GW_STATE_NOAVAIL);
|
||||||
|
_accounts.insert(gw, acc);
|
||||||
|
emit newAccount(acc);
|
||||||
|
}
|
||||||
|
else if (strcmp(event->subclass_name, "sofia::gateway_del") == 0)
|
||||||
|
{
|
||||||
|
QSharedPointer<Account> acc = _accounts.take(switch_event_get_header_nil(event, "Gateway"));
|
||||||
|
if (!acc.isNull())
|
||||||
emit delAccount(acc);
|
emit delAccount(acc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -112,6 +112,18 @@ void AccountDialog::writeConfig()
|
||||||
|
|
||||||
_settings->beginGroup(_accId);
|
_settings->beginGroup(_accId);
|
||||||
|
|
||||||
|
if (!g_FSHost.getAccountByUUID(_accId).isNull())
|
||||||
|
{
|
||||||
|
QString res;
|
||||||
|
QString arg = QString("profile softphone killgw %1").arg(g_FSHost.getAccountByUUID(_accId).data()->getName());
|
||||||
|
|
||||||
|
if (g_FSHost.sendCmd("sofia", arg.toAscii().data() , &res) != SWITCH_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not killgw %s from profile softphone.\n",
|
||||||
|
g_FSHost.getAccountByUUID(_accId).data()->getName().toAscii().data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_settings->beginGroup("gateway/attrs");
|
_settings->beginGroup("gateway/attrs");
|
||||||
_settings->setValue("name", ui->sofiaGwNameEdit->text());
|
_settings->setValue("name", ui->sofiaGwNameEdit->text());
|
||||||
_settings->endGroup();
|
_settings->endGroup();
|
||||||
|
|
|
@ -13,11 +13,6 @@ PrefAccounts::PrefAccounts(Ui::PrefDialog *ui) :
|
||||||
connect(_ui->sofiaGwEditBtn, SIGNAL(clicked()), this, SLOT(editAccountBtnClicked()));
|
connect(_ui->sofiaGwEditBtn, SIGNAL(clicked()), this, SLOT(editAccountBtnClicked()));
|
||||||
|
|
||||||
_ui->accountsTable->horizontalHeader()->setStretchLastSection(true);
|
_ui->accountsTable->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
|
||||||
if (switch_event_reserve_subclass(FSCOMM_EVENT_ACC_REMOVED) != SWITCH_STATUS_SUCCESS) {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrefAccounts::addAccountBtnClicked()
|
void PrefAccounts::addAccountBtnClicked()
|
||||||
|
@ -97,9 +92,14 @@ void PrefAccounts::remAccountBtnClicked()
|
||||||
QSharedPointer<Account> acc = g_FSHost.getAccountByUUID(item->data(Qt::UserRole).toString());
|
QSharedPointer<Account> acc = g_FSHost.getAccountByUUID(item->data(Qt::UserRole).toString());
|
||||||
if (!acc.isNull())
|
if (!acc.isNull())
|
||||||
{
|
{
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "acc_name", acc.data()->getName().toAscii().data());
|
QString res;
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "acc_uuid", acc.data()->getUUID().toAscii().data());
|
QString arg = QString("profile softphone killgw %1").arg(acc.data()->getName());
|
||||||
switch_event_fire(&event);
|
|
||||||
|
if (g_FSHost.sendCmd("sofia", arg.toAscii().data() , &res) != SWITCH_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not killgw %s from profile softphone.\n",
|
||||||
|
acc.data()->getName().toAscii().data());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ui->accountsTable->removeRow(row-offset);
|
_ui->accountsTable->removeRow(row-offset);
|
||||||
|
@ -108,16 +108,7 @@ void PrefAccounts::remAccountBtnClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
readConfig(false);
|
||||||
QString res;
|
|
||||||
_settings->sync();
|
|
||||||
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()
|
||||||
|
@ -125,7 +116,7 @@ void PrefAccounts::writeConfig()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrefAccounts::readConfig()
|
void PrefAccounts::readConfig(bool reload)
|
||||||
{
|
{
|
||||||
|
|
||||||
_ui->accountsTable->clearContents();
|
_ui->accountsTable->clearContents();
|
||||||
|
@ -155,6 +146,8 @@ void PrefAccounts::readConfig()
|
||||||
|
|
||||||
_settings->endGroup();
|
_settings->endGroup();
|
||||||
|
|
||||||
|
if (reload)
|
||||||
|
{
|
||||||
QString res;
|
QString res;
|
||||||
_settings->sync();
|
_settings->sync();
|
||||||
if (g_FSHost.sendCmd("sofia", "profile softphone rescan", &res) != SWITCH_STATUS_SUCCESS)
|
if (g_FSHost.sendCmd("sofia", "profile softphone rescan", &res) != SWITCH_STATUS_SUCCESS)
|
||||||
|
@ -162,6 +155,7 @@ void PrefAccounts::readConfig()
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not rescan the softphone profile.\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not rescan the softphone profile.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_ui->accountsTable->rowCount() == 1)
|
if (_ui->accountsTable->rowCount() == 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@ public:
|
||||||
void writeConfig();
|
void writeConfig();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void readConfig();
|
void readConfig(bool reload=true);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void addAccountBtnClicked();
|
void addAccountBtnClicked();
|
||||||
|
|
Loading…
Reference in New Issue