Revision
14572
Author
jmesquita
Date
2009-08-19 17:05:18 -0500 (Wed, 19 Aug 2009)

Log Message

We can see call, channels and events in realtime and with filtering.

Modified Paths

Diff

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/interfaces/monitorstatemachine.cpp (14571 => 14572)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/interfaces/monitorstatemachine.cpp	2009-08-19 18:34:29 UTC (rev 14571)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/interfaces/monitorstatemachine.cpp	2009-08-19 22:05:18 UTC (rev 14572)
@@ -2,6 +2,10 @@
 #include "eslconnection.h"
 #include "esl.h"
 
+Event::Event(QHash<QString, QString> headers)
+        : _headers(headers)
+{}
+
 State::State(int state_id, QString state_name, QHash<QString, QString> variables)
         : _state_id(state_id),
         _state_name(state_name),
@@ -154,4 +158,17 @@
         }
     }
 
+    /* Append new event to uuid */
+    QString event_uuid = e._headers.value("Unique-ID");
+    if (!event_uuid.isEmpty())
+    {
+        Event *event = new Event(e._headers);
+        Channel * chan = _channels.value(event_uuid, NULL);
+        if (!chan)
+            chan = _inactive_channels.value(event_uuid, NULL);
+        if (!chan)
+            qDebug() << QString("Event %1 has no uuid.").arg(e.getType());
+        chan->addEvent(event);
+        emit newEvent(chan, event);
+    }
 }

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/interfaces/monitorstatemachine.h (14571 => 14572)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/interfaces/monitorstatemachine.h	2009-08-19 18:34:29 UTC (rev 14571)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/interfaces/monitorstatemachine.h	2009-08-19 22:05:18 UTC (rev 14572)
@@ -7,6 +7,16 @@
 
 class ESLconnection;
 
+class Event
+{
+private:
+    QHash<QString, QString> _headers;
+public:
+    Event(QHash<QString, QString> headers);
+    QString getEventName() { return _headers.value("Event-Name"); }
+    QHash<QString, QString> getHeaders() { return _headers; }
+};
+
 class State
 {
 private:
@@ -27,6 +37,7 @@
     QString *_uuid;
     QList <State *> _states;
     State *_currentConfig;
+    QList<Event *> _events;
 public:
     Channel(QString uuid, State *state);
     QHash<QString, QString> getCurrentStateVariables() { return _currentConfig->getHeaders(); }
@@ -35,6 +46,9 @@
     QString getCurrentStateHeader(QString header) { return _currentConfig->getHeader(header); }
     void stateChanged(State *state) { _states.append(state); _currentConfig = state; }
     QList <State *> getStates() { return _states; }
+    void addEvent(Event * event) { _events.append(event); }
+    QList<Event *> getEvents() { return _events; }
+    Event * getEvent(int i) { return _events.at(i); }
 };
 
 class Call
@@ -79,6 +93,7 @@
     void callCreated(Call *);
     void callDestroyed(Call *);
     void channelDestroyed(Channel *);
+    void newEvent(Channel *, Event *);
 };
 
 #endif // MONITORSTATEMACHINE_H

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/realtimemodels.cpp (14571 => 14572)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/realtimemodels.cpp	2009-08-19 18:34:29 UTC (rev 14571)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/realtimemodels.cpp	2009-08-19 22:05:18 UTC (rev 14572)
@@ -20,3 +20,23 @@
 
     return (_uuid_list.contains(sourceModel()->data(index0, Qt::UserRole).toString()));
 }
+
+EventSortModel::EventSortModel(QObject *parent) :
+        QSortFilterProxyModel(parent)
+{}
+
+void EventSortModel::setUUIDFilter(QString uuid)
+{
+    _uuid = uuid;
+    invalidateFilter();
+}
+
+bool EventSortModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
+{
+    QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
+
+    if (_uuid.isEmpty())
+        return false;
+
+    return (sourceModel()->data(index0, Qt::UserRole).toString() == _uuid);
+}

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/realtimemodels.h (14571 => 14572)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/realtimemodels.h	2009-08-19 18:34:29 UTC (rev 14571)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/realtimemodels.h	2009-08-19 22:05:18 UTC (rev 14572)
@@ -16,4 +16,17 @@
     QList<QString> _uuid_list;
 };
 
