Revision
14234
Author
jmesquita
Date
2009-07-13 22:42:55 -0500 (Mon, 13 Jul 2009)

Log Message

We are now on the right track after anthm and Math got me on the right path.

Modified Paths

Added Paths

Removed Paths

Diff

Deleted: freeswitch/trunk/contrib/jmesquita/fsgui/esl_connection.cpp

Deleted: freeswitch/trunk/contrib/jmesquita/fsgui/esl_connection.h

Deleted: freeswitch/trunk/contrib/jmesquita/fsgui/fs_gui.cpp

Deleted: freeswitch/trunk/contrib/jmesquita/fsgui/fs_gui.h

Deleted: freeswitch/trunk/contrib/jmesquita/fsgui/fs_gui.ui

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/fsgui.pro (14233 => 14234)


--- freeswitch/trunk/contrib/jmesquita/fsgui/fsgui.pro	2009-07-14 02:00:00 UTC (rev 14233)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/fsgui.pro	2009-07-14 03:42:55 UTC (rev 14234)
@@ -1,17 +1,27 @@
-# -------------------------------------------------
-# Project created by QtCreator 2009-01-18T13:57:52
-# -------------------------------------------------
+
+DESTDIR = ./bin/
+message(The project will be installed in $$DESTDIR)
 TARGET = fs_gui
 TEMPLATE = app
-SOURCES += main.cpp \
-    fs_gui.cpp \
-    server_manager.cpp \
-    esl_connection.cpp
-INCLUDEPATH += ../../../libs/esl/src/include
-HEADERS += fs_gui.h \
-    server_manager.h \
-    esl_connection.h
-FORMS += fs_gui.ui \
-    server_manager.ui
+
+MOC_DIR = ./build/
+OBJECTS_DIR = ./build/
+UI_DIR = ./build/
+
+SOURCES += ./src/main.cpp \
+    ./src/fs_gui.cpp \
+    ./src/server_manager.cpp \
+    ./src/esl_connection.cpp
+
+INCLUDEPATH += ../../../libs/esl/src/include \
+    ./src/include
+
+HEADERS += ./src/include/fs_gui.h \
+    ./src/include/server_manager.h \
+    ./src/include/esl_connection.h
+
+FORMS += ./resources/fs_gui.ui \
+    ./resources/server_manager.ui
+
 LIBS += -L../../../libs/esl \
     -lesl

Deleted: freeswitch/trunk/contrib/jmesquita/fsgui/main.cpp

Added: freeswitch/trunk/contrib/jmesquita/fsgui/resources/fs_gui.ui (0 => 14234)


--- freeswitch/trunk/contrib/jmesquita/fsgui/resources/fs_gui.ui	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/resources/fs_gui.ui	2009-07-14 03:42:55 UTC (rev 14234)
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Cfsgui</class>
+ <widget class="QMainWindow" name="Cfsgui">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>600</width>
+    <height>400</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>FSGui - The console for humans</string>
+  </property>
+  <widget class="QWidget" name="centralWidget">
+   <layout class="QGridLayout" name="gridLayout">
+    <item row="0" column="0" colspan="2">
+     <widget class="QTextEdit" name="textConsole">
+      <property name="undoRedoEnabled">
+       <bool>false</bool>
+      </property>
+      <property name="readOnly">
+       <bool>true</bool>
+      </property>
+      <property name="textInteractionFlags">
+       <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+      </property>
+     </widget>
+    </item>
+    <item row="1" column="0">
+     <widget class="QLineEdit" name="lineCmd">
+      <property name="enabled">
+       <bool>false</bool>
+      </property>
+     </widget>
+    </item>
+    <item row="1" column="1">
+     <widget class="QPushButton" name="btnSend">
+      <property name="enabled">
+       <bool>false</bool>
+      </property>
+      <property name="text">
+       <string>Send</string>
+      </property>
+      <property name="autoDefault">
+       <bool>false</bool>
+      </property>
+      <property name="default">
+       <bool>true</bool>
+      </property>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QMenuBar" name="menuBar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>600</width>
+     <height>26</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuFile">
+    <property name="title">
+     <string>&amp;File</string>
+    </property>
+    <addaction name="actionConnect"/>
+    <addaction name="actionDisconnect"/>
+    <addaction name="separator"/>
+    <addaction name="actionQuit"/>
+   </widget>
+   <widget class="QMenu" name="menuHelp">
+    <property name="title">
+     <string>&amp;Help</string>
+    </property>
+    <addaction name="actionAbout"/>
+   </widget>
+   <addaction name="menuFile"/>
+   <addaction name="menuHelp"/>
+  </widget>
+  <widget class="QStatusBar" name="statusBar">
+   <property name="sizeGripEnabled">
+    <bool>false</bool>
+   </property>
+  </widget>
+  <action name="actionQuit">
+   <property name="text">
+    <string>&amp;Quit</string>
+   </property>
+  </action>
+  <action name="actionAbout">
+   <property name="text">
+    <string>&amp;About</string>
+   </property>
+  </action>
+  <action name="actionConnect">
+   <property name="text">
+    <string>&amp;Connect</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+C</string>
+   </property>
+  </action>
+  <action name="actionDisconnect">
+   <property name="enabled">
+    <bool>false</bool>
+   </property>
+   <property name="text">
+    <string>&amp;Disconnect</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+D</string>
+   </property>
+  </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <tabstops>
+  <tabstop>lineCmd</tabstop>
+  <tabstop>textConsole</tabstop>
+  <tabstop>btnSend</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>

