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