Revision
14289
Author
jmesquita
Date
2009-07-17 19:02:51 -0500 (Fri, 17 Jul 2009)

Log Message

Do proper connect/disconnect on tabs and add a Server manager entry to file menu

Modified Paths

Diff

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/resources/fs_gui.ui (14288 => 14289)


--- freeswitch/trunk/contrib/jmesquita/fsgui/resources/fs_gui.ui	2009-07-17 23:26:14 UTC (rev 14288)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/resources/fs_gui.ui	2009-07-18 00:02:51 UTC (rev 14289)
@@ -68,6 +68,8 @@
     <property name="title">
      <string>&amp;File</string>
     </property>
+    <addaction name="actionServerManager"/>
+    <addaction name="separator"/>
     <addaction name="actionConnect"/>
     <addaction name="actionDisconnect"/>
     <addaction name="separator"/>
@@ -128,6 +130,14 @@
     <string>&amp;Preferences</string>
    </property>
   </action>
+  <action name="actionServerManager">
+   <property name="text">
+    <string>&amp;Server Manager</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+M</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <resources/>

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/completers.cpp (14288 => 14289)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/completers.cpp	2009-07-17 23:26:14 UTC (rev 14288)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/completers.cpp	2009-07-18 00:02:51 UTC (rev 14289)
@@ -1,3 +1,40 @@
+/*
+ * 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 "completers.h"
 

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/consolepage.cpp (14288 => 14289)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/consolepage.cpp	2009-07-17 23:26:14 UTC (rev 14288)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/consolepage.cpp	2009-07-18 00:02:51 UTC (rev 14289)
@@ -50,9 +50,9 @@
     lineCmdEventFilter(new keyPressEventFilter(histCompleter))
 {
     m_ui->setupUi(this);
-    setConsoleBackground();
     connect(m_ui->comboLogLevel, SIGNAL(currentIndexChanged(int)),
             this, SLOT(loglevelChanged(int)));
+    setConsoleBackground();
     m_ui->lineCmd->installEventFilter(lineCmdEventFilter);
 }
 consolePage::~consolePage()
@@ -72,6 +72,19 @@
     QSettings settings(SETTINGS_ORGANIZATION, SETTINGS_APPLICATION);
     m_ui->textConsole->setPalette(settings.value("consoleBackgroundColor",QColor(Qt::white)).value<QColor>());
 }
+int consolePage::isConnected()
+{
+    if (eslConnection)
+        return eslConnection->connected();
+}
+void consolePage::doDisconnect()
+{
+    eslConnection->disconnect();
+}
+void consolePage::doConnect()
+{
+    eslConnection->doConnect();
+}
 void consolePage::init(QString host)
 {
     this->host = host;
@@ -153,18 +166,21 @@
     m_ui->lineCmd->setFocus();
     readSettings();
     eslConnection->sendRecv("event plain BACKGROUND_JOB");
+    emit gotConnected();
 }
 void consolePage::gotDisconnectedSlot()
 {
     appendConsoleText(tr("Disconnected!"));
     m_ui->lineCmd->setEnabled(eslConnection->connected());
     m_ui->comboLogLevel->setEnabled(eslConnection->connected());
+    emit gotDisconnected();
 }
 void consolePage::connectionFailedSlot(QString msg)
 {
     appendConsoleText("Connection Failed: "+msg);
     m_ui->lineCmd->setEnabled(eslConnection->connected());
     m_ui->comboLogLevel->setEnabled(eslConnection->connected());
+    emit gotDisconnected();
 }
 void consolePage::gotEventSlot(ESLevent * event)
 {

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp (14288 => 14289)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp	2009-07-17 23:26:14 UTC (rev 14288)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/fs_gui.cpp	2009-07-18 00:02:51 UTC (rev 14289)
@@ -52,12 +52,18 @@
     // Set the default status bar message
     m_ui->statusBar->showMessage(tr("Ready"));
 
+    connect(m_ui->actionServerManager, SIGNAL(triggered()),
+            this, SLOT(newConnectionFromDialog()));
     connect(m_ui->actionConnect, SIGNAL(triggered()),
-            this, SLOT(newConnectionFromDialog()));
+            this, SLOT(doConnect()));
+    connect(m_ui->actionDisconnect, SIGNAL(triggered()),
+            this, SLOT(doDisconnect()));
     connect(m_ui->actionAbout, SIGNAL(triggered()),
             this, SLOT(showAbout()));
     connect(m_ui->tabWidget, SIGNAL(tabCloseRequested(int)),
             this, SLOT(closeTab(int)));
+    connect(m_ui->tabWidget, SIGNAL(currentChanged(int)),
+            this, SLOT(changeTab(int)));
     connect(m_ui->actionPreferences, SIGNAL(triggered()),
             this, SLOT(showPreferences()));
 
@@ -117,6 +123,10 @@
     if (serverDialog->exec())
     {
         consolePage *page = new consolePage();
+        connect(page, SIGNAL(gotConnected()),
+                this, SLOT(gotConnected()));
+        connect(page, SIGNAL(gotDisconnected()),
+                this, SLOT(gotDisconnected()));
         m_ui->tabWidget->addTab(page, serverDialog->getHost());
         page->init(serverDialog->getHost());
         m_ui->tabWidget->setCurrentWidget(page);
@@ -129,6 +139,31 @@
     m_ui->tabWidget->removeTab(index);
     delete tab;
 }
+void Cfsgui::changeTab(int index)
+{
+    consolePage *tab = static_cast<consolePage *>(m_ui->tabWidget->widget(index));
+    if (tab)
+    {
+        if (tab->isConnected())
+        {
+            gotConnected();
+        }
+        else
+        {
+            gotDisconnected();
+        }
+    }
+}
+void Cfsgui::gotConnected()
+{
+    m_ui->actionConnect->setDisabled(true);
+    m_ui->actionDisconnect->setEnabled(true);
+}
+void Cfsgui::gotDisconnected()
+{
+    m_ui->actionConnect->setEnabled(true);
+    m_ui->actionDisconnect->setDisabled(true);
+}
 void Cfsgui::backgroundColorChanged()
 {
     for (int i = 0; i < m_ui->tabWidget->count(); i++)
@@ -137,3 +172,13 @@
         tab->setConsoleBackground();
     }
 }
+void Cfsgui::doDisconnect()
+{
+    consolePage *tab = static_cast<consolePage *>(m_ui->tabWidget->widget(m_ui->tabWidget->currentIndex()));
+    tab->doDisconnect();
+}
+void Cfsgui::doConnect()
+{
+    consolePage *tab = static_cast<consolePage *>(m_ui->tabWidget->widget(m_ui->tabWidget->currentIndex()));
+    tab->doConnect();
+}

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/completers.h (14288 => 14289)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/completers.h	2009-07-17 23:26:14 UTC (rev 14288)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/completers.h	2009-07-18 00:02:51 UTC (rev 14289)
@@ -1,3 +1,40 @@
+/*
+ * 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 COMPLETERS_H
 #define COMPLETERS_H
 

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/consolepage.h (14288 => 14289)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/consolepage.h	2009-07-17 23:26:14 UTC (rev 14288)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/consolepage.h	2009-07-18 00:02:51 UTC (rev 14289)
@@ -22,10 +22,16 @@
     ~consolePage();
     void init(QString host);
     void setConsoleBackground();
+    int isConnected();
+    void doConnect();
+    void doDisconnect();
 
 protected:
     virtual void changeEvent(QEvent *e);
     void appendConsoleText(const QString);
+signals:
+    void gotConnected();
+    void gotDisconnected();
 
 private slots:
     void gotConnectedSlot();

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h (14288 => 14289)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h	2009-07-17 23:26:14 UTC (rev 14288)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/include/fs_gui.h	2009-07-18 00:02:51 UTC (rev 14289)
@@ -64,7 +64,12 @@
     void showPreferences();
     void newConnectionFromDialog();
     void closeTab(int);
+    void changeTab(int);
     void backgroundColorChanged();
+    void doConnect();
+    void doDisconnect();
+    void gotDisconnected();
+    void gotConnected();
 
 private:
     Ui::Cfsgui *m_ui;