Fix editing accounts and add more descriptive information of why it fails.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16504 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
João Mesquita 2010-01-24 20:18:24 +00:00
parent 62341a9526
commit e3ea7c61bb
6 changed files with 30 additions and 5 deletions

View File

@ -4,6 +4,9 @@
Account::Account(QString name) :
_name(name)
{
_statusCode = QString();
_statusPhrase = QString();
QSettings settings;
settings.beginGroup("FreeSWITCH/conf/sofia.conf/profiles/profile/gateways");
foreach(QString g, settings.childGroups())
@ -12,7 +15,17 @@ Account::Account(QString name) :
if(settings.value("gateway/attrs/name").toString() == name)
{
_uuid = g;
settings.endGroup();
break;
}
settings.endGroup();
}
}
QString Account::getStateName()
{
if (_statusPhrase.isEmpty())
return fscomm_gw_state_names[_state];
return QString("%1 - %2").arg(fscomm_gw_state_names[_state], _statusPhrase);
}

View File

@ -35,13 +35,17 @@ public:
QString getName() { return _name; }
void setState(int state) { _state = state; }
int getState() { return _state; }
QString getStateName() { return fscomm_gw_state_names[_state]; }
QString getStateName();
QString getUUID() { return _uuid; }
void setStausCode(QString code) { _statusCode = code; }
void setStatusPhrase(QString phrase) { _statusPhrase = phrase; }
private:
QString _name;
int _state;
QString _uuid;
QString _statusCode;
QString _statusPhrase;
};
#endif // ACCOUNT_H

View File

@ -49,7 +49,6 @@ class Call {
public:
Call();
Call(int call_id, QString cid_name, QString cid_number, fscomm_call_direction_t direction, QString uuid);
/*~Call() { qDebug() << "I am being freed uuid: " << _uuid; }*/
QString getCidName(void) { return _cid_name; }
QString getCidNumber(void) { return _cid_number; }
int getCallID(void) { return _call_id; }

View File

@ -346,30 +346,38 @@ void FSHost::generalEventHandler(switch_event_t *event)
return;
if (state == "TRYING") {
acc.data()->setStatusPhrase(switch_event_get_header_nil(event, "Phrase"));
acc.data()->setState(FSCOMM_GW_STATE_TRYING);
emit accountStateChange(acc);
} else if (state == "REGISTER") {
acc.data()->setStatusPhrase(switch_event_get_header_nil(event, "Phrase"));
acc.data()->setState(FSCOMM_GW_STATE_REGISTER);
emit accountStateChange(acc);
} else if (state == "REGED") {
acc.data()->setStatusPhrase(switch_event_get_header_nil(event, "Phrase"));
acc.data()->setState(FSCOMM_GW_STATE_REGED);
emit accountStateChange(acc);
} else if (state == "UNREGED") {
acc.data()->setStatusPhrase(switch_event_get_header_nil(event, "Phrase"));
acc.data()->setState(FSCOMM_GW_STATE_UNREGED);
emit accountStateChange(acc);
} else if (state == "UNREGISTER") {
acc.data()->setStatusPhrase(switch_event_get_header_nil(event, "Phrase"));
acc.data()->setState(FSCOMM_GW_STATE_UNREGISTER);
emit accountStateChange(acc);
} else if (state =="FAILED") {
acc.data()->setStatusPhrase(switch_event_get_header_nil(event, "Phrase"));
acc.data()->setState(FSCOMM_GW_STATE_FAILED);
emit accountStateChange(acc);
} else if (state == "FAIL_WAIT") {
acc.data()->setState(FSCOMM_GW_STATE_FAIL_WAIT);
emit accountStateChange(acc);
} else if (state == "EXPIRED") {
acc.data()->setStatusPhrase(switch_event_get_header_nil(event, "Phrase"));
acc.data()->setState(FSCOMM_GW_STATE_EXPIRED);
emit accountStateChange(acc);
} else if (state == "NOREG") {
acc.data()->setStatusPhrase(switch_event_get_header_nil(event, "Phrase"));
acc.data()->setState(FSCOMM_GW_STATE_NOREG);
emit accountStateChange(acc);
}

View File

@ -168,6 +168,7 @@ void MainWindow::coreLoadingError(QString err)
void MainWindow::accountAdd(QSharedPointer<Account> acc)
{
qDebug() << "Adding: " << acc.data()->getName();
ui->tableAccounts->setRowCount(ui->tableAccounts->rowCount()+1);
QTableWidgetItem *gwField = new QTableWidgetItem(acc.data()->getName());
QTableWidgetItem *stField = new QTableWidgetItem(acc.data()->getStateName());
@ -180,16 +181,17 @@ void MainWindow::accountAdd(QSharedPointer<Account> acc)
void MainWindow::accountDel(QSharedPointer<Account> acc)
{
qDebug() << "Deleting: " << acc.data()->getName();
foreach (QTableWidgetItem *i, ui->tableAccounts->findItems(acc.data()->getName(), Qt::MatchExactly))
{
if (i->text() == acc.data()->getName())
{
ui->tableAccounts->removeRow(i->row());
ui->tableAccounts->setRowCount(ui->tableAccounts->rowCount()-1);
//ui->tableAccounts->setRowCount(ui->tableAccounts->rowCount()-1);
ui->tableAccounts->resizeColumnsToContents();
ui->tableAccounts->resizeRowsToContents();
ui->tableAccounts->horizontalHeader()->setStretchLastSection(true);
return;
break;
}
}
}

View File

@ -183,7 +183,6 @@ static switch_status_t do_config(void)
settings.beginGroup("FreeSWITCH/conf");
if (settings.childGroups().isEmpty())
{
qDebug() << "We are settings default.";
setQSettingsDefaults();
}
settings.endGroup();