1 | /* $Id: UIDetailsWidgetNATNetwork.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIDetailsWidgetNATNetwork class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef FEQT_INCLUDED_SRC_networkmanager_UIDetailsWidgetNATNetwork_h
|
---|
29 | #define FEQT_INCLUDED_SRC_networkmanager_UIDetailsWidgetNATNetwork_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Qt includes: */
|
---|
35 | #include <QWidget>
|
---|
36 |
|
---|
37 | /* GUI includes: */
|
---|
38 | #include "QIManagerDialog.h"
|
---|
39 | #include "QIWithRetranslateUI.h"
|
---|
40 | #include "UIPortForwardingTable.h"
|
---|
41 |
|
---|
42 | /* Forward declarations: */
|
---|
43 | class QAbstractButton;
|
---|
44 | class QCheckBox;
|
---|
45 | class QLabel;
|
---|
46 | class QLineEdit;
|
---|
47 | class QRadioButton;
|
---|
48 | class QIDialogButtonBox;
|
---|
49 | class QILineEdit;
|
---|
50 | class QITabWidget;
|
---|
51 |
|
---|
52 |
|
---|
53 | /** Network Manager: NAT network data structure. */
|
---|
54 | struct UIDataNATNetwork
|
---|
55 | {
|
---|
56 | /** Constructs data. */
|
---|
57 | UIDataNATNetwork()
|
---|
58 | : m_fExists(false)
|
---|
59 | , m_strName(QString())
|
---|
60 | , m_strPrefixIPv4(QString())
|
---|
61 | , m_strPrefixIPv6(QString())
|
---|
62 | , m_fSupportsDHCP(false)
|
---|
63 | , m_fSupportsIPv6(false)
|
---|
64 | , m_fAdvertiseDefaultIPv6Route(false)
|
---|
65 | {}
|
---|
66 |
|
---|
67 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
68 | bool equal(const UIDataNATNetwork &other) const
|
---|
69 | {
|
---|
70 | return true
|
---|
71 | && (m_fExists == other.m_fExists)
|
---|
72 | && (m_strName == other.m_strName)
|
---|
73 | && (m_strPrefixIPv4 == other.m_strPrefixIPv4)
|
---|
74 | && (m_strPrefixIPv6 == other.m_strPrefixIPv6)
|
---|
75 | && (m_fSupportsDHCP == other.m_fSupportsDHCP)
|
---|
76 | && (m_fSupportsIPv6 == other.m_fSupportsIPv6)
|
---|
77 | && (m_fAdvertiseDefaultIPv6Route == other.m_fAdvertiseDefaultIPv6Route)
|
---|
78 | && (m_rules4 == other.m_rules4)
|
---|
79 | && (m_rules6 == other.m_rules6)
|
---|
80 | ;
|
---|
81 | }
|
---|
82 |
|
---|
83 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
84 | bool operator==(const UIDataNATNetwork &other) const { return equal(other); }
|
---|
85 | /** Returns whether the @a other passed data is different from this one. */
|
---|
86 | bool operator!=(const UIDataNATNetwork &other) const { return !equal(other); }
|
---|
87 |
|
---|
88 | /** Holds whether this network is not NULL. */
|
---|
89 | bool m_fExists;
|
---|
90 | /** Holds network name. */
|
---|
91 | QString m_strName;
|
---|
92 | /** Holds network IPv4 prefix. */
|
---|
93 | QString m_strPrefixIPv4;
|
---|
94 | /** Holds network IPv6 prefix. */
|
---|
95 | QString m_strPrefixIPv6;
|
---|
96 | /** Holds whether this network supports DHCP. */
|
---|
97 | bool m_fSupportsDHCP;
|
---|
98 | /** Holds whether this network supports IPv6. */
|
---|
99 | bool m_fSupportsIPv6;
|
---|
100 | /** Holds whether this network advertised as default IPv6 route. */
|
---|
101 | bool m_fAdvertiseDefaultIPv6Route;
|
---|
102 | /** Holds IPv4 port forwarding rules. */
|
---|
103 | UIPortForwardingDataList m_rules4;
|
---|
104 | /** Holds IPv6 port forwarding rules. */
|
---|
105 | UIPortForwardingDataList m_rules6;
|
---|
106 | };
|
---|
107 |
|
---|
108 |
|
---|
109 | /** Network Manager: NAT network details-widget. */
|
---|
110 | class UIDetailsWidgetNATNetwork : public QIWithRetranslateUI<QWidget>
|
---|
111 | {
|
---|
112 | Q_OBJECT;
|
---|
113 |
|
---|
114 | signals:
|
---|
115 |
|
---|
116 | /** Notifies listeners about data changed and whether it @a fDiffers. */
|
---|
117 | void sigDataChanged(bool fDiffers);
|
---|
118 |
|
---|
119 | /** Notifies listeners about data change rejected and should be reseted. */
|
---|
120 | void sigDataChangeRejected();
|
---|
121 | /** Notifies listeners about data change accepted and should be applied. */
|
---|
122 | void sigDataChangeAccepted();
|
---|
123 |
|
---|
124 | public:
|
---|
125 |
|
---|
126 | /** Constructs medium details dialog passing @a pParent to the base-class.
|
---|
127 | * @param enmEmbedding Brings embedding type. */
|
---|
128 | UIDetailsWidgetNATNetwork(EmbedTo enmEmbedding, QWidget *pParent = 0);
|
---|
129 |
|
---|
130 | /** Returns the host network data. */
|
---|
131 | const UIDataNATNetwork &data() const { return m_newData; }
|
---|
132 | /** Defines the host network @a data.
|
---|
133 | * @param busyNames Holds the list of names busy by other
|
---|
134 | * NAT networks.
|
---|
135 | * @param fHoldPosition Holds whether we should try to keep
|
---|
136 | * port forwarding rule position intact. */
|
---|
137 | void setData(const UIDataNATNetwork &data,
|
---|
138 | const QStringList &busyNames = QStringList(),
|
---|
139 | bool fHoldPosition = false);
|
---|
140 |
|
---|
141 | /** @name Change handling stuff.
|
---|
142 | * @{ */
|
---|
143 | /** Revalidates changes. */
|
---|
144 | bool revalidate() const;
|
---|
145 |
|
---|
146 | /** Updates button states. */
|
---|
147 | void updateButtonStates();
|
---|
148 | /** @} */
|
---|
149 |
|
---|
150 | protected:
|
---|
151 |
|
---|
152 | /** Handles translation event. */
|
---|
153 | virtual void retranslateUi() RT_OVERRIDE;
|
---|
154 |
|
---|
155 | private slots:
|
---|
156 |
|
---|
157 | /** @name Change handling stuff.
|
---|
158 | * @{ */
|
---|
159 | /** Handles network name text change. */
|
---|
160 | void sltNetworkNameChanged(const QString &strText);
|
---|
161 | /** Handles network IPv4 prefix text change. */
|
---|
162 | void sltNetworkIPv4PrefixChanged(const QString &strText);
|
---|
163 | /** Handles network IPv6 prefix text change. */
|
---|
164 | void sltNetworkIPv6PrefixChanged(const QString &strText);
|
---|
165 | /** Handles network supports DHCP choice change. */
|
---|
166 | void sltSupportsDHCPChanged(bool fChecked);
|
---|
167 | /** Handles network supports IPv6 choice change. */
|
---|
168 | void sltSupportsIPv6Changed(bool fChecked);
|
---|
169 | /** Handles network advertised as default IPv6 route choice change. */
|
---|
170 | void sltAdvertiseDefaultIPv6RouteChanged(bool fChecked);
|
---|
171 |
|
---|
172 | /** Handles IPv4 forwarding rules table change. */
|
---|
173 | void sltForwardingRulesIPv4Changed();
|
---|
174 | /** Handles IPv6 forwarding rules table change. */
|
---|
175 | void sltForwardingRulesIPv6Changed();
|
---|
176 |
|
---|
177 | /** Handles button-box button click. */
|
---|
178 | void sltHandleButtonBoxClick(QAbstractButton *pButton);
|
---|
179 | /** @} */
|
---|
180 |
|
---|
181 | private:
|
---|
182 |
|
---|
183 | /** @name Prepare/cleanup cascade.
|
---|
184 | * @{ */
|
---|
185 | /** Prepares all. */
|
---|
186 | void prepare();
|
---|
187 | /** Prepares this. */
|
---|
188 | void prepareThis();
|
---|
189 | /** Prepares tab-widget. */
|
---|
190 | void prepareTabWidget();
|
---|
191 | /** Prepares 'Options' tab. */
|
---|
192 | void prepareTabOptions();
|
---|
193 | /** Prepares 'Forwarding' tab. */
|
---|
194 | void prepareTabForwarding();
|
---|
195 | /** @} */
|
---|
196 |
|
---|
197 | /** @name Loading stuff.
|
---|
198 | * @{ */
|
---|
199 | /** Loads 'Options' data. */
|
---|
200 | void loadDataForOptions();
|
---|
201 | /** Loads 'Forwarding' data. */
|
---|
202 | void loadDataForForwarding();
|
---|
203 | /** @} */
|
---|
204 |
|
---|
205 | /** @name General variables.
|
---|
206 | * @{ */
|
---|
207 | /** Holds the parent widget embedding type. */
|
---|
208 | const EmbedTo m_enmEmbedding;
|
---|
209 |
|
---|
210 | /** Holds the old data copy. */
|
---|
211 | UIDataNATNetwork m_oldData;
|
---|
212 | /** Holds the new data copy. */
|
---|
213 | UIDataNATNetwork m_newData;
|
---|
214 |
|
---|
215 | /** Holds the tab-widget. */
|
---|
216 | QITabWidget *m_pTabWidget;
|
---|
217 | /** @} */
|
---|
218 |
|
---|
219 | /** @name Network variables.
|
---|
220 | * @{ */
|
---|
221 | /** Holds the network name label instance. */
|
---|
222 | QLabel *m_pLabelNetworkName;
|
---|
223 | /** Holds the network name editor instance. */
|
---|
224 | QLineEdit *m_pEditorNetworkName;
|
---|
225 | /** Holds the network IPv4 prefix label instance. */
|
---|
226 | QLabel *m_pLabelNetworkIPv4Prefix;
|
---|
227 | /** Holds the network IPv4 prefix editor instance. */
|
---|
228 | QLineEdit *m_pEditorNetworkIPv4Prefix;
|
---|
229 | /** Holds the 'supports DHCP' check-box instance. */
|
---|
230 | QCheckBox *m_pCheckboxSupportsDHCP;
|
---|
231 | /** Holds the IPv4 group-box instance. */
|
---|
232 | QCheckBox *m_pCheckboxIPv6;
|
---|
233 | /** Holds the network IPv6 prefix label instance. */
|
---|
234 | QLabel *m_pLabelNetworkIPv6Prefix;
|
---|
235 | /** Holds the network IPv6 prefix editor instance. */
|
---|
236 | QLineEdit *m_pEditorNetworkIPv6Prefix;
|
---|
237 | /** Holds the 'advertise default IPv6 route' check-box instance. */
|
---|
238 | QCheckBox *m_pCheckboxAdvertiseDefaultIPv6Route;
|
---|
239 | /** Holds the 'Options' button-box instance. */
|
---|
240 | QIDialogButtonBox *m_pButtonBoxOptions;
|
---|
241 | /** Holds the list of names busy by other
|
---|
242 | * NAT networks. */
|
---|
243 | QStringList m_busyNames;
|
---|
244 | /** @} */
|
---|
245 |
|
---|
246 | /** @name Forwarding variables.
|
---|
247 | * @{ */
|
---|
248 | /** */
|
---|
249 | QITabWidget *m_pTabWidgetForwarding;
|
---|
250 | /** */
|
---|
251 | UIPortForwardingTable *m_pForwardingTableIPv4;
|
---|
252 | /** */
|
---|
253 | UIPortForwardingTable *m_pForwardingTableIPv6;
|
---|
254 | /** Holds the 'Forwarding' button-box instance. */
|
---|
255 | QIDialogButtonBox *m_pButtonBoxForwarding;
|
---|
256 | /** Holds whether we should try to keep
|
---|
257 | * port forwarding rule position intact. */
|
---|
258 | bool m_fHoldPosition;
|
---|
259 | /** @} */
|
---|
260 | };
|
---|
261 |
|
---|
262 |
|
---|
263 | #endif /* !FEQT_INCLUDED_SRC_networkmanager_UIDetailsWidgetNATNetwork_h */
|
---|
264 |
|
---|