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