Revision
16101
Author
jmesquita
Date
2009-12-30 22:09:22 -0600 (Wed, 30 Dec 2009)

Log Message

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

Added Paths

Diff

Added: freeswitch/trunk/contrib/jmesquita/FSPhone/FSPhone.pro (0 => 16101)


--- freeswitch/trunk/contrib/jmesquita/FSPhone/FSPhone.pro	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/FSPhone.pro	2009-12-31 04:09:22 UTC (rev 16101)
@@ -0,0 +1,28 @@
+# #####################################
+# 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

Added: freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp (0 => 16101)


--- freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.cpp	2009-12-31 04:09:22 UTC (rev 16101)
@@ -0,0 +1,42 @@
+#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);
+}

Added: freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h (0 => 16101)


--- freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/fshost.h	2009-12-31 04:09:22 UTC (rev 16101)
@@ -0,0 +1,23 @@
+#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

Added: freeswitch/trunk/contrib/jmesquita/FSPhone/main.cpp (0 => 16101)


--- freeswitch/trunk/contrib/jmesquita/FSPhone/main.cpp	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/main.cpp	2009-12-31 04:09:22 UTC (rev 16101)
@@ -0,0 +1,10 @@
+#include <QtGui/QApplication>
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    MainWindow w;
+    w.show();
+    return a.exec();
+}

Added: freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.cpp (0 => 16101)


--- freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.cpp	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.cpp	2009-12-31 04:09:22 UTC (rev 16101)
@@ -0,0 +1,28 @@
+#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;
+    }
+}

Added: freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.h (0 => 16101)


--- freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.h	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.h	2009-12-31 04:09:22 UTC (rev 16101)
@@ -0,0 +1,57 @@
+/*
+ * 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

Added: freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.ui (0 => 16101)


--- freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.ui	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/FSPhone/mainwindow.ui	2009-12-31 04:09:22 UTC (rev 16101)
@@ -0,0 +1,24 @@
+<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>