diff options
author | Gerald Combs <gerald@wireshark.org> | 2014-12-29 14:12:43 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2014-12-30 20:44:02 +0000 |
commit | 3b578619098dc86e69a2ddbbc5b10d0fdb062537 (patch) | |
tree | efccb738368246c11d30a6c5a76a757a9357f612 | |
parent | 97f5f39c96eaeddbc05906abcf4d1a7fadb5a69c (diff) |
Qt: More WiresharkDialog conversions.
Convert the Follow Stream and Export Objects dialogs.
Change-Id: I8a4dda634f2f0475a24cf09601f76fb52069fe50
Reviewed-on: https://code.wireshark.org/review/6126
Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r-- | ui/qt/export_object_dialog.cpp | 36 | ||||
-rw-r--r-- | ui/qt/export_object_dialog.h | 10 | ||||
-rw-r--r-- | ui/qt/follow_stream_dialog.cpp | 72 | ||||
-rw-r--r-- | ui/qt/follow_stream_dialog.h | 13 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 10 | ||||
-rw-r--r-- | ui/qt/wireshark_dialog.cpp | 10 | ||||
-rw-r--r-- | ui/qt/wireshark_dialog.h | 2 |
7 files changed, 73 insertions, 80 deletions
diff --git a/ui/qt/export_object_dialog.cpp b/ui/qt/export_object_dialog.cpp index 4c65cdc6ab..c98e9c5beb 100644 --- a/ui/qt/export_object_dialog.cpp +++ b/ui/qt/export_object_dialog.cpp @@ -21,6 +21,12 @@ #include "export_object_dialog.h" #include "ui_export_object_dialog.h" + +#include <ui/alert_box.h> + +#include <wsutil/filesystem.h> +#include <wsutil/str_util.h> + #include "wireshark_application.h" #include <QDialogButtonBox> @@ -28,12 +34,6 @@ #include <QMessageBox> #include <QFileDialog> -#include <ui/alert_box.h> - -#include <wsutil/filesystem.h> - -#include <wsutil/str_util.h> - extern "C" { // object_list_add_entry and object_list_get_entry are defined in ui/export_object.h @@ -59,10 +59,9 @@ eo_reset(void *tapdata) } // extern "C" -ExportObjectDialog::ExportObjectDialog(QWidget *parent, capture_file *cf, ObjectType object_type) : - QDialog(parent), +ExportObjectDialog::ExportObjectDialog(QWidget &parent, CaptureFile &cf, ObjectType object_type) : + WiresharkDialog(parent, cf), eo_ui_(new Ui::ExportObjectDialog), - cap_file_(cf), save_bt_(NULL), save_all_bt_(NULL), tap_name_(NULL), @@ -110,14 +109,13 @@ ExportObjectDialog::ExportObjectDialog(QWidget *parent, capture_file *cf, Object save_all_bt_ = eo_ui_->buttonBox->button(QDialogButtonBox::SaveAll); close_bt = eo_ui_->buttonBox->button(QDialogButtonBox::Close); - this->setWindowTitle(QString(tr("Wireshark: %1 object list")).arg(name_)); + setWindowTitle(wsApp->windowTitleString(QStringList() << tr("Export") << tr("%1 object list").arg(name_))); if (save_bt_) save_bt_->setEnabled(false); if (save_all_bt_) save_all_bt_->setEnabled(false); if (close_bt) close_bt->setDefault(true); - connect(wsApp, SIGNAL(captureFileClosing(const capture_file*)), - this, SLOT(captureFileClosing(const capture_file*))); + connect(&cap_file_, SIGNAL(captureFileClosing()), this, SLOT(captureFileClosing())); show(); raise(); @@ -175,8 +173,6 @@ void ExportObjectDialog::show() { GString *error_msg; - if (!cap_file_) destroy(); // Assert? - /* Data will be gathered via a tap callback */ error_msg = register_tap_listener(tap_name_, (void *)&export_object_list_, NULL, 0, eo_reset, @@ -195,7 +191,7 @@ void ExportObjectDialog::show() } QDialog::show(); - cf_retap_packets(cap_file_); + cap_file_.retapPackets(); eo_ui_->progressFrame->hide(); for (int i = 0; i < eo_ui_->objectTree->columnCount(); i++) eo_ui_->objectTree->resizeColumnToContents(i); @@ -207,11 +203,9 @@ void ExportObjectDialog::accept() // Don't close the dialog. } -void ExportObjectDialog::captureFileClosing(const capture_file *cf) +void ExportObjectDialog::captureFileClosing() { - if (cap_file_ && cf == cap_file_) { - close(); - } + close(); } void ExportObjectDialog::on_buttonBox_helpRequested() @@ -231,8 +225,8 @@ void ExportObjectDialog::on_objectTree_currentItemChanged(QTreeWidgetItem *item, if (save_bt_) save_bt_->setEnabled(true); export_object_entry_t *entry = item->data(0, Qt::UserRole).value<export_object_entry_t *>(); - if (entry && cap_file_) { - cf_goto_frame(cap_file_, entry->pkt_num); + if (entry && !file_closed_) { + cf_goto_frame(cap_file_.capFile(), entry->pkt_num); } } diff --git a/ui/qt/export_object_dialog.h b/ui/qt/export_object_dialog.h index be1534efa9..56ab284cbd 100644 --- a/ui/qt/export_object_dialog.h +++ b/ui/qt/export_object_dialog.h @@ -34,7 +34,8 @@ #include <ui/export_object.h> -#include <QDialog> +#include "wireshark_dialog.h" + #include <QMetaType> #include <QTreeWidgetItem> #include <QAbstractButton> @@ -50,14 +51,14 @@ struct _export_object_list_t { }; -class ExportObjectDialog : public QDialog +class ExportObjectDialog : public WiresharkDialog { Q_OBJECT public: enum ObjectType { Dicom, Http, Smb, Tftp }; - explicit ExportObjectDialog(QWidget *parent, capture_file *cf, ObjectType object_type); + explicit ExportObjectDialog(QWidget &parent, CaptureFile &cf, ObjectType object_type); ~ExportObjectDialog(); @@ -70,7 +71,7 @@ public slots: private slots: void accept(); - void captureFileClosing(const capture_file *cf); + void captureFileClosing(); void on_buttonBox_helpRequested(); void on_objectTree_currentItemChanged(QTreeWidgetItem *item, QTreeWidgetItem *previous); void on_buttonBox_clicked(QAbstractButton *button); @@ -87,7 +88,6 @@ private: typedef void (*eo_protocoldata_reset_cb)(void); Ui::ExportObjectDialog *eo_ui_; - capture_file *cap_file_; QPushButton *save_bt_; QPushButton *save_all_bt_; diff --git a/ui/qt/follow_stream_dialog.cpp b/ui/qt/follow_stream_dialog.cpp index a6f2638546..7533a37862 100644 --- a/ui/qt/follow_stream_dialog.cpp +++ b/ui/qt/follow_stream_dialog.cpp @@ -62,15 +62,14 @@ // To do: // - Instead of calling QMessageBox, display the error message in the text // box and disable the appropriate controls. -// - Add stream number for UDP. // - Draw text by hand similar to ByteViewText. This would let us add // extra information, e.g. a timestamp column and get rid of the data // limit. +// - Add a progress bar and connect captureCaptureUpdateContinue to it -FollowStreamDialog::FollowStreamDialog(QWidget *parent, follow_type_t type, capture_file *cf) : - QDialog(parent), +FollowStreamDialog::FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_type_t type) : + WiresharkDialog(parent, cf), ui(new Ui::FollowStreamDialog), - cap_file_(cf), follow_type_(type), truncated_(false), save_as_(false) @@ -82,13 +81,10 @@ FollowStreamDialog::FollowStreamDialog(QWidget *parent, follow_type_t type, capt follow_info_.show_type = SHOW_ASCII; follow_info_.show_stream = BOTH_HOSTS; - ui->teStreamContent->installEventFilter(this); // XXX Use recent settings instead - if (parent) { - resize(parent->width() * 2 / 3, parent->height()); - } + resize(parent.width() * 2 / 3, parent.height()); QComboBox *cbcs = ui->cbCharset; cbcs->blockSignals(true); @@ -114,6 +110,7 @@ FollowStreamDialog::FollowStreamDialog(QWidget *parent, follow_type_t type, capt this, SLOT(fillHintLabel(int))); connect(ui->teStreamContent, SIGNAL(mouseClickedOnTextCursorPosition(int)), this, SLOT(goToPacketForTextPos(int))); + connect(&cap_file_, SIGNAL(captureFileClosing()), this, SLOT(captureFileClosing())); fillHintLabel(-1); } @@ -170,7 +167,7 @@ void FollowStreamDialog::fillHintLabel(int text_pos) void FollowStreamDialog::goToPacketForTextPos(int text_pos) { int pkt = -1; - if (!cap_file_) { + if (file_closed_) { return; } @@ -186,14 +183,14 @@ void FollowStreamDialog::goToPacketForTextPos(int text_pos) } } -void FollowStreamDialog::updateWidgets(bool enable) +void FollowStreamDialog::updateWidgets(bool follow_in_progress) { - if (!cap_file_) { + bool enable = !follow_in_progress; + if (file_closed_) { + ui->teStreamContent->setEnabled(true); enable = false; - ui->streamNumberSpinBox->setToolTip(QString()); - ui->streamNumberLabel->setToolTip(QString()); } - ui->teStreamContent->setEnabled(enable); + ui->cbDirections->setEnabled(enable); ui->cbCharset->setEnabled(enable); ui->streamNumberSpinBox->setEnabled(enable); @@ -244,10 +241,9 @@ void FollowStreamDialog::helpButton() void FollowStreamDialog::filterOut() { - emit updateFilter(filter_out_filter_, TRUE); - this->close(); + close(); } void FollowStreamDialog::on_cbDirections_currentIndexChanged(int index) @@ -289,11 +285,13 @@ void FollowStreamDialog::on_leFind_returnPressed() void FollowStreamDialog::on_streamNumberSpinBox_valueChanged(int stream_num) { + if (file_closed_) return; + if (stream_num >= 0) { - updateWidgets(false); + updateWidgets(true); follow_index((follow_type_ == FOLLOW_TCP) ? TCP_STREAM : UDP_STREAM, stream_num); follow(QString(), true); - updateWidgets(); + updateWidgets(false); } } @@ -595,14 +593,6 @@ void FollowStreamDialog::addText(QString text, gboolean is_from_server, guint32 } } -void FollowStreamDialog::setCaptureFile(capture_file *cf) -{ - if (!cf) { // We only want to know when the file closes. - cap_file_ = NULL; - } - updateWidgets(); -} - // The following keyboard shortcuts should work (although // they may not work consistently depending on focus): // / (slash), Ctrl-F - Focus and highlight the search box @@ -859,19 +849,19 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index) resetStream(); - if (cap_file_ == NULL) + if (file_closed_) { QMessageBox::warning(this, tr("No capture file."), tr("Please make sure you have a capture file opened.")); return false; } - if (cap_file_->edt == NULL) + if (cap_file_.capFile()->edt == NULL) { QMessageBox::warning(this, tr("Error following stream."), tr("Capture file invalid.")); return false; } - proto_get_frame_protocols(cap_file_->edt->pi.layers, NULL, &is_tcp, &is_udp, NULL, NULL); + proto_get_frame_protocols(cap_file_.capFile()->edt->pi.layers, NULL, &is_tcp, &is_udp, NULL, NULL); switch (follow_type_) { @@ -890,7 +880,7 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index) case FOLLOW_SSL: /* we got ssl so we can follow */ removeStreamControls(); - if (!epan_dissect_packet_contains_field(cap_file_->edt, "ssl")) { + if (!epan_dissect_packet_contains_field(cap_file_.capFile()->edt, "ssl")) { QMessageBox::critical(this, tr("Error following stream."), tr("Please make sure you have an SSL packet selected.")); return false; @@ -911,7 +901,7 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index) follow_filter = gchar_free_to_qstring( build_follow_index_filter((follow_type_ == FOLLOW_TCP) ? TCP_STREAM : UDP_STREAM)); } else { - follow_filter = gchar_free_to_qstring(build_follow_conv_filter(&cap_file_->edt->pi)); + follow_filter = gchar_free_to_qstring(build_follow_conv_filter(&cap_file_.capFile()->edt->pi)); } if (follow_filter.isEmpty()) { QMessageBox::warning(this, @@ -1214,28 +1204,28 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index) .arg(gchar_free_to_qstring(format_size( stats.bytes_written[0] + stats.bytes_written[1], format_size_unit_bytes|format_size_prefix_si))); - this->setWindowTitle(QString("Follow TCP Stream (%1)").arg(follow_filter)); + setWindowSubtitle(tr("Follow TCP Stream (%1)").arg(follow_filter)); break; case FOLLOW_UDP: both_directions_string = QString("Entire conversation (%1)") .arg(gchar_free_to_qstring(format_size( follow_info_.bytes_written[0] + follow_info_.bytes_written[1], format_size_unit_bytes|format_size_prefix_si))); - this->setWindowTitle(QString("Follow UDP Stream (%1)").arg(follow_filter)); + setWindowSubtitle(tr("Follow UDP Stream (%1)").arg(follow_filter)); break; case FOLLOW_SSL: both_directions_string = QString("Entire conversation (%1)") .arg(gchar_free_to_qstring(format_size( follow_info_.bytes_written[0] + follow_info_.bytes_written[1], format_size_unit_bytes|format_size_prefix_si))); - this->setWindowTitle(QString("Follow SSL Stream (%1)").arg(follow_filter)); + setWindowSubtitle(tr("Follow SSL Stream (%1)").arg(follow_filter)); break; } ui->cbDirections->clear(); - this->ui->cbDirections->addItem(both_directions_string); - this->ui->cbDirections->addItem(client_to_server_string); - this->ui->cbDirections->addItem(server_to_client_string); + ui->cbDirections->addItem(both_directions_string); + ui->cbDirections->addItem(client_to_server_string); + ui->cbDirections->addItem(server_to_client_string); followStream(); fillHintLabel(-1); @@ -1248,6 +1238,14 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index) return true; } +void FollowStreamDialog::captureFileClosing() +{ + QString tooltip = tr("File closed."); + ui->streamNumberSpinBox->setToolTip(tooltip); + ui->streamNumberLabel->setToolTip(tooltip); + WiresharkDialog::captureFileClosing(); +} + #define FLT_BUF_SIZE 1024 /* diff --git a/ui/qt/follow_stream_dialog.h b/ui/qt/follow_stream_dialog.h index 9a2fa55e37..107767d446 100644 --- a/ui/qt/follow_stream_dialog.h +++ b/ui/qt/follow_stream_dialog.h @@ -36,7 +36,8 @@ #include "ui/follow.h" -#include <QDialog> +#include "wireshark_dialog.h" + #include <QFile> #include <QMap> #include <QPushButton> @@ -60,18 +61,18 @@ namespace Ui { class FollowStreamDialog; } -class FollowStreamDialog : public QDialog +class FollowStreamDialog : public WiresharkDialog { Q_OBJECT public: - explicit FollowStreamDialog(QWidget *parent = 0, follow_type_t type = FOLLOW_TCP, capture_file *cf = NULL); + explicit FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_type_t type = FOLLOW_TCP); ~FollowStreamDialog(); bool follow(QString previous_filter = QString(), bool use_stream_index = false); public slots: - void setCaptureFile(capture_file *cf); + void captureFileClosing(); protected: bool eventFilter(QObject *obj, QEvent *event); @@ -102,7 +103,8 @@ signals: private: void removeStreamControls(); void resetStream(void); - void updateWidgets(bool enable = true); + void updateWidgets(bool follow_in_progress); + void updateWidgets() { updateWidgets(false); } // Needed for WiresharkDialog? frs_return_t showBuffer(char *buffer, size_t nchars, gboolean is_from_server, guint32 packet_num, guint32 *global_pos); @@ -117,7 +119,6 @@ private: Ui::FollowStreamDialog *ui; - capture_file *cap_file_; QPushButton *b_filter_out_; QPushButton *b_find_; QPushButton *b_print_; diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 6ddc868b58..4461a8248f 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -1542,22 +1542,22 @@ void MainWindow::on_actionFileExportSSLSessionKeys_triggered() void MainWindow::on_actionFileExportObjectsDICOM_triggered() { - new ExportObjectDialog(this, capture_file_.capFile(), ExportObjectDialog::Dicom); + new ExportObjectDialog(*this, capture_file_, ExportObjectDialog::Dicom); } void MainWindow::on_actionFileExportObjectsHTTP_triggered() { - new ExportObjectDialog(this, capture_file_.capFile(), ExportObjectDialog::Http); + new ExportObjectDialog(*this, capture_file_, ExportObjectDialog::Http); } void MainWindow::on_actionFileExportObjectsSMB_triggered() { - new ExportObjectDialog(this, capture_file_.capFile(), ExportObjectDialog::Smb); + new ExportObjectDialog(*this, capture_file_, ExportObjectDialog::Smb); } void MainWindow::on_actionFileExportObjectsTFTP_triggered() { - new ExportObjectDialog(this, capture_file_.capFile(), ExportObjectDialog::Tftp); + new ExportObjectDialog(*this, capture_file_, ExportObjectDialog::Tftp); } void MainWindow::on_actionFilePrint_triggered() @@ -2034,7 +2034,7 @@ void MainWindow::on_actionAnalyzeDecodeAs_triggered() } void MainWindow::openFollowStreamDialog(follow_type_t type) { - FollowStreamDialog *fsd = new FollowStreamDialog(this, type, capture_file_.capFile()); + FollowStreamDialog *fsd = new FollowStreamDialog(*this, capture_file_, type); connect(fsd, SIGNAL(updateFilter(QString&, bool)), this, SLOT(filterPackets(QString&, bool))); connect(fsd, SIGNAL(goToPacket(int)), packet_list_, SLOT(goToPacket(int))); diff --git a/ui/qt/wireshark_dialog.cpp b/ui/qt/wireshark_dialog.cpp index ad6e51a954..c4a7c66bf0 100644 --- a/ui/qt/wireshark_dialog.cpp +++ b/ui/qt/wireshark_dialog.cpp @@ -46,16 +46,16 @@ WiresharkDialog::WiresharkDialog(QWidget &parent, CaptureFile &capture_file) : { connect(&cap_file_, SIGNAL(captureFileClosing()), this, SLOT(captureFileClosing())); connect(&cap_file_, SIGNAL(captureFileClosed()), this, SLOT(captureFileClosing())); - setWindowTitle(); + setWindowTitleFromSubtitle(); } void WiresharkDialog::setWindowSubtitle(const QString &subtitle) { subtitle_ = subtitle; - setWindowTitle(); + setWindowTitleFromSubtitle(); } -void WiresharkDialog::setWindowTitle() +void WiresharkDialog::setWindowTitleFromSubtitle() { QString title = wsApp->windowTitleString(QStringList() << subtitle_ << cap_file_.fileTitle()); QDialog::setWindowTitle(title); @@ -63,13 +63,13 @@ void WiresharkDialog::setWindowTitle() void WiresharkDialog::updateWidgets() { - setWindowTitle(); + setWindowTitleFromSubtitle(); } void WiresharkDialog::captureFileClosing() { file_closed_ = true; - setWindowTitle(); + setWindowTitleFromSubtitle(); updateWidgets(); } diff --git a/ui/qt/wireshark_dialog.h b/ui/qt/wireshark_dialog.h index 5bcd8840ee..95be7f05c6 100644 --- a/ui/qt/wireshark_dialog.h +++ b/ui/qt/wireshark_dialog.h @@ -50,7 +50,7 @@ protected slots: private: const QString &windowSubtitle() { return subtitle_; } - void setWindowTitle(); + void setWindowTitleFromSubtitle(); QString subtitle_; |