Fix comment end after SPDX identifier
[metze/wireshark/wip.git] / ui / qt / show_packet_bytes_dialog.h
1 /* show_packet_bytes_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 SHOW_PACKET_BYTES_DIALOG_H
11 #define SHOW_PACKET_BYTES_DIALOG_H
12
13 #include <config.h>
14 #include <glib.h>
15 #include <stdio.h>
16
17 #ifdef HAVE_UNISTD_H
18 #include <unistd.h>
19 #endif
20
21 #include "file.h"
22 #include "wireshark_dialog.h"
23
24 #include <QLineEdit>
25 #include <QPushButton>
26 #include <QTextEdit>
27
28 namespace Ui {
29 class ShowPacketBytesDialog;
30 class ShowPacketBytesTextEdit;
31 }
32
33 class ShowPacketBytesDialog : public WiresharkDialog
34 {
35     Q_OBJECT
36
37 public:
38     explicit ShowPacketBytesDialog(QWidget &parent, CaptureFile &cf);
39     ~ShowPacketBytesDialog();
40
41 public slots:
42     void captureFileClosing();
43
44 protected:
45     bool eventFilter(QObject *obj, QEvent *event);
46     void keyPressEvent(QKeyEvent *event);
47
48 private slots:
49     void on_sbStart_valueChanged(int value);
50     void on_sbEnd_valueChanged(int value);
51     void on_cbDecodeAs_currentIndexChanged(int idx);
52     void on_cbShowAs_currentIndexChanged(int idx);
53     void on_leFind_returnPressed();
54     void on_bFind_clicked();
55     void on_buttonBox_rejected();
56
57     void showSelected(int start, int end);
58     void useRegexFind(bool use_regex);
59     void findText(bool go_back = true);
60     void helpButton();
61     void printBytes();
62     void copyBytes();
63     void saveAs();
64
65 private:
66     enum DecodeAsType {
67         DecodeAsNone,
68         DecodeAsBASE64,
69         DecodeAsCompressed,
70         DecodeAsQuotedPrintable,
71         DecodeAsROT13
72     };
73     enum ShowAsType {
74         ShowAsASCII,
75         ShowAsASCIIandControl,
76         ShowAsCArray,
77         ShowAsEBCDIC,
78         ShowAsHexDump,
79         ShowAsHTML,
80         ShowAsImage,
81         ShowAsISO8859_1,
82         ShowAsRAW,
83         ShowAsUTF8,
84         ShowAsYAML
85     };
86
87     void setStartAndEnd(int start, int end);
88     bool enableShowSelected();
89     void updateWidgets(); // Needed for WiresharkDialog?
90     void updateHintLabel();
91     void sanitizeBuffer(QByteArray &ba, bool handle_CR);
92     void symbolizeBuffer(QByteArray &ba);
93     QByteArray decodeQuotedPrintable(const guint8 *bytes, int length);
94     void rot13(QByteArray &ba);
95     void updateFieldBytes(bool initialization = false);
96     void updatePacketBytes();
97
98     Ui::ShowPacketBytesDialog  *ui;
99
100     const field_info  *finfo_;
101     QByteArray  field_bytes_;
102     QString     hint_label_;
103     QPushButton *print_button_;
104     QPushButton *copy_button_;
105     QPushButton *save_as_button_;
106     DecodeAsType decode_as_;
107     ShowAsType  show_as_;
108     bool        use_regex_find_;
109     int         start_;
110     int         end_;
111     QImage      image_;
112 };
113
114 class ShowPacketBytesTextEdit : public QTextEdit
115 {
116     Q_OBJECT
117
118 public:
119     explicit ShowPacketBytesTextEdit(QWidget *parent = 0) :
120         QTextEdit(parent), show_selected_enabled_(true), menus_enabled_(true) { }
121     ~ShowPacketBytesTextEdit() { }
122
123     void setShowSelectedEnabled(bool enabled) { show_selected_enabled_ = enabled; }
124     void setMenusEnabled(bool enabled) { menus_enabled_ = enabled; }
125
126 signals:
127     void showSelected(int, int);
128
129 private slots:
130     void contextMenuEvent(QContextMenuEvent *event);
131     void showSelected();
132     void showAll();
133
134 private:
135     bool show_selected_enabled_;
136     bool menus_enabled_;
137 };
138
139 #endif // SHOW_PACKET_BYTES_DIALOG_H
140
141 /*
142  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
143  *
144  * Local variables:
145  * c-basic-offset: 4
146  * tab-width: 8
147  * indent-tabs-mode: nil
148  * End:
149  *
150  * vi: set shiftwidth=4 tabstop=8 expandtab:
151  * :indentSize=4:tabSize=8:noTabs=true:
152  */