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