Diff
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/fsgui.pro (14263 => 14264)
--- freeswitch/trunk/contrib/jmesquita/fsgui/fsgui.pro 2009-07-16 00:46:35 UTC (rev 14263)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/fsgui.pro 2009-07-16 00:49:41 UTC (rev 14264)
@@ -1,27 +1,23 @@
-
DESTDIR = ./bin/
message(The project will be installed in $$DESTDIR)
TARGET = fs_gui
TEMPLATE = app
-
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
-
+SOURCES += src/main.cpp \
+ src/fs_gui.cpp \
+ src/server_manager.cpp \
+ src/esl_connection.cpp \
+ src/consolepage.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
-
+ src/include
+HEADERS += src/include/fs_gui.h \
+ src/include/server_manager.h \
+ src/include/esl_connection.h \
+ src/include/consolepage.h
+FORMS += resources/fs_gui.ui \
+ resources/server_manager.ui \
+ resources/consolepage.ui
LIBS += -L../../../libs/esl \
-lesl
Added: freeswitch/trunk/contrib/jmesquita/fsgui/resources/consolepage.ui (0 => 14264)
--- freeswitch/trunk/contrib/jmesquita/fsgui/resources/consolepage.ui (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/resources/consolepage.ui 2009-07-16 00:49:41 UTC (rev 14264)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>consolePage</class>
+ <widget class="QWidget" name="consolePage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>274</width>
+ <height>244</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>consolePage</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTextEdit" name="textConsole"/>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLineEdit" name="lineCmd"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnSend">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Send</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/resources/fs_gui.ui (14263 => 14264)
--- freeswitch/trunk/contrib/jmesquita/fsgui/resources/fs_gui.ui 2009-07-16 00:46:35 UTC (rev 14263)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/resources/fs_gui.ui 2009-07-16 00:49:41 UTC (rev 14264)
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>600</width>
- <height>400</height>
+ <width>296</width>
+ <height>303</height>
</rect>
</property>
<property name="windowTitle">
@@ -18,7 +18,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
- <number>1</number>
+ <number>0</number>
</property>
<property name="tabsClosable">
<bool>true</bool>
@@ -53,36 +53,6 @@
</widget>
</widget>
</item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLineEdit" name="lineCmd">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="btnSend">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Send</string>
- </property>
- <property name="shortcut">
- <string>Return</string>
- </property>
- <property name="autoDefault">
- <bool>false</bool>
- </property>
- <property name="default">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
@@ -90,7 +60,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>600</width>
+ <width>296</width>
<height>26</height>
</rect>
</property>
@@ -148,10 +118,6 @@
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
- <tabstops>
- <tabstop>lineCmd</tabstop>
- <tabstop>btnSend</tabstop>
- </tabstops>
<resources/>
<connections>
<connection>
Added: freeswitch/trunk/contrib/jmesquita/fsgui/src/consolepage.cpp (0 => 14264)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/consolepage.cpp (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/consolepage.cpp 2009-07-16 00:49:41 UTC (rev 14264)
@@ -0,0 +1,204 @@
+/*
+ * 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 "consolepage.h"
+#include "ui_consolepage.h"
+#include "esl_connection.h"
+#include "esl.h"
+
+consolePage::consolePage(QWidget *parent) :
+ QWidget(parent),
+ m_ui(new Ui::consolePage)
+{
+ m_ui->setupUi(this);
+}
+consolePage::~consolePage()
+{
+ delete m_ui;
+}
+void consolePage::init(QString host)
+{
+ this->host = host;
+ connect(m_ui->lineCmd, SIGNAL(textChanged(QString)),
+ this, SLOT(typedCommand()));
+ connect(m_ui->btnSend, SIGNAL(clicked()),
+ this, SLOT(sendCommand()));
+
+ QString settingsApplication = "FSGui";
+ QString settingsOrganization = "FreeSWITCH";
+
+ QSettings settings(settingsOrganization, settingsApplication);
+
+ settings.beginGroup("servers");
+ settings.beginGroup(host);
+ QString port = settings.value("port").toString();
+ QString pass = settings.value("password").toString();
+ settings.endGroup();
+ settings.endGroup();
+
+ qDebug() << settings.allKeys();
+ 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*)));
+
+ eslConnection->doConnect();
+}
+void consolePage::changeEvent(QEvent *e)
+{
+ QWidget::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ m_ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
+void consolePage::appendConsoleText(const QString text)
+{
+ m_ui->textConsole->append(text);
+}
+void consolePage::getDisconnectedSlot()
+{
+ eslConnection->disconnect();
+}
+void consolePage::typedCommand()
+{
+ m_ui->btnSend->setDisabled(m_ui->lineCmd->text().isEmpty());
+}
+void consolePage::sendCommand()
+{
+ QStringList cmdList = m_ui->lineCmd->text().split(" ");
+ QString args("");
+ for(int i = 1; i < cmdList.size(); i++)
+ {
+ args += cmdList[i];
+ if (i != cmdList.size()-1)
+ args += " ";
+ }
+ ESLevent *e = new ESLevent(eslConnection->api(cmdList[0].toAscii(), args.toAscii()));
+ gotEventSlot(e);
+ m_ui->lineCmd->clear();
+}
+void consolePage::gotConnectedSlot()
+{
+ appendConsoleText(tr("Connected!"));
+ m_ui->lineCmd->setEnabled(true);
+ m_ui->lineCmd->setFocus();
+}
+void consolePage::gotDisconnectedSlot()
+{
+ appendConsoleText(tr("Disconnected!"));
+ m_ui->lineCmd->setDisabled(true);
+ delete eslConnection;
+}
+void consolePage::connectionFailedSlot(QString msg)
+{
+ appendConsoleText("Connection Failed: "+msg);
+ m_ui->lineCmd->setDisabled(true);
+ delete eslConnection;
+}
+void consolePage::gotEventSlot(ESLevent * event)
+{
+ QString type (event->getHeader("Content-Type"));
+ if (QString::compare("log/data", type, Qt::CaseInsensitive) == 0)
+ {
+ switch (atoi(event->getHeader("log-level")))
+ {
+ case ESL_LOG_LEVEL_NOTICE:
+ {
+ m_ui->textConsole->setTextColor(Qt::cyan);
+ break;
+ }
+ case ESL_LOG_LEVEL_WARNING:
+ {
+ m_ui->textConsole->setTextColor(Qt::yellow);
+ break;
+ }
+ case ESL_LOG_LEVEL_ERROR:
+ case ESL_LOG_LEVEL_CRIT:
+ {
+ m_ui->textConsole->setTextColor(Qt::red);
+ break;
+ }
+ case ESL_LOG_LEVEL_ALERT:
+ case ESL_LOG_LEVEL_EMERG:
+ case ESL_LOG_LEVEL_INFO:
+ {
+ m_ui->textConsole->setTextColor(Qt::green);
+ break;
+ }
+ case ESL_LOG_LEVEL_DEBUG:
+ {
+ m_ui->textConsole->setTextColor(Qt::magenta);
+ break;
+ }
+ default:
+ {
+ m_ui->textConsole->setTextColor(Qt::black);
+ }
+ }
+ }
+ else
+ {
+ m_ui->textConsole->setTextColor(Qt::black);
+ }
+
+ 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;
+}
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/esl_connection.cpp (14263 => 14264)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/esl_connection.cpp 2009-07-16 00:46:35 UTC (rev 14263)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/esl_connection.cpp 2009-07-16 00:49:41 UTC (rev 14264)
@@ -86,7 +86,6 @@
else
{
emit connectionFailed(QString(handle.err));
- qDebug() << handle.err;
}
}
@@ -291,7 +290,6 @@
if (!connected())
{
emit gotDisconnected();
- qDebug() << handle.err;
break;
}
else
@@ -387,7 +385,7 @@
return nextHeader();
}
-const char *ESLevent::serialize(const char *format)
+const char *ESLevent::serialize()
{
this_check("");
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp (14263 => 14264)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp 2009-07-16 00:46:35 UTC (rev 14263)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp 2009-07-16 00:49:41 UTC (rev 14264)
@@ -38,8 +38,7 @@
#include "fs_gui.h"
#include "ui_fs_gui.h"
-#include "esl_connection.h"
-#include "esl.h"
+#include "consolepage.h"
Cfsgui::Cfsgui(QWidget *parent) :
QMainWindow(parent),
@@ -55,24 +54,14 @@
this, SLOT(newConnectionFromDialog()));
connect(m_ui->actionAbout, SIGNAL(triggered()),
this, SLOT(showAbout()));
- connect(m_ui->lineCmd, SIGNAL(textChanged(QString)),
- this, SLOT(typedCommand()));
- connect(m_ui->btnSend, SIGNAL(clicked()),
- this, SLOT(sendCommand()));
- /* Why QtDesigner does not allow me to delete this? */
- m_ui->tabWidget->removeTab(1);
- delete m_ui->tab_2;
+ m_ui->tabWidget->clear();
}
Cfsgui::~Cfsgui()
{
delete m_ui;
delete serverDialog;
}
-void Cfsgui::appendConsoleText(const QString text)
-{
- m_ui->textConsole->append(text);
-}
void Cfsgui::showAbout()
{
QMessageBox::about(this, tr("About FSGui"),
@@ -81,115 +70,7 @@
"<p>This is small application that will help you connect "
"to your FreeSWITCH© installation."));
}
-void Cfsgui::getDisconnectedSlot()
-{
- eslConnection->disconnect();
-}
-void Cfsgui::typedCommand()
-{
- m_ui->btnSend->setDisabled(m_ui->lineCmd->text().isEmpty());
-}
-void Cfsgui::sendCommand()
-{
- QStringList cmdList = m_ui->lineCmd->text().split(" ");
- QString args("");
- for(int i = 1; i < cmdList.size(); i++)
- {
- args += cmdList[i];
- if (i != cmdList.size()-1)
- args += " ";
- }
- ESLevent *e = new ESLevent(eslConnection->api(cmdList[0].toAscii(), args.toAscii()));
- gotEventSlot(e);
- m_ui->lineCmd->clear();
-}
-void Cfsgui::gotConnectedSlot()
-{
- m_ui->statusBar->showMessage(tr("Connected"));
- appendConsoleText(tr("Connected!"));
- 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(tr("Disconnected"));
- appendConsoleText(tr("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);
- delete eslConnection;
-}
-void Cfsgui::gotEventSlot(ESLevent * event)
-{
- QString type (event->getHeader("Content-Type"));
- if (QString::compare("log/data", type, Qt::CaseInsensitive) == 0)
- {
- switch (atoi(event->getHeader("log-level")))
- {
- case ESL_LOG_LEVEL_NOTICE:
- {
- m_ui->textConsole->setTextColor(Qt::cyan);
- break;
- }
- case ESL_LOG_LEVEL_WARNING:
- {
- m_ui->textConsole->setTextColor(Qt::yellow);
- break;
- }
- case ESL_LOG_LEVEL_ERROR:
- case ESL_LOG_LEVEL_CRIT:
- {
- m_ui->textConsole->setTextColor(Qt::red);
- break;
- }
- case ESL_LOG_LEVEL_ALERT:
- case ESL_LOG_LEVEL_EMERG:
- case ESL_LOG_LEVEL_INFO:
- {
- m_ui->textConsole->setTextColor(Qt::green);
- break;
- }
- case ESL_LOG_LEVEL_DEBUG:
- {
- m_ui->textConsole->setTextColor(Qt::magenta);
- break;
- }
- default:
- {
- m_ui->textConsole->setTextColor(Qt::black);
- }
- }
- }
- else
- {
- m_ui->textConsole->setTextColor(Qt::black);
- }
- 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);
@@ -218,24 +99,8 @@
if (serverDialog->exec())
{
- m_ui->statusBar->showMessage("Connecting...");
- eslConnection = new ESLconnection(serverDialog->getHost().toAscii(),
- serverDialog->getPort().toAscii(),
- serverDialog->getPass().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();
+ consolePage *page = new consolePage();
+ m_ui->tabWidget->addTab(page, serverDialog->getHost());
+ page->init(serverDialog->getHost());
}
}
Added: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/consolepage.h (0 => 14264)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/consolepage.h (rev 0)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/consolepage.h 2009-07-16 00:49:41 UTC (rev 14264)
@@ -0,0 +1,40 @@
+#ifndef CONSOLEPAGE_H
+#define CONSOLEPAGE_H
+
+#include <QtGui/QWidget>
+
+namespace Ui {
+ class consolePage;
+}
+
+/* Forward declarations */
+class ESLevent;
+class ESLconnection;
+
+class consolePage : public QWidget {
+ Q_OBJECT
+
+public:
+ consolePage(QWidget *parent = 0);
+ ~consolePage();
+ void init(QString host);
+
+protected:
+ virtual void changeEvent(QEvent *e);
+ void appendConsoleText(const QString);
+
+private slots:
+ void gotConnectedSlot();
+ void gotDisconnectedSlot();
+ void connectionFailedSlot(QString);
+ void gotEventSlot(ESLevent *);
+ void getDisconnectedSlot();
+ void typedCommand();
+ void sendCommand();
+private:
+ Ui::consolePage *m_ui;
+ ESLconnection *eslConnection;
+ QString host;
+};
+
+#endif // CONSOLEPAGE_H
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/esl_connection.h (14263 => 14264)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/esl_connection.h 2009-07-16 00:46:35 UTC (rev 14263)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/esl_connection.h 2009-07-16 00:49:41 UTC (rev 14264)
@@ -61,7 +61,7 @@
ESLevent(esl_event_t *wrap_me, int free_me = 0);
ESLevent(ESLevent *me);
virtual ~ESLevent();
- const char *serialize(const char *format = NULL);
+ const char *serialize();
bool setPriority(esl_priority_t priority = ESL_PRIORITY_NORMAL);
const char *getHeader(const char *header_name);
char *getBody(void);
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h (14263 => 14264)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h 2009-07-16 00:46:35 UTC (rev 14263)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h 2009-07-16 00:49:41 UTC (rev 14264)
@@ -46,9 +46,6 @@
class Cfsgui;
}
-/* Forward declarations */
-class ESLevent;
-class ESLconnection;
class Cfsgui : public QMainWindow {
Q_OBJECT
@@ -60,23 +57,14 @@
protected:
virtual void changeEvent(QEvent *e);
void closeEvent(QCloseEvent *e);
- void appendConsoleText(const QString);
private slots:
void showAbout();
void newConnectionFromDialog();
- 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
Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/server_manager.cpp (14263 => 14264)
--- freeswitch/trunk/contrib/jmesquita/fsgui/src/server_manager.cpp 2009-07-16 00:46:35 UTC (rev 14263)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/server_manager.cpp 2009-07-16 00:49:41 UTC (rev 14264)
@@ -45,7 +45,7 @@
{
m_ui->setupUi(this);
- settingsApplication = "FsGUI";
+ settingsApplication = "FSGui";
settingsOrganization = "FreeSWITCH";
readSettings();
connect(m_ui->btnSave, SIGNAL(clicked()),