Revision
14218
Author
jmesquita
Date
2009-07-13 02:27:49 -0500 (Mon, 13 Jul 2009)

Log Message

We connect, disconnect, send and receive stuff. But not all of it, yet

Modified Paths

Diff

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/esl_connection.cpp (14217 => 14218)


--- freeswitch/trunk/contrib/jmesquita/fsgui/esl_connection.cpp	2009-07-13 07:15:00 UTC (rev 14217)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/esl_connection.cpp	2009-07-13 07:27:49 UTC (rev 14218)
@@ -1,3 +1,4 @@
+#include <QtGui>
 #include "esl_oop.h"
 #include "esl_connection.h"
 
@@ -12,7 +13,7 @@
 void eslConnectionManager::doConnect(QString host, QString pass, QString port)
 {
     connection = new ESLconnection(host.toAscii(), port.toAscii(), pass.toAscii());
-    eslSetLogLevel(0);
+    eslSetLogLevel(7);
     isConnected = false;
 }
 
@@ -21,6 +22,23 @@
         connection->disconnect();
 }
 
+void eslConnectionManager::sendCmd(QString string)
+{
+    if (connection->connected())
+    {
+        QStringList list = string.split(" ", QString::SkipEmptyParts, Qt::CaseSensitive);
+        QString cmd = list.takeFirst();
+        QString arg("");
+        for (int i=0; i < list.size(); i++)
+        {
+            arg.append(list[i]);
+            if (i != list.size()-1)
+                arg.append(" ");
+        }
+        connection->api(cmd.toAscii(), arg.toAscii());
+    }
+}
+
 void eslConnectionManager::run()
 {
     forever
@@ -39,7 +57,6 @@
         }
         else if (connection->connected() && isConnected)
         {
-            /* We should process our event queue here */
             ESLevent * event = connection->recvEventTimed(10);
             if (event)
             {

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/esl_connection.h (14217 => 14218)


--- freeswitch/trunk/contrib/jmesquita/fsgui/esl_connection.h	2009-07-13 07:15:00 UTC (rev 14217)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/esl_connection.h	2009-07-13 07:27:49 UTC (rev 14218)
@@ -16,6 +16,7 @@
     eslConnectionManager(QString,QString,QString);
     void doConnect(QString, QString, QString);
     void doDisconnect();
+    void sendCmd(QString);
 signals:
     void gotDisconnected();
     void gotConnected();

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/fs_gui.cpp (14217 => 14218)


--- freeswitch/trunk/contrib/jmesquita/fsgui/fs_gui.cpp	2009-07-13 07:15:00 UTC (rev 14217)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/fs_gui.cpp	2009-07-13 07:27:49 UTC (rev 14218)
@@ -1,7 +1,6 @@
 #include "fs_gui.h"
 #include "ui_fs_gui.h"
 #include "esl_oop.h"
-#include <iostream>
 
 Cfsgui::Cfsgui(QWidget *parent) :
     QMainWindow(parent),
@@ -17,6 +16,10 @@
             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()
@@ -35,12 +38,26 @@
     eslConnection->doDisconnect();
 }
 
+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()
 {
     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()
 {
@@ -48,6 +65,7 @@
     appendConsoleText("Disconnected!");
     m_ui->actionConnect->setEnabled(true);
     m_ui->actionDisconnect->setDisabled(true);
+    m_ui->lineCmd->setDisabled(true);
 }
 
 void Cfsgui::gotEventSlot(ESLevent * event)

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/fs_gui.h (14217 => 14218)


--- freeswitch/trunk/contrib/jmesquita/fsgui/fs_gui.h	2009-07-13 07:15:00 UTC (rev 14217)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/fs_gui.h	2009-07-13 07:27:49 UTC (rev 14218)
@@ -29,6 +29,8 @@
     void gotDisconnectedSlot();
     void gotEventSlot(ESLevent *);
     void getDisconnectedSlot();
+    void typedCommand();
+    void sendCommand();
 
 private:
     Ui::Cfsgui *m_ui;

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/fs_gui.ui (14217 => 14218)


--- freeswitch/trunk/contrib/jmesquita/fsgui/fs_gui.ui	2009-07-13 07:15:00 UTC (rev 14217)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/fs_gui.ui	2009-07-13 07:27:49 UTC (rev 14218)
@@ -29,7 +29,11 @@
      </widget>
     </item>
     <item row="1" column="0">
-     <widget class="QLineEdit" name="lineCmd"/>
+     <widget class="QLineEdit" name="lineCmd">
+      <property name="enabled">
+       <bool>false</bool>
+      </property>
+     </widget>
     </item>
     <item row="1" column="1">
      <widget class="QPushButton" name="btnSend">
@@ -39,14 +43,11 @@
       <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>false</bool>
+       <bool>true</bool>
       </property>
      </widget>
     </item>
@@ -58,7 +59,7 @@
      <x>0</x>
      <y>0</y>
      <width>600</width>
-     <height>22</height>
+     <height>26</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuFile">