Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
stratoshark_main_window.h
Go to the documentation of this file.
1
10#pragma once
11
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;
77class ProtoTree;
80
81class QAction;
82class QActionGroup;
83
84namespace Ui {
86}
87
88Q_DECLARE_METATYPE(ts_type)
89Q_DECLARE_METATYPE(ts_precision)
90
91
97{
98 Q_OBJECT
99
100public:
106 explicit StratosharkMainWindow(QWidget *parent = nullptr);
107
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
138
142 void setFunnelMenus(void);
143
148 void removeAdditionalToolbar(QString toolbarName);
149
154 void addInterfaceToolbar(const iface_toolbar *toolbar_entry);
155
160 void removeInterfaceToolbar(const char *menu_title);
161
166 QString getMwFileName();
167
172 void setMwFileName(QString fileName);
173
174protected:
181 bool eventFilter(QObject *obj, QEvent *event) override;
182
188 bool event(QEvent *event) override;
189
194 void keyPressEvent(QKeyEvent *event) override;
195
200 void closeEvent(QCloseEvent *event) override;
201
206 void dragEnterEvent(QDragEnterEvent *event) override;
207
212 void dropEvent(QDropEvent *event) override;
213
218 void changeEvent(QEvent *event) override;
219
224 void openRecentCaptureFile(const QString &filename) override;
225
233 bool tryClosingCaptureFile(QString before_what, FileCloseContext context = Default) override;
234
235private:
240 enum MatchSelected {
241 MatchSelectedReplace,
242 MatchSelectedAnd,
243 MatchSelectedOr,
244 MatchSelectedNot,
245 MatchSelectedAndNot,
246 MatchSelectedOrNot
247 };
248
249 Ui::StratosharkMainWindow *main_ui_;
250 QFont mono_font_;
251 QWidget *previous_focus_;
252 FileSetDialog *file_set_dialog_;
253 QActionGroup *show_hide_actions_;
254 QActionGroup *time_display_actions_;
255 QActionGroup *time_precision_actions_;
256 FunnelStatistics *funnel_statistics_;
257 QList<QPair<QAction *, bool>> freeze_actions_;
258 QPointer<QWidget> freeze_focus_;
259 QMap<QAction *, ts_type> td_actions;
260 QMap<QAction *, ts_precision> tp_actions;
261 bool was_maximized_;
263 QString mwFileName_;
265 bool capture_stopping_;
266 bool capture_filter_valid_;
267#ifdef HAVE_LIBPCAP
268 capture_session cap_session_;
269 CaptureOptionsDialog *capture_options_dialog_;
270 info_data_t info_data_;
271#endif
272
273 QPoint dragStartPosition;
278 void freeze();
279
283 void thaw();
284
289 void mergeCaptureFile();
290
295 void importCaptureFile();
296
303 bool saveCaptureFile(capture_file *cf, bool dont_reopen);
304
313 bool saveAsCaptureFile(capture_file *cf, bool must_support_comments = false, bool dont_reopen = false);
314
319 void exportSelectedPackets();
320
325 void exportDissections(export_type_e export_type);
326
327#ifdef Q_OS_WIN
335 void fileAddExtension(QString &file_name, int file_type, ws_compression_type compression_type);
336#endif
337
341 void captureStop();
342
344 void initMainToolbarIcons();
345
347 void initShowHideMainWidgets();
348
350 void initTimeDisplayFormatMenu();
351
353 void initTimePrecisionFormatMenu();
354
356 void initFreezeActions();
357
362 void setMenusForCaptureFile(bool force_disable = false) override;
363
368 void setMenusForCaptureInProgress(bool capture_in_progress = false);
369
371 void setMenusForCaptureStopping();
372
377 void setForCapturedPackets(bool have_captured_packets);
378
383 void setMenusForFileSet(bool enable_list_files);
384
388 void updateStyleSheet();
389
396 void externalMenuHelper(ext_menu_t *menu, QMenu *subMenu, int depth);
397
405 void setForCaptureInProgress(bool capture_in_progress = false, bool handle_toolbars = false, GArray *ifaces = NULL);
406
414 QMenu *findOrAddMenu(QMenu *parent_menu, const QStringList &menu_parts);
415
420 void captureFileReadStarted(const QString &action);
421
427 void addMenuActions(QList<QAction *> &actions, int menu_group);
428
434 void removeMenuActions(QList<QAction *> &actions, int menu_group);
435
441 void goToConversationFrame(bool go_next, bool start_current = true);
442
448 void colorizeWithFilter(QByteArray filter, int color_number = -1);
449
450signals:
456
459
462
467 void packetInfoChanged(struct _packet_info *pinfo);
468
473 void fieldFilterChanged(const QByteArray field_filter);
474
475#ifdef HAVE_LIBPCAP
481 void showExtcapOptions(QString &device_name, bool startCaptureOnClose);
482#endif
483
484public slots:
485 // Qt lets you connect signals and slots using functors (new, manual style)
486 // and strings (old style). Functors are preferred since they're connected at
487 // compile time and less error prone.
488 //
489 // If you're manually connecting a signal to a slot, don't prefix its name
490 // with "on_". Otherwise Qt will try to automatically connect it and you'll
491 // get runtime warnings.
492
493 // in main_window_slots.cpp
494
503 bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type, bool is_tempfile = false);
504
511 bool openCaptureFile(QString cf_path = QString(), QString display_filter = QString()) { return openCaptureFile(cf_path, display_filter, WTAP_TYPE_AUTO); }
512
518 void filterPackets(QString new_filter = QString(), bool force = false) override;
519
522
524 void layoutToolbars();
525
528
530 void updateRecentActions();
531
534
537
538#ifdef HAVE_LIBPCAP
543 void captureCapturePrepared(capture_session *session);
544
549 void captureCaptureUpdateStarted(capture_session *session);
550
555 void captureCaptureUpdateFinished(capture_session *session);
556
560 void captureCaptureFixedFinished(capture_session *);
561
565 void captureCaptureFailed(capture_session *);
566#endif
567
569 void captureFileOpened();
570
573
575 void captureFileClosing();
576
578 void captureFileClosed();
579
580#ifdef HAVE_LUA
582 void openLuaDebuggerDialog();
583#endif
584
585private slots:
590 void captureEventHandler(CaptureEvent ev);
591
593 void initViewColorizeMenu();
594
596 void initConversationMenus();
597
605 static bool addFollowStreamMenuItem(const void *key, void *value, void *userdata);
606
608 void initFollowStreamMenus();
609
610 // in main_window_slots.cpp
615 void startCapture(QStringList);
616
618 void startCapture();
619
621 void pushLiveCaptureInProgress();
622
624 void popLiveCaptureInProgress();
625
627 void stopCapture();
628
630 void loadWindowGeometry();
631
633 void saveWindowGeometry();
634
638 void mainStackChanged(int);
639
641 void updateRecentCaptures();
642
644 void addPacketComment();
645
647 void editPacketComment();
648
650 void deletePacketComment();
651
653 void deleteCommentsFromPackets();
654
661 QString commentToMenuText(QString text, int max_len = 40);
662
664 void setEditCommentsMenu();
665
667 void setMenusForSelectedPacket();
668
673 void setMenusForSelectedTreeRow(FieldInformation *fi = NULL);
674
676 void interfaceSelectionChanged();
677
682 void captureFilterSyntaxChanged(bool valid);
683
685 void redissectPackets();
686
688 void checkDisplayFilter();
689
691 void fieldsChanged();
692
694 void reloadLuaPlugins();
695
701 void showAccordionFrame(AccordionFrame *show_frame, bool toggle = false);
702
707 void showColumnEditor(int column);
708
710 void showPreferenceEditor();
711
713 void addStatsPluginsToMenu();
714
716 void addDynamicMenus();
717
719 void reloadDynamicMenus();
720
722 void addPluginIFStructures();
723
729 QMenu *searchSubMenu(QString objectName);
730
734 void activatePluginIFToolbar(bool);
735
741 void startInterfaceCapture(bool valid, const QString capture_filter);
742
745 void applyGlobalCommandLineOptions();
746
751 void setFeaturesEnabled(bool enabled = true);
752
754 void on_actionNewDisplayFilterExpression_triggered();
755
761 void onFilterSelected(QString filterText, bool prepare);
762
764 void onFilterPreferences();
765
770 void onFilterEdit(int uatIndex);
771
778 void queuedFilterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);
779
786 void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
787
794 void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
795
797 void openTapParameterDialog();
798
800 void connectFileMenuActions();
801
803 void printFile();
804
806 void connectEditMenuActions();
807
812 void copySelectedItems(StratosharkMainWindow::CopySelected selection_type);
813
815 void findPacket();
816
818 void editTimeShift();
819
821 void editConfigurationProfiles();
822
826 void editTimeShiftFinished(int);
827
833 void addPacketCommentFinished(PacketCommentDialog *pc_dialog, int result);
834
841 void editPacketCommentFinished(PacketCommentDialog *pc_dialog, int result, unsigned nComment);
842
844 void deleteAllPacketComments();
845
850 void deleteAllPacketCommentsFinished(int result);
851
856 void showPreferencesDialog(QString module_name) override;
857
859 void connectViewMenuActions();
860
865 void showHideMainWidgets(QAction *action);
866
871 void setTimestampFormat(QAction *action);
872
877 void setTimestampPrecision(QAction *action);
878
883 void setTimeDisplaySecondsWithHoursAndMinutes(bool checked);
884
886 void editResolvedName();
887
889 void setNameResolution();
890
894 void zoomText();
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};
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
Manages a capture file and its associated state and operations.
Definition capture_file.h:27
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
Core application class handling global state, signals, and configurations.
Definition main_application.h:39
The main window of the application.
Definition main_window.h:51
CopySelected
Enumeration for determining what to copy when items are selected.
Definition main_window.h:211
CaptureFile capture_file_
Definition main_window.h:278
FileCloseContext
Context under which a capture file is being closed.
Definition main_window.h:235
@ Default
Default closing context.
Definition main_window.h:237
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:45
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
Stratoshark main application window, extending MainWindow with Stratoshark-specific menus,...
Definition stratoshark_main_window.h:97
CaptureFile * captureFile()
Returns a pointer to the current capture file object.
Definition stratoshark_main_window.h:137
void setMwFileName(QString fileName)
Sets the file path shown in the main window title bar.
Definition stratoshark_main_window.cpp:2776
void layoutToolbars()
Repositions and resizes toolbars according to current layout settings.
Definition stratoshark_main_window_slots.cpp:295
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:1748
void setFunnelMenus(void)
Rebuilds the Lua funnel statistics menus from registered funnel entries.
Definition stratoshark_main_window.cpp:2737
void dragEnterEvent(QDragEnterEvent *event) override
Accepts drag-enter events for capture files dragged onto the window.
Definition stratoshark_main_window.cpp:979
bool event(QEvent *event) override
Handles window-level events such as activation changes.
Definition stratoshark_main_window.cpp:873
void captureFileOpened()
Updates UI state when a capture file is first opened.
Definition stratoshark_main_window_slots.cpp:729
void updateForUnsavedChanges()
Updates title bar, menus, and status bar to reflect unsaved changes.
Definition stratoshark_main_window.cpp:2433
void captureFileClosed()
Resets UI state after a capture file has been fully closed.
Definition stratoshark_main_window_slots.cpp:789
void updatePreferenceActions()
Refreshes menu items that reflect preference values.
Definition stratoshark_main_window_slots.cpp:346
void keyPressEvent(QKeyEvent *event) override
Handles key press events for global keyboard shortcuts.
Definition stratoshark_main_window.cpp:887
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:2771
void addInterfaceToolbar(const iface_toolbar *toolbar_entry)
Adds an interface toolbar for the given toolbar descriptor.
Definition stratoshark_main_window.cpp:759
void filterPackets(QString new_filter=QString(), bool force=false) override
Applies a new display filter to the open capture file.
Definition stratoshark_main_window_slots.cpp:269
void showCaptureOptionsDialog()
Opens the capture options dialog (interface selection, filters, etc.).
Definition stratoshark_main_window_slots.cpp:2740
~StratosharkMainWindow()
Destroys the main window and releases all associated resources.
Definition stratoshark_main_window.cpp:708
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:160
void setTitlebarForCaptureFile()
Updates the window title bar to reflect the current capture file name and state.
Definition stratoshark_main_window.cpp:2284
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:511
void updateRecentActions()
Rebuilds the File → Open Recent submenu from the recent-files list.
Definition stratoshark_main_window_slots.cpp:360
void changeEvent(QEvent *event) override
Responds to locale or palette changes by retranslating the UI.
Definition stratoshark_main_window.cpp:2438
QMenu * createPopupMenu() override
Creates and returns the window's right-click popup menu.
Definition stratoshark_main_window.cpp:730
void removeInterfaceToolbar(const char *menu_title)
Removes the interface toolbar with the given menu title.
Definition stratoshark_main_window.cpp:802
void captureFileClosing()
Updates UI state while a capture file is being closed.
Definition stratoshark_main_window_slots.cpp:774
void dropEvent(QDropEvent *event) override
Opens a capture file dropped onto the window.
Definition stratoshark_main_window.cpp:1010
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:969
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:2742
void captureFileReadFinished()
Updates UI state after a capture file has been fully read.
Definition stratoshark_main_window_slots.cpp:751
void closeEvent(QCloseEvent *event) override
Prompts the user to save unsaved changes before closing the window.
Definition stratoshark_main_window.cpp:927
bool eventFilter(QObject *obj, QEvent *event) override
Filters events on watched objects (e.g. focus changes on child widgets).
Definition stratoshark_main_window.cpp:855
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
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
Represents a capture file and its associated metadata.
Definition cfile.h:84
Opaque handle representing an active or pending capture session.
Definition capture_session.h:142
Represents a node in the plugin-registered menubar tree (menu, item, separator, or URL).
Definition plugin_if.h:72
Describes an interface toolbar and the set of controls it exposes.
Definition iface_toolbar.h:75
Definition capture_info.h:40
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:43
ts_type
Format used to display packet timestamps in the summary packet list.
Definition timestamp.h:22