| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
capture_file_dialog.h
Go to the documentation of this file.
1
9
10#ifndef CAPTURE_FILE_DIALOG_H
11#define CAPTURE_FILE_DIALOG_H
12
13#include <ui/qt/widgets/wireshark_file_dialog.h>
14
15#include <ui/qt/widgets/display_filter_edit.h>
16#include <ui/qt/widgets/compression_group_box.h>
17#include "packet_range_group_box.h"
18#include "ui/help_url.h"
19
20#include <ui/packet_range.h>
21
22#include <ui/qt/models/packet_list_record.h>
23#include <epan/cfile.h>
24
25#include "ui/file_dialog.h"
26
27#include <QVBoxLayout>
28#include <QLabel>
29#include <QRadioButton>
30#include <QCheckBox>
31#include <QDialogButtonBox>
32#include <QComboBox>
33
37 class CaptureFileDialog : public WiresharkFileDialog
38{
39 // The GTK+ Open Capture File dialog has the following elements and features:
40 // - The ability to select a capture file from a list of known extensions
41 // - A display filter entry
42 // - Name resolution checkboxes
43 // - Capture file preview information
44 // Ideally we should provide similar functionality here.
45 //
46 // You can subclass QFileDialog (which we've done here) and add widgets as
47 // described at
48 //
49 // https://web.archive.org/web/20100528190736/http://developer.qt.nokia.com/faq/answer/how_can_i_add_widgets_to_my_qfiledialog_instance
50 //
51 // However, Qt's idea of what a file dialog looks like isn't what Microsoft
52 // and Apple think a file dialog looks like.
53 //
54 // On Windows, we should probably use the Common Item Dialog:
55 //
56 // https://learn.microsoft.com/en-us/windows/win32/shell/common-file-dialog
57 //
58 // We currently use GetOpenFileNam in ui/win32/file_dlg_win32.c.
59 //
60 // On macOS we should use NSOpenPanel and NSSavePanel:
61 //
62 // https://developer.apple.com/documentation/appkit/nsopenpanel?language=objc
63 // https://developer.apple.com/documentation/appkit/nssavepanel?language=objc
64 //
65 // On other platforms we should fall back to QFileDialog (or maybe
66 // KDE's or GTK+/GNOME's file dialog, as appropriate for the desktop
67 // environment being used, if QFileDialog doesn't do so with various
68 // platform plugins).
69 //
70 // Yes, that's four implementations of the same window.
71 //
72 // If a plain native open file dialog is good enough we can just the static
73 // version of QFileDialog::getOpenFileName. (Commenting out Q_OBJECT and
74 // "explicit" below has the same effect.)
75
76 Q_OBJECT
77 public:
83 explicit CaptureFileDialog(QWidget *parent = NULL, capture_file *cf = NULL);
84
92 static check_savability_t checkSaveAsWithComments(QWidget *parent, capture_file *cf, int file_type);
93
98 int mergeType();
99
104 int selectedFileType();
105
110 ws_compression_type compressionType();
111
112 private:
114 capture_file *cap_file_;
115
120 void addMergeControls(QVBoxLayout &v_box);
121
126 void addFormatTypeSelector(QVBoxLayout &v_box);
127
132 void addDisplayFilterEdit(QString &display_filter);
133
138 void addPreview(QVBoxLayout &v_box);
139
146 QString fileExtensionType(int et, bool extension_globs = true);
147
154 QString fileType(int ft, QStringList &suffixes);
155
160 QStringList buildFileOpenTypeList(void);
161
163 QVBoxLayout left_v_box_;
164
166 QVBoxLayout right_v_box_;
167
169 DisplayFilterEdit* display_filter_edit_;
170
172 int last_row_;
173
175 QLabel preview_format_;
176
178 QLabel preview_size_;
179
181 QLabel preview_first_elapsed_;
182
184 QList<QLabel *> preview_labels_;
185
187 QRadioButton merge_prepend_;
188
190 QRadioButton merge_chrono_;
191
193 QRadioButton merge_append_;
194
196 QComboBox format_type_;
197
199 QHash<QString, int> type_hash_;
200
202 QHash<QString, QStringList> type_suffixes_;
203
208 void addGzipControls(QVBoxLayout &v_box);
209
216 void addRangeControls(QVBoxLayout &v_box, packet_range_t *range, QString selRange = QString());
217
223 QDialogButtonBox *addHelpButton(topic_action_e help_topic);
224
230 QStringList buildFileSaveAsTypeList(bool must_support_comments);
231
233 int default_ft_;
234
236 CompressionGroupBox compress_group_box_;
237
239 PacketRangeGroupBox packet_range_group_box_;
240
242 QPushButton *save_bt_;
243
245 topic_action_e help_topic_;
246
247signals:
248
249 public slots:
253 void accept() Q_DECL_OVERRIDE;
254
259 int exec() Q_DECL_OVERRIDE;
260
268 int open(QString &file_name, unsigned int &type, QString &display_filter);
269
276 check_savability_t saveAs(QString &file_name, bool must_support_comments);
277
285 check_savability_t exportSelectedPackets(QString &file_name, packet_range_t *range, QString selRange = QString());
286
293 int merge(QString &file_name, QString &display_filter);
294
295 private slots:
299 void fixFilenameExtension();
300
305 void preview(const QString & path);
306
310 void on_buttonBox_helpRequested();
311};
312
313#endif // CAPTURE_FILE_DIALOG_H
cfile.h
capture_file
struct _capture_file capture_file
Represents a capture file and its associated metadata.
CaptureFileDialog::mergeType
int mergeType()
Retrieves the selected merge type.
Definition capture_file_dialog.cpp:769
CaptureFileDialog::compressionType
ws_compression_type compressionType()
Retrieves the selected compression type.
Definition capture_file_dialog.cpp:505
CaptureFileDialog::CaptureFileDialog
CaptureFileDialog(QWidget *parent=NULL, capture_file *cf=NULL)
Constructs a new CaptureFileDialog.
Definition capture_file_dialog.cpp:48
CaptureFileDialog::selectedFileType
int selectedFileType()
Retrieves the selected file type.
Definition capture_file_dialog.cpp:501
CaptureFileDialog::accept
void accept() Q_DECL_OVERRIDE
Accepts the dialog and finalizes the operation.
Definition capture_file_dialog.cpp:201
CaptureFileDialog::merge
int merge(QString &file_name, QString &display_filter)
Opens a file dialog to merge capture files.
Definition capture_file_dialog.cpp:693
CaptureFileDialog::open
int open(QString &file_name, unsigned int &type, QString &display_filter)
Opens a file dialog to open a capture file.
Definition capture_file_dialog.cpp:570
CaptureFileDialog::exec
int exec() Q_DECL_OVERRIDE
Executes the dialog in a modal state.
Definition capture_file_dialog.cpp:225
CaptureFileDialog::saveAs
check_savability_t saveAs(QString &file_name, bool must_support_comments)
Opens a file dialog to save the capture file.
Definition capture_file_dialog.cpp:602
CaptureFileDialog::exportSelectedPackets
check_savability_t exportSelectedPackets(QString &file_name, packet_range_t *range, QString selRange=QString())
Opens a file dialog to export specific packets.
Definition capture_file_dialog.cpp:643
CaptureFileDialog::checkSaveAsWithComments
static check_savability_t checkSaveAsWithComments(QWidget *parent, capture_file *cf, int file_type)
Checks whether the capture file can be saved with comments in the specified format.
Definition capture_file_dialog.cpp:76
CompressionGroupBox
UI element for selecting compression type from among those supported.
Definition compression_group_box.h:25
DisplayFilterEdit
A line edit widget specialized for entering, validating, and managing display filters.
Definition display_filter_edit.h:36
PacketRangeGroupBox
UI element for controlling a range selection. The range provided in "initRange" is not owned by this ...
Definition packet_range_group_box.h:29
WiresharkFileDialog::WiresharkFileDialog
WiresharkFileDialog(QWidget *parent=nullptr, const QString &caption=QString(), const QString &directory=QString(), const QString &filter=QString())
Constructs a Wireshark file dialog.
Definition wireshark_file_dialog.cpp:21
compression_group_box.h
display_filter_edit.h
file_dialog.h
check_savability_t
check_savability_t
Outcome of a "check if savable" prompt when closing or overwriting a capture file.
Definition file_dialog.h:22
help_url.h
topic_action_e
topic_action_e
Identifies a help topic or navigable destination reachable from the UI help system.
Definition help_url.h:28
packet_list_record.h
packet_range.h
packet_range_t
struct packet_range_tag packet_range_t
Fully describes a packet range selection, including UI settings, derived counts, and dependency sets ...
packet_range_group_box.h
wireshark_file_dialog.h