Diff
Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp (16116 => 16117)
--- freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp 2010-01-02 03:59:01 UTC (rev 16116)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp 2010-01-02 06:37:46 UTC (rev 16117)
@@ -112,6 +112,29 @@
_active_calls.insert(uuid, call);
emit newOutgoingCall(uuid);
}
+ else if (strcmp(event->subclass_name, "sofia::gateway_state") == 0)
+ {
+ QString state = switch_event_get_header_nil(event, "State");
+ QString gw = switch_event_get_header_nil(event, "Gateway");
+ if (state == "TRYING")
+ emit gwStateChange(gw, FSPHONE_GW_STATE_TRYING);
+ else if (state == "REGISTER")
+ emit gwStateChange(gw, FSPHONE_GW_STATE_REGISTER);
+ else if (state == "REGED")
+ emit gwStateChange(gw, FSPHONE_GW_STATE_REGED);
+ else if (state == "UNREGED")
+ emit gwStateChange(gw, FSPHONE_GW_STATE_UNREGED);
+ else if (state == "UNREGISTER")
+ emit gwStateChange(gw, FSPHONE_GW_STATE_UNREGISTER);
+ else if (state =="FAILED")
+ emit gwStateChange(gw, FSPHONE_GW_STATE_FAILED);
+ else if (state == "FAIL_WAIT")
+ emit gwStateChange(gw, FSPHONE_GW_STATE_FAIL_WAIT);
+ else if (state == "EXPIRED")
+ emit gwStateChange(gw, FSPHONE_GW_STATE_EXPIRED);
+ else if (state == "NOREG")
+ emit gwStateChange(gw, FSPHONE_GW_STATE_NOREG);
+ }
else
{
printf("We got a not treated custom event: %s\n", (!zstr(event->subclass_name) ? event->subclass_name : "NULL"));
Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h (16116 => 16117)
--- freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h 2010-01-02 03:59:01 UTC (rev 16116)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h 2010-01-02 06:37:46 UTC (rev 16117)
@@ -7,6 +7,28 @@
class Call;
+#define FSPHONE_GW_STATE_TRYING 0
+#define FSPHONE_GW_STATE_REGISTER 1
+#define FSPHONE_GW_STATE_REGED 2
+#define FSPHONE_GW_STATE_UNREGED 3
+#define FSPHONE_GW_STATE_UNREGISTER 4
+#define FSPHONE_GW_STATE_FAILED 5
+#define FSPHONE_GW_STATE_FAIL_WAIT 6
+#define FSPHONE_GW_STATE_EXPIRED 7
+#define FSPHONE_GW_STATE_NOREG 8
+
+static const char *fsphone_gw_state_names[] = {
+ "TRYING",
+ "REGISTER",
+ "REGED",
+ "UNREGED",
+ "UNREGISTER",
+ "FAILED",
+ "FAIL_WAIT",
+ "EXPIRED",
+ "NOREG"
+};
+
class FSHost : public QThread
{
Q_OBJECT
@@ -15,6 +37,7 @@
switch_status_t sendCmd(const char *cmd, const char *args, QString *res);
void generalEventHandler(switch_event_t *event);
Call * getCallByUUID(QString uuid) { return _active_calls.value(uuid, NULL); }
+ QString getGwStateName(int id) { return fsphone_gw_state_names[id]; }
protected:
void run(void);
@@ -25,6 +48,7 @@
void answered(QString);
void newOutgoingCall(QString);
void hungup(QString);
+ void gwStateChange(QString, int);
private:
QHash<QString, Call*> _active_calls;
Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.cpp (16116 => 16117)
--- freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.cpp 2010-01-02 03:59:01 UTC (rev 16116)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.cpp 2010-01-02 06:37:46 UTC (rev 16117)
@@ -40,6 +40,7 @@
connect(&g_FSHost, SIGNAL(answered(QString)), this, SLOT(answered(QString)));
connect(&g_FSHost, SIGNAL(hungup(QString)), this, SLOT(hungup(QString)));
connect(&g_FSHost, SIGNAL(newOutgoingCall(QString)), this, SLOT(newOutgoingCall(QString)));
+ connect(&g_FSHost, SIGNAL(gwStateChange(QString,int)), this, SLOT(gwStateChanged(QString,int)));
connect(ui->newCallBtn, SIGNAL(clicked()), this, SLOT(makeCall()));
connect(ui->answerBtn, SIGNAL(clicked()), this, SLOT(paAnswer()));
@@ -57,6 +58,31 @@
g_FSHost.wait();
}
+void MainWindow::gwStateChanged(QString gw, int state)
+{
+ ui->statusBar->showMessage(tr("Account %1 is %2").arg(gw, g_FSHost.getGwStateName(state)));
+
+ /* TODO: This should be placed somewhere else when the config handler is here... */
+ QList<QTableWidgetItem *> match = ui->tableAccounts->findItems(gw, Qt::MatchExactly);
+ if (match.isEmpty())
+ {
+ /* Create the damn thing */
+ ui->tableAccounts->setRowCount(ui->tableAccounts->rowCount()+1);
+ QTableWidgetItem *gwField = new QTableWidgetItem(gw);
+ QTableWidgetItem *stField = new QTableWidgetItem(g_FSHost.getGwStateName(state));
+ ui->tableAccounts->setItem(0,0,gwField);
+ ui->tableAccounts->setItem(0,1,stField);
+ ui->tableAccounts->resizeColumnsToContents();
+ return;
+ }
+
+ QTableWidgetItem *gwField = match.at(0);
+ QTableWidgetItem *stField = ui->tableAccounts->item(gwField->row(),1);
+ stField->setText(g_FSHost.getGwStateName(state));
+ ui->tableAccounts->resizeColumnsToContents();
+
+}
+
void MainWindow::dialDTMF(QString dtmf)
{
QString result;
@@ -92,7 +118,7 @@
void MainWindow::fshostReady()
{
- ui->statusBar->showMessage("Ready", 0);
+ ui->statusBar->showMessage("Ready");
ui->newCallBtn->setEnabled(true);
ui->textEdit->setEnabled(true);
ui->textEdit->setText("Ready to dial and receive calls!");
@@ -131,7 +157,7 @@
}
ui->textEdit->setText("Click to dial number...");
- ui->statusBar->showMessage("Call hungup", 10);
+ ui->statusBar->showMessage("Call hungup");
ui->hangupBtn->setEnabled(false);
}
Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.h (16116 => 16117)
--- freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.h 2010-01-02 03:59:01 UTC (rev 16116)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.h 2010-01-02 06:37:46 UTC (rev 16117)
@@ -57,6 +57,7 @@
void dtmfDialed(QString);
private slots:
+ void gwStateChanged(QString, int);
void dialDTMF(QString);
void callListDoubleClick(QListWidgetItem *);
void makeCall();
Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.ui (16116 => 16117)
--- freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.ui 2010-01-02 03:59:01 UTC (rev 16116)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.ui 2010-01-02 06:37:46 UTC (rev 16117)
@@ -6,15 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
- <width>805</width>
- <height>500</height>
+ <width>579</width>
+ <height>541</height>
</rect>
</property>
<property name="windowTitle">
<string>FSPhone - A FreeSWITCH softphone</string>
</property>
<widget class="QWidget" name="centralWidget">
- <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
@@ -198,13 +198,78 @@
<property name="title">
<string>Active Calls</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_3">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QListWidget" name="listCalls"/>
</item>
</layout>
</widget>
</item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Active Accounts</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QTableWidget" name="tableAccounts">
+ <property name="alternatingRowColors">
+ <bool>false</bool>
+ </property>
+ <property name="selectionMode">
+ <enum>QAbstractItemView::NoSelection</enum>
+ </property>
+ <property name="selectionBehavior">
+ <enum>QAbstractItemView::SelectRows</enum>
+ </property>
+ <property name="showGrid">
+ <bool>false</bool>
+ </property>
+ <property name="cornerButtonEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="rowCount">
+ <number>0</number>
+ </property>
+ <attribute name="horizontalHeaderVisible">
+ <bool>true</bool>
+ </attribute>
+ <attribute name="horizontalHeaderCascadingSectionResizes">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="verticalHeaderVisible">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="verticalHeaderHighlightSections">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="verticalHeaderVisible">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="horizontalHeaderCascadingSectionResizes">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="horizontalHeaderVisible">
+ <bool>true</bool>
+ </attribute>
+ <attribute name="verticalHeaderHighlightSections">
+ <bool>false</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string>Account</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Status</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
</layout>
</item>
</layout>
@@ -214,7 +279,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>805</width>
+ <width>579</width>
<height>24</height>
</rect>
</property>