+class EventSortModel : public QSortFilterProxyModel {
+
+    Q_OBJECT
+
+public:
+    EventSortModel(QObject *parent = 0);
+    void setUUIDFilter(QString uuid);
+
+protected:
+     bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
+    QString _uuid;
+};
+
 #endif // REALTIMEMODELS_H

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/realtimestatisticsdialog.cpp (14571 => 14572)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/realtimestatisticsdialog.cpp	2009-08-19 18:34:29 UTC (rev 14571)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/realtimestatisticsdialog.cpp	2009-08-19 22:05:18 UTC (rev 14572)
@@ -11,6 +11,14 @@
 {
     m_ui->setupUi(this);
 
+    /* Connect event stuff */
+    connect(sm, SIGNAL(newEvent(Channel*,Event*)),
+            this, SLOT(newEvent(Channel*,Event*)));
+    connect(m_ui->listActiveEvents, SIGNAL(clicked(QModelIndex)),
+            this, SLOT(activeEventSelected(QModelIndex)));
+    connect(m_ui->listInactiveEvents, SIGNAL(clicked(QModelIndex)),
+            this, SLOT(inactiveEventSelected(QModelIndex)));
+
     /* Connect channel stuff */
     connect(sm, SIGNAL(channelCreated(Channel*)),
             this, SLOT(channelCreate(Channel*)));
@@ -33,6 +41,7 @@
     connect(m_ui->listInactiveCalls, SIGNAL(itemSelectionChanged()),
             this, SLOT(inactiveCallSelectionChanged()));
 
+    /* Channel models */
     _channel_model = new QStandardItemModel(this);
     _channel_sort_model = new ChannelSortModel(this);
     _channel_sort_model->setSourceModel(_channel_model);
@@ -43,6 +52,13 @@
     _inactive_channel_sort_model->setSourceModel(_inactive_channel_model);
     m_ui->listInactiveChannels->setModel(_inactive_channel_sort_model);
 
+    /* Event models */
+    _event_model = new QStandardItemModel(this);
+    _event_sort_model = new EventSortModel(this);
+    _event_sort_model->setSourceModel(_event_model);
+    m_ui->listActiveEvents->setModel(_event_sort_model);
+    m_ui->listInactiveEvents->setModel(_event_sort_model);
+
 }
 
 RealtimeStatisticsDialog::~RealtimeStatisticsDialog()
@@ -68,9 +84,9 @@
     if (!ch)
         return;
 
-    QStandardItem *item = new QStandardItem(QString("%1 - %2").arg(ch->getUUID(), ch->getCurrentStateHeader("Channel-State")));
+    QStandardItem *item = new QStandardItem(QString("%1 - %2").arg(ch->getUUID()));
     item->setData(ch->getUUID(), Qt::UserRole);
-    _channel_model->insertRow(0, item);
+    _channel_model->appendRow(item);
 }
 
 void RealtimeStatisticsDialog::channelDestroy(Channel *ch)
@@ -86,10 +102,13 @@
         if (item->data(Qt::UserRole) == ch->getUUID())
         {
             if (selectedIndex.isValid() && selectedIndex.data(Qt::UserRole) == ch->getUUID())
-                m_ui->listActiveVariables->clear();
+            {
+                m_ui->listActiveHeaders->clear();
+            }
 
             _channel_model->takeRow(item->index().row());
-            _inactive_channel_model->insertRow(0, item);
+            _inactive_channel_model->appendRow(item);
+            _event_sort_model->setUUIDFilter("");
         }
     }
 }
@@ -107,7 +126,6 @@
             {
                 activeChannelSelected(_channel_model->indexFromItem(item));
             }
-        item->setText(QString("%1 - %2").arg(ch->getUUID(), ch->getCurrentStateHeader("Channel-State")));
     }
 
     foreach (QStandardItem *item, _inactive_channel_model->findItems("*", Qt::MatchWildcard | Qt::MatchRecursive))
@@ -117,38 +135,62 @@
             {
                 inactiveChannelSelected(_inactive_channel_model->indexFromItem(item));
             }
