Wireshark 4.5.0
The Wireshark network protocol analyzer
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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_dialog.h"
67#include "main_window.h"
68
69class AccordionFrame;
70class ByteViewTab;
71class CaptureOptionsDialog;
72class PrintDialog;
73class FileSetDialog;
74class FilterDialog;
76class WelcomePage;
78class PacketList;
79class ProtoTree;
82
83class QAction;
84class QActionGroup;
85
86namespace Ui {
88}
89
90Q_DECLARE_METATYPE(ts_type)
91Q_DECLARE_METATYPE(ts_precision)
92
94{
95 Q_OBJECT
96
97public:
98 explicit StratosharkMainWindow(QWidget *parent = nullptr);
100
101#ifdef HAVE_LIBPCAP
102 capture_session *captureSession() { return &cap_session_; }
103 info_data_t *captureInfoData() { return &info_data_; }
104#endif
105
106 virtual QMenu *createPopupMenu();
107
108 CaptureFile *captureFile() { return &capture_file_; }
109
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
118protected:
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
127private:
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 QMap<QString, QTextCodec *> text_codec_map_;
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#if defined(Q_OS_MAC)
174 QMenu *dock_menu_;
175#endif
176
177#ifdef HAVE_SOFTWARE_UPDATE
178 QAction *update_action_;
179#endif
180
181 QPoint dragStartPosition;
182
183 void freeze();
184 void thaw();
185
186 void mergeCaptureFile();
187 void importCaptureFile();
188 bool saveCaptureFile(capture_file *cf, bool dont_reopen);
189 bool saveAsCaptureFile(capture_file *cf, bool must_support_comments = false, bool dont_reopen = false);
190 void exportSelectedPackets();
191 void exportDissections(export_type_e export_type);
192
193#ifdef Q_OS_WIN
194 void fileAddExtension(QString &file_name, int file_type, wtap_compression_type compression_type);
195#endif // Q_OS_WIN
196 bool testCaptureFileClose(QString before_what, FileCloseContext context = Default);
197 void captureStop();
198
199 void findTextCodecs();
200
201 void initMainToolbarIcons();
202 void initShowHideMainWidgets();
203 void initTimeDisplayFormatMenu();
204 void initTimePrecisionFormatMenu();
205 void initFreezeActions();
206
207 void setMenusForCaptureFile(bool force_disable = false);
208 void setMenusForCaptureInProgress(bool capture_in_progress = false);
209 void setMenusForCaptureStopping();
210 void setForCapturedPackets(bool have_captured_packets);
211 void setMenusForFileSet(bool enable_list_files);
212 void setWindowIcon(const QIcon &icon);
213 void updateStyleSheet();
214
215 void externalMenuHelper(ext_menu_t * menu, QMenu * subMenu, int depth);
216
217 void setForCaptureInProgress(bool capture_in_progress = false, bool handle_toolbars = false, GArray *ifaces = NULL);
218 QMenu* findOrAddMenu(QMenu *parent_menu, const QStringList& menu_parts);
219
220 void captureFileReadStarted(const QString &action);
221
222 void addMenuActions(QList<QAction *> &actions, int menu_group);
223 void removeMenuActions(QList<QAction *> &actions, int menu_group);
224 void goToConversationFrame(bool go_next, bool start_current = true);
225 void colorizeWithFilter(QByteArray filter, int color_number = -1);
226
227signals:
228 void setDissectedCaptureFile(capture_file *cf);
229 void closePacketDialogs();
230 void reloadFields();
231 void packetInfoChanged(struct _packet_info *pinfo);
232 void fieldFilterChanged(const QByteArray field_filter);
233
234#ifdef HAVE_LIBPCAP
235 void showExtcapOptions(QString &device_name, bool startCaptureOnClose);
236#endif
237
238public slots:
239 // Qt lets you connect signals and slots using functors (new, manual style)
240 // and strings (old style). Functors are preferred since they're connected at
241 // compile time and less error prone.
242 //
243 // If you're manually connecting a signal to a slot, don't prefix its name
244 // with "on_". Otherwise Qt will try to automatically connect it and you'll
245 // get runtime warnings.
246
247 // in main_window_slots.cpp
256 // XXX We might want to return a cf_read_status_t or a CaptureFile.
257 bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type, bool is_tempfile = false);
258 bool openCaptureFile(QString cf_path = QString(), QString display_filter = QString()) { return openCaptureFile(cf_path, display_filter, WTAP_TYPE_AUTO); }
259 void filterPackets(QString new_filter = QString(), bool force = false);
260 void updateForUnsavedChanges();
261 void layoutToolbars();
262 void updatePreferenceActions();
263 void updateRecentActions();
264
265 void setTitlebarForCaptureFile();
266
267 void showCaptureOptionsDialog();
268
269#ifdef HAVE_LIBPCAP
270 void captureCapturePrepared(capture_session *);
271 void captureCaptureUpdateStarted(capture_session *);
272 void captureCaptureUpdateFinished(capture_session *);
273 void captureCaptureFixedFinished(capture_session *cap_session);
274 void captureCaptureFailed(capture_session *);
275#endif
276
277 void captureFileOpened();
278 void captureFileReadFinished();
279 void captureFileClosing();
280 void captureFileClosed();
281
282private slots:
283
284 void captureEventHandler(CaptureEvent ev);
285
286 void initViewColorizeMenu();
287 void initConversationMenus();
288 static bool addFollowStreamMenuItem(const void *key, void *value, void *userdata);
289 void initFollowStreamMenus();
290
291 // in main_window_slots.cpp
297 void startCapture(QStringList);
298 void startCapture();
299 void pushLiveCaptureInProgress();
300 void popLiveCaptureInProgress();
301 void stopCapture();
302
303 void loadWindowGeometry();
304 void saveWindowGeometry();
305 void mainStackChanged(int);
306 void updateRecentCaptures();
307 void recentActionTriggered();
308 void addPacketComment();
309 void editPacketComment();
310 void deletePacketComment();
311 void deleteCommentsFromPackets();
312 QString commentToMenuText(QString text, int max_len = 40);
313 void setEditCommentsMenu();
314 void setMenusForSelectedPacket();
315 void setMenusForSelectedTreeRow(FieldInformation *fi = NULL);
316 void interfaceSelectionChanged();
317 void captureFilterSyntaxChanged(bool valid);
318 void redissectPackets();
319 void checkDisplayFilter();
320 void fieldsChanged();
321 void reloadLuaPlugins();
322 void showAccordionFrame(AccordionFrame *show_frame, bool toggle = false);
323 void showColumnEditor(int column);
324 void showPreferenceEditor(); // module_t *, pref *
325 void addStatsPluginsToMenu();
326 void addDynamicMenus();
327 void reloadDynamicMenus();
328 void addPluginIFStructures();
329 QMenu * searchSubMenu(QString objectName);
330 void activatePluginIFToolbar(bool);
331
332 void startInterfaceCapture(bool valid, const QString capture_filter);
333
334 void applyGlobalCommandLineOptions();
335 void setFeaturesEnabled(bool enabled = true);
336
337 void on_actionNewDisplayFilterExpression_triggered();
338 void onFilterSelected(QString, bool);
339 void onFilterPreferences();
340 void onFilterEdit(int uatIndex);
341
342 // Handle FilterAction signals
343 void queuedFilterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);
344
350 void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
351
357 void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
358 void openTapParameterDialog();
359
360#if defined(HAVE_SOFTWARE_UPDATE) && defined(Q_OS_WIN)
361 void softwareUpdateRequested();
362#endif
363
364 void connectFileMenuActions();
365 void printFile();
366
367 void connectEditMenuActions();
368 void copySelectedItems(StratosharkMainWindow::CopySelected selection_type);
369 void findPacket();
370 void editTimeShift();
371 void editConfigurationProfiles();
372 void editTimeShiftFinished(int);
373 void addPacketCommentFinished(PacketCommentDialog* pc_dialog, int result);
374 void editPacketCommentFinished(PacketCommentDialog* pc_dialog, int result, unsigned nComment);
375 void deleteAllPacketComments();
376 void deleteAllPacketCommentsFinished(int result);
377 void showPreferencesDialog(QString module_name);
378
379 void connectViewMenuActions();
380 void showHideMainWidgets(QAction *action);
381 void setTimestampFormat(QAction *action);
382 void setTimestampPrecision(QAction *action);
383 void setTimeDisplaySecondsWithHoursAndMinutes(bool checked);
384 void editResolvedName();
385 void setNameResolution();
386 void zoomText();
387 void showColoringRulesDialog();
388 void colorizeConversation(bool create_rule = false);
389 void colorizeActionTriggered();
390 void openPacketDialog(bool from_reference = false);
391 void reloadCaptureFileAsFormatOrCapture();
392 void reloadCaptureFile();
393
394 void connectGoMenuActions();
395
396 void setPreviousFocus();
397 void resetPreviousFocus();
398
399 void connectCaptureMenuActions();
400 void startCaptureTriggered();
401
402 void connectAnalyzeMenuActions();
403
404 void matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type);
405 void applyFieldAsColumn();
406
407 void filterMenuAboutToShow();
408
409 void applyConversationFilter();
410
411 void openFollowStreamDialog(int proto_id, unsigned stream_num, unsigned sub_stream_num, bool use_stream_index = true);
412 void openFollowStreamDialog(int proto_id);
413
414 void statCommandExpertInfo(const char *, void *);
415
416 void connectToolsMenuActions();
417
418 void connectHelpMenuActions();
419
420#ifdef HAVE_SOFTWARE_UPDATE
421 void checkForUpdates();
422#endif
423
424 void goToCancelClicked();
425 void goToGoClicked();
426 void goToLineEditReturnPressed();
427
428 void connectStatisticsMenuActions();
429
430 void showResolvedAddressesDialog();
431 void showConversationsDialog();
432 void showEndpointsDialog();
433
434 void openStatisticsTreeDialog(const char *abbr);
435 void statCommandIOGraph(const char *, void *);
436 void showIOGraphDialog(io_graph_item_unit_t, QString);
437
438 void externalMenuItemTriggered();
439
440 void on_actionContextWikiProtocolPage_triggered();
441 void on_actionContextFilterFieldReference_triggered();
442
443 void extcap_options_finished(int result);
444 void showExtcapOptionsDialog(QString & device_name, bool startCaptureOnClose);
445
446 friend class MainApplication;
447};
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:94
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:53
Definition iface_toolbar.h:60
Definition capture_info.h:40
Definition packet_info.h:43