Add the supported protocols internals dialog.
authorGerald Combs <gerald@wireshark.org>
Thu, 1 Oct 2015 17:18:56 +0000 (10:18 -0700)
committerGerald Combs <gerald@wireshark.org>
Thu, 1 Oct 2015 21:11:47 +0000 (21:11 +0000)
Includes a bonus search field.

Change-Id: I0b101b725d531a59c8a2fdbfbf4690b507135546
Reviewed-on: https://code.wireshark.org/review/10731
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
ui/qt/CMakeLists.txt
ui/qt/Makefile.am
ui/qt/Makefile.common
ui/qt/Wireshark.pro
ui/qt/main_window.h
ui/qt/main_window.ui
ui/qt/main_window_slots.cpp
ui/qt/supported_protocols_dialog.cpp [new file with mode: 0644]
ui/qt/supported_protocols_dialog.h [new file with mode: 0644]
ui/qt/supported_protocols_dialog.ui [new file with mode: 0644]

index 7be8a8fce1d82b1bb399593b6e035cb00b27865c..efb028110b9f7b477cd3a12a5895b526c234d3b2 100644 (file)
@@ -130,6 +130,7 @@ set(WIRESHARK_QT_HEADERS
        service_response_time_dialog.h
        simple_statistics_dialog.h
        stock_icon_tool_button.h
+       supported_protocols_dialog.h
        syntax_line_edit.h
        tap_parameter_dialog.h
        tcp_stream_dialog.h
@@ -269,6 +270,7 @@ set(WIRESHARK_QT_SRC
        sparkline_delegate.cpp
        stock_icon.cpp
        stock_icon_tool_button.cpp
+       supported_protocols_dialog.cpp
        syntax_line_edit.cpp
        tap_parameter_dialog.cpp
        tcp_stream_dialog.cpp
@@ -384,6 +386,7 @@ set(WIRESHARK_QT_UI
        search_frame.ui
        sequence_dialog.ui
        splash_overlay.ui
+       supported_protocols_dialog.ui
        tap_parameter_dialog.ui
        tcp_stream_dialog.ui
        time_shift_dialog.ui
index 5bc4678f52364883558a40732f7f6be20aa2e772..e4198c630a96d3843f3156b1fc22b7a46743c69f 100644 (file)
@@ -264,6 +264,8 @@ sctp_graph_byte_dialog.$(OBJEXT): ui_sctp_graph_byte_dialog.h
 
 splash_overlay.$(OBJEXT): ui_splash_overlay.h
 
+supported_protocols_dialog.$(OBJEXT): ui_supported_protocols_dialog.h
+
 tap_parameter_dialog.$(OBJEXT): ui_tap_parameter_dialog.h
 
 tcp_stream_dialog.$(OBJEXT): ui_tcp_stream_dialog.h
index e12e96e90fc0e570e7cd17569ed9b92e6de298df..ab8c3c9086923e7786197b088789ce0d0aa5edcd 100644 (file)
@@ -97,6 +97,7 @@ NODIST_GENERATED_HEADER_FILES =       \
        ui_search_frame.h       \
        ui_sequence_dialog.h    \
        ui_splash_overlay.h     \
+       ui_supported_protocols_dialog.h \
        ui_tap_parameter_dialog.h       \
        ui_tcp_stream_dialog.h  \
        ui_time_shift_dialog.h  \
@@ -251,6 +252,7 @@ MOC_HDRS =  \
        splash_overlay.h        \
        stats_tree_dialog.h     \
        stock_icon_tool_button.h        \
+       supported_protocols_dialog.h    \
        syntax_line_edit.h      \
        tap_parameter_dialog.h  \
        tcp_stream_dialog.h     \
@@ -334,6 +336,7 @@ UI_FILES =  \
        search_frame.ui \
        sequence_dialog.ui      \
        splash_overlay.ui       \
+       supported_protocols_dialog.ui   \
        tap_parameter_dialog.ui \
        tcp_stream_dialog.ui    \
        time_shift_dialog.ui    \
@@ -497,6 +500,7 @@ WIRESHARK_QT_SRC =  \
        splash_overlay.cpp      \
        stock_icon.cpp          \
        stock_icon_tool_button.cpp      \
+       supported_protocols_dialog.cpp  \
        syntax_line_edit.cpp    \
        tap_parameter_dialog.cpp        \
        tcp_stream_dialog.cpp   \
index 6129b5af8dceb9c9e138e7010111d823298d37a6..9e6a6a1c66f583c2334c6a36fe0c83dc7ef28f9e 100644 (file)
@@ -275,6 +275,7 @@ FORMS += \
     search_frame.ui \
     sequence_dialog.ui \
     splash_overlay.ui \
+    supported_protocols_dialog.ui \
     tap_parameter_dialog.ui \
     tcp_stream_dialog.ui \
     time_shift_dialog.ui \
@@ -648,6 +649,7 @@ HEADERS += \
     simple_dialog.h \
     sparkline_delegate.h \
     stock_icon_tool_button.h \
+    supported_protocols_dialog.h \
     syntax_line_edit.h \
     tap_parameter_dialog.h \
     time_shift_dialog.h \
index 7c8bc82bf64fd2d272b2ed4f5fd133df30ba9060..8f25f1e3343cbd656d93c983e6832e5c08668caf 100644 (file)
@@ -394,6 +394,7 @@ private slots:
 
     void on_actionViewInternalsConversationHashTables_triggered();
     void on_actionViewInternalsDissectorTables_triggered();
+    void on_actionViewInternalsSupportedProtocols_triggered();
 
     void openPacketDialog(bool from_reference = false);
     void on_actionViewShowPacketInNewWindow_triggered();
index e1bd077c5d6c45bd8a2d6d5a398dcd80b501410a..090d00dfef90afaf8789cf0171a7e67c777d7d32 100644 (file)
      </property>
      <addaction name="actionViewInternalsConversationHashTables"/>
      <addaction name="actionViewInternalsDissectorTables"/>
+     <addaction name="actionViewInternalsSupportedProtocols"/>
     </widget>
     <addaction name="actionViewMainToolbar"/>
     <addaction name="actionViewFilterToolbar"/>
     <string>Show each dissector table and its entries</string>
    </property>
   </action>
+  <action name="actionViewInternalsSupportedProtocols">
+   <property name="text">
+    <string>Supported Protocols</string>
+   </property>
+   <property name="toolTip">
+    <string>Show the currently supported protocols and display filter fields</string>
+   </property>
+  </action>
   <action name="actionContextCopyBytesHexTextDump">
    <property name="text">
     <string>Bytes as Hex + ASCII Dump</string>
index e3d7dae4e73b8ce4b28b14f10183f9d51db7da23..2579f02169fa31aff375b8b505b950f2f9354c11 100644 (file)
 #include "sequence_dialog.h"
 #include "stats_tree_dialog.h"
 #include "stock_icon.h"
+#include "supported_protocols_dialog.h"
 #include "tap_parameter_dialog.h"
 #include "tcp_stream_dialog.h"
 #include "time_shift_dialog.h"
@@ -2330,6 +2331,12 @@ void MainWindow::on_actionViewInternalsDissectorTables_triggered()
     dissector_tables_dlg->show();
 }
 
+void MainWindow::on_actionViewInternalsSupportedProtocols_triggered()
+{
+    SupportedProtocolsDialog *supported_protocols_dlg = new SupportedProtocolsDialog(this);
+    supported_protocols_dlg->show();
+}
+
 void MainWindow::on_actionViewShowPacketInNewWindow_triggered()
 {
     openPacketDialog();
diff --git a/ui/qt/supported_protocols_dialog.cpp b/ui/qt/supported_protocols_dialog.cpp
new file mode 100644 (file)
index 0000000..0a19307
--- /dev/null
@@ -0,0 +1,136 @@
+/* supported_protocols_dialog.cpp
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "supported_protocols_dialog.h"
+#include "ui_supported_protocols_dialog.h"
+
+#include "config.h"
+
+#include <glib.h>
+
+#include <epan/proto.h>
+
+#include <QTreeWidgetItem>
+#include <QElapsedTimer>
+
+#include "wireshark_application.h"
+
+enum { name_col_, filter_col_, type_col_, descr_col_ };
+
+SupportedProtocolsDialog::SupportedProtocolsDialog(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::SupportedProtocolsDialog),
+    field_count_(0)
+{
+    ui->setupUi(this);
+    setWindowTitle(wsApp->windowTitleString(tr("Supported Protocols")));
+
+    // XXX Use recent settings instead
+    if (parent) resize(parent->width() * 3 / 4, parent->height());
+
+    // Some of our names are unreasonably long.
+    int one_em = fontMetrics().height();
+    ui->protoTreeWidget->setColumnWidth(name_col_, one_em * 15);
+    ui->protoTreeWidget->setColumnWidth(filter_col_, one_em * 10);
+    ui->protoTreeWidget->setColumnWidth(type_col_, one_em * 12);
+    ui->protoTreeWidget->setColumnWidth(descr_col_, one_em * 30);
+
+    QTimer::singleShot(0, this, SLOT(fillTree()));
+}
+
+SupportedProtocolsDialog::~SupportedProtocolsDialog()
+{
+    delete ui;
+}
+
+void SupportedProtocolsDialog::updateStatistics()
+{
+    QLocale locale = QLocale::system();
+    QString hint = tr("%1 protocols, %2 fields.")
+            .arg(locale.toString(ui->protoTreeWidget->topLevelItemCount()))
+            .arg(locale.toString(field_count_));
+    ui->hintLabel->setText(hint);
+}
+
+void SupportedProtocolsDialog::fillTree()
+{
+    void *proto_cookie;
+    QList <QTreeWidgetItem *> proto_list;
+
+    for (int proto_id = proto_get_first_protocol(&proto_cookie); proto_id != -1;
+         proto_id = proto_get_next_protocol(&proto_cookie)) {
+        protocol_t *protocol = find_protocol_by_id(proto_id);
+        QTreeWidgetItem *proto_ti = new QTreeWidgetItem();
+        proto_ti->setText(name_col_, proto_get_protocol_short_name(protocol));
+        proto_ti->setText(filter_col_, proto_get_protocol_filter_name(proto_id));
+        // type_col_ empty
+        proto_ti->setText(descr_col_, proto_get_protocol_long_name(protocol));
+        proto_ti->setData(name_col_, Qt::UserRole, proto_id);
+        proto_list << proto_ti;
+    }
+
+    updateStatistics();
+    ui->protoTreeWidget->invisibleRootItem()->addChildren(proto_list);
+    ui->protoTreeWidget->sortByColumn(name_col_, Qt::AscendingOrder);
+
+    foreach (QTreeWidgetItem *proto_ti, proto_list) {
+        void *field_cookie;
+        int proto_id = proto_ti->data(name_col_, Qt::UserRole).toInt();
+        QList <QTreeWidgetItem *> field_list;
+        for (header_field_info *hfinfo = proto_get_first_protocol_field(proto_id, &field_cookie); hfinfo != NULL;
+             hfinfo = proto_get_next_protocol_field(proto_id, &field_cookie)) {
+            if (hfinfo->same_name_prev_id != -1) continue;
+
+            QTreeWidgetItem *field_ti = new QTreeWidgetItem();
+            field_ti->setText(name_col_, hfinfo->name);
+            field_ti->setText(filter_col_, hfinfo->abbrev);
+            field_ti->setText(type_col_, ftype_pretty_name(hfinfo->type));
+            field_ti->setText(descr_col_, hfinfo->blurb);
+            field_list << field_ti;
+
+            field_count_++;
+            if (field_count_ % 1000 == 0) updateStatistics();
+        }
+        std::sort(field_list.begin(), field_list.end());
+        proto_ti->addChildren(field_list);
+    }
+
+    updateStatistics();
+    ui->protoTreeWidget->sortByColumn(name_col_, Qt::AscendingOrder);
+}
+
+// Copied from DisplayFilterExpressionDialog
+void SupportedProtocolsDialog::on_searchLineEdit_textChanged(const QString &search_re)
+{
+    QTreeWidgetItemIterator it(ui->protoTreeWidget);
+    QRegExp regex(search_re, Qt::CaseInsensitive);
+    while (*it) {
+        bool hidden = true;
+        if (search_re.isEmpty() || (*it)->text(0).contains(regex)) {
+            hidden = false;
+        }
+        (*it)->setHidden(hidden);
+        if (!hidden && (*it)->parent()) {
+            (*it)->parent()->setHidden(false);
+        }
+        ++it;
+    }
+}
diff --git a/ui/qt/supported_protocols_dialog.h b/ui/qt/supported_protocols_dialog.h
new file mode 100644 (file)
index 0000000..1dd8ea2
--- /dev/null
@@ -0,0 +1,64 @@
+/* supported_protocols_dialog.h
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef SUPPORTED_PROTOCOLS_DIALOG_H
+#define SUPPORTED_PROTOCOLS_DIALOG_H
+
+#include <QDialog>
+
+namespace Ui {
+class SupportedProtocolsDialog;
+}
+
+class SupportedProtocolsDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit SupportedProtocolsDialog(QWidget *parent = 0);
+    ~SupportedProtocolsDialog();
+
+private:
+    Ui::SupportedProtocolsDialog *ui;
+
+    int field_count_;
+    void updateStatistics();
+
+private slots:
+    void fillTree();
+
+    void on_searchLineEdit_textChanged(const QString &search_re);
+};
+
+#endif // SUPPORTED_PROTOCOLS_DIALOG_H
+
+/*
+ * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
diff --git a/ui/qt/supported_protocols_dialog.ui b/ui/qt/supported_protocols_dialog.ui
new file mode 100644 (file)
index 0000000..fd1c6a2
--- /dev/null
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SupportedProtocolsDialog</class>
+ <widget class="QDialog" name="SupportedProtocolsDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>640</width>
+    <height>540</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QTreeWidget" name="protoTreeWidget">
+     <column>
+      <property name="text">
+       <string>Name</string>
+      </property>
+     </column>
+     <column>
+      <property name="text">
+       <string>Filter</string>
+      </property>
+     </column>
+     <column>
+      <property name="text">
+       <string>Type</string>
+      </property>
+     </column>
+     <column>
+      <property name="text">
+       <string>Description</string>
+      </property>
+     </column>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="searchLabel">
+       <property name="toolTip">
+        <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Search the list of field names.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+       </property>
+       <property name="text">
+        <string>Search:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="searchLineEdit"/>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QLabel" name="hintLabel">
+     <property name="text">
+      <string>&lt;small&gt;&lt;i&gt;Gathering protocol information…&lt;/i&gt;&lt;/small&gt;</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Close</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>SupportedProtocolsDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>SupportedProtocolsDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>