Added: freeswitch/trunk/contrib/jmesquita/fsgui/resources/server_manager.ui (0 => 14234)


--- freeswitch/trunk/contrib/jmesquita/fsgui/resources/server_manager.ui	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/resources/server_manager.ui	2009-07-14 03:42:55 UTC (rev 14234)
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CserverManager</class>
+ <widget class="QDialog" name="CserverManager">
+  <property name="windowModality">
+   <enum>Qt::NonModal</enum>
+  </property>
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>516</width>
+    <height>249</height>
+   </rect>
+  </property>
+  <property name="focusPolicy">
+   <enum>Qt::NoFocus</enum>
+  </property>
+  <property name="windowTitle">
+   <string>Server Manager</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QTreeView" name="treeView"/>
+     </item>
+     <item>
+      <widget class="QGroupBox" name="groupBox">
+       <property name="title">
+        <string>Server Settings</string>
+       </property>
+       <layout class="QFormLayout" name="formLayout">
+        <item row="0" column="0">
+         <widget class="QLabel" name="label">
+          <property name="text">
+           <string>Host</string>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="1">
+         <widget class="QLineEdit" name="host">
+          <property name="text">
+           <string>localhost</string>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="0">
+         <widget class="QLabel" name="label_2">
+          <property name="text">
+           <string>Password</string>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="1">
+         <widget class="QLineEdit" name="pass">
+          <property name="text">
+           <string>ClueCon</string>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="0">
+         <widget class="QLabel" name="label_3">
+          <property name="text">
+           <string>Port</string>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="1">
+         <widget class="QLineEdit" name="port">
+          <property name="text">
+           <string>8021</string>
+          </property>
+         </widget>
+        </item>
+        <item row="3" column="0">
+         <widget class="QPushButton" name="pushButton">
+          <property name="text">
+           <string>Save</string>
+          </property>
+         </widget>
+        </item>
+        <item row="3" column="1">
+         <widget class="QPushButton" name="pushButton_2">
+          <property name="text">
+           <string>Delete</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>CserverManager</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>CserverManager</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

Deleted: freeswitch/trunk/contrib/jmesquita/fsgui/server_manager.cpp

Deleted: freeswitch/trunk/contrib/jmesquita/fsgui/server_manager.h

Deleted: freeswitch/trunk/contrib/jmesquita/fsgui/server_manager.ui

