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