From 1d43b2a3aa50359e002c2016024167cb8c7fa365 Mon Sep 17 00:00:00 2001 From: Jirka Novak Date: Wed, 6 Jan 2021 23:49:36 +0100 Subject: [PATCH] Telecom dialogs: Fixed issues during capture file closing When capture file is closing/closed, dialogs do not disable buttons which can't work without capture file. Patch fixes it. --- ui/qt/rtp_analysis_dialog.cpp | 10 ++++------ ui/qt/rtp_stream_dialog.cpp | 15 ++++++++++++--- ui/qt/sequence_dialog.cpp | 4 ++-- ui/qt/voip_calls_dialog.cpp | 23 +++++++++++++++++++---- ui/qt/voip_calls_dialog.h | 1 + 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/ui/qt/rtp_analysis_dialog.cpp b/ui/qt/rtp_analysis_dialog.cpp index a2827d1499..6b26513e16 100644 --- a/ui/qt/rtp_analysis_dialog.cpp +++ b/ui/qt/rtp_analysis_dialog.cpp @@ -376,8 +376,6 @@ RtpAnalysisDialog::RtpAnalysisDialog(QWidget &parent, CaptureFile &cf, rtpstream this, SLOT(updateWidgets())); connect(ui->reverseTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(updateWidgets())); - connect(&cap_file_, SIGNAL(captureFileClosing()), - this, SLOT(updateWidgets())); updateWidgets(); updateStatistics(); @@ -393,9 +391,9 @@ RtpAnalysisDialog::~RtpAnalysisDialog() delete rev_tempfile_; } +// TODO: Can be removed if not used to fix issue with disabling buttons void RtpAnalysisDialog::captureFileClosing() { - updateWidgets(); WiresharkDialog::captureFileClosing(); } @@ -428,8 +426,8 @@ void RtpAnalysisDialog::updateWidgets() hint.append(tr(" G: Go to packet, N: Next problem packet")); } - bool enable_save_fwd_audio = fwd_statinfo_.rtp_stats.total_nr && (save_payload_error_ == TAP_RTP_NO_ERROR); - bool enable_save_rev_audio = rev_statinfo_.rtp_stats.total_nr && (save_payload_error_ == TAP_RTP_NO_ERROR); + bool enable_save_fwd_audio = fwd_statinfo_.rtp_stats.total_nr && (save_payload_error_ == TAP_RTP_NO_ERROR) && !file_closed_; + bool enable_save_rev_audio = rev_statinfo_.rtp_stats.total_nr && (save_payload_error_ == TAP_RTP_NO_ERROR) && !file_closed_; ui->actionSaveAudioUnsync->setEnabled(enable_save_fwd_audio && enable_save_rev_audio); ui->actionSaveForwardAudioUnsync->setEnabled(enable_save_fwd_audio); ui->actionSaveReverseAudioUnsync->setEnabled(enable_save_rev_audio); @@ -447,7 +445,7 @@ void RtpAnalysisDialog::updateWidgets() ui->actionSaveReverseCsv->setEnabled(enable_save_rev_csv); #if defined(QT_MULTIMEDIA_LIB) - player_button_->setEnabled(num_streams_ > 0); + player_button_->setEnabled(num_streams_ > 0 && !file_closed_); #else player_button_->setEnabled(false); player_button_->setText(tr("No Audio")); diff --git a/ui/qt/rtp_stream_dialog.cpp b/ui/qt/rtp_stream_dialog.cpp index a480abdced..2fe278a282 100644 --- a/ui/qt/rtp_stream_dialog.cpp +++ b/ui/qt/rtp_stream_dialog.cpp @@ -487,7 +487,7 @@ void RtpStreamDialog::updateWidgets() prepare_button_->setEnabled(enable); export_button_->setEnabled(enable); copy_button_->setEnabled(has_data); - analyze_button_->setEnabled(selected); + analyze_button_->setEnabled(enable); ui->actionFindReverse->setEnabled(enable); ui->actionGoToSetup->setEnabled(enable); @@ -496,10 +496,10 @@ void RtpStreamDialog::updateWidgets() ui->actionExportAsRtpDump->setEnabled(enable); ui->actionCopyAsCsv->setEnabled(has_data); ui->actionCopyAsYaml->setEnabled(has_data); - ui->actionAnalyze->setEnabled(selected); + ui->actionAnalyze->setEnabled(enable); #if defined(QT_MULTIMEDIA_LIB) - player_button_->setEnabled(selected); + player_button_->setEnabled(enable); #else player_button_->setEnabled(false); player_button_->setText(tr("No Audio")); @@ -543,12 +543,21 @@ QList RtpStreamDialog::streamRowData(int row) const void RtpStreamDialog::captureFileClosing() { + ui->todCheckBox->setEnabled(false); + ui->displayFilterCheckBox->setEnabled(false); + remove_tap_listener_rtpstream(&tapinfo_); + WiresharkDialog::captureFileClosing(); } void RtpStreamDialog::showStreamMenu(QPoint pos) { + ui->actionGoToSetup->setEnabled(!file_closed_); + ui->actionMarkPackets->setEnabled(!file_closed_); + ui->actionPrepareFilter->setEnabled(!file_closed_); + ui->actionExportAsRtpDump->setEnabled(!file_closed_); + ui->actionAnalyze->setEnabled(!file_closed_); ctx_menu_.popup(ui->streamTreeWidget->viewport()->mapToGlobal(pos)); } diff --git a/ui/qt/sequence_dialog.cpp b/ui/qt/sequence_dialog.cpp index 06aab35570..534c5477d7 100644 --- a/ui/qt/sequence_dialog.cpp +++ b/ui/qt/sequence_dialog.cpp @@ -335,8 +335,8 @@ void SequenceDialog::diagramClicked(QMouseEvent *event) ui->actionDeselectRtpStream->setEnabled(false); if (sai) { if (GA_INFO_TYPE_RTP == sai->info_type) { - ui->actionSelectRtpStream->setEnabled(true); - ui->actionDeselectRtpStream->setEnabled(true); + ui->actionSelectRtpStream->setEnabled(true && !file_closed_); + ui->actionDeselectRtpStream->setEnabled(true && !file_closed_); current_rtp_sai_ = sai; } } diff --git a/ui/qt/voip_calls_dialog.cpp b/ui/qt/voip_calls_dialog.cpp index 65331efac4..ce4c302137 100644 --- a/ui/qt/voip_calls_dialog.cpp +++ b/ui/qt/voip_calls_dialog.cpp @@ -142,11 +142,13 @@ void VoipCallsDialog::captureFileClosing() // the cache is active, the ToD cannot be modified. ui->todCheckBox->setEnabled(false); cache_model_->setSourceModel(NULL); + ui->displayFilterCheckBox->setEnabled(false); if (!voip_calls_tap_listeners_removed_) { voip_calls_remove_all_tap_listeners(&tapinfo_); voip_calls_tap_listeners_removed_ = true; } tapinfo_.session = NULL; + WiresharkDialog::captureFileClosing(); } @@ -158,13 +160,17 @@ void VoipCallsDialog::contextMenuEvent(QContextMenuEvent *event) return; QMenu popupMenu; + QAction *action; - QAction * action = popupMenu.addAction(tr("Select &All"), this, SLOT(selectAll())); + action = popupMenu.addAction(tr("Select &All"), this, SLOT(selectAll())); action->setToolTip(tr("Select all calls")); + action = popupMenu.addAction(tr("Select &None"), this, SLOT(selectNone())); + action->setToolTip(tr("Clear selection")); popupMenu.addSeparator(); action = popupMenu.addAction(tr("Display time as time of day"), this, SLOT(switchTimeOfDay())); action->setCheckable(true); action->setChecked(call_infos_model_->timeOfDay()); + action->setEnabled(!file_closed_); popupMenu.addSeparator(); action = popupMenu.addAction(tr("Copy as CSV"), this, SLOT(copyAsCSV())); action->setToolTip(tr("Copy stream list as CSV.")); @@ -324,14 +330,18 @@ void VoipCallsDialog::updateWidgets() have_ga_items = true; } - prepare_button_->setEnabled(selected && have_ga_items); - sequence_button_->setEnabled(selected && have_ga_items); + bool enable = selected && have_ga_items && !file_closed_; + + prepare_button_->setEnabled(enable); + sequence_button_->setEnabled(enable); #if defined(QT_MULTIMEDIA_LIB) - player_button_->setEnabled(selected && have_ga_items); + player_button_->setEnabled(enable); #else player_button_->setEnabled(false); player_button_->setText(tr("No Audio")); #endif + + WiresharkDialog::updateWidgets(); } void VoipCallsDialog::prepareFilter() @@ -557,6 +567,11 @@ void VoipCallsDialog::selectAll() ui->callTreeView->selectAll(); } +void VoipCallsDialog::selectNone() +{ + ui->callTreeView->clearSelection(); +} + void VoipCallsDialog::copyAsCSV() { QString csv; diff --git a/ui/qt/voip_calls_dialog.h b/ui/qt/voip_calls_dialog.h index e52fd0253c..82a66fdc0d 100644 --- a/ui/qt/voip_calls_dialog.h +++ b/ui/qt/voip_calls_dialog.h @@ -92,6 +92,7 @@ private: private slots: void captureFileClosing(); void selectAll(); + void selectNone(); void copyAsCSV(); void copyAsYAML(); void switchTimeOfDay();