Added: freeswitch/trunk/contrib/jmesquita/fsgui/src/esl_connection.cpp (0 => 14234)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/esl_connection.cpp	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/esl_connection.cpp	2009-07-14 03:42:55 UTC (rev 14234)
@@ -0,0 +1,498 @@
+/*
+ * Copyright (c) 2007, Anthony Minessale II
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the original author; nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Contributor(s):
+ *
+ * Joao Mesquita <jmesquita (at) gmail.com>
+ *
+ */
+
+#include <QtGui>
+#include <esl.h>
+#include <esl_connection.h>
+
+#define connection_construct_common() memset(&handle, 0, sizeof(handle)); last_event_obj = NULL
+#define event_construct_common() event = NULL; serialized_string = NULL; mine = 0; hp = NULL
+
+void eslSetLogLevel(int level)
+{
+    esl_global_set_default_logger(level);
+}
+
+ESLconnection::ESLconnection(const char *host, const char *port, const char *password)
+        : _host(new QString(host)), _port(new QString(port)), _pass(new QString(password))
+{
+    connection_construct_common();
+}
+
+ESLconnection::~ESLconnection()
+{
+    if (handle.connected) {
+        esl_disconnect(&handle);
+    }
+
+}
+
+int ESLconnection::disconnect()
+{
+    if (handle.connected) {
+        return esl_disconnect(&handle);
+    }
+
+    return 0;
+}
+
+void ESLconnection::doConnect()
+{
+    int x_port = _port->toInt();
+
+    esl_global_set_default_logger(7);
+
+    if (esl_connect(&handle, _host->toAscii(), x_port, _pass->toAscii()) == ESL_SUCCESS)
+    {
+        sendRecv("log 7");
+        emit gotConnected();
+        start();
+    }
+    else
+    {
+        emit connectionFailed(QString(handle.err));
+        qDebug() << handle.err;
+    }
+}
+
+int ESLconnection::connected()
+{
+    return handle.connected;
+}
+
+int ESLconnection::send(const char *cmd)
+{
+    return esl_send(&handle, cmd);
+}
+
+ESLevent *ESLconnection::sendRecv(const char *cmd)
+{
+    if (esl_send_recv(&handle, cmd) == ESL_SUCCESS) {
+        esl_event_t *event;
+        esl_event_dup(&event, handle.last_sr_event);
+        return new ESLevent(event, 1);
+    }
+
+    return NULL;
+}
+
+ESLevent *ESLconnection::api(const char *cmd, const char *arg)
+{
+    size_t len;
+    char *cmd_buf;
+
+    if (!cmd) {
+        return NULL;
+    }
+
+    len = strlen(cmd) + (arg ? strlen(arg) : 0) + 10;
+
+    cmd_buf = (char *) malloc(len + 1);
+    assert(cmd_buf);
+
+    snprintf(cmd_buf, len, "api %s %s", cmd, arg ? arg : "");
+    *(cmd_buf + (len)) = '\0';
+
+
+    if (esl_send_recv(&handle, cmd_buf) == ESL_SUCCESS) {
+        esl_event_t *event;
+        esl_event_dup(&event, handle.last_sr_event);
+        return new ESLevent(event, 1);
+    }
+
+    free(cmd_buf);
+
+    return NULL;
+}
+
+ESLevent *ESLconnection::bgapi(const char *cmd, const char *arg)
+{
+    size_t len;
+    char *cmd_buf;
+
+    if (!cmd) {
+        return NULL;
+    }
+
+    len = strlen(cmd) + (arg ? strlen(arg) : 0) + 10;
+
+    cmd_buf = (char *) malloc(len + 1);
+    assert(cmd_buf);
+
+    snprintf(cmd_buf, len, "bgapi %s %s", cmd, arg ? arg : "");
+    *(cmd_buf + (len)) = '\0';
+
+    if (esl_send_recv(&handle, cmd_buf) == ESL_SUCCESS) {
+        esl_event_t *event;
+        esl_event_dup(&event, handle.last_sr_event);
+        return new ESLevent(event, 1);
+    }
+
+    free(cmd_buf);
+
+    return NULL;
+}
+
+ESLevent *ESLconnection::getInfo()
+{
+    if (handle.connected && handle.info_event) {
+        esl_event_t *event;
+        esl_event_dup(&event, handle.info_event);
+        return new ESLevent(event, 1);
+    }
+
+    return NULL;
+}
+
+int ESLconnection::setAsyncExecute(const char *val)
+{
+    if (val) {
+        handle.async_execute = esl_true(val);
+    }
+    return handle.async_execute;
+}
+
+int ESLconnection::setEventLock(const char *val)
+{
+    if (val) {
+        handle.event_lock = esl_true(val);
+    }
+    return handle.event_lock;
+}
+
+int ESLconnection::execute(const char *app, const char *arg, const char *uuid)
+{
+    return esl_execute(&handle, app, arg, uuid);
+}
+
+
+int ESLconnection::executeAsync(const char *app, const char *arg, const char *uuid)
+{
+    int async = handle.async_execute;
+    int r;
+
+    handle.async_execute = 1;
+    r = esl_execute(&handle, app, arg, uuid);
+    handle.async_execute = async;
+
+    return r;
+}
+
+int ESLconnection::sendEvent(ESLevent *send_me)
+{
+    return esl_sendevent(&handle, send_me->event);
+}
+
+ESLevent *ESLconnection::recvEvent()
+{
+    if (last_event_obj) {
+        delete last_event_obj;
+    }
+
+    if (esl_recv_event(&handle, 1, NULL) == ESL_SUCCESS) {
+        esl_event_t *e = handle.last_ievent ? handle.last_ievent : handle.last_event;
+        if (e) {
+            esl_event_t *event;
+            esl_event_dup(&event, e);
+            last_event_obj = new ESLevent(event, 1);
+            return last_event_obj;
+        }
+    }
+
+    last_event_obj = new ESLevent("server_disconnected");
+
+    return last_event_obj;
+}
+
+ESLevent *ESLconnection::recvEventTimed(int ms)
+{
+    if (last_event_obj) {
+        delete last_event_obj;
+        last_event_obj = NULL;
+    }
+
+    if (esl_recv_event_timed(&handle, ms, 1, NULL) == ESL_SUCCESS) {
+        esl_event_t *e = handle.last_ievent ? handle.last_ievent : handle.last_event;
+        if (e) {
+            esl_event_t *event;
+            esl_event_dup(&event, e);
+            last_event_obj = new ESLevent(event, 1);
+            return last_event_obj;
+        }
+    }
+
+    return NULL;
+}
+
+ESLevent *ESLconnection::filter(const char *header, const char *value)
+{
+    esl_status_t status = esl_filter(&handle, header, value);
+
+    if (status == ESL_SUCCESS && handle.last_sr_event) {
+        esl_event_t *event;
+        esl_event_dup(&event, handle.last_sr_event);
+        return new ESLevent(event, 1);
+    }
+
+    return NULL;
+
+}
+
+int ESLconnection::events(const char *etype, const char *value)
+{
+    esl_event_type_t type_id = ESL_EVENT_TYPE_PLAIN;
+
+    if (!strcmp(etype, "xml")) {
+        type_id = ESL_EVENT_TYPE_XML;
+    }
+
+    return esl_events(&handle, type_id, value);
+}
+
+void ESLconnection::run(void)
+{
+    forever
+    {
+        if (!connected())
+        {
+            emit gotDisconnected();
+            qDebug() << handle.err;
+            break;
+        }
+        else
+        {
+            ESLevent * event = recvEventTimed(10);
+            if (event)
+            {
+                ESLevent * e = new ESLevent(event);
+                emit gotEvent(e);
+            }
+        }
+    }
+
+}
+
+// ESLevent
+///////////////////////////////////////////////////////////////////////
+
+ESLevent::ESLevent(const char *type, const char *subclass_name)
+{
+    esl_event_types_t event_id;
+
+    event_construct_common();
+
+    if (esl_name_event(type, &event_id) != ESL_SUCCESS) {
+        event_id = ESL_EVENT_MESSAGE;
+    }
+
+    if (!esl_strlen_zero(subclass_name) && event_id != ESL_EVENT_CUSTOM) {
+        esl_log(ESL_LOG_WARNING, "Changing event type to custom because you specified a subclass name!\n");
+        event_id = ESL_EVENT_CUSTOM;
+    }
+
+    if (esl_event_create_subclass(&event, event_id, subclass_name) != ESL_SUCCESS) {
+        esl_log(ESL_LOG_ERROR, "Failed to create event!\n");
+        event = NULL;
+    }
+
+    serialized_string = NULL;
+    mine = 1;
+}
+
+ESLevent::ESLevent(esl_event_t *wrap_me, int free_me)
+{
+    event_construct_common();
+    event = wrap_me;
+    mine = free_me;
+    serialized_string = NULL;
+}
+
+
+ESLevent::ESLevent(ESLevent *me)
+{
+    /* workaround for silly php thing */
+    event = me->event;
+    mine = me->mine;
+    serialized_string = NULL;
+    me->event = NULL;
+    me->mine = 0;
+    esl_safe_free(me->serialized_string);
+}
+
+ESLevent::~ESLevent()
+{
+
+    if (serialized_string) {
+        free(serialized_string);
+    }
+
+    if (event && mine) {
+        esl_event_destroy(&event);
+    }
+}
+
+const char *ESLevent::nextHeader(void)
+{
+    const char *name = NULL;
+
+    if (hp) {
+        name = hp->name;
+        hp = hp->next;
+    }
+
+    return name;
+}
+
+const char *ESLevent::firstHeader(void)
+{
+    if (event) {
+        hp = event->headers;
+    }
+
+    return nextHeader();
+}
+
+const char *ESLevent::serialize(const char *format)
+{
+    this_check("");
+
+    esl_safe_free(serialized_string);
+
+    if (!event) {
+        return "";
+    }
+
+    if (esl_event_serialize(event, &serialized_string, ESL_TRUE) == ESL_SUCCESS) {
+        return serialized_string;
+    }
+
+    return "";
+
+}
+
+bool ESLevent::setPriority(esl_priority_t priority)
+{
+    this_check(false);
+
+    if (event) {
+        esl_event_set_priority(event, priority);
+        return true;
+    } else {
+        esl_log(ESL_LOG_ERROR, "Trying to setPriority an event that does not exist!\n");
+    }
+    return false;
+}
+
+const char *ESLevent::getHeader(const char *header_name)
+{
+    this_check("");
+
+    if (event) {
+        return esl_event_get_header(event, header_name);
+    } else {
+        esl_log(ESL_LOG_ERROR, "Trying to getHeader an event that does not exist!\n");
+    }
+    return NULL;
+}
+
+bool ESLevent::addHeader(const char *header_name, const char *value)
+{
+    this_check(false);
+
+    if (event) {
+        return esl_event_add_header_string(event, ESL_STACK_BOTTOM, header_name, value) == ESL_SUCCESS ? true : false;
+    } else {
+        esl_log(ESL_LOG_ERROR, "Trying to addHeader an event that does not exist!\n");
+    }
+
+    return false;
+}
+
+bool ESLevent::delHeader(const char *header_name)
+{
+    this_check(false);
+
+    if (event) {
+        return esl_event_del_header(event, header_name) == ESL_SUCCESS ? true : false;
+    } else {
+        esl_log(ESL_LOG_ERROR, "Trying to delHeader an event that does not exist!\n");
+    }
+
+    return false;
+}
+
+
+bool ESLevent::addBody(const char *value)
+{
+    this_check(false);
+
+    if (event) {
+        return esl_event_add_body(event, "%s", value) == ESL_SUCCESS ? true : false;
+    } else {
+        esl_log(ESL_LOG_ERROR, "Trying to addBody an event that does not exist!\n");
+    }
+
+    return false;
+}
+
+char *ESLevent::getBody(void)
+{
+
+    this_check((char *)"");
+
+    if (event) {
+        return esl_event_get_body(event);
+    } else {
+        esl_log(ESL_LOG_ERROR, "Trying to getBody an event that does not exist!\n");
+    }
+
+    return NULL;
+}
+
+const char *ESLevent::getType(void)
+{
+    this_check("");
+
+    if (event) {
+        return esl_event_name(event->event_id);
+    } else {
+        esl_log(ESL_LOG_ERROR, "Trying to getType an event that does not exist!\n");
+    }
+
+    return (char *) "invalid";
+}

