Wireshark  4.3.0
The Wireshark network protocol analyzer
capture_file_dialog.h
Go to the documentation of this file.
1 
10 #ifndef CAPTURE_FILE_DIALOG_H
11 #define CAPTURE_FILE_DIALOG_H
12 
14 
15 #ifndef Q_OS_WIN
17 #include "packet_range_group_box.h"
18 #include "ui/help_url.h"
19 #endif // Q_OS_WIN
20 
21 #include <ui/packet_range.h>
22 
24 #include "cfile.h"
25 
26 #include "ui/file_dialog.h"
27 
28 #include <QVBoxLayout>
29 #include <QLabel>
30 #include <QRadioButton>
31 #include <QCheckBox>
32 #include <QDialogButtonBox>
33 #include <QComboBox>
34 
36 {
37  // The GTK+ Open Capture File dialog has the following elements and features:
38  // - The ability to select a capture file from a list of known extensions
39  // - A display filter entry
40  // - Name resolution checkboxes
41  // - Capture file preview information
42  // Ideally we should provide similar functionality here.
43  //
44  // You can subclass QFileDialog (which we've done here) and add widgets as
45  // described at
46  //
47  // https://web.archive.org/web/20100528190736/http://developer.qt.nokia.com/faq/answer/how_can_i_add_widgets_to_my_qfiledialog_instance
48  //
49  // However, Qt's idea of what a file dialog looks like isn't what Microsoft
50  // and Apple think a file dialog looks like.
51  //
52  // On Windows, we should probably use the Common Item Dialog:
53  //
54  // https://learn.microsoft.com/en-us/windows/win32/shell/common-file-dialog
55  //
56  // We currently use GetOpenFileNam in ui/win32/file_dlg_win32.c.
57  //
58  // On macOS we should use NSOpenPanel and NSSavePanel:
59  //
60  // https://developer.apple.com/documentation/appkit/nsopenpanel?language=objc
61  // https://developer.apple.com/documentation/appkit/nssavepanel?language=objc
62  //
63  // On other platforms we should fall back to QFileDialog (or maybe
64  // KDE's or GTK+/GNOME's file dialog, as appropriate for the desktop
65  // environment being used, if QFileDialog doesn't do so with various
66  // platform plugins).
67  //
68  // Yes, that's four implementations of the same window.
69  //
70  // If a plain native open file dialog is good enough we can just the static
71  // version of QFileDialog::getOpenFileName. (Commenting out Q_OBJECT and
72  // "explicit" below has the same effect.)
73 
74  Q_OBJECT
75 public:
76  explicit CaptureFileDialog(QWidget *parent = NULL, capture_file *cf = NULL);
77  static check_savability_t checkSaveAsWithComments(QWidget *
78 #if defined(Q_OS_WIN)
79  parent
80 #endif // Q_OS_WIN
81  , capture_file *cf, int file_type);
82 
83  int mergeType();
84  int selectedFileType();
85  wtap_compression_type compressionType();
86 
87 private:
88  capture_file *cap_file_;
89 
90 #if !defined(Q_OS_WIN)
91  void addMergeControls(QVBoxLayout &v_box);
92  void addFormatTypeSelector(QVBoxLayout &v_box);
93  void addDisplayFilterEdit(QString &display_filter);
94  void addPreview(QVBoxLayout &v_box);
95  QString fileExtensionType(int et, bool extension_globs = true);
96  QString fileType(int ft, QStringList &suffixes);
97  QStringList buildFileOpenTypeList(void);
98 
99  QVBoxLayout left_v_box_;
100  QVBoxLayout right_v_box_;
101 
102  DisplayFilterEdit* display_filter_edit_;
103  int last_row_;
104 
105  QLabel preview_format_;
106  QLabel preview_size_;
107  QLabel preview_first_elapsed_;
108  QList<QLabel *> preview_labels_;
109 
110  QRadioButton merge_prepend_;
111  QRadioButton merge_chrono_;
112  QRadioButton merge_append_;
113 
114  QComboBox format_type_;
115  QHash<QString, int> type_hash_;
116  QHash<QString, QStringList> type_suffixes_;
117 
118  void addGzipControls(QVBoxLayout &v_box);
119  void addRangeControls(QVBoxLayout &v_box, packet_range_t *range, QString selRange = QString());
120  QDialogButtonBox *addHelpButton(topic_action_e help_topic);
121 
122  QStringList buildFileSaveAsTypeList(bool must_support_comments);
123 
124  int default_ft_;
125 
126  QCheckBox compress_;
127 
128  PacketRangeGroupBox packet_range_group_box_;
129  QPushButton *save_bt_;
130  topic_action_e help_topic_;
131 
132 #else // Q_OS_WIN
133  int file_type_;
134  int merge_type_;
135  wtap_compression_type compression_type_;
136 #endif // Q_OS_WIN
137 
138 signals:
139 
140 public slots:
141 
142 #ifndef Q_OS_WIN
143  void accept() Q_DECL_OVERRIDE;
144 #endif
145  int exec() Q_DECL_OVERRIDE;
146  int open(QString &file_name, unsigned int &type, QString &display_filter);
147  check_savability_t saveAs(QString &file_name, bool must_support_comments);
148  check_savability_t exportSelectedPackets(QString &file_name, packet_range_t *range, QString selRange = QString());
149  int merge(QString &file_name, QString &display_filter);
150 
151 private slots:
152 #if !defined(Q_OS_WIN)
153  void fixFilenameExtension();
154  void preview(const QString & path);
155  void on_buttonBox_helpRequested();
156 #endif // Q_OS_WIN
157 };
158 
159 #endif // CAPTURE_FILE_DIALOG_H
Definition: capture_file_dialog.h:36
Definition: display_filter_edit.h:28
Definition: packet_range_group_box.h:29
The WiresharkFileDialog class.
Definition: wireshark_file_dialog.h:30
Definition: cfile.h:67
Definition: packet_range.h:39