Diff
Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp (16101 => 16102)
--- freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp 2009-12-31 04:09:22 UTC (rev 16101)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp 2009-12-31 05:08:40 UTC (rev 16102)
@@ -32,11 +32,21 @@
}
printf("Everything OK, Entering runtime loop.\n");
-
+ emit ready();
/* Go into the runtime loop. If the argument is true, this basically sets runtime.running = 1 and loops while that is set
* If its false, it initializes the libedit for the console, then does the same thing
*/
switch_core_runtime_loop(!console);
-
fflush(stdout);
}
+
+switch_status_t FSHost::sendCmd(const char *cmd, const char *args, QString *res)
+{
+ switch_status_t status = SWITCH_STATUS_FALSE;
+ switch_stream_handle_t stream = { 0 };
+ SWITCH_STANDARD_STREAM(stream);
+ status = switch_api_execute(cmd, args, NULL, &stream);
+ *res = switch_str_nil((char *) stream.data);
+
+ return status;
+}
Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h (16101 => 16102)
--- freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h 2009-12-31 04:09:22 UTC (rev 16101)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h 2009-12-31 05:08:40 UTC (rev 16102)
@@ -10,14 +10,14 @@
public:
explicit FSHost(QObject *parent = 0);
~FSHost(void);
+ switch_status_t sendCmd(const char *cmd, const char *args, QString *res);
protected:
void run(void);
signals:
+ void ready(void);
-public slots:
-
};
#endif // FSHOST_H
Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.cpp (16101 => 16102)
--- freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.cpp 2009-12-31 04:09:22 UTC (rev 16101)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.cpp 2009-12-31 05:08:40 UTC (rev 16102)
@@ -7,6 +7,11 @@
{
ui->setupUi(this);
this->fshost = new FSHost();
+
+ connect(this->fshost, SIGNAL(ready()),this, SLOT(fshostReady()));
+ connect(ui->paDevlistBtn, SIGNAL(clicked()), this, SLOT(paDevlist()));
+ connect(ui->showCodecsBtn, SIGNAL(clicked()), this, SLOT(showCodecs()));
+
this->fshost->start();
}
@@ -15,6 +20,31 @@
delete ui;
}
+void MainWindow::fshostReady()
+{
+ ui->statusBar->showMessage("FreeSWITCH is ready!", 0);
+}
+
+void MainWindow::paDevlist()
+{
+ QString result;
+ if (this->fshost->sendCmd("pa", "devlist as xml", &result) == SWITCH_STATUS_FALSE) {
+ ui->textEdit->setText("Error sending that command");
+ }
+
+ ui->textEdit->setText(result);
+}
+
+void MainWindow::showCodecs()
+{
+ QString result;
+ if (this->fshost->sendCmd("show", "codecs as xml", &result) == SWITCH_STATUS_FALSE) {
+ ui->textEdit->setText("Error sending that command");
+ }
+
+ ui->textEdit->setText(result);
+}
+
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.h (16101 => 16102)
--- freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.h 2009-12-31 04:09:22 UTC (rev 16101)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.h 2009-12-31 05:08:40 UTC (rev 16102)
@@ -35,6 +35,7 @@
#include <QMainWindow>
#include <fshost.h>
+#include <switch.h>
namespace Ui {
class MainWindow;
@@ -49,6 +50,11 @@
protected:
void changeEvent(QEvent *e);
+private slots:
+ void fshostReady();
+ void paDevlist();
+ void showCodecs();
+
private:
Ui::MainWindow *ui;
FSHost *fshost;
Modified: freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.ui (16101 => 16102)
--- freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.ui 2009-12-31 04:09:22 UTC (rev 16101)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.ui 2009-12-31 05:08:40 UTC (rev 16102)
@@ -1,24 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow" >
- <property name="geometry" >
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>600</width>
- <height>400</height>
+ <width>691</width>
+ <height>334</height>
</rect>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string>MainWindow</string>
</property>
- <widget class="QMenuBar" name="menuBar" />
- <widget class="QToolBar" name="mainToolBar" />
- <widget class="QWidget" name="centralWidget" />
- <widget class="QStatusBar" name="statusBar" />
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTextEdit" name="textEdit"/>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QPushButton" name="paDevlistBtn">
+ <property name="text">
+ <string>pa devlist</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="showCodecsBtn">
+ <property name="text">
+ <string>show codecs</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>691</width>
+ <height>24</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QToolBar" name="mainToolBar">
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ </widget>
+ <widget class="QStatusBar" name="statusBar"/>
</widget>
- <layoutDefault spacing="6" margin="11" />
- <pixmapfunction></pixmapfunction>
+ <layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>