From e3ea7c61bb577a9799978f8f39307caabc6a616d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Mesquita?= Date: Sun, 24 Jan 2010 20:18:24 +0000 Subject: [PATCH] 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 --- fscomm/account.cpp | 13 +++++++++++++ fscomm/account.h | 6 +++++- fscomm/call.h | 1 - fscomm/fshost.cpp | 8 ++++++++ fscomm/mainwindow.cpp | 6 ++++-- fscomm/mod_qsettings/mod_qsettings.cpp | 1 - 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/fscomm/account.cpp b/fscomm/account.cpp index 9711818426..3309c01b6a 100644 --- a/fscomm/account.cpp +++ b/fscomm/account.cpp @@ -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); +} diff --git a/fscomm/account.h b/fscomm/account.h index 7a044151f3..302a112678 100644 --- a/fscomm/account.h +++ b/fscomm/account.h @@ -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 diff --git a/fscomm/call.h b/fscomm/call.h index b02459e4b9..6ec45d2076 100644 --- a/fscomm/call.h +++ b/fscomm/call.h @@ -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; } diff --git a/fscomm/fshost.cpp b/fscomm/fshost.cpp index 7acad440e8..69e732cc7a 100644 --- a/fscomm/fshost.cpp +++ b/fscomm/fshost.cpp @@ -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); } diff --git a/fscomm/mainwindow.cpp b/fscomm/mainwindow.cpp index e9a0d7baf0..3ff3b4f695 100644 --- a/fscomm/mainwindow.cpp +++ b/fscomm/mainwindow.cpp @@ -168,6 +168,7 @@ void MainWindow::coreLoadingError(QString err) void MainWindow::accountAdd(QSharedPointer 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 acc) void MainWindow::accountDel(QSharedPointer 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; } } } diff --git a/fscomm/mod_qsettings/mod_qsettings.cpp b/fscomm/mod_qsettings/mod_qsettings.cpp index bc3fb34e16..e8e873b5c7 100644 --- a/fscomm/mod_qsettings/mod_qsettings.cpp +++ b/fscomm/mod_qsettings/mod_qsettings.cpp @@ -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();