aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/interface_toolbar.h
blob: 9e58c43b304bcade6d61c881b135eb6e3838bc94 (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
/* interface_toolbar.h
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef INTERFACE_TOOLBAR_H
#define INTERFACE_TOOLBAR_H

#include <glib.h>

#include "ui/iface_toolbar.h"
#include "funnel_text_dialog.h"
#include "interface_toolbar_reader.h"

#include <QFrame>
#include <QList>
#include <QMap>
#include <QString>


namespace Ui {
class InterfaceToolbar;
}

struct interface_values
{
    QThread *reader_thread;
    int out_fd;
    QMap<int, QByteArray> value;
    QMap<int, bool> value_changed;
    QMap<int, QList<QByteArray> > list;
    QMap<int, FunnelTextDialog *> log_dialog;
    QMap<int, QString> log_text;
    QMap<int, bool> widget_disabled;
};

class InterfaceToolbar : public QFrame
{
    Q_OBJECT

public:
    explicit InterfaceToolbar(QWidget *parent = 0, const iface_toolbar *toolbar = NULL);
    ~InterfaceToolbar();

    void startCapture(GArray *ifaces);
    void stopCapture();
    bool hasInterface(QString ifname);

public slots:
    void interfaceListChanged();
    void controlReceived(QString ifname, int num, int command, QByteArray message);

signals:
    void closeReader();

private slots:
    void startReaderThread(QString ifname, void *control_in);
    void updateWidgets();

    void onControlButtonClicked();
    void onLogButtonClicked();
    void onHelpButtonClicked();
    void onRestoreButtonClicked();
    void onCheckBoxChanged(int state);
    void onComboBoxChanged(int idx);
    void onLineEditChanged();

    void closeLog();

    void on_interfacesComboBox_currentIndexChanged(const QString &ifname);

private:
    void initializeControls(const iface_toolbar *toolbar);
    void setDefaultValue(int num, const QByteArray &value);
    void sendChangedValues(QString ifname);
    QWidget *createCheckbox(iface_toolbar_control *control);
    QWidget *createButton(iface_toolbar_control *control);
    QWidget *createSelector(iface_toolbar_control *control);
    QWidget *createString(iface_toolbar_control *control);
    void controlSend(QString ifname, int num, int type, const QByteArray &payload);
    void setWidgetValue(QWidget *widget, int type, QByteArray payload);
    void setInterfaceValue(QString ifname, QWidget *widget, int num, int type, QByteArray payload);

    Ui::InterfaceToolbar *ui;
    QMap<QString, struct interface_values> interface_;
    QMap<int, QByteArray> default_value_;
    QMap<int, QList<QByteArray> > default_list_;
    QMap<int, QWidget *> control_widget_;
    QMap<int, QWidget *> label_widget_;
    QString help_link_;
    bool use_spacer_;
};

#endif // INTERFACE_TOOLBAR_H

/*
 * Editor modelines
 *
 * Local Variables:
 * c-basic-offset: 4
 * tab-width: 8
 * indent-tabs-mode: nil
 * End:
 *
 * ex: set shiftwidth=4 tabstop=8 expandtab:
 * :indentSize=4:tabSize=8:noTabs=true:
 */