Added: freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp (0 => 14234)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp	2009-07-14 03:42:55 UTC (rev 14234)
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2007, Anthony Minessale II
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the original author; nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Contributor(s):
+ *
+ * Joao Mesquita <jmesquita (at) gmail.com>
+ *
+ */
+
+#include "fs_gui.h"
+#include "ui_fs_gui.h"
+#include "esl_connection.h"
+
+Cfsgui::Cfsgui(QWidget *parent) :
+    QMainWindow(parent),
+    m_ui(new Ui::Cfsgui),
+    serverDialog(new CserverManager)
+{
+    m_ui->setupUi(this);
+
+    // Set the default status bar message
+    m_ui->statusBar->showMessage(tr("Ready"));
+
+    connect(m_ui->actionConnect, SIGNAL(triggered()),
+            serverDialog, SLOT(show()));
+    connect(serverDialog, SIGNAL(doConnect(QString,QString,QString)),
+            this, SLOT(newConnectionFromDialog(QString,QString,QString)));
+    connect(m_ui->lineCmd, SIGNAL(textChanged(QString)),
+            this, SLOT(typedCommand()));
+    connect(m_ui->btnSend, SIGNAL(clicked()),
+            this, SLOT(sendCommand()));
+}
+
+Cfsgui::~Cfsgui()
+{
+    delete m_ui;
+    delete serverDialog;
+}
+
+void Cfsgui::appendConsoleText(const QString text)
+{
+    m_ui->textConsole->append(text);
+}
+
+void Cfsgui::getDisconnectedSlot()
+{
+    eslConnection->disconnect();
+}
+
+void Cfsgui::typedCommand()
+{
+    m_ui->btnSend->setDisabled(m_ui->lineCmd->text().isEmpty());
+}
+
+void Cfsgui::sendCommand()
+{
+    QString cmd = m_ui->lineCmd->text();
+    //eslConnection->sendCmd(cmd);
+    m_ui->lineCmd->clear();
+}
+
+void Cfsgui::gotConnectedSlot()
+{
+    qDebug() << "We got connected.";
+    m_ui->statusBar->showMessage("Connected");
+    appendConsoleText("Conneted!");
+    m_ui->actionConnect->setDisabled(true);
+    m_ui->actionDisconnect->setEnabled(true);
+    m_ui->lineCmd->setEnabled(true);
+    m_ui->lineCmd->setFocus();
+}
+void Cfsgui::gotDisconnectedSlot()
+{
+    m_ui->statusBar->showMessage("Disconnected");
+    appendConsoleText("Disconnected!");
+    m_ui->actionConnect->setEnabled(true);
+    m_ui->actionDisconnect->setDisabled(true);
+    m_ui->lineCmd->setDisabled(true);
+    delete eslConnection;
+}
+
+void Cfsgui::connectionFailedSlot(QString msg)
+{
+    qDebug() << msg;
+    m_ui->statusBar->showMessage("Connection Failed: "+msg);
+    appendConsoleText("Connection Failed: "+msg);
+    m_ui->actionConnect->setEnabled(true);
+    m_ui->actionDisconnect->setDisabled(true);
+    m_ui->lineCmd->setDisabled(true);
+}
+
+void Cfsgui::gotEventSlot(ESLevent * event)
+{
+    if (event->getBody())
+    {
+        QString text = event->getBody();
+
+        if (text.endsWith("\r\n"))
+            text.chop(2);
+        if (text.endsWith("\n"))
+            text.chop(1);
+
+        appendConsoleText(text);
+    }
+    delete event;
+}
+
+void Cfsgui::changeEvent(QEvent *e)
+{
+    QMainWindow::changeEvent(e);
+    switch (e->type()) {
+    case QEvent::LanguageChange:
+        m_ui->retranslateUi(this);
+        break;
+    default:
+        break;
+    }
+}
+
+void Cfsgui::closeEvent(QCloseEvent *e)
+{
+    /* TODO: We have to stop threads and do cleanup */
+    e->accept();
+}
+
+void Cfsgui::newConnectionFromDialog(QString host, QString pass, QString port)
+{
+    m_ui->statusBar->showMessage("Connecting...");
+    eslConnection = new ESLconnection(host.toAscii(),
+                                      port.toAscii(),
+                                      pass.toAscii());
+    /* Connect signals from eslConnection */
+    connect(eslConnection, SIGNAL(gotConnected(void)),
+            this, SLOT(gotConnectedSlot(void)));
+    connect(eslConnection, SIGNAL(gotDisconnected(void)),
+            this, SLOT(gotDisconnectedSlot(void)));
+    connect(eslConnection, SIGNAL(connectionFailed(QString)),
+            this, SLOT(connectionFailedSlot(QString)));
+    connect(eslConnection, SIGNAL(gotEvent(ESLevent*)),
+            this, SLOT(gotEventSlot(ESLevent*)));
+
+    /* Connect the disconnect menu */
+    connect(m_ui->actionDisconnect, SIGNAL(triggered()),
+            this, SLOT(getDisconnectedSlot()));
+
+    eslConnection->doConnect();
+}

