| 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
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_combo.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
91class StratosharkMainWindow : public MainWindow
92{
93 Q_OBJECT
94
95 public:
96 explicit StratosharkMainWindow(QWidget *parent = nullptr);
97 ~StratosharkMainWindow();
98
99#ifdef HAVE_LIBPCAP
100 capture_session *captureSession() { return &cap_session_; }
101 info_data_t *captureInfoData() { return &info_data_; }
102#endif
103
104 QMenu *createPopupMenu() override;
105
106 CaptureFile *captureFile() { return &capture_file_; }
107
108 void setFunnelMenus(void);
109 void removeAdditionalToolbar(QString toolbarName);
110
111 void addInterfaceToolbar(const iface_toolbar *toolbar_entry);
112 void removeInterfaceToolbar(const char *menu_title);
113
114 QString getMwFileName();
115 void setMwFileName(QString fileName);
116
117 protected:
118 bool eventFilter(QObject *obj, QEvent *event) override;
119 bool event(QEvent *event) override;
120 void keyPressEvent(QKeyEvent *event) override;
121 void closeEvent(QCloseEvent *event) override;
122 void dragEnterEvent(QDragEnterEvent *event) override;
123 void dropEvent(QDropEvent *event) override;
124 void changeEvent(QEvent* event) override;
125 void openRecentCaptureFile(const QString &filename) override;
126
127
128 bool tryClosingCaptureFile(QString before_what, FileCloseContext context = Default) override;
129
130 private:
131 // XXX Move to FilterUtils
132 enum MatchSelected {
133 MatchSelectedReplace,
134 MatchSelectedAnd,
135 MatchSelectedOr,
136 MatchSelectedNot,
137 MatchSelectedAndNot,
138 MatchSelectedOrNot
139 };
140
141 Ui::StratosharkMainWindow *main_ui_;
142 QFont mono_font_;
143 QWidget *previous_focus_;
144 FileSetDialog *file_set_dialog_;
145 QActionGroup *show_hide_actions_;
146 QActionGroup *time_display_actions_;
147 QActionGroup *time_precision_actions_;
148 FunnelStatistics *funnel_statistics_;
149 QList<QPair<QAction *, bool> > freeze_actions_;
150 QPointer<QWidget> freeze_focus_;
151 QMap<QAction *, ts_type> td_actions;
152 QMap<QAction *, ts_precision> tp_actions;
153 bool was_maximized_;
154
155 /* the following values are maintained so that the capture file name and status
156 is available when there is no cf structure available */
157 QString mwFileName_;
158
159 bool capture_stopping_;
160 bool capture_filter_valid_;
161#ifdef HAVE_LIBPCAP
162 capture_session cap_session_;
163 CaptureOptionsDialog *capture_options_dialog_;
164 info_data_t info_data_;
165#endif
166
167 QPoint dragStartPosition;
168
169 void freeze();
170 void thaw();
171
172 void mergeCaptureFile();
173 void importCaptureFile();
174 bool saveCaptureFile(capture_file *cf, bool dont_reopen);
175 bool saveAsCaptureFile(capture_file *cf, bool must_support_comments = false, bool dont_reopen = false);
176 void exportSelectedPackets();
177 void exportDissections(export_type_e export_type);
178
179#ifdef Q_OS_WIN
180 void fileAddExtension(QString &file_name, int file_type, ws_compression_type compression_type);
181#endif // Q_OS_WIN
182 void captureStop();
183
184 void initMainToolbarIcons();
185 void initShowHideMainWidgets();
186 void initTimeDisplayFormatMenu();
187 void initTimePrecisionFormatMenu();
188 void initFreezeActions();
189
190 void setMenusForCaptureFile(bool force_disable = false) override;
191 void setMenusForCaptureInProgress(bool capture_in_progress = false);
192 void setMenusForCaptureStopping();
193 void setForCapturedPackets(bool have_captured_packets);
194 void setMenusForFileSet(bool enable_list_files);
195 void updateStyleSheet();
196
197 void externalMenuHelper(ext_menu_t * menu, QMenu * subMenu, int depth);
198
199 void setForCaptureInProgress(bool capture_in_progress = false, bool handle_toolbars = false, GArray *ifaces = NULL);
200 QMenu* findOrAddMenu(QMenu *parent_menu, const QStringList& menu_parts);
201
202 void captureFileReadStarted(const QString &action);
203
204 void addMenuActions(QList<QAction *> &actions, int menu_group);
205 void removeMenuActions(QList<QAction *> &actions, int menu_group);
206 void goToConversationFrame(bool go_next, bool start_current = true);
207 void colorizeWithFilter(QByteArray filter, int color_number = -1);
208
209signals:
210 void setDissectedCaptureFile(capture_file *cf);
211 void closePacketDialogs();
212 void reloadFields();
213 void packetInfoChanged(struct _packet_info *pinfo);
214 void fieldFilterChanged(const QByteArray field_filter);
215
216#ifdef HAVE_LIBPCAP
217 void showExtcapOptions(QString &device_name, bool startCaptureOnClose);
218#endif
219
220 public slots:
221 // Qt lets you connect signals and slots using functors (new, manual style)
222 // and strings (old style). Functors are preferred since they're connected at
223 // compile time and less error prone.
224 //
225 // If you're manually connecting a signal to a slot, don't prefix its name
226 // with "on_". Otherwise Qt will try to automatically connect it and you'll
227 // get runtime warnings.
228
229 // in main_window_slots.cpp
238 // XXX We might want to return a cf_read_status_t or a CaptureFile.
239 bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type, bool is_tempfile = false);
240 bool openCaptureFile(QString cf_path = QString(), QString display_filter = QString()) { return openCaptureFile(cf_path, display_filter, WTAP_TYPE_AUTO); }
241 void filterPackets(QString new_filter = QString(), bool force = false) override;
242 void updateForUnsavedChanges();
243 void layoutToolbars();
244 void updatePreferenceActions();
245 void updateRecentActions();
246
247 void setTitlebarForCaptureFile();
248
249 void showCaptureOptionsDialog();
250
251#ifdef HAVE_LIBPCAP
252 void captureCapturePrepared(capture_session *);
253 void captureCaptureUpdateStarted(capture_session *);
254 void captureCaptureUpdateFinished(capture_session *);
255 void captureCaptureFixedFinished(capture_session *cap_session);
256 void captureCaptureFailed(capture_session *);
257#endif
258
259 void captureFileOpened();
260 void captureFileReadFinished();
261 void captureFileClosing();
262 void captureFileClosed();
263
264#ifdef HAVE_LUA
265 void openLuaDebuggerDialog();
266#endif
267
268 private slots:
269
270 void captureEventHandler(CaptureEvent ev);
271
272 void initViewColorizeMenu();
273 void initConversationMenus();
274 static bool addFollowStreamMenuItem(const void *key, void *value, void *userdata);
275 void initFollowStreamMenus();
276
277 // in main_window_slots.cpp
283 void startCapture(QStringList);
284 void startCapture();
285 void pushLiveCaptureInProgress();
286 void popLiveCaptureInProgress();
287 void stopCapture();
288
289 void loadWindowGeometry();
290 void saveWindowGeometry();
291 void mainStackChanged(int);
292 void updateRecentCaptures();
293 void addPacketComment();
294 void editPacketComment();
295 void deletePacketComment();
296 void deleteCommentsFromPackets();
297 QString commentToMenuText(QString text, int max_len = 40);
298 void setEditCommentsMenu();
299 void setMenusForSelectedPacket();
300 void setMenusForSelectedTreeRow(FieldInformation *fi = NULL);
301 void interfaceSelectionChanged();
302 void captureFilterSyntaxChanged(bool valid);
303 void redissectPackets();
304 void checkDisplayFilter();
305 void fieldsChanged();
306 void reloadLuaPlugins();
307 void showAccordionFrame(AccordionFrame *show_frame, bool toggle = false);
308 void showColumnEditor(int column);
309 void showPreferenceEditor(); // module_t *, pref *
310 void addStatsPluginsToMenu();
311 void addDynamicMenus();
312 void reloadDynamicMenus();
313 void addPluginIFStructures();
314 QMenu * searchSubMenu(QString objectName);
315 void activatePluginIFToolbar(bool);
316
317 void startInterfaceCapture(bool valid, const QString capture_filter);
318
319 void applyGlobalCommandLineOptions();
320 void setFeaturesEnabled(bool enabled = true);
321
322 void on_actionNewDisplayFilterExpression_triggered();
323 void onFilterSelected(QString, bool);
324 void onFilterPreferences();
325 void onFilterEdit(int uatIndex);
326
327 // Handle FilterAction signals
328 void queuedFilterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);
329
335 void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
336
342 void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
343 void openTapParameterDialog();
344
345 void connectFileMenuActions();
346 void printFile();
347
348 void connectEditMenuActions();
349 void copySelectedItems(StratosharkMainWindow::CopySelected selection_type);
350 void findPacket();
351 void editTimeShift();
352 void editConfigurationProfiles();
353 void editTimeShiftFinished(int);
354 void addPacketCommentFinished(PacketCommentDialog* pc_dialog, int result);
355 void editPacketCommentFinished(PacketCommentDialog* pc_dialog, int result, unsigned nComment);
356 void deleteAllPacketComments();
357 void deleteAllPacketCommentsFinished(int result);
358 void showPreferencesDialog(QString module_name) override;
359
360 void connectViewMenuActions();
361 void showHideMainWidgets(QAction *action);
362 void setTimestampFormat(QAction *action);
363 void setTimestampPrecision(QAction *action);
364 void setTimeDisplaySecondsWithHoursAndMinutes(bool checked);
365 void editResolvedName();
366 void setNameResolution();
367 void zoomText();
368 void showColoringRulesDialog();
369 void colorizeConversation(bool create_rule = false);
370 void colorizeActionTriggered();
371 void openPacketDialog(bool from_reference = false);
372 void reloadCaptureFileAsFormatOrCapture();
373 void reloadCaptureFile();
374
375 void connectGoMenuActions();
376
377 void setPreviousFocus();
378 void resetPreviousFocus();
379
380 void connectCaptureMenuActions();
381 void startCaptureTriggered();
382
383 void connectAnalyzeMenuActions();
384
385 void matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type);
386 void applyFieldAsColumn();
387
388 void filterMenuAboutToShow();
389
390 void applyConversationFilter();
391
392 void openFollowStreamDialog(int proto_id, unsigned stream_num, unsigned sub_stream_num, bool use_stream_index = true);
393 void openFollowStreamDialog(int proto_id);
394
395 void statCommandExpertInfo(const char *, void *);
396
397 void connectToolsMenuActions();
398
399 void connectHelpMenuActions();
400
401 void goToCancelClicked();
402 void goToGoClicked();
403 void goToLineEditReturnPressed();
404
405 void connectStatisticsMenuActions();
406
407 void showResolvedAddressesDialog();
408 void showConversationsDialog();
409 void showEndpointsDialog();
410
411 void openStatisticsTreeDialog(const char *abbr);
412 void statCommandIOGraph(const char *, void *);
413 void showIOGraphDialog(io_graph_item_unit_t, QString) override;
414
415 void showPlotDialog(const QString& y_field = QString(), bool filtered = false) override;
416
417 void externalMenuItemTriggered();
418
419 void on_actionContextWikiProtocolPage_triggered();
420 void on_actionContextFilterFieldReference_triggered();
421
422 void extcap_options_finished(int result);
423 void showExtcapOptionsDialog(QString device_name, bool startCaptureOnClose);
424
425 friend class MainApplication;
426};
capture_file_dialog.h
capture_file_properties_dialog.h
capture_opts.h
capture_session.h
AccordionFrame
Definition accordion_frame.h:18
CaptureEvent
Definition capture_event.h:21
CaptureFile
Definition capture_file.h:21
DataSourceTab
Definition data_source_tab.h:33
FieldInformation
Definition field_information.h:23
FileSetDialog
Definition file_set_dialog.h:29
FilterDialog
Definition filter_dialog.h:28
FilterExpressionToolBar
Definition filter_expression_toolbar.h:18
FunnelStatistics
Definition funnel_statistics.h:32
MainApplication
Definition main_application.h:36
MainWindow
Definition main_window.h:48
PacketCommentDialog
Definition packet_comment_dialog.h:20
PacketList
Definition packet_list.h:41
PrintDialog
Definition print_dialog.h:27
ProtoTree
Definition proto_tree.h:27
StratosharkMainWindow
Definition stratoshark_main_window.h:92
StratosharkMainWindow::openCaptureFile
bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type, bool is_tempfile=false)
Definition stratoshark_main_window_slots.cpp:159
StratosharkMainWindow::openRecentCaptureFile
void openRecentCaptureFile(const QString &filename) override
Definition stratoshark_main_window_slots.cpp:968
WiresharkApplication
Definition wireshark_application.h:16
display_filter_combo.h
field_information.h
iface_toolbar.h
main_window.h
plugin_if.h
_capture_file
Definition cfile.h:71
_capture_session
Definition capture_session.h:136
_ext_menubar_t
Definition plugin_if.h:53
_iface_toolbar
Definition iface_toolbar.h:60
_info_data
Definition capture_info.h:40
_packet_info
Definition packet_info.h:43
timestamp.h
ws_ui_util.h