Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
logray_main_window.h
Go to the documentation of this file.
1
10#ifndef LOGRAY_MAIN_WINDOW_H
11#define LOGRAY_MAIN_WINDOW_H
12
39#include <stdio.h>
40
41#include <config.h>
42
43#include "file.h"
44
45#include "ui/ws_ui_util.h"
46#include "ui/iface_toolbar.h"
47
48#include <epan/plugin_if.h>
49#include <epan/timestamp.h>
50
51#ifdef HAVE_LIBPCAP
52#include "capture_opts.h"
53#endif
55
56#include <QMainWindow>
57#include <QPointer>
58#include <QTextCodec>
59
60#ifdef _WIN32
61# include <QTimer>
62#else
63# include <QSocketNotifier>
64#endif
65
66#include "capture_file.h"
67#include "capture_file_dialog.h"
71#include "main_window.h"
72
73class AccordionFrame;
74class ByteViewTab;
75class CaptureOptionsDialog;
76class PrintDialog;
77class FileSetDialog;
78class FilterDialog;
80class WelcomePage;
82class PacketList;
83class ProtoTree;
86
87class QAction;
88class QActionGroup;
89
90namespace Ui {
91 class LograyMainWindow;
92}
93
94Q_DECLARE_METATYPE(ts_type)
95Q_DECLARE_METATYPE(ts_precision)
96
98{
99 Q_OBJECT
100
101public:
102 explicit LograyMainWindow(QWidget *parent = nullptr);
104
105#ifdef HAVE_LIBPCAP
106 capture_session *captureSession() { return &cap_session_; }
107 info_data_t *captureInfoData() { return &info_data_; }
108#endif
109
110 virtual QMenu *createPopupMenu();
111
112 CaptureFile *captureFile() { return &capture_file_; }
113
114 void removeAdditionalToolbar(QString toolbarName);
115
116 void addInterfaceToolbar(const iface_toolbar *toolbar_entry);
117 void removeInterfaceToolbar(const char *menu_title);
118
119 QString getMwFileName();
120 void setMwFileName(QString fileName);
121
122protected:
123 virtual bool eventFilter(QObject *obj, QEvent *event);
124 virtual bool event(QEvent *event);
125 virtual void keyPressEvent(QKeyEvent *event);
126 virtual void closeEvent(QCloseEvent *event);
127 virtual void dragEnterEvent(QDragEnterEvent *event);
128 virtual void dropEvent(QDropEvent *event);
129 virtual void changeEvent(QEvent* event);
130
131private:
132 // XXX Move to FilterUtils
133 enum MatchSelected {
134 MatchSelectedReplace,
135 MatchSelectedAnd,
136 MatchSelectedOr,
137 MatchSelectedNot,
138 MatchSelectedAndNot,
139 MatchSelectedOrNot
140 };
141
142 enum FileCloseContext {
143 Default,
144 Quit,
145 Restart,
146 Reload,
147 Update
148 };
149
150 Ui::LograyMainWindow *main_ui_;
151 CaptureFile capture_file_;
152 QFont mono_font_;
153 QMap<QString, QTextCodec *> text_codec_map_;
154 QWidget *previous_focus_;
155 FileSetDialog *file_set_dialog_;
156 QActionGroup *show_hide_actions_;
157 QActionGroup *time_display_actions_;
158 QActionGroup *time_precision_actions_;
159 FunnelStatistics *funnel_statistics_;
160 QList<QPair<QAction *, bool> > freeze_actions_;
161 QPointer<QWidget> freeze_focus_;
162 QMap<QAction *, ts_type> td_actions;
163 QMap<QAction *, ts_precision> tp_actions;
164 bool was_maximized_;
165
166 /* the following values are maintained so that the capture file name and status
167 is available when there is no cf structure available */
168 QString mwFileName_;
169
170 bool capture_stopping_;
171 bool capture_filter_valid_;
172 bool use_capturing_title_;
173#ifdef HAVE_LIBPCAP
174 capture_session cap_session_;
175 CaptureOptionsDialog *capture_options_dialog_;
176 info_data_t info_data_;
177#endif
178
179#if defined(Q_OS_MAC)
180 QMenu *dock_menu_;
181#endif
182
183#ifdef HAVE_SOFTWARE_UPDATE
184 QAction *update_action_;
185#endif
186
187 QPoint dragStartPosition;
188
189 void freeze();
190 void thaw();
191
192 void mergeCaptureFile();
193 void importCaptureFile();
194 bool saveCaptureFile(capture_file *cf, bool dont_reopen);
195 bool saveAsCaptureFile(capture_file *cf, bool must_support_comments = false, bool dont_reopen = false);
196 void exportSelectedPackets();
197 void exportDissections(export_type_e export_type);
198
199#ifdef Q_OS_WIN
200 void fileAddExtension(QString &file_name, int file_type, wtap_compression_type compression_type);
201#endif // Q_OS_WIN
202 bool testCaptureFileClose(QString before_what, FileCloseContext context = Default);
203 void captureStop();
204
205 void findTextCodecs();
206
207 void initMainToolbarIcons();
208 void initShowHideMainWidgets();
209 void initTimeDisplayFormatMenu();
210 void initTimePrecisionFormatMenu();
211 void initFreezeActions();
212
213 void setTitlebarForCaptureInProgress();
214 void setMenusForCaptureFile(bool force_disable = false);
215 void setMenusForCaptureInProgress(bool capture_in_progress = false);
216 void setMenusForCaptureStopping();
217 void setForCapturedPackets(bool have_captured_packets);
218 void setMenusForFileSet(bool enable_list_files);
219 void setWindowIcon(const QIcon &icon);
220 QString replaceWindowTitleVariables(QString title);
221 void updateStyleSheet();
222
223 void externalMenuHelper(ext_menu_t * menu, QMenu * subMenu, int depth);
224
225 void setForCaptureInProgress(bool capture_in_progress = false, bool handle_toolbars = false, GArray *ifaces = NULL);
226 QMenu* findOrAddMenu(QMenu *parent_menu, const QStringList& menu_parts);
227
228 void captureFileReadStarted(const QString &action);
229
230 void addMenuActions(QList<QAction *> &actions, int menu_group);
231 void removeMenuActions(QList<QAction *> &actions, int menu_group);
232 void goToConversationFrame(bool go_next);
233 void colorizeWithFilter(QByteArray filter, int color_number = -1);
234
235signals:
236 void setDissectedCaptureFile(capture_file *cf);
237 void closePacketDialogs();
238 void reloadFields();
239 void packetInfoChanged(struct _packet_info *pinfo);
240 void fieldFilterChanged(const QByteArray field_filter);
241
242 void fieldHighlight(FieldInformation *);
243
244 void captureActive(int);
245
246#ifdef HAVE_LIBPCAP
247 void showExtcapOptions(QString &device_name, bool startCaptureOnClose);
248#endif
249
250public slots:
251 // in main_window_slots.cpp
260 // XXX We might want to return a cf_read_status_t or a CaptureFile.
261 bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type, bool is_tempfile = false);
262 bool openCaptureFile(QString cf_path = QString(), QString display_filter = QString()) { return openCaptureFile(cf_path, display_filter, WTAP_TYPE_AUTO); }
263 void filterPackets(QString new_filter = QString(), bool force = false);
264 void updateForUnsavedChanges();
265 void layoutToolbars();
266 void updatePreferenceActions();
267 void updateRecentActions();
268
269 void setTitlebarForCaptureFile();
270 void setWSWindowTitle(QString title = QString());
271
272 void showCaptureOptionsDialog();
273
274#ifdef HAVE_LIBPCAP
275 void captureCapturePrepared(capture_session *);
276 void captureCaptureUpdateStarted(capture_session *);
277 void captureCaptureUpdateFinished(capture_session *);
278 void captureCaptureFixedFinished(capture_session *cap_session);
279 void captureCaptureFailed(capture_session *);
280#endif
281
282 void captureFileOpened();
283 void captureFileReadFinished();
284 void captureFileClosing();
285 void captureFileClosed();
286
287private slots:
288
289 void captureEventHandler(CaptureEvent ev);
290
291 // Manually connected slots (no "on_<object>_<signal>").
292
293 void initViewColorizeMenu();
294 void initConversationMenus();
295 static bool addFollowStreamMenuItem(const void *key, void *value, void *userdata);
296 void initFollowStreamMenus();
297
298 // in main_window_slots.cpp
304 void startCapture(QStringList);
305 void startCapture();
306 void pushLiveCaptureInProgress();
307 void popLiveCaptureInProgress();
308 void stopCapture();
309
310 void loadWindowGeometry();
311 void saveWindowGeometry();
312 void mainStackChanged(int);
313 void updateRecentCaptures();
314 void recentActionTriggered();
315 void addPacketComment();
316 void editPacketComment();
317 void deletePacketComment();
318 void deleteCommentsFromPackets();
319 QString commentToMenuText(QString text, int max_len = 40);
320 void setEditCommentsMenu();
321 void setMenusForSelectedPacket();
322 void setMenusForSelectedTreeRow(FieldInformation *fi = NULL);
323 void interfaceSelectionChanged();
324 void captureFilterSyntaxChanged(bool valid);
325 void redissectPackets();
326 void checkDisplayFilter();
327 void fieldsChanged();
328 void reloadLuaPlugins();
329 void showAccordionFrame(AccordionFrame *show_frame, bool toggle = false);
330 void showColumnEditor(int column);
331 void showPreferenceEditor(); // module_t *, pref *
332 void addStatsPluginsToMenu();
333 void addDynamicMenus();
334 void reloadDynamicMenus();
335 void addPluginIFStructures();
336 QMenu * searchSubMenu(QString objectName);
337 void activatePluginIFToolbar(bool);
338 void updateTitlebar();
339
340 void startInterfaceCapture(bool valid, const QString capture_filter);
341
342 void applyGlobalCommandLineOptions();
343 void setFeaturesEnabled(bool enabled = true);
344
345 void on_actionNewDisplayFilterExpression_triggered();
346 void onFilterSelected(QString, bool);
347 void onFilterPreferences();
348 void onFilterEdit(int uatIndex);
349
350 // Handle FilterAction signals
351 void queuedFilterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);
352
358 void openStatCommandDialog(const QString &menu_path, const char *arg, void *userdata);
359
365 void openTapParameterDialog(const QString cfg_str, const QString arg, void *userdata);
366 void openTapParameterDialog();
367
368#if defined(HAVE_SOFTWARE_UPDATE) && defined(Q_OS_WIN)
369 void softwareUpdateRequested();
370#endif
371
372 // Automatically connected slots ("on_<object>_<signal>").
373 //
374 // The slots below follow the naming conventaion described in
375 // https://doc.qt.io/archives/qt-4.8/qmetaobject.html#connectSlotsByName
376 // and are automatically connected at initialization time via
377 // main_ui_->setupUi, which in turn calls connectSlotsByName.
378 //
379 // If you're manually connecting a signal to a slot, don't prefix its name
380 // with "on_". Otherwise you'll get runtime warnings.
381
382 // We might want move these to main_window_actions.cpp similar to
383 // gtk/main_menubar.c
384
385 void connectFileMenuActions();
386 void printFile();
387
388 void connectEditMenuActions();
389 void copySelectedItems(LograyMainWindow::CopySelected selection_type);
390 void findPacket();
391 void editTimeShift();
392 void editConfigurationProfiles();
393 void editTimeShiftFinished(int);
394 void addPacketCommentFinished(PacketCommentDialog* pc_dialog, int result);
395 void editPacketCommentFinished(PacketCommentDialog* pc_dialog, int result, unsigned nComment);
396 void deleteAllPacketComments();
397 void deleteAllPacketCommentsFinished(int result);
398 void showPreferencesDialog(QString module_name);
399
400 void connectViewMenuActions();
401 void showHideMainWidgets(QAction *action);
402 void setTimestampFormat(QAction *action);
403 void setTimestampPrecision(QAction *action);
404 void setTimeDisplaySecondsWithHoursAndMinutes(bool checked);
405 void editResolvedName();
406 void setNameResolution();
407 void zoomText();
408 void showColoringRulesDialog();
409 void colorizeConversation(bool create_rule = false);
410 void colorizeActionTriggered();
411 void openPacketDialog(bool from_reference = false);
412 void reloadCaptureFileAsFormatOrCapture();
413 void reloadCaptureFile();
414
415 void connectGoMenuActions();
416
417 void setPreviousFocus();
418 void resetPreviousFocus();
419
420 void connectCaptureMenuActions();
421 void startCaptureTriggered();
422
423 void connectAnalyzeMenuActions();
424
425 void matchFieldFilter(FilterAction::Action action, FilterAction::ActionType filter_type);
426 void applyFieldAsColumn();
427
428 void filterMenuAboutToShow();
429
430 void applyConversationFilter();
431
432 void openFollowStreamDialog(int proto_id, unsigned stream_num, unsigned sub_stream_num, bool use_stream_index = true);
433 void openFollowStreamDialog(int proto_id);
434
435 void statCommandExpertInfo(const char *, void *);
436
437 void connectToolsMenuActions();
438
439 void connectHelpMenuActions();
440
441#ifdef HAVE_SOFTWARE_UPDATE
442 void checkForUpdates();
443#endif
444
445 void goToCancelClicked();
446 void goToGoClicked();
447 void goToLineEditReturnPressed();
448
449 void connectStatisticsMenuActions();
450
451 void showResolvedAddressesDialog();
452 void showConversationsDialog();
453 void showEndpointsDialog();
454
455 void openStatisticsTreeDialog(const char *abbr);
456 void statCommandIOGraph(const char *, void *);
457 void showIOGraphDialog(io_graph_item_unit_t, QString);
458
459 void externalMenuItemTriggered();
460
461 void on_actionContextWikiProtocolPage_triggered();
462 void on_actionContextFilterFieldReference_triggered();
463
464 void extcap_options_finished(int result);
465 void showExtcapOptionsDialog(QString & device_name, bool startCaptureOnClose);
466
467 friend class MainApplication;
468};
469
470#endif // LOGRAY_MAIN_WINDOW_H
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 logray_main_window.h:98
bool openCaptureFile(QString cf_path, QString display_filter, unsigned int type, bool is_tempfile=false)
Definition logray_main_window_slots.cpp:158
Definition main_application.h:49
Definition main_window.h:45
Definition packet_comment_dialog.h:20
Definition packet_list.h:40
Definition print_dialog.h:27
Definition proto_tree.h:27
Definition welcome_page.h:27
Definition wireshark_application.h:16
Definition cfile.h:67
Definition capture_session.h:137
Definition plugin_if.h:55
Definition iface_toolbar.h:60
Definition capture_info.h:40
Definition packet_info.h:43