Added: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/esl_connection.h (0 => 14234)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/esl_connection.h	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/esl_connection.h	2009-07-14 03:42:55 UTC (rev 14234)
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2007, Anthony Minessale II
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 
+ * * Neither the name of the original author; nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ * 
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Contributor(s):
+ *
+ * Joao Mesquita <jmesquita (at) gmail.com>
+ *
+ */
+
+#ifndef _ESL_CONNECTION_H_
+#define _ESL_CONNECTION_H_
+#include <QThread>
+#include <esl.h>
+
+/*#ifdef __cplusplus
+extern "C" { 
+#endif*/
+
+#define this_check(x) do { if (!this) { esl_log(ESL_LOG_ERROR, "object is not initalized\n"); return x;}} while(0)
+#define this_check_void() do { if (!this) { esl_log(ESL_LOG_ERROR, "object is not initalized\n"); return;}} while(0)
+
+
+class ESLevent {
+ private:
+	esl_event_header_t *hp;
+ public:
+	esl_event_t *event;
+	char *serialized_string;
+	int mine;
+
+	ESLevent(const char *type, const char *subclass_name = NULL);
+	ESLevent(esl_event_t *wrap_me, int free_me = 0);
+	ESLevent(ESLevent *me);
+	virtual ~ESLevent();
+	const char *serialize(const char *format = NULL);
+	bool setPriority(esl_priority_t priority = ESL_PRIORITY_NORMAL);
+	const char *getHeader(const char *header_name);
+	char *getBody(void);
+	const char *getType(void);
+	bool addBody(const char *value);
+	bool addHeader(const char *header_name, const char *value);
+	bool delHeader(const char *header_name);
+	const char *firstHeader(void);
+	const char *nextHeader(void);
+};
+
+class ESLconnection : public QThread
+{
+    Q_OBJECT
+ private:
+    esl_handle_t handle;
+    ESLevent *last_event_obj;
+    QString *_host;
+    QString *_port;
+    QString *_pass;
+ public:
+    ESLconnection(const char *host, const char *port, const char *password);
+    virtual ~ESLconnection();
+    int connected();
+    void doConnect();
+    ESLevent *getInfo();
+    int send(const char *cmd);
+    ESLevent *sendRecv(const char *cmd);
+    ESLevent *api(const char *cmd, const char *arg = NULL);
+    ESLevent *bgapi(const char *cmd, const char *arg = NULL);
+    int sendEvent(ESLevent *send_me);
+    ESLevent *recvEvent();
+    ESLevent *recvEventTimed(int ms);
+    ESLevent *filter(const char *header, const char *value);
+    int events(const char *etype, const char *value);
+    int execute(const char *app, const char *arg = NULL, const char *uuid = NULL);
+    int executeAsync(const char *app, const char *arg = NULL, const char *uuid = NULL);
+    int setAsyncExecute(const char *val);
+    int setEventLock(const char *val);
+    int disconnect(void);
+ signals:
+    void gotConnected(void);
+    void gotDisconnected(void);
+    void connectionFailed(QString);
+    void gotEvent(ESLevent*);
+protected:
+    void run();
+};
+
+void eslSetLogLevel(int level);
+
+/*#ifdef __cplusplus
+}
+#endif*/
+
+#endif

