| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
stratoshark_main_window.h
Go to the documentation of this file.
1
9
10#pragma once
11
31
37
38#include <stdio.h>
39
40#include <config.h>
41
42#include "ui/ws_ui_util.h"
43#include "ui/iface_toolbar.h"
44#ifdef HAVE_LIBPCAP
45#include "ui/capture_opts.h"
46#endif
47#include "ui/plugins/include/plugin_if.h"
48
49#include <epan/timestamp.h>
50
51#include <capture/capture_session.h>
52
53#include <QMainWindow>
54#include <QPointer>
55
56#ifdef _WIN32
57# include <QTimer>
58#else
59# include <QSocketNotifier>
60#endif
61
62#include "capture_file_dialog.h"
63#include "capture_file_properties_dialog.h"
64#include <ui/qt/utils/field_information.h>
65#include <ui/qt/widgets/display_filter_entry.h>
66#include "main_window.h"
67
68 class AccordionFrame;
69 class DataSourceTab;
70 class CaptureOptionsDialog;
71 class PrintDialog;
72 class FileSetDialog;
73 class FilterDialog;
74 class FunnelStatistics;
75 class PacketCommentDialog;
76 class PacketList;
77 class ProtoTree;
78 class FilterExpressionToolBar;
79 class WiresharkApplication;
80
81 class QAction;
82 class QActionGroup;
83
84 namespace Ui {
85 class StratosharkMainWindow;
86}
87
88Q_DECLARE_METATYPE(ts_type)
89Q_DECLARE_METATYPE(ts_precision)
90
91
96class StratosharkMainWindow : public MainWindow
97{
98 Q_OBJECT
99
100 public:
106 explicit StratosharkMainWindow(QWidget *parent = nullptr);
107
111 ~StratosharkMainWindow();
112
113#ifdef HAVE_LIBPCAP
118 capture_session *captureSession() { return &cap_session_; }
119
124 info_data_t *captureInfoData() { return &info_data_; }
125#endif
126
131 QMenu *createPopupMenu() override;
132
136 void setFunnelMenus(void);
137
142 void removeAdditionalToolbar(QString toolbarName);
143
148 void addInterfaceToolbar(const iface_toolbar *toolbar_entry);
149
154 void removeInterfaceToolbar(const char *menu_title);
155
160 QString getMwFileName();
161
166 void setMwFileName(QString fileName);
167
168 protected:
175 bool eventFilter(QObject *obj, QEvent *event) override;
176
182 bool event(QEvent *event) override;
183
188 void keyPressEvent(QKeyEvent *event) override;
189
194 void closeEvent(QCloseEvent *event) override;
195
200 void dragEnterEvent(QDragEnterEvent *event) override;
201
206 void dropEvent(QDropEvent *event) override;
207
212 void changeEvent(QEvent *event) override;
213
218 void openRecentCaptureFile(const QString &filename) override;
219
227 bool tryClosingCaptureFile(QString before_what, FileCloseContext context = Default) override;
228
229 private:
234 enum MatchSelected {
235 MatchSelectedReplace,
236 MatchSelectedAnd,
237 MatchSelectedOr,
238 MatchSelectedNot,
239 MatchSelectedAndNot,
240 MatchSelectedOrNot
241 };
242
243 Ui::StratosharkMainWindow *main_ui_;
244 QFont mono_font_;
245 QWidget *previous_focus_;
246 FileSetDialog *file_set_dialog_;
247 QActionGroup *show_hide_actions_;
248 QActionGroup *time_display_actions_;
249 QActionGroup *time_precision_actions_;
250 FunnelStatistics *funnel_statistics_;
251 QList<QPair<QAction *, bool>> freeze_actions_;
252 QPointer<QWidget> freeze_focus_;
253 QMap<QAction *, ts_type> td_actions;
254 QMap<QAction *, ts_precision> tp_actions;
255 bool was_maximized_;
256
257 QString mwFileName_;
258
259 bool capture_stopping_;
260 bool capture_filter_valid_;
261#ifdef HAVE_LIBPCAP
262 capture_session cap_session_;
263 CaptureOptionsDialog *capture_options_dialog_;
264 info_data_t info_data_;
265#endif
266
267 QPoint dragStartPosition;
268
272 void freeze();
273
277 void thaw();
278
283 void mergeCaptureFile();
284
289 void importCaptureFile();
290
297 bool saveCaptureFile(capture_file *cf, bool dont_reopen);
298
307 bool saveAsCaptureFile(capture_file *cf, bool must_support_comments = false, bool dont_reopen = false);
308
313 void exportSelectedPackets();
314
319 void exportDissections(export_type_e export_type);
320
321#ifdef Q_OS_WIN
329 void fileAddExtension(QString &file_name, int file_type, ws_compression_type compression_type);
330#endif
331
335 void captureStop();
336
338 void initMainToolbarIcons();
339
341 void initShowHideMainWidgets();
342
344 void initTimeDisplayFormatMenu();
345
347 void initTimePrecisionFormatMenu();
348
350 void initFreezeActions();
351
356 void setMenusForCaptureFile(bool force_disable = false) override;
357
362 void setMenusForCaptureInProgress(bool capture_in_progress = false);
363
365 void setMenusForCaptureStopping();
366
371 void setForCapturedPackets(bool have_captured_packets);
372
377 void setMenusForFileSet(bool enable_list_files);
378
382 void updateStyleSheet();
383
390 void externalMenuHelper(ext_menu_t *menu, QMenu *subMenu, int depth);
391
399 void setForCaptureInProgress(bool capture_in_progress = false, bool handle_toolbars = false, GArray *ifaces = NULL);
400
408 QMenu *findOrAddMenu(QMenu *parent_menu, const QStringList &menu_parts);
409
414 void captureFileReadStarted(const QString &action);
415
421 void addMenuActions(QList<QAction *> &actions, int menu_group);
422
428 void removeMenuActions(QList<QAction *> &actions, int menu_group);
429
435 void goToConversationFrame(bool go_next, bool start_current = true);
436
442 void colorizeWithFilter(QByteArray filter, int color_number = -1);
443
444signals:
449 void setDissectedCaptureFile(capture_file *cf);
450
452 void closePacketDialogs();
453
455 void reloadFields();
456
461 void packetInfoChanged(struct _packet_info *pinfo);
462
467 void fieldFilterChanged(const QByteArray field_filter);
468
469#ifdef HAVE_LIBPCAP
475 void showExtcapOptions(QString &device_name, bool startCaptureOnClose);
476#endif
477
478 public slots:
479 // Qt lets you connect signals and slots using functors (new, manual style)
480 // and strings (old style). Functors are preferred since they're connected at
481 // compile time and less error prone.
482 //
483 // If you're manually connecting a signal to a slot, don't prefix its name
484 // with "on_". Otherwise Qt will try to automatically connect it and you'll
485 // get runtime warnings.
486
487 // in main_window_slots.cpp
488
497 bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type, bool is_tempfile = false);
498
505 bool openCaptureFile(QString cf_path = QString(), QString display_filter = QString()) { return openCaptureFile(cf_path, display_filter, WTAP_TYPE_AUTO); }
506
508 void updateForUnsavedChanges();
509
511 void layoutToolbars();
512
514 void updatePreferenceActions();
515
517 void updateRecentActions();
518
520 void setTitlebarForCaptureFile();
521
523 void showCaptureOptionsDialog();
524
525#ifdef HAVE_LIBPCAP
530 void captureCapturePrepared(capture_session *session);
531
536 void captureCaptureUpdateStarted(capture_session *session);
537
542 void captureCaptureUpdateFinished(capture_session *session);
543
547 void captureCaptureFixedFinished(capture_session *);
548
552 void captureCaptureFailed(capture_session *);
553#endif
554
556 void captureFileOpened();
557
559 void captureFileReadFinished();
560
562 void captureFileClosing();
563
565 void captureFileClosed();
566
567#ifdef HAVE_LUA
569 void openLuaDebuggerDialog();
570#endif
571
572 protected slots:
578 void applyFilter(QString new_filter = QString(), bool force = false) override;
579
580 private slots:
588 void onAppInitialized();
589
594 void captureEventHandler(CaptureEvent ev);
595
597 void initViewColorizeMenu();
598
600 void initConversationMenus();
601
609 static bool addFollowStreamMenuItem(const void *key, void *value, void *userdata);
610
612 void initFollowStreamMenus();
613
614 // in main_window_slots.cpp
619 void startCapture(QStringList);
620
622 void startCapture();
623
625 void pushLiveCaptureInProgress();
626
628 void popLiveCaptureInProgress();
629
631 void stopCapture();
632
634 void loadWindowGeometry();
635
637 void saveWindowGeometry();
638
642 void mainStackChanged(int);
643
645 void updateRecentCaptures();
646
648 void addPacketComment();
649
651 void editPacketComment();
652
654 void deletePacketComment();
655
657 void deleteCommentsFromPackets();
658
665 QString commentToMenuText(QString text, int max_len = 40);
666
668 void setEditCommentsMenu();
669
671 void setMenusForSelectedPacket();
672
677 void setMenusForSelectedTreeRow(FieldInformation *fi = NULL);
678
680 void interfaceSelectionChanged();
681
686 void captureFilterSyntaxChanged(bool valid);
687
689 void redissectPackets();
690
692 void checkDisplayFilter();
693
695 void fieldsChanged();
696
698 void reloadLuaPlugins();
699
705 void showAccordionFrame(AccordionFrame *show_frame, bool toggle = false);
706
711 void showColumnEditor(int column);
712
714 void showPreferenceEditor();
715
717 void addStatsPluginsToMenu();
718
720 void addDynamicMenus();
721
723 void reloadDynamicMenus();
724
726 void addPluginIFStructures();
727
733 QMenu *searchSubMenu(QString objectName);
734
738 void activatePluginIFToolbar(bool);
739
745 void startInterfaceCapture(bool valid, const QString capture_filter);
746
749 void applyGlobalCommandLineOptions();
750
755 void setFeaturesEnabled(bool enabled = true);
756
758 void on_actionNewDisplayFilterExpression_triggered();
759
765 void onFilterSelected(QString filterText, bool prepare);
766
768 void onFilterPreferences();
769
774 void onFilterEdit(int uatIndex);
775
782 void queuedFilterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);
783
790 void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
791
798 void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
799
801 void openTapParameterDialog();
802
804 void connectFileMenuActions();
805
807 void printFile();
808
810 void connectEditMenuActions();
811
816 void copySelectedItems(StratosharkMainWindow::CopySelected selection_type);
817
819 void findPacket();
820
822 void editTimeShift();
823
825 void editConfigurationProfiles();
826
830 void editTimeShiftFinished(int);
831
837 void addPacketCommentFinished(PacketCommentDialog *pc_dialog, int result);
838
845 void editPacketCommentFinished(PacketCommentDialog *pc_dialog, int result, unsigned nComment);
846
848 void deleteAllPacketComments();
849
854 void deleteAllPacketCommentsFinished(int result);
855
860 void showPreferencesDialog(QString module_name) override;
861
863 void connectViewMenuActions();
864
869 void showHideMainWidgets(QAction *action);
870
875 void setTimestampFormat(QAction *action);
876
881 void setTimestampPrecision(QAction *action);
882
887 void setTimeDisplaySecondsWithHoursAndMinutes(bool checked);
888
890 void editResolvedName();
891
893 void setNameResolution();
894
895
897 void showColoringRulesDialog();
898
904 void colorizeConversation(bool create_rule = false);
905
907 void colorizeActionTriggered();
908
913 void openPacketDialog(bool from_reference = false);
914
916 void reloadCaptureFileAsFormatOrCapture();
917
919 void reloadCaptureFile();
920
922 void connectGoMenuActions();
923
925 void setPreviousFocus();
926
928 void resetPreviousFocus();
929
931 void connectCaptureMenuActions();
932
934 void startCaptureTriggered();
935
937 void connectAnalyzeMenuActions();
938
945 void matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type);
946
948 void applyFieldAsColumn();
949
951 void filterMenuAboutToShow();
952
954 void applyConversationFilter();
955
963 void openFollowStreamDialog(int proto_id, unsigned stream_num, unsigned sub_stream_num, bool use_stream_index = true);
964
969 void openFollowStreamDialog(int proto_id);
970
974 void statCommandExpertInfo(const char *, void *);
975
977 void connectToolsMenuActions();
978
980 void connectHelpMenuActions();
981
983 void goToCancelClicked();
984
986 void goToGoClicked();
987
989 void goToLineEditReturnPressed();
990
992 void connectStatisticsMenuActions();
993
995 void showResolvedAddressesDialog();
996
998 void showConversationsDialog();
999
1001 void showEndpointsDialog();
1002
1007 void openStatisticsTreeDialog(const char *abbr);
1008
1012 void statCommandIOGraph(const char *, void *);
1013
1019 void showIOGraphDialog(io_graph_item_unit_t value_units, QString yfield) override;
1020
1026 void showPlotDialog(const QString &y_field = QString(), bool filtered = false) override;
1027
1029 void externalMenuItemTriggered();
1030
1032 void on_actionContextWikiProtocolPage_triggered();
1033
1035 void on_actionContextFilterFieldReference_triggered();
1036
1041 void extcap_options_finished(int result);
1042
1048 void showExtcapOptionsDialog(QString device_name, bool startCaptureOnClose);
1049
1051 friend class MainApplication;
1052};
capture_file_dialog.h
capture_file_properties_dialog.h
info_data_t
struct _info_data info_data_t
Aggregates packet count statistics and UI state for a live capture info display.
capture_opts.h
capture_session.h
capture_session
struct _capture_session capture_session
Opaque handle representing an active or pending capture session.
capture_file
struct _capture_file capture_file
Represents a capture file and its associated metadata.
AccordionFrame
A QFrame that shows and hides itself with a slide animation.
Definition accordion_frame.h:21
CaptureEvent
Represents an event occurring during a capture or file operation.
Definition capture_event.h:24
DataSourceTab
A tab widget that manages and displays different data sources for a packet (e.g., Hex,...
Definition data_source_tab.h:36
FieldInformation
Represents information about a dissected packet field.
Definition field_information.h:26
FileSetDialog
A dialog for managing and displaying capture file sets.
Definition file_set_dialog.h:32
FilterAction::Action
Action
Defines an action to be taken with a filter.
Definition filter_action.h:30
FilterAction::ActionType
ActionType
Defines how the new filter should be combined with the existing one.
Definition filter_action.h:43
FilterDialog
A dialog for managing and editing capture filters, display filters, and display macros.
Definition filter_dialog.h:31
FilterExpressionToolBar
A toolbar that displays filter expressions and supports drag-and-drop operations.
Definition filter_expression_toolbar.h:21
FunnelStatistics
Manages statistics and user interface interactions for Lua-based funnel plugins.
Definition funnel_statistics.h:35
MainWindow::CopySelected
CopySelected
Enumeration for determining what to copy when items are selected.
Definition main_window.h:228
MainWindow::MainWindow
MainWindow(QWidget *parent=nullptr)
Constructs a new MainWindow.
Definition main_window.cpp:50
MainWindow::FileCloseContext
FileCloseContext
Context under which a capture file is being closed.
Definition main_window.h:252
MainWindow::Default
@ Default
Default closing context.
Definition main_window.h:254
PacketCommentDialog
Dialog for viewing or editing a packet comment.
Definition packet_comment_dialog.h:23
PacketList
The main packet list view for displaying captured packets.
Definition packet_list.h:45
PrintDialog
Dialog that provides packet print and print-preview functionality for a live or saved capture file.
Definition print_dialog.h:31
ProtoTree
A tree view for displaying protocol dissection details.
Definition proto_tree.h:30
StratosharkMainWindow::setMwFileName
void setMwFileName(QString fileName)
Sets the file path shown in the main window title bar.
Definition stratoshark_main_window.cpp:2763
StratosharkMainWindow::layoutToolbars
void layoutToolbars()
Repositions and resizes toolbars according to current layout settings.
Definition stratoshark_main_window_slots.cpp:284
StratosharkMainWindow::tryClosingCaptureFile
bool tryClosingCaptureFile(QString before_what, FileCloseContext context=Default) override
Attempts to close the current capture file, prompting the user to save if there are unsaved changes.
Definition stratoshark_main_window.cpp:1738
StratosharkMainWindow::setFunnelMenus
void setFunnelMenus(void)
Rebuilds the Lua funnel statistics menus from registered funnel entries.
Definition stratoshark_main_window.cpp:2724
StratosharkMainWindow::applyFilter
void applyFilter(QString new_filter=QString(), bool force=false) override
Applies a new display filter to the open capture file.
Definition stratoshark_main_window_slots.cpp:271
StratosharkMainWindow::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *event) override
Accepts drag-enter events for capture files dragged onto the window.
Definition stratoshark_main_window.cpp:969
StratosharkMainWindow::event
bool event(QEvent *event) override
Handles window-level events such as activation changes.
Definition stratoshark_main_window.cpp:863
StratosharkMainWindow::captureFileOpened
void captureFileOpened()
Updates UI state when a capture file is first opened.
Definition stratoshark_main_window_slots.cpp:718
StratosharkMainWindow::MainApplication
friend class MainApplication
Friend class allowing access to private members.
Definition stratoshark_main_window.h:1051
StratosharkMainWindow::updateForUnsavedChanges
void updateForUnsavedChanges()
Updates title bar, menus, and status bar to reflect unsaved changes.
Definition stratoshark_main_window.cpp:2420
StratosharkMainWindow::captureFileClosed
void captureFileClosed()
Resets UI state after a capture file has been fully closed.
Definition stratoshark_main_window_slots.cpp:778
StratosharkMainWindow::updatePreferenceActions
void updatePreferenceActions()
Refreshes menu items that reflect preference values.
Definition stratoshark_main_window_slots.cpp:335
StratosharkMainWindow::keyPressEvent
void keyPressEvent(QKeyEvent *event) override
Handles key press events for global keyboard shortcuts.
Definition stratoshark_main_window.cpp:877
StratosharkMainWindow::packetInfoChanged
void packetInfoChanged(struct _packet_info *pinfo)
Emitted when the selected packet changes, providing the new packet info.
StratosharkMainWindow::getMwFileName
QString getMwFileName()
Returns the file path currently shown in the main window title bar.
Definition stratoshark_main_window.cpp:2758
StratosharkMainWindow::addInterfaceToolbar
void addInterfaceToolbar(const iface_toolbar *toolbar_entry)
Adds an interface toolbar for the given toolbar descriptor.
Definition stratoshark_main_window.cpp:752
StratosharkMainWindow::showCaptureOptionsDialog
void showCaptureOptionsDialog()
Opens the capture options dialog (interface selection, filters, etc.).
Definition stratoshark_main_window_slots.cpp:2742
StratosharkMainWindow::~StratosharkMainWindow
~StratosharkMainWindow()
Destroys the main window and releases all associated resources.
Definition stratoshark_main_window.cpp:701
StratosharkMainWindow::fieldFilterChanged
void fieldFilterChanged(const QByteArray field_filter)
Emitted when the field-based display filter changes.
StratosharkMainWindow::openCaptureFile
bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type, bool is_tempfile=false)
Open a capture file.
Definition stratoshark_main_window_slots.cpp:162
StratosharkMainWindow::setTitlebarForCaptureFile
void setTitlebarForCaptureFile()
Updates the window title bar to reflect the current capture file name and state.
Definition stratoshark_main_window.cpp:2274
StratosharkMainWindow::setDissectedCaptureFile
void setDissectedCaptureFile(capture_file *cf)
Emitted when a dissected capture file becomes the active file.
StratosharkMainWindow::openCaptureFile
bool openCaptureFile(QString cf_path=QString(), QString display_filter=QString())
Convenience overload that auto-detects file type.
Definition stratoshark_main_window.h:505
StratosharkMainWindow::updateRecentActions
void updateRecentActions()
Rebuilds the File → Open Recent submenu from the recent-files list.
Definition stratoshark_main_window_slots.cpp:349
StratosharkMainWindow::changeEvent
void changeEvent(QEvent *event) override
Responds to locale or palette changes by retranslating the UI.
Definition stratoshark_main_window.cpp:2425
StratosharkMainWindow::createPopupMenu
QMenu * createPopupMenu() override
Creates and returns the window's right-click popup menu.
Definition stratoshark_main_window.cpp:723
StratosharkMainWindow::removeInterfaceToolbar
void removeInterfaceToolbar(const char *menu_title)
Removes the interface toolbar with the given menu title.
Definition stratoshark_main_window.cpp:793
StratosharkMainWindow::StratosharkMainWindow
StratosharkMainWindow(QWidget *parent=nullptr)
Constructs the Stratoshark main window and initialises all menus, toolbars, and UI components.
Definition stratoshark_main_window.cpp:319
StratosharkMainWindow::captureFileClosing
void captureFileClosing()
Updates UI state while a capture file is being closed.
Definition stratoshark_main_window_slots.cpp:763
StratosharkMainWindow::dropEvent
void dropEvent(QDropEvent *event) override
Opens a capture file dropped onto the window.
Definition stratoshark_main_window.cpp:1000
StratosharkMainWindow::closePacketDialogs
void closePacketDialogs()
Emitted to request that all packet-detail dialogs close themselves.
StratosharkMainWindow::openRecentCaptureFile
void openRecentCaptureFile(const QString &filename) override
Opens the given recent capture file, handling any necessary prompts.
Definition stratoshark_main_window_slots.cpp:958
StratosharkMainWindow::reloadFields
void reloadFields()
Emitted to request that all views reload their field definitions.
StratosharkMainWindow::removeAdditionalToolbar
void removeAdditionalToolbar(QString toolbarName)
Removes an additional (plugin/interface) toolbar by name.
Definition stratoshark_main_window.cpp:2729
StratosharkMainWindow::captureFileReadFinished
void captureFileReadFinished()
Updates UI state after a capture file has been fully read.
Definition stratoshark_main_window_slots.cpp:740
StratosharkMainWindow::closeEvent
void closeEvent(QCloseEvent *event) override
Prompts the user to save unsaved changes before closing the window.
Definition stratoshark_main_window.cpp:917
StratosharkMainWindow::eventFilter
bool eventFilter(QObject *obj, QEvent *event) override
Filters events on watched objects (e.g. focus changes on child widgets).
Definition stratoshark_main_window.cpp:845
WiresharkApplication
Top-level Qt application object for the Wireshark GUI.
Definition wireshark_application.h:19
display_filter_entry.h
field_information.h
export_type_e
export_type_e
Output format for packet data export operations.
Definition file_dialog.h:32
iface_toolbar.h
iface_toolbar
struct _iface_toolbar iface_toolbar
Describes an interface toolbar and the set of controls it exposes.
io_graph_item_unit_t
io_graph_item_unit_t
Selects the Y-axis value unit or aggregate calculation mode for an I/O graph plot.
Definition io_graph_item.h:29
main_window.h
plugin_if.h
ext_menu_t
ext_menubar_t ext_menu_t
Definition plugin_if.h:65
_packet_info
Represents the metadata and indexing information for a single captured frame.
Definition packet_info.h:43
timestamp.h
ts_precision
ts_precision
Sub-second precision used when formatting packet timestamps.
Definition timestamp.h:41
ts_type
ts_type
Format used to display packet timestamps in the summary packet list.
Definition timestamp.h:22
ws_ui_util.h