-        item->setText(QString("%1 - %2").arg(ch->getUUID(), ch->getCurrentStateHeader("Channel-State")));
     }
 }
 
 void RealtimeStatisticsDialog::activeChannelSelected(QModelIndex index)
 {
-    m_ui->listActiveVariables->clear();
 
+    m_ui->listActiveHeaders->clear();
+
     Channel * ch = _sm->getChannel(index.data(Qt::UserRole).toString());
     if (!ch)
         return;
 
-    foreach (QString key, ch->getCurrentStateVariables().keys())
-    {
-        m_ui->listActiveVariables->addItem(QString("%1 = %2").arg(key, ch->getCurrentStateVariables().value(key)));
-    }
+    _event_sort_model->setUUIDFilter(ch->getUUID());
 }
 
 void RealtimeStatisticsDialog::inactiveChannelSelected(QModelIndex index)
 {
-    m_ui->listInactiveVariables->clear();
+    m_ui->listActiveHeaders->clear();
 
     Channel * ch = _sm->getInactiveChannel(index.data(Qt::UserRole).toString());
     if (!ch)
         return;
 
-    foreach (QString key, ch->getCurrentStateVariables().keys())
+    _event_sort_model->setUUIDFilter(ch->getUUID());
+}
+
+void RealtimeStatisticsDialog::activeEventSelected(QModelIndex index)
+{
+    Channel *ch = _sm->getChannel(index.data(Qt::UserRole).toString());
+    if (!ch)
+        return;
+
+    m_ui->listActiveHeaders->clear();
+
+    Event * e = ch->getEvent(index.row());
+    foreach (QString key, e->getHeaders().keys())
     {
-        m_ui->listInactiveVariables->addItem(QString("%1 = %2").arg(key, ch->getCurrentStateVariables().value(key)));
+        m_ui->listActiveHeaders->addItem(QString("%1 = %2").arg(key, e->getHeaders().value(key)));
     }
 }
 
+void RealtimeStatisticsDialog::inactiveEventSelected(QModelIndex index)
+{
+    Channel *ch = _sm->getInactiveChannel(index.data(Qt::UserRole).toString());
+    if (!ch)
+        return;
+
+    m_ui->listInactiveHeaders->clear();
+
+    Event * e = ch->getEvent(index.row());
+    foreach (QString key, e->getHeaders().keys())
+    {
+        m_ui->listInactiveHeaders->addItem(QString("%1 = %2").arg(key, e->getHeaders().value(key)));
+    }
+}
+
 void RealtimeStatisticsDialog::activeCallSelectionChanged()
 {
     QList<QListWidgetItem *> selection = m_ui->listActiveCalls->selectedItems();
@@ -212,3 +254,13 @@
         }
     }
 }
+
+void RealtimeStatisticsDialog::newEvent(Channel *ch, Event *e)
+{
+    if (!ch && !e)
+        return;
+
+    QStandardItem *item = new QStandardItem(e->getEventName());
+    item->setData(ch->getUUID(), Qt::UserRole);
+    _event_model->appendRow(item);
+}

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/realtimestatisticsdialog.h (14571 => 14572)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/realtimestatisticsdialog.h	2009-08-19 18:34:29 UTC (rev 14571)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/realtimestatisticsdialog.h	2009-08-19 22:05:18 UTC (rev 14572)
@@ -8,9 +8,11 @@
 }
 
 class MonitorStateMachine;
+class Event;
 class Channel;
 class Call;
 class ChannelSortModel;
+class EventSortModel;
 
 
 class RealtimeStatisticsDialog : public QDialog {
@@ -29,18 +31,27 @@
     void channelStateChanged(Channel *);
     void activeChannelSelected(QModelIndex);
     void inactiveChannelSelected(QModelIndex);
+    void activeEventSelected(QModelIndex);
+    void inactiveEventSelected(QModelIndex);
     void activeCallSelectionChanged();
     void inactiveCallSelectionChanged();
     void callCreate(Call *);
     void callDestroy(Call *);
+    void newEvent(Channel *, Event *);
 
 private:
     Ui::RealtimeStatisticsDialog *m_ui;
     MonitorStateMachine *_sm;
+    /* Channel models */
     QStandardItemModel *_channel_model;
     ChannelSortModel *_channel_sort_model;
     QStandardItemModel *_inactive_channel_model;
     ChannelSortModel *_inactive_channel_sort_model;
+    /* Event models */
+    QStandardItemModel *_event_model;
+    EventSortModel *_event_sort_model;
+    QStandardItemModel *_inactive_event_model;
+    EventSortModel *_inactive_event_sort_model;
 };
 
 #endif // REALTIMESTATISTICSDIALOG_H

