Wireshark 5.1.0
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
48
49#include <epan/timestamp.h>
50
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"
66#include "main_window.h"
67
68class AccordionFrame;
69class DataSourceTab;
70class CaptureOptionsDialog;
71class PrintDialog;
72class FileSetDialog;
73class FilterDialog;
76class PacketList;
78class ProtoTree;
81
82class QAction;
83class QActionGroup;
84
85namespace Ui {
86 class StratosharkMainWindow;
87}
88
89Q_DECLARE_METATYPE(ts_type)
90Q_DECLARE_METATYPE(ts_precision)
91
92
98{
99 Q_OBJECT
100
101public:
107 explicit StratosharkMainWindow(QWidget *parent = nullptr);
108
113
114#ifdef HAVE_LIBPCAP
119 capture_session *captureSession() { return &cap_session_; }
120
125 info_data_t *captureInfoData() { return &info_data_; }
126#endif
127
132 QMenu *createPopupMenu() override;
133
137 void setFunnelMenus(void);
138
143 void removeAdditionalToolbar(QString toolbarName);
144
149 void addInterfaceToolbar(const iface_toolbar *toolbar_entry);
150
155 void removeInterfaceToolbar(const char *menu_title);
156
161 QString getMwFileName();
162
167 void setMwFileName(QString fileName);
168
169protected:
176 bool eventFilter(QObject *obj, QEvent *event) override;
177
183 bool event(QEvent *event) override;
184
189 void keyPressEvent(QKeyEvent *event) override;
190
195 void closeEvent(QCloseEvent *event) override;
196
201 void dragEnterEvent(QDragEnterEvent *event) override;
202
207 void dropEvent(QDropEvent *event) override;
208
213 void changeEvent(QEvent *event) override;
214
219 void openRecentCaptureFile(const QString &filename) override;
220
228 bool tryClosingCaptureFile(QString before_what, FileCloseContext context = Default) override;
229
230private:
235 enum MatchSelected {
236 MatchSelectedReplace,
237 MatchSelectedAnd,
238 MatchSelectedOr,
239 MatchSelectedNot,
240 MatchSelectedAndNot,
241 MatchSelectedOrNot
242 };
243
244 Ui::StratosharkMainWindow *main_ui_;
245 QFont mono_font_;
246 QWidget *previous_focus_;
247 FileSetDialog *file_set_dialog_;
248 QActionGroup *show_hide_actions_;
249 QAction *appearance_mode_spacer_ = nullptr;
250 QActionGroup *time_display_actions_;
251 QActionGroup *time_precision_actions_;
252 FunnelStatistics *funnel_statistics_;
253 QList<QPair<QAction *, bool>> freeze_actions_;
254 QPointer<QWidget> freeze_focus_;
255 QPointer<PreferencesDialog> preferences_dialog_;
256 QMap<QAction *, ts_type> td_actions;
257 QMap<QAction *, ts_precision> tp_actions;
258 bool was_maximized_;
259
260 QString mwFileName_;
261
262 bool capture_stopping_;
263 bool capture_filter_valid_;
264#ifdef HAVE_LIBPCAP
265 capture_session cap_session_;
266 CaptureOptionsDialog *capture_options_dialog_;
267 info_data_t info_data_;
268#endif
269
270 QPoint dragStartPosition;
271
275 void freeze();
276
280 void thaw();
281
286 void mergeCaptureFile();
287
292 void importCaptureFile();
293
300 bool saveCaptureFile(capture_file *cf, bool dont_reopen);
301
310 bool saveAsCaptureFile(capture_file *cf, bool must_support_comments = false, bool dont_reopen = false);
311
316 void exportSelectedPackets();
317
322 void exportDissections(export_type_e export_type);
323
324#ifdef Q_OS_WIN
332 void fileAddExtension(QString &file_name, int file_type, ws_compression_type compression_type);
333#endif
334
338 void captureStop();
339
341 void initMainToolbarIcons();
342
344 void updateMainToolbarIconSize();
345
350 void cycleAppearanceMode();
351
353 void updateAppearanceModeAction();
354
356 void updateAppearanceModeButton();
357
359 void initShowHideMainWidgets();
360
362 void initTimeDisplayFormatMenu();
363
365 void initTimePrecisionFormatMenu();
366
368 void initFreezeActions();
369
374 void setMenusForCaptureFile(bool force_disable = false) override;
375
380 void setMenusForCaptureInProgress(bool capture_in_progress = false);
381
383 void setMenusForCaptureStopping();
384
389 void setForCapturedPackets(bool have_captured_packets);
390
395 void setMenusForFileSet(bool enable_list_files);
396
400 void updateStyleSheet();
401
408 void externalMenuHelper(ext_menu_t *menu, QMenu *subMenu, int depth);
409
417 void setForCaptureInProgress(bool capture_in_progress = false, bool handle_toolbars = false, GArray *ifaces = NULL);
418
426 QMenu *findOrAddMenu(QMenu *parent_menu, const QStringList &menu_parts);
427
432 void captureFileReadStarted(const QString &action);
433
439 void addMenuActions(QList<QAction *> &actions, int menu_group);
440
446 void removeMenuActions(QList<QAction *> &actions, int menu_group);
447
453 void goToConversationFrame(bool go_next, bool start_current = true);
454
460 void colorizeWithFilter(QByteArray filter, int color_number = -1);
461
462signals:
468
471
474
479 void packetInfoChanged(struct _packet_info *pinfo);
480
485 void fieldFilterChanged(const QByteArray field_filter);
486
487#ifdef HAVE_LIBPCAP
493 void showExtcapOptions(QString &device_name, bool startCaptureOnClose);
494#endif
495
496public slots:
497 // Qt lets you connect signals and slots using functors (new, manual style)
498 // and strings (old style). Functors are preferred since they're connected at
499 // compile time and less error prone.
500 //
501 // If you're manually connecting a signal to a slot, don't prefix its name
502 // with "on_". Otherwise Qt will try to automatically connect it and you'll
503 // get runtime warnings.
504
505 // in main_window_slots.cpp
506
515 bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type, bool is_tempfile = false);
516
523 bool openCaptureFile(QString cf_path = QString(), QString display_filter = QString()) { return openCaptureFile(cf_path, display_filter, WTAP_TYPE_AUTO); }
524
527
529 void layoutToolbars();
530
533
535 void updateRecentActions();
536
539
542
543#ifdef HAVE_LIBPCAP
548 void captureCapturePrepared(capture_session *session);
549
554 void captureCaptureUpdateStarted(capture_session *session);
555
560 void captureCaptureUpdateFinished(capture_session *session);
561
565 void captureCaptureFixedFinished(capture_session *);
566
570 void captureCaptureFailed(capture_session *);
571#endif
572
574 void captureFileOpened();
575
582
584 void captureFileClosing();
585
587 void captureFileClosed();
588
589#ifdef HAVE_LUA
591 void openLuaDebuggerDialog();
592#endif
593
594protected slots:
600 void applyFilter(QString new_filter = QString(), bool force = false) override;
601
602private slots:
610 void onAppInitialized();
611
616 void captureEventHandler(CaptureEvent ev);
617
619 void initViewColorizeMenu();
620
622 void initConversationMenus();
623
631 static bool addFollowStreamMenuItem(const void *key, void *value, void *userdata);
632
634 void initFollowStreamMenus();
635
636 // in main_window_slots.cpp
641 void startCapture(QStringList);
642
644 void startCapture();
645
647 void pushLiveCaptureInProgress();
648
650 void popLiveCaptureInProgress();
651
653 void stopCapture();
654
656 void loadWindowGeometry();
657
659 void saveWindowGeometry();
660
664 void mainStackChanged(int);
665
667 void updateRecentCaptures();
668
670 void addPacketComment();
671
673 void editPacketComment();
674
676 void deletePacketComment();
677
679 void deleteCommentsFromPackets();
680
687 QString commentToMenuText(QString text, int max_len = 40);
688
690 void setEditCommentsMenu();
691
693 void setMenusForSelectedPacket();
694
699 void setMenusForSelectedTreeRow(FieldInformation *fi = NULL);
700
702 void interfaceSelectionChanged();
703
708 void captureFilterSyntaxChanged(bool valid);
709
711 void redissectPackets();
712
714 void checkDisplayFilter();
715
717 void fieldsChanged();
718
720 void reloadLuaPlugins();
721
727 void showAccordionFrame(AccordionFrame *show_frame, bool toggle = false);
728
733 void showColumnEditor(int column);
734
736 void showPreferenceEditor();
737
739 void addStatsPluginsToMenu();
740
742 void addDynamicMenus();
743
745 void reloadDynamicMenus();
746
748 void addPluginIFStructures();
749
755 QMenu *searchSubMenu(QString objectName);
756
760 void activatePluginIFToolbar(bool);
761
767 void startInterfaceCapture(bool valid, const QString capture_filter);
768
771 void applyGlobalCommandLineOptions();
772
777 void setFeaturesEnabled(bool enabled = true);
778
780 void on_actionNewDisplayFilterExpression_triggered();
781
787 void onFilterSelected(QString filterText, bool prepare);
788
790 void onFilterPreferences();
791
796 void onFilterEdit(int uatIndex);
797
804 void queuedFilterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);
805
812 void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
813
820 void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
821
823 void openTapParameterDialog();
824
826 void connectFileMenuActions();
827
829 void printFile();
830
832 void connectEditMenuActions();
833
838 void copySelectedItems(StratosharkMainWindow::CopySelected selection_type);
839
841 void findPacket();
842
844 void editTimeShift();
845
847 void editConfigurationProfiles();
848
852 void editTimeShiftFinished(int);
853
859 void addPacketCommentFinished(PacketCommentDialog *pc_dialog, int result);
860
867 void editPacketCommentFinished(PacketCommentDialog *pc_dialog, int result, unsigned nComment);
868
870 void deleteAllPacketComments();
871
876 void deleteAllPacketCommentsFinished(int result);
877
882 void showPreferencesDialog(QString module_name) override;
883
885 void connectViewMenuActions();
886
891 void showHideMainWidgets(QAction *action);
892
897 void setTimestampFormat(QAction *action);
898
903 void setTimestampPrecision(QAction *action);
904
909 void setTimeDisplaySecondsWithHoursAndMinutes(bool checked);
910
912 void editResolvedName();
913
915 void setNameResolution();
916
917
919 void showColoringRulesDialog();
920
922 void showTaggingRulesDialog();
923
929 void colorizeConversation(bool create_rule = false);
930
932 void colorizeActionTriggered();
933
938 void openPacketDialog(bool from_reference = false);
939
941 void reloadCaptureFileAsFormatOrCapture();
942
944 void reloadCaptureFile();
945
947 void connectGoMenuActions();
948
950 void setPreviousFocus();
951
953 void resetPreviousFocus();
954
956 void connectCaptureMenuActions();
957
959 void startCaptureTriggered();
960
962 void connectAnalyzeMenuActions();
963
970 void matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type);
971
973 void applyFieldAsColumn();
974
976 void filterMenuAboutToShow();
977
979 void applyConversationFilter();
980
988 void openFollowStreamDialog(int proto_id, unsigned stream_num, unsigned sub_stream_num, bool use_stream_index = true);
989
994 void openFollowStreamDialog(int proto_id);
995
999 void statCommandExpertInfo(const char *, void *);
1000
1002 void connectToolsMenuActions();
1003
1005 void connectHelpMenuActions();
1006
1008 void goToCancelClicked();
1009
1011 void goToGoClicked();
1012
1014 void goToLineEditReturnPressed();
1015
1017 void connectStatisticsMenuActions();
1018
1020 void showResolvedAddressesDialog();
1021
1023 void showConversationsDialog();
1024
1026 void showEndpointsDialog();
1027
1032 void openStatisticsTreeDialog(const char *abbr);
1033
1037 void statCommandIOGraph(const char *, void *);
1038
1044 void showIOGraphDialog(io_graph_item_unit_t value_units, QString yfield) override;
1045
1051 void showPlotDialog(const QString &y_field = QString(), bool filtered = false) override;
1052
1059 void showIOGraphDialogForFilters(const QString &displayFilter,
1060 const QVector<QString> &filters,
1061 const QVector<QString> &names = QVector<QString>()) override;
1062
1064 void externalMenuItemTriggered();
1065
1067 void on_actionContextWikiProtocolPage_triggered();
1068
1070 void on_actionContextFilterFieldReference_triggered();
1071
1076 void extcap_options_finished(int result);
1077
1083 void showExtcapOptionsDialog(QString device_name, bool startCaptureOnClose);
1084
1086 friend class MainApplication;
1087};
struct _info_data info_data_t
Aggregates packet count statistics and UI state for a live capture info display.
struct _capture_session capture_session
Opaque handle representing an active or pending capture session.
struct _capture_file capture_file
Represents a capture file and its associated metadata.
A QFrame that shows and hides itself with a slide animation.
Definition accordion_frame.h:21
Represents an event occurring during a capture or file operation.
Definition capture_event.h:24
Context
Defines the operational context of the event.
Definition capture_event.h:29
A tab widget that manages and displays different data sources for a packet (e.g., Hex,...
Definition data_source_tab.h:36
Represents information about a dissected packet field.
Definition field_information.h:26
A dialog for managing and displaying capture file sets.
Definition file_set_dialog.h:32
Action
Defines an action to be taken with a filter.
Definition filter_action.h:30
ActionType
Defines how the new filter should be combined with the existing one.
Definition filter_action.h:43
A dialog for managing and editing capture filters, display filters, and display macros.
Definition filter_dialog.h:31
A toolbar that displays filter expressions and supports drag-and-drop operations.
Definition filter_expression_toolbar.h:21
Manages statistics and user interface interactions for Lua-based funnel plugins.
Definition funnel_statistics.h:35
CopySelected
Enumeration for determining what to copy when items are selected.
Definition main_window.h:255
MainWindow(QWidget *parent=nullptr)
Constructs a new MainWindow.
Definition main_window.cpp:51
FileCloseContext
Context under which a capture file is being closed.
Definition main_window.h:279
@ Default
Default closing context.
Definition main_window.h:281
Dialog for viewing or editing a packet comment.
Definition packet_comment_dialog.h:23
The main packet list view for displaying captured packets.
Definition packet_list.h:52
Dialog for configuring Wireshark preferences.
Definition preferences_dialog.h:33
Dialog that provides packet print and print-preview functionality for a live or saved capture file.
Definition print_dialog.h:31
A tree view for displaying protocol dissection details.
Definition proto_tree.h:30
void setMwFileName(QString fileName)
Sets the file path shown in the main window title bar.
Definition stratoshark_main_window.cpp:2876
void layoutToolbars()
Repositions and resizes toolbars according to current layout settings.
Definition stratoshark_main_window_slots.cpp:287
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:1782
void setFunnelMenus(void)
Rebuilds the Lua funnel statistics menus from registered funnel entries.
Definition stratoshark_main_window.cpp:2837
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:274
void dragEnterEvent(QDragEnterEvent *event) override
Accepts drag-enter events for capture files dragged onto the window.
Definition stratoshark_main_window.cpp:1013
bool event(QEvent *event) override
Handles window-level events such as activation changes.
Definition stratoshark_main_window.cpp:907
void captureFileOpened()
Updates UI state when a capture file is first opened.
Definition stratoshark_main_window_slots.cpp:724
friend class MainApplication
Friend class allowing access to private members.
Definition stratoshark_main_window.h:1086
void updateForUnsavedChanges()
Updates title bar, menus, and status bar to reflect unsaved changes.
Definition stratoshark_main_window.cpp:2533
void captureFileClosed()
Resets UI state after a capture file has been fully closed.
Definition stratoshark_main_window_slots.cpp:784
void updatePreferenceActions()
Refreshes menu items that reflect preference values.
Definition stratoshark_main_window_slots.cpp:338
void keyPressEvent(QKeyEvent *event) override
Handles key press events for global keyboard shortcuts.
Definition stratoshark_main_window.cpp:921
void packetInfoChanged(struct _packet_info *pinfo)
Emitted when the selected packet changes, providing the new packet info.
QString getMwFileName()
Returns the file path currently shown in the main window title bar.
Definition stratoshark_main_window.cpp:2871
void addInterfaceToolbar(const iface_toolbar *toolbar_entry)
Adds an interface toolbar for the given toolbar descriptor.
Definition stratoshark_main_window.cpp:796
void showCaptureOptionsDialog()
Opens the capture options dialog (interface selection, filters, etc.).
Definition stratoshark_main_window_slots.cpp:2820
~StratosharkMainWindow()
Destroys the main window and releases all associated resources.
Definition stratoshark_main_window.cpp:740
void fieldFilterChanged(const QByteArray field_filter)
Emitted when the field-based display filter changes.
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:165
void setTitlebarForCaptureFile()
Updates the window title bar to reflect the current capture file name and state.
Definition stratoshark_main_window.cpp:2387
void setDissectedCaptureFile(capture_file *cf)
Emitted when a dissected capture file becomes the active file.
bool openCaptureFile(QString cf_path=QString(), QString display_filter=QString())
Convenience overload that auto-detects file type.
Definition stratoshark_main_window.h:523
void captureFileReadFinished(CaptureEvent::Context context)
Updates UI state after a capture file has been fully read.
Definition stratoshark_main_window_slots.cpp:746
void updateRecentActions()
Rebuilds the File → Open Recent submenu from the recent-files list.
Definition stratoshark_main_window_slots.cpp:352
void changeEvent(QEvent *event) override
Responds to locale or palette changes by retranslating the UI.
Definition stratoshark_main_window.cpp:2538
QMenu * createPopupMenu() override
Creates and returns the window's right-click popup menu.
Definition stratoshark_main_window.cpp:767
void removeInterfaceToolbar(const char *menu_title)
Removes the interface toolbar with the given menu title.
Definition stratoshark_main_window.cpp:837
StratosharkMainWindow(QWidget *parent=nullptr)
Constructs the Stratoshark main window and initialises all menus, toolbars, and UI components.
Definition stratoshark_main_window.cpp:322
void captureFileClosing()
Updates UI state while a capture file is being closed.
Definition stratoshark_main_window_slots.cpp:769
void dropEvent(QDropEvent *event) override
Opens a capture file dropped onto the window.
Definition stratoshark_main_window.cpp:1044
void closePacketDialogs()
Emitted to request that all packet-detail dialogs close themselves.
void openRecentCaptureFile(const QString &filename) override
Opens the given recent capture file, handling any necessary prompts.
Definition stratoshark_main_window_slots.cpp:964
void reloadFields()
Emitted to request that all views reload their field definitions.
void removeAdditionalToolbar(QString toolbarName)
Removes an additional (plugin/interface) toolbar by name.
Definition stratoshark_main_window.cpp:2842
void closeEvent(QCloseEvent *event) override
Prompts the user to save unsaved changes before closing the window.
Definition stratoshark_main_window.cpp:961
bool eventFilter(QObject *obj, QEvent *event) override
Filters events on watched objects (e.g. focus changes on child widgets).
Definition stratoshark_main_window.cpp:889
Top-level Qt application object for the Wireshark GUI.
Definition wireshark_application.h:19
export_type_e
Output format for packet data export operations.
Definition file_dialog.h:32
struct _iface_toolbar iface_toolbar
Describes an interface toolbar and the set of controls it exposes.
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
ext_menubar_t ext_menu_t
Definition plugin_if.h:65
Represents the metadata and indexing information for a single captured frame.
Definition packet_info.h:43
ts_precision
Sub-second precision used when formatting packet timestamps.
Definition timestamp.h:41
ts_type
Format used to display packet timestamps in the summary packet list.
Definition timestamp.h:22