2013-05-20 18:56:56 +00:00
/* main_window_slots.cpp
2012-10-02 18:47:05 +00:00
*
* Wireshark - Network traffic analyzer
* By Gerald Combs < gerald @ wireshark . org >
* Copyright 1998 Gerald Combs
*
2018-02-07 11:26:45 +00:00
* SPDX - License - Identifier : GPL - 2.0 - or - later
2012-10-02 18:47:05 +00:00
*/
2012-10-16 00:42:30 +00:00
# include <config.h>
2015-10-14 23:50:22 +00:00
// Qt 5.5.0 + Visual C++ 2013
# ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable:4996)
# endif
2022-02-10 23:11:43 +00:00
# include "wireshark_main_window.h"
2017-05-31 19:34:55 +00:00
/*
2022-02-10 23:11:43 +00:00
* The generated Ui_WiresharkMainWindow : : setupUi ( ) can grow larger than our configured limit ,
2017-05-31 19:34:55 +00:00
* so turn off - Wframe - larger - than = for ui_main_window . h .
*/
DIAG_OFF ( frame - larger - than = )
2022-02-10 23:11:43 +00:00
# include <ui_wireshark_main_window.h>
2017-05-31 19:34:55 +00:00
DIAG_ON ( frame - larger - than = )
2012-10-02 18:47:05 +00:00
# ifdef _WIN32
# include <windows.h>
# endif
2016-10-30 21:07:33 +00:00
# include "ui/dissect_opts.h"
2016-06-28 01:40:09 +00:00
2012-10-02 18:47:05 +00:00
# ifdef HAVE_LIBPCAP
2014-06-30 05:38:29 +00:00
# include "ui/capture.h"
2014-07-04 07:24:02 +00:00
# endif
2012-10-02 18:47:05 +00:00
2016-10-30 21:07:33 +00:00
# include "ui/commandline.h"
2020-10-03 02:17:00 +00:00
# include "ui/urls.h"
2015-12-22 20:07:00 +00:00
# include "epan/color_filters.h"
2016-11-24 14:37:01 +00:00
# include "epan/export_object.h"
2014-09-22 23:33:05 +00:00
2012-10-16 00:01:23 +00:00
# include "wsutil/file_util.h"
2014-09-22 23:33:05 +00:00
# include "wsutil/filesystem.h"
2021-06-08 01:46:52 +00:00
# include <wsutil/wslog.h>
2021-06-18 18:21:42 +00:00
# include <wsutil/ws_assert.h>
2012-10-16 00:01:23 +00:00
2014-12-12 20:35:31 +00:00
# include "epan/addr_resolv.h"
2013-01-23 19:04:36 +00:00
# include "epan/column.h"
2015-08-22 00:12:39 +00:00
# include "epan/dfilter/dfilter-macro.h"
2019-11-04 09:42:29 +00:00
# include "epan/conversation_filter.h"
2014-09-22 23:33:05 +00:00
# include "epan/epan_dissect.h"
2013-02-06 18:22:54 +00:00
# include "epan/filter_expressions.h"
2014-09-22 23:33:05 +00:00
# include "epan/prefs.h"
2017-01-24 16:34:07 +00:00
# include "epan/plugin_if.h"
2015-08-22 00:12:39 +00:00
# include "epan/uat.h"
2017-06-27 14:36:19 +00:00
# include "epan/uat-int.h"
2014-09-22 23:33:05 +00:00
# include "epan/value_string.h"
2013-01-23 19:04:36 +00:00
2015-08-11 12:08:08 +00:00
# ifdef HAVE_LUA
# include <epan/wslua/init_wslua.h>
# endif
2012-10-16 00:01:23 +00:00
# include "ui/alert_box.h"
2014-06-30 01:36:22 +00:00
# ifdef HAVE_LIBPCAP
# include "ui/capture_ui_utils.h"
# endif
2014-09-22 23:33:05 +00:00
2012-10-02 18:47:05 +00:00
# include "ui/capture_globals.h"
# include "ui/help_url.h"
2012-10-16 00:01:23 +00:00
# include "ui/main_statusbar.h"
2013-02-06 18:22:54 +00:00
# include "ui/preference_utils.h"
2014-09-22 23:33:05 +00:00
# include "ui/recent.h"
2014-04-11 06:41:16 +00:00
# include "ui/recent_utils.h"
2012-10-16 18:14:16 +00:00
# include "ui/ssl_key_export.h"
2017-10-14 20:14:14 +00:00
# include "ui/ws_ui_util.h"
2016-02-29 21:29:19 +00:00
# include "ui/all_files_wildcard.h"
2015-08-11 12:08:08 +00:00
# include "ui/qt/simple_dialog.h"
2012-10-02 18:47:05 +00:00
2017-07-25 14:15:18 +00:00
# include <ui/qt/utils/variant_pointer.h>
2017-06-27 14:36:19 +00:00
# include <ui/qt/widgets/drag_drop_toolbar.h>
2018-05-16 00:02:26 +00:00
# include "ui/qt/widgets/wireshark_file_dialog.h"
2017-01-11 12:55:23 +00:00
2013-03-06 22:04:17 +00:00
# ifdef HAVE_SOFTWARE_UPDATE
# include "ui/software_update.h"
# endif
2015-02-11 23:00:27 +00:00
# include "about_dialog.h"
2015-01-22 11:27:23 +00:00
# include "bluetooth_att_server_attributes_dialog.h"
2015-05-13 15:33:28 +00:00
# include "bluetooth_devices_dialog.h"
2015-06-08 17:38:48 +00:00
# include "bluetooth_hci_summary_dialog.h"
2012-10-02 18:47:05 +00:00
# include "capture_file_dialog.h"
2014-11-12 22:24:16 +00:00
# include "capture_file_properties_dialog.h"
2016-03-31 00:24:44 +00:00
# ifdef HAVE_LIBPCAP
2019-12-02 18:43:08 +00:00
# include "capture_options_dialog.h"
2016-03-31 00:24:44 +00:00
# endif
2017-07-25 14:15:18 +00:00
# include <ui/qt/utils/color_utils.h>
2015-02-05 00:36:19 +00:00
# include "coloring_rules_dialog.h"
2014-04-29 15:10:27 +00:00
# include "conversation_dialog.h"
2016-03-18 17:34:41 +00:00
# include "conversation_colorize_action.h"
2015-09-30 23:54:40 +00:00
# include "conversation_hash_tables_dialog.h"
2015-07-21 17:32:42 +00:00
# include "enabled_protocols_dialog.h"
2013-11-22 01:07:36 +00:00
# include "decode_as_dialog.h"
2017-07-05 14:56:45 +00:00
# include <ui/qt/widgets/display_filter_edit.h>
2015-06-01 23:29:17 +00:00
# include "display_filter_expression_dialog.h"
2015-09-25 21:33:54 +00:00
# include "dissector_tables_dialog.h"
2014-08-06 17:07:42 +00:00
# include "endpoint_dialog.h"
2015-03-11 22:22:20 +00:00
# include "expert_info_dialog.h"
2016-11-24 14:37:01 +00:00
# include "export_object_action.h"
2012-10-18 21:14:43 +00:00
# include "export_object_dialog.h"
2014-01-14 18:37:40 +00:00
# include "export_pdu_dialog.h"
2015-04-28 08:26:46 +00:00
# include "extcap_options_dialog.h"
2016-03-31 00:24:44 +00:00
# include "file_set_dialog.h"
2015-08-18 18:46:12 +00:00
# include "filter_action.h"
2015-06-03 23:26:00 +00:00
# include "filter_dialog.h"
2016-06-01 01:29:39 +00:00
# include "firewall_rules_dialog.h"
2015-08-11 12:08:08 +00:00
# include "funnel_statistics.h"
2015-08-05 00:42:53 +00:00
# include "gsm_map_summary_dialog.h"
2015-09-03 18:18:13 +00:00
# include "iax2_analysis_dialog.h"
2017-04-15 21:30:30 +00:00
# include "interface_toolbar.h"
Add a Qt I/O Graph dialog.
For each graph you can set:
- Its visibility
- A name
- A display filter
- Color, from a fixed list
- Plot style: Line, Impulse, Bar, Stacked Bar, Dot, Square, Diamond
- Basic Y Axes (packets/s, bytes/s, bits/s)
- Computed Y Axes (SUM, MIN, AVG, MAX)
- Smoothing
You can pan and zoom using the mouse and keyboard. Clicking on a graph
selects the last packet for that interval. If all graphs have the same Y
axis a single label is shown, otherwise a legend is shown.
The time scale (X axis) can be toggled between relative seconds and the
time of day.
Graphs can be saved as PDF, PNG, BMP, and JPEG. Settings are "sticky"
via the io_graphs UAT.
To do:
- Minimize graph drawing delays.
- Figure out why smoothing differs from GTK+
- Everything else at the top of io_graph_dialog.cpp
- Fix empty resets.
A fair amount of code was copied from TCPStreamDialog. We might want to
subclass QCustomPlot and place the shared code there.
Move common syntax checking to SyntaxLineEdit.
Move some common code from ui/gtk/io_stat.c to ui/io_graph_item.[ch] and
use it in both GTK+ and Qt.
Make the io_graph_item_t array allocation in io_stat.c static. The
behavior should be identical and this gives us additional compile-time
checks.
Change-Id: I9a3d544469b7048f0761fdbf7bcf20f44ae76577
Reviewed-on: https://code.wireshark.org/review/435
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Tested-by: Gerald Combs <gerald@wireshark.org>
2014-02-12 00:07:10 +00:00
# include "io_graph_dialog.h"
2017-07-05 14:56:45 +00:00
# include <ui/qt/widgets/additional_toolbar.h>
2014-04-08 22:13:45 +00:00
# include "lbm_stream_dialog.h"
# include "lbm_lbtrm_transport_dialog.h"
# include "lbm_lbtru_transport_dialog.h"
2015-09-20 07:42:11 +00:00
# include "lte_mac_statistics_dialog.h"
2015-09-28 10:38:29 +00:00
# include "lte_rlc_statistics_dialog.h"
2015-10-10 22:53:45 +00:00
# include "lte_rlc_graph_dialog.h"
2022-02-01 03:30:09 +00:00
# include "main_application.h"
2015-08-31 19:24:48 +00:00
# include "mtp3_summary_dialog.h"
2015-08-22 00:12:39 +00:00
# include "multicast_statistics_dialog.h"
2012-12-23 04:37:58 +00:00
# include "packet_comment_dialog.h"
2020-05-05 18:58:52 +00:00
# include "packet_diagram.h"
2015-02-11 23:00:27 +00:00
# include "packet_dialog.h"
# include "packet_list.h"
2019-05-29 14:06:38 +00:00
# include "credentials_dialog.h"
2013-01-05 02:30:58 +00:00
# include "preferences_dialog.h"
# include "print_dialog.h"
2012-12-29 01:39:02 +00:00
# include "profile_dialog.h"
2015-02-03 16:39:14 +00:00
# include "protocol_hierarchy_dialog.h"
2017-07-25 14:15:18 +00:00
# include <ui/qt/utils/qt_ui_utils.h>
2015-07-09 23:00:14 +00:00
# include "resolved_addresses_dialog.h"
Add DCE-RPC and ONC-RPC service response time dialogs.
Add RpcServiceResponseTimeDialog, which handles DCE-RPC and ONC-RPC
service response time statistics. Try to make it as lightweight as
possible, since we might want to pull this into the RPC dissectors
similar to the other SRT statistics.
Allow program names on the command line in place of numbers or UUIDs. Make
matches case-insensitive. E.g. the following are equivalent:
-z rpc,srt,100003,3
-z rpc,srt,nfs,3
-z rpc,srt,NFS,3
as are the following:
-z dcerpc,srt,f5cc5a18-4264-101a-8c59-08002b2f8426,56
-z dcerpc,srt,nspi,56
-z dcerpc,srt,NSPI,56
Change-Id: Ie451c64bf6fbc776f27d81e3bc248435c5cbc9e4
Reviewed-on: https://code.wireshark.org/review/9981
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2015-08-11 18:48:07 +00:00
# include "rpc_service_response_time_dialog.h"
2015-01-15 01:25:56 +00:00
# include "rtp_stream_dialog.h"
2015-02-02 17:01:29 +00:00
# include "rtp_analysis_dialog.h"
2013-12-13 07:25:30 +00:00
# include "sctp_all_assocs_dialog.h"
# include "sctp_assoc_analyse_dialog.h"
# include "sctp_graph_dialog.h"
2013-10-24 22:52:30 +00:00
# include "sequence_dialog.h"
2016-02-07 21:15:12 +00:00
# include "show_packet_bytes_dialog.h"
2013-11-21 01:28:17 +00:00
# include "stats_tree_dialog.h"
2022-02-25 12:49:51 +00:00
# include "strip_headers_dialog.h"
2017-07-25 14:15:18 +00:00
# include <ui/qt/utils/stock_icon.h>
2015-10-01 17:18:56 +00:00
# include "supported_protocols_dialog.h"
2015-06-05 20:17:13 +00:00
# include "tap_parameter_dialog.h"
2013-08-27 18:13:20 +00:00
# include "tcp_stream_dialog.h"
# include "time_shift_dialog.h"
2015-08-22 00:12:39 +00:00
# include "uat_dialog.h"
2014-11-19 00:21:42 +00:00
# include "voip_calls_dialog.h"
2015-08-18 18:46:12 +00:00
# include "wlan_statistics_dialog.h"
2019-06-29 12:30:51 +00:00
# include <ui/qt/widgets/wireless_timeline.h>
2012-10-02 18:47:05 +00:00
2019-09-29 09:39:40 +00:00
# include <functional>
2012-12-07 01:46:20 +00:00
# include <QClipboard>
2015-05-22 22:33:38 +00:00
# include <QFileInfo>
2013-02-06 18:22:54 +00:00
# include <QMessageBox>
2014-07-09 17:50:51 +00:00
# include <QMetaObject>
2014-12-10 00:54:17 +00:00
# include <QToolBar>
2015-03-30 14:10:01 +00:00
# include <QDesktopServices>
# include <QUrl>
2021-04-10 08:48:40 +00:00
# include <QMutex>
2012-12-05 19:04:59 +00:00
2016-04-29 15:53:44 +00:00
// XXX You must uncomment QT_WINEXTRAS_LIB lines in CMakeList.txt and
// cmakeconfig.h.in.
2018-04-05 13:12:39 +00:00
// #if defined(QT_WINEXTRAS_LIB)
2016-04-29 15:53:44 +00:00
// #include <QWinJumpList>
// #include <QWinJumpListCategory>
// #include <QWinJumpListItem>
// #endif
2012-10-02 18:47:05 +00:00
//
// Public slots
//
2022-02-10 23:11:43 +00:00
bool WiresharkMainWindow : : openCaptureFile ( QString cf_path , QString read_filter , unsigned int type , gboolean is_tempfile )
2012-10-02 18:47:05 +00:00
{
QString file_name = " " ;
dfilter_t * rfcode = NULL ;
2015-01-18 10:22:19 +00:00
gchar * err_msg ;
2012-10-02 18:47:05 +00:00
int err ;
2014-11-22 11:58:43 +00:00
gboolean name_param ;
2016-06-13 18:02:46 +00:00
gboolean ret = true ;
2014-11-22 11:58:43 +00:00
// was a file name given as function parameter?
name_param = ! cf_path . isEmpty ( ) ;
2012-10-02 18:47:05 +00:00
for ( ; ; ) {
if ( cf_path . isEmpty ( ) ) {
2022-05-31 12:06:34 +00:00
CaptureFileDialog open_dlg ( this , capture_file_ . capFile ( ) ) ;
2012-10-02 18:47:05 +00:00
2022-05-31 12:06:34 +00:00
if ( open_dlg . open ( file_name , type , read_filter ) ) {
2012-10-02 18:47:05 +00:00
cf_path = file_name ;
} else {
2016-06-13 18:02:46 +00:00
ret = false ;
goto finish ;
2012-10-02 18:47:05 +00:00
}
2018-10-01 20:09:33 +00:00
} else {
this - > welcome_page_ - > getInterfaceFrame ( ) - > showRunOnFile ( ) ;
2012-10-02 18:47:05 +00:00
}
2018-06-30 19:08:54 +00:00
// TODO detect call from "cf_read" -> "update_progress_dlg"
// ("capture_file_.capFile()->read_lock"), possibly queue opening the
// file and return early to avoid the warning in testCaptureFileClose.
2016-01-25 11:07:10 +00:00
QString before_what ( tr ( " before opening another file " ) ) ;
if ( ! testCaptureFileClose ( before_what ) ) {
2016-06-13 18:02:46 +00:00
ret = false ;
goto finish ;
2015-03-01 12:56:34 +00:00
}
2017-12-14 18:29:48 +00:00
if ( dfilter_compile ( qUtf8Printable ( read_filter ) , & rfcode , & err_msg ) ) {
2014-09-09 20:42:58 +00:00
cf_set_rfcode ( CaptureFile : : globalCapFile ( ) , rfcode ) ;
2014-11-22 11:58:43 +00:00
} else {
/* Not valid. Tell the user, and go back and run the file
selection box again once they dismiss the alert . */
2019-04-23 01:19:40 +00:00
//bad_dfilter_alert_box(top_level, read_filter->str);
2014-11-22 11:58:43 +00:00
QMessageBox : : warning ( this , tr ( " Invalid Display Filter " ) ,
QString ( " The filter expression " ) +
read_filter +
QString ( " isn't a valid display filter. ( " ) +
2015-01-18 10:22:19 +00:00
err_msg + QString ( " ). " ) ,
2014-11-22 11:58:43 +00:00
QMessageBox : : Ok ) ;
if ( ! name_param ) {
// go back to the selection dialogue only if the file
// was selected from this dialogue
cf_path . clear ( ) ;
continue ;
}
}
2017-11-05 10:39:54 +00:00
/* Make the file name available via MainWindow */
setMwFileName ( cf_path ) ;
2014-03-20 16:57:29 +00:00
/* Try to open the capture file. This closes the current file if it succeeds. */
2014-09-09 20:42:58 +00:00
CaptureFile : : globalCapFile ( ) - > window = this ;
2017-12-14 18:29:48 +00:00
if ( cf_open ( CaptureFile : : globalCapFile ( ) , qUtf8Printable ( cf_path ) , type , is_tempfile , & err ) ! = CF_OK ) {
2012-10-02 18:47:05 +00:00
/* We couldn't open it; don't dismiss the open dialog box,
just leave it around so that the user can , after they
dismiss the alert box popped up for the open error ,
try again . */
2014-09-09 20:42:58 +00:00
CaptureFile : : globalCapFile ( ) - > window = NULL ;
2017-08-26 08:30:47 +00:00
dfilter_free ( rfcode ) ;
2012-10-02 18:47:05 +00:00
cf_path . clear ( ) ;
continue ;
}
2014-09-09 20:42:58 +00:00
switch ( cf_read ( CaptureFile : : globalCapFile ( ) , FALSE ) ) {
2012-10-02 18:47:05 +00:00
case CF_READ_OK :
case CF_READ_ERROR :
/* Just because we got an error, that doesn't mean we were unable
to read any of the file ; we handle what we could get from the
file . */
break ;
case CF_READ_ABORTED :
/* The user bailed out of re-reading the capture file; the
capture file has been closed - just free the capture file name
string and return ( without changing the last containing
directory ) . */
2014-09-09 20:42:58 +00:00
capture_file_ . setCapFile ( NULL ) ;
2016-06-13 18:02:46 +00:00
ret = false ;
goto finish ;
2012-10-02 18:47:05 +00:00
}
break ;
}
2018-10-01 20:09:33 +00:00
2022-02-01 03:30:09 +00:00
mainApp - > setLastOpenDirFromFilename ( cf_path ) ;
2012-10-02 18:47:05 +00:00
main_ui_ - > statusBar - > showExpert ( ) ;
2015-06-05 20:17:13 +00:00
2016-06-13 18:02:46 +00:00
finish :
2016-06-28 00:21:24 +00:00
# ifdef HAVE_LIBPCAP
2016-06-28 01:40:09 +00:00
if ( global_commandline_info . quit_after_cap )
2016-06-13 18:02:46 +00:00
exit ( 0 ) ;
2016-06-28 00:21:24 +00:00
# endif
2016-06-13 18:02:46 +00:00
return ret ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : filterPackets ( QString new_filter , bool force )
2012-12-07 01:46:20 +00:00
{
cf_status_t cf_status ;
2014-09-09 20:42:58 +00:00
cf_status = cf_filter_packets ( CaptureFile : : globalCapFile ( ) , new_filter . toUtf8 ( ) . data ( ) , force ) ;
2012-12-07 01:46:20 +00:00
if ( cf_status = = CF_OK ) {
if ( new_filter . length ( ) > 0 ) {
2013-09-09 19:30:30 +00:00
int index = df_combo_box_ - > findText ( new_filter ) ;
if ( index = = - 1 ) {
2012-12-07 01:46:20 +00:00
df_combo_box_ - > insertItem ( 0 , new_filter ) ;
2013-09-09 19:30:30 +00:00
df_combo_box_ - > setCurrentIndex ( 0 ) ;
2015-08-20 08:29:03 +00:00
} else {
2013-09-09 19:30:30 +00:00
df_combo_box_ - > setCurrentIndex ( index ) ;
2012-12-07 01:46:20 +00:00
}
2015-08-20 08:06:48 +00:00
} else {
df_combo_box_ - > lineEdit ( ) - > clear ( ) ;
2012-12-07 01:46:20 +00:00
}
2021-10-24 20:10:07 +00:00
// Only after the display filter has been updated,
// disable the arrow button
emit displayFilterSuccess ( true ) ;
2012-12-07 01:46:20 +00:00
} else {
emit displayFilterSuccess ( false ) ;
}
2015-12-16 22:41:13 +00:00
if ( packet_list_ ) {
packet_list_ - > resetColumns ( ) ;
}
2012-12-07 01:46:20 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : layoutToolbars ( )
2014-12-10 00:54:17 +00:00
{
Qt : : ToolButtonStyle tbstyle = Qt : : ToolButtonIconOnly ;
switch ( prefs . gui_toolbar_main_style ) {
case TB_STYLE_TEXT :
tbstyle = Qt : : ToolButtonTextOnly ;
break ;
case TB_STYLE_BOTH :
tbstyle = Qt : : ToolButtonTextUnderIcon ;
2015-08-20 08:29:03 +00:00
break ;
2014-12-10 00:54:17 +00:00
}
main_ui_ - > mainToolBar - > setToolButtonStyle ( tbstyle ) ;
2015-12-03 09:22:23 +00:00
main_ui_ - > mainToolBar - > setVisible ( recent . main_toolbar_show ) ;
main_ui_ - > displayFilterToolBar - > setVisible ( recent . filter_toolbar_show ) ;
2018-11-01 09:54:23 +00:00
# if defined(HAVE_LIBNL) && defined(HAVE_NL80211)
2015-12-03 09:22:23 +00:00
main_ui_ - > wirelessToolBar - > setVisible ( recent . wireless_toolbar_show ) ;
2018-11-01 09:54:23 +00:00
# endif
2015-12-03 09:22:23 +00:00
main_ui_ - > statusBar - > setVisible ( recent . statusbar_show ) ;
2017-01-24 16:34:07 +00:00
2019-04-23 01:19:40 +00:00
foreach ( QAction * action , main_ui_ - > menuInterfaceToolbars - > actions ( ) ) {
2017-04-15 21:30:30 +00:00
QToolBar * toolbar = action - > data ( ) . value < QToolBar * > ( ) ;
2019-04-23 01:19:40 +00:00
if ( g_list_find_custom ( recent . interface_toolbars , action - > text ( ) . toUtf8 ( ) , ( GCompareFunc ) strcmp ) ) {
2017-04-15 21:30:30 +00:00
toolbar - > setVisible ( true ) ;
} else {
toolbar - > setVisible ( false ) ;
}
}
2017-01-24 16:34:07 +00:00
QList < QToolBar * > toolbars = findChildren < QToolBar * > ( ) ;
2019-04-23 01:19:40 +00:00
foreach ( QToolBar * bar , toolbars ) {
2017-02-24 08:49:11 +00:00
AdditionalToolBar * iftoolbar = dynamic_cast < AdditionalToolBar * > ( bar ) ;
if ( iftoolbar ) {
2017-01-24 16:34:07 +00:00
bool visible = false ;
2019-04-23 01:19:40 +00:00
if ( g_list_find_custom ( recent . gui_additional_toolbars , qUtf8Printable ( iftoolbar - > menuName ( ) ) , ( GCompareFunc ) strcmp ) )
2017-01-24 16:34:07 +00:00
visible = true ;
iftoolbar - > setVisible ( visible ) ;
2017-04-15 21:30:30 +00:00
2017-01-24 16:34:07 +00:00
}
}
2014-12-10 00:54:17 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : updatePreferenceActions ( )
2014-12-12 20:35:31 +00:00
{
2017-02-16 09:41:58 +00:00
main_ui_ - > actionViewPacketList - > setEnabled ( prefs_has_layout_pane_content ( layout_pane_content_plist ) ) ;
main_ui_ - > actionViewPacketDetails - > setEnabled ( prefs_has_layout_pane_content ( layout_pane_content_pdetails ) ) ;
main_ui_ - > actionViewPacketBytes - > setEnabled ( prefs_has_layout_pane_content ( layout_pane_content_pbytes ) ) ;
2020-05-05 18:58:52 +00:00
main_ui_ - > actionViewPacketDiagram - > setEnabled ( prefs_has_layout_pane_content ( layout_pane_content_pdiagram ) ) ;
2017-02-16 09:41:58 +00:00
2014-12-12 20:35:31 +00:00
main_ui_ - > actionViewNameResolutionPhysical - > setChecked ( gbl_resolv_flags . mac_name ) ;
main_ui_ - > actionViewNameResolutionNetwork - > setChecked ( gbl_resolv_flags . network_name ) ;
main_ui_ - > actionViewNameResolutionTransport - > setChecked ( gbl_resolv_flags . transport_name ) ;
2015-02-20 14:30:23 +00:00
// Should this be a "recent" setting?
main_ui_ - > actionGoAutoScroll - > setChecked ( prefs . capture_auto_scroll ) ;
2014-12-12 20:35:31 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : updateRecentActions ( )
2015-12-03 09:22:23 +00:00
{
main_ui_ - > actionViewMainToolbar - > setChecked ( recent . main_toolbar_show ) ;
main_ui_ - > actionViewFilterToolbar - > setChecked ( recent . filter_toolbar_show ) ;
main_ui_ - > actionViewWirelessToolbar - > setChecked ( recent . wireless_toolbar_show ) ;
main_ui_ - > actionViewStatusBar - > setChecked ( recent . statusbar_show ) ;
2017-02-16 09:41:58 +00:00
main_ui_ - > actionViewPacketList - > setChecked ( recent . packet_list_show & & prefs_has_layout_pane_content ( layout_pane_content_plist ) ) ;
main_ui_ - > actionViewPacketDetails - > setChecked ( recent . tree_view_show & & prefs_has_layout_pane_content ( layout_pane_content_pdetails ) ) ;
main_ui_ - > actionViewPacketBytes - > setChecked ( recent . byte_view_show & & prefs_has_layout_pane_content ( layout_pane_content_pbytes ) ) ;
2020-05-05 18:58:52 +00:00
main_ui_ - > actionViewPacketDiagram - > setChecked ( recent . packet_diagram_show & & prefs_has_layout_pane_content ( layout_pane_content_pdiagram ) ) ;
2015-12-03 09:22:23 +00:00
2019-04-23 01:19:40 +00:00
foreach ( QAction * action , main_ui_ - > menuInterfaceToolbars - > actions ( ) ) {
if ( g_list_find_custom ( recent . interface_toolbars , action - > text ( ) . toUtf8 ( ) , ( GCompareFunc ) strcmp ) ) {
2017-04-15 21:30:30 +00:00
action - > setChecked ( true ) ;
} else {
action - > setChecked ( false ) ;
}
}
2019-04-23 01:19:40 +00:00
foreach ( QAction * action , main_ui_ - > menuAdditionalToolbars - > actions ( ) ) {
2017-01-24 16:34:07 +00:00
ext_toolbar_t * toolbar = VariantPointer < ext_toolbar_t > : : asPtr ( action - > data ( ) ) ;
bool checked = false ;
2019-04-23 01:19:40 +00:00
if ( toolbar & & g_list_find_custom ( recent . gui_additional_toolbars , toolbar - > name , ( GCompareFunc ) strcmp ) )
2017-01-24 16:34:07 +00:00
checked = true ;
2017-02-24 08:49:11 +00:00
action - > setChecked ( checked ) ;
2017-01-24 16:34:07 +00:00
}
2019-04-23 01:19:40 +00:00
foreach ( QAction * tda , td_actions . keys ( ) ) {
2015-12-03 09:22:23 +00:00
if ( recent . gui_time_format = = td_actions [ tda ] ) {
tda - > setChecked ( true ) ;
}
}
2019-04-23 01:19:40 +00:00
foreach ( QAction * tpa , tp_actions . keys ( ) ) {
2015-12-03 09:22:23 +00:00
if ( recent . gui_time_precision = = tp_actions [ tpa ] ) {
tpa - > setChecked ( true ) ;
2016-06-30 21:55:19 +00:00
break ;
2015-12-03 09:22:23 +00:00
}
}
main_ui_ - > actionViewTimeDisplaySecondsWithHoursAndMinutes - > setChecked ( recent . gui_seconds_format = = TS_SECONDS_HOUR_MIN_SEC ) ;
main_ui_ - > actionViewColorizePacketList - > setChecked ( recent . packet_list_colorize ) ;
}
2016-06-22 19:44:02 +00:00
// Don't connect to this directly. Connect to or emit fiterAction(...) instead.
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : queuedFilterAction ( QString action_filter , FilterAction : : Action action , FilterAction : : ActionType type )
2014-04-29 15:10:27 +00:00
{
QString cur_filter , new_filter ;
if ( ! df_combo_box_ ) return ;
cur_filter = df_combo_box_ - > lineEdit ( ) - > text ( ) ;
switch ( type ) {
case FilterAction : : ActionTypePlain :
new_filter = action_filter ;
break ;
case FilterAction : : ActionTypeAnd :
if ( cur_filter . length ( ) ) {
new_filter = " ( " + cur_filter + " ) && ( " + action_filter + " ) " ;
2019-04-23 01:19:40 +00:00
}
else {
2014-04-29 15:10:27 +00:00
new_filter = action_filter ;
}
break ;
case FilterAction : : ActionTypeOr :
if ( cur_filter . length ( ) ) {
new_filter = " ( " + cur_filter + " ) || ( " + action_filter + " ) " ;
} else {
new_filter = action_filter ;
}
break ;
case FilterAction : : ActionTypeNot :
new_filter = " !( " + action_filter + " ) " ;
break ;
case FilterAction : : ActionTypeAndNot :
if ( cur_filter . length ( ) ) {
new_filter = " ( " + cur_filter + " ) && !( " + action_filter + " ) " ;
} else {
new_filter = " !( " + action_filter + " ) " ;
}
break ;
case FilterAction : : ActionTypeOrNot :
if ( cur_filter . length ( ) ) {
new_filter = " ( " + cur_filter + " ) || !( " + action_filter + " ) " ;
} else {
new_filter = " !( " + action_filter + " ) " ;
}
break ;
default :
2021-06-18 18:21:42 +00:00
ws_assert_not_reached ( ) ;
2014-04-29 15:10:27 +00:00
break ;
}
2019-04-23 01:19:40 +00:00
switch ( action ) {
2014-04-29 15:10:27 +00:00
case FilterAction : : ActionApply :
df_combo_box_ - > lineEdit ( ) - > setText ( new_filter ) ;
df_combo_box_ - > applyDisplayFilter ( ) ;
break ;
2016-06-24 22:17:25 +00:00
case FilterAction : : ActionColorize :
colorizeWithFilter ( new_filter . toUtf8 ( ) ) ;
break ;
case FilterAction : : ActionCopy :
2022-02-01 03:30:09 +00:00
mainApp - > clipboard ( ) - > setText ( new_filter ) ;
2016-06-24 22:17:25 +00:00
break ;
case FilterAction : : ActionFind :
main_ui_ - > searchFrame - > findFrameWithFilter ( new_filter ) ;
break ;
2014-04-29 15:10:27 +00:00
case FilterAction : : ActionPrepare :
df_combo_box_ - > lineEdit ( ) - > setText ( new_filter ) ;
df_combo_box_ - > lineEdit ( ) - > setFocus ( ) ;
break ;
2015-03-11 22:22:20 +00:00
case FilterAction : : ActionWebLookup :
{
QString url = QString ( " https://www.google.com/search?q= " ) + new_filter ;
QDesktopServices : : openUrl ( QUrl ( url ) ) ;
break ;
}
2014-04-29 15:10:27 +00:00
default :
2021-06-18 18:21:42 +00:00
ws_assert_not_reached ( ) ;
2014-04-29 15:10:27 +00:00
break ;
}
}
2012-10-02 18:47:05 +00:00
// Capture callbacks
2013-10-11 21:26:26 +00:00
# ifdef HAVE_LIBPCAP
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : captureCapturePrepared ( capture_session * session ) {
2013-04-01 17:57:47 +00:00
setTitlebarForCaptureInProgress ( ) ;
2012-10-02 18:47:05 +00:00
2022-02-01 03:30:09 +00:00
setWindowIcon ( mainApp - > captureIcon ( ) ) ;
2012-10-02 18:47:05 +00:00
/* Disable menu items that make no sense if you're currently running
a capture . */
2019-11-07 11:35:47 +00:00
bool handle_toolbars = ( session - > session_will_restart ? false : true ) ;
setForCaptureInProgress ( true , handle_toolbars , session - > capture_opts - > ifaces ) ;
2012-10-02 18:47:05 +00:00
// set_capture_if_dialog_for_capture_in_progress(TRUE);
// /* Don't set up main window for a capture file. */
// main_set_for_capture_file(FALSE);
2018-06-01 13:43:36 +00:00
showCapture ( ) ;
2012-10-02 18:47:05 +00:00
}
2014-09-09 20:42:58 +00:00
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : captureCaptureUpdateStarted ( capture_session * session ) {
2012-10-02 18:47:05 +00:00
2013-04-01 17:57:47 +00:00
/* We've done this in "prepared" above, but it will be cleared while
switching to the next multiple file . */
setTitlebarForCaptureInProgress ( ) ;
2019-11-07 11:35:47 +00:00
bool handle_toolbars = ( session - > session_will_restart ? false : true ) ;
setForCaptureInProgress ( true , handle_toolbars , session - > capture_opts - > ifaces ) ;
2013-04-01 17:57:47 +00:00
2012-11-01 22:12:57 +00:00
setForCapturedPackets ( true ) ;
2012-10-02 18:47:05 +00:00
}
2018-06-15 11:21:28 +00:00
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : captureCaptureUpdateFinished ( capture_session * session ) {
2012-10-02 18:47:05 +00:00
/* The capture isn't stopping any more - it's stopped. */
capture_stopping_ = false ;
/* Update the main window as appropriate */
updateForUnsavedChanges ( ) ;
/* Enable menu items that make sense if you're not currently running
a capture . */
2019-11-07 11:35:47 +00:00
bool handle_toolbars = ( session - > session_will_restart ? false : true ) ;
setForCaptureInProgress ( false , handle_toolbars ) ;
2016-09-18 21:00:07 +00:00
setMenusForCaptureFile ( ) ;
2014-09-21 20:28:29 +00:00
2022-02-01 03:30:09 +00:00
setWindowIcon ( mainApp - > normalIcon ( ) ) ;
2022-07-29 18:16:16 +00:00
popLiveCaptureInProgress ( ) ;
2014-10-01 19:44:14 +00:00
2016-06-28 01:40:09 +00:00
if ( global_commandline_info . quit_after_cap ) {
2014-10-02 16:28:28 +00:00
// Command line asked us to quit after capturing.
// Don't pop up a dialog to ask for unsaved files etc.
exit ( 0 ) ;
2014-10-01 19:44:14 +00:00
}
2012-10-02 18:47:05 +00:00
}
2017-12-22 12:58:02 +00:00
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : captureCaptureFixedFinished ( capture_session * ) {
2012-10-02 18:47:05 +00:00
/* The capture isn't stopping any more - it's stopped. */
capture_stopping_ = false ;
/* Enable menu items that make sense if you're not currently running
a capture . */
setForCaptureInProgress ( false ) ;
2017-08-18 00:30:01 +00:00
/* There isn't a real capture_file structure yet, so just force disabling
menu options . They will " refresh " when the capture file is reloaded to
display packets */
setMenusForCaptureFile ( true ) ;
2014-09-21 20:28:29 +00:00
2022-02-01 03:30:09 +00:00
setWindowIcon ( mainApp - > normalIcon ( ) ) ;
2022-07-29 18:16:16 +00:00
popLiveCaptureInProgress ( ) ;
2014-10-01 19:44:14 +00:00
2016-06-28 01:40:09 +00:00
if ( global_commandline_info . quit_after_cap ) {
2014-10-02 16:28:28 +00:00
// Command line asked us to quit after capturing.
// Don't pop up a dialog to ask for unsaved files etc.
exit ( 0 ) ;
2014-10-01 19:44:14 +00:00
}
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : captureCaptureFailed ( capture_session * ) {
2012-10-02 18:47:05 +00:00
/* Capture isn't stopping any more. */
capture_stopping_ = false ;
setForCaptureInProgress ( false ) ;
2018-06-01 13:43:36 +00:00
showWelcome ( ) ;
2014-09-21 20:28:29 +00:00
2016-09-16 18:32:04 +00:00
// Reset expert information indicator
main_ui_ - > statusBar - > captureFileClosing ( ) ;
2022-02-01 03:30:09 +00:00
mainApp - > popStatus ( WiresharkApplication : : FileStatus ) ;
2016-09-16 18:32:04 +00:00
2022-02-01 03:30:09 +00:00
setWindowIcon ( mainApp - > normalIcon ( ) ) ;
2022-07-29 18:16:16 +00:00
popLiveCaptureInProgress ( ) ;
2014-10-01 19:44:14 +00:00
2016-06-28 01:40:09 +00:00
if ( global_commandline_info . quit_after_cap ) {
2014-10-02 16:28:28 +00:00
// Command line asked us to quit after capturing.
// Don't pop up a dialog to ask for unsaved files etc.
exit ( 0 ) ;
2014-10-01 19:44:14 +00:00
}
2013-10-11 21:26:26 +00:00
}
2018-06-15 11:21:28 +00:00
# endif // HAVE_LIBPCAP
2012-10-02 18:47:05 +00:00
2014-09-09 20:42:58 +00:00
// Callbacks from cfile.c and file.c via CaptureFile::captureFileCallback
2012-10-02 18:47:05 +00:00
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : captureEventHandler ( CaptureEvent ev )
2017-12-22 12:58:02 +00:00
{
2018-03-28 08:04:50 +00:00
switch ( ev . captureContext ( ) ) {
2018-01-03 09:38:13 +00:00
case CaptureEvent : : File :
2018-03-28 08:04:50 +00:00
switch ( ev . eventType ( ) ) {
2017-12-22 12:58:02 +00:00
case CaptureEvent : : Opened :
captureFileOpened ( ) ;
break ;
case CaptureEvent : : Closing :
captureFileClosing ( ) ;
break ;
case CaptureEvent : : Closed :
captureFileClosed ( ) ;
break ;
case CaptureEvent : : Started :
captureFileReadStarted ( tr ( " Loading " ) ) ;
break ;
case CaptureEvent : : Finished :
captureFileReadFinished ( ) ;
break ;
default :
break ;
}
2018-01-03 09:38:13 +00:00
break ;
case CaptureEvent : : Reload :
2018-03-28 08:04:50 +00:00
switch ( ev . eventType ( ) ) {
2017-12-22 12:58:02 +00:00
case CaptureEvent : : Started :
captureFileReadStarted ( tr ( " Reloading " ) ) ;
break ;
case CaptureEvent : : Finished :
captureFileReadFinished ( ) ;
break ;
default :
break ;
}
2018-01-03 09:38:13 +00:00
break ;
case CaptureEvent : : Rescan :
2018-03-28 08:04:50 +00:00
switch ( ev . eventType ( ) ) {
2017-12-22 12:58:02 +00:00
case CaptureEvent : : Started :
2018-01-03 09:00:39 +00:00
setMenusForCaptureFile ( true ) ;
captureFileReadStarted ( tr ( " Rescanning " ) ) ;
2017-12-22 12:58:02 +00:00
break ;
case CaptureEvent : : Finished :
2018-01-03 09:00:39 +00:00
captureFileReadFinished ( ) ;
2017-12-22 12:58:02 +00:00
break ;
default :
break ;
}
2018-01-03 09:38:13 +00:00
break ;
case CaptureEvent : : Retap :
2018-03-28 08:04:50 +00:00
switch ( ev . eventType ( ) ) {
2017-12-22 12:58:02 +00:00
case CaptureEvent : : Started :
freeze ( ) ;
break ;
case CaptureEvent : : Finished :
thaw ( ) ;
break ;
case CaptureEvent : : Flushed :
draw_tap_listeners ( FALSE ) ;
break ;
default :
break ;
}
2018-01-03 09:38:13 +00:00
break ;
case CaptureEvent : : Merge :
2018-03-28 08:04:50 +00:00
switch ( ev . eventType ( ) ) {
2017-12-22 12:58:02 +00:00
case CaptureEvent : : Started :
2022-02-01 03:30:09 +00:00
mainApp - > popStatus ( WiresharkApplication : : FileStatus ) ;
mainApp - > pushStatus ( WiresharkApplication : : FileStatus , tr ( " Merging files. " ) , QString ( ) ) ;
2017-12-22 12:58:02 +00:00
break ;
case CaptureEvent : : Finished :
2022-02-01 03:30:09 +00:00
mainApp - > popStatus ( WiresharkApplication : : FileStatus ) ;
2017-12-22 12:58:02 +00:00
break ;
default :
break ;
}
2018-01-03 09:38:13 +00:00
break ;
case CaptureEvent : : Save :
2018-03-28 08:04:50 +00:00
switch ( ev . eventType ( ) ) {
2017-12-22 12:58:02 +00:00
case CaptureEvent : : Started :
2018-01-03 09:38:13 +00:00
{
2018-03-28 08:04:50 +00:00
QFileInfo file_info ( ev . filePath ( ) ) ;
2022-02-01 03:30:09 +00:00
mainApp - > popStatus ( WiresharkApplication : : FileStatus ) ;
mainApp - > pushStatus ( WiresharkApplication : : FileStatus , tr ( " Saving %1… " ) . arg ( file_info . fileName ( ) ) ) ;
2017-12-22 12:58:02 +00:00
break ;
2018-01-03 09:38:13 +00:00
}
2017-12-22 12:58:02 +00:00
default :
break ;
}
2018-01-03 09:38:13 +00:00
break ;
2017-12-22 12:58:02 +00:00
# ifdef HAVE_LIBPCAP
2018-01-03 09:38:13 +00:00
case CaptureEvent : : Capture :
2018-03-28 08:04:50 +00:00
switch ( ev . eventType ( ) ) {
2017-12-22 12:58:02 +00:00
case CaptureEvent : : Prepared :
2018-03-28 08:04:50 +00:00
captureCapturePrepared ( ev . capSession ( ) ) ;
2017-12-22 12:58:02 +00:00
break ;
case CaptureEvent : : Stopping :
capture_stopping_ = true ;
setMenusForCaptureStopping ( ) ;
break ;
case CaptureEvent : : Failed :
2018-03-28 08:04:50 +00:00
captureCaptureFailed ( ev . capSession ( ) ) ;
2017-12-22 12:58:02 +00:00
default :
break ;
}
2018-01-03 09:38:13 +00:00
break ;
case CaptureEvent : : Update :
2018-03-28 08:04:50 +00:00
switch ( ev . eventType ( ) ) {
2017-12-22 12:58:02 +00:00
case CaptureEvent : : Started :
2018-03-28 08:04:50 +00:00
captureCaptureUpdateStarted ( ev . capSession ( ) ) ;
2017-12-22 12:58:02 +00:00
break ;
case CaptureEvent : : Finished :
2018-03-28 08:04:50 +00:00
captureCaptureUpdateFinished ( ev . capSession ( ) ) ;
2017-12-22 12:58:02 +00:00
break ;
default :
break ;
}
2018-01-03 09:38:13 +00:00
break ;
case CaptureEvent : : Fixed :
2018-03-28 08:04:50 +00:00
switch ( ev . eventType ( ) ) {
2017-12-22 12:58:02 +00:00
case CaptureEvent : : Finished :
2018-03-28 08:04:50 +00:00
captureCaptureFixedFinished ( ev . capSession ( ) ) ;
2017-12-22 12:58:02 +00:00
break ;
default :
break ;
}
2018-01-03 09:38:13 +00:00
break ;
2017-12-22 12:58:02 +00:00
# endif
2018-01-03 09:38:13 +00:00
}
2017-12-22 12:58:02 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : captureFileOpened ( ) {
2014-09-09 20:42:58 +00:00
if ( capture_file_ . window ( ) ! = this ) return ;
2012-10-02 18:47:05 +00:00
2016-09-18 19:54:50 +00:00
file_set_dialog_ - > fileOpened ( capture_file_ . capFile ( ) ) ;
2012-10-02 18:47:05 +00:00
setMenusForFileSet ( true ) ;
2014-09-09 20:42:58 +00:00
emit setCaptureFile ( capture_file_ . capFile ( ) ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : captureFileReadStarted ( const QString & action ) {
2012-10-02 18:47:05 +00:00
// tap_param_dlg_update();
/* Set up main window for a capture file. */
// main_set_for_capture_file(TRUE);
2022-02-01 03:30:09 +00:00
mainApp - > popStatus ( WiresharkApplication : : FileStatus ) ;
2015-05-22 22:33:38 +00:00
QString msg = QString ( tr ( " %1: %2 " ) ) . arg ( action ) . arg ( capture_file_ . fileName ( ) ) ;
2015-03-04 07:54:23 +00:00
QString msgtip = QString ( ) ;
2022-02-01 03:30:09 +00:00
mainApp - > pushStatus ( WiresharkApplication : : FileStatus , msg , msgtip ) ;
2018-06-01 13:43:36 +00:00
showCapture ( ) ;
2015-11-17 23:11:28 +00:00
main_ui_ - > actionAnalyzeReloadLuaPlugins - > setEnabled ( false ) ;
2017-06-19 20:28:10 +00:00
main_ui_ - > wirelessTimelineWidget - > captureFileReadStarted ( capture_file_ . capFile ( ) ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : captureFileReadFinished ( ) {
2014-09-09 20:42:58 +00:00
if ( ! capture_file_ . capFile ( ) - > is_tempfile & & capture_file_ . capFile ( ) - > filename ) {
2014-04-11 06:41:16 +00:00
/* Add this filename to the list of recent files in the "Recent Files" submenu */
2014-09-09 20:42:58 +00:00
add_menu_recent_capture_file ( capture_file_ . capFile ( ) - > filename ) ;
2012-10-02 18:47:05 +00:00
2014-04-11 06:41:16 +00:00
/* Remember folder for next Open dialog and save it in recent */
2022-02-01 03:30:09 +00:00
mainApp - > setLastOpenDirFromFilename ( capture_file_ . capFile ( ) - > filename ) ;
2014-04-11 06:41:16 +00:00
}
2012-10-02 18:47:05 +00:00
/* Update the appropriate parts of the main window. */
updateForUnsavedChanges ( ) ;
2017-04-06 21:45:33 +00:00
/* enable wireless timeline if capture allows it */
2017-06-19 20:28:10 +00:00
main_ui_ - > wirelessTimelineWidget - > captureFileReadFinished ( ) ;
2017-04-06 21:45:33 +00:00
2013-03-31 22:59:56 +00:00
/* Enable menu items that make sense if you have some captured packets. */
2012-11-01 22:12:57 +00:00
setForCapturedPackets ( true ) ;
2012-10-02 18:47:05 +00:00
2015-05-22 22:33:38 +00:00
main_ui_ - > statusBar - > setFileName ( capture_file_ ) ;
2015-11-17 23:11:28 +00:00
main_ui_ - > actionAnalyzeReloadLuaPlugins - > setEnabled ( true ) ;
2015-03-04 07:54:23 +00:00
2015-09-16 17:46:45 +00:00
packet_list_ - > captureFileReadFinished ( ) ;
2014-09-09 20:42:58 +00:00
emit setDissectedCaptureFile ( capture_file_ . capFile ( ) ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : captureFileClosing ( ) {
2012-10-02 18:47:05 +00:00
setMenusForCaptureFile ( true ) ;
2012-11-01 22:12:57 +00:00
setForCapturedPackets ( false ) ;
2012-10-02 18:47:05 +00:00
setForCaptureInProgress ( false ) ;
2015-05-12 00:14:38 +00:00
// Reset expert information indicator
2015-08-28 19:57:57 +00:00
main_ui_ - > statusBar - > captureFileClosing ( ) ;
2012-12-18 17:21:20 +00:00
main_ui_ - > searchFrame - > animatedHide ( ) ;
2017-01-25 09:57:49 +00:00
main_ui_ - > goToFrame - > animatedHide ( ) ;
2019-04-23 01:19:40 +00:00
// gtk_widget_show(expert_info_none);
2012-10-30 19:21:24 +00:00
emit setCaptureFile ( NULL ) ;
2013-09-06 00:41:07 +00:00
emit setDissectedCaptureFile ( NULL ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : captureFileClosed ( ) {
2012-10-02 18:47:05 +00:00
packets_bar_update ( ) ;
2016-09-18 19:54:50 +00:00
file_set_dialog_ - > fileClosed ( ) ;
2012-10-02 18:47:05 +00:00
setMenusForFileSet ( false ) ;
2015-11-02 13:46:57 +00:00
setWindowModified ( false ) ;
2012-10-02 18:47:05 +00:00
2015-05-12 00:14:38 +00:00
// Reset expert information indicator
2015-08-28 19:57:57 +00:00
main_ui_ - > statusBar - > captureFileClosing ( ) ;
2022-02-01 03:30:09 +00:00
mainApp - > popStatus ( WiresharkApplication : : FileStatus ) ;
2012-10-16 00:01:23 +00:00
2015-12-15 11:12:27 +00:00
setWSWindowTitle ( ) ;
2022-02-01 03:30:09 +00:00
setWindowIcon ( mainApp - > normalIcon ( ) ) ;
2015-11-16 20:33:17 +00:00
setMenusForSelectedPacket ( ) ;
2012-10-16 00:01:23 +00:00
setMenusForSelectedTreeRow ( ) ;
2015-06-25 21:32:30 +00:00
2016-06-28 00:21:24 +00:00
# ifdef HAVE_LIBPCAP
2015-06-25 21:32:30 +00:00
if ( ! global_capture_opts . multi_files_on )
2018-06-01 13:43:36 +00:00
showWelcome ( ) ;
2016-06-28 00:21:24 +00:00
# endif
2012-10-02 18:47:05 +00:00
}
//
// Private slots
//
// ui/gtk/capture_dlg.c:start_capture_confirmed
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : startCapture ( ) {
2022-03-21 10:04:21 +00:00
startCapture ( QStringList ( ) ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : startCapture ( QStringList interfaces _U_ ) {
2013-10-11 21:26:26 +00:00
# ifdef HAVE_LIBPCAP
2017-08-25 09:27:38 +00:00
interface_options * interface_opts ;
2012-10-02 18:47:05 +00:00
guint i ;
2022-01-06 07:02:11 +00:00
interface_t * device ;
gboolean can_start_capture = TRUE ;
2012-10-02 18:47:05 +00:00
2022-03-18 12:53:42 +00:00
if ( interfaces . count ( ) > 0 ) {
global_capture_opts . num_selected = 0 ;
for ( i = 0 ; i < global_capture_opts . all_ifaces - > len ; i + + ) {
device = & g_array_index ( global_capture_opts . all_ifaces , interface_t , i ) ;
if ( interfaces . contains ( device - > name ) ) {
device - > selected = TRUE ;
global_capture_opts . num_selected + + ;
}
else {
device - > selected = FALSE ;
}
}
}
2012-10-02 18:47:05 +00:00
/* did the user ever select a capture interface before? */
2019-04-23 01:19:40 +00:00
if ( global_capture_opts . num_selected = = 0 ) {
2020-07-17 11:45:01 +00:00
QString msg = QString ( tr ( " No interface selected. " ) ) ;
2022-02-01 03:30:09 +00:00
mainApp - > pushStatus ( WiresharkApplication : : TemporaryStatus , msg ) ;
2015-06-24 21:41:44 +00:00
main_ui_ - > actionCaptureStart - > setChecked ( false ) ;
2012-10-02 18:47:05 +00:00
return ;
}
2022-01-06 07:02:11 +00:00
for ( i = 0 ; i < global_capture_opts . all_ifaces - > len ; i + + ) {
device = & g_array_index ( global_capture_opts . all_ifaces , interface_t , i ) ;
if ( device - > selected & & ( device - > if_info . type = = IF_EXTCAP ) ) {
/* device is EXTCAP and is selected. Check if all mandatory
* settings are set .
*/
if ( extcap_has_configuration ( device - > name , TRUE ) )
{
/* Request openning of extcap options dialog */
QString device_name ( device - > name ) ;
emit showExtcapOptions ( device_name , false ) ;
/* Cancel start of capture */
can_start_capture = FALSE ;
}
}
}
/* If some of extcap was not configured, do not start with the capture */
if ( ! can_start_capture ) {
QString msg = QString ( tr ( " Configure all extcaps before start of capture. " ) ) ;
2022-02-01 03:30:09 +00:00
mainApp - > pushStatus ( WiresharkApplication : : TemporaryStatus , msg ) ;
2022-01-06 07:02:11 +00:00
main_ui_ - > actionCaptureStart - > setChecked ( false ) ;
return ;
}
2013-08-08 00:26:57 +00:00
// Ideally we should have disabled the start capture
// toolbar buttons and menu items. This may not be the
// case, e.g. with QtMacExtras.
2019-04-23 01:19:40 +00:00
if ( ! capture_filter_valid_ ) {
2020-07-17 11:45:01 +00:00
QString msg = QString ( tr ( " Invalid capture filter. " ) ) ;
2022-02-01 03:30:09 +00:00
mainApp - > pushStatus ( WiresharkApplication : : TemporaryStatus , msg ) ;
2015-06-24 21:41:44 +00:00
main_ui_ - > actionCaptureStart - > setChecked ( false ) ;
2013-08-08 00:26:57 +00:00
return ;
}
2018-06-01 13:43:36 +00:00
showCapture ( ) ;
2015-11-28 19:03:46 +00:00
2012-10-02 18:47:05 +00:00
/* XXX - we might need to init other pref data as well... */
/* XXX - can this ever happen? */
2014-09-29 23:27:11 +00:00
if ( cap_session_ . state ! = CAPTURE_STOPPED )
2019-04-23 01:19:40 +00:00
return ;
2012-10-02 18:47:05 +00:00
/* close the currently loaded capture file */
2019-04-23 01:19:40 +00:00
cf_close ( ( capture_file * ) cap_session_ . cf ) ;
2012-10-02 18:47:05 +00:00
/* Copy the selected interfaces to the set of interfaces to use for
this capture . */
collect_ifaces ( & global_capture_opts ) ;
2014-09-09 20:42:58 +00:00
CaptureFile : : globalCapFile ( ) - > window = this ;
2018-05-15 00:23:34 +00:00
info_data_ . ui . ui = this ;
Clean up handling of --capture-comment.
Don't store the comments in a capture_options structure, because that's
available only if we're being built with capture support, and
--capture-comment can be used in TShark when reading a capture file and
writing another capture file, with no live capture taking place.
This means we don't handle that option in capture_opts_add_opt(); handle
it in the programs that support it.
Support writing multiple comments in dumpcap when capturing.
These changes also fix builds without pcap, and makes --capture-comment
work in Wireshark when a capture is started from the command line with
-k.
Update the help messages to indicate that --capture-comment adds a
capture comment, it doesn't change any comment (much less "the" comment,
as there isn't necessarily a single comment).
Update the man pages:
- not to presume that only pcapng files support file comments (even if
that's true now, it might not be true in the future);
- to note that multiple instances of --capture-comment are supported,
and that multiple comments will be written, whether capturing or reading
one file and writing another;
- clarify that Wireshark doesn't *discard* SHB comments other than the
first one, even though it only displays the first one;
2021-07-15 05:16:30 +00:00
if ( capture_start ( & global_capture_opts , NULL , & cap_session_ , & info_data_ ,
main_window_update ) ) {
2015-04-13 18:47:31 +00:00
capture_options * capture_opts = cap_session_ . capture_opts ;
GString * interface_names ;
/* Add "interface name<live capture in progress>" on main status bar */
interface_names = get_iface_list_string ( capture_opts , 0 ) ;
2019-04-23 01:19:40 +00:00
if ( strlen ( interface_names - > str ) > 0 ) {
2015-04-13 18:47:31 +00:00
g_string_append ( interface_names , " : " ) ;
}
g_string_append ( interface_names , " " ) ;
2022-02-01 03:30:09 +00:00
mainApp - > popStatus ( WiresharkApplication : : FileStatus ) ;
2019-12-20 05:57:04 +00:00
QString msg = QString ( " %1<live capture in progress> " ) . arg ( interface_names - > str ) ;
QString msgtip = QString ( " to file: " ) ;
if ( capture_opts - > save_file )
msgtip + = capture_opts - > save_file ;
2022-02-01 03:30:09 +00:00
mainApp - > pushStatus ( WiresharkApplication : : FileStatus , msg , msgtip ) ;
2015-04-13 18:47:31 +00:00
g_string_free ( interface_names , TRUE ) ;
2012-10-02 18:47:05 +00:00
/* The capture succeeded, which means the capture filter syntax is
valid ; add this capture filter to the recent capture filter list . */
2016-01-07 00:09:24 +00:00
QByteArray filter_ba ;
2012-10-02 18:47:05 +00:00
for ( i = 0 ; i < global_capture_opts . ifaces - > len ; i + + ) {
2017-08-25 09:27:38 +00:00
interface_opts = & g_array_index ( global_capture_opts . ifaces , interface_options , i ) ;
if ( interface_opts - > cfilter ) {
recent_add_cfilter ( interface_opts - > name , interface_opts - > cfilter ) ;
2016-01-07 00:09:24 +00:00
if ( filter_ba . isEmpty ( ) ) {
2017-08-25 09:27:38 +00:00
filter_ba = interface_opts - > cfilter ;
2016-01-07 00:09:24 +00:00
} else {
/* Not the first selected interface; is its capture filter
the same as the one the other interfaces we ' ve looked
at have ? */
2022-05-21 00:31:17 +00:00
/* XXX: GCC 12.1 has a bogus warning at -O2 and higher
* even though the isEmpty ( ) check guarantees that
* filter_ba . constData ( ) is never NULL or empty .
*/
# if WS_IS_AT_LEAST_GNUC_VERSION(12,1)
DIAG_OFF ( stringop - overread )
# endif
2017-08-25 09:27:38 +00:00
if ( strcmp ( interface_opts - > cfilter , filter_ba . constData ( ) ) ! = 0 ) {
2022-05-21 00:31:17 +00:00
# if WS_IS_AT_LEAST_GNUC_VERSION(12,1)
DIAG_ON ( stringop - overread )
# endif
2019-04-23 01:19:40 +00:00
/* No, so not all selected interfaces have the same capture
filter . */
2016-01-07 00:09:24 +00:00
filter_ba . clear ( ) ;
}
}
2012-10-02 18:47:05 +00:00
}
}
2016-01-07 00:09:24 +00:00
if ( ! filter_ba . isEmpty ( ) ) {
recent_add_cfilter ( NULL , filter_ba . constData ( ) ) ;
}
2012-12-03 19:58:55 +00:00
} else {
2014-09-09 20:42:58 +00:00
CaptureFile : : globalCapFile ( ) - > window = NULL ;
2012-10-02 18:47:05 +00:00
}
2013-10-11 21:26:26 +00:00
# endif // HAVE_LIBPCAP
2012-10-02 18:47:05 +00:00
}
2022-07-29 18:16:16 +00:00
void WiresharkMainWindow : : popLiveCaptureInProgress ( ) {
2016-07-13 21:21:35 +00:00
/* Pop the "<live capture in progress>" message off the status bar. */
main_ui_ - > statusBar - > setFileName ( capture_file_ ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : stopCapture ( ) {
2012-10-02 18:47:05 +00:00
//#ifdef HAVE_AIRPCAP
// if (airpcap_if_active)
// airpcap_set_toolbar_stop_capture(airpcap_if_active);
//#endif
2013-10-11 21:26:26 +00:00
# ifdef HAVE_LIBPCAP
2014-09-29 23:27:11 +00:00
capture_stop ( & cap_session_ ) ;
2013-10-11 21:26:26 +00:00
# endif // HAVE_LIBPCAP
2015-03-07 16:45:00 +00:00
2012-10-02 18:47:05 +00:00
}
2015-09-06 19:00:48 +00:00
// Keep focus rects from showing through the welcome screen. Primarily for
2017-04-05 19:15:27 +00:00
// macOS.
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : mainStackChanged ( int )
2015-09-06 19:00:48 +00:00
{
for ( int i = 0 ; i < main_ui_ - > mainStack - > count ( ) ; i + + ) {
main_ui_ - > mainStack - > widget ( i ) - > setEnabled ( i = = main_ui_ - > mainStack - > currentIndex ( ) ) ;
}
}
2012-10-02 18:47:05 +00:00
// XXX - Copied from ui/gtk/menus.c
/**
* Add the capture filename ( with an absolute path ) to the " Recent Files " menu .
*/
// XXX - We should probably create a RecentFile class.
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : updateRecentCaptures ( ) {
2012-10-02 18:47:05 +00:00
QAction * ra ;
QMenu * recentMenu = main_ui_ - > menuOpenRecentCaptureFile ;
QString action_cf_name ;
if ( ! recentMenu ) {
return ;
}
recentMenu - > clear ( ) ;
2018-04-05 13:12:39 +00:00
#if 0
# if defined(QT_WINEXTRAS_LIB)
QWinJumpList recent_jl ( this ) ;
QWinJumpListCategory * recent_jlc = recent_jl . recent ( ) ;
if ( recent_jlc ) {
recent_jlc - > clear ( ) ;
recent_jlc - > setVisible ( true ) ;
}
# endif
# endif
# if defined(Q_OS_MAC)
2016-04-29 15:53:44 +00:00
if ( ! dock_menu_ ) {
dock_menu_ = new QMenu ( ) ;
dock_menu_ - > setAsDockMenu ( ) ;
}
dock_menu_ - > clear ( ) ;
# endif
2012-10-02 18:47:05 +00:00
/* Iterate through the actions in menuOpenRecentCaptureFile,
* removing special items , a maybe duplicate entry and every item above count_max */
int shortcut = Qt : : Key_0 ;
2022-02-01 03:30:09 +00:00
foreach ( recent_item_status * ri , mainApp - > recentItems ( ) ) {
2012-10-02 18:47:05 +00:00
// Add the new item
ra = new QAction ( recentMenu ) ;
ra - > setData ( ri - > filename ) ;
// XXX - Needs get_recent_item_status or equivalent
ra - > setEnabled ( ri - > accessible ) ;
recentMenu - > insertAction ( NULL , ra ) ;
action_cf_name = ra - > data ( ) . toString ( ) ;
if ( shortcut < = Qt : : Key_9 ) {
2021-11-28 11:43:27 +00:00
ra - > setShortcut ( Qt : : META | ( Qt : : Key ) shortcut ) ;
2012-10-02 18:47:05 +00:00
shortcut + + ;
}
ra - > setText ( action_cf_name ) ;
connect ( ra , SIGNAL ( triggered ( ) ) , this , SLOT ( recentActionTriggered ( ) ) ) ;
2016-04-29 15:53:44 +00:00
2018-04-05 13:12:39 +00:00
/* This is slow, at least on my VM here. The added links also open Wireshark
* in a new window . It might make more sense to add a recent item when we
* open a capture file . */
#if 0
# if defined(QT_WINEXTRAS_LIB)
if ( recent_jlc ) {
QFileInfo fi ( ri - > filename ) ;
QWinJumpListItem * jli = recent_jlc - > addLink (
fi . fileName ( ) ,
QApplication : : applicationFilePath ( ) ,
QStringList ( ) < < " -r " < < ri - > filename
) ;
// XXX set icon
jli - > setWorkingDirectory ( QDir : : toNativeSeparators ( QApplication : : applicationDirPath ( ) ) ) ;
}
# endif
# endif
# if defined(Q_OS_MAC)
2016-04-29 15:53:44 +00:00
QAction * rda = new QAction ( dock_menu_ ) ;
QFileInfo fi ( ri - > filename ) ;
rda - > setText ( fi . fileName ( ) ) ;
dock_menu_ - > insertAction ( NULL , rda ) ;
connect ( rda , SIGNAL ( triggered ( ) ) , ra , SLOT ( trigger ( ) ) ) ;
# endif
2012-10-02 18:47:05 +00:00
}
if ( recentMenu - > actions ( ) . count ( ) > 0 ) {
// Separator + "Clear"
// XXX - Do we really need this?
ra = new QAction ( recentMenu ) ;
ra - > setSeparator ( true ) ;
recentMenu - > insertAction ( NULL , ra ) ;
ra = new QAction ( recentMenu ) ;
ra - > setText ( tr ( " Clear Menu " ) ) ;
recentMenu - > insertAction ( NULL , ra ) ;
2022-02-01 03:30:09 +00:00
connect ( ra , SIGNAL ( triggered ( ) ) , mainApp , SLOT ( clearRecentCaptures ( ) ) ) ;
2012-10-02 18:47:05 +00:00
} else {
if ( main_ui_ - > actionDummyNoFilesFound ) {
recentMenu - > addAction ( main_ui_ - > actionDummyNoFilesFound ) ;
}
}
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : recentActionTriggered ( ) {
2012-10-02 18:47:05 +00:00
QAction * ra = qobject_cast < QAction * > ( sender ( ) ) ;
if ( ra ) {
QString cfPath = ra - > data ( ) . toString ( ) ;
openCaptureFile ( cfPath ) ;
}
}
2022-02-10 23:11:43 +00:00
QString WiresharkMainWindow : : commentToMenuText ( QString text , int max_len )
2021-07-12 11:50:36 +00:00
{
2021-11-25 11:20:25 +00:00
text = text . trimmed ( ) . replace ( QRegularExpression ( " ( \\ r? \\ n| \\ r \\ n?)+ " ) , " " ) ;
2021-07-12 11:50:36 +00:00
if ( text . size ( ) > 0 ) {
if ( text . size ( ) > max_len ) {
text . truncate ( max_len ) ;
text + = " … " ;
}
}
else {
text = tr ( " (empty comment) " , " placeholder for empty comment " ) ;
}
return text ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : setEditCommentsMenu ( )
2021-04-29 11:23:21 +00:00
{
main_ui_ - > menuPacketComment - > clear ( ) ;
2021-11-28 11:43:27 +00:00
main_ui_ - > menuPacketComment - > addAction ( tr ( " Add New Comment… " ) , this , SLOT ( actionAddPacketComment ( ) ) , QKeySequence ( Qt : : CTRL | Qt : : ALT | Qt : : Key_C ) ) ;
2021-04-29 11:23:21 +00:00
if ( selectedRows ( ) . count ( ) = = 1 ) {
const int thisRow = selectedRows ( ) . first ( ) ;
frame_data * current_frame = frameDataForRow ( thisRow ) ;
wtap_block_t pkt_block = cf_get_packet_block ( capture_file_ . capFile ( ) , current_frame ) ;
guint nComments = wtap_block_count_option ( pkt_block , OPT_COMMENT ) ;
if ( nComments > 0 ) {
QAction * aPtr ;
main_ui_ - > menuPacketComment - > addSeparator ( ) ;
for ( guint i = 0 ; i < nComments ; i + + ) {
2021-07-12 11:50:36 +00:00
QString comment = packet_list_ - > getPacketComment ( i ) ;
comment = this - > commentToMenuText ( comment ) ;
2021-04-29 11:23:21 +00:00
aPtr = main_ui_ - > menuPacketComment - > addAction ( tr ( " Edit \" %1 \" " , " edit packet comment " ) . arg ( comment ) ,
this , SLOT ( actionEditPacketComment ( ) ) ) ;
aPtr - > setData ( i ) ;
}
main_ui_ - > menuPacketComment - > addSeparator ( ) ;
for ( guint i = 0 ; i < nComments ; i + + ) {
2021-07-12 11:50:36 +00:00
QString comment = packet_list_ - > getPacketComment ( i ) ;
comment = this - > commentToMenuText ( comment ) ;
2021-04-29 11:23:21 +00:00
aPtr = main_ui_ - > menuPacketComment - > addAction ( tr ( " Delete \" %1 \" " , " delete packet comment " ) . arg ( comment ) ,
this , SLOT ( actionDeletePacketComment ( ) ) ) ;
aPtr - > setData ( i ) ;
}
2021-08-11 12:57:45 +00:00
main_ui_ - > menuPacketComment - > addSeparator ( ) ;
main_ui_ - > menuPacketComment - > addAction ( tr ( " Delete packet comments " ) , this , SLOT ( actionDeleteCommentsFromPackets ( ) ) ) ;
2021-04-29 11:23:21 +00:00
}
wtap_block_unref ( pkt_block ) ;
}
2021-08-11 12:57:45 +00:00
if ( selectedRows ( ) . count ( ) > 1 ) {
main_ui_ - > menuPacketComment - > addSeparator ( ) ;
2022-03-21 22:13:57 +00:00
main_ui_ - > menuPacketComment - > addAction ( tr ( " Delete comments from %n packet(s) " , nullptr , static_cast < int > ( selectedRows ( ) . count ( ) ) ) , this , SLOT ( actionDeleteCommentsFromPackets ( ) ) ) ;
2021-08-11 12:57:45 +00:00
}
2021-04-29 11:23:21 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : setMenusForSelectedPacket ( )
2012-12-17 23:03:21 +00:00
{
2021-02-22 11:48:46 +00:00
gboolean is_ip = FALSE , is_tcp = FALSE , is_udp = FALSE , is_dccp = FALSE , is_sctp = FALSE , is_tls = FALSE , is_rtp = FALSE , is_lte_rlc = FALSE ,
2021-09-13 07:38:46 +00:00
is_http = FALSE , is_http2 = FALSE , is_quic = FALSE , is_sip = FALSE , is_exported_pdu = FALSE ;
2012-12-17 23:03:21 +00:00
2015-07-29 19:09:28 +00:00
/* Making the menu context-sensitive allows for easier selection of the
desired item and has the added benefit , with large captures , of
avoiding needless looping through huge lists for marked , ignored ,
or time - referenced packets . */
2012-12-17 23:03:21 +00:00
/* We have one or more items in the packet list */
2015-07-21 16:51:12 +00:00
bool have_frames = false ;
2012-12-17 23:03:21 +00:00
/* A frame is selected */
2015-07-21 16:51:12 +00:00
bool frame_selected = false ;
2019-11-12 15:39:19 +00:00
bool multi_selection = false ;
2017-03-01 16:03:17 +00:00
/* A visible packet comes after this one in the selection history */
bool next_selection_history = false ;
/* A visible packet comes before this one in the selection history */
bool previous_selection_history = false ;
2012-12-17 23:03:21 +00:00
/* We have marked frames. (XXX - why check frame_selected?) */
2015-07-21 16:51:12 +00:00
bool have_marked = false ;
2012-12-17 23:03:21 +00:00
/* We have a marked frame other than the current frame (i.e.,
we have at least one marked frame , and either there ' s more
than one marked frame or the current frame isn ' t marked ) . */
2015-07-21 16:51:12 +00:00
bool another_is_marked = false ;
2012-12-17 23:03:21 +00:00
/* One or more frames are hidden by a display filter */
2015-07-21 16:51:12 +00:00
bool have_filtered = false ;
2012-12-17 23:03:21 +00:00
/* One or more frames have been ignored */
2015-07-21 16:51:12 +00:00
bool have_ignored = false ;
bool have_time_ref = false ;
2012-12-17 23:03:21 +00:00
/* We have a time reference frame other than the current frame (i.e.,
we have at least one time reference frame , and either there ' s more
than one time reference frame or the current frame isn ' t a
time reference frame ) . ( XXX - why check frame_selected ? ) */
2015-07-21 16:51:12 +00:00
bool another_is_time_ref = false ;
2012-12-17 23:03:21 +00:00
2015-07-29 19:09:28 +00:00
QList < QAction * > cc_actions = QList < QAction * > ( )
< < main_ui_ - > actionViewColorizeConversation1 < < main_ui_ - > actionViewColorizeConversation2
< < main_ui_ - > actionViewColorizeConversation3 < < main_ui_ - > actionViewColorizeConversation4
< < main_ui_ - > actionViewColorizeConversation5 < < main_ui_ - > actionViewColorizeConversation6
< < main_ui_ - > actionViewColorizeConversation7 < < main_ui_ - > actionViewColorizeConversation8
< < main_ui_ - > actionViewColorizeConversation9 < < main_ui_ - > actionViewColorizeConversation10 ;
2014-09-09 20:42:58 +00:00
if ( capture_file_ . capFile ( ) ) {
2019-11-12 15:39:19 +00:00
QList < int > rows = selectedRows ( ) ;
frame_data * current_frame = 0 ;
2019-11-17 19:02:20 +00:00
if ( rows . count ( ) > 0 )
2019-11-12 15:39:19 +00:00
current_frame = frameDataForRow ( rows . at ( 0 ) ) ;
frame_selected = rows . count ( ) = = 1 ;
2019-11-17 19:02:20 +00:00
if ( packet_list_ - > multiSelectActive ( ) )
2019-11-12 15:39:19 +00:00
{
frame_selected = false ;
multi_selection = true ;
}
2017-03-01 16:03:17 +00:00
next_selection_history = packet_list_ - > haveNextHistory ( ) ;
previous_selection_history = packet_list_ - > havePreviousHistory ( ) ;
2014-09-09 20:42:58 +00:00
have_frames = capture_file_ . capFile ( ) - > count > 0 ;
2018-05-23 18:15:32 +00:00
have_marked = capture_file_ . capFile ( ) - > marked_count > 0 ;
2019-11-12 15:39:19 +00:00
another_is_marked = have_marked & & rows . count ( ) < = 1 & &
! ( capture_file_ . capFile ( ) - > marked_count = = 1 & & frame_selected & & current_frame - > marked ) ;
2014-09-09 20:42:58 +00:00
have_filtered = capture_file_ . capFile ( ) - > displayed_count > 0 & & capture_file_ . capFile ( ) - > displayed_count ! = capture_file_ . capFile ( ) - > count ;
have_ignored = capture_file_ . capFile ( ) - > ignored_count > 0 ;
have_time_ref = capture_file_ . capFile ( ) - > ref_time_count > 0 ;
2019-11-12 15:39:19 +00:00
another_is_time_ref = have_time_ref & & rows . count ( ) < = 1 & &
! ( capture_file_ . capFile ( ) - > ref_time_count = = 1 & & frame_selected & & current_frame - > ref_time ) ;
2013-11-21 16:42:10 +00:00
2019-11-12 15:39:19 +00:00
if ( capture_file_ . capFile ( ) - > edt & & ! multi_selection )
2013-11-21 16:42:10 +00:00
{
2015-10-20 14:07:10 +00:00
proto_get_frame_protocols ( capture_file_ . capFile ( ) - > edt - > pi . layers ,
& is_ip , & is_tcp , & is_udp , & is_sctp ,
2018-11-01 16:17:28 +00:00
& is_tls , & is_rtp , & is_lte_rlc ) ;
2021-02-22 11:48:46 +00:00
is_dccp = proto_is_frame_protocol ( capture_file_ . capFile ( ) - > edt - > pi . layers , " dccp " ) ;
2016-01-02 13:58:08 +00:00
is_http = proto_is_frame_protocol ( capture_file_ . capFile ( ) - > edt - > pi . layers , " http " ) ;
2019-02-27 04:55:52 +00:00
is_http2 = proto_is_frame_protocol ( capture_file_ . capFile ( ) - > edt - > pi . layers , " http2 " ) ;
2021-06-21 16:01:15 +00:00
/* TODO: to follow a QUIC stream we need a *decrypted* QUIC connection, i.e. checking for "quic" in the protocol stack is not enough */
2019-10-02 00:20:43 +00:00
is_quic = proto_is_frame_protocol ( capture_file_ . capFile ( ) - > edt - > pi . layers , " quic " ) ;
2021-03-26 17:24:38 +00:00
is_sip = proto_is_frame_protocol ( capture_file_ . capFile ( ) - > edt - > pi . layers , " sip " ) ;
2021-09-13 07:38:46 +00:00
is_exported_pdu = proto_is_frame_protocol ( capture_file_ . capFile ( ) - > edt - > pi . layers , " exported_pdu " ) ;
/* For Exported PDU there is a tag inserting IP addresses into the SRC and DST columns */
if ( is_exported_pdu & &
( capture_file_ . capFile ( ) - > edt - > pi . net_src . type = = AT_IPv4 | | capture_file_ . capFile ( ) - > edt - > pi . net_src . type = = AT_IPv6 ) & &
( capture_file_ . capFile ( ) - > edt - > pi . net_dst . type = = AT_IPv4 | | capture_file_ . capFile ( ) - > edt - > pi . net_dst . type = = AT_IPv6 ) ) {
is_ip = TRUE ;
}
2013-11-21 16:42:10 +00:00
}
2012-12-17 23:03:21 +00:00
}
2015-07-27 22:28:50 +00:00
2022-03-21 22:13:57 +00:00
main_ui_ - > actionEditMarkPacket - > setText ( tr ( " &Mark/Unmark Packet(s) " , " " , static_cast < int > ( selectedRows ( ) . count ( ) ) ) ) ;
main_ui_ - > actionEditIgnorePacket - > setText ( tr ( " &Ignore/Unignore Packet(s) " , " " , static_cast < int > ( selectedRows ( ) . count ( ) ) ) ) ;
2019-11-12 15:39:19 +00:00
main_ui_ - > actionCopyListAsText - > setEnabled ( selectedRows ( ) . count ( ) > 0 ) ;
main_ui_ - > actionCopyListAsCSV - > setEnabled ( selectedRows ( ) . count ( ) > 0 ) ;
main_ui_ - > actionCopyListAsYAML - > setEnabled ( selectedRows ( ) . count ( ) > 0 ) ;
main_ui_ - > actionEditMarkPacket - > setEnabled ( frame_selected | | multi_selection ) ;
2012-12-17 23:03:21 +00:00
main_ui_ - > actionEditMarkAllDisplayed - > setEnabled ( have_frames ) ;
/* Unlike un-ignore, do not allow unmark of all frames when no frames are displayed */
main_ui_ - > actionEditUnmarkAllDisplayed - > setEnabled ( have_marked ) ;
main_ui_ - > actionEditNextMark - > setEnabled ( another_is_marked ) ;
main_ui_ - > actionEditPreviousMark - > setEnabled ( another_is_marked ) ;
2019-11-21 11:35:29 +00:00
GArray * linkTypes = Q_NULLPTR ;
if ( capture_file_ . capFile ( ) & & capture_file_ . capFile ( ) - > linktypes )
linkTypes = capture_file_ . capFile ( ) - > linktypes ;
2021-08-11 12:57:45 +00:00
bool enableEditComments = linkTypes & & wtap_dump_can_write ( capture_file_ . capFile ( ) - > linktypes , WTAP_COMMENT_PER_PACKET ) ;
main_ui_ - > menuPacketComment - > setEnabled ( enableEditComments & & selectedRows ( ) . count ( ) > 0 ) ;
2021-04-29 11:23:21 +00:00
main_ui_ - > actionDeleteAllPacketComments - > setEnabled ( enableEditComments ) ;
2012-12-17 23:03:21 +00:00
2019-11-12 15:39:19 +00:00
main_ui_ - > actionEditIgnorePacket - > setEnabled ( frame_selected | | multi_selection ) ;
2012-12-17 23:03:21 +00:00
main_ui_ - > actionEditIgnoreAllDisplayed - > setEnabled ( have_filtered ) ;
/* Allow un-ignore of all frames even with no frames currently displayed */
main_ui_ - > actionEditUnignoreAllDisplayed - > setEnabled ( have_ignored ) ;
main_ui_ - > actionEditSetTimeReference - > setEnabled ( frame_selected ) ;
main_ui_ - > actionEditUnsetAllTimeReferences - > setEnabled ( have_time_ref ) ;
main_ui_ - > actionEditNextTimeReference - > setEnabled ( another_is_time_ref ) ;
main_ui_ - > actionEditPreviousTimeReference - > setEnabled ( another_is_time_ref ) ;
2012-12-21 18:49:44 +00:00
main_ui_ - > actionEditTimeShift - > setEnabled ( have_frames ) ;
2012-12-17 23:03:21 +00:00
2015-07-31 23:52:37 +00:00
main_ui_ - > actionGoGoToLinkedPacket - > setEnabled ( false ) ;
2017-03-01 16:03:17 +00:00
main_ui_ - > actionGoNextHistoryPacket - > setEnabled ( next_selection_history ) ;
main_ui_ - > actionGoPreviousHistoryPacket - > setEnabled ( previous_selection_history ) ;
2015-07-31 23:52:37 +00:00
2015-07-29 19:09:28 +00:00
main_ui_ - > actionAnalyzeFollowTCPStream - > setEnabled ( is_tcp ) ;
main_ui_ - > actionAnalyzeFollowUDPStream - > setEnabled ( is_udp ) ;
2021-02-22 11:48:46 +00:00
main_ui_ - > actionAnalyzeFollowDCCPStream - > setEnabled ( is_dccp ) ;
2021-09-26 08:54:19 +00:00
main_ui_ - > actionAnalyzeFollowTLSStream - > setEnabled ( is_tls & & ! is_quic ) ;
2016-01-02 13:58:08 +00:00
main_ui_ - > actionAnalyzeFollowHTTPStream - > setEnabled ( is_http ) ;
2019-02-27 04:55:52 +00:00
main_ui_ - > actionAnalyzeFollowHTTP2Stream - > setEnabled ( is_http2 ) ;
2019-10-02 00:20:43 +00:00
main_ui_ - > actionAnalyzeFollowQUICStream - > setEnabled ( is_quic ) ;
2021-03-26 17:24:38 +00:00
main_ui_ - > actionAnalyzeFollowSIPCall - > setEnabled ( is_sip ) ;
2015-07-29 19:09:28 +00:00
2019-04-23 01:19:40 +00:00
foreach ( QAction * cc_action , cc_actions ) {
2015-07-29 19:09:28 +00:00
cc_action - > setEnabled ( frame_selected ) ;
}
2016-01-13 20:10:04 +00:00
main_ui_ - > actionViewColorizeNewColoringRule - > setEnabled ( frame_selected ) ;
2015-07-10 23:15:55 +00:00
main_ui_ - > actionViewColorizeResetColorization - > setEnabled ( tmp_color_filters_used ( ) ) ;
2015-02-11 23:00:27 +00:00
main_ui_ - > actionViewShowPacketInNewWindow - > setEnabled ( frame_selected ) ;
2015-07-21 16:51:12 +00:00
main_ui_ - > actionViewEditResolvedName - > setEnabled ( frame_selected & & is_ip ) ;
2014-08-08 10:59:42 +00:00
2016-03-18 17:34:41 +00:00
emit packetInfoChanged ( capture_file_ . packetInfo ( ) ) ;
2014-08-08 10:59:42 +00:00
2012-12-17 23:03:21 +00:00
// set_menu_sensitivity(ui_manager_main_menubar, "/Menubar/ViewMenu/NameResolution/ResolveName",
// frame_selected && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
2016-03-26 03:16:17 +00:00
// gbl_resolv_flags.transport_name));
2016-06-01 01:29:39 +00:00
main_ui_ - > actionToolsFirewallAclRules - > setEnabled ( frame_selected ) ;
2016-03-22 16:25:34 +00:00
main_ui_ - > actionStatisticsTcpStreamRoundTripTime - > setEnabled ( is_tcp ) ;
main_ui_ - > actionStatisticsTcpStreamStevens - > setEnabled ( is_tcp ) ;
main_ui_ - > actionStatisticsTcpStreamTcptrace - > setEnabled ( is_tcp ) ;
main_ui_ - > actionStatisticsTcpStreamThroughput - > setEnabled ( is_tcp ) ;
main_ui_ - > actionStatisticsTcpStreamWindowScaling - > setEnabled ( is_tcp ) ;
2013-12-13 07:25:30 +00:00
main_ui_ - > actionSCTPAnalyseThisAssociation - > setEnabled ( is_sctp ) ;
main_ui_ - > actionSCTPShowAllAssociations - > setEnabled ( is_sctp ) ;
2013-12-18 13:49:10 +00:00
main_ui_ - > actionSCTPFilterThisAssociation - > setEnabled ( is_sctp ) ;
2021-03-27 20:01:43 +00:00
main_ui_ - > actionTelephonyRtpStreamAnalysis - > setEnabled ( is_rtp ) ;
2021-04-14 13:47:07 +00:00
main_ui_ - > actionTelephonyRtpPlayer - > setEnabled ( is_rtp ) ;
2015-10-20 14:07:10 +00:00
main_ui_ - > actionTelephonyLteRlcGraph - > setEnabled ( is_lte_rlc ) ;
2012-12-17 23:03:21 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : setMenusForSelectedTreeRow ( FieldInformation * finfo ) {
2015-07-27 22:28:50 +00:00
2015-07-29 23:24:39 +00:00
bool can_match_selected = false ;
bool is_framenum = false ;
bool have_field_info = false ;
bool have_subtree = false ;
2015-07-31 23:52:37 +00:00
bool can_open_url = false ;
2017-05-19 13:05:06 +00:00
bool have_packet_bytes = false ;
2016-03-18 17:34:41 +00:00
QByteArray field_filter ;
2015-07-31 23:52:37 +00:00
int field_id = - 1 ;
2015-07-30 23:15:40 +00:00
2017-10-30 12:58:28 +00:00
field_info * fi = 0 ;
2019-04-23 01:19:40 +00:00
if ( finfo )
2017-10-30 12:58:28 +00:00
fi = finfo - > fieldInfo ( ) ;
2014-09-09 20:42:58 +00:00
if ( capture_file_ . capFile ( ) ) {
capture_file_ . capFile ( ) - > finfo_selected = fi ;
2015-07-29 23:24:39 +00:00
if ( fi & & fi - > tree_type ! = - 1 ) {
have_subtree = true ;
}
2017-05-19 13:05:06 +00:00
2021-12-23 04:09:54 +00:00
if ( fi & & fi - > ds_tvb & & ( fi - > length > 0 ) ) {
2017-05-19 13:05:06 +00:00
have_packet_bytes = true ;
}
2012-10-16 00:01:23 +00:00
}
2014-09-09 20:42:58 +00:00
if ( capture_file_ . capFile ( ) ! = NULL & & fi ! = NULL ) {
2015-07-31 23:52:37 +00:00
header_field_info * hfinfo = fi - > hfinfo ;
int linked_frame = - 1 ;
2015-02-11 23:00:27 +00:00
2015-07-29 23:24:39 +00:00
have_field_info = true ;
can_match_selected = proto_can_match_selected ( capture_file_ . capFile ( ) - > finfo_selected , capture_file_ . capFile ( ) - > edt ) ;
2015-07-31 23:52:37 +00:00
if ( hfinfo & & hfinfo - > type = = FT_FRAMENUM ) {
is_framenum = true ;
linked_frame = fvalue_get_uinteger ( & fi - > value ) ;
}
2012-10-16 00:01:23 +00:00
2015-07-30 23:15:40 +00:00
char * tmp_field = proto_construct_match_selected_string ( fi , capture_file_ . capFile ( ) - > edt ) ;
2016-03-18 17:34:41 +00:00
field_filter = tmp_field ;
2015-07-30 23:15:40 +00:00
wmem_free ( NULL , tmp_field ) ;
2015-07-31 23:52:37 +00:00
field_id = fi - > hfinfo - > id ;
/* if the selected field isn't a protocol, get its parent */
if ( ! proto_registrar_is_protocol ( field_id ) ) {
field_id = proto_registrar_get_parent ( fi - > hfinfo - > id ) ;
}
2015-10-14 00:34:43 +00:00
if ( field_id > = 0 ) {
2015-07-31 23:52:37 +00:00
can_open_url = true ;
main_ui_ - > actionContextWikiProtocolPage - > setData ( field_id ) ;
main_ui_ - > actionContextFilterFieldReference - > setData ( field_id ) ;
} else {
main_ui_ - > actionContextWikiProtocolPage - > setData ( QVariant ( ) ) ;
main_ui_ - > actionContextFilterFieldReference - > setData ( QVariant ( ) ) ;
}
if ( linked_frame > 0 ) {
main_ui_ - > actionGoGoToLinkedPacket - > setData ( linked_frame ) ;
} else {
main_ui_ - > actionGoGoToLinkedPacket - > setData ( QVariant ( ) ) ;
}
2015-07-30 23:15:40 +00:00
}
2015-07-29 23:24:39 +00:00
2015-09-25 17:00:14 +00:00
// Always enable / disable the following items.
main_ui_ - > actionFileExportPacketBytes - > setEnabled ( have_field_info ) ;
2019-11-12 15:39:19 +00:00
main_ui_ - > actionCopyAllVisibleItems - > setEnabled ( capture_file_ . capFile ( ) ! = NULL & & ! packet_list_ - > multiSelectActive ( ) ) ;
2015-09-25 17:00:14 +00:00
main_ui_ - > actionCopyAllVisibleSelectedTreeItems - > setEnabled ( can_match_selected ) ;
main_ui_ - > actionEditCopyDescription - > setEnabled ( can_match_selected ) ;
main_ui_ - > actionEditCopyFieldName - > setEnabled ( can_match_selected ) ;
main_ui_ - > actionEditCopyValue - > setEnabled ( can_match_selected ) ;
main_ui_ - > actionEditCopyAsFilter - > setEnabled ( can_match_selected ) ;
2017-12-20 08:08:16 +00:00
main_ui_ - > actionAnalyzeShowPacketBytes - > setEnabled ( have_packet_bytes ) ;
2017-05-19 13:05:06 +00:00
main_ui_ - > actionFileExportPacketBytes - > setEnabled ( have_packet_bytes ) ;
2015-09-25 17:00:14 +00:00
main_ui_ - > actionViewExpandSubtrees - > setEnabled ( have_subtree ) ;
2017-12-18 09:25:03 +00:00
main_ui_ - > actionViewCollapseSubtrees - > setEnabled ( have_subtree ) ;
2015-09-25 17:00:14 +00:00
main_ui_ - > actionGoGoToLinkedPacket - > setEnabled ( is_framenum ) ;
main_ui_ - > actionAnalyzeCreateAColumn - > setEnabled ( can_match_selected ) ;
main_ui_ - > actionContextShowLinkedPacketInNewWindow - > setEnabled ( is_framenum ) ;
main_ui_ - > actionContextWikiProtocolPage - > setEnabled ( can_open_url ) ;
main_ui_ - > actionContextFilterFieldReference - > setEnabled ( can_open_url ) ;
2019-04-23 01:19:40 +00:00
// Only enable / disable the following items if we have focus so that we
// don't clobber anything we may have set in setMenusForSelectedPacket.
2015-09-25 17:00:14 +00:00
if ( ! proto_tree_ | | ! proto_tree_ - > hasFocus ( ) ) return ;
2016-03-18 17:34:41 +00:00
emit packetInfoChanged ( capture_file_ . packetInfo ( ) ) ;
emit fieldFilterChanged ( field_filter ) ;
2015-07-30 23:15:40 +00:00
2019-04-23 01:19:40 +00:00
// set_menu_sensitivity(ui_manager_tree_view_menu, "/TreeViewPopup/ResolveName",
// frame_selected && (gbl_resolv_flags.mac_name || gbl_resolv_flags.network_name ||
// gbl_resolv_flags.transport_name));
2015-03-09 07:11:13 +00:00
2012-10-16 00:01:23 +00:00
}
2012-10-02 18:47:05 +00:00
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : interfaceSelectionChanged ( )
2012-12-03 19:58:55 +00:00
{
2013-10-11 21:26:26 +00:00
# ifdef HAVE_LIBPCAP
2013-08-08 00:26:57 +00:00
// XXX This doesn't disable the toolbar button when using
// QtMacExtras.
if ( global_capture_opts . num_selected > 0 & & capture_filter_valid_ ) {
2014-09-18 21:09:55 +00:00
main_ui_ - > actionCaptureStart - > setEnabled ( true ) ;
2012-12-03 19:58:55 +00:00
} else {
2014-09-18 21:09:55 +00:00
main_ui_ - > actionCaptureStart - > setEnabled ( false ) ;
2012-12-03 19:58:55 +00:00
}
2013-10-11 21:26:26 +00:00
# endif // HAVE_LIBPCAP
2012-12-03 19:58:55 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : captureFilterSyntaxChanged ( bool valid )
2013-08-08 00:26:57 +00:00
{
capture_filter_valid_ = valid ;
interfaceSelectionChanged ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : startInterfaceCapture ( bool valid , const QString capture_filter )
2014-06-04 09:03:59 +00:00
{
capture_filter_valid_ = valid ;
2018-06-01 20:54:49 +00:00
welcome_page_ - > setCaptureFilter ( capture_filter ) ;
2018-06-30 19:08:54 +00:00
QString before_what ( tr ( " before starting a new capture " ) ) ;
if ( testCaptureFileClose ( before_what ) ) {
// The interface tree will update the selected interfaces via its timer
// so no need to do anything here.
2022-03-18 12:53:42 +00:00
startCapture ( QStringList ( ) ) ;
2018-06-30 19:08:54 +00:00
}
2014-06-04 09:03:59 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : applyGlobalCommandLineOptions ( )
2016-06-30 21:55:19 +00:00
{
2016-10-30 21:07:33 +00:00
if ( global_dissect_options . time_format ! = TS_NOT_SET ) {
2019-04-23 01:19:40 +00:00
foreach ( QAction * tda , td_actions . keys ( ) ) {
2016-10-30 21:07:33 +00:00
if ( global_dissect_options . time_format = = td_actions [ tda ] ) {
2016-06-30 21:55:19 +00:00
tda - > setChecked ( true ) ;
2016-10-30 21:07:33 +00:00
recent . gui_time_format = global_dissect_options . time_format ;
timestamp_set_type ( global_dissect_options . time_format ) ;
2016-06-30 21:55:19 +00:00
break ;
}
}
}
2016-10-19 18:53:40 +00:00
if ( global_commandline_info . full_screen ) {
this - > showFullScreen ( ) ;
}
2016-06-30 21:55:19 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : redissectPackets ( )
2012-12-17 23:03:21 +00:00
{
2015-11-18 07:48:50 +00:00
if ( capture_file_ . capFile ( ) ) {
2014-09-09 20:42:58 +00:00
cf_redissect_packets ( capture_file_ . capFile ( ) ) ;
2015-11-18 07:48:50 +00:00
main_ui_ - > statusBar - > expertUpdate ( ) ;
}
2015-08-14 05:54:51 +00:00
proto_free_deregistered_fields ( ) ;
2012-12-17 23:03:21 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : checkDisplayFilter ( )
2014-11-06 10:19:25 +00:00
{
2015-08-18 19:15:27 +00:00
if ( ! df_combo_box_ - > checkDisplayFilter ( ) ) {
g_free ( CaptureFile : : globalCapFile ( ) - > dfilter ) ;
CaptureFile : : globalCapFile ( ) - > dfilter = NULL ;
2014-11-06 10:19:25 +00:00
}
2015-12-02 21:15:28 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : fieldsChanged ( )
2015-12-02 21:15:28 +00:00
{
2015-12-22 20:07:00 +00:00
gchar * err_msg = NULL ;
2016-01-01 04:14:08 +00:00
if ( ! color_filters_reload ( & err_msg , color_filter_add_cb ) ) {
2015-12-22 20:07:00 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , err_msg ) ;
g_free ( err_msg ) ;
}
2015-12-02 21:15:28 +00:00
tap_listeners_dfilter_recompile ( ) ;
emit checkDisplayFilter ( ) ;
2014-11-06 10:19:25 +00:00
2014-09-09 20:42:58 +00:00
if ( have_custom_cols ( & CaptureFile : : globalCapFile ( ) - > cinfo ) ) {
2015-08-17 19:39:41 +00:00
// Recreate packet list columns according to new/changed/deleted fields
packet_list_ - > fieldsChanged ( CaptureFile : : globalCapFile ( ) ) ;
2014-11-06 10:19:25 +00:00
}
2015-08-24 20:12:17 +00:00
emit reloadFields ( ) ;
2014-11-06 10:19:25 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : reloadLuaPlugins ( )
2016-01-03 12:48:39 +00:00
{
# ifdef HAVE_LUA
2022-02-01 03:30:09 +00:00
if ( mainApp - > isReloadingLua ( ) )
2016-01-03 12:48:39 +00:00
return ;
2021-09-27 11:10:43 +00:00
gboolean uses_lua_filehandler = FALSE ;
if ( capture_file_ . capFile ( ) ) {
// Check if the current capture file is opened with a Lua FileHandler
capture_file * cf = capture_file_ . capFile ( ) ;
uses_lua_filehandler = wtap_uses_lua_filehandler ( cf - > provider . wth ) ;
if ( uses_lua_filehandler & & cf - > unsaved_changes ) {
// Prompt to save the file before reloading, in case the FileHandler has changed
QString before_what ( tr ( " before reloading Lua plugins " ) ) ;
if ( ! testCaptureFileClose ( before_what , Reload ) ) {
return ;
}
}
}
2022-02-01 03:30:09 +00:00
mainApp - > setReloadingLua ( true ) ;
2016-01-03 12:48:39 +00:00
wslua_reload_plugins ( NULL , NULL ) ;
funnel_statistics_reload_menus ( ) ;
reloadDynamicMenus ( ) ;
closePacketDialogs ( ) ;
// Preferences may have been deleted so close all widgets using prefs
main_ui_ - > preferenceEditorFrame - > animatedHide ( ) ;
2022-02-01 03:30:09 +00:00
mainApp - > readConfigurationFiles ( true ) ;
2021-08-30 20:02:17 +00:00
commandline_options_reapply ( ) ;
2016-01-03 12:48:39 +00:00
fieldsChanged ( ) ;
2021-10-04 08:08:30 +00:00
prefs_apply_all ( ) ;
2021-09-27 11:10:43 +00:00
if ( uses_lua_filehandler ) {
// Reload the file in case the FileHandler has changed
2021-10-03 19:16:16 +00:00
if ( cf_reload ( capture_file_ . capFile ( ) ) ! = CF_OK ) {
cf_close ( capture_file_ . capFile ( ) ) ;
}
2021-09-27 11:10:43 +00:00
proto_free_deregistered_fields ( ) ;
} else {
redissectPackets ( ) ;
}
2016-01-03 12:48:39 +00:00
2022-02-01 03:30:09 +00:00
mainApp - > setReloadingLua ( false ) ;
2016-01-03 12:48:39 +00:00
SimpleDialog : : displayQueuedMessages ( ) ;
# endif
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : showAccordionFrame ( AccordionFrame * show_frame , bool toggle )
2015-06-17 15:41:41 +00:00
{
QList < AccordionFrame * > frame_list = QList < AccordionFrame * > ( )
< < main_ui_ - > goToFrame < < main_ui_ - > searchFrame
2015-07-21 16:51:12 +00:00
< < main_ui_ - > addressEditorFrame < < main_ui_ - > columnEditorFrame
2016-02-18 19:48:23 +00:00
< < main_ui_ - > preferenceEditorFrame < < main_ui_ - > filterExpressionFrame ;
2015-06-17 15:41:41 +00:00
frame_list . removeAll ( show_frame ) ;
2019-04-23 01:19:40 +00:00
foreach ( AccordionFrame * af , frame_list ) af - > animatedHide ( ) ;
2015-06-17 15:41:41 +00:00
if ( toggle ) {
if ( show_frame - > isVisible ( ) ) {
show_frame - > animatedHide ( ) ;
return ;
}
}
show_frame - > animatedShow ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : showColumnEditor ( int column )
2015-01-01 19:41:03 +00:00
{
2022-02-01 03:30:09 +00:00
previous_focus_ = mainApp - > focusWidget ( ) ;
2015-01-01 19:41:03 +00:00
connect ( previous_focus_ , SIGNAL ( destroyed ( ) ) , this , SLOT ( resetPreviousFocus ( ) ) ) ;
main_ui_ - > columnEditorFrame - > editColumn ( column ) ;
2017-11-08 20:10:42 +00:00
showAccordionFrame ( main_ui_ - > columnEditorFrame ) ;
2015-06-17 15:41:41 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : showPreferenceEditor ( )
2015-06-17 15:41:41 +00:00
{
showAccordionFrame ( main_ui_ - > preferenceEditorFrame ) ;
2015-01-01 19:41:03 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : initViewColorizeMenu ( )
2015-07-10 23:15:55 +00:00
{
QList < QAction * > cc_actions = QList < QAction * > ( )
< < main_ui_ - > actionViewColorizeConversation1 < < main_ui_ - > actionViewColorizeConversation2
< < main_ui_ - > actionViewColorizeConversation3 < < main_ui_ - > actionViewColorizeConversation4
< < main_ui_ - > actionViewColorizeConversation5 < < main_ui_ - > actionViewColorizeConversation6
< < main_ui_ - > actionViewColorizeConversation7 < < main_ui_ - > actionViewColorizeConversation8
< < main_ui_ - > actionViewColorizeConversation9 < < main_ui_ - > actionViewColorizeConversation10 ;
guint8 color_num = 1 ;
2019-04-23 01:19:40 +00:00
foreach ( QAction * cc_action , cc_actions ) {
2015-07-10 23:15:55 +00:00
cc_action - > setData ( color_num ) ;
connect ( cc_action , SIGNAL ( triggered ( ) ) , this , SLOT ( colorizeConversation ( ) ) ) ;
const color_filter_t * colorf = color_filters_tmp_color ( color_num ) ;
if ( colorf ) {
QColor bg = ColorUtils : : fromColorT ( colorf - > bg_color ) ;
QColor fg = ColorUtils : : fromColorT ( colorf - > fg_color ) ;
cc_action - > setIcon ( StockIcon : : colorIcon ( bg . rgb ( ) , fg . rgb ( ) , QString : : number ( color_num ) ) ) ;
}
color_num + + ;
}
# ifdef Q_OS_MAC
// Spotlight uses Cmd+Space
main_ui_ - > actionViewColorizeResetColorization - > setShortcut ( QKeySequence ( " Meta+Space " ) ) ;
# endif
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : addStatsPluginsToMenu ( ) {
2015-01-06 09:22:48 +00:00
GList * cfg_list = stats_tree_get_cfg_list ( ) ;
QAction * stats_tree_action ;
QMenu * parent_menu ;
bool first_item = true ;
2022-04-11 22:23:29 +00:00
for ( GList * iter = g_list_first ( cfg_list ) ; iter ; iter = gxx_list_next ( iter ) ) {
2019-08-14 08:18:51 +00:00
stats_tree_cfg * cfg = gxx_list_data ( stats_tree_cfg * , iter ) ;
2022-04-11 22:23:29 +00:00
if ( ! menu_groups_ . contains ( cfg - > stat_group ) ) {
continue ;
}
2015-01-06 09:22:48 +00:00
if ( cfg - > plugin ) {
if ( first_item ) {
main_ui_ - > menuStatistics - > addSeparator ( ) ;
first_item = false ;
}
parent_menu = main_ui_ - > menuStatistics ;
// gtk/main_menubar.c compresses double slashes, hence SkipEmptyParts
2020-05-28 18:40:08 +00:00
# if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
QStringList cfg_name_parts = QString ( cfg - > name ) . split ( " / " , Qt : : SkipEmptyParts ) ;
# else
2015-01-06 09:22:48 +00:00
QStringList cfg_name_parts = QString ( cfg - > name ) . split ( " / " , QString : : SkipEmptyParts ) ;
2020-05-28 18:40:08 +00:00
# endif
2015-01-06 09:22:48 +00:00
if ( cfg_name_parts . isEmpty ( ) ) continue ;
QString stat_name = cfg_name_parts . takeLast ( ) ;
if ( ! cfg_name_parts . isEmpty ( ) ) {
QString menu_name = cfg_name_parts . join ( " / " ) ;
parent_menu = findOrAddMenu ( parent_menu , menu_name ) ;
}
stats_tree_action = new QAction ( stat_name , this ) ;
stats_tree_action - > setData ( cfg - > abbr ) ;
parent_menu - > addAction ( stats_tree_action ) ;
connect ( stats_tree_action , SIGNAL ( triggered ( ) ) , this , SLOT ( actionStatisticsPlugin_triggered ( ) ) ) ;
}
}
g_list_free ( cfg_list ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : setFeaturesEnabled ( bool enabled )
2013-05-20 18:56:33 +00:00
{
main_ui_ - > menuBar - > setEnabled ( enabled ) ;
main_ui_ - > mainToolBar - > setEnabled ( enabled ) ;
main_ui_ - > displayFilterToolBar - > setEnabled ( enabled ) ;
2019-04-23 01:19:40 +00:00
if ( enabled )
2013-05-20 18:56:33 +00:00
{
main_ui_ - > statusBar - > clearMessage ( ) ;
2016-06-23 08:00:26 +00:00
# ifdef HAVE_LIBPCAP
2016-06-22 21:41:16 +00:00
main_ui_ - > actionGoAutoScroll - > setChecked ( auto_scroll_live ) ;
2016-06-23 08:00:26 +00:00
# endif
2013-05-20 18:56:33 +00:00
}
else
{
2020-09-29 00:40:05 +00:00
main_ui_ - > statusBar - > showMessage ( tr ( " Please wait while Wireshark is initializing… " ) ) ;
2013-05-20 18:56:33 +00:00
}
}
2015-06-01 23:29:17 +00:00
// Display Filter Toolbar
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionDisplayFilterExpression_triggered ( )
2015-06-01 23:29:17 +00:00
{
DisplayFilterExpressionDialog * dfe_dialog = new DisplayFilterExpressionDialog ( this ) ;
connect ( dfe_dialog , SIGNAL ( insertDisplayFilter ( QString ) ) ,
df_combo_box_ - > lineEdit ( ) , SLOT ( insertFilter ( const QString & ) ) ) ;
dfe_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionNewDisplayFilterExpression_triggered ( )
2015-10-28 21:41:59 +00:00
{
main_ui_ - > filterExpressionFrame - > addExpression ( df_combo_box_ - > lineEdit ( ) - > text ( ) ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : onFilterSelected ( QString filterText , bool prepare )
2013-02-06 18:22:54 +00:00
{
2018-06-25 18:01:37 +00:00
if ( filterText . length ( ) < = 0 )
2017-07-05 12:15:38 +00:00
return ;
2018-06-25 18:01:37 +00:00
df_combo_box_ - > setDisplayFilter ( filterText ) ;
2017-07-05 12:15:38 +00:00
// Holding down the Shift key will only prepare filter.
2018-06-25 18:01:37 +00:00
if ( ! prepare )
2017-07-05 12:15:38 +00:00
df_combo_box_ - > applyDisplayFilter ( ) ;
2018-06-25 18:01:37 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : onFilterPreferences ( )
2018-06-25 18:01:37 +00:00
{
2019-08-09 09:28:04 +00:00
emit showPreferencesDialog ( PrefsModel : : typeToString ( PrefsModel : : FilterButtons ) ) ;
2018-06-25 18:01:37 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : onFilterEdit ( int uatIndex )
2018-06-25 18:01:37 +00:00
{
main_ui_ - > filterExpressionFrame - > editExpression ( uatIndex ) ;
2013-02-06 18:22:54 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : openStatCommandDialog ( const QString & menu_path , const char * arg , void * userdata )
2014-07-09 17:50:51 +00:00
{
QString slot = QString ( " statCommand%1 " ) . arg ( menu_path ) ;
QMetaObject : : invokeMethod ( this , slot . toLatin1 ( ) . constData ( ) , Q_ARG ( const char * , arg ) , Q_ARG ( void * , userdata ) ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : openTapParameterDialog ( const QString cfg_str , const QString arg , void * userdata )
2015-06-05 20:17:13 +00:00
{
TapParameterDialog * tp_dialog = TapParameterDialog : : showTapParameterStatistics ( * this , capture_file_ , cfg_str , arg , userdata ) ;
if ( ! tp_dialog ) return ;
2019-04-23 01:19:40 +00:00
connect ( tp_dialog , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ,
this , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ) ;
2015-08-28 19:28:24 +00:00
connect ( tp_dialog , SIGNAL ( updateFilter ( QString ) ) ,
df_combo_box_ - > lineEdit ( ) , SLOT ( setText ( QString ) ) ) ;
2015-06-05 20:17:13 +00:00
tp_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : openTapParameterDialog ( )
2015-06-05 20:17:13 +00:00
{
QAction * tpa = qobject_cast < QAction * > ( QObject : : sender ( ) ) ;
if ( ! tpa ) return ;
const QString cfg_str = tpa - > data ( ) . toString ( ) ;
openTapParameterDialog ( cfg_str , NULL , NULL ) ;
}
2019-11-14 16:08:28 +00:00
# if defined(HAVE_SOFTWARE_UPDATE) && defined(Q_OS_WIN)
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : softwareUpdateRequested ( ) {
2016-12-13 18:33:02 +00:00
// We could call testCaptureFileClose here, but that would give us yet
// another dialog. Just try again later.
if ( capture_file_ . capFile ( ) & & capture_file_ . capFile ( ) - > state ! = FILE_CLOSED ) {
2022-02-01 03:30:09 +00:00
mainApp - > rejectSoftwareUpdate ( ) ;
2016-12-13 18:33:02 +00:00
}
}
# endif
2012-10-02 18:47:05 +00:00
// File Menu
2022-09-22 22:15:48 +00:00
void WiresharkMainWindow : : connectFileMenuActions ( )
2012-10-02 18:47:05 +00:00
{
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileOpen , & QAction : : triggered , this ,
[ this ] ( ) { openCaptureFile ( ) ; } ) ;
2012-10-02 18:47:05 +00:00
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileMerge , & QAction : : triggered , this ,
[ this ] ( ) { mergeCaptureFile ( ) ; } ) ;
2012-10-02 18:47:05 +00:00
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileImportFromHexDump , & QAction : : triggered , this ,
[ this ] ( ) { importCaptureFile ( ) ; } ) ;
2012-10-02 18:47:05 +00:00
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileClose , & QAction : : triggered , this , [ this ] ( ) {
QString before_what ( tr ( " before closing the file " ) ) ;
if ( testCaptureFileClose ( before_what ) ) {
showWelcome ( ) ;
}
} ) ;
2012-10-02 18:47:05 +00:00
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileSave , & QAction : : triggered , this ,
[ this ] ( ) { saveCaptureFile ( capture_file_ . capFile ( ) , false ) ; } ) ;
2012-10-02 18:47:05 +00:00
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileSaveAs , & QAction : : triggered , this ,
[ this ] ( ) { saveAsCaptureFile ( capture_file_ . capFile ( ) ) ; } ) ;
2012-10-02 18:47:05 +00:00
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileSetListFiles , & QAction : : triggered , this ,
[ this ] ( ) { file_set_dialog_ - > show ( ) ; } ) ;
2012-10-02 18:47:05 +00:00
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileSetNextFile , & QAction : : triggered , this , [ this ] ( ) {
fileset_entry * entry = fileset_get_next ( ) ;
2012-10-02 18:47:05 +00:00
2022-09-22 22:15:48 +00:00
if ( entry ) {
QString new_cf_path = entry - > fullname ;
openCaptureFile ( new_cf_path ) ;
}
} ) ;
2012-10-02 18:47:05 +00:00
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileSetPreviousFile , & QAction : : triggered , this , [ this ] ( ) {
fileset_entry * entry = fileset_get_previous ( ) ;
2012-10-02 18:47:05 +00:00
2022-09-22 22:15:48 +00:00
if ( entry ) {
QString new_cf_path = entry - > fullname ;
openCaptureFile ( new_cf_path ) ;
}
} ) ;
2012-10-02 18:47:05 +00:00
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileExportPackets , & QAction : : triggered , this ,
[ this ] ( ) { exportSelectedPackets ( ) ; } ) ;
2012-10-12 23:40:29 +00:00
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileExportAsPlainText , & QAction : : triggered , this ,
[ this ] ( ) { exportDissections ( export_type_text ) ; } ) ;
2012-10-12 23:40:29 +00:00
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileExportAsCSV , & QAction : : triggered , this ,
[ this ] ( ) { exportDissections ( export_type_csv ) ; } ) ;
2012-10-12 23:40:29 +00:00
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileExportAsCArrays , & QAction : : triggered , this ,
[ this ] ( ) { exportDissections ( export_type_carrays ) ; } ) ;
2012-10-12 23:40:29 +00:00
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileExportAsPSML , & QAction : : triggered , this ,
[ this ] ( ) { exportDissections ( export_type_psml ) ; } ) ;
2012-10-12 23:40:29 +00:00
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileExportAsPDML , & QAction : : triggered , this ,
[ this ] ( ) { exportDissections ( export_type_pdml ) ; } ) ;
2012-10-12 23:40:29 +00:00
2022-09-22 22:15:48 +00:00
connect ( main_ui_ - > actionFileExportAsJSON , & QAction : : triggered , this ,
[ this ] ( ) { exportDissections ( export_type_json ) ; } ) ;
connect ( main_ui_ - > actionFileExportPacketBytes , & QAction : : triggered , this ,
[ this ] ( ) { exportPacketBytes ( ) ; } ) ;
connect ( main_ui_ - > actionFileExportPDU , & QAction : : triggered , this ,
[ this ] ( ) { exportPDU ( ) ; } ) ;
connect ( main_ui_ - > actionFileStripHeaders , & QAction : : triggered , this ,
[ this ] ( ) { stripPacketHeaders ( ) ; } ) ;
connect ( main_ui_ - > actionFileExportTLSSessionKeys , & QAction : : triggered , this ,
[ this ] ( ) { exportTLSSessionKeys ( ) ; } ) ;
connect ( main_ui_ - > actionFilePrint , & QAction : : triggered , this ,
[ this ] ( ) { printFile ( ) ; } ) ;
2016-06-19 14:52:50 +00:00
}
2022-09-22 22:15:48 +00:00
void WiresharkMainWindow : : exportPacketBytes ( )
2012-10-16 00:01:23 +00:00
{
QString file_name ;
2014-09-09 20:42:58 +00:00
if ( ! capture_file_ . capFile ( ) | | ! capture_file_ . capFile ( ) - > finfo_selected ) return ;
2012-10-16 00:01:23 +00:00
2018-05-16 00:02:26 +00:00
file_name = WiresharkFileDialog : : getSaveFileName ( this ,
2022-02-01 03:30:09 +00:00
mainApp - > windowTitleString ( tr ( " Export Selected Packet Bytes " ) ) ,
mainApp - > lastOpenDir ( ) . canonicalPath ( ) ,
2019-04-23 01:19:40 +00:00
tr ( " Raw data (*.bin *.dat *.raw);;All Files ( " ALL_FILES_WILDCARD " ) " )
) ;
2012-10-16 00:01:23 +00:00
if ( file_name . length ( ) > 0 ) {
const guint8 * data_p ;
2014-09-09 20:42:58 +00:00
data_p = tvb_get_ptr ( capture_file_ . capFile ( ) - > finfo_selected - > ds_tvb , 0 , - 1 ) +
capture_file_ . capFile ( ) - > finfo_selected - > start ;
2021-06-06 12:10:22 +00:00
write_file_binary_mode ( qUtf8Printable ( file_name ) , data_p , capture_file_ . capFile ( ) - > finfo_selected - > length ) ;
2012-10-16 00:01:23 +00:00
/* Save the directory name for future file dialogs. */
2022-02-01 03:30:09 +00:00
mainApp - > setLastOpenDirFromFilename ( file_name ) ;
2012-10-16 00:01:23 +00:00
}
}
2016-02-07 21:15:12 +00:00
2022-09-22 22:15:48 +00:00
void WiresharkMainWindow : : exportPDU ( )
2014-01-14 18:37:40 +00:00
{
ExportPDUDialog * exportpdu_dialog = new ExportPDUDialog ( this ) ;
if ( exportpdu_dialog - > isMinimized ( ) = = true )
{
exportpdu_dialog - > showNormal ( ) ;
}
else
{
exportpdu_dialog - > show ( ) ;
}
exportpdu_dialog - > raise ( ) ;
exportpdu_dialog - > activateWindow ( ) ;
}
2012-10-12 23:40:29 +00:00
2022-09-22 22:15:48 +00:00
void WiresharkMainWindow : : stripPacketHeaders ( )
2022-02-25 12:49:51 +00:00
{
StripHeadersDialog * stripheaders_dialog = new StripHeadersDialog ( this ) ;
if ( stripheaders_dialog - > isMinimized ( ) = = true )
{
stripheaders_dialog - > showNormal ( ) ;
}
else
{
stripheaders_dialog - > show ( ) ;
}
stripheaders_dialog - > raise ( ) ;
stripheaders_dialog - > activateWindow ( ) ;
}
2022-09-22 22:15:48 +00:00
void WiresharkMainWindow : : exportTLSSessionKeys ( )
2012-10-16 18:14:16 +00:00
{
QString file_name ;
QString save_title ;
int keylist_len ;
keylist_len = ssl_session_key_count ( ) ;
/* don't show up the dialog, if no data has to be saved */
if ( keylist_len < 1 ) {
/* shouldn't happen as the menu item should have been greyed out */
QMessageBox : : warning (
this ,
tr ( " No Keys " ) ,
2018-09-13 15:40:27 +00:00
tr ( " There are no TLS Session Keys to save. " ) ,
2012-10-16 18:14:16 +00:00
QMessageBox : : Ok
) ;
return ;
}
2022-02-01 03:30:09 +00:00
save_title . append ( mainApp - > windowTitleString ( tr ( " Export TLS Session Keys (%Ln key(s)) " , " " , keylist_len ) ) ) ;
2018-05-16 00:02:26 +00:00
file_name = WiresharkFileDialog : : getSaveFileName ( this ,
2019-04-23 01:19:40 +00:00
save_title ,
2022-02-01 03:30:09 +00:00
mainApp - > lastOpenDir ( ) . canonicalPath ( ) ,
2019-04-23 01:19:40 +00:00
tr ( " TLS Session Keys (*.keys *.txt);;All Files ( " ALL_FILES_WILDCARD " ) " )
) ;
2012-10-16 18:14:16 +00:00
if ( file_name . length ( ) > 0 ) {
2021-06-07 06:59:02 +00:00
gsize keylist_length ;
gchar * keylist = ssl_export_sessions ( & keylist_length ) ;
write_file_binary_mode ( qUtf8Printable ( file_name ) , keylist , keylist_length ) ;
2012-10-16 18:14:16 +00:00
/* Save the directory name for future file dialogs. */
2022-02-01 03:30:09 +00:00
mainApp - > setLastOpenDirFromFilename ( file_name ) ;
2012-10-16 18:14:16 +00:00
g_free ( keylist ) ;
}
}
2022-09-22 22:15:48 +00:00
void WiresharkMainWindow : : printFile ( )
2012-11-01 20:57:45 +00:00
{
2018-05-21 20:33:37 +00:00
capture_file * cf = capture_file_ . capFile ( ) ;
g_return_if_fail ( cf ) ;
2012-11-01 20:57:45 +00:00
2019-11-12 15:39:19 +00:00
QList < int > rows = packet_list_ - > selectedRows ( true ) ;
QStringList entries ;
2019-11-17 19:02:20 +00:00
foreach ( int row , rows )
2019-11-12 15:39:19 +00:00
entries < < QString : : number ( row ) ;
QString selRange = entries . join ( " , " ) ;
2019-04-23 01:19:40 +00:00
2019-11-12 15:39:19 +00:00
PrintDialog * pdlg_ = new PrintDialog ( this , cf , selRange ) ;
2019-09-29 09:39:40 +00:00
pdlg_ - > setWindowModality ( Qt : : ApplicationModal ) ;
pdlg_ - > show ( ) ;
2012-11-01 20:57:45 +00:00
}
2012-12-07 01:46:20 +00:00
// Edit Menu
2022-09-22 22:35:04 +00:00
void WiresharkMainWindow : : connectEditMenuActions ( )
2015-03-23 11:04:36 +00:00
{
2022-09-22 22:35:04 +00:00
connect ( main_ui_ - > actionCopyAllVisibleItems , & QAction : : triggered , this ,
[ this ] ( ) { copySelectedItems ( CopyAllVisibleItems ) ; } ) ;
2015-03-23 11:04:36 +00:00
2022-09-22 22:35:04 +00:00
connect ( main_ui_ - > actionCopyListAsText , & QAction : : triggered , this ,
[ this ] ( ) { copySelectedItems ( CopyListAsText ) ; } ) ;
2019-11-12 15:39:19 +00:00
2022-09-22 22:35:04 +00:00
connect ( main_ui_ - > actionCopyListAsCSV , & QAction : : triggered , this ,
[ this ] ( ) { copySelectedItems ( CopyListAsCSV ) ; } ) ;
2019-11-12 15:39:19 +00:00
2022-09-22 22:35:04 +00:00
connect ( main_ui_ - > actionCopyListAsYAML , & QAction : : triggered , this ,
[ this ] ( ) { copySelectedItems ( CopyListAsYAML ) ; } ) ;
2019-11-12 15:39:19 +00:00
2022-09-22 22:35:04 +00:00
connect ( main_ui_ - > actionCopyAllVisibleSelectedTreeItems , & QAction : : triggered , this ,
[ this ] ( ) { copySelectedItems ( CopyAllVisibleSelectedTreeItems ) ; } ) ;
2015-03-23 11:04:36 +00:00
2022-09-18 23:38:01 +00:00
connect ( main_ui_ - > actionEditCopyDescription , & QAction : : triggered , this ,
2022-09-22 22:35:04 +00:00
[ this ] ( ) { copySelectedItems ( CopySelectedDescription ) ; } ) ;
2022-09-18 23:38:01 +00:00
connect ( main_ui_ - > actionEditCopyFieldName , & QAction : : triggered , this ,
2022-09-22 22:35:04 +00:00
[ this ] ( ) { copySelectedItems ( CopySelectedFieldName ) ; } ) ;
2022-09-18 23:38:01 +00:00
connect ( main_ui_ - > actionEditCopyValue , & QAction : : triggered , this ,
2022-09-22 22:35:04 +00:00
[ this ] ( ) { copySelectedItems ( CopySelectedValue ) ; } ) ;
2022-09-18 23:38:01 +00:00
connect ( main_ui_ - > actionEditCopyAsFilter , & QAction : : triggered , this ,
[ this ] ( ) { matchFieldFilter ( FilterAction : : ActionCopy , FilterAction : : ActionTypePlain ) ; } ) ;
connect ( main_ui_ - > actionEditFindPacket , & QAction : : triggered , this ,
[ this ] ( ) { findPacket ( ) ; } ) ;
connect ( main_ui_ - > actionEditFindNext , & QAction : : triggered , this ,
[ this ] ( ) { main_ui_ - > searchFrame - > findNext ( ) ; } ) ;
connect ( main_ui_ - > actionEditFindPrevious , & QAction : : triggered , this ,
[ this ] ( ) { main_ui_ - > searchFrame - > findPrevious ( ) ; } ) ;
// The items below are used in the packet list and detail context menus.
// Use QueuedConnections so that the context menus aren't destroyed
// prematurely.
connect ( main_ui_ - > actionEditMarkPacket , & QAction : : triggered , this , [ this ] ( ) {
freeze ( ) ;
packet_list_ - > markFrame ( ) ;
thaw ( ) ;
setMenusForSelectedPacket ( ) ;
} , Qt : : QueuedConnection ) ;
connect ( main_ui_ - > actionEditMarkAllDisplayed , & QAction : : triggered , this , [ this ] ( ) {
freeze ( ) ;
packet_list_ - > markAllDisplayedFrames ( true ) ;
thaw ( ) ;
setMenusForSelectedPacket ( ) ;
} , Qt : : QueuedConnection ) ;
connect ( main_ui_ - > actionEditUnmarkAllDisplayed , & QAction : : triggered , this , [ this ] ( ) {
freeze ( ) ;
packet_list_ - > markAllDisplayedFrames ( false ) ;
thaw ( ) ;
setMenusForSelectedPacket ( ) ;
} , Qt : : QueuedConnection ) ;
connect ( main_ui_ - > actionEditNextMark , & QAction : : triggered , this , [ this ] ( ) {
if ( capture_file_ . capFile ( ) ) {
cf_find_packet_marked ( capture_file_ . capFile ( ) , SD_FORWARD ) ;
}
} , Qt : : QueuedConnection ) ;
2012-12-07 01:46:20 +00:00
2022-09-18 23:38:01 +00:00
connect ( main_ui_ - > actionEditPreviousMark , & QAction : : triggered , this , [ this ] ( ) {
if ( capture_file_ . capFile ( ) ) {
cf_find_packet_marked ( capture_file_ . capFile ( ) , SD_BACKWARD ) ;
}
} , Qt : : QueuedConnection ) ;
2012-12-07 01:46:20 +00:00
2022-09-18 23:38:01 +00:00
connect ( main_ui_ - > actionEditIgnorePacket , & QAction : : triggered , this , [ this ] ( ) {
freeze ( ) ;
packet_list_ - > ignoreFrame ( ) ;
thaw ( ) ;
setMenusForSelectedPacket ( ) ;
} , Qt : : QueuedConnection ) ;
2012-12-07 01:46:20 +00:00
2022-09-18 23:38:01 +00:00
connect ( main_ui_ - > actionEditIgnoreAllDisplayed , & QAction : : triggered , this , [ this ] ( ) {
freeze ( ) ;
packet_list_ - > ignoreAllDisplayedFrames ( true ) ;
thaw ( ) ;
setMenusForSelectedPacket ( ) ;
} , Qt : : QueuedConnection ) ;
connect ( main_ui_ - > actionEditUnignoreAllDisplayed , & QAction : : triggered , this , [ this ] ( ) {
freeze ( ) ;
packet_list_ - > ignoreAllDisplayedFrames ( false ) ;
thaw ( ) ;
setMenusForSelectedPacket ( ) ;
} , Qt : : QueuedConnection ) ;
connect ( main_ui_ - > actionEditSetTimeReference , & QAction : : triggered , this , [ this ] ( ) {
packet_list_ - > setTimeReference ( ) ;
setMenusForSelectedPacket ( ) ;
} , Qt : : QueuedConnection ) ;
connect ( main_ui_ - > actionEditUnsetAllTimeReferences , & QAction : : triggered , this , [ this ] ( ) {
packet_list_ - > unsetAllTimeReferences ( ) ;
setMenusForSelectedPacket ( ) ;
} , Qt : : QueuedConnection ) ;
connect ( main_ui_ - > actionEditNextTimeReference , & QAction : : triggered , this , [ this ] ( ) {
if ( ! capture_file_ . capFile ( ) ) return ;
cf_find_packet_time_reference ( capture_file_ . capFile ( ) , SD_FORWARD ) ;
} , Qt : : QueuedConnection ) ;
connect ( main_ui_ - > actionEditPreviousTimeReference , & QAction : : triggered , this , [ this ] ( ) {
if ( ! capture_file_ . capFile ( ) ) return ;
cf_find_packet_time_reference ( capture_file_ . capFile ( ) , SD_BACKWARD ) ;
} , Qt : : QueuedConnection ) ;
connect ( main_ui_ - > actionEditTimeShift , & QAction : : triggered , this ,
[ this ] ( ) { editTimeShift ( ) ; } , Qt : : QueuedConnection ) ;
connect ( main_ui_ - > actionEditConfigurationProfiles , & QAction : : triggered , this ,
[ this ] ( ) { editConfigurationProfiles ( ) ; } , Qt : : QueuedConnection ) ;
connect ( main_ui_ - > actionEditPreferences , & QAction : : triggered , this ,
[ this ] ( ) { showPreferencesDialog ( PrefsModel : : typeToString ( PrefsModel : : Appearance ) ) ; } , Qt : : QueuedConnection ) ;
2012-12-07 01:46:20 +00:00
}
2022-09-22 22:35:04 +00:00
// XXX This should probably be somewhere else.
void WiresharkMainWindow : : copySelectedItems ( WiresharkMainWindow : : CopySelected selection_type )
{
char label_str [ ITEM_LABEL_LENGTH ] ;
QString clip ;
if ( ! capture_file_ . capFile ( ) ) return ;
field_info * finfo_selected = capture_file_ . capFile ( ) - > finfo_selected ;
switch ( selection_type ) {
case CopySelectedDescription :
if ( proto_tree_ - > selectionModel ( ) - > hasSelection ( ) ) {
QModelIndex idx = proto_tree_ - > selectionModel ( ) - > selectedIndexes ( ) . first ( ) ;
clip = idx . data ( Qt : : DisplayRole ) . toString ( ) ;
}
break ;
case CopySelectedFieldName :
if ( finfo_selected & & finfo_selected - > hfinfo - > abbrev ! = 0 ) {
clip . append ( finfo_selected - > hfinfo - > abbrev ) ;
}
break ;
case CopySelectedValue :
if ( finfo_selected & & capture_file_ . capFile ( ) - > edt ! = 0 ) {
gchar * field_str = get_node_field_value ( finfo_selected , capture_file_ . capFile ( ) - > edt ) ;
clip . append ( field_str ) ;
g_free ( field_str ) ;
}
break ;
case CopyAllVisibleItems :
clip = proto_tree_ - > toString ( ) ;
break ;
case CopyAllVisibleSelectedTreeItems :
if ( proto_tree_ - > selectionModel ( ) - > hasSelection ( ) ) {
clip = proto_tree_ - > toString ( proto_tree_ - > selectionModel ( ) - > selectedIndexes ( ) . first ( ) ) ;
}
break ;
case CopyListAsText :
case CopyListAsCSV :
case CopyListAsYAML :
if ( packet_list_ - > selectedRows ( ) . count ( ) > 0 )
{
QList < int > rows = packet_list_ - > selectedRows ( ) ;
QStringList content ;
PacketList : : SummaryCopyType copyType = PacketList : : CopyAsText ;
if ( selection_type = = CopyListAsCSV )
copyType = PacketList : : CopyAsCSV ;
else if ( selection_type = = CopyListAsYAML )
copyType = PacketList : : CopyAsYAML ;
if ( ( copyType = = PacketList : : CopyAsText ) | |
( copyType = = PacketList : : CopyAsCSV ) ) {
QString headerEntry = packet_list_ - > createHeaderSummaryText ( copyType ) ;
content < < headerEntry ;
}
foreach ( int row , rows )
{
QModelIndex idx = packet_list_ - > model ( ) - > index ( row , 0 ) ;
if ( ! idx . isValid ( ) )
continue ;
QString entry = packet_list_ - > createSummaryText ( idx , copyType ) ;
content < < entry ;
}
if ( content . count ( ) > 0 ) {
clip = content . join ( " \n " ) ;
//
// Each YAML item ends with a newline, so the string
// ends with a newline already if it's CopyListAsYAML.
// If we add a newline, there'd be an extra blank
// line.
//
// Otherwise, we've used newlines as separators, not
// terminators, so there's no final newline. Add it.
//
if ( selection_type ! = CopyListAsYAML )
clip + = " \n " ;
}
}
break ;
}
if ( clip . length ( ) = = 0 ) {
/* If no representation then... Try to read the value */
proto_item_fill_label ( capture_file_ . capFile ( ) - > finfo_selected , label_str ) ;
clip . append ( label_str ) ;
}
if ( clip . length ( ) ) {
mainApp - > clipboard ( ) - > setText ( clip ) ;
} else {
QString err = tr ( " Couldn't copy text. Try another item. " ) ;
mainApp - > pushStatus ( WiresharkApplication : : TemporaryStatus , err ) ;
}
}
2022-09-18 23:38:01 +00:00
void WiresharkMainWindow : : findPacket ( )
2012-12-15 01:04:39 +00:00
{
2019-09-22 12:56:46 +00:00
if ( ! packet_list_ - > model ( ) | | packet_list_ - > model ( ) - > rowCount ( ) < 1 ) {
2012-12-15 01:04:39 +00:00
return ;
}
2022-02-01 03:30:09 +00:00
previous_focus_ = mainApp - > focusWidget ( ) ;
2012-12-15 01:04:39 +00:00
connect ( previous_focus_ , SIGNAL ( destroyed ( ) ) , this , SLOT ( resetPreviousFocus ( ) ) ) ;
2019-04-23 01:19:40 +00:00
if ( ! main_ui_ - > searchFrame - > isVisible ( ) ) {
2017-06-19 13:57:04 +00:00
showAccordionFrame ( main_ui_ - > searchFrame , true ) ;
2019-11-04 12:06:06 +00:00
} else {
main_ui_ - > searchFrame - > animatedHide ( ) ;
2015-11-27 23:09:46 +00:00
}
2017-06-19 13:57:04 +00:00
main_ui_ - > searchFrame - > setFocus ( ) ;
2012-12-15 01:04:39 +00:00
}
2022-09-18 23:38:01 +00:00
void WiresharkMainWindow : : editTimeShift ( )
2012-12-21 17:37:57 +00:00
{
2019-09-29 09:39:40 +00:00
TimeShiftDialog * ts_dialog = new TimeShiftDialog ( this , capture_file_ . capFile ( ) ) ;
connect ( ts_dialog , SIGNAL ( finished ( int ) ) , this , SLOT ( editTimeShiftFinished ( int ) ) ) ;
2012-12-21 17:37:57 +00:00
connect ( this , SIGNAL ( setCaptureFile ( capture_file * ) ) ,
2019-09-29 09:39:40 +00:00
ts_dialog , SLOT ( setCaptureFile ( capture_file * ) ) ) ;
connect ( ts_dialog , SIGNAL ( timeShifted ( ) ) , packet_list_ , SLOT ( applyTimeShift ( ) ) ) ;
ts_dialog - > setWindowModality ( Qt : : ApplicationModal ) ;
ts_dialog - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
ts_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : editTimeShiftFinished ( int )
2019-09-29 09:39:40 +00:00
{
2018-12-15 22:43:04 +00:00
if ( capture_file_ . capFile ( ) - > unsaved_changes ) {
updateForUnsavedChanges ( ) ;
}
2012-12-21 17:37:57 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : actionAddPacketComment ( )
2021-04-29 11:23:21 +00:00
{
QList < int > rows = selectedRows ( ) ;
2021-08-11 12:57:45 +00:00
if ( rows . count ( ) = = 0 )
2021-04-29 11:23:21 +00:00
return ;
frame_data * fdata = frameDataForRow ( rows . at ( 0 ) ) ;
if ( ! fdata )
return ;
PacketCommentDialog * pc_dialog ;
2021-08-11 12:57:45 +00:00
pc_dialog = new PacketCommentDialog ( false , this , NULL ) ;
2022-02-10 23:11:43 +00:00
connect ( pc_dialog , & QDialog : : finished , std : : bind ( & WiresharkMainWindow : : addPacketCommentFinished , this , pc_dialog , std : : placeholders : : _1 ) ) ;
2021-04-29 11:23:21 +00:00
pc_dialog - > setWindowModality ( Qt : : ApplicationModal ) ;
pc_dialog - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
pc_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : addPacketCommentFinished ( PacketCommentDialog * pc_dialog _U_ , int result _U_ )
2021-04-29 11:23:21 +00:00
{
if ( result = = QDialog : : Accepted ) {
packet_list_ - > addPacketComment ( pc_dialog - > text ( ) ) ;
updateForUnsavedChanges ( ) ;
}
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : actionEditPacketComment ( )
2012-12-23 04:37:58 +00:00
{
2019-11-12 15:39:19 +00:00
QList < int > rows = selectedRows ( ) ;
2019-11-17 19:02:20 +00:00
if ( rows . count ( ) ! = 1 )
2019-11-12 15:39:19 +00:00
return ;
2021-04-29 11:23:21 +00:00
QAction * ra = qobject_cast < QAction * > ( sender ( ) ) ;
guint nComment = ra - > data ( ) . toUInt ( ) ;
2019-09-29 09:39:40 +00:00
PacketCommentDialog * pc_dialog ;
2021-08-11 12:57:45 +00:00
pc_dialog = new PacketCommentDialog ( true , this , packet_list_ - > getPacketComment ( nComment ) ) ;
2022-02-10 23:11:43 +00:00
connect ( pc_dialog , & QDialog : : finished , std : : bind ( & WiresharkMainWindow : : editPacketCommentFinished , this , pc_dialog , std : : placeholders : : _1 , nComment ) ) ;
2019-09-29 09:39:40 +00:00
pc_dialog - > setWindowModality ( Qt : : ApplicationModal ) ;
pc_dialog - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
pc_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : editPacketCommentFinished ( PacketCommentDialog * pc_dialog _U_ , int result _U_ , guint nComment )
2019-09-29 09:39:40 +00:00
{
if ( result = = QDialog : : Accepted ) {
2021-04-29 11:23:21 +00:00
packet_list_ - > setPacketComment ( nComment , pc_dialog - > text ( ) ) ;
2012-12-23 04:37:58 +00:00
updateForUnsavedChanges ( ) ;
}
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : actionDeletePacketComment ( )
2021-04-29 11:23:21 +00:00
{
QAction * ra = qobject_cast < QAction * > ( sender ( ) ) ;
guint nComment = ra - > data ( ) . toUInt ( ) ;
packet_list_ - > setPacketComment ( nComment , QString ( " " ) ) ;
updateForUnsavedChanges ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : actionDeleteCommentsFromPackets ( )
2021-08-11 12:57:45 +00:00
{
packet_list_ - > deleteCommentsFromPackets ( ) ;
updateForUnsavedChanges ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionDeleteAllPacketComments_triggered ( )
2017-11-23 19:22:45 +00:00
{
2019-09-29 09:39:40 +00:00
QMessageBox * msg_dialog = new QMessageBox ( ) ;
connect ( msg_dialog , SIGNAL ( finished ( int ) ) , this , SLOT ( deleteAllPacketCommentsFinished ( int ) ) ) ;
2017-11-23 19:22:45 +00:00
2019-09-29 09:39:40 +00:00
msg_dialog - > setIcon ( QMessageBox : : Question ) ;
msg_dialog - > setText ( tr ( " Are you sure you want to remove all packet comments? " ) ) ;
2017-11-23 19:22:45 +00:00
2019-09-29 09:39:40 +00:00
msg_dialog - > setStandardButtons ( QMessageBox : : Ok | QMessageBox : : Cancel ) ;
msg_dialog - > setDefaultButton ( QMessageBox : : Ok ) ;
2017-11-23 19:22:45 +00:00
2019-09-29 09:39:40 +00:00
msg_dialog - > setWindowModality ( Qt : : ApplicationModal ) ;
msg_dialog - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
msg_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : deleteAllPacketCommentsFinished ( int result )
2019-09-29 09:39:40 +00:00
{
if ( result = = QMessageBox : : Ok ) {
2017-11-23 19:22:45 +00:00
/* XXX Do we need a wait/hourglass for large files? */
packet_list_ - > deleteAllPacketComments ( ) ;
updateForUnsavedChanges ( ) ;
}
}
2022-09-18 23:38:01 +00:00
void WiresharkMainWindow : : editConfigurationProfiles ( )
2012-12-29 01:39:02 +00:00
{
2019-09-29 09:39:40 +00:00
ProfileDialog * cp_dialog = new ProfileDialog ( ) ;
cp_dialog - > setWindowModality ( Qt : : ApplicationModal ) ;
cp_dialog - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
cp_dialog - > show ( ) ;
2012-12-29 01:39:02 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : showPreferencesDialog ( QString module_name )
2013-01-05 02:30:58 +00:00
{
2019-09-29 09:39:40 +00:00
PreferencesDialog * pref_dialog = new PreferencesDialog ( this ) ;
2022-02-01 03:30:09 +00:00
connect ( pref_dialog , SIGNAL ( destroyed ( QObject * ) ) , mainApp , SLOT ( flushAppSignals ( ) ) ) ;
2017-02-16 14:08:06 +00:00
saveWindowGeometry ( ) ; // Save in case the layout panes are rearranged
2019-12-03 18:28:25 +00:00
pref_dialog - > setPane ( module_name ) ;
2019-09-29 09:39:40 +00:00
pref_dialog - > setWindowModality ( Qt : : ApplicationModal ) ;
pref_dialog - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
pref_dialog - > show ( ) ;
2013-01-05 02:30:58 +00:00
}
2012-10-02 18:47:05 +00:00
// View Menu
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : showHideMainWidgets ( QAction * action )
2014-10-22 17:05:35 +00:00
{
if ( ! action ) {
return ;
}
bool show = action - > isChecked ( ) ;
QWidget * widget = action - > data ( ) . value < QWidget * > ( ) ;
2015-06-17 03:51:44 +00:00
// We may have come from the toolbar context menu, so check/uncheck each
// action as well.
2014-10-22 17:05:35 +00:00
if ( widget = = main_ui_ - > mainToolBar ) {
recent . main_toolbar_show = show ;
2015-06-17 03:51:44 +00:00
main_ui_ - > actionViewMainToolbar - > setChecked ( show ) ;
2014-10-22 17:05:35 +00:00
} else if ( widget = = main_ui_ - > displayFilterToolBar ) {
recent . filter_toolbar_show = show ;
2015-06-17 03:51:44 +00:00
main_ui_ - > actionViewFilterToolbar - > setChecked ( show ) ;
2018-11-01 09:54:23 +00:00
# if defined(HAVE_LIBNL) && defined(HAVE_NL80211)
2019-04-23 01:19:40 +00:00
} else if ( widget = = main_ui_ - > wirelessToolBar ) {
2015-06-16 19:21:46 +00:00
recent . wireless_toolbar_show = show ;
2015-06-17 03:51:44 +00:00
main_ui_ - > actionViewWirelessToolbar - > setChecked ( show ) ;
2018-11-01 09:54:23 +00:00
# endif
2014-10-22 17:05:35 +00:00
} else if ( widget = = main_ui_ - > statusBar ) {
recent . statusbar_show = show ;
2015-06-17 03:51:44 +00:00
main_ui_ - > actionViewStatusBar - > setChecked ( show ) ;
2014-10-22 17:05:35 +00:00
} else if ( widget = = packet_list_ ) {
recent . packet_list_show = show ;
2015-06-17 03:51:44 +00:00
main_ui_ - > actionViewPacketList - > setChecked ( show ) ;
2014-10-22 17:05:35 +00:00
} else if ( widget = = proto_tree_ ) {
recent . tree_view_show = show ;
2015-06-17 03:51:44 +00:00
main_ui_ - > actionViewPacketDetails - > setChecked ( show ) ;
2014-10-22 17:05:35 +00:00
} else if ( widget = = byte_view_tab_ ) {
recent . byte_view_show = show ;
2015-06-17 03:51:44 +00:00
main_ui_ - > actionViewPacketBytes - > setChecked ( show ) ;
2020-05-05 18:58:52 +00:00
} else if ( widget = = packet_diagram_ ) {
recent . packet_diagram_show = show ;
main_ui_ - > actionViewPacketDiagram - > setChecked ( show ) ;
2017-01-24 16:34:07 +00:00
} else {
2019-04-23 01:19:40 +00:00
foreach ( QAction * action , main_ui_ - > menuInterfaceToolbars - > actions ( ) ) {
2017-04-15 21:30:30 +00:00
QToolBar * toolbar = action - > data ( ) . value < QToolBar * > ( ) ;
if ( widget = = toolbar ) {
2019-04-23 01:19:40 +00:00
GList * entry = g_list_find_custom ( recent . interface_toolbars , action - > text ( ) . toUtf8 ( ) , ( GCompareFunc ) strcmp ) ;
2017-04-15 21:30:30 +00:00
if ( show & & ! entry ) {
recent . interface_toolbars = g_list_append ( recent . interface_toolbars , g_strdup ( action - > text ( ) . toUtf8 ( ) ) ) ;
} else if ( ! show & & entry ) {
recent . interface_toolbars = g_list_remove ( recent . interface_toolbars , entry - > data ) ;
}
action - > setChecked ( show ) ;
}
}
2017-01-24 16:34:07 +00:00
ext_toolbar_t * toolbar = VariantPointer < ext_toolbar_t > : : asPtr ( action - > data ( ) ) ;
if ( toolbar ) {
2019-04-23 01:19:40 +00:00
GList * entry = g_list_find_custom ( recent . gui_additional_toolbars , toolbar - > name , ( GCompareFunc ) strcmp ) ;
2017-01-24 16:34:07 +00:00
if ( show & & ! entry ) {
recent . gui_additional_toolbars = g_list_append ( recent . gui_additional_toolbars , g_strdup ( toolbar - > name ) ) ;
} else if ( ! show & & entry ) {
recent . gui_additional_toolbars = g_list_remove ( recent . gui_additional_toolbars , entry - > data ) ;
}
action - > setChecked ( show ) ;
QList < QToolBar * > toolbars = findChildren < QToolBar * > ( ) ;
2019-04-23 01:19:40 +00:00
foreach ( QToolBar * bar , toolbars ) {
2017-02-24 08:49:11 +00:00
AdditionalToolBar * iftoolbar = dynamic_cast < AdditionalToolBar * > ( bar ) ;
if ( iftoolbar & & iftoolbar - > menuName ( ) . compare ( toolbar - > name ) = = 0 ) {
2017-01-24 16:34:07 +00:00
iftoolbar - > setVisible ( show ) ;
}
}
}
2014-10-22 17:05:35 +00:00
}
if ( widget ) {
widget - > setVisible ( show ) ;
}
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : setTimestampFormat ( QAction * action )
2014-10-21 20:36:10 +00:00
{
if ( ! action ) {
return ;
}
ts_type tsf = action - > data ( ) . value < ts_type > ( ) ;
if ( recent . gui_time_format ! = tsf ) {
timestamp_set_type ( tsf ) ;
recent . gui_time_format = tsf ;
2016-02-04 14:05:39 +00:00
if ( packet_list_ ) {
packet_list_ - > resetColumns ( ) ;
2022-06-28 12:23:05 +00:00
packet_list_ - > resizeAllColumns ( true ) ;
2014-10-21 20:36:10 +00:00
}
}
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : setTimestampPrecision ( QAction * action )
2014-10-21 20:36:10 +00:00
{
if ( ! action ) {
return ;
}
ts_precision tsp = action - > data ( ) . value < ts_precision > ( ) ;
if ( recent . gui_time_precision ! = tsp ) {
timestamp_set_precision ( tsp ) ;
recent . gui_time_precision = tsp ;
2016-02-04 14:05:39 +00:00
if ( packet_list_ ) {
packet_list_ - > resetColumns ( ) ;
2022-06-28 12:23:05 +00:00
packet_list_ - > resizeAllColumns ( true ) ;
2014-10-21 20:36:10 +00:00
}
}
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewTimeDisplaySecondsWithHoursAndMinutes_triggered ( bool checked )
2014-10-21 20:36:10 +00:00
{
if ( checked ) {
recent . gui_seconds_format = TS_SECONDS_HOUR_MIN_SEC ;
} else {
recent . gui_seconds_format = TS_SECONDS_DEFAULT ;
}
timestamp_set_seconds_type ( recent . gui_seconds_format ) ;
2016-02-04 14:05:39 +00:00
if ( packet_list_ ) {
packet_list_ - > resetColumns ( ) ;
2022-06-28 12:23:05 +00:00
packet_list_ - > resizeAllColumns ( true ) ;
2014-10-21 20:36:10 +00:00
}
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewEditResolvedName_triggered ( )
2015-07-21 16:51:12 +00:00
{
2019-04-23 01:19:40 +00:00
//int column = packet_list_->selectedColumn();
2015-07-21 16:51:12 +00:00
int column = - 1 ;
if ( packet_list_ - > currentIndex ( ) . isValid ( ) ) {
column = packet_list_ - > currentIndex ( ) . column ( ) ;
}
main_ui_ - > addressEditorFrame - > editAddresses ( capture_file_ , column ) ;
showAccordionFrame ( main_ui_ - > addressEditorFrame ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : setNameResolution ( )
2014-12-12 20:35:31 +00:00
{
gbl_resolv_flags . mac_name = main_ui_ - > actionViewNameResolutionPhysical - > isChecked ( ) ? TRUE : FALSE ;
gbl_resolv_flags . network_name = main_ui_ - > actionViewNameResolutionNetwork - > isChecked ( ) ? TRUE : FALSE ;
gbl_resolv_flags . transport_name = main_ui_ - > actionViewNameResolutionTransport - > isChecked ( ) ? TRUE : FALSE ;
if ( packet_list_ ) {
2015-12-12 22:28:26 +00:00
packet_list_ - > resetColumns ( ) ;
2014-12-12 20:35:31 +00:00
}
2022-02-01 03:30:09 +00:00
mainApp - > emitAppSignal ( WiresharkApplication : : NameResolutionChanged ) ;
2014-12-12 20:35:31 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewNameResolutionPhysical_triggered ( )
2014-12-12 20:35:31 +00:00
{
setNameResolution ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewNameResolutionNetwork_triggered ( )
2014-12-12 20:35:31 +00:00
{
setNameResolution ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewNameResolutionTransport_triggered ( )
2014-12-12 20:35:31 +00:00
{
setNameResolution ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : zoomText ( )
2014-09-23 20:35:10 +00:00
{
2022-02-01 03:30:09 +00:00
mainApp - > zoomTextFont ( recent . gui_zoom_level ) ;
2014-09-23 20:35:10 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewZoomIn_triggered ( )
2014-09-23 20:35:10 +00:00
{
recent . gui_zoom_level + + ;
zoomText ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewZoomOut_triggered ( )
2014-09-23 20:35:10 +00:00
{
recent . gui_zoom_level - - ;
zoomText ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewNormalSize_triggered ( )
2014-09-23 20:35:10 +00:00
{
recent . gui_zoom_level = 0 ;
zoomText ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewColorizePacketList_triggered ( bool checked ) {
2014-09-22 23:33:05 +00:00
recent . packet_list_colorize = checked ;
2022-06-28 12:06:49 +00:00
packet_list_ - > recolorPackets ( ) ;
2014-09-22 23:33:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewColoringRules_triggered ( )
2015-02-05 00:36:19 +00:00
{
2019-09-29 09:39:40 +00:00
ColoringRulesDialog * coloring_rules_dialog = new ColoringRulesDialog ( this ) ;
connect ( coloring_rules_dialog , SIGNAL ( accepted ( ) ) ,
2015-11-12 19:50:01 +00:00
packet_list_ , SLOT ( recolorPackets ( ) ) ) ;
2019-09-29 09:39:40 +00:00
connect ( coloring_rules_dialog , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ,
2019-04-23 01:19:40 +00:00
this , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ) ;
2019-09-29 09:39:40 +00:00
coloring_rules_dialog - > setWindowModality ( Qt : : ApplicationModal ) ;
coloring_rules_dialog - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
coloring_rules_dialog - > show ( ) ;
2015-02-05 00:36:19 +00:00
}
2015-07-10 23:15:55 +00:00
// actionViewColorizeConversation1 - 10
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : colorizeConversation ( bool create_rule )
2015-07-10 23:15:55 +00:00
{
2016-03-18 17:34:41 +00:00
QAction * colorize_action = qobject_cast < QAction * > ( sender ( ) ) ;
if ( ! colorize_action ) return ;
2015-07-10 23:15:55 +00:00
2019-11-12 15:39:19 +00:00
if ( capture_file_ . capFile ( ) & & selectedRows ( ) . count ( ) > 0 ) {
2016-03-18 17:34:41 +00:00
packet_info * pi = capture_file_ . packetInfo ( ) ;
guint8 cc_num = colorize_action - > data ( ) . toUInt ( ) ;
2017-06-20 18:08:39 +00:00
gchar * filter = conversation_filter_from_packet ( pi ) ;
2016-01-23 12:18:30 +00:00
if ( filter = = NULL ) {
2022-02-01 03:30:09 +00:00
mainApp - > pushStatus ( WiresharkApplication : : TemporaryStatus , tr ( " Unable to build conversation filter. " ) ) ;
2015-07-10 23:15:55 +00:00
return ;
}
if ( create_rule ) {
ColoringRulesDialog coloring_rules_dialog ( this , filter ) ;
2015-11-12 19:50:01 +00:00
connect ( & coloring_rules_dialog , SIGNAL ( accepted ( ) ) ,
packet_list_ , SLOT ( recolorPackets ( ) ) ) ;
2019-04-23 01:19:40 +00:00
connect ( & coloring_rules_dialog , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ,
this , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ) ;
2015-07-10 23:15:55 +00:00
coloring_rules_dialog . exec ( ) ;
} else {
2015-12-22 20:07:00 +00:00
gchar * err_msg = NULL ;
if ( ! color_filters_set_tmp ( cc_num , filter , FALSE , & err_msg ) ) {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , err_msg ) ;
g_free ( err_msg ) ;
}
2015-07-10 23:15:55 +00:00
packet_list_ - > recolorPackets ( ) ;
}
}
2015-07-12 19:56:05 +00:00
setMenusForSelectedPacket ( ) ;
2015-07-10 23:15:55 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : colorizeActionTriggered ( )
2015-07-29 19:09:28 +00:00
{
2016-03-18 17:34:41 +00:00
QByteArray filter ;
int color_number = - 1 ;
2015-07-29 19:09:28 +00:00
2016-03-18 17:34:41 +00:00
ConversationAction * conv_action = qobject_cast < ConversationAction * > ( sender ( ) ) ;
if ( conv_action ) {
filter = conv_action - > filter ( ) ;
color_number = conv_action - > colorNumber ( ) ;
} else {
ColorizeAction * colorize_action = qobject_cast < ColorizeAction * > ( sender ( ) ) ;
if ( colorize_action ) {
filter = colorize_action - > filter ( ) ;
color_number = colorize_action - > colorNumber ( ) ;
}
}
2015-07-29 19:09:28 +00:00
2016-06-24 22:17:25 +00:00
colorizeWithFilter ( filter , color_number ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : colorizeWithFilter ( QByteArray filter , int color_number )
2016-06-24 22:17:25 +00:00
{
2016-03-18 17:34:41 +00:00
if ( filter . isEmpty ( ) ) return ;
2015-07-29 19:09:28 +00:00
2016-03-18 17:34:41 +00:00
if ( color_number > 0 ) {
2015-07-29 19:09:28 +00:00
// Assume "Color X"
2015-12-22 20:07:00 +00:00
gchar * err_msg = NULL ;
2016-03-18 17:34:41 +00:00
if ( ! color_filters_set_tmp ( color_number , filter . constData ( ) , FALSE , & err_msg ) ) {
2015-12-22 20:07:00 +00:00
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , err_msg ) ;
g_free ( err_msg ) ;
}
2015-07-29 19:09:28 +00:00
packet_list_ - > recolorPackets ( ) ;
} else {
// New coloring rule
ColoringRulesDialog coloring_rules_dialog ( window ( ) , filter ) ;
2015-11-12 19:50:01 +00:00
connect ( & coloring_rules_dialog , SIGNAL ( accepted ( ) ) ,
2019-04-23 01:19:40 +00:00
packet_list_ , SLOT ( recolorPackets ( ) ) ) ;
connect ( & coloring_rules_dialog , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ,
this , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ) ;
2015-07-29 19:09:28 +00:00
coloring_rules_dialog . exec ( ) ;
}
main_ui_ - > actionViewColorizeResetColorization - > setEnabled ( tmp_color_filters_used ( ) ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewColorizeResetColorization_triggered ( )
2015-07-10 23:15:55 +00:00
{
2015-12-22 20:07:00 +00:00
gchar * err_msg = NULL ;
if ( ! color_filters_reset_tmp ( & err_msg ) ) {
simple_dialog ( ESD_TYPE_ERROR , ESD_BTN_OK , " %s " , err_msg ) ;
g_free ( err_msg ) ;
}
2015-07-10 23:15:55 +00:00
packet_list_ - > recolorPackets ( ) ;
2015-07-12 19:56:05 +00:00
setMenusForSelectedPacket ( ) ;
2015-07-10 23:15:55 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewColorizeNewColoringRule_triggered ( )
2015-07-10 23:15:55 +00:00
{
colorizeConversation ( true ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewResetLayout_triggered ( )
2017-02-18 21:40:49 +00:00
{
recent . gui_geometry_main_upper_pane = 0 ;
recent . gui_geometry_main_lower_pane = 0 ;
applyRecentPaneGeometry ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewResizeColumns_triggered ( )
2014-09-23 20:35:10 +00:00
{
2019-11-17 19:02:20 +00:00
if ( ! packet_list_ - > model ( ) )
2019-09-22 12:56:46 +00:00
return ;
2019-07-03 21:01:34 +00:00
for ( int col = 0 ; col < packet_list_ - > model ( ) - > columnCount ( ) ; col + + ) {
2014-09-23 20:35:10 +00:00
packet_list_ - > resizeColumnToContents ( col ) ;
2015-05-13 22:46:51 +00:00
recent_set_column_width ( col , packet_list_ - > columnWidth ( col ) ) ;
2014-09-23 20:35:10 +00:00
}
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : openPacketDialog ( bool from_reference )
2015-02-11 23:00:27 +00:00
{
2019-11-12 15:39:19 +00:00
frame_data * fdata = Q_NULLPTR ;
2015-02-11 23:00:27 +00:00
2015-03-02 04:01:17 +00:00
/* Find the frame for which we're popping up a dialog */
2019-04-23 01:19:40 +00:00
if ( from_reference ) {
2015-03-02 04:01:17 +00:00
guint32 framenum = fvalue_get_uinteger ( & ( capture_file_ . capFile ( ) - > finfo_selected - > value ) ) ;
if ( framenum = = 0 )
return ;
2017-12-08 03:31:43 +00:00
fdata = frame_data_sequence_find ( capture_file_ . capFile ( ) - > provider . frames , framenum ) ;
2019-11-17 19:02:20 +00:00
} else if ( selectedRows ( ) . count ( ) = = 1 ) {
2019-11-12 15:39:19 +00:00
fdata = frameDataForRow ( selectedRows ( ) . at ( 0 ) ) ;
2019-11-17 19:02:20 +00:00
} else if ( selectedRows ( ) . count ( ) > 1 )
2019-11-12 15:39:19 +00:00
return ;
2015-03-02 04:01:17 +00:00
/* If we have a frame, pop up the dialog */
if ( fdata ) {
PacketDialog * packet_dialog = new PacketDialog ( * this , capture_file_ , fdata ) ;
2019-07-28 19:24:24 +00:00
connect ( packet_dialog , SIGNAL ( showProtocolPreferences ( QString ) ) ,
this , SLOT ( showPreferencesDialog ( QString ) ) ) ;
connect ( packet_dialog , SIGNAL ( editProtocolPreference ( preference * , pref_module * ) ) ,
main_ui_ - > preferenceEditorFrame , SLOT ( editPreference ( preference * , pref_module * ) ) ) ;
2015-08-24 20:19:01 +00:00
connect ( this , SIGNAL ( closePacketDialogs ( ) ) ,
packet_dialog , SLOT ( close ( ) ) ) ;
2022-02-01 03:30:09 +00:00
zoomText ( ) ; // Emits mainApp->zoomMonospaceFont(QFont)
2015-03-02 04:01:17 +00:00
packet_dialog - > show ( ) ;
}
2015-02-11 23:00:27 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewInternalsConversationHashTables_triggered ( )
2015-09-30 23:54:40 +00:00
{
ConversationHashTablesDialog * conversation_hash_tables_dlg = new ConversationHashTablesDialog ( this ) ;
conversation_hash_tables_dlg - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewInternalsDissectorTables_triggered ( )
2015-09-25 21:33:54 +00:00
{
DissectorTablesDialog * dissector_tables_dlg = new DissectorTablesDialog ( this ) ;
dissector_tables_dlg - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewInternalsSupportedProtocols_triggered ( )
2015-10-01 17:18:56 +00:00
{
SupportedProtocolsDialog * supported_protocols_dlg = new SupportedProtocolsDialog ( this ) ;
supported_protocols_dlg - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewShowPacketInNewWindow_triggered ( )
2015-02-11 23:00:27 +00:00
{
openPacketDialog ( ) ;
}
// This is only used in ProtoTree. Defining it here makes more sense.
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionContextShowLinkedPacketInNewWindow_triggered ( )
2015-02-11 23:00:27 +00:00
{
openPacketDialog ( true ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewReload_triggered ( )
2014-02-16 18:12:10 +00:00
{
2016-01-25 21:11:55 +00:00
capture_file * cf = CaptureFile : : globalCapFile ( ) ;
if ( cf - > unsaved_changes ) {
QString before_what ( tr ( " before reloading the file " ) ) ;
if ( ! testCaptureFileClose ( before_what , Reload ) )
return ;
}
cf_reload ( cf ) ;
2014-02-16 18:12:10 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewReload_as_File_Format_or_Capture_triggered ( )
2015-06-29 11:05:32 +00:00
{
capture_file * cf = CaptureFile : : globalCapFile ( ) ;
2016-01-25 21:11:55 +00:00
if ( cf - > unsaved_changes ) {
QString before_what ( tr ( " before reloading the file " ) ) ;
if ( ! testCaptureFileClose ( before_what , Reload ) )
return ;
}
2015-06-29 11:05:32 +00:00
if ( cf - > open_type = = WTAP_TYPE_AUTO )
cf - > open_type = open_info_name_to_type ( " MIME Files Format " ) ;
else /* TODO: This should be latest format chosen by user */
cf - > open_type = WTAP_TYPE_AUTO ;
cf_reload ( cf ) ;
}
2012-10-02 18:47:05 +00:00
// Expand / collapse slots in proto_tree
// Go Menu
2012-12-07 01:46:20 +00:00
// Analyze Menu
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : filterMenuAboutToShow ( )
2019-08-27 15:14:31 +00:00
{
QMenu * menu = qobject_cast < QMenu * > ( sender ( ) ) ;
QString field_filter ;
if ( capture_file_ . capFile ( ) & & capture_file_ . capFile ( ) - > finfo_selected ) {
char * tmp_field = proto_construct_match_selected_string ( capture_file_ . capFile ( ) - > finfo_selected ,
capture_file_ . capFile ( ) - > edt ) ;
field_filter = QString ( tmp_field ) ;
wmem_free ( NULL , tmp_field ) ;
}
bool enable = ! field_filter . isEmpty ( ) ;
bool prepare = menu - > objectName ( ) . compare ( " menuPrepareAFilter " ) = = 0 ;
menu - > clear ( ) ;
QActionGroup * group = FilterAction : : createFilterGroup ( field_filter , prepare , enable , menu ) ;
menu - > addActions ( group - > actions ( ) ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : matchFieldFilter ( FilterAction : : Action action , FilterAction : : ActionType filter_type )
2012-12-07 01:46:20 +00:00
{
2012-12-07 20:08:00 +00:00
QString field_filter ;
2012-12-07 01:46:20 +00:00
2019-06-14 20:08:37 +00:00
if ( packet_list_ - > contextMenuActive ( ) | | packet_list_ - > hasFocus ( ) ) {
2019-06-28 10:37:47 +00:00
field_filter = packet_list_ - > getFilterFromRowAndColumn ( packet_list_ - > currentIndex ( ) ) ;
2014-09-09 20:42:58 +00:00
} else if ( capture_file_ . capFile ( ) & & capture_file_ . capFile ( ) - > finfo_selected ) {
2015-07-27 22:28:50 +00:00
char * tmp_field = proto_construct_match_selected_string ( capture_file_ . capFile ( ) - > finfo_selected ,
2019-04-23 01:19:40 +00:00
capture_file_ . capFile ( ) - > edt ) ;
2015-01-17 02:47:48 +00:00
field_filter = QString ( tmp_field ) ;
wmem_free ( NULL , tmp_field ) ;
2012-12-07 20:08:00 +00:00
}
if ( field_filter . isEmpty ( ) ) {
2020-07-17 11:45:01 +00:00
QString err = tr ( " No filter available. Try another %1. " ) . arg ( packet_list_ - > contextMenuActive ( ) ? tr ( " column " ) : tr ( " item " ) ) ;
2022-02-01 03:30:09 +00:00
mainApp - > pushStatus ( WiresharkApplication : : TemporaryStatus , err ) ;
2012-12-07 01:46:20 +00:00
return ;
}
2019-08-26 13:30:22 +00:00
setDisplayFilter ( field_filter , action , filter_type ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionAnalyzeDisplayFilters_triggered ( )
2015-06-03 23:26:00 +00:00
{
if ( ! display_filter_dlg_ ) {
display_filter_dlg_ = new FilterDialog ( this , FilterDialog : : DisplayFilter ) ;
}
display_filter_dlg_ - > show ( ) ;
display_filter_dlg_ - > raise ( ) ;
display_filter_dlg_ - > activateWindow ( ) ;
}
2015-08-22 00:12:39 +00:00
struct epan_uat ;
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionAnalyzeDisplayFilterMacros_triggered ( )
2015-08-22 00:12:39 +00:00
{
struct epan_uat * dfm_uat ;
dfilter_macro_get_uat ( & dfm_uat ) ;
2019-09-29 09:39:40 +00:00
UatDialog * uat_dlg = new UatDialog ( parentWidget ( ) , dfm_uat ) ;
2022-02-01 03:30:09 +00:00
connect ( uat_dlg , SIGNAL ( destroyed ( QObject * ) ) , mainApp , SLOT ( flushAppSignals ( ) ) ) ;
2015-08-22 00:12:39 +00:00
2019-09-29 09:39:40 +00:00
uat_dlg - > setWindowModality ( Qt : : ApplicationModal ) ;
uat_dlg - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
uat_dlg - > show ( ) ;
2015-08-22 00:12:39 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionAnalyzeCreateAColumn_triggered ( )
2015-03-09 07:11:13 +00:00
{
2016-01-23 12:18:30 +00:00
if ( capture_file_ . capFile ( ) ! = 0 & & capture_file_ . capFile ( ) - > finfo_selected ! = 0 ) {
2020-07-14 17:04:00 +00:00
header_field_info * hfinfo = capture_file_ . capFile ( ) - > finfo_selected - > hfinfo ;
int col = column_prefs_has_custom ( hfinfo - > abbrev ) ;
if ( col = = - 1 ) {
insertColumn ( hfinfo - > name , hfinfo - > abbrev ) ;
} else {
QString status ;
if ( QString ( hfinfo - > name ) = = get_column_title ( col ) ) {
status = tr ( " The \" %1 \" column already exists. " ) . arg ( hfinfo - > name ) ;
} else {
status = tr ( " The \" %1 \" column already exists as \" %2 \" . " ) . arg ( hfinfo - > name ) . arg ( get_column_title ( col ) ) ;
}
2022-02-01 03:30:09 +00:00
mainApp - > pushStatus ( WiresharkApplication : : TemporaryStatus , status ) ;
2020-07-14 17:04:00 +00:00
if ( ! get_column_visible ( col ) ) {
packet_list_ - > setColumnHidden ( col , false ) ;
set_column_visible ( col , TRUE ) ;
prefs_main_write ( ) ;
}
}
2015-03-09 07:11:13 +00:00
}
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : applyConversationFilter ( )
2014-08-08 10:59:42 +00:00
{
2016-03-18 17:34:41 +00:00
ConversationAction * conv_action = qobject_cast < ConversationAction * > ( sender ( ) ) ;
if ( ! conv_action ) return ;
packet_info * pinfo = capture_file_ . packetInfo ( ) ;
if ( ! pinfo ) return ;
QByteArray conv_filter = conv_action - > filter ( ) ;
if ( conv_filter . isEmpty ( ) ) return ;
2014-08-08 10:59:42 +00:00
2016-03-18 17:34:41 +00:00
if ( conv_action - > isFilterValid ( pinfo ) ) {
2014-08-08 10:59:42 +00:00
2016-03-18 17:34:41 +00:00
df_combo_box_ - > lineEdit ( ) - > setText ( conv_filter ) ;
df_combo_box_ - > applyDisplayFilter ( ) ;
}
2014-08-08 10:59:42 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : applyExportObject ( )
2016-11-24 14:37:01 +00:00
{
ExportObjectAction * export_action = qobject_cast < ExportObjectAction * > ( sender ( ) ) ;
if ( ! export_action )
return ;
2017-12-26 16:46:48 +00:00
ExportObjectDialog * export_dialog = new ExportObjectDialog ( * this , capture_file_ , export_action - > exportObject ( ) ) ;
2019-11-21 14:57:32 +00:00
export_dialog - > setWindowModality ( Qt : : ApplicationModal ) ;
export_dialog - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
export_dialog - > show ( ) ;
2016-11-24 14:37:01 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionAnalyzeEnabledProtocols_triggered ( )
2015-07-21 17:32:42 +00:00
{
2019-09-29 09:39:40 +00:00
EnabledProtocolsDialog * enable_proto_dialog = new EnabledProtocolsDialog ( this ) ;
2022-02-01 03:30:09 +00:00
connect ( enable_proto_dialog , SIGNAL ( destroyed ( QObject * ) ) , mainApp , SLOT ( flushAppSignals ( ) ) ) ;
2015-08-26 18:24:29 +00:00
2019-09-29 09:39:40 +00:00
enable_proto_dialog - > setWindowModality ( Qt : : ApplicationModal ) ;
enable_proto_dialog - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
enable_proto_dialog - > show ( ) ;
2015-07-21 17:32:42 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionAnalyzeDecodeAs_triggered ( )
2013-11-22 01:07:36 +00:00
{
2013-12-10 21:07:26 +00:00
QAction * da_action = qobject_cast < QAction * > ( sender ( ) ) ;
2020-02-04 02:07:10 +00:00
bool create_new = da_action & & da_action - > property ( " create_new " ) . toBool ( ) ;
2013-12-10 21:07:26 +00:00
2019-09-29 09:39:40 +00:00
DecodeAsDialog * da_dialog = new DecodeAsDialog ( this , capture_file_ . capFile ( ) , create_new ) ;
2022-02-01 03:30:09 +00:00
connect ( da_dialog , SIGNAL ( destroyed ( QObject * ) ) , mainApp , SLOT ( flushAppSignals ( ) ) ) ;
2015-08-26 18:24:29 +00:00
2019-09-29 09:39:40 +00:00
da_dialog - > setWindowModality ( Qt : : ApplicationModal ) ;
da_dialog - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
da_dialog - > show ( ) ;
2013-11-22 01:07:36 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionAnalyzeReloadLuaPlugins_triggered ( )
2015-08-11 12:08:08 +00:00
{
2016-01-03 12:48:39 +00:00
reloadLuaPlugins ( ) ;
2015-11-17 23:11:28 +00:00
}
2015-08-11 12:08:08 +00:00
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : openFollowStreamDialog ( follow_type_t type , guint stream_num , guint sub_stream_num , bool use_stream_index ) {
2014-12-29 22:12:43 +00:00
FollowStreamDialog * fsd = new FollowStreamDialog ( * this , capture_file_ , type ) ;
2015-09-17 19:32:28 +00:00
connect ( fsd , SIGNAL ( updateFilter ( QString , bool ) ) , this , SLOT ( filterPackets ( QString , bool ) ) ) ;
2013-11-14 17:37:40 +00:00
connect ( fsd , SIGNAL ( goToPacket ( int ) ) , packet_list_ , SLOT ( goToPacket ( int ) ) ) ;
2020-07-05 11:35:57 +00:00
fsd - > addCodecs ( text_codec_map_ ) ;
2013-11-13 22:18:01 +00:00
fsd - > show ( ) ;
2019-03-01 14:20:22 +00:00
if ( use_stream_index ) {
2018-03-17 12:54:30 +00:00
// If a specific conversation was requested, then ignore any previous
// display filters and display all related packets.
2019-02-27 04:55:52 +00:00
fsd - > follow ( " " , true , stream_num , sub_stream_num ) ;
2018-03-17 12:54:30 +00:00
} else {
fsd - > follow ( getFilter ( ) ) ;
}
2013-11-13 22:18:01 +00:00
}
2013-09-09 19:30:30 +00:00
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : openFollowStreamDialogForType ( follow_type_t type ) {
2019-02-27 04:55:52 +00:00
openFollowStreamDialog ( type , 0 , 0 , false ) ;
2019-03-01 14:20:22 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : openSCTPAllAssocsDialog ( )
2013-12-13 07:25:30 +00:00
{
2014-09-09 20:42:58 +00:00
SCTPAllAssocsDialog * sctp_dialog = new SCTPAllAssocsDialog ( this , capture_file_ . capFile ( ) ) ;
2019-04-23 01:19:40 +00:00
connect ( sctp_dialog , SIGNAL ( filterPackets ( QString , bool ) ) ,
this , SLOT ( filterPackets ( QString , bool ) ) ) ;
2013-12-13 07:25:30 +00:00
connect ( this , SIGNAL ( setCaptureFile ( capture_file * ) ) ,
sctp_dialog , SLOT ( setCaptureFile ( capture_file * ) ) ) ;
sctp_dialog - > fillTable ( ) ;
if ( sctp_dialog - > isMinimized ( ) = = true )
{
sctp_dialog - > showNormal ( ) ;
}
else
{
sctp_dialog - > show ( ) ;
}
sctp_dialog - > raise ( ) ;
sctp_dialog - > activateWindow ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionSCTPShowAllAssociations_triggered ( )
2013-12-13 07:25:30 +00:00
{
openSCTPAllAssocsDialog ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionSCTPAnalyseThisAssociation_triggered ( )
2013-12-13 07:25:30 +00:00
{
2018-08-15 19:46:39 +00:00
const sctp_assoc_info_t * assoc = SCTPAssocAnalyseDialog : : findAssocForPacket ( capture_file_ . capFile ( ) ) ;
if ( ! assoc ) {
return ;
}
SCTPAssocAnalyseDialog * sctp_analyse = new SCTPAssocAnalyseDialog ( this , assoc , capture_file_ . capFile ( ) ) ;
2019-04-23 01:19:40 +00:00
connect ( sctp_analyse , SIGNAL ( filterPackets ( QString , bool ) ) ,
this , SLOT ( filterPackets ( QString , bool ) ) ) ;
2013-12-13 07:25:30 +00:00
if ( sctp_analyse - > isMinimized ( ) = = true )
{
sctp_analyse - > showNormal ( ) ;
}
else
{
sctp_analyse - > show ( ) ;
}
sctp_analyse - > raise ( ) ;
sctp_analyse - > activateWindow ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionSCTPFilterThisAssociation_triggered ( )
2013-12-18 13:49:10 +00:00
{
2018-08-15 19:46:39 +00:00
const sctp_assoc_info_t * assoc = SCTPAssocAnalyseDialog : : findAssocForPacket ( capture_file_ . capFile ( ) ) ;
2013-12-18 13:49:10 +00:00
if ( assoc ) {
QString newFilter = QString ( " sctp.assoc_index==%1 " ) . arg ( assoc - > assoc_id ) ;
assoc = NULL ;
emit filterPackets ( newFilter , false ) ;
}
}
2015-08-21 16:45:48 +00:00
// -z wlan,stat
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : statCommandWlanStatistics ( const char * arg , void * )
2015-08-18 18:46:12 +00:00
{
WlanStatisticsDialog * wlan_stats_dlg = new WlanStatisticsDialog ( * this , capture_file_ , arg ) ;
2019-04-23 01:19:40 +00:00
connect ( wlan_stats_dlg , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ,
this , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ) ;
2015-08-18 18:46:12 +00:00
wlan_stats_dlg - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionWirelessWlanStatistics_triggered ( )
2015-08-18 18:46:12 +00:00
{
statCommandWlanStatistics ( NULL , NULL ) ;
}
2015-08-21 16:45:48 +00:00
// -z expert
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : statCommandExpertInfo ( const char * , void * )
2015-03-11 22:22:20 +00:00
{
const DisplayFilterEdit * df_edit = dynamic_cast < DisplayFilterEdit * > ( df_combo_box_ - > lineEdit ( ) ) ;
2022-06-12 15:28:57 +00:00
ExpertInfoDialog * expert_dialog = new ExpertInfoDialog ( * this , capture_file_ , df_edit - > text ( ) ) ;
2015-03-11 22:22:20 +00:00
2017-06-29 00:00:38 +00:00
connect ( expert_dialog - > getExpertInfoView ( ) , SIGNAL ( goToPacket ( int , int ) ) ,
2015-03-11 22:22:20 +00:00
packet_list_ , SLOT ( goToPacket ( int , int ) ) ) ;
2019-04-23 01:19:40 +00:00
connect ( expert_dialog , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ,
this , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ) ;
2015-03-11 22:22:20 +00:00
expert_dialog - > show ( ) ;
}
2022-09-22 22:15:48 +00:00
void WiresharkMainWindow : : on_actionAnalyzeShowPacketBytes_triggered ( )
{
ShowPacketBytesDialog * spbd = new ShowPacketBytesDialog ( * this , capture_file_ ) ;
spbd - > addCodecs ( text_codec_map_ ) ;
spbd - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionAnalyzeExpertInfo_triggered ( )
2015-03-11 22:22:20 +00:00
{
statCommandExpertInfo ( NULL , NULL ) ;
}
2013-12-18 13:49:10 +00:00
2012-10-02 18:47:05 +00:00
// Next / previous / first / last slots in packet_list
2013-08-27 18:13:20 +00:00
// Statistics Menu
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsFlowGraph_triggered ( )
2013-10-24 22:52:30 +00:00
{
2014-12-29 19:42:01 +00:00
SequenceDialog * sequence_dialog = new SequenceDialog ( * this , capture_file_ ) ;
2013-10-24 22:52:30 +00:00
sequence_dialog - > show ( ) ;
}
2013-09-04 23:15:59 +00:00
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : openTcpStreamDialog ( int graph_type )
2013-08-27 18:13:20 +00:00
{
2014-09-09 20:42:58 +00:00
TCPStreamDialog * stream_dialog = new TCPStreamDialog ( this , capture_file_ . capFile ( ) , ( tcp_graph_type ) graph_type ) ;
2013-09-06 00:41:07 +00:00
connect ( stream_dialog , SIGNAL ( goToPacket ( int ) ) ,
2013-08-30 21:15:24 +00:00
packet_list_ , SLOT ( goToPacket ( int ) ) ) ;
2013-09-04 23:15:59 +00:00
connect ( this , SIGNAL ( setCaptureFile ( capture_file * ) ) ,
2013-09-06 00:41:07 +00:00
stream_dialog , SLOT ( setCaptureFile ( capture_file * ) ) ) ;
2016-01-20 14:15:23 +00:00
if ( stream_dialog - > result ( ) = = QDialog : : Accepted ) {
stream_dialog - > show ( ) ;
}
2013-08-27 18:13:20 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsTcpStreamStevens_triggered ( )
2013-09-04 23:15:59 +00:00
{
openTcpStreamDialog ( GRAPH_TSEQ_STEVENS ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsTcpStreamTcptrace_triggered ( )
2013-09-13 22:29:05 +00:00
{
openTcpStreamDialog ( GRAPH_TSEQ_TCPTRACE ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsTcpStreamThroughput_triggered ( )
2013-09-04 23:15:59 +00:00
{
openTcpStreamDialog ( GRAPH_THROUGHPUT ) ;
}
2013-08-27 18:13:20 +00:00
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsTcpStreamRoundTripTime_triggered ( )
2013-09-08 01:25:27 +00:00
{
openTcpStreamDialog ( GRAPH_RTT ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsTcpStreamWindowScaling_triggered ( )
2013-09-09 01:40:06 +00:00
{
openTcpStreamDialog ( GRAPH_WSCALE ) ;
}
2015-08-21 16:45:48 +00:00
// -z mcast,stat
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : statCommandMulticastStatistics ( const char * arg , void * )
2015-08-12 21:09:35 +00:00
{
MulticastStatisticsDialog * mcast_stats_dlg = new MulticastStatisticsDialog ( * this , capture_file_ , arg ) ;
2019-04-23 01:19:40 +00:00
connect ( mcast_stats_dlg , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ,
this , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ) ;
2015-08-12 21:09:35 +00:00
mcast_stats_dlg - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsUdpMulticastStreams_triggered ( )
2015-08-12 21:09:35 +00:00
{
statCommandMulticastStatistics ( NULL , NULL ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : openStatisticsTreeDialog ( const gchar * abbr )
2013-11-21 01:28:17 +00:00
{
2014-12-29 19:42:01 +00:00
StatsTreeDialog * st_dialog = new StatsTreeDialog ( * this , capture_file_ , abbr ) ;
2013-11-21 01:28:17 +00:00
// connect(st_dialog, SIGNAL(goToPacket(int)),
// packet_list_, SLOT(goToPacket(int)));
st_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatistics29WestTopics_Advertisements_by_Topic_triggered ( )
2014-04-08 22:13:45 +00:00
{
openStatisticsTreeDialog ( " lbmr_topic_ads_topic " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatistics29WestTopics_Advertisements_by_Source_triggered ( )
2014-04-08 22:13:45 +00:00
{
openStatisticsTreeDialog ( " lbmr_topic_ads_source " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatistics29WestTopics_Advertisements_by_Transport_triggered ( )
2014-04-08 22:13:45 +00:00
{
openStatisticsTreeDialog ( " lbmr_topic_ads_transport " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatistics29WestTopics_Queries_by_Topic_triggered ( )
2014-04-08 22:13:45 +00:00
{
openStatisticsTreeDialog ( " lbmr_topic_queries_topic " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatistics29WestTopics_Queries_by_Receiver_triggered ( )
2014-04-08 22:13:45 +00:00
{
openStatisticsTreeDialog ( " lbmr_topic_queries_receiver " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatistics29WestTopics_Wildcard_Queries_by_Pattern_triggered ( )
2014-04-08 22:13:45 +00:00
{
openStatisticsTreeDialog ( " lbmr_topic_queries_pattern " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatistics29WestTopics_Wildcard_Queries_by_Receiver_triggered ( )
2014-04-08 22:13:45 +00:00
{
openStatisticsTreeDialog ( " lbmr_topic_queries_pattern_receiver " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatistics29WestQueues_Advertisements_by_Queue_triggered ( )
2014-04-08 22:13:45 +00:00
{
openStatisticsTreeDialog ( " lbmr_queue_ads_queue " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatistics29WestQueues_Advertisements_by_Source_triggered ( )
2014-04-08 22:13:45 +00:00
{
openStatisticsTreeDialog ( " lbmr_queue_ads_source " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatistics29WestQueues_Queries_by_Queue_triggered ( )
2014-04-08 22:13:45 +00:00
{
openStatisticsTreeDialog ( " lbmr_queue_queries_queue " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatistics29WestQueues_Queries_by_Receiver_triggered ( )
2014-04-08 22:13:45 +00:00
{
openStatisticsTreeDialog ( " lbmr_queue_queries_receiver " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatistics29WestUIM_Streams_triggered ( )
2014-04-08 22:13:45 +00:00
{
2014-09-09 20:42:58 +00:00
LBMStreamDialog * stream_dialog = new LBMStreamDialog ( this , capture_file_ . capFile ( ) ) ;
2014-04-08 22:13:45 +00:00
// connect(stream_dialog, SIGNAL(goToPacket(int)),
// packet_list_, SLOT(goToPacket(int)));
connect ( this , SIGNAL ( setCaptureFile ( capture_file * ) ) ,
stream_dialog , SLOT ( setCaptureFile ( capture_file * ) ) ) ;
stream_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatistics29WestLBTRM_triggered ( )
2014-04-08 22:13:45 +00:00
{
2014-09-09 20:42:58 +00:00
LBMLBTRMTransportDialog * lbtrm_dialog = new LBMLBTRMTransportDialog ( this , capture_file_ . capFile ( ) ) ;
2014-04-08 22:13:45 +00:00
connect ( lbtrm_dialog , SIGNAL ( goToPacket ( int ) ) ,
packet_list_ , SLOT ( goToPacket ( int ) ) ) ;
connect ( this , SIGNAL ( setCaptureFile ( capture_file * ) ) ,
lbtrm_dialog , SLOT ( setCaptureFile ( capture_file * ) ) ) ;
lbtrm_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatistics29WestLBTRU_triggered ( )
2014-04-08 22:13:45 +00:00
{
2014-09-09 20:42:58 +00:00
LBMLBTRUTransportDialog * lbtru_dialog = new LBMLBTRUTransportDialog ( this , capture_file_ . capFile ( ) ) ;
2014-04-08 22:13:45 +00:00
connect ( lbtru_dialog , SIGNAL ( goToPacket ( int ) ) ,
packet_list_ , SLOT ( goToPacket ( int ) ) ) ;
connect ( this , SIGNAL ( setCaptureFile ( capture_file * ) ) ,
lbtru_dialog , SLOT ( setCaptureFile ( capture_file * ) ) ) ;
lbtru_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsANCP_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " ancp " ) ;
}
2021-07-23 08:43:05 +00:00
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsBACappInstanceId_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " bacapp_instanceid " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsBACappIP_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " bacapp_ip " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsBACappObjectId_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " bacapp_objectid " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsBACappService_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " bacapp_service " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsCollectd_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " collectd " ) ;
}
2022-06-08 15:42:58 +00:00
void WiresharkMainWindow : : on_actionStatisticsConversations_triggered ( )
2014-04-29 15:10:27 +00:00
{
2022-06-08 15:42:58 +00:00
ConversationDialog * conv_dialog = new ConversationDialog ( * this , capture_file_ ) ;
2019-04-23 01:19:40 +00:00
connect ( conv_dialog , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ,
this , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ) ;
2019-09-30 00:49:30 +00:00
connect ( conv_dialog , SIGNAL ( openFollowStreamDialog ( follow_type_t , guint , guint ) ) ,
this , SLOT ( openFollowStreamDialog ( follow_type_t , guint , guint ) ) ) ;
2014-04-29 15:10:27 +00:00
connect ( conv_dialog , SIGNAL ( openTcpStreamGraph ( int ) ) ,
2019-04-23 01:19:40 +00:00
this , SLOT ( openTcpStreamDialog ( int ) ) ) ;
2014-04-29 15:10:27 +00:00
conv_dialog - > show ( ) ;
}
2022-06-08 15:42:58 +00:00
void WiresharkMainWindow : : on_actionStatisticsEndpoints_triggered ( )
2014-08-06 17:07:42 +00:00
{
2022-06-08 15:42:58 +00:00
EndpointDialog * endp_dialog = new EndpointDialog ( * this , capture_file_ ) ;
2019-04-23 01:19:40 +00:00
connect ( endp_dialog , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ,
this , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ) ;
2014-08-06 17:07:42 +00:00
connect ( endp_dialog , SIGNAL ( openFollowStreamDialog ( follow_type_t ) ) ,
2019-03-01 14:20:22 +00:00
this , SLOT ( openFollowStreamDialogForType ( follow_type_t ) ) ) ;
2014-08-06 17:07:42 +00:00
connect ( endp_dialog , SIGNAL ( openTcpStreamGraph ( int ) ) ,
this , SLOT ( openTcpStreamDialog ( int ) ) ) ;
endp_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsHART_IP_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " hart_ip " ) ;
}
2022-09-22 22:15:48 +00:00
void WiresharkMainWindow : : on_actionStatisticsHpfeeds_triggered ( )
{
openStatisticsTreeDialog ( " hpfeeds " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsHTTPPacketCounter_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " http " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsHTTPRequests_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " http_req " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsHTTPLoadDistribution_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " http_srv " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsHTTPRequestSequences_triggered ( )
2018-01-15 01:19:06 +00:00
{
2018-03-29 02:58:29 +00:00
openStatisticsTreeDialog ( " http_seq " ) ;
2018-01-15 01:19:06 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsPacketLengths_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " plen " ) ;
}
2022-06-08 15:42:58 +00:00
void WiresharkMainWindow : : on_actionStatisticsIOGraph_triggered ( )
Add a Qt I/O Graph dialog.
For each graph you can set:
- Its visibility
- A name
- A display filter
- Color, from a fixed list
- Plot style: Line, Impulse, Bar, Stacked Bar, Dot, Square, Diamond
- Basic Y Axes (packets/s, bytes/s, bits/s)
- Computed Y Axes (SUM, MIN, AVG, MAX)
- Smoothing
You can pan and zoom using the mouse and keyboard. Clicking on a graph
selects the last packet for that interval. If all graphs have the same Y
axis a single label is shown, otherwise a legend is shown.
The time scale (X axis) can be toggled between relative seconds and the
time of day.
Graphs can be saved as PDF, PNG, BMP, and JPEG. Settings are "sticky"
via the io_graphs UAT.
To do:
- Minimize graph drawing delays.
- Figure out why smoothing differs from GTK+
- Everything else at the top of io_graph_dialog.cpp
- Fix empty resets.
A fair amount of code was copied from TCPStreamDialog. We might want to
subclass QCustomPlot and place the shared code there.
Move common syntax checking to SyntaxLineEdit.
Move some common code from ui/gtk/io_stat.c to ui/io_graph_item.[ch] and
use it in both GTK+ and Qt.
Make the io_graph_item_t array allocation in io_stat.c static. The
behavior should be identical and this gives us additional compile-time
checks.
Change-Id: I9a3d544469b7048f0761fdbf7bcf20f44ae76577
Reviewed-on: https://code.wireshark.org/review/435
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Tested-by: Gerald Combs <gerald@wireshark.org>
2014-02-12 00:07:10 +00:00
{
2019-11-05 13:36:18 +00:00
const DisplayFilterEdit * df_edit = qobject_cast < DisplayFilterEdit * > ( df_combo_box_ - > lineEdit ( ) ) ;
QString displayFilter ;
2019-11-17 19:02:20 +00:00
if ( df_edit )
2019-11-05 13:36:18 +00:00
displayFilter = df_edit - > text ( ) ;
IOGraphDialog * iog_dialog = new IOGraphDialog ( * this , capture_file_ , displayFilter ) ;
Add a Qt I/O Graph dialog.
For each graph you can set:
- Its visibility
- A name
- A display filter
- Color, from a fixed list
- Plot style: Line, Impulse, Bar, Stacked Bar, Dot, Square, Diamond
- Basic Y Axes (packets/s, bytes/s, bits/s)
- Computed Y Axes (SUM, MIN, AVG, MAX)
- Smoothing
You can pan and zoom using the mouse and keyboard. Clicking on a graph
selects the last packet for that interval. If all graphs have the same Y
axis a single label is shown, otherwise a legend is shown.
The time scale (X axis) can be toggled between relative seconds and the
time of day.
Graphs can be saved as PDF, PNG, BMP, and JPEG. Settings are "sticky"
via the io_graphs UAT.
To do:
- Minimize graph drawing delays.
- Figure out why smoothing differs from GTK+
- Everything else at the top of io_graph_dialog.cpp
- Fix empty resets.
A fair amount of code was copied from TCPStreamDialog. We might want to
subclass QCustomPlot and place the shared code there.
Move common syntax checking to SyntaxLineEdit.
Move some common code from ui/gtk/io_stat.c to ui/io_graph_item.[ch] and
use it in both GTK+ and Qt.
Make the io_graph_item_t array allocation in io_stat.c static. The
behavior should be identical and this gives us additional compile-time
checks.
Change-Id: I9a3d544469b7048f0761fdbf7bcf20f44ae76577
Reviewed-on: https://code.wireshark.org/review/435
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Tested-by: Gerald Combs <gerald@wireshark.org>
2014-02-12 00:07:10 +00:00
connect ( iog_dialog , SIGNAL ( goToPacket ( int ) ) , packet_list_ , SLOT ( goToPacket ( int ) ) ) ;
2015-08-24 20:12:17 +00:00
connect ( this , SIGNAL ( reloadFields ( ) ) , iog_dialog , SLOT ( reloadFields ( ) ) ) ;
Add a Qt I/O Graph dialog.
For each graph you can set:
- Its visibility
- A name
- A display filter
- Color, from a fixed list
- Plot style: Line, Impulse, Bar, Stacked Bar, Dot, Square, Diamond
- Basic Y Axes (packets/s, bytes/s, bits/s)
- Computed Y Axes (SUM, MIN, AVG, MAX)
- Smoothing
You can pan and zoom using the mouse and keyboard. Clicking on a graph
selects the last packet for that interval. If all graphs have the same Y
axis a single label is shown, otherwise a legend is shown.
The time scale (X axis) can be toggled between relative seconds and the
time of day.
Graphs can be saved as PDF, PNG, BMP, and JPEG. Settings are "sticky"
via the io_graphs UAT.
To do:
- Minimize graph drawing delays.
- Figure out why smoothing differs from GTK+
- Everything else at the top of io_graph_dialog.cpp
- Fix empty resets.
A fair amount of code was copied from TCPStreamDialog. We might want to
subclass QCustomPlot and place the shared code there.
Move common syntax checking to SyntaxLineEdit.
Move some common code from ui/gtk/io_stat.c to ui/io_graph_item.[ch] and
use it in both GTK+ and Qt.
Make the io_graph_item_t array allocation in io_stat.c static. The
behavior should be identical and this gives us additional compile-time
checks.
Change-Id: I9a3d544469b7048f0761fdbf7bcf20f44ae76577
Reviewed-on: https://code.wireshark.org/review/435
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Tested-by: Gerald Combs <gerald@wireshark.org>
2014-02-12 00:07:10 +00:00
iog_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsSametime_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " sametime " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsDNS_triggered ( )
2014-12-30 11:31:46 +00:00
{
openStatisticsTreeDialog ( " dns " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : actionStatisticsPlugin_triggered ( )
2015-01-06 09:22:48 +00:00
{
QAction * action = qobject_cast < QAction * > ( sender ( ) ) ;
2019-04-23 01:19:40 +00:00
if ( action ) {
2015-01-06 09:22:48 +00:00
openStatisticsTreeDialog ( action - > data ( ) . toString ( ) . toUtf8 ( ) ) ;
}
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsHTTP2_triggered ( )
2015-01-08 16:35:58 +00:00
{
openStatisticsTreeDialog ( " http2 " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsSOMEIPmessages_triggered ( )
2022-01-07 18:07:06 +00:00
{
openStatisticsTreeDialog ( " someip_messages " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsSOMEIPSDentries_triggered ( )
2022-01-07 18:07:06 +00:00
{
openStatisticsTreeDialog ( " someipsd_entries " ) ;
}
2013-11-21 01:28:17 +00:00
// Telephony Menu
2022-02-10 23:11:43 +00:00
RtpPlayerDialog * WiresharkMainWindow : : openTelephonyRtpPlayerDialog ( )
2020-12-30 08:51:00 +00:00
{
2021-05-09 14:29:11 +00:00
RtpPlayerDialog * dialog ;
2021-04-25 12:47:59 +00:00
# ifdef HAVE_LIBPCAP
2021-05-09 14:29:11 +00:00
dialog = RtpPlayerDialog : : openRtpPlayerDialog ( * this , capture_file_ , packet_list_ , captureSession ( ) - > state ! = CAPTURE_STOPPED ) ;
2021-04-25 12:47:59 +00:00
# else
2021-05-09 14:29:11 +00:00
dialog = RtpPlayerDialog : : openRtpPlayerDialog ( * this , capture_file_ , packet_list_ , false ) ;
2021-04-25 12:47:59 +00:00
# endif
2021-03-27 20:01:43 +00:00
2021-05-09 14:29:11 +00:00
dialog - > show ( ) ;
return dialog ;
2020-12-30 08:51:00 +00:00
}
2022-02-10 23:11:43 +00:00
VoipCallsDialog * WiresharkMainWindow : : openTelephonyVoipCallsDialogVoip ( )
2014-11-19 00:21:42 +00:00
{
2021-05-09 14:29:11 +00:00
VoipCallsDialog * dialog ;
2021-03-27 20:01:43 +00:00
2021-05-09 14:29:11 +00:00
dialog = VoipCallsDialog : : openVoipCallsDialogVoip ( * this , capture_file_ , packet_list_ ) ;
dialog - > show ( ) ;
return dialog ;
2014-11-19 00:21:42 +00:00
}
2022-02-10 23:11:43 +00:00
VoipCallsDialog * WiresharkMainWindow : : openTelephonyVoipCallsDialogSip ( )
2021-04-07 05:40:09 +00:00
{
2021-05-09 14:29:11 +00:00
VoipCallsDialog * dialog ;
2021-04-07 05:40:09 +00:00
2021-05-09 14:29:11 +00:00
dialog = VoipCallsDialog : : openVoipCallsDialogSip ( * this , capture_file_ , packet_list_ ) ;
dialog - > show ( ) ;
return dialog ;
}
2022-02-10 23:11:43 +00:00
RtpAnalysisDialog * WiresharkMainWindow : : openTelephonyRtpAnalysisDialog ( )
2021-05-09 14:29:11 +00:00
{
RtpAnalysisDialog * dialog ;
dialog = RtpAnalysisDialog : : openRtpAnalysisDialog ( * this , capture_file_ , packet_list_ ) ;
dialog - > show ( ) ;
return dialog ;
2021-04-07 05:40:09 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyVoipCalls_triggered ( )
2014-11-19 00:21:42 +00:00
{
2021-05-09 14:29:11 +00:00
openTelephonyVoipCallsDialogVoip ( ) ;
2014-11-19 00:21:42 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyGsmMapSummary_triggered ( )
2015-08-05 00:42:53 +00:00
{
GsmMapSummaryDialog * gms_dialog = new GsmMapSummaryDialog ( * this , capture_file_ ) ;
gms_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyIax2StreamAnalysis_triggered ( )
2015-08-31 19:24:48 +00:00
{
2015-09-03 18:18:13 +00:00
Iax2AnalysisDialog * iax2_analysis_dialog = new Iax2AnalysisDialog ( * this , capture_file_ ) ;
connect ( iax2_analysis_dialog , SIGNAL ( goToPacket ( int ) ) ,
packet_list_ , SLOT ( goToPacket ( int ) ) ) ;
iax2_analysis_dialog - > show ( ) ;
2015-08-31 19:24:48 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyISUPMessages_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " isup_msg " ) ;
}
2015-09-20 07:42:11 +00:00
// -z mac-lte,stat
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : statCommandLteMacStatistics ( const char * arg , void * )
2015-09-20 07:42:11 +00:00
{
LteMacStatisticsDialog * lte_mac_stats_dlg = new LteMacStatisticsDialog ( * this , capture_file_ , arg ) ;
2019-04-23 01:19:40 +00:00
connect ( lte_mac_stats_dlg , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ,
this , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ) ;
2015-09-20 07:42:11 +00:00
lte_mac_stats_dlg - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyLteMacStatistics_triggered ( )
2015-09-20 07:42:11 +00:00
{
statCommandLteMacStatistics ( NULL , NULL ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : statCommandLteRlcStatistics ( const char * arg , void * )
2015-09-28 10:38:29 +00:00
{
LteRlcStatisticsDialog * lte_rlc_stats_dlg = new LteRlcStatisticsDialog ( * this , capture_file_ , arg ) ;
2019-04-23 01:19:40 +00:00
connect ( lte_rlc_stats_dlg , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ,
this , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ) ;
2015-10-17 15:54:55 +00:00
// N.B. It is necessary for the RLC Statistics window to launch the RLC graph in this way, to ensure
// that the goToPacket() signal/slot connection gets set up...
connect ( lte_rlc_stats_dlg , SIGNAL ( launchRLCGraph ( bool , guint16 , guint8 , guint16 , guint16 , guint8 ) ) ,
this , SLOT ( launchRLCGraph ( bool , guint16 , guint8 , guint16 , guint16 , guint8 ) ) ) ;
2015-09-28 10:38:29 +00:00
lte_rlc_stats_dlg - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyLteRlcStatistics_triggered ( )
2015-09-28 10:38:29 +00:00
{
statCommandLteRlcStatistics ( NULL , NULL ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : launchRLCGraph ( bool channelKnown ,
2019-04-23 01:19:40 +00:00
guint16 ueid , guint8 rlcMode ,
guint16 channelType , guint16 channelId , guint8 direction )
2015-10-10 22:53:45 +00:00
{
2015-10-17 15:54:55 +00:00
LteRlcGraphDialog * lrg_dialog = new LteRlcGraphDialog ( * this , capture_file_ , channelKnown ) ;
connect ( lrg_dialog , SIGNAL ( goToPacket ( int ) ) , packet_list_ , SLOT ( goToPacket ( int ) ) ) ;
// This is a bit messy, but wanted to hide these parameters from users of
// on_actionTelephonyLteRlcGraph_triggered().
if ( channelKnown ) {
lrg_dialog - > setChannelInfo ( ueid , rlcMode , channelType , channelId , direction ) ;
}
2015-10-10 22:53:45 +00:00
lrg_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyLteRlcGraph_triggered ( )
2015-10-17 15:54:55 +00:00
{
// We don't yet know the channel.
launchRLCGraph ( false , 0 , 0 , 0 , 0 , 0 ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyMtp3Summary_triggered ( )
2015-09-03 18:18:13 +00:00
{
Mtp3SummaryDialog * mtp3s_dialog = new Mtp3SummaryDialog ( * this , capture_file_ ) ;
mtp3s_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyOsmuxPacketCounter_triggered ( )
2017-05-09 12:04:18 +00:00
{
openStatisticsTreeDialog ( " osmux " ) ;
}
2022-02-10 23:11:43 +00:00
RtpStreamDialog * WiresharkMainWindow : : openTelephonyRtpStreamsDialog ( )
2021-05-09 14:29:11 +00:00
{
RtpStreamDialog * dialog ;
dialog = RtpStreamDialog : : openRtpStreamDialog ( * this , capture_file_ , packet_list_ ) ;
dialog - > show ( ) ;
return dialog ;
2015-01-15 01:25:56 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyRtpStreams_triggered ( )
2021-03-27 20:01:43 +00:00
{
openTelephonyRtpStreamsDialog ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyRtpStreamAnalysis_triggered ( )
2015-02-02 17:01:29 +00:00
{
2021-04-22 19:33:11 +00:00
QVector < rtpstream_id_t * > stream_ids ;
2021-04-14 13:47:07 +00:00
QString err ;
if ( QGuiApplication : : keyboardModifiers ( ) . testFlag ( Qt : : ControlModifier ) ) {
2021-04-22 19:33:11 +00:00
err = findRtpStreams ( & stream_ids , true ) ;
2021-04-14 13:47:07 +00:00
} else {
2021-04-22 19:33:11 +00:00
err = findRtpStreams ( & stream_ids , false ) ;
2021-04-14 13:47:07 +00:00
}
2021-11-28 11:43:27 +00:00
if ( ! err . isNull ( ) ) {
2021-04-14 13:47:07 +00:00
QMessageBox : : warning ( this , tr ( " RTP packet search failed " ) ,
err ,
QMessageBox : : Ok ) ;
} else {
2021-05-09 14:29:11 +00:00
openTelephonyRtpAnalysisDialog ( ) - > addRtpStreams ( stream_ids ) ;
2021-04-14 13:47:07 +00:00
}
2021-04-22 19:33:11 +00:00
foreach ( rtpstream_id_t * id , stream_ids ) {
rtpstream_id_free ( id ) ;
2021-04-14 13:47:07 +00:00
}
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyRtpPlayer_triggered ( )
2021-04-14 13:47:07 +00:00
{
2021-04-22 19:33:11 +00:00
QVector < rtpstream_id_t * > stream_ids ;
2021-04-14 13:47:07 +00:00
QString err ;
if ( QGuiApplication : : keyboardModifiers ( ) . testFlag ( Qt : : ControlModifier ) ) {
2021-04-22 19:33:11 +00:00
err = findRtpStreams ( & stream_ids , true ) ;
2021-04-14 13:47:07 +00:00
} else {
2021-04-22 19:33:11 +00:00
err = findRtpStreams ( & stream_ids , false ) ;
2021-04-14 13:47:07 +00:00
}
2021-11-28 11:43:27 +00:00
if ( ! err . isNull ( ) ) {
2021-04-14 13:47:07 +00:00
QMessageBox : : warning ( this , tr ( " RTP packet search failed " ) ,
err ,
QMessageBox : : Ok ) ;
2021-11-21 21:05:36 +00:00
# ifdef QT_MULTIMEDIA_LIB
2021-04-14 13:47:07 +00:00
} else {
2021-05-09 14:29:11 +00:00
openTelephonyRtpPlayerDialog ( ) - > addRtpStreams ( stream_ids ) ;
2021-11-21 21:05:36 +00:00
# endif // QT_MULTIMEDIA_LIB
2021-04-14 13:47:07 +00:00
}
2021-04-22 19:33:11 +00:00
foreach ( rtpstream_id_t * id , stream_ids ) {
rtpstream_id_free ( id ) ;
2021-04-14 13:47:07 +00:00
}
2015-02-02 17:01:29 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyRTSPPacketCounter_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " rtsp " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonySMPPOperations_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " smpp_commands " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyUCPMessages_triggered ( )
2013-11-21 01:28:17 +00:00
{
openStatisticsTreeDialog ( " ucp_messages " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyF1APMessages_triggered ( )
2021-07-23 08:43:05 +00:00
{
openStatisticsTreeDialog ( " f1ap " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonyNGAPMessages_triggered ( )
2021-10-05 10:52:40 +00:00
{
openStatisticsTreeDialog ( " ngap " ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionTelephonySipFlows_triggered ( )
2014-11-19 00:21:42 +00:00
{
2021-05-09 14:29:11 +00:00
openTelephonyVoipCallsDialogSip ( ) ;
2014-11-19 00:21:42 +00:00
}
2016-06-01 01:29:39 +00:00
// Wireless Menu
2015-01-22 11:27:23 +00:00
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionBluetoothATT_Server_Attributes_triggered ( )
2015-01-22 11:27:23 +00:00
{
BluetoothAttServerAttributesDialog * bluetooth_att_sever_attributes_dialog = new BluetoothAttServerAttributesDialog ( * this , capture_file_ ) ;
connect ( bluetooth_att_sever_attributes_dialog , SIGNAL ( goToPacket ( int ) ) ,
packet_list_ , SLOT ( goToPacket ( int ) ) ) ;
2015-09-19 01:04:19 +00:00
connect ( bluetooth_att_sever_attributes_dialog , SIGNAL ( updateFilter ( QString , bool ) ) ,
this , SLOT ( filterPackets ( QString , bool ) ) ) ;
2015-01-22 11:27:23 +00:00
bluetooth_att_sever_attributes_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionBluetoothDevices_triggered ( )
2015-05-13 15:33:28 +00:00
{
2015-05-19 09:55:01 +00:00
BluetoothDevicesDialog * bluetooth_devices_dialog = new BluetoothDevicesDialog ( * this , capture_file_ , packet_list_ ) ;
2015-05-13 15:33:28 +00:00
connect ( bluetooth_devices_dialog , SIGNAL ( goToPacket ( int ) ) ,
packet_list_ , SLOT ( goToPacket ( int ) ) ) ;
2015-09-19 01:04:19 +00:00
connect ( bluetooth_devices_dialog , SIGNAL ( updateFilter ( QString , bool ) ) ,
this , SLOT ( filterPackets ( QString , bool ) ) ) ;
2015-05-13 15:33:28 +00:00
bluetooth_devices_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionBluetoothHCI_Summary_triggered ( )
2015-06-08 17:38:48 +00:00
{
BluetoothHciSummaryDialog * bluetooth_hci_summary_dialog = new BluetoothHciSummaryDialog ( * this , capture_file_ ) ;
connect ( bluetooth_hci_summary_dialog , SIGNAL ( goToPacket ( int ) ) ,
packet_list_ , SLOT ( goToPacket ( int ) ) ) ;
2015-09-19 01:04:19 +00:00
connect ( bluetooth_hci_summary_dialog , SIGNAL ( updateFilter ( QString , bool ) ) ,
this , SLOT ( filterPackets ( QString , bool ) ) ) ;
2015-06-08 17:38:48 +00:00
bluetooth_hci_summary_dialog - > show ( ) ;
}
2016-06-01 01:29:39 +00:00
// Tools Menu
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionToolsFirewallAclRules_triggered ( )
2016-06-01 01:29:39 +00:00
{
FirewallRulesDialog * firewall_rules_dialog = new FirewallRulesDialog ( * this , capture_file_ ) ;
firewall_rules_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionToolsCredentials_triggered ( )
2019-05-29 14:06:38 +00:00
{
CredentialsDialog * credentials_dialog = new CredentialsDialog ( * this , capture_file_ , packet_list_ ) ;
credentials_dialog - > show ( ) ;
}
2016-06-01 01:29:39 +00:00
2012-10-02 18:47:05 +00:00
// Help Menu
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpContents_triggered ( ) {
2012-10-02 18:47:05 +00:00
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( HELP_CONTENT ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpMPWireshark_triggered ( ) {
2012-10-02 18:47:05 +00:00
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( LOCALPAGE_MAN_WIRESHARK ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpMPWireshark_Filter_triggered ( ) {
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( LOCALPAGE_MAN_WIRESHARK_FILTER ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpMPCapinfos_triggered ( ) {
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( LOCALPAGE_MAN_CAPINFOS ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpMPDumpcap_triggered ( ) {
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( LOCALPAGE_MAN_DUMPCAP ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpMPEditcap_triggered ( ) {
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( LOCALPAGE_MAN_EDITCAP ) ;
2013-07-23 10:32:02 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpMPMergecap_triggered ( ) {
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( LOCALPAGE_MAN_MERGECAP ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpMPRawshark_triggered ( ) {
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( LOCALPAGE_MAN_RAWSHARK ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpMPReordercap_triggered ( ) {
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( LOCALPAGE_MAN_REORDERCAP ) ;
2013-07-23 10:32:02 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpMPText2pcap_triggered ( ) {
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( LOCALPAGE_MAN_TEXT2PCAP ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpMPTShark_triggered ( ) {
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( LOCALPAGE_MAN_TSHARK ) ;
2013-07-23 10:32:02 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpWebsite_triggered ( ) {
2012-10-02 18:47:05 +00:00
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( ONLINEPAGE_HOME ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpFAQ_triggered ( ) {
2012-10-02 18:47:05 +00:00
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( ONLINEPAGE_FAQ ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpAsk_triggered ( ) {
2012-10-02 18:47:05 +00:00
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( ONLINEPAGE_ASK ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpDownloads_triggered ( ) {
2012-10-02 18:47:05 +00:00
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( ONLINEPAGE_DOWNLOAD ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpWiki_triggered ( ) {
2012-10-02 18:47:05 +00:00
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( ONLINEPAGE_WIKI ) ;
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpSampleCaptures_triggered ( ) {
2012-10-02 18:47:05 +00:00
2022-02-01 03:30:09 +00:00
mainApp - > helpTopicAction ( ONLINEPAGE_SAMPLE_FILES ) ;
2012-10-02 18:47:05 +00:00
}
2013-03-06 22:04:17 +00:00
# ifdef HAVE_SOFTWARE_UPDATE
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : checkForUpdates ( )
2013-03-06 22:04:17 +00:00
{
software_update_check ( ) ;
}
# endif
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionHelpAbout_triggered ( )
2014-01-02 17:04:10 +00:00
{
2014-01-20 07:53:00 +00:00
AboutDialog * about_dialog = new AboutDialog ( this ) ;
2014-01-02 17:04:10 +00:00
2014-01-08 14:43:41 +00:00
if ( about_dialog - > isMinimized ( ) = = true )
2014-01-02 17:04:10 +00:00
{
2014-01-08 14:43:41 +00:00
about_dialog - > showNormal ( ) ;
2014-01-02 17:04:10 +00:00
}
else
{
2014-01-08 14:43:41 +00:00
about_dialog - > show ( ) ;
2014-01-02 17:04:10 +00:00
}
2014-01-08 14:43:41 +00:00
about_dialog - > raise ( ) ;
about_dialog - > activateWindow ( ) ;
2014-01-02 17:04:10 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionGoGoToPacket_triggered ( ) {
2019-09-22 12:56:46 +00:00
if ( ! packet_list_ - > model ( ) | | packet_list_ - > model ( ) - > rowCount ( ) < 1 ) {
2012-10-02 18:47:05 +00:00
return ;
}
2022-02-01 03:30:09 +00:00
previous_focus_ = mainApp - > focusWidget ( ) ;
2012-10-02 18:47:05 +00:00
connect ( previous_focus_ , SIGNAL ( destroyed ( ) ) , this , SLOT ( resetPreviousFocus ( ) ) ) ;
2012-12-15 01:04:39 +00:00
2015-06-17 15:41:41 +00:00
showAccordionFrame ( main_ui_ - > goToFrame , true ) ;
2012-12-15 01:04:39 +00:00
if ( main_ui_ - > goToFrame - > isVisible ( ) ) {
2015-06-05 08:06:16 +00:00
main_ui_ - > goToLineEdit - > clear ( ) ;
2015-06-17 15:41:41 +00:00
main_ui_ - > goToLineEdit - > setFocus ( ) ;
2012-12-15 01:04:39 +00:00
}
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionGoGoToLinkedPacket_triggered ( )
2015-07-31 23:52:37 +00:00
{
QAction * gta = qobject_cast < QAction * > ( sender ( ) ) ;
if ( ! gta ) return ;
bool ok = false ;
int packet_num = gta - > data ( ) . toInt ( & ok ) ;
if ( ! ok ) return ;
packet_list_ - > goToPacket ( packet_num ) ;
}
2015-11-12 16:35:34 +00:00
// gtk/main_menubar.c:goto_conversation_frame
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : goToConversationFrame ( bool go_next ) {
2015-11-12 16:35:34 +00:00
gchar * filter = NULL ;
dfilter_t * dfcode = NULL ;
gboolean found_packet = FALSE ;
2019-11-25 03:10:27 +00:00
packet_info * pi = capture_file_ . packetInfo ( ) ;
if ( ! pi ) {
// No packet was selected, or multiple packets were selected.
return ;
}
2015-11-12 16:35:34 +00:00
/* Try to build a conversation
* filter in the order TCP , UDP , IP , Ethernet and apply the
* coloring */
2017-06-20 18:08:39 +00:00
filter = conversation_filter_from_packet ( pi ) ;
2016-01-23 12:18:30 +00:00
if ( filter = = NULL ) {
2022-02-01 03:30:09 +00:00
mainApp - > pushStatus ( WiresharkApplication : : TemporaryStatus , tr ( " Unable to build conversation filter. " ) ) ;
2015-11-12 16:35:34 +00:00
g_free ( filter ) ;
return ;
}
if ( ! dfilter_compile ( filter , & dfcode , NULL ) ) {
/* The attempt failed; report an error. */
2022-02-01 03:30:09 +00:00
mainApp - > pushStatus ( WiresharkApplication : : TemporaryStatus , tr ( " Error compiling filter for this conversation. " ) ) ;
2015-11-12 16:35:34 +00:00
g_free ( filter ) ;
return ;
}
found_packet = cf_find_packet_dfilter ( capture_file_ . capFile ( ) , dfcode , go_next ? SD_FORWARD : SD_BACKWARD ) ;
if ( ! found_packet ) {
/* We didn't find a packet */
2022-02-01 03:30:09 +00:00
mainApp - > pushStatus ( WiresharkApplication : : TemporaryStatus , tr ( " No previous/next packet in conversation. " ) ) ;
2015-11-12 16:35:34 +00:00
}
dfilter_free ( dfcode ) ;
g_free ( filter ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionGoNextConversationPacket_triggered ( )
2015-11-12 16:35:34 +00:00
{
goToConversationFrame ( true ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionGoPreviousConversationPacket_triggered ( )
2015-11-12 16:35:34 +00:00
{
goToConversationFrame ( false ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionGoAutoScroll_toggled ( bool checked )
2015-02-20 14:30:23 +00:00
{
2015-11-27 16:01:05 +00:00
packet_list_ - > setVerticalAutoScroll ( checked ) ;
2015-02-20 14:30:23 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : resetPreviousFocus ( ) {
2012-10-02 18:47:05 +00:00
previous_focus_ = NULL ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_goToCancel_clicked ( )
2012-10-02 18:47:05 +00:00
{
2012-12-18 17:21:20 +00:00
main_ui_ - > goToFrame - > animatedHide ( ) ;
2012-10-02 18:47:05 +00:00
if ( previous_focus_ ) {
disconnect ( previous_focus_ , SIGNAL ( destroyed ( ) ) , this , SLOT ( resetPreviousFocus ( ) ) ) ;
previous_focus_ - > setFocus ( ) ;
resetPreviousFocus ( ) ;
}
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_goToGo_clicked ( )
2012-10-02 18:47:05 +00:00
{
2015-08-09 12:36:53 +00:00
gotoFrame ( main_ui_ - > goToLineEdit - > text ( ) . toInt ( ) ) ;
2012-10-02 18:47:05 +00:00
on_goToCancel_clicked ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_goToLineEdit_returnPressed ( )
2012-10-02 18:47:05 +00:00
{
on_goToGo_clicked ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionCaptureStart_triggered ( )
2012-10-02 18:47:05 +00:00
{
//#ifdef HAVE_AIRPCAP
// airpcap_if_active = airpcap_if_selected;
// if (airpcap_if_active)
// airpcap_set_toolbar_start_capture(airpcap_if_active);
//#endif
// if (cap_open_w) {
// /*
// * There's an options dialog; get the values from it and close it.
// */
// gboolean success;
// /* Determine if "capture start" while building of the "capture options" window */
// /* is in progress. If so, ignore the "capture start. */
// /* XXX: Would it be better/cleaner for the "capture options" window code to */
// /* disable the capture start button temporarily ? */
// if (cap_open_complete == FALSE) {
// return; /* Building options window: ignore "capture start" */
// }
// success = capture_dlg_prep(cap_open_w);
// window_destroy(GTK_WIDGET(cap_open_w));
// if (!success)
// return; /* error in options dialog */
// }
2013-10-11 21:26:26 +00:00
# ifdef HAVE_LIBPCAP
2012-10-02 18:47:05 +00:00
if ( global_capture_opts . num_selected = = 0 ) {
2020-07-17 11:45:01 +00:00
QString err_msg = tr ( " No Interface Selected. " ) ;
2022-02-01 03:30:09 +00:00
mainApp - > pushStatus ( WiresharkApplication : : TemporaryStatus , err_msg ) ;
2015-06-24 21:41:44 +00:00
main_ui_ - > actionCaptureStart - > setChecked ( false ) ;
2012-10-02 18:47:05 +00:00
return ;
}
/* XXX - will closing this remove a temporary file? */
2015-09-05 18:30:17 +00:00
QString before_what ( tr ( " before starting a new capture " ) ) ;
2016-01-11 09:46:02 +00:00
if ( testCaptureFileClose ( before_what ) ) {
2022-03-18 12:53:42 +00:00
startCapture ( QStringList ( ) ) ;
2015-06-24 21:18:04 +00:00
} else {
// simply clicking the button sets it to 'checked' even though we've
// decided to do nothing, so undo that
main_ui_ - > actionCaptureStart - > setChecked ( false ) ;
}
2013-10-11 21:26:26 +00:00
# endif // HAVE_LIBPCAP
2012-10-02 18:47:05 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionCaptureStop_triggered ( )
2012-10-02 18:47:05 +00:00
{
stopCapture ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionCaptureRestart_triggered ( )
2015-03-18 16:02:54 +00:00
{
2019-02-20 09:10:48 +00:00
# ifdef HAVE_LIBPCAP
2016-01-25 11:07:10 +00:00
QString before_what ( tr ( " before restarting the capture " ) ) ;
2019-02-19 18:02:30 +00:00
cap_session_ . capture_opts - > restart = TRUE ;
2016-01-25 11:07:10 +00:00
if ( ! testCaptureFileClose ( before_what , Restart ) )
2015-12-19 21:36:30 +00:00
return ;
2022-03-18 12:53:42 +00:00
startCapture ( QStringList ( ) ) ;
2019-02-20 09:10:48 +00:00
# endif // HAVE_LIBPCAP
2015-03-18 16:02:54 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionCaptureCaptureFilters_triggered ( )
2015-06-03 23:26:00 +00:00
{
if ( ! capture_filter_dlg_ ) {
capture_filter_dlg_ = new FilterDialog ( this , FilterDialog : : CaptureFilter ) ;
}
capture_filter_dlg_ - > show ( ) ;
capture_filter_dlg_ - > raise ( ) ;
capture_filter_dlg_ - > activateWindow ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsCaptureFileProperties_triggered ( )
2013-07-09 18:08:40 +00:00
{
2014-12-22 23:51:36 +00:00
CaptureFilePropertiesDialog * capture_file_properties_dialog = new CaptureFilePropertiesDialog ( * this , capture_file_ ) ;
2014-11-12 22:24:16 +00:00
connect ( capture_file_properties_dialog , SIGNAL ( captureCommentChanged ( ) ) ,
this , SLOT ( updateForUnsavedChanges ( ) ) ) ;
capture_file_properties_dialog - > show ( ) ;
2013-07-09 18:08:40 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsResolvedAddresses_triggered ( )
2015-07-09 23:00:14 +00:00
{
2019-10-04 19:05:13 +00:00
QString capFileName ;
wtap * wth = Q_NULLPTR ;
2019-11-17 19:02:20 +00:00
if ( capture_file_ . isValid ( ) )
2019-10-04 19:05:13 +00:00
{
capFileName = capture_file_ . capFile ( ) - > filename ;
wth = capture_file_ . capFile ( ) - > provider . wth ;
}
ResolvedAddressesDialog * resolved_addresses_dialog =
new ResolvedAddressesDialog ( this , capFileName , wth ) ;
2015-07-09 23:00:14 +00:00
resolved_addresses_dialog - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionStatisticsProtocolHierarchy_triggered ( )
2015-02-03 16:39:14 +00:00
{
ProtocolHierarchyDialog * phd = new ProtocolHierarchyDialog ( * this , capture_file_ ) ;
2019-04-23 01:19:40 +00:00
connect ( phd , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ,
this , SIGNAL ( filterAction ( QString , FilterAction : : Action , FilterAction : : ActionType ) ) ) ;
2015-02-03 16:39:14 +00:00
phd - > show ( ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionCaptureOptions_triggered ( )
2013-11-25 14:15:49 +00:00
{
2016-11-11 16:48:33 +00:00
# ifdef HAVE_LIBPCAP
2019-12-02 18:43:08 +00:00
if ( ! capture_options_dialog_ ) {
capture_options_dialog_ = new CaptureOptionsDialog ( this ) ;
2016-03-31 00:24:44 +00:00
2019-12-02 18:43:08 +00:00
connect ( capture_options_dialog_ , SIGNAL ( startCapture ( ) ) , this , SLOT ( startCapture ( ) ) ) ;
connect ( capture_options_dialog_ , SIGNAL ( stopCapture ( ) ) , this , SLOT ( stopCapture ( ) ) ) ;
2016-03-31 00:24:44 +00:00
2019-12-02 18:43:08 +00:00
connect ( capture_options_dialog_ , SIGNAL ( interfacesChanged ( ) ) ,
2018-06-01 20:54:49 +00:00
this - > welcome_page_ , SLOT ( interfaceSelected ( ) ) ) ;
2019-12-02 18:43:08 +00:00
connect ( capture_options_dialog_ , SIGNAL ( interfacesChanged ( ) ) ,
2018-06-01 20:54:49 +00:00
this - > welcome_page_ - > getInterfaceFrame ( ) , SLOT ( updateSelectedInterfaces ( ) ) ) ;
2019-12-02 18:43:08 +00:00
connect ( capture_options_dialog_ , SIGNAL ( interfaceListChanged ( ) ) ,
2018-06-01 20:54:49 +00:00
this - > welcome_page_ - > getInterfaceFrame ( ) , SLOT ( interfaceListChanged ( ) ) ) ;
2019-12-02 18:43:08 +00:00
connect ( capture_options_dialog_ , SIGNAL ( captureFilterTextEdited ( QString ) ) ,
2018-06-01 20:54:49 +00:00
this - > welcome_page_ , SLOT ( setCaptureFilterText ( QString ) ) ) ;
2017-03-10 13:37:18 +00:00
// Propagate selection changes from main UI to dialog.
2018-06-01 20:54:49 +00:00
connect ( this - > welcome_page_ , SIGNAL ( interfacesChanged ( ) ) ,
2019-12-02 18:43:08 +00:00
capture_options_dialog_ , SLOT ( interfaceSelected ( ) ) ) ;
2016-03-31 00:24:44 +00:00
2019-12-02 18:43:08 +00:00
connect ( capture_options_dialog_ , SIGNAL ( setFilterValid ( bool , const QString ) ) ,
2016-03-31 00:24:44 +00:00
this , SLOT ( startInterfaceCapture ( bool , const QString ) ) ) ;
2021-12-07 05:47:54 +00:00
2022-01-06 07:02:11 +00:00
connect ( capture_options_dialog_ , SIGNAL ( showExtcapOptions ( QString & , bool ) ) ,
this , SLOT ( showExtcapOptionsDialog ( QString & , bool ) ) ) ;
2016-03-31 00:24:44 +00:00
}
2019-12-02 18:43:08 +00:00
capture_options_dialog_ - > updateInterfaces ( ) ;
2016-03-31 00:24:44 +00:00
2019-12-02 18:43:08 +00:00
if ( capture_options_dialog_ - > isMinimized ( ) ) {
capture_options_dialog_ - > showNormal ( ) ;
2016-03-31 00:24:44 +00:00
} else {
2019-12-02 18:43:08 +00:00
capture_options_dialog_ - > show ( ) ;
2013-11-25 14:15:49 +00:00
}
2019-12-02 18:43:08 +00:00
capture_options_dialog_ - > raise ( ) ;
capture_options_dialog_ - > activateWindow ( ) ;
2016-11-11 16:48:33 +00:00
# endif
2013-11-25 14:15:49 +00:00
}
2014-07-25 07:44:50 +00:00
2016-11-11 16:48:33 +00:00
# ifdef HAVE_LIBPCAP
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionCaptureRefreshInterfaces_triggered ( )
2014-07-25 07:44:50 +00:00
{
2015-12-03 20:31:47 +00:00
main_ui_ - > actionCaptureRefreshInterfaces - > setEnabled ( false ) ;
2022-02-01 03:30:09 +00:00
mainApp - > refreshLocalInterfaces ( ) ;
2015-12-03 20:31:47 +00:00
main_ui_ - > actionCaptureRefreshInterfaces - > setEnabled ( true ) ;
2014-07-25 07:44:50 +00:00
}
2013-11-25 21:50:58 +00:00
# endif
2013-11-25 14:15:49 +00:00
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : externalMenuItem_triggered ( )
2015-03-30 14:10:01 +00:00
{
QAction * triggerAction = NULL ;
QVariant v ;
ext_menubar_t * entry = NULL ;
2016-01-23 12:18:30 +00:00
if ( QObject : : sender ( ) ) {
2015-03-30 14:10:01 +00:00
triggerAction = ( QAction * ) QObject : : sender ( ) ;
v = triggerAction - > data ( ) ;
2016-01-23 12:18:30 +00:00
if ( v . canConvert < void * > ( ) ) {
2015-03-30 14:10:01 +00:00
entry = ( ext_menubar_t * ) v . value < void * > ( ) ;
2016-01-23 12:18:30 +00:00
if ( entry - > type = = EXT_MENUBAR_ITEM ) {
2019-04-23 01:19:40 +00:00
entry - > callback ( EXT_MENUBAR_QT_GUI , ( gpointer ) ( ( void * ) main_ui_ ) , entry - > user_data ) ;
2016-01-23 12:18:30 +00:00
} else {
2015-03-30 14:10:01 +00:00
QDesktopServices : : openUrl ( QUrl ( QString ( ( gchar * ) entry - > user_data ) ) ) ;
}
}
}
}
2013-11-25 14:15:49 +00:00
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : extcap_options_finished ( int result )
2015-04-28 08:26:46 +00:00
{
2016-01-23 12:18:30 +00:00
if ( result = = QDialog : : Accepted ) {
2018-06-30 19:08:54 +00:00
QString before_what ( tr ( " before starting a new capture " ) ) ;
if ( testCaptureFileClose ( before_what ) ) {
2022-03-18 12:53:42 +00:00
startCapture ( QStringList ( ) ) ;
2018-06-30 19:08:54 +00:00
}
2015-04-28 08:26:46 +00:00
}
2018-06-01 20:54:49 +00:00
this - > welcome_page_ - > getInterfaceFrame ( ) - > interfaceListChanged ( ) ;
2015-04-28 08:26:46 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : showExtcapOptionsDialog ( QString & device_name , bool startCaptureOnClose )
2015-04-28 08:26:46 +00:00
{
2022-01-06 07:02:11 +00:00
ExtcapOptionsDialog * extcap_options_dialog = ExtcapOptionsDialog : : createForDevice ( device_name , startCaptureOnClose , this ) ;
2015-04-28 08:26:46 +00:00
/* The dialog returns null, if the given device name is not a valid extcap device */
2016-01-23 12:18:30 +00:00
if ( extcap_options_dialog ) {
2019-05-14 19:41:47 +00:00
extcap_options_dialog - > setModal ( true ) ;
extcap_options_dialog - > setAttribute ( Qt : : WA_DeleteOnClose ) ;
2022-01-06 07:02:11 +00:00
if ( startCaptureOnClose ) {
connect ( extcap_options_dialog , SIGNAL ( finished ( int ) ) ,
this , SLOT ( extcap_options_finished ( int ) ) ) ;
}
2021-12-08 21:55:57 +00:00
# ifdef HAVE_LIBPCAP
2022-01-06 07:02:11 +00:00
if ( capture_options_dialog_ & & startCaptureOnClose ) {
2021-12-07 05:47:54 +00:00
/* Allow capture options dialog to close */
connect ( extcap_options_dialog , SIGNAL ( accepted ( ) ) ,
capture_options_dialog_ , SLOT ( accept ( ) ) ) ;
}
2021-12-08 21:55:57 +00:00
# endif
2015-04-28 08:26:46 +00:00
extcap_options_dialog - > show ( ) ;
}
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionContextWikiProtocolPage_triggered ( )
2015-07-31 23:52:37 +00:00
{
QAction * wa = qobject_cast < QAction * > ( sender ( ) ) ;
if ( ! wa ) return ;
bool ok = false ;
int field_id = wa - > data ( ) . toInt ( & ok ) ;
if ( ! ok ) return ;
const QString proto_abbrev = proto_registrar_get_abbrev ( field_id ) ;
2022-02-01 03:30:09 +00:00
int ret = QMessageBox : : question ( this , mainApp - > windowTitleString ( tr ( " Wiki Page for %1 " ) . arg ( proto_abbrev ) ) ,
2019-04-23 01:19:40 +00:00
tr ( " <p>The Wireshark Wiki is maintained by the community.</p> "
" <p>The page you are about to load might be wonderful, "
" incomplete, wrong, or nonexistent.</p> "
" <p>Proceed to the wiki?</p> " ) ,
QMessageBox : : Yes | QMessageBox : : No , QMessageBox : : Yes ) ;
2015-07-31 23:52:37 +00:00
if ( ret ! = QMessageBox : : Yes ) return ;
2020-10-26 00:42:11 +00:00
QUrl wiki_url = QString ( WS_WIKI_URL ( " Protocols/%1 " ) ) . arg ( proto_abbrev ) ;
2015-07-31 23:52:37 +00:00
QDesktopServices : : openUrl ( wiki_url ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionContextFilterFieldReference_triggered ( )
2015-07-31 23:52:37 +00:00
{
QAction * wa = qobject_cast < QAction * > ( sender ( ) ) ;
if ( ! wa ) return ;
bool ok = false ;
int field_id = wa - > data ( ) . toInt ( & ok ) ;
if ( ! ok ) return ;
const QString proto_abbrev = proto_registrar_get_abbrev ( field_id ) ;
2020-10-03 02:17:00 +00:00
QUrl dfref_url = QString ( WS_DOCS_URL " /dfref/%1/%2 " )
2015-07-31 23:52:37 +00:00
. arg ( proto_abbrev [ 0 ] )
. arg ( proto_abbrev ) ;
QDesktopServices : : openUrl ( dfref_url ) ;
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : on_actionViewFullScreen_triggered ( bool checked )
2016-10-19 18:53:40 +00:00
{
if ( checked ) {
// Save the state for future restore
was_maximized_ = this - > isMaximized ( ) ;
this - > showFullScreen ( ) ;
} else {
// Restore the previous state
if ( was_maximized_ )
this - > showMaximized ( ) ;
else
this - > showNormal ( ) ;
}
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : activatePluginIFToolbar ( bool )
2017-01-24 16:34:07 +00:00
{
2017-02-24 08:49:11 +00:00
QAction * sendingAction = dynamic_cast < QAction * > ( sender ( ) ) ;
if ( ! sendingAction | | ! sendingAction - > data ( ) . isValid ( ) )
2017-01-24 16:34:07 +00:00
return ;
2017-02-24 08:49:11 +00:00
ext_toolbar_t * toolbar = VariantPointer < ext_toolbar_t > : : asPtr ( sendingAction - > data ( ) ) ;
2017-01-24 16:34:07 +00:00
QList < QToolBar * > toolbars = findChildren < QToolBar * > ( ) ;
2019-04-23 01:19:40 +00:00
foreach ( QToolBar * bar , toolbars ) {
2017-02-24 08:49:11 +00:00
AdditionalToolBar * iftoolbar = dynamic_cast < AdditionalToolBar * > ( bar ) ;
if ( iftoolbar & & iftoolbar - > menuName ( ) . compare ( toolbar - > name ) = = 0 ) {
if ( iftoolbar - > isVisible ( ) ) {
2017-01-24 16:34:07 +00:00
iftoolbar - > setVisible ( false ) ;
sendingAction - > setChecked ( true ) ;
2017-02-24 08:49:11 +00:00
} else {
2017-01-24 16:34:07 +00:00
iftoolbar - > setVisible ( true ) ;
sendingAction - > setChecked ( true ) ;
}
}
}
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : rtpPlayerDialogReplaceRtpStreams ( QVector < rtpstream_id_t * > stream_ids _U_ )
2021-03-27 20:01:43 +00:00
{
2021-11-28 11:43:27 +00:00
# ifdef QT_MULTIMEDIA_LIB
2021-05-09 14:29:11 +00:00
openTelephonyRtpPlayerDialog ( ) - > replaceRtpStreams ( stream_ids ) ;
2021-11-28 11:43:27 +00:00
# endif
2021-03-27 20:01:43 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : rtpPlayerDialogAddRtpStreams ( QVector < rtpstream_id_t * > stream_ids _U_ )
2021-03-27 20:01:43 +00:00
{
2021-11-28 11:43:27 +00:00
# ifdef QT_MULTIMEDIA_LIB
2021-05-09 14:29:11 +00:00
openTelephonyRtpPlayerDialog ( ) - > addRtpStreams ( stream_ids ) ;
2021-11-28 11:43:27 +00:00
# endif
2021-03-27 20:01:43 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : rtpPlayerDialogRemoveRtpStreams ( QVector < rtpstream_id_t * > stream_ids _U_ )
2021-03-27 20:01:43 +00:00
{
2021-11-28 11:43:27 +00:00
# ifdef QT_MULTIMEDIA_LIB
2021-05-09 14:29:11 +00:00
openTelephonyRtpPlayerDialog ( ) - > removeRtpStreams ( stream_ids ) ;
2021-11-28 11:43:27 +00:00
# endif
2021-04-07 05:40:09 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : rtpAnalysisDialogReplaceRtpStreams ( QVector < rtpstream_id_t * > stream_ids )
2021-04-07 05:40:09 +00:00
{
2021-05-09 14:29:11 +00:00
openTelephonyRtpAnalysisDialog ( ) - > replaceRtpStreams ( stream_ids ) ;
2021-04-07 05:40:09 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : rtpAnalysisDialogAddRtpStreams ( QVector < rtpstream_id_t * > stream_ids )
2021-04-07 05:40:09 +00:00
{
2021-05-09 14:29:11 +00:00
openTelephonyRtpAnalysisDialog ( ) - > addRtpStreams ( stream_ids ) ;
2021-04-07 05:40:09 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : rtpAnalysisDialogRemoveRtpStreams ( QVector < rtpstream_id_t * > stream_ids )
2021-04-07 05:40:09 +00:00
{
2021-05-09 14:29:11 +00:00
openTelephonyRtpAnalysisDialog ( ) - > removeRtpStreams ( stream_ids ) ;
2021-03-27 20:01:43 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : rtpStreamsDialogSelectRtpStreams ( QVector < rtpstream_id_t * > stream_ids )
2021-03-27 20:01:43 +00:00
{
2021-05-09 14:29:11 +00:00
openTelephonyRtpStreamsDialog ( ) - > selectRtpStream ( stream_ids ) ;
2021-03-27 20:01:43 +00:00
}
2022-02-10 23:11:43 +00:00
void WiresharkMainWindow : : rtpStreamsDialogDeselectRtpStreams ( QVector < rtpstream_id_t * > stream_ids )
2021-03-27 20:01:43 +00:00
{
2021-05-09 14:29:11 +00:00
openTelephonyRtpStreamsDialog ( ) - > deselectRtpStream ( stream_ids ) ;
2021-03-27 20:01:43 +00:00
}
2015-10-14 23:50:22 +00:00
# ifdef _MSC_VER
# pragma warning(pop)
# endif