Add an initial "Decode As" dialog. Currently read-only.
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 22 Nov 2013 01:07:36 +0000 (01:07 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 22 Nov 2013 01:07:36 +0000 (01:07 +0000)
Fixup some of the Statistics menu items.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@53499 f5534014-38df-0310-8fa8-9805f1628bb7

12 files changed:
ui/gtk/decode_as_dlg.c
ui/qt/CMakeLists.txt
ui/qt/Makefile.am
ui/qt/Makefile.common
ui/qt/QtShark.pro
ui/qt/decode_as_dialog.cpp [new file with mode: 0644]
ui/qt/decode_as_dialog.h [new file with mode: 0644]
ui/qt/decode_as_dialog.ui [new file with mode: 0644]
ui/qt/main_window.h
ui/qt/main_window.ui
ui/qt/main_window_slots.cpp
ui/qt/wireshark_application.cpp

index 65dd576f7ab219f368aa724f53bc5aa44b69effe..c9eaede9175a6db70fc28c658ff3567730ac90b6 100644 (file)
@@ -290,12 +290,12 @@ decode_build_show_list (const gchar *table_name, ftenum_t selector_type,
     g_assert(user_data);
     g_assert(value);
 
-    current = (dissector_handle_t)dtbl_entry_get_handle((dtbl_entry_t *)value);
+    current = dtbl_entry_get_handle((dtbl_entry_t *)value);
     if (current == NULL)
         current_proto_name = "(none)";
     else
         current_proto_name = dissector_handle_get_short_name(current);
-    initial = (dissector_handle_t)dtbl_entry_get_initial_handle((dtbl_entry_t *)value);
+    initial = dtbl_entry_get_initial_handle((dtbl_entry_t *)value);
     if (initial == NULL)
         initial_proto_name = "(none)";
     else
index e1412ef49401eba81fc233fd16c629982d470ee9..587600bc221c100f9d9f0d36652b916df813b3aa 100644 (file)
@@ -37,6 +37,7 @@ set(WIRESHARK_QT_HEADERS
        color_dialog.h
        color_utils.h
        column_preferences_frame.h
+       decode_as_dialog.h
        display_filter_combo.h
        display_filter_edit.h
        elided_label.h
@@ -102,6 +103,7 @@ set(WIRESHARK_QT_SRC
        color_utils.cpp
        capture_preferences_frame.cpp
        column_preferences_frame.cpp
+       decode_as_dialog.cpp
        display_filter_combo.cpp
        display_filter_edit.cpp
        elided_label.cpp
@@ -167,6 +169,7 @@ set(DIRTY_FILES
 set(WIRESHARK_QT_UI
        capture_preferences_frame.ui
        column_preferences_frame.ui
+       decode_as_dialog.ui
        export_object_dialog.ui
        file_set_dialog.ui
        filter_expressions_preferences_frame.ui
index 36b3946668ad27970fe29b3189eee2814ecbb822..855dea607437ed7d157430098390e749e20fa94b 100644 (file)
@@ -128,6 +128,8 @@ capture_preferences_frame.cpp capture_preferences_frame.h: ui_capture_preference
 
 column_preferences_frame.cpp column_preferences_frame.h: ui_column_preferences_frame.h
 
+decode_as_dialog.cpp decode_as_dialog.h: ui_decode_as_dialog.h
+
 export_object_dialog.cpp export_object_dialog.h: ui_export_object_dialog.h
 
 file_set_dialog.cpp file_set_dialog.h: ui_file_set_dialog.h
index 73d6f9870ef38e8f22c6722de545fb363e3822a0..62c5aa5f0acd20abdd2995ee06376e95f37201fb 100644 (file)
@@ -33,6 +33,7 @@ GENERATED_HEADER_FILES =
 NODIST_GENERATED_HEADER_FILES = \
        ui_capture_preferences_frame.h \
        ui_column_preferences_frame.h \
+       ui_decode_as_dialog.h \
        ui_export_object_dialog.h \
        ui_file_set_dialog.h \
        ui_filter_expressions_preferences_frame.h \
@@ -106,6 +107,7 @@ MOC_HDRS = \
        color_utils.h \
        capture_preferences_frame.h \
        column_preferences_frame.h \
+       decode_as_dialog.h \
        display_filter_combo.h \
        display_filter_edit.h \
        elided_label.h \
@@ -159,6 +161,7 @@ MOC_HDRS = \
 UI_FILES = \
        capture_preferences_frame.ui    \
        column_preferences_frame.ui     \
+       decode_as_dialog.ui             \
        export_object_dialog.ui         \
        file_set_dialog.ui              \
        filter_expressions_preferences_frame.ui \
@@ -247,6 +250,7 @@ WIRESHARK_QT_SRC = \
        color_utils.cpp \
        capture_preferences_frame.cpp \
        column_preferences_frame.cpp \
+       decode_as_dialog.cpp \
        display_filter_combo.cpp \
        display_filter_edit.cpp \
        elided_label.cpp \
index b571c27d7ca319abb7b6f25fab8352a4ebdc7e3a..7e0a7a2e8f857b7e9d714823cc2b64f44bd76835 100644 (file)
@@ -224,6 +224,7 @@ HEADERS_WS_C  = \
 FORMS += \
     capture_preferences_frame.ui \
     column_preferences_frame.ui \
+    decode_as_dialog.ui \
     export_object_dialog.ui \
     file_set_dialog.ui \
     filter_expressions_preferences_frame.ui \
@@ -254,6 +255,7 @@ HEADERS += $$HEADERS_WS_C \
     accordion_frame.h \
     capture_preferences_frame.h \
     column_preferences_frame.h \
+    decode_as_dialog.h \
     elided_label.h \
     export_dissection_dialog.h \
     export_object_dialog.h \
@@ -549,6 +551,7 @@ SOURCES += \
     color_dialog.cpp \
     color_utils.cpp \
     column_preferences_frame.cpp \
+    decode_as_dialog.cpp \
     display_filter_combo.cpp \
     display_filter_edit.cpp \
     elided_label.cpp \
diff --git a/ui/qt/decode_as_dialog.cpp b/ui/qt/decode_as_dialog.cpp
new file mode 100644 (file)
index 0000000..9e6c65b
--- /dev/null
@@ -0,0 +1,167 @@
+/* stats_tree_dialog.h
+ *
+ * $Id$
+ *
+ * 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 "decode_as_dialog.h"
+#include "ui_decode_as_dialog.h"
+
+#include "epan/decode_as.h"
+#include "epan/dissectors/packet-dcerpc.h"
+
+#include "wireshark_application.h"
+
+#include <QTreeWidgetItem>
+
+#include <QDebug>
+
+const int field_col_    = 0;
+const int value_col_    = 1;
+const int default_col_  = 2;
+const int current_col_  = 3;
+
+DecodeAsDialog::DecodeAsDialog(QWidget *parent, capture_file *cf) :
+    QDialog(parent),
+    ui(new Ui::DecodeAsDialog),
+    cap_file_(cf)
+{
+    ui->setupUi(this);
+
+    connect(wsApp, SIGNAL(preferencesChanged()), this, SLOT(fillTable()));
+    fillTable();
+}
+
+DecodeAsDialog::~DecodeAsDialog()
+{
+    delete ui;
+}
+
+void DecodeAsDialog::setCaptureFile(capture_file *cf)
+{
+    cap_file_ = cf;
+    fillTable();
+}
+
+void DecodeAsDialog::fillTable()
+{
+    ui->decodeAsTreeWidget->clear();
+    dissector_all_tables_foreach_changed(buildChangedList, this);
+    decode_dcerpc_add_show_list(buildDceRpcChangedList, this);
+}
+
+void DecodeAsDialog::buildChangedList(const gchar *table_name, ftenum_t selector_type, gpointer key, gpointer value, gpointer user_data)
+{
+    DecodeAsDialog *da_dlg = (DecodeAsDialog *)user_data;
+    if (!da_dlg) return;
+
+    dissector_handle_t default_dh, current_dh;
+    QString value_str;
+    QString default_proto_name = "(none)", current_proto_name = "(none)";
+    QTreeWidgetItem *ti = new QTreeWidgetItem();
+
+    current_dh = dtbl_entry_get_handle((dtbl_entry_t *)value);
+    if (current_dh) {
+        current_proto_name = dissector_handle_get_short_name(current_dh);
+    }
+    default_dh = dtbl_entry_get_initial_handle((dtbl_entry_t *)value);
+    if (default_dh) {
+        default_proto_name = dissector_handle_get_short_name(default_dh);
+    }
+
+    switch (selector_type) {
+
+    case FT_UINT8:
+    case FT_UINT16:
+    case FT_UINT24:
+    case FT_UINT32:
+        switch (get_dissector_table_base(table_name)) {
+
+        case BASE_DEC:
+            value_str = QString::number(GPOINTER_TO_UINT(key));
+            break;
+
+        case BASE_HEX:
+            switch (get_dissector_table_selector_type(table_name)) {
+
+            case FT_UINT8:
+                value_str = QString("%1").arg(GPOINTER_TO_UINT(key), 2, 16, QChar('0'));
+                break;
+
+            case FT_UINT16:
+                value_str = QString("%1").arg(GPOINTER_TO_UINT(key), 4, 16, QChar('0'));
+                break;
+
+            case FT_UINT24:
+                value_str = QString("%1").arg(GPOINTER_TO_UINT(key), 6, 16, QChar('0'));
+                break;
+
+            case FT_UINT32:
+                value_str = QString("%1").arg(GPOINTER_TO_UINT(key), 8, 16, QChar('0'));
+                break;
+
+            default:
+                g_assert_not_reached();
+                break;
+            }
+            break;
+
+        case BASE_OCT:
+            value_str = QString::number(GPOINTER_TO_UINT(key), 8);
+            break;
+        }
+        break;
+
+    case FT_STRING:
+    case FT_STRINGZ:
+        value_str = (char *)key;
+        break;
+
+    default:
+        g_assert_not_reached();
+        break;
+    }
+
+    ti->setText(field_col_, get_dissector_table_ui_name(table_name));
+    ti->setText(value_col_, value_str);
+    ti->setText(default_col_, default_proto_name);
+    ti->setText(current_col_, current_proto_name);
+
+    da_dlg->ui->decodeAsTreeWidget->addTopLevelItem(ti);
+}
+
+void DecodeAsDialog::buildDceRpcChangedList(gpointer data, gpointer user_data)
+{
+    decode_dcerpc_bind_values_t *binding = (decode_dcerpc_bind_values_t *)data;
+    qDebug() << "=bdcecl" << binding->ifname;
+}
+
+/*
+ * 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/decode_as_dialog.h b/ui/qt/decode_as_dialog.h
new file mode 100644 (file)
index 0000000..2072143
--- /dev/null
@@ -0,0 +1,76 @@
+/* stats_tree_dialog.h
+ *
+ * $Id$
+ *
+ * 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 DECODE_AS_DIALOG_H
+#define DECODE_AS_DIALOG_H
+
+#include "config.h"
+
+#include <glib.h>
+
+#include "cfile.h"
+
+#include <QDialog>
+
+namespace Ui {
+class DecodeAsDialog;
+}
+
+class DecodeAsDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit DecodeAsDialog(QWidget *parent = 0, capture_file *cf = NULL);
+    ~DecodeAsDialog();
+
+public slots:
+    void setCaptureFile(capture_file *cf);
+
+private:
+    Ui::DecodeAsDialog *ui;
+
+    capture_file *cap_file_;
+
+    static void buildChangedList(const gchar *table_name, ftenum_t selector_type,
+                          gpointer key, gpointer value, gpointer user_data);
+    static void buildDceRpcChangedList(gpointer data, gpointer user_data);
+
+private slots:
+    void fillTable();
+};
+
+#endif // DECODE_AS_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/decode_as_dialog.ui b/ui/qt/decode_as_dialog.ui
new file mode 100644 (file)
index 0000000..ad6eee0
--- /dev/null
@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DecodeAsDialog</class>
+ <widget class="QDialog" name="DecodeAsDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>750</width>
+    <height>600</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Wireshark: Decode As</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QTreeWidget" name="decodeAsTreeWidget">
+     <column>
+      <property name="text">
+       <string>Field</string>
+      </property>
+     </column>
+     <column>
+      <property name="text">
+       <string>Value</string>
+      </property>
+     </column>
+     <column>
+      <property name="text">
+       <string>Default</string>
+      </property>
+     </column>
+     <column>
+      <property name="text">
+       <string>Current</string>
+      </property>
+     </column>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,1">
+     <item>
+      <widget class="QToolButton" name="newToolButton">
+       <property name="toolTip">
+        <string>Create a new profile using default settings.</string>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="icon">
+        <iconset>
+         <normaloff>:/stock/plus-8.png</normaloff>:/stock/plus-8.png</iconset>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QToolButton" name="deleteToolButton">
+       <property name="toolTip">
+        <string>Remove this profile.</string>
+       </property>
+       <property name="icon">
+        <iconset>
+         <normaloff>:/stock/minus-8.png</normaloff>:/stock/minus-8.png</iconset>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QToolButton" name="copyToolButton">
+       <property name="toolTip">
+        <string>Copy this profile.</string>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="icon">
+        <iconset>
+         <normaloff>:/stock/copy-8.png</normaloff>:/stock/copy-8.png</iconset>
+       </property>
+      </widget>
+     </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>
+     <item>
+      <widget class="ElidedLabel" name="pathLabel">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+         <horstretch>1</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+       </property>
+       <property name="openExternalLinks">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>ElidedLabel</class>
+   <extends>QLabel</extends>
+   <header>elided_label.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>DecodeAsDialog</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>DecodeAsDialog</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>
index c6ac5219ca75d981dbe07d425b336188f4e7588f..a296680a4d48fa0114ca75a2614271e7f285e90c 100644 (file)
@@ -277,6 +277,8 @@ private slots:
     void on_actionAnalyzePAFAndNotSelected_triggered();
     void on_actionAnalyzePAFOrNotSelected_triggered();
 
+    void on_actionAnalyzeDecodeAs_triggered();
+
     void openFollowStreamDialog(follow_type_t type);
     void on_actionAnalyzeFollowTCPStream_triggered();
     void on_actionAnalyzeFollowUDPStream_triggered();
index 92574efde450194e208943746c6e15f51db01718..c6fcb5cb38b71744621fe459c202903de244806a 100644 (file)
     <addaction name="menuApplyAsFilter"/>
     <addaction name="menuPrepareAFilter"/>
     <addaction name="separator"/>
+    <addaction name="actionAnalyzeDecodeAs"/>
+    <addaction name="separator"/>
     <addaction name="actionAnalyzeFollowTCPStream"/>
     <addaction name="actionAnalyzeFollowUDPStream"/>
     <addaction name="actionAnalyzeFollowSSLStream"/>
     </widget>
     <addaction name="actionSummary"/>
     <addaction name="actionProtocol_Hierarchy"/>
-    <addaction name="actionStatisticsFlowGraph"/>
-    <addaction name="menuTcpStreamGraphs"/>
+    <addaction name="actionStatisticsPacketLen"/>
     <addaction name="separator"/>
     <addaction name="separator"/>
     <addaction name="actionStatisticsANCP"/>
     <addaction name="menuBACnet"/>
     <addaction name="actionStatisticsCollectd"/>
+    <addaction name="actionStatisticsFlowGraph"/>
     <addaction name="actionStatisticsHART_IP"/>
     <addaction name="menuHTTP"/>
-    <addaction name="actionStatisticsPacketLen"/>
     <addaction name="actionStatisticsSametime"/>
+    <addaction name="menuTcpStreamGraphs"/>
    </widget>
    <widget class="QMenu" name="menuTelephony">
     <property name="title">
   </action>
   <action name="actionStatisticsFlowGraph">
    <property name="text">
-    <string>Flow Graph...</string>
+    <string>Flow Graph</string>
    </property>
    <property name="toolTip">
     <string>Flow sequence diagram</string>
     <string>UCP message statistics</string>
    </property>
   </action>
+  <action name="actionAnalyzeDecodeAs">
+   <property name="text">
+    <string>Decode &amp;As...</string>
+   </property>
+   <property name="toolTip">
+    <string>Change the way packets are dissected</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <customwidgets>
index d03511a15c6c6c9ea1952fc6ce93c3b2207c5646..9e30d8953b8d414d153f473ccdfa40488e92d10e 100644 (file)
@@ -70,6 +70,7 @@
 #endif
 
 #include "capture_file_dialog.h"
+#include "decode_as_dialog.h"
 #include "export_object_dialog.h"
 #include "packet_comment_dialog.h"
 #include "preferences_dialog.h"
@@ -1740,6 +1741,14 @@ void MainWindow::on_actionAnalyzePAFOrNotSelected_triggered()
     matchSelectedFilter(MatchSelectedOrNot, false, false);
 }
 
+void MainWindow::on_actionAnalyzeDecodeAs_triggered()
+{
+    DecodeAsDialog *da_dialog = new DecodeAsDialog(this, cap_file_);
+    connect(this, SIGNAL(setCaptureFile(capture_file*)),
+            da_dialog, SLOT(setCaptureFile(capture_file*)));
+    da_dialog->show();
+}
+
 void MainWindow::openFollowStreamDialog(follow_type_t type) {
     FollowStreamDialog *fsd = new FollowStreamDialog(this, type, cap_file_);
     connect(fsd, SIGNAL(updateFilter(QString&, bool)), this, SLOT(filterPackets(QString&, bool)));
index 92c22e80deb31b72bf5d6bc566dcca9ab11acef8..4dd0b0eac5b1c3bacf79ca70d609286fb94daa69 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "wsutil/filesystem.h"
 
+#include "epan/decode_as.h"
 #include "epan/disabled_protos.h"
 #include "epan/tap.h"
 #include "epan/timestamp.h"
@@ -652,6 +653,9 @@ e_prefs * WiresharkApplication::readConfigurationFiles(char **gdp_path, char **d
     int                  pf_open_errno, pf_read_errno;
     e_prefs             *prefs_p;
 
+    /* load the decode as entries of this profile */
+    load_decode_as_entries();
+
     /* Read the preference files. */
     prefs_p = read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path,
                          &pf_open_errno, &pf_read_errno, &pf_path);