Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / ui / qt / extcap_argument.h
blob4d9528263bdf033563577dbf269b1b234ed86c48
1 /** @file
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
10 #ifndef UI_QT_EXTCAP_ARGUMENT_H_
11 #define UI_QT_EXTCAP_ARGUMENT_H_
13 #include <QObject>
14 #include <QWidget>
15 #include <QLabel>
16 #include <QVariant>
17 #include <QList>
18 #include <QLineEdit>
19 #include <QComboBox>
20 #include <QButtonGroup>
21 #include <QCheckBox>
22 #include <QDateTime>
24 #include <extcap_parser.h>
26 #define EXTCAP_GUI_BLANK_LABEL "QLabel { color : ; }"
27 #define EXTCAP_GUI_ERROR_LABEL "QLabel { color : red; }"
29 class ExtcapValue;
31 typedef QList<ExtcapValue> ExtcapValueList;
33 class ExtcapValue
35 public:
36 ExtcapValue(QString value, QString call, bool enabled, bool isDefault) :
37 _value(value), _call(call), _enabled(enabled),
38 _isDefault(isDefault), _depth(0) {}
39 virtual ~ExtcapValue();
41 void setChildren(ExtcapValueList children);
42 ExtcapValueList children()
44 if (_children.length() == 0)
45 return ExtcapValueList();
46 return _children;
49 QString value() const { return _value; }
50 const QString call() const { return _call; }
51 bool enabled() const { return _enabled; }
52 bool isDefault() const { return _isDefault; }
54 int depth() { return _depth; }
56 private:
57 QString _value;
58 QString _call;
60 bool _enabled;
61 bool _isDefault;
63 int _depth;
65 ExtcapValueList _children;
70 class ExtcapArgument: public QObject
72 Q_OBJECT
74 public:
75 ExtcapArgument(QObject *parent = Q_NULLPTR);
76 ExtcapArgument(extcap_arg * argument, QObject *parent = Q_NULLPTR);
77 ExtcapArgument(const ExtcapArgument &obj);
78 virtual ~ExtcapArgument();
80 virtual QWidget * createLabel(QWidget * parent = 0);
81 virtual QWidget * createEditor(QWidget * parent = 0);
83 virtual extcap_arg * argument() { return _argument; }
84 virtual QString call();
85 virtual QString value();
86 virtual QString defaultValue();
88 bool isDefault();
89 virtual bool isValid();
90 bool isRequired();
91 bool reload();
93 QString prefKey(const QString & device_name);
94 virtual QString prefValue();
96 void resetValue();
98 virtual QString group() const;
99 virtual int argNr() const;
101 static ExtcapArgument * create(extcap_arg * argument = Q_NULLPTR, QObject * parent = Q_NULLPTR);
102 virtual bool isSetDefaultValueSupported();
104 public Q_SLOTS:
105 virtual void setDefaultValue();
106 void onBoolChanged(bool);
107 void onIntChanged(int);
108 void onStringChanged(QString);
110 Q_SIGNALS:
111 void valueChanged();
113 protected:
115 bool fileExists();
117 ExtcapValueList loadValues(QString parent);
118 bool reloadValues();
120 ExtcapValueList values;
122 extcap_arg * _argument;
123 QLabel * _label;
124 int _number;
126 const QString label_style;
131 class ExtArgText : public ExtcapArgument
133 Q_OBJECT
135 public:
136 ExtArgText(extcap_arg * argument, QObject *parent = Q_NULLPTR);
138 virtual QWidget * createEditor(QWidget * parent);
139 virtual QString value();
140 virtual bool isValid();
141 virtual bool isSetDefaultValueSupported();
143 public Q_SLOTS:
144 virtual void setDefaultValue();
146 protected:
148 QLineEdit * textBox;
153 class ExtArgNumber : public ExtArgText
155 Q_OBJECT
157 public:
158 ExtArgNumber(extcap_arg * argument, QObject *parent = Q_NULLPTR);
160 virtual QWidget * createEditor(QWidget * parent);
161 virtual QString defaultValue();
166 class ExtArgSelector : public ExtcapArgument
168 Q_OBJECT
170 public:
171 ExtArgSelector(extcap_arg * argument, QObject *parent = Q_NULLPTR);
173 virtual QWidget * createEditor(QWidget * parent);
174 virtual QString value();
175 virtual bool isValid();
176 virtual bool isSetDefaultValueSupported();
178 public Q_SLOTS:
179 virtual void setDefaultValue();
181 protected:
182 QComboBox * boxSelection;
184 private Q_SLOTS:
185 void onReloadTriggered();
190 class ExtArgEditSelector : public ExtArgSelector
192 Q_OBJECT
194 public:
195 ExtArgEditSelector(extcap_arg * argument, QObject *parent = Q_NULLPTR);
196 virtual QWidget * createEditor(QWidget * parent);
197 virtual QString value();
199 public Q_SLOTS:
200 virtual void setDefaultValue();
204 class ExtArgRadio : public ExtcapArgument
206 Q_OBJECT
208 public:
209 ExtArgRadio(extcap_arg * argument, QObject *parent = Q_NULLPTR);
210 virtual ~ExtArgRadio();
212 virtual QWidget * createEditor(QWidget * parent);
213 virtual QString value();
214 virtual bool isValid();
215 virtual bool isSetDefaultValueSupported();
217 public Q_SLOTS:
218 virtual void setDefaultValue();
220 private:
222 QButtonGroup * selectorGroup;
223 QList<QString> * callStrings;
228 class ExtArgBool : public ExtcapArgument
230 Q_OBJECT
232 public:
233 ExtArgBool(extcap_arg * argument, QObject *parent = Q_NULLPTR);
235 virtual QWidget * createLabel(QWidget * parent);
236 virtual QWidget * createEditor(QWidget * parent);
238 virtual QString call();
239 virtual QString value();
240 virtual bool isValid();
241 virtual QString defaultValue();
242 virtual QString prefValue();
243 virtual bool isSetDefaultValueSupported();
245 public Q_SLOTS:
246 virtual void setDefaultValue();
248 private:
250 QCheckBox * boolBox;
252 bool defaultBool();
257 class ExtArgTimestamp : public ExtcapArgument
259 Q_OBJECT
261 public:
262 ExtArgTimestamp(extcap_arg * argument, QObject *parent = Q_NULLPTR);
263 virtual QWidget * createEditor(QWidget * parent);
265 virtual bool isValid();
266 virtual QString defaultValue();
267 virtual QString value();
268 virtual QString prefValue();
269 virtual bool isSetDefaultValueSupported();
271 public Q_SLOTS:
272 virtual void setDefaultValue();
274 private Q_SLOTS:
275 void onDateTimeChanged(QDateTime);
277 private:
278 QDateTime ts;
279 QDateTimeEdit *tsBox;
282 #endif /* UI_QT_EXTCAP_ARGUMENT_H_ */