aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2012-10-12 23:40:29 +0000
committerGerald Combs <gerald@wireshark.org>2012-10-12 23:40:29 +0000
commitcfa22deaae3169b3bca9fd4cd9c564d391531bb0 (patch)
tree9ae2671a2c61b6a3bbf23e2f8097a6a34270f713
parentc91c1df500cc3950cc7a375aaae72f20ea0eb652 (diff)
Add a packet format group box, similar to the packet range group box.
Use it in the new "Export Packet Dissections" dialog. I'm omitting PostScript exports on purpose. If you *really* need that feature you can probably get better results than we produce using text + enscript or print-to-PDF + pdf2ps/pdftops or PSML/PDML + XSL + ... The Windows code is untested. I'll check in any needed fixes shortly. svn path=/trunk/; revision=45513
-rw-r--r--print.h8
-rw-r--r--ui/qt/CMakeLists.txt5
-rw-r--r--ui/qt/Makefile.common4
-rw-r--r--ui/qt/QtShark.pro11
-rw-r--r--ui/qt/capture_file_dialog.cpp47
-rw-r--r--ui/qt/capture_file_dialog.h7
-rw-r--r--ui/qt/export_dissection_dialog.cpp249
-rw-r--r--ui/qt/export_dissection_dialog.h73
-rw-r--r--ui/qt/main_window.cpp26
-rw-r--r--ui/qt/main_window.h8
-rw-r--r--ui/qt/main_window.ui50
-rw-r--r--ui/qt/main_window_slots.cpp36
-rw-r--r--ui/qt/packet_format_group_box.cpp88
-rw-r--r--ui/qt/packet_format_group_box.h41
-rw-r--r--ui/qt/packet_format_group_box.ui111
-rw-r--r--ui/qt/packet_range_group_box.cpp1
16 files changed, 715 insertions, 50 deletions
diff --git a/print.h b/print.h
index 42a5812faa..00907ea09a 100644
--- a/print.h
+++ b/print.h
@@ -33,6 +33,10 @@
#include "packet-range.h"
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
/*
* Print stream code; this provides a "print stream" class with subclasses
* of various sorts. Additional subclasses might be implemented elsewhere.
@@ -155,4 +159,8 @@ extern void write_fields_finale(output_fields_t* fields, FILE *fh);
extern const gchar* get_node_field_value(field_info* fi, epan_dissect_t* edt);
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
#endif /* print.h */
diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt
index e6a01d76f2..a671f95616 100644
--- a/ui/qt/CMakeLists.txt
+++ b/ui/qt/CMakeLists.txt
@@ -33,6 +33,7 @@ set(QTSHARK_H_SRC
color_utils.h
display_filter_combo.h
display_filter_edit.h
+ export_dissection_dialog.h
file_set_dialog.h
import_text_dialog.h
interface_tree.h
@@ -41,6 +42,7 @@ set(QTSHARK_H_SRC
main_welcome.h
main_window.h
monospace_font.h
+ packet_format_group_box.h
packet_list.h
packet_list_model.h
packet_range_group_box.h
@@ -66,6 +68,7 @@ set(QTSHARK_CPP_SRC
color_utils.cpp
display_filter_combo.cpp
display_filter_edit.cpp
+ export_dissection_dialog.cpp
file_set_dialog.cpp
import_text_dialog.cpp
interface_tree.cpp
@@ -76,6 +79,7 @@ set(QTSHARK_CPP_SRC
main_window.cpp
main_window_slots.cpp
monospace_font.cpp
+ packet_format_group_box.cpp
packet_list.cpp
packet_list_model.cpp
packet_list_record.cpp
@@ -99,6 +103,7 @@ set(QTSHARK_UI
import_text_dialog.ui
main_welcome.ui
main_window.ui
+ packet_format_group_box.ui
packet_range_group_box.ui
)
diff --git a/ui/qt/Makefile.common b/ui/qt/Makefile.common
index 428871a9b5..3cb2849a8f 100644
--- a/ui/qt/Makefile.common
+++ b/ui/qt/Makefile.common
@@ -78,6 +78,7 @@ MOC_HDRS = \
color_utils.h \
display_filter_combo.h \
display_filter_edit.h \
+ export_dissection_dialog.h \
file_set_dialog.h \
interface_tree.h \
label_stack.h \
@@ -85,6 +86,7 @@ MOC_HDRS = \
main_welcome.h \
main_window.h \
monospace_font.h \
+ packet_format_group_box.h \
packet_list.h \
packet_list_model.h \
packet_range_group_box.h \
@@ -133,6 +135,7 @@ WIRESHARK_QT_SRC = \
color_utils.cpp \
display_filter_combo.cpp \
display_filter_edit.cpp \
+ export_dissection_dialog.cpp \
file_set_dialog.cpp \
interface_tree.cpp \
label_stack.cpp \
@@ -141,6 +144,7 @@ WIRESHARK_QT_SRC = \
main_window.cpp \
main_window_slots.cpp \
monospace_font.cpp \
+ packet_format_group_box.cpp \
packet_list.cpp \
packet_list_model.cpp \
packet_list_record.cpp \
diff --git a/ui/qt/QtShark.pro b/ui/qt/QtShark.pro
index 8d62aa1a15..8ce1c737f7 100644
--- a/ui/qt/QtShark.pro
+++ b/ui/qt/QtShark.pro
@@ -179,7 +179,8 @@ FORMS += main_window.ui \
main_welcome.ui \
import_text_dialog.ui \
file_set_dialog.ui \
- packet_range_group_box.ui
+ packet_range_group_box.ui \
+ packet_format_group_box.ui
win32 { ## These should be in config.pri ??
!isEmpty(PORTAUDIO_DIR) {
@@ -202,7 +203,9 @@ win32 { ## These should be in config.pri ??
}
}
-HEADERS += $$HEADERS_WS_C
+HEADERS += $$HEADERS_WS_C \
+ export_dissection_dialog.h \
+ packet_format_group_box.h
win32 {
OBJECTS_WS_C = $$SOURCES_WS_C
@@ -407,4 +410,6 @@ SOURCES += \
simple_dialog_qt.cpp \
sparkline_delegate.cpp \
syntax_line_edit.cpp \
- wireshark_application.cpp
+ wireshark_application.cpp \
+ export_dissection_dialog.cpp \
+ packet_format_group_box.cpp
diff --git a/ui/qt/capture_file_dialog.cpp b/ui/qt/capture_file_dialog.cpp
index 5504b8f48e..b42006e7a6 100644
--- a/ui/qt/capture_file_dialog.cpp
+++ b/ui/qt/capture_file_dialog.cpp
@@ -145,6 +145,9 @@ CaptureFileDialog::CaptureFileDialog(QWidget *parent, capture_file *cf, QString
// Left and right boxes for controls and preview
h_box->addLayout(&left_v_box_);
h_box->addLayout(&right_v_box_);
+
+ qDebug() << "FIX: CaptureFileDialog help button";
+
#else // Q_WS_WIN
merge_type_ = 0;
#endif // Q_WS_WIN
@@ -285,16 +288,16 @@ void CaptureFileDialog::addMergeControls(QVBoxLayout &v_box) {
merge_prepend_.setText("Prepend packets");
merge_prepend_.setToolTip("Insert packets from the selected file before the current file. Packet timestamps will be ignored.");
- v_box.addWidget(&merge_prepend_);
+ v_box.addWidget(&merge_prepend_, 0, Qt::AlignTop);
merge_chrono_.setText("Merge chronologically");
merge_chrono_.setToolTip("Insert packets in chronological order.");
merge_chrono_.setChecked(true);
- v_box.addWidget(&merge_chrono_);
+ v_box.addWidget(&merge_chrono_, 0, Qt::AlignTop);
merge_append_.setText("Append packets");
merge_append_.setToolTip("Insert packets from the selected file after the current file. Packet timestamps will be ignored.");
- v_box.addWidget(&merge_append_);
+ v_box.addWidget(&merge_append_, 0, Qt::AlignTop);
}
// You have to use open, merge, saveAs, or exportPackets. We should
@@ -460,19 +463,19 @@ void CaptureFileDialog::addDisplayFilterEdit() {
void CaptureFileDialog::addResolutionControls(QVBoxLayout &v_box) {
mac_res_.setText(tr("&MAC name resolution"));
mac_res_.setChecked(gbl_resolv_flags.mac_name);
- v_box.addWidget(&mac_res_);
+ v_box.addWidget(&mac_res_, 0, Qt::AlignTop);
transport_res_.setText(tr("&Transport name resolution"));
transport_res_.setChecked(gbl_resolv_flags.transport_name);
- v_box.addWidget(&transport_res_);
+ v_box.addWidget(&transport_res_, 0, Qt::AlignTop);
network_res_.setText(tr("&Network name resolution"));
network_res_.setChecked(gbl_resolv_flags.network_name);
- v_box.addWidget(&network_res_);
+ v_box.addWidget(&network_res_, 0, Qt::AlignTop);
external_res_.setText(tr("&External name resolver"));
external_res_.setChecked(gbl_resolv_flags.use_external_net_name_resolver);
- v_box.addWidget(&external_res_);
+ v_box.addWidget(&external_res_, 0, Qt::AlignTop);
}
void CaptureFileDialog::addGzipControls(QVBoxLayout &v_box) {
@@ -482,17 +485,13 @@ void CaptureFileDialog::addGzipControls(QVBoxLayout &v_box) {
} else {
compress_.setChecked(false);
}
- v_box.addWidget(&compress_);
+ v_box.addWidget(&compress_, 0, Qt::AlignTop);
}
-void CaptureFileDialog::addRangeControls(packet_range_t *range) {
- QGridLayout *fd_grid = qobject_cast<QGridLayout*>(layout());
-
+void CaptureFileDialog::addRangeControls(QVBoxLayout &v_box, packet_range_t *range) {
packet_range_group_box_.initRange(range);
-
- fd_grid->addWidget(&packet_range_group_box_, last_row_, 1, 1, -1);
- last_row_++;
+ v_box.addWidget(&packet_range_group_box_, 0, Qt::AlignTop);
}
int CaptureFileDialog::open(QString &file_name) {
@@ -562,18 +561,19 @@ check_savability_t CaptureFileDialog::exportSelectedPackets(QString &file_name,
setAcceptMode(QFileDialog::AcceptSave);
setLabelText(FileType, tr("Export as:"));
- addGzipControls(left_v_box_);
- addRangeControls(range);
+ addRangeControls(left_v_box_, range);
+ addGzipControls(right_v_box_);
if (button_box) {
save_bt_ = button_box->button(QDialogButtonBox::Save);
+ if (save_bt_) {
+ connect(&packet_range_group_box_, SIGNAL(validityChanged(bool)),
+ save_bt_, SLOT(setEnabled(bool)));
+ }
}
- connect(&packet_range_group_box_, SIGNAL(validityChanged(bool)),
- this, SLOT(rangeValidityChanged(bool)));
-
// Grow the dialog to account for the extra widgets.
- resize(width(), height() + (packet_range_group_box_.height() * 2 / 3) + left_v_box_.minimumSize().height());
+ resize(width(), height() + (packet_range_group_box_.height() * 2 / 3));
if (!file_name.isEmpty()) {
selectFile(file_name);
@@ -652,11 +652,6 @@ int CaptureFileDialog::mergeType() {
return 0;
}
-void CaptureFileDialog::rangeValidityChanged(bool is_valid) {
- if (save_bt_) save_bt_->setEnabled(is_valid);
-}
-#endif // Q_WS_WINDOWS
-
// Slots
@@ -792,6 +787,8 @@ void CaptureFileDialog::preview(const QString & path)
wtap_close(wth);
}
+#endif // Q_WS_WINDOWS
+
/*
* Editor modelines
*
diff --git a/ui/qt/capture_file_dialog.h b/ui/qt/capture_file_dialog.h
index 0b228162bc..779b60c60b 100644
--- a/ui/qt/capture_file_dialog.h
+++ b/ui/qt/capture_file_dialog.h
@@ -104,7 +104,7 @@ private:
#if !defined(Q_WS_WIN)
void addResolutionControls(QVBoxLayout &v_box);
void addGzipControls(QVBoxLayout &v_box);
- void addRangeControls(packet_range_t *range);
+ void addRangeControls(QVBoxLayout &v_box, packet_range_t *range);
QStringList buildFileSaveAsTypeList(bool must_support_comments);
@@ -135,12 +135,11 @@ public slots:
check_savability_t saveAs(QString &file_name, bool must_support_comments);
check_savability_t exportSelectedPackets(QString &file_name, packet_range_t *range);
int merge(QString &file_name);
-#if !defined(Q_WS_WIN)
- void rangeValidityChanged(bool is_valid);
-#endif // Q_WS_WIN
private slots:
+#if !defined(Q_WS_WIN)
void preview(const QString & path);
+#endif // Q_WS_WIN
};
#endif // CAPTURE_FILE_DIALOG_H
diff --git a/ui/qt/export_dissection_dialog.cpp b/ui/qt/export_dissection_dialog.cpp
new file mode 100644
index 0000000000..47ba3d72cc
--- /dev/null
+++ b/ui/qt/export_dissection_dialog.cpp
@@ -0,0 +1,249 @@
+/* export_dissection_dialog.cpp
+ *
+ * $Id: capture_file_dialog.h 45164 2012-09-27 02:43:09Z eapache $
+ *
+ * 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 "export_dissection_dialog.h"
+
+#if !defined(Q_WS_WIN)
+#include "print.h"
+
+#include "ui/alert_box.h"
+#include "ui/help_url.h"
+
+#include <epan/filesystem.h>
+
+#include "qt_ui_utils.h"
+
+#include <QDialogButtonBox>
+#include <QGridLayout>
+#include <QPushButton>
+#include <QMessageBox>
+#include <QDesktopServices>
+#include <QUrl>
+
+#include <QDebug>
+#endif // Q_WS_WIN
+
+ExportDissectionDialog::ExportDissectionDialog(QWidget *parent, export_type_e export_type, capture_file *cap_file):
+ QFileDialog(parent),
+ export_type_(export_type),
+ cap_file_(cap_file),
+ save_bt_(NULL)
+{
+#if !defined(Q_WS_WIN)
+ QDialogButtonBox *button_box = findChild<QDialogButtonBox *>();
+ QGridLayout *fd_grid = qobject_cast<QGridLayout*>(layout());
+ QHBoxLayout *h_box = new QHBoxLayout();
+ QStringList name_filters;
+ int last_row;
+
+ setWindowTitle(tr("Wireshark: Export Packet Dissections"));
+ setAcceptMode(QFileDialog::AcceptSave);
+ setLabelText(FileType, "Export as:");
+
+ if (button_box) {
+ save_bt_ = button_box->button(QDialogButtonBox::Save);
+ }
+
+ // export_type_map_keys() sorts alphabetically. We don't want that.
+ name_filters
+ << "Plain text (*.txt)"
+ << "Comma Separated Values - summary (*.csv)"
+ << "PSML - summary (*.psml, *.xml)"
+ << "PDML - details (*.pdml, *.xml)"
+ << "C Arrays - bytes (*.c, *.h)";
+ export_type_map_[name_filters[0]] = export_type_text;
+ export_type_map_[name_filters[1]] = export_type_csv;
+ export_type_map_[name_filters[2]] = export_type_psml;
+ export_type_map_[name_filters[3]] = export_type_pdml;
+ export_type_map_[name_filters[4]] = export_type_carrays;
+ setNameFilters(name_filters);
+ selectNameFilter(export_type_map_.key(export_type));
+ exportTypeChanged(export_type_map_.key(export_type));
+
+ last_row = fd_grid->rowCount();
+ fd_grid->addItem(new QSpacerItem(1, 1), last_row, 0);
+ fd_grid->addLayout(h_box, last_row, 1);
+
+ /* Init the export range */
+ packet_range_init(&print_args_.range, cap_file_);
+ /* Default to displayed packets */
+ print_args_.range.process_filtered = TRUE;
+
+ packet_range_group_box_.initRange(&print_args_.range);
+ h_box->addWidget(&packet_range_group_box_);
+
+ h_box->addWidget(&packet_format_group_box_, 0, Qt::AlignTop);
+
+ if (save_bt_) {
+ connect(&packet_range_group_box_, SIGNAL(validityChanged(bool)),
+ this, SLOT(checkValidity()));
+ connect(&packet_format_group_box_, SIGNAL(formatChanged()),
+ this, SLOT(checkValidity()));
+ }
+ connect(this, SIGNAL(filterSelected(QString)), this, SLOT(exportTypeChanged(QString)));
+
+ // Grow the dialog to account for the extra widgets.
+ resize(width(), height() + (packet_range_group_box_.height() * 2 / 3));
+
+ qDebug() << "FIX: ExportDissectionDialog help button";
+
+#else // Q_WS_WIN
+#endif // Q_WS_WIN
+}
+
+ExportDissectionDialog::~ExportDissectionDialog()
+{
+}
+
+int ExportDissectionDialog::exec()
+{
+#if !defined(Q_WS_WIN)
+ int retval;
+
+ if (!cap_file_) return QDialog::Rejected;
+
+ retval = QFileDialog::exec();
+
+ if (retval == QDialog::Accepted && selectedFiles().length() > 0) {
+ print_args_t print_args;
+ cf_print_status_t status;
+ QString file_name = selectedFiles()[0];
+
+ /* Fill in our print (and export) args */
+
+ print_args_.file = file_name.toUtf8().data();
+ print_args_.format = PR_FMT_TEXT;
+ print_args_.to_file = TRUE;
+ print_args_.cmd = NULL;
+ print_args_.print_summary = TRUE;
+ print_args_.print_dissections = print_dissections_as_displayed;
+ print_args_.print_hex = FALSE;
+ print_args_.print_formfeed = FALSE;
+
+
+ switch (export_type_) {
+ case export_type_text: /* Text */
+ print_args_.print_summary = packet_format_group_box_.summaryEnabled();
+ print_args_.print_dissections = print_dissections_none;
+ if (packet_format_group_box_.detailsEnabled()) {
+ if (packet_format_group_box_.allCollapsedEnabled())
+ print_args_.print_dissections = print_dissections_collapsed;
+ else if (packet_format_group_box_.asDisplayedEnabled())
+ print_args_.print_dissections = print_dissections_as_displayed;
+ else if (packet_format_group_box_.allExpandedEnabled())
+ print_args_.print_dissections = print_dissections_expanded;
+ }
+ print_args_.print_hex = packet_format_group_box_.bytesEnabled();
+ print_args_.stream = print_stream_text_new(TRUE, print_args_.file);
+ if (print_args_.stream == NULL) {
+ open_failure_alert_box(print_args_.file, errno, TRUE);
+ return QDialog::Rejected;
+ }
+ status = cf_print_packets(cap_file_, &print_args_);
+ break;
+ case export_type_csv: /* CSV */
+ status = cf_write_csv_packets(cap_file_, &print_args_);
+ break;
+ case export_type_carrays: /* C Arrays */
+ status = cf_write_carrays_packets(cap_file_, &print_args_);
+ break;
+ case export_type_psml: /* PSML */
+ status = cf_write_psml_packets(cap_file_, &print_args_);
+ break;
+ case export_type_pdml: /* PDML */
+ status = cf_write_pdml_packets(cap_file_, &print_args_);
+ break;
+ default:
+ return QDialog::Rejected;
+ }
+
+ switch (status) {
+ case CF_PRINT_OK:
+ break;
+ case CF_PRINT_OPEN_ERROR:
+ open_failure_alert_box(print_args.file, errno, TRUE);
+ break;
+ case CF_PRINT_WRITE_ERROR:
+ write_failure_alert_box(print_args.file, errno);
+ break;
+ }
+
+ if (selectedFiles().length() > 0) {
+ gchar *dirname;
+ /* Save the directory name for future file dialogs. */
+ dirname = get_dirname(print_args_.file); /* Overwrites file_name data */
+ set_last_open_dir(dirname);
+ }
+ }
+
+ return retval;
+#else // Q_WS_WIN
+ win32_export_file(parent->effectiveWinId(), export_type_);
+ return QDialog::Accepted;
+#endif // Q_WS_WIN
+}
+
+void ExportDissectionDialog::exportTypeChanged(QString name_filter)
+{
+ export_type_ = export_type_map_.value(name_filter);
+ if (export_type_ == export_type_text) {
+ packet_format_group_box_.setEnabled(true);
+ print_args_.format = PR_FMT_TEXT;
+ } else {
+ packet_format_group_box_.setEnabled(false);
+ }
+
+ checkValidity();
+}
+
+void ExportDissectionDialog::checkValidity()
+{
+ bool enable = true;
+
+ if (!save_bt_) return;
+
+ if (!packet_range_group_box_.isValid()) enable = false;
+
+ if (export_type_ == export_type_text) {
+ if ( ! packet_format_group_box_.summaryEnabled() &&
+ ! packet_format_group_box_.detailsEnabled() &&
+ ! packet_format_group_box_.bytesEnabled() ) {
+ enable = false;
+ }
+ }
+
+ save_bt_->setEnabled(enable);
+}
+
+//#if !defined(Q_WS_WIN)
+//void ExportDissectionDialog::on_buttonBox_helpRequested()
+//{
+// gchar *url = topic_action_url(HELP_EXPORT_FILE_DIALOG);
+
+// if(url != NULL) {
+// QDesktopServices::openUrl(QUrl(url));
+// g_free(url);
+// }
+//}
+
+//#endif // Q_WS_WIN
diff --git a/ui/qt/export_dissection_dialog.h b/ui/qt/export_dissection_dialog.h
new file mode 100644
index 0000000000..c6b462e82d
--- /dev/null
+++ b/ui/qt/export_dissection_dialog.h
@@ -0,0 +1,73 @@
+/* export_dissection_dialog.h
+ *
+ * $Id: capture_file_dialog.h 45164 2012-09-27 02:43:09Z eapache $
+ *
+ * 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 EXPORT_DISSECTION_DIALOG_H
+#define EXPORT_DISSECTION_DIALOG_H
+
+#include "config.h"
+
+#include <glib.h>
+
+#include "file.h"
+#include "print.h"
+
+#include "ui/file_dialog.h"
+
+#ifndef Q_WS_WIN
+#import "packet_range_group_box.h"
+#import "packet_format_group_box.h"
+#endif // Q_WS_WIN
+
+#include <QFileDialog>
+
+class ExportDissectionDialog : public QFileDialog
+{
+ Q_OBJECT
+
+public:
+ explicit ExportDissectionDialog(QWidget *parent, export_type_e export_type, capture_file *cap_file);
+ ~ExportDissectionDialog();
+
+public slots:
+ int exec();
+
+private slots:
+ void exportTypeChanged(QString name_filter);
+ void checkValidity();
+
+private:
+ export_type_e export_type_;
+#if !defined(Q_WS_WIN)
+ capture_file *cap_file_;
+ print_args_t print_args_;
+
+ QMap<QString, export_type_e> export_type_map_;
+ PacketRangeGroupBox packet_range_group_box_;
+
+ PacketFormatGroupBox packet_format_group_box_;
+
+ QPushButton *save_bt_;
+#endif // Q_WS_WIN
+};
+
+#endif // EXPORT_DISSECTION_DIALOG_H
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index c639042c3a..9f6492be9f 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -44,9 +44,9 @@
#include "wireshark_application.h"
#include "proto_tree.h"
#include "byte_view_tab.h"
-#include "capture_file_dialog.h"
#include "display_filter_edit.h"
#include "import_text_dialog.h"
+#include "export_dissection_dialog.h"
#include "qt_ui_utils.h"
@@ -712,7 +712,7 @@ void MainWindow::exportSelectedPackets() {
if (!cap_file_)
return;
- /* init the packet range */
+ /* Init the packet range */
packet_range_init(&range, cap_file_);
range.process_filtered = TRUE;
range.include_dependents = TRUE;
@@ -837,6 +837,22 @@ void MainWindow::exportSelectedPackets() {
return;
}
+void MainWindow::exportDissections(export_type_e export_type) {
+ QString file_name = "";
+ ExportDissectionDialog ed_dlg(this, export_type, cap_file_);
+ packet_range_t range;
+
+ if (!cap_file_)
+ return;
+
+ /* Init the packet range */
+ packet_range_init(&range, cap_file_);
+ range.process_filtered = TRUE;
+ range.include_dependents = TRUE;
+
+ ed_dlg.exec();
+}
+
void MainWindow::fileAddExtension(QString &file_name, int file_type, bool compressed) {
QString file_name_lower;
QString file_suffix;
@@ -1057,7 +1073,7 @@ void MainWindow::setMenusForCaptureFile(bool force_disable)
main_ui_->actionFileSave->setEnabled(false);
main_ui_->actionFileSaveAs->setEnabled(false);
main_ui_->actionFileExportPackets->setEnabled(false);
- main_ui_->actionFileExportPacketDissections->setEnabled(false);
+ main_ui_->menuFileExportPacketDissections->setEnabled(false);
main_ui_->actionFileExportPacketBytes->setEnabled(false);
main_ui_->actionFileExportSSLSessionKeys->setEnabled(false);
main_ui_->actionFileExportObjects->setEnabled(false);
@@ -1098,7 +1114,7 @@ void MainWindow::setMenusForCaptureFile(bool force_disable)
* we can write the file out in at least one format.
*/
main_ui_->actionFileExportPackets->setEnabled(cf_can_write_with_wiretap(cap_file_));
- main_ui_->actionFileExportPacketDissections->setEnabled(true);
+ main_ui_->menuFileExportPacketDissections->setEnabled(true);
main_ui_->actionFileExportPacketBytes->setEnabled(true);
main_ui_->actionFileExportSSLSessionKeys->setEnabled(true);
main_ui_->actionFileExportObjects->setEnabled(true);
@@ -1112,7 +1128,7 @@ void MainWindow::setMenusForCaptureInProgress(bool capture_in_progress) {
main_ui_->actionFileOpen->setEnabled(!capture_in_progress);
main_ui_->menuOpenRecentCaptureFile->setEnabled(!capture_in_progress);
- main_ui_->actionFileExportPacketDissections->setEnabled(capture_in_progress);
+ main_ui_->menuFileExportPacketDissections->setEnabled(capture_in_progress);
main_ui_->actionFileExportPacketBytes->setEnabled(capture_in_progress);
main_ui_->actionFileExportSSLSessionKeys->setEnabled(capture_in_progress);
main_ui_->actionFileExportObjects->setEnabled(capture_in_progress);
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index 7f69ed98e6..c7403d0e52 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -52,6 +52,7 @@
#include "display_filter_combo.h"
#include "progress_bar.h"
#include "file_set_dialog.h"
+#include "capture_file_dialog.h"
class QAction;
@@ -101,6 +102,7 @@ private:
void saveCaptureFile(capture_file *cf, bool stay_closed);
void saveAsCaptureFile(capture_file *cf, bool must_support_comments, bool stay_closed);
void exportSelectedPackets();
+ void exportDissections(export_type_e export_type);
void fileAddExtension(QString &file_name, int file_type, bool compressed);
bool testCaptureFileClose(bool from_quit = false, QString& before_what = *new QString());
@@ -159,6 +161,12 @@ private slots:
void on_actionFileSetNextFile_triggered();
void on_actionFileSetPreviousFile_triggered();
void on_actionFileExportPackets_triggered();
+ void on_actionFileExportAsPlainText_triggered();
+ // We're dropping PostScript exports
+ void on_actionFileExportAsCSV_triggered();
+ void on_actionFileExportAsCArrays_triggered();
+ void on_actionFileExportAsPSML_triggered();
+ void on_actionFileExportAsPDML_triggered();
void on_actionGoGoToPacket_triggered();
void resetPreviousFocus();
diff --git a/ui/qt/main_window.ui b/ui/qt/main_window.ui
index bf30e0007e..45940d9284 100644
--- a/ui/qt/main_window.ui
+++ b/ui/qt/main_window.ui
@@ -111,6 +111,17 @@
<addaction name="actionFileSetNextFile"/>
<addaction name="actionFileSetPreviousFile"/>
</widget>
+ <widget class="QMenu" name="menuFileExportPacketDissections">
+ <property name="title">
+ <string>Export Packet Dissections</string>
+ </property>
+ <addaction name="actionFileExportAsPlainText"/>
+ <addaction name="actionFileExportAsCSV"/>
+ <addaction name="actionFileExportAsCArrays"/>
+ <addaction name="separator"/>
+ <addaction name="actionFileExportAsPSML"/>
+ <addaction name="actionFileExportAsPDML"/>
+ </widget>
<addaction name="actionFileOpen"/>
<addaction name="menuOpenRecentCaptureFile"/>
<addaction name="actionFileMerge"/>
@@ -123,7 +134,7 @@
<addaction name="menuFileSet"/>
<addaction name="separator"/>
<addaction name="actionFileExportPackets"/>
- <addaction name="actionFileExportPacketDissections"/>
+ <addaction name="menuFileExportPacketDissections"/>
<addaction name="actionFileExportPacketBytes"/>
<addaction name="actionFileExportSSLSessionKeys"/>
<addaction name="actionFileExportObjects"/>
@@ -581,17 +592,12 @@
</action>
<action name="actionFileExportPackets">
<property name="text">
- <string>Export Packets...</string>
+ <string>Export Specified Packets...</string>
</property>
<property name="toolTip">
<string>Export specified packets</string>
</property>
</action>
- <action name="actionFileExportPacketDissections">
- <property name="text">
- <string>Export Packet Dissections...</string>
- </property>
- </action>
<action name="actionFileExportPacketBytes">
<property name="text">
<string>Export Packet &amp;Bytes...</string>
@@ -682,6 +688,36 @@
<string>Ctrl+R</string>
</property>
</action>
+ <action name="actionFileExportAsPlainText">
+ <property name="text">
+ <string>As Plain &amp;Text...</string>
+ </property>
+ </action>
+ <action name="actionFileExportAsPostScript">
+ <property name="text">
+ <string>As PostScript...</string>
+ </property>
+ </action>
+ <action name="actionFileExportAsCSV">
+ <property name="text">
+ <string>As CSV...</string>
+ </property>
+ </action>
+ <action name="actionFileExportAsCArrays">
+ <property name="text">
+ <string>As &quot;C&quot; Arrays...</string>
+ </property>
+ </action>
+ <action name="actionFileExportAsPSML">
+ <property name="text">
+ <string>As PSML XML...</string>
+ </property>
+ </action>
+ <action name="actionFileExportAsPDML">
+ <property name="text">
+ <string>As PDML XML...</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index f6e00f0ad3..1d86f334d5 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -537,11 +537,6 @@ void MainWindow::on_actionFileSaveAs_triggered()
saveAsCaptureFile(cap_file_, FALSE, TRUE);
}
-void MainWindow::on_actionFileExportPackets_triggered()
-{
- exportSelectedPackets();
-}
-
void MainWindow::on_actionFileSetListFiles_triggered()
{
file_set_dialog_.exec();
@@ -567,6 +562,37 @@ void MainWindow::on_actionFileSetPreviousFile_triggered()
}
}
+void MainWindow::on_actionFileExportPackets_triggered()
+{
+ exportSelectedPackets();
+}
+
+void MainWindow::on_actionFileExportAsPlainText_triggered()
+{
+ exportDissections(export_type_text);
+}
+
+void MainWindow::on_actionFileExportAsCSV_triggered()
+{
+ exportDissections(export_type_csv);
+}
+
+void MainWindow::on_actionFileExportAsCArrays_triggered()
+{
+ exportDissections(export_type_carrays);
+}
+
+void MainWindow::on_actionFileExportAsPSML_triggered()
+{
+ exportDissections(export_type_psml);
+}
+
+void MainWindow::on_actionFileExportAsPDML_triggered()
+{
+ exportDissections(export_type_pdml);
+}
+
+
// View Menu
// Expand / collapse slots in proto_tree
diff --git a/ui/qt/packet_format_group_box.cpp b/ui/qt/packet_format_group_box.cpp
new file mode 100644
index 0000000000..511a7d7b22
--- /dev/null
+++ b/ui/qt/packet_format_group_box.cpp
@@ -0,0 +1,88 @@
+#include "packet_format_group_box.h"
+#include "ui_packet_format_group_box.h"
+
+#include <QStyle>
+#include <QDebug>
+
+PacketFormatGroupBox::PacketFormatGroupBox(QWidget *parent) :
+ QGroupBox(parent),
+ pf_ui_(new Ui::PacketFormatGroupBox)
+{
+ pf_ui_->setupUi(this);
+
+ setStyleSheet(QString(
+ "QRadioButton {"
+ " padding-left: %1px;"
+ "}"
+ ).arg(style()->pixelMetric(QStyle::PM_LayoutLeftMargin)));
+}
+
+PacketFormatGroupBox::~PacketFormatGroupBox()
+{
+ delete pf_ui_;
+}
+
+bool PacketFormatGroupBox::summaryEnabled()
+{
+ return pf_ui_->summaryCheckBox->isChecked();
+}
+
+bool PacketFormatGroupBox::detailsEnabled()
+{
+ return pf_ui_->detailsCheckBox->isChecked();
+}
+
+bool PacketFormatGroupBox::bytesEnabled()
+{
+ return pf_ui_->bytesCheckBox->isChecked();
+}
+
+bool PacketFormatGroupBox::allCollapsedEnabled()
+{
+ return pf_ui_->allCollapsedButton->isChecked();
+}
+
+bool PacketFormatGroupBox::asDisplayedEnabled()
+{
+ return pf_ui_->asDisplayedButton->isChecked();
+}
+
+bool PacketFormatGroupBox::allExpandedEnabled()
+{
+ return pf_ui_->allExpandedButton->isChecked();
+}
+
+void PacketFormatGroupBox::on_summaryCheckBox_toggled(bool checked)
+{
+ Q_UNUSED(checked);
+ emit formatChanged();
+}
+
+void PacketFormatGroupBox::on_detailsCheckBox_toggled(bool checked)
+{
+ pf_ui_->allCollapsedButton->setEnabled(checked);
+ pf_ui_->asDisplayedButton->setEnabled(checked);
+ pf_ui_->allExpandedButton->setEnabled(checked);
+ emit formatChanged();
+}
+
+void PacketFormatGroupBox::on_bytesCheckBox_toggled(bool checked)
+{
+ Q_UNUSED(checked);
+ emit formatChanged();
+}
+
+void PacketFormatGroupBox::on_allCollapsedButton_toggled(bool checked)
+{
+ if (checked) emit formatChanged();
+}
+
+void PacketFormatGroupBox::on_asDisplayedButton_toggled(bool checked)
+{
+ if (checked) emit formatChanged();
+}
+
+void PacketFormatGroupBox::on_allExpandedButton_toggled(bool checked)
+{
+ if (checked) emit formatChanged();
+}
diff --git a/ui/qt/packet_format_group_box.h b/ui/qt/packet_format_group_box.h
new file mode 100644
index 0000000000..1aee9037ca
--- /dev/null
+++ b/ui/qt/packet_format_group_box.h
@@ -0,0 +1,41 @@
+#ifndef PACKET_FORMAT_GROUP_BOX_H
+#define PACKET_FORMAT_GROUP_BOX_H
+
+#include <QGroupBox>
+
+namespace Ui {
+class PacketFormatGroupBox;
+}
+
+class PacketFormatGroupBox : public QGroupBox
+{
+ Q_OBJECT
+
+public:
+ explicit PacketFormatGroupBox(QWidget *parent = 0);
+ ~PacketFormatGroupBox();
+
+ bool summaryEnabled();
+ bool detailsEnabled();
+ bool bytesEnabled();
+
+ bool allCollapsedEnabled();
+ bool asDisplayedEnabled();
+ bool allExpandedEnabled();
+
+signals:
+ void formatChanged();
+
+private slots:
+ void on_detailsCheckBox_toggled(bool checked);
+ void on_summaryCheckBox_toggled(bool checked);
+ void on_bytesCheckBox_toggled(bool checked);
+ void on_allCollapsedButton_toggled(bool checked);
+ void on_asDisplayedButton_toggled(bool checked);
+ void on_allExpandedButton_toggled(bool checked);
+
+private:
+ Ui::PacketFormatGroupBox *pf_ui_;
+};
+
+#endif // PACKET_FORMAT_GROUP_BOX_H
diff --git a/ui/qt/packet_format_group_box.ui b/ui/qt/packet_format_group_box.ui
new file mode 100644
index 0000000000..1244ef3689
--- /dev/null
+++ b/ui/qt/packet_format_group_box.ui
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PacketFormatGroupBox</class>
+ <widget class="QGroupBox" name="PacketFormatGroupBox">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>178</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>GroupBox</string>
+ </property>
+ <property name="title">
+ <string>Packet Format</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QCheckBox" name="summaryCheckBox">
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Packet summary lines similar to the packet list&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="text">
+ <string>Summary line</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="detailsCheckBox">
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Packet details similar to the protocol tree&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="text">
+ <string>Details:</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="allCollapsedButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Export only top-level packet detail items&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="text">
+ <string>All co&amp;llapsed</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="asDisplayedButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Expand and collapse packet details as they are currently displayed.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="text">
+ <string>As displa&amp;yed</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="allExpandedButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Export all packet detail items&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="text">
+ <string>All e&amp;xpanded</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="bytesCheckBox">
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Export a hexdump of the packet data similar to the packet bytes view&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="text">
+ <string>Bytes</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/ui/qt/packet_range_group_box.cpp b/ui/qt/packet_range_group_box.cpp
index 9d8198eaee..3f5f873738 100644
--- a/ui/qt/packet_range_group_box.cpp
+++ b/ui/qt/packet_range_group_box.cpp
@@ -24,7 +24,6 @@
#include "packet_range_group_box.h"
#include "ui_packet_range_group_box.h"
-#include <QDebug>
PacketRangeGroupBox::PacketRangeGroupBox(QWidget *parent) :
QGroupBox(parent),
pr_ui_(new Ui::PacketRangeGroupBox),