[Freeswitch-svn] [commit] r11502 - freeswitch/trunk/scripts/contrib/jmesquita/fsgui
FreeSWITCH SVN
mrene at freeswitch.org
Mon Jan 26 19:09:18 PST 2009
Author: mrene
Date: Mon Jan 26 21:09:18 2009
New Revision: 11502
Log:
Refactor
Modified:
freeswitch/trunk/scripts/contrib/jmesquita/fsgui/conn_event_handler.cpp
freeswitch/trunk/scripts/contrib/jmesquita/fsgui/conn_event_handler.h
freeswitch/trunk/scripts/contrib/jmesquita/fsgui/fsgui.cpp
freeswitch/trunk/scripts/contrib/jmesquita/fsgui/fsgui.h
Modified: freeswitch/trunk/scripts/contrib/jmesquita/fsgui/conn_event_handler.cpp
==============================================================================
--- freeswitch/trunk/scripts/contrib/jmesquita/fsgui/conn_event_handler.cpp (original)
+++ freeswitch/trunk/scripts/contrib/jmesquita/fsgui/conn_event_handler.cpp Mon Jan 26 21:09:18 2009
@@ -6,29 +6,32 @@
memset(&handle, 0, sizeof(esl_handle_t));
}
-conn_event_handler::~conn_event_handler(void){
- getDisconnected();
+conn_event_handler::~conn_event_handler(void)
+{
+ if (isConnected()) {
+ Disconnect();
+ }
}
-void conn_event_handler::getDisconnected(){
+void conn_event_handler::Disconnect()
+{
esl_disconnect(&handle);
}
-void conn_event_handler::getConnected(QString hostname, int port, QString password){
- QByteArray h = hostname.toAscii();
- QByteArray p = password.toAscii();
- const char * Hostname = h.data();
- const char * Password = p.data();
- esl_status_t status = esl_connect(&handle, Hostname, port, Password);
- if ( status != ESL_SUCCESS)
- {
- QString errDesc = handle.err;
- emit connectionError(errDesc);
- }
- else
- {
- emit gotConnected();
- }
+void conn_event_handler::Connect(const QString& hostname, int port, const QString& password)
+{
+
+ esl_status_t status = esl_connect(&handle, hostname.toAscii().data(), port, password.toAscii().data());
+
+ if ( status != ESL_SUCCESS)
+ {
+ QString errDesc = handle.err;
+ emit connectionError(errDesc);
+ }
+ else
+ {
+ emit onConnected();
+ }
}
void conn_event_handler::handleError(){
@@ -40,7 +43,7 @@
return;
}
-void conn_event_handler::sendMessage(QString message)
+void conn_event_handler::sendMessage(const QString& message)
{
if (isConnected())
{
@@ -76,12 +79,11 @@
return;
}
-void conn_event_handler::handleRecvMessage(QString msg)
+void conn_event_handler::handleRecvMessage(const QString &msg)
{
- return;
}
-bool conn_event_handler::isConnected()
+bool conn_event_handler::isConnected() const
{
return handle.connected;
}
Modified: freeswitch/trunk/scripts/contrib/jmesquita/fsgui/conn_event_handler.h
==============================================================================
--- freeswitch/trunk/scripts/contrib/jmesquita/fsgui/conn_event_handler.h (original)
+++ freeswitch/trunk/scripts/contrib/jmesquita/fsgui/conn_event_handler.h Mon Jan 26 21:09:18 2009
@@ -3,37 +3,33 @@
#include <QtGui>
-extern "C" {
- #include "esl.h"
- #include "esl_event.h"
- #include "esl_threadmutex.h"
- #include "esl_config.h"
-}
-
+#include "esl.h"
+#include "esl_event.h"
+#include "esl_threadmutex.h"
+#include "esl_config.h"
class conn_event_handler : public QObject
{
-
Q_OBJECT
public:
conn_event_handler();
~conn_event_handler();
- void getConnected(QString, int, QString);
- void getDisconnected(void);
- bool isConnected(void);
+ void Connect(const QString&, int, const QString&);
+ void Disconnect(void);
+ bool isConnected(void) const;
private slots:
void handleError();
void readClient(void);
public slots:
- void sendMessage(QString);
+ void sendMessage(const QString&);
private:
- void handleRecvMessage(QString);
+ void handleRecvMessage(const QString&);
esl_handle_t handle;
signals:
- void connectionError(QString);
- void gotConnected(void);
- void messageSignal(QString);
+ void connectionError(const QString&);
+ void onConnected(void);
+ void messageSignal(const QString&);
};
#endif // CONN_EVENT_HANDLER_H
Modified: freeswitch/trunk/scripts/contrib/jmesquita/fsgui/fsgui.cpp
==============================================================================
--- freeswitch/trunk/scripts/contrib/jmesquita/fsgui/fsgui.cpp (original)
+++ freeswitch/trunk/scripts/contrib/jmesquita/fsgui/fsgui.cpp Mon Jan 26 21:09:18 2009
@@ -25,21 +25,21 @@
delete ui;
}
-void FSGui::error(QString msg){
+void FSGui::error(const QString &msg){
ui->statusBar->showMessage(msg);
}
-void FSGui::connectSlot(QString hostname, QString port, QString password){
+void FSGui::connectSlot(const QString& hostname, const QString& port, const QString& password){
socket = new conn_event_handler();
connect( socket , SIGNAL( connectionError(QString) ),
this, SLOT( error(QString) ) );
- connect(socket , SIGNAL( gotConnected() ),
+ connect(socket , SIGNAL( onConnected() ),
this, SLOT(connectionSuccessful()));
connect(socket , SIGNAL( messageSignal(QString) ),
this, SLOT( messageSlot(QString) ));
connect(this, SIGNAL(btnSendClickedSignal(QString)),
socket, SLOT(sendMessage(QString)));
- socket->getConnected(hostname, port.toInt(), password);
+ socket->Connect(hostname, port.toInt(), password);
ui->btnSend->setEnabled(true);
}
@@ -53,7 +53,7 @@
ui->lineCmd->clear();
}
-void FSGui::lineCmdEditedSlot(QString text)
+void FSGui::lineCmdEditedSlot(const QString& text)
{
if (socket->isConnected() && !text.isEmpty())
{
@@ -65,7 +65,7 @@
}
}
-void FSGui::messageSlot(QString msg)
+void FSGui::messageSlot(const QString& msg)
{
if (!msg.isEmpty())
{
Modified: freeswitch/trunk/scripts/contrib/jmesquita/fsgui/fsgui.h
==============================================================================
--- freeswitch/trunk/scripts/contrib/jmesquita/fsgui/fsgui.h (original)
+++ freeswitch/trunk/scripts/contrib/jmesquita/fsgui/fsgui.h Mon Jan 26 21:09:18 2009
@@ -4,7 +4,6 @@
#include <QtGui/QMainWindow>
#include "conn_event_handler.h"
-
namespace Ui
{
class FSGuiClass;
@@ -25,15 +24,15 @@
QLabel * statusBarLabel;
private slots:
- void error(QString);
+ void error(const QString&);
void connectionSuccessful(void);
- void connectSlot(QString, QString, QString);
+ void connectSlot(const QString&, const QString&, const QString&);
void btnSendClickedSlot();
- void lineCmdEditedSlot(QString);
- void messageSlot(QString);
+ void lineCmdEditedSlot(const QString&);
+ void messageSlot(const QString&);
signals:
- void btnSendClickedSignal(QString);
+ void btnSendClickedSignal(const QString&);
};
More information about the Freeswitch-svn
mailing list