summaryrefslogtreecommitdiffstats
path: root/ui/qt/import_text_dialog.h
blob: ac9537d93dfe546b5aa601af438c241226ed174c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/** @file
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef IMPORT_TEXT_DIALOG_H
#define IMPORT_TEXT_DIALOG_H

#include <config.h>

#include <stdio.h>

#include <glib.h>

#include "ui/text_import.h"

#include <ui/qt/widgets/syntax_line_edit.h>

#include <QDialog>
#include <QPushButton>
#include <QRadioButton>
#include <QButtonGroup>

namespace Ui {
class ImportTextDialog;
}

class ImportTextDialog : public QDialog
{
    Q_OBJECT

public:
    explicit ImportTextDialog(QWidget *parent = 0);
    ~ImportTextDialog();
    QString &capfileName();

private:
    void enableHeaderWidgets(uint encapsulation = WTAP_ENCAP_ETHERNET);

    /* regex fields */
    void enableFieldWidgets(bool enable_direction_input = true, bool enable_time_input = true);

    void check_line_edit(SyntaxLineEdit *le, bool &ok_enable, const QString &num_str, int base, guint max_val, bool is_short, guint *val_ptr);
    void checkAddress(SyntaxLineEdit *le, bool &ok_enable, const QString &addr_str, ws_in4_addr *val_ptr);
    void checkIPv6Address(SyntaxLineEdit *le, bool &ok_enable, const QString &addr_str, ws_in6_addr *val_ptr);
    bool checkDateTimeFormat(const QString &time_format);

    void loadSettingsFile();
    void saveSettingsFile();
    void applyDialogSettings();
    void storeDialogSettings();

    void updateImportButtonState();

    Ui::ImportTextDialog *ti_ui_;
    QVariantMap settings;

    QPushButton *import_button_;
    QButtonGroup *encap_buttons;
    text_import_info_t import_info_;
    QString capfile_name_;
    bool file_ok_;
    bool timestamp_format_ok_;

    /* Regex input */
    bool regex_ok_;
    bool re_has_dir_;
    bool in_indication_ok_;
    bool out_indication_ok_;
    bool re_has_time_;

    bool ether_type_ok_;
    bool proto_ok_;
    bool source_addr_ok_;
    bool dest_addr_ok_;
    bool source_port_ok_;
    bool dest_port_ok_;
    bool tag_ok_;
    bool ppi_ok_;
    bool payload_ok_;
    bool max_len_ok_;

public slots:
    int exec();

private slots:
    void on_textFileBrowseButton_clicked();
    void on_textFileLineEdit_textChanged(const QString &arg1);
    void on_modeTabWidget_currentChanged(int index);
    void on_timestampFormatLineEdit_textChanged(const QString &arg1);

    /* Hex Dump input */
    void on_noOffsetButton_toggled(bool checked);
    void on_directionIndicationCheckBox_toggled(bool checked);
    void on_asciiIdentificationCheckBox_toggled(bool checked);

    /* Regex input */
    void on_regexTextEdit_textChanged();
    void on_dataEncodingComboBox_currentIndexChanged(int index);
    void on_dirInIndicationLineEdit_textChanged(const QString &arg1);
    void on_dirOutIndicationLineEdit_textChanged(const QString &arg1);

    /* Encapsulation input */
    void on_encapComboBox_currentIndexChanged(int index);
    void encap_buttonsToggled(QAbstractButton *button, bool checked);
    void on_ipVersionComboBox_currentIndexChanged(int index);
    void on_ethertypeLineEdit_textChanged(const QString &ethertype_str);
    void on_protocolLineEdit_textChanged(const QString &protocol_str);
    void on_sourceAddressLineEdit_textChanged(const QString &source_addr_str);
    void on_destinationAddressLineEdit_textChanged(const QString &destination_addr_str);
    void on_sourcePortLineEdit_textChanged(const QString &source_port_str);
    void on_destinationPortLineEdit_textChanged(const QString &destination_port_str);
    void on_tagLineEdit_textChanged(const QString &tag_str);
    void on_ppiLineEdit_textChanged(const QString &ppi_str);

    /* Footer input */
    void on_maxLengthLineEdit_textChanged(const QString &max_frame_len_str);
    void on_buttonBox_helpRequested();
};


#endif // IMPORT_TEXT_DIALOG_H