Modified: freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/realtimestatisticsdialog.ui (14571 => 14572)


--- freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/realtimestatisticsdialog.ui	2009-08-19 18:34:29 UTC (rev 14571)
+++ freeswitch/trunk/contrib/jmesquita/fsgui/src/plugins/consoleplugin/realtimestatisticsdialog.ui	2009-08-19 22:05:18 UTC (rev 14572)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>612</width>
-    <height>534</height>
+    <width>1186</width>
+    <height>496</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -16,7 +16,7 @@
   <property name="sizeGripEnabled">
    <bool>true</bool>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_2">
+  <layout class="QHBoxLayout" name="horizontalLayout_6">
    <item>
     <widget class="QTabWidget" name="tabWidget">
      <property name="currentIndex">
@@ -28,58 +28,73 @@
       </attribute>
       <layout class="QHBoxLayout" name="horizontalLayout_5">
        <item>
-        <layout class="QVBoxLayout" name="verticalLayout">
-         <item>
-          <widget class="QGroupBox" name="groupBox">
-           <property name="title">
-            <string>Channels</string>
-           </property>
-           <layout class="QHBoxLayout" name="horizontalLayout">
-            <item>
-             <widget class="QListView" name="listActiveChannels">
-              <property name="editTriggers">
-               <set>QAbstractItemView::NoEditTriggers</set>
-              </property>
-              <property name="alternatingRowColors">
-               <bool>true</bool>
-              </property>
-             </widget>
-            </item>
-           </layout>
-          </widget>
-         </item>
-         <item>
-          <widget class="QGroupBox" name="groupBox_3">
-           <property name="title">
-            <string>Calls</string>
-           </property>
-           <layout class="QHBoxLayout" name="horizontalLayout_3">
-            <item>
-             <widget class="QListWidget" name="listActiveCalls">
-              <property name="editTriggers">
-               <set>QAbstractItemView::NoEditTriggers</set>
-              </property>
-              <property name="alternatingRowColors">
-               <bool>true</bool>
-              </property>
-              <property name="selectionMode">
-               <enum>QAbstractItemView::ExtendedSelection</enum>
-              </property>
-             </widget>
-            </item>
-           </layout>
-          </widget>
-         </item>
-        </layout>
+        <widget class="QGroupBox" name="groupBox_3">
+         <property name="title">
+          <string>Calls</string>
+         </property>
+         <layout class="QHBoxLayout" name="horizontalLayout_3">
+          <item>
+           <widget class="QListWidget" name="listActiveCalls">
+            <property name="editTriggers">
+             <set>QAbstractItemView::NoEditTriggers</set>
+            </property>
+            <property name="alternatingRowColors">
+             <bool>true</bool>
+            </property>
+            <property name="selectionMode">
+             <enum>QAbstractItemView::ExtendedSelection</enum>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
        </item>
        <item>
+        <widget class="QGroupBox" name="groupBox">
+         <property name="title">
+          <string>Channels</string>
+         </property>
+         <layout class="QHBoxLayout" name="horizontalLayout">
+          <item>
+           <widget class="QListView" name="listActiveChannels">
+            <property name="editTriggers">
+             <set>QAbstractItemView::NoEditTriggers</set>
+            </property>
+            <property name="alternatingRowColors">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item>
+        <widget class="QGroupBox" name="groupBox_4">
+         <property name="title">
+          <string>Events</string>
+         </property>
+         <layout class="QHBoxLayout" name="horizontalLayout_4">
+          <item>
+           <widget class="QListView" name="listActiveEvents">
+            <property name="editTriggers">
+             <set>QAbstractItemView::NoEditTriggers</set>
+            </property>
+            <property name="alternatingRowColors">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item>
         <widget class="QGroupBox" name="groupBox_2">
          <property name="title">
