提交 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)
}
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;
}
......@@ -10,13 +10,13 @@ Q_OBJECT
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:
public slots:
void ready(void);
};
......
......@@ -7,6 +7,11 @@ MainWindow::MainWindow(QWidget *parent) :
{
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 @@ MainWindow::~MainWindow()
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);
......
......@@ -35,6 +35,7 @@
#include <QMainWindow>
#include <fshost.h>
#include <switch.h>
namespace Ui {
class MainWindow;
......@@ -49,6 +50,11 @@ public:
protected:
void changeEvent(QEvent *e);
private slots:
void fshostReady();
void paDevlist();
void showCodecs();
private:
Ui::MainWindow *ui;
FSHost *fshost;
......
<?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>
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论