Added: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h (0 => 14234)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h	2009-07-14 03:42:55 UTC (rev 14234)
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2007, Anthony Minessale II
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the original author; nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Contributor(s):
+ *
+ * Joao Mesquita <jmesquita (at) gmail.com>
+ *
+ */
+
+#ifndef FS_GUI_H
+#define FS_GUI_H
+
+#include <QtGui>
+#include "server_manager.h"
+
+namespace Ui {
+    class Cfsgui;
+}
+
+/* Forward declarations */
+class ESLevent;
+class ESLconnection;
+
+class Cfsgui : public QMainWindow {
+    Q_OBJECT
+    Q_DISABLE_COPY(Cfsgui)
+public:
+    explicit Cfsgui (QWidget *parent = 0);
+    virtual ~Cfsgui();
+
+protected:
+    virtual void changeEvent(QEvent *e);
+    void closeEvent(QCloseEvent *e);
+    void appendConsoleText(const QString);
+
+private slots:
+    void newConnectionFromDialog(QString,QString,QString);
+    void gotConnectedSlot();
+    void gotDisconnectedSlot();
+    void connectionFailedSlot(QString);
+    void gotEventSlot(ESLevent *);
+    void getDisconnectedSlot();
+    void typedCommand();
+    void sendCommand();
+
+private:
+    Ui::Cfsgui *m_ui;
+    CserverManager *serverDialog;
+    ESLconnection *eslConnection;
+};
+
+#endif // FS_GUI_H

