Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
wireshark_dialog.h
1 /* wireshark_dialog.h
2  *
3  * Wireshark - Network traffic analyzer
4  * By Gerald Combs <gerald@wireshark.org>
5  * Copyright 1998 Gerald Combs
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9 
10 #ifndef WIRESHARK_DIALOG_H
11 #define WIRESHARK_DIALOG_H
12 
13 /*
14  * @file General dialog base class
15  *
16  * Base class which provides convenience methods for dialogs that handle
17  * capture files.
18  *
19  * This class attempts to destroy itself when closed. Doing this safely and
20  * properly can be a bit tricky while scanning and tapping packets since
21  */
22 
23 // "General" is a misnomer but we already have a class named
24 // "CaptureFileDialog". Suggestions for a better name from
25 // https://code.wireshark.org/review/#/c/9739/:
26 // BaseCaptureDialog, CaptureHelperDialog (or rename CaptureFileDialog to something else - WiresharkFileDialog).
27 // TapDialog might make sense as well.
28 
29 #include "capture_file.h"
30 #include "geometry_state_dialog.h"
31 
33 {
34  Q_OBJECT
35 
36 public:
37  // XXX Unlike the entire QWidget API, parent is mandatory here.
38  explicit WiresharkDialog(QWidget &parent, CaptureFile &capture_file);
39 
50  void beginRetapPackets();
59  virtual void endRetapPackets();
60 
61 protected:
62  virtual void keyPressEvent(QKeyEvent *event) { QDialog::keyPressEvent(event); }
63  virtual void accept();
64  virtual void reject();
65 
72  void setWindowSubtitle(const QString &subtitle);
73  const QString &windowSubtitle() { return subtitle_; }
74  virtual void updateWidgets();
75 
76  // Capture file and tapping
77  CaptureFile &cap_file_;
93  bool registerTapListener(const char *tap_name, void *tap_data,
94  const char *filter, guint flags,
95  void (*tap_reset)(void *tapdata),
96  gboolean (*tap_packet)(void *tapdata, struct _packet_info *pinfo, struct epan_dissect *edt, const void *data),
97  void (*tap_draw)(void *tap_data));
98 
102  virtual void removeTapListeners();
103 
107  // XXX Needs a getter?
109 
114  bool dialogClosed() { return dialog_closed_; }
115 
121  virtual void captureFileClosing();
122  virtual void captureFileClosed();
123 
124 protected slots:
125  void captureEvent(CaptureEvent);
126 
127 private:
128  void setWindowTitleFromSubtitle();
129 
130  void tryDeleteLater();
131 
132  QString subtitle_;
133  QList<void *> tap_listeners_;
134  int retap_depth_;
135  bool dialog_closed_;
136 
137 private slots:
138 };
139 
140 #endif // WIRESHARK_DIALOG_H
141 
142 /*
143  * Editor modelines
144  *
145  * Local Variables:
146  * c-basic-offset: 4
147  * tab-width: 8
148  * indent-tabs-mode: nil
149  * End:
150  *
151  * ex: set shiftwidth=4 tabstop=8 expandtab:
152  * :indentSize=4:tabSize=8:noTabs=true:
153  */
void setWindowSubtitle(const QString &subtitle)
Set the window subtitle, e.g. "Foo Timeouts". The subtitle and file name will be added to the dialog ...
Definition: wireshark_dialog.cpp:70
bool registerTapListener(const char *tap_name, void *tap_data, const char *filter, guint flags, void(*tap_reset)(void *tapdata), gboolean(*tap_packet)(void *tapdata, struct _packet_info *pinfo, struct epan_dissect *edt, const void *data), void(*tap_draw)(void *tap_data))
Convenience wrapper for register_tap_listener. Tap listeners registered via this function are automat...
Definition: wireshark_dialog.cpp:103
Definition: geometry_state_dialog.h:15
Definition: packet_info.h:44
bool file_closed_
true if the file has been closed, false otherwise.
Definition: wireshark_dialog.h:108
virtual void removeTapListeners()
Remove all tap listeners registered via registerTapListener.
Definition: wireshark_dialog.cpp:165
Definition: capture_event.h:19
virtual void captureFileClosing()
Called when the capture file is about to close. This can be used to enable or disable widgets accordi...
Definition: wireshark_dialog.cpp:172
void beginRetapPackets()
Mark the start of a code block that retaps packets. If the user closes the dialog while tapping...
Definition: wireshark_dialog.cpp:154
Definition: epan_dissect.h:28
Definition: wireshark_dialog.h:32
Definition: cfile.h:58
virtual void endRetapPackets()
Mark the end of a code block that retaps packets. If the user has closed the dialog it will be desroy...
Definition: wireshark_dialog.cpp:159
Definition: capture_file.h:22
bool dialogClosed()
Check to see if the user has closed (and not minimized) the dialog.
Definition: wireshark_dialog.h:114