1 | /* $Id: UIDetailsWidgetNATNetwork.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIDetailsWidgetNATNetwork class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2024 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 "UIPortForwardingTable.h"
|
---|
40 |
|
---|
41 | /* Forward declarations: */
|
---|
42 | class QAbstractButton;
|
---|
43 | class QCheckBox;
|
---|
44 | class QLabel;
|
---|
45 | class QLineEdit;
|
---|
46 | class QRadioButton;
|
---|
47 | class QIDialogButtonBox;
|
---|
48 | class QILineEdit;
|
---|
49 | class QITabWidget;
|
---|
50 |
|
---|
51 |
|
---|
52 | /** Network Manager: NAT network data structure. */
|
---|
53 | struct UIDataNATNetwork
|
---|
54 | {
|
---|
55 | /** Constructs data. */
|
---|
56 | UIDataNATNetwork()
|
---|
57 | : m_fExists(false)
|
---|
58 | , m_strName(QString())
|
---|
59 | , m_strPrefixIPv4(QString())
|
---|
60 | , m_strPrefixIPv6(QString())
|
---|
61 | , m_fSupportsDHCP(false)
|
---|
62 | , m_fSupportsIPv6(false)
|
---|
63 | , m_fAdvertiseDefaultIPv6Route(false)
|
---|
64 | {}
|
---|
65 |
|
---|
66 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
67 | bool equal(const UIDataNATNetwork &other) const
|
---|
68 | {
|
---|
69 | return true
|
---|
70 | && (m_fExists == other.m_fExists)
|
---|
71 | && (m_strName == other.m_strName)
|
---|
72 | && (m_strPrefixIPv4 == other.m_strPrefixIPv4)
|
---|
73 | && (m_strPrefixIPv6 == other.m_strPrefixIPv6)
|
---|
74 | && (m_fSupportsDHCP == other.m_fSupportsDHCP)
|
---|
75 | && (m_fSupportsIPv6 == other.m_fSupportsIPv6)
|
---|
76 | && (m_fAdvertiseDefaultIPv6Route == other.m_fAdvertiseDefaultIPv6Route)
|
---|
77 | && (m_rules4 == other.m_rules4)
|
---|
78 | && (m_rules6 == other.m_rules6)
|
---|
79 | ;
|
---|
80 | }
|
---|
81 |
|
---|
82 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
83 | bool operator==(const UIDataNATNetwork &other) const { return equal(other); }
|
---|
84 | /** Returns whether the @a other passed data is different from this one. */
|
---|
85 | bool operator!=(const UIDataNATNetwork &other) const { return !equal(other); }
|
---|
86 |
|
---|
87 | /** Holds whether this network is not NULL. */
|
---|
88 | bool m_fExists;
|
---|
89 | /** Holds network name. */
|
---|
90 | QString m_strName;
|
---|
91 | /** Holds network IPv4 prefix. */
|
---|
92 | QString m_strPrefixIPv4;
|
---|
93 | /** Holds network IPv6 prefix. */
|
---|
94 | QString m_strPrefixIPv6;
|
---|
95 | /** Holds whether this network supports DHCP. */
|
---|
96 | bool m_fSupportsDHCP;
|
---|
97 | /** Holds whether this network supports IPv6. */
|
---|
98 | bool m_fSupportsIPv6;
|
---|
99 | /** Holds whether this network advertised as default IPv6 route. */
|
---|
100 | bool m_fAdvertiseDefaultIPv6Route;
|
---|
101 | /** Holds IPv4 port forwarding rules. */
|
---|
102 | UIPortForwardingDataList m_rules4;
|
---|
103 | /** Holds IPv6 port forwarding rules. */
|
---|
104 | UIPortForwardingDataList m_rules6;
|
---|
105 | };
|
---|
106 |
|
---|
107 |
|
---|
108 | /** Network Manager: NAT network details-widget. */
|
---|
109 | class UIDetailsWidgetNATNetwork : public QWidget
|
---|
110 | {
|
---|
111 | Q_OBJECT;
|
---|
112 |
|
---|
113 | signals:
|
---|
114 |
|
---|
115 | /** Notifies listeners about data changed and whether it @a fDiffers. */
|
---|
116 | void sigDataChanged(bool fDiffers);
|
---|
117 |
|
---|
118 | /** Notifies listeners about data change rejected and should be reseted. */
|
---|
119 | void sigDataChangeRejected();
|
---|
120 | /** Notifies listeners about data change accepted and should be applied. */
|
---|
121 | void sigDataChangeAccepted();
|
---|
122 |
|
---|
123 | public:
|
---|
124 |
|
---|
125 | /** Constructs medium details dialog passing @a pParent to the base-class.
|
---|
126 | * @param enmEmbedding Brings embedding type. */
|
---|
127 | UIDetailsWidgetNATNetwork(EmbedTo enmEmbedding, QWidget *pParent = 0);
|
---|
128 |
|
---|
129 | /** Returns the host network data. */
|
---|
130 | const UIDataNATNetwork &data() const { return m_newData; }
|
---|
131 | /** Defines the host network @a data.
|
---|
132 | * @param busyNames Holds the list of names busy by other
|
---|
133 | * NAT networks.
|
---|
134 | * @param fHoldPosition Holds whether we should try to keep
|
---|
135 | * port forwarding rule position intact. */
|
---|
136 | void setData(const UIDataNATNetwork &data,
|
---|
137 | const QStringList &busyNames = QStringList(),
|
---|
138 | bool fHoldPosition = false);
|
---|
139 |
|
---|
140 | /** @name Change handling stuff.
|
---|
141 | * @{ */
|
---|
142 | /** Revalidates changes. */
|
---|
143 | bool revalidate() const;
|
---|
144 |
|
---|
145 | /** Updates button states. */
|
---|
146 | void updateButtonStates();
|
---|
147 | /** @} */
|
---|
148 |
|
---|
149 | private slots:
|
---|
150 |
|
---|
151 | /** @name Change handling stuff.
|
---|
152 | * @{ */
|
---|
153 | /** Handles network name text change. */
|
---|
154 | void sltNetworkNameChanged(const QString &strText);
|
---|
155 | /** Handles network IPv4 prefix text change. */
|
---|
156 | void sltNetworkIPv4PrefixChanged(const QString &strText);
|
---|
157 | /** Handles network IPv6 prefix text change. */
|
---|
158 | void sltNetworkIPv6PrefixChanged(const QString &strText);
|
---|
159 | /** Handles network supports DHCP choice change. */
|
---|
160 | void sltSupportsDHCPChanged(bool fChecked);
|
---|
161 | /** Handles network supports IPv6 choice change. */
|
---|
162 | void sltSupportsIPv6Changed(bool fChecked);
|
---|
163 | /** Handles network advertised as default IPv6 route choice change. */
|
---|
164 | void sltAdvertiseDefaultIPv6RouteChanged(bool fChecked);
|
---|
165 |
|
---|
166 | /** Handles IPv4 forwarding rules table change. */
|
---|
167 | void sltForwardingRulesIPv4Changed();
|
---|
168 | /** Handles IPv6 forwarding rules table change. */
|
---|
169 | void sltForwardingRulesIPv6Changed();
|
---|
170 |
|
---|
171 | /** Handles button-box button click. */
|
---|
172 | void sltHandleButtonBoxClick(QAbstractButton *pButton);
|
---|
173 | /** @} */
|
---|
174 | /** Handles translation event. */
|
---|
175 | void sltRetranslateUI();
|
---|
176 |
|
---|
177 | private:
|
---|
178 |
|
---|
179 | /** @name Prepare/cleanup cascade.
|
---|
180 | * @{ */
|
---|
181 | /** Prepares all. */
|
---|
182 | void prepare();
|
---|
183 | /** Prepares this. */
|
---|
184 | void prepareThis();
|
---|
185 | /** Prepares tab-widget. */
|
---|
186 | void prepareTabWidget();
|
---|
187 | /** Prepares 'Options' tab. */
|
---|
188 | void prepareTabOptions();
|
---|
189 | /** Prepares 'Forwarding' tab. */
|
---|
190 | void prepareTabForwarding();
|
---|
191 | /** @} */
|
---|
192 |
|
---|
193 | /** @name Loading stuff.
|
---|
194 | * @{ */
|
---|
195 | /** Loads 'Options' data. */
|
---|
196 | void loadDataForOptions();
|
---|
197 | /** Loads 'Forwarding' data. */
|
---|
198 | void loadDataForForwarding();
|
---|
199 | /** @} */
|
---|
200 |
|
---|
201 | /** @name General variables.
|
---|
202 | * @{ */
|
---|
203 | /** Holds the parent widget embedding type. */
|
---|
204 | const EmbedTo m_enmEmbedding;
|
---|
205 |
|
---|
206 | /** Holds the old data copy. */
|
---|
207 | UIDataNATNetwork m_oldData;
|
---|
208 | /** Holds the new data copy. */
|
---|
209 | UIDataNATNetwork m_newData;
|
---|
210 |
|
---|
211 | /** Holds the tab-widget. */
|
---|
212 | QITabWidget *m_pTabWidget;
|
---|
213 | /** @} */
|
---|
214 |
|
---|
215 | /** @name Network variables.
|
---|
216 | * @{ */
|
---|
217 | /** Holds the network name label instance. */
|
---|
218 | QLabel *m_pLabelNetworkName;
|
---|
219 | /** Holds the network name editor instance. */
|
---|
220 | QLineEdit *m_pEditorNetworkName;
|
---|
221 | /** Holds the network IPv4 prefix label instance. */
|
---|
222 | QLabel *m_pLabelNetworkIPv4Prefix;
|
---|
223 | /** Holds the network IPv4 prefix editor instance. */
|
---|
224 | QLineEdit *m_pEditorNetworkIPv4Prefix;
|
---|
225 | /** Holds the 'supports DHCP' check-box instance. */
|
---|
226 | QCheckBox *m_pCheckboxSupportsDHCP;
|
---|
227 | /** Holds the IPv4 group-box instance. */
|
---|
228 | QCheckBox *m_pCheckboxIPv6;
|
---|
229 | /** Holds the network IPv6 prefix label instance. */
|
---|
230 | QLabel *m_pLabelNetworkIPv6Prefix;
|
---|
231 | /** Holds the network IPv6 prefix editor instance. */
|
---|
232 | QLineEdit *m_pEditorNetworkIPv6Prefix;
|
---|
233 | /** Holds the 'advertise default IPv6 route' check-box instance. */
|
---|
234 | QCheckBox *m_pCheckboxAdvertiseDefaultIPv6Route;
|
---|
235 | /** Holds the 'Options' button-box instance. */
|
---|
236 | QIDialogButtonBox *m_pButtonBoxOptions;
|
---|
237 | /** Holds the list of names busy by other
|
---|
238 | * NAT networks. */
|
---|
239 | QStringList m_busyNames;
|
---|
240 | /** @} */
|
---|
241 |
|
---|
242 | /** @name Forwarding variables.
|
---|
243 | * @{ */
|
---|
244 | /** */
|
---|
245 | QITabWidget *m_pTabWidgetForwarding;
|
---|
246 | /** */
|
---|
247 | UIPortForwardingTable *m_pForwardingTableIPv4;
|
---|
248 | /** */
|
---|
249 | UIPortForwardingTable *m_pForwardingTableIPv6;
|
---|
250 | /** Holds the 'Forwarding' button-box instance. */
|
---|
251 | QIDialogButtonBox *m_pButtonBoxForwarding;
|
---|
252 | /** Holds whether we should try to keep
|
---|
253 | * port forwarding rule position intact. */
|
---|
254 | bool m_fHoldPosition;
|
---|
255 | /** @} */
|
---|
256 | };
|
---|
257 |
|
---|
258 |
|
---|
259 | #endif /* !FEQT_INCLUDED_SRC_networkmanager_UIDetailsWidgetNATNetwork_h */
|
---|