Added: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/server_manager.h (0 => 14234)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/server_manager.h	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/server_manager.h	2009-07-14 03:42:55 UTC (rev 14234)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2007, Anthony Minessale II
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the original author; nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Contributor(s):
+ *
+ * Joao Mesquita <jmesquita (at) gmail.com>
+ *
+ */
+
+#ifndef SERVER_MANAGER_H
+#define SERVER_MANAGER_H
+
+#include <QtGui/QDialog>
+
+namespace Ui {
+    class CserverManager;
+}
+
+class CserverManager : public QDialog {
+    Q_OBJECT
+    Q_DISABLE_COPY(CserverManager)
+public:
+    explicit CserverManager(QWidget *parent = 0);
+    virtual ~CserverManager();
+signals:
+    void doConnect(QString, QString, QString);
+protected:
+    virtual void changeEvent(QEvent *e);
+private slots:
+    void newConnection();
+private:
+    Ui::CserverManager *m_ui;
+};
+
+#endif // SERVER_MANAGER_H

Added: freeswitch/trunk/contrib/jmesquita/fsgui/src/main.cpp (0 => 14234)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/main.cpp	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/main.cpp	2009-07-14 03:42:55 UTC (rev 14234)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, Anthony Minessale II
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the original author; nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Contributor(s):
+ *
+ * Joao Mesquita <jmesquita (at) gmail.com>
+ *
+ */
+
+#include <QtGui/QApplication>
+#include "fs_gui.h"
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    Cfsgui w;
+    w.show();
+    return a.exec();
+}

