提交 8690f6a9 authored 作者: João Mesquita's avatar João Mesquita

Added a couple of API calls from the interface. We still need to shutdown properly.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk/contrib@16102 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 deded589
...@@ -32,11 +32,21 @@ void FSHost::run(void) ...@@ -32,11 +32,21 @@ void FSHost::run(void)
} }
printf("Everything OK, Entering runtime loop.\n"); 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 /* 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 * If its false, it initializes the libedit for the console, then does the same thing
*/ */
switch_core_runtime_loop(!console); switch_core_runtime_loop(!console);
fflush(stdout); 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;
}
...@@ -10,13 +10,13 @@ Q_OBJECT ...@@ -10,13 +10,13 @@ Q_OBJECT
public: public:
explicit FSHost(QObject *parent = 0); explicit FSHost(QObject *parent = 0);
~FSHost(void); ~FSHost(void);
switch_status_t sendCmd(const char *cmd, const char *args, QString *res);
protected: protected:
void run(void); void run(void);
signals: signals:
void ready(void);
public slots:
}; };
......
...@@ -7,6 +7,11 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -7,6 +7,11 @@ MainWindow::MainWindow(QWidget *parent) :
{ {
ui->setupUi(this); ui->setupUi(this);
this->fshost = new FSHost(); 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(); this->fshost->start();
} }
...@@ -15,6 +20,31 @@ MainWindow::~MainWindow() ...@@ -15,6 +20,31 @@ MainWindow::~MainWindow()
delete ui; 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) void MainWindow::changeEvent(QEvent *e)
{ {
QMainWindow::changeEvent(e); QMainWindow::changeEvent(e);
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <QMainWindow> #include <QMainWindow>
#include <fshost.h> #include <fshost.h>
#include <switch.h>
namespace Ui { namespace Ui {
class MainWindow; class MainWindow;
...@@ -49,6 +50,11 @@ public: ...@@ -49,6 +50,11 @@ public:
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
private slots:
void fshostReady();
void paDevlist();
void showCodecs();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
FSHost *fshost; FSHost *fshost;
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>MainWindow</class> <class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" > <widget class="QMainWindow" name="MainWindow">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>600</width> <width>691</width>
<height>400</height> <height>334</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string>MainWindow</string> <string>MainWindow</string>
</property> </property>
<widget class="QMenuBar" name="menuBar" /> <widget class="QWidget" name="centralWidget">
<widget class="QToolBar" name="mainToolBar" /> <layout class="QHBoxLayout" name="horizontalLayout">
<widget class="QWidget" name="centralWidget" /> <item>
<widget class="QStatusBar" name="statusBar" /> <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> </widget>
<layoutDefault spacing="6" margin="11" /> <layoutdefault spacing="6" margin="11"/>
<pixmapfunction></pixmapfunction>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论