-          <string>Variables</string>
+          <string>Headers</string>
          </property>
          <layout class="QHBoxLayout" name="horizontalLayout_2">
           <item>
-           <widget class="QListWidget" name="listActiveVariables">
+           <widget class="QListWidget" name="listActiveHeaders">
             <property name="editTriggers">
              <set>QAbstractItemView::NoEditTriggers</set>
             </property>
@@ -100,66 +115,81 @@
       <attribute name="title">
        <string>Inactive</string>
       </attribute>
-      <layout class="QHBoxLayout" name="horizontalLayout_12">
+      <layout class="QHBoxLayout" name="horizontalLayout_11">
        <item>
-        <layout class="QVBoxLayout" name="verticalLayout_4">
-         <item>
-          <widget class="QGroupBox" name="groupBox_7">
-           <property name="title">
-            <string>Channels</string>
-           </property>
-           <layout class="QHBoxLayout" name="horizontalLayout_9">
-            <item>
-             <widget class="QListView" name="listInactiveChannels">
-              <property name="editTriggers">
-               <set>QAbstractItemView::NoEditTriggers</set>
-              </property>
-              <property name="alternatingRowColors">
-               <bool>true</bool>
-              </property>
-             </widget>
-            </item>
-           </layout>
-          </widget>
-         </item>
-         <item>
-          <widget class="QGroupBox" name="groupBox_8">
-           <property name="title">
-            <string>Calls</string>
-           </property>
-           <layout class="QHBoxLayout" name="horizontalLayout_10">
-            <item>
-             <widget class="QListWidget" name="listInactiveCalls">
-              <property name="editTriggers">
-               <set>QAbstractItemView::NoEditTriggers</set>
-              </property>
-              <property name="alternatingRowColors">
-               <bool>true</bool>
-              </property>
-              <property name="selectionMode">
-               <enum>QAbstractItemView::ExtendedSelection</enum>
-              </property>
-             </widget>
-            </item>
-           </layout>
-          </widget>
-         </item>
-        </layout>
+        <widget class="QGroupBox" name="groupBox_8">
+         <property name="title">
+          <string>Calls</string>
+         </property>
+         <layout class="QHBoxLayout" name="horizontalLayout_10">
+          <item>
+           <widget class="QListWidget" name="listInactiveCalls">
+            <property name="editTriggers">
+             <set>QAbstractItemView::NoEditTriggers</set>
+            </property>
+            <property name="alternatingRowColors">
+             <bool>true</bool>
+            </property>
+            <property name="selectionMode">
+             <enum>QAbstractItemView::ExtendedSelection</enum>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
        </item>
        <item>
-        <widget class="QGroupBox" name="groupBox_9">
+        <widget class="QGroupBox" name="groupBox_7">
          <property name="title">
-          <string>Variables</string>
+          <string>Channels</string>
          </property>
-         <layout class="QHBoxLayout" name="horizontalLayout_11">
+         <layout class="QHBoxLayout" name="horizontalLayout_9">
           <item>
-           <widget class="QListWidget" name="listInactiveVariables">
+           <widget class="QListView" name="listInactiveChannels">
             <property name="editTriggers">
              <set>QAbstractItemView::NoEditTriggers</set>
             </property>
             <property name="alternatingRowColors">
              <bool>true</bool>
             </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item>
+        <widget class="QGroupBox" name="groupBox_6">
+         <property name="title">
+          <string>Events</string>
+         </property>
+         <layout class="QHBoxLayout" name="horizontalLayout_8">
+          <item>
+           <widget class="QListView" name="listInactiveEvents">
+            <property name="editTriggers">
+             <set>QAbstractItemView::NoEditTriggers</set>
+            </property>
+            <property name="alternatingRowColors">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item>
+        <widget class="QGroupBox" name="groupBox_5">
+         <property name="title">
+          <string>Headers</string>
+         </property>
+         <layout class="QHBoxLayout" name="horizontalLayout_7">
+          <item>
+           <widget class="QListWidget" name="listInactiveHeaders">
+            <property name="editTriggers">
+             <set>QAbstractItemView::NoEditTriggers</set>
+            </property>
+            <property name="alternatingRowColors">
+             <bool>true</bool>
+            </property>
             <property name="sortingEnabled">
              <bool>false</bool>
             </property>