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

This is really fun. We can run freeswitch under the loop of this small…

This is really fun. We can run freeswitch under the loop of this small application. Lets start hacking the softphone!

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk/contrib@16101 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 22de5d10
# #####################################
# version check qt
# #####################################
contains(QT_VERSION, ^4\.[0-4]\..*) {
message("Cannot build FsGui with Qt version $$QT_VERSION.")
error("Use at least Qt 4.5.")
}
QT += xml
TARGET = fsphone
TEMPLATE = app
INCLUDEPATH = ../../../src/include \
../../../libs/apr/include \
../../../libs/libteletone/src
LIBS = -L../../../.libs \
-lfreeswitch \
-lm \
-lcrypt \
-lrt
# This is here to comply with the default freeswitch installation
QMAKE_LFLAGS += -Wl,-rpath,/usr/local/freeswitch/lib
SOURCES += main.cpp \
mainwindow.cpp \
fshost.cpp
HEADERS += mainwindow.h \
fshost.h
FORMS += mainwindow.ui
#include "fshost.h"
FSHost::FSHost(QObject *parent) :
QThread(parent)
{
/* Initialize libs & globals */
printf("Initializing globals...\n");
switch_core_setrlimits();
switch_core_set_globals();
}
FSHost::~FSHost()
{
switch_status_t destroy_status;
/* When the runtime loop exits, its time to shutdown */
destroy_status = switch_core_destroy();
wait();
}
void FSHost::run(void)
{
switch_core_flag_t flags = SCF_USE_SQL;
const char *err = NULL;
switch_bool_t console = SWITCH_FALSE;
/* If you need to override configuration directories, you need to change them in the SWITCH_GLOBAL_dirs global structure */
printf("Initializing core...\n");
/* Initialize the core and load modules, that will startup FS completely */
if (switch_core_init_and_modload(flags, console, &err) != SWITCH_STATUS_SUCCESS) {
fprintf(stderr, "Failed to initialize FreeSWITCH's core: %s\n", err);
return;
}
printf("Everything OK, Entering runtime loop.\n");
/* 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);
}
#ifndef FSHOST_H
#define FSHOST_H
#include <QThread>
#include <switch.h>
class FSHost : public QThread
{
Q_OBJECT
public:
explicit FSHost(QObject *parent = 0);
~FSHost(void);
protected:
void run(void);
signals:
public slots:
};
#endif // FSHOST_H
#include <QtGui/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->fshost = new FSHost();
this->fshost->start();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Anthony Minessale II <anthm@freeswitch.org>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Joao Mesquita <jmesquita@freeswitch.org>
*
*
*
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <fshost.h>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
protected:
void changeEvent(QEvent *e);
private:
Ui::MainWindow *ui;
FSHost *fshost;
};
#endif // MAINWINDOW_H
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<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>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论