Added: freeswitch/trunk/contrib/jmesquita/fsgui/src/server_manager.cpp (0 => 14234)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/server_manager.cpp	                        (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/server_manager.cpp	2009-07-14 03:42:55 UTC (rev 14234)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2007, Anthony Minessale II
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of the original author; nor the names of any contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Contributor(s):
+ *
+ * Joao Mesquita <jmesquita (at) gmail.com>
+ *
+ */
+
+#include "server_manager.h"
+#include "ui_server_manager.h"
+
+CserverManager::CserverManager(QWidget *parent) :
+    QDialog(parent),
+    m_ui(new Ui::CserverManager)
+{
+    m_ui->setupUi(this);
+    connect(this, SIGNAL(accepted()),
+            this, SLOT(newConnection()));
+}
+
+CserverManager::~CserverManager()
+{
+    delete m_ui;
+}
+
+void CserverManager::changeEvent(QEvent *e)
+{
+    QDialog::changeEvent(e);
+    switch (e->type()) {
+    case QEvent::LanguageChange:
+        m_ui->retranslateUi(this);
+        break;
+    default:
+        break;
+    }
+}
+
+void CserverManager::newConnection()
+{
+    //TODO: Sanity checking needed.
+    emit doConnect(m_ui->host->text(),
+                   m_ui->pass->text(),
+                   m_ui->port->text());
+}