Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
capture_file_dialog.h
1 /* capture_file_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 CAPTURE_FILE_DIALOG_H
11 #define CAPTURE_FILE_DIALOG_H
12 
13 #ifndef Q_OS_WIN
14 #include <ui/qt/widgets/display_filter_edit.h>
15 #include "packet_range_group_box.h"
16 #include "ui/help_url.h"
17 #endif // Q_OS_WIN
18 
19 #include <ui/packet_range.h>
20 
21 #include <ui/qt/models/packet_list_record.h>
22 #include "cfile.h"
23 
24 #include "ui/file_dialog.h"
25 
26 #include <QFileDialog>
27 #include <QVBoxLayout>
28 #include <QLabel>
29 #include <QRadioButton>
30 #include <QCheckBox>
31 #include <QDialogButtonBox>
32 #include <QComboBox>
33 
34 class CaptureFileDialog : public QFileDialog
35 {
36  // The GTK+ Open Capture File dialog has the following elements and features:
37  // - The ability to select a capture file from a list of known extensions
38  // - A display filter entry
39  // - Name resolution checkboxes
40  // - Capture file preview information
41  // Ideally we should provide similar functionality here.
42  //
43  // You can subclass QFileDialog (which we've done here) and add widgets as
44  // described at
45  // http://developer.qt.nokia.com/faq/answer/how_can_i_add_widgets_to_my_qfiledialog_instance
46  // However, Qt's idea of what a file dialog looks like isn't what Microsoft
47  // and Apple think a file dialog looks like.
48  //
49  // On Windows Vista and later we should probably use IFileOpenDialog. On earlier
50  // versions of Windows (including XP) we should use GetOpenFileName, which is
51  // what we do in ui/win32/file_dlg_win32.c. macOS we should use NSOpenPanel. On
52  // other platforms we should fall back to QFileDialog.
53  //
54  // Yes, that's four implementations of the same window.
55  //
56  // If a plain native open file dialog is good enough we can just the static
57  // version of QFileDialog::getOpenFileName. (Commenting out Q_OBJECT and
58  // "explicit" below has the same effect.)
59 
60  Q_OBJECT
61 public:
62  explicit CaptureFileDialog(QWidget *parent = NULL, capture_file *cf = NULL, QString &display_filter = *new QString());
63  static check_savability_t checkSaveAsWithComments(QWidget *
64 #if defined(Q_OS_WIN)
65  parent
66 #endif // Q_OS_WIN
67  , capture_file *cf, int file_type);
68 
69  int mergeType();
70  int selectedFileType();
71  bool isCompressed();
72 
73 private:
74  capture_file *cap_file_;
75  QString &display_filter_;
76 
77 #if !defined(Q_OS_WIN)
78  void addMergeControls(QVBoxLayout &v_box);
79  void addFormatTypeSelector(QVBoxLayout &v_box);
80  void addDisplayFilterEdit();
81  void addPreview(QVBoxLayout &v_box);
82  QString fileExtensionType(int et, bool extension_globs = true);
83  QString fileType(int ft, QStringList &suffixes);
84  QStringList buildFileOpenTypeList(void);
85 
86  QVBoxLayout left_v_box_;
87  QVBoxLayout right_v_box_;
88 
89  DisplayFilterEdit* display_filter_edit_;
90  int last_row_;
91 
92  QLabel preview_format_;
93  QLabel preview_size_;
94  QLabel preview_first_elapsed_;
95  QList<QLabel *> preview_labels_;
96 
97  QRadioButton merge_prepend_;
98  QRadioButton merge_chrono_;
99  QRadioButton merge_append_;
100 
101  QComboBox format_type_;
102  QHash<QString, int> type_hash_;
103  QHash<QString, QStringList> type_suffixes_;
104 
105  void addGzipControls(QVBoxLayout &v_box);
106  void addRangeControls(QVBoxLayout &v_box, packet_range_t *range);
107  QDialogButtonBox *addHelpButton(topic_action_e help_topic);
108 
109  QStringList buildFileSaveAsTypeList(bool must_support_comments);
110 
111  int default_ft_;
112 
113  QCheckBox compress_;
114 
115  PacketRangeGroupBox packet_range_group_box_;
116  QPushButton *save_bt_;
117  topic_action_e help_topic_;
118 
119 #else // Q_OS_WIN
120  int file_type_;
121  int merge_type_;
122  gboolean compressed_;
123 #endif // Q_OS_WIN
124 
125 signals:
126 
127 public slots:
128 
129 #ifndef Q_OS_WIN
130  void accept() Q_DECL_OVERRIDE;
131 #endif
132  int exec() Q_DECL_OVERRIDE;
133  int open(QString &file_name, unsigned int &type);
134  check_savability_t saveAs(QString &file_name, bool must_support_comments);
135  check_savability_t exportSelectedPackets(QString &file_name, packet_range_t *range);
136  int merge(QString &file_name);
137 
138 private slots:
139 #if !defined(Q_OS_WIN)
140  void fixFilenameExtension();
141  void preview(const QString & path);
142  void on_buttonBox_helpRequested();
143 #endif // Q_OS_WIN
144 };
145 
146 #endif // CAPTURE_FILE_DIALOG_H
147 
148 /*
149  * Editor modelines
150  *
151  * Local Variables:
152  * c-basic-offset: 4
153  * tab-width: 8
154  * indent-tabs-mode: nil
155  * End:
156  *
157  * ex: set shiftwidth=4 tabstop=8 expandtab:
158  * :indentSize=4:tabSize=8:noTabs=true:
159  */
Definition: capture_file_dialog.h:34
Definition: packet_range_group_box.h:26
Definition: packet_range.h:38
Definition: cfile.h:58
Definition: display_filter_edit.h:26