1 | /* $Id: UIDetailsWidgetHostNetwork.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIDetailsWidgetHostNetwork 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_UIDetailsWidgetHostNetwork_h
|
---|
29 | #define FEQT_INCLUDED_SRC_networkmanager_UIDetailsWidgetHostNetwork_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 |
|
---|
40 | /* Forward declarations: */
|
---|
41 | class QAbstractButton;
|
---|
42 | class QCheckBox;
|
---|
43 | class QLabel;
|
---|
44 | class QRadioButton;
|
---|
45 | class QIDialogButtonBox;
|
---|
46 | class QILineEdit;
|
---|
47 | class QITabWidget;
|
---|
48 |
|
---|
49 |
|
---|
50 | #ifdef VBOX_WS_MAC
|
---|
51 | /** Network Manager: Host network data structure. */
|
---|
52 | struct UIDataHostNetwork
|
---|
53 | {
|
---|
54 | /** Constructs data. */
|
---|
55 | UIDataHostNetwork()
|
---|
56 | : m_fExists(false)
|
---|
57 | , m_strName(QString())
|
---|
58 | , m_strMask(QString())
|
---|
59 | , m_strLBnd(QString())
|
---|
60 | , m_strUBnd(QString())
|
---|
61 | {}
|
---|
62 |
|
---|
63 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
64 | bool equal(const UIDataHostNetwork &other) const
|
---|
65 | {
|
---|
66 | return true
|
---|
67 | && (m_fExists == other.m_fExists)
|
---|
68 | && (m_strName == other.m_strName)
|
---|
69 | && (m_strMask == other.m_strMask)
|
---|
70 | && (m_strLBnd == other.m_strLBnd)
|
---|
71 | && (m_strUBnd == other.m_strUBnd)
|
---|
72 | ;
|
---|
73 | }
|
---|
74 |
|
---|
75 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
76 | bool operator==(const UIDataHostNetwork &other) const { return equal(other); }
|
---|
77 | /** Returns whether the @a other passed data is different from this one. */
|
---|
78 | bool operator!=(const UIDataHostNetwork &other) const { return !equal(other); }
|
---|
79 |
|
---|
80 | /** Holds this interface is not NULL. */
|
---|
81 | bool m_fExists;
|
---|
82 | /** Holds network name. */
|
---|
83 | QString m_strName;
|
---|
84 | /** Holds network mask. */
|
---|
85 | QString m_strMask;
|
---|
86 | /** Holds lower bound. */
|
---|
87 | QString m_strLBnd;
|
---|
88 | /** Holds upper bound. */
|
---|
89 | QString m_strUBnd;
|
---|
90 | };
|
---|
91 |
|
---|
92 | #else /* !VBOX_WS_MAC */
|
---|
93 |
|
---|
94 | /** Network Manager: Host Network Interface data structure. */
|
---|
95 | struct UIDataHostNetworkInterface
|
---|
96 | {
|
---|
97 | /** Constructs data. */
|
---|
98 | UIDataHostNetworkInterface()
|
---|
99 | : m_fExists(false)
|
---|
100 | , m_strName(QString())
|
---|
101 | , m_fDHCPEnabled(false)
|
---|
102 | , m_strAddress(QString())
|
---|
103 | , m_strMask(QString())
|
---|
104 | , m_fSupportedIPv6(false)
|
---|
105 | , m_strAddress6(QString())
|
---|
106 | , m_strPrefixLength6(QString())
|
---|
107 | {}
|
---|
108 |
|
---|
109 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
110 | bool equal(const UIDataHostNetworkInterface &other) const
|
---|
111 | {
|
---|
112 | return true
|
---|
113 | && (m_fExists == other.m_fExists)
|
---|
114 | && (m_strName == other.m_strName)
|
---|
115 | && (m_fDHCPEnabled == other.m_fDHCPEnabled)
|
---|
116 | && (m_strAddress == other.m_strAddress)
|
---|
117 | && (m_strMask == other.m_strMask)
|
---|
118 | && (m_fSupportedIPv6 == other.m_fSupportedIPv6)
|
---|
119 | && (m_strAddress6 == other.m_strAddress6)
|
---|
120 | && (m_strPrefixLength6 == other.m_strPrefixLength6)
|
---|
121 | ;
|
---|
122 | }
|
---|
123 |
|
---|
124 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
125 | bool operator==(const UIDataHostNetworkInterface &other) const { return equal(other); }
|
---|
126 | /** Returns whether the @a other passed data is different from this one. */
|
---|
127 | bool operator!=(const UIDataHostNetworkInterface &other) const { return !equal(other); }
|
---|
128 |
|
---|
129 | /** Holds this interface is not NULL. */
|
---|
130 | bool m_fExists;
|
---|
131 | /** Holds interface name. */
|
---|
132 | QString m_strName;
|
---|
133 | /** Holds whether DHCP is enabled for that interface. */
|
---|
134 | bool m_fDHCPEnabled;
|
---|
135 | /** Holds IPv4 interface address. */
|
---|
136 | QString m_strAddress;
|
---|
137 | /** Holds IPv4 interface mask. */
|
---|
138 | QString m_strMask;
|
---|
139 | /** Holds whether IPv6 protocol supported. */
|
---|
140 | bool m_fSupportedIPv6;
|
---|
141 | /** Holds IPv6 interface address. */
|
---|
142 | QString m_strAddress6;
|
---|
143 | /** Holds IPv6 interface prefix length. */
|
---|
144 | QString m_strPrefixLength6;
|
---|
145 | };
|
---|
146 |
|
---|
147 | /** Network Manager: DHCP Server data structure. */
|
---|
148 | struct UIDataDHCPServer
|
---|
149 | {
|
---|
150 | /** Constructs data. */
|
---|
151 | UIDataDHCPServer()
|
---|
152 | : m_fEnabled(false)
|
---|
153 | , m_strAddress(QString())
|
---|
154 | , m_strMask(QString())
|
---|
155 | , m_strLowerAddress(QString())
|
---|
156 | , m_strUpperAddress(QString())
|
---|
157 | {}
|
---|
158 |
|
---|
159 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
160 | bool equal(const UIDataDHCPServer &other) const
|
---|
161 | {
|
---|
162 | return true
|
---|
163 | && (m_fEnabled == other.m_fEnabled)
|
---|
164 | && (m_strAddress == other.m_strAddress)
|
---|
165 | && (m_strMask == other.m_strMask)
|
---|
166 | && (m_strLowerAddress == other.m_strLowerAddress)
|
---|
167 | && (m_strUpperAddress == other.m_strUpperAddress)
|
---|
168 | ;
|
---|
169 | }
|
---|
170 |
|
---|
171 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
172 | bool operator==(const UIDataDHCPServer &other) const { return equal(other); }
|
---|
173 | /** Returns whether the @a other passed data is different from this one. */
|
---|
174 | bool operator!=(const UIDataDHCPServer &other) const { return !equal(other); }
|
---|
175 |
|
---|
176 | /** Holds whether DHCP server enabled. */
|
---|
177 | bool m_fEnabled;
|
---|
178 | /** Holds DHCP server address. */
|
---|
179 | QString m_strAddress;
|
---|
180 | /** Holds DHCP server mask. */
|
---|
181 | QString m_strMask;
|
---|
182 | /** Holds DHCP server lower address. */
|
---|
183 | QString m_strLowerAddress;
|
---|
184 | /** Holds DHCP server upper address. */
|
---|
185 | QString m_strUpperAddress;
|
---|
186 | };
|
---|
187 |
|
---|
188 | /** Network Manager: Host network data structure. */
|
---|
189 | struct UIDataHostNetwork
|
---|
190 | {
|
---|
191 | /** Constructs data. */
|
---|
192 | UIDataHostNetwork()
|
---|
193 | : m_interface(UIDataHostNetworkInterface())
|
---|
194 | , m_dhcpserver(UIDataDHCPServer())
|
---|
195 | {}
|
---|
196 |
|
---|
197 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
198 | bool equal(const UIDataHostNetwork &other) const
|
---|
199 | {
|
---|
200 | return true
|
---|
201 | && (m_interface == other.m_interface)
|
---|
202 | && (m_dhcpserver == other.m_dhcpserver)
|
---|
203 | ;
|
---|
204 | }
|
---|
205 |
|
---|
206 | /** Returns whether the @a other passed data is equal to this one. */
|
---|
207 | bool operator==(const UIDataHostNetwork &other) const { return equal(other); }
|
---|
208 | /** Returns whether the @a other passed data is different from this one. */
|
---|
209 | bool operator!=(const UIDataHostNetwork &other) const { return !equal(other); }
|
---|
210 |
|
---|
211 | /** Holds the interface data. */
|
---|
212 | UIDataHostNetworkInterface m_interface;
|
---|
213 | /** Holds the DHCP server data. */
|
---|
214 | UIDataDHCPServer m_dhcpserver;
|
---|
215 | };
|
---|
216 | #endif /* !VBOX_WS_MAC */
|
---|
217 |
|
---|
218 |
|
---|
219 | /** Network Manager: Host network details-widget. */
|
---|
220 | class UIDetailsWidgetHostNetwork : public QWidget
|
---|
221 | {
|
---|
222 | Q_OBJECT;
|
---|
223 |
|
---|
224 | signals:
|
---|
225 |
|
---|
226 | /** Notifies listeners about data changed and whether it @a fDiffers. */
|
---|
227 | void sigDataChanged(bool fDiffers);
|
---|
228 |
|
---|
229 | /** Notifies listeners about data change rejected and should be reseted. */
|
---|
230 | void sigDataChangeRejected();
|
---|
231 | /** Notifies listeners about data change accepted and should be applied. */
|
---|
232 | void sigDataChangeAccepted();
|
---|
233 |
|
---|
234 | public:
|
---|
235 |
|
---|
236 | /** Constructs medium details dialog passing @a pParent to the base-class.
|
---|
237 | * @param enmEmbedding Brings embedding type. */
|
---|
238 | UIDetailsWidgetHostNetwork(EmbedTo enmEmbedding, QWidget *pParent = 0);
|
---|
239 |
|
---|
240 | /** Returns the host network data. */
|
---|
241 | const UIDataHostNetwork &data() const { return m_newData; }
|
---|
242 | #ifdef VBOX_WS_MAC
|
---|
243 | /** Defines the host network @a data.
|
---|
244 | * @param busyNames Holds the list of names busy by other networks. */
|
---|
245 | void setData(const UIDataHostNetwork &data,
|
---|
246 | const QStringList &busyNames = QStringList());
|
---|
247 | #else /* !VBOX_WS_MAC */
|
---|
248 | /** Defines the host network @a data. */
|
---|
249 | void setData(const UIDataHostNetwork &data);
|
---|
250 | #endif /* !VBOX_WS_MAC */
|
---|
251 |
|
---|
252 | /** @name Change handling stuff.
|
---|
253 | * @{ */
|
---|
254 | /** Revalidates changes for passed @a pWidget. */
|
---|
255 | bool revalidate() const;
|
---|
256 |
|
---|
257 | /** Updates button states. */
|
---|
258 | void updateButtonStates();
|
---|
259 | /** @} */
|
---|
260 |
|
---|
261 | private slots:
|
---|
262 |
|
---|
263 | /** @name Change handling stuff.
|
---|
264 | * @{ */
|
---|
265 | #ifdef VBOX_WS_MAC
|
---|
266 | /** Handles network name text change. */
|
---|
267 | void sltTextChangedName(const QString &strText);
|
---|
268 | /** Handles network mask text change. */
|
---|
269 | void sltTextChangedMask(const QString &strText);
|
---|
270 | /** Handles network lower bound text change. */
|
---|
271 | void sltTextChangedLBnd(const QString &strText);
|
---|
272 | /** Handles network upper bound text change. */
|
---|
273 | void sltTextChangedUBnd(const QString &strText);
|
---|
274 |
|
---|
275 | #else /* !VBOX_WS_MAC */
|
---|
276 |
|
---|
277 | /** Handles interface automatic configuration choice change. */
|
---|
278 | void sltToggledButtonAutomatic(bool fChecked);
|
---|
279 | /** Handles interface manual configuration choice change. */
|
---|
280 | void sltToggledButtonManual(bool fChecked);
|
---|
281 | /** Handles interface IPv4 text change. */
|
---|
282 | void sltTextChangedIPv4(const QString &strText);
|
---|
283 | /** Handles interface NMv4 text change. */
|
---|
284 | void sltTextChangedNMv4(const QString &strText);
|
---|
285 | /** Handles interface IPv6 text change. */
|
---|
286 | void sltTextChangedIPv6(const QString &strText);
|
---|
287 | /** Handles interface NMv6 text change. */
|
---|
288 | void sltTextChangedNMv6(const QString &strText);
|
---|
289 |
|
---|
290 | /** Handles DHCP server status change. */
|
---|
291 | void sltStatusChangedServer(int iChecked);
|
---|
292 | /** Handles DHCP server address text change. */
|
---|
293 | void sltTextChangedAddress(const QString &strText);
|
---|
294 | /** Handles DHCP server mask text change. */
|
---|
295 | void sltTextChangedMask(const QString &strText);
|
---|
296 | /** Handles DHCP server lower address text change. */
|
---|
297 | void sltTextChangedLowerAddress(const QString &strText);
|
---|
298 | /** Handles DHCP server upper address text change. */
|
---|
299 | void sltTextChangedUpperAddress(const QString &strText);
|
---|
300 | #endif /* !VBOX_WS_MAC */
|
---|
301 |
|
---|
302 | /** Handles button-box button click. */
|
---|
303 | void sltHandleButtonBoxClick(QAbstractButton *pButton);
|
---|
304 | /** @} */
|
---|
305 |
|
---|
306 | /** Handles translation event. */
|
---|
307 | void sltRetranslateUI();
|
---|
308 |
|
---|
309 | private:
|
---|
310 |
|
---|
311 | /** @name Prepare/cleanup cascade.
|
---|
312 | * @{ */
|
---|
313 | /** Prepares all. */
|
---|
314 | void prepare();
|
---|
315 | /** Prepares this. */
|
---|
316 | void prepareThis();
|
---|
317 | #ifdef VBOX_WS_MAC
|
---|
318 | /** Prepares options. */
|
---|
319 | void prepareOptions();
|
---|
320 | #else /* !VBOX_WS_MAC */
|
---|
321 | /** Prepares tab-widget. */
|
---|
322 | void prepareTabWidget();
|
---|
323 | /** Prepares 'Interface' tab. */
|
---|
324 | void prepareTabInterface();
|
---|
325 | /** Prepares 'DHCP server' tab. */
|
---|
326 | void prepareTabDHCPServer();
|
---|
327 | #endif /* !VBOX_WS_MAC */
|
---|
328 | /** @} */
|
---|
329 |
|
---|
330 | /** @name Loading stuff.
|
---|
331 | * @{ */
|
---|
332 | #ifdef VBOX_WS_MAC
|
---|
333 | /** Loads data. */
|
---|
334 | void loadData();
|
---|
335 | #else /* !VBOX_WS_MAC */
|
---|
336 | /** Loads interface data. */
|
---|
337 | void loadDataForInterface();
|
---|
338 | /** Loads server data. */
|
---|
339 | void loadDataForDHCPServer();
|
---|
340 | #endif /* !VBOX_WS_MAC */
|
---|
341 | /** @} */
|
---|
342 |
|
---|
343 | /** @name General variables.
|
---|
344 | * @{ */
|
---|
345 | /** Holds the parent widget embedding type. */
|
---|
346 | const EmbedTo m_enmEmbedding;
|
---|
347 |
|
---|
348 | /** Holds the old data copy. */
|
---|
349 | UIDataHostNetwork m_oldData;
|
---|
350 | /** Holds the new data copy. */
|
---|
351 | UIDataHostNetwork m_newData;
|
---|
352 |
|
---|
353 | #ifndef VBOX_WS_MAC
|
---|
354 | /** Holds the tab-widget. */
|
---|
355 | QITabWidget *m_pTabWidget;
|
---|
356 | #endif /* !VBOX_WS_MAC */
|
---|
357 | /** @} */
|
---|
358 |
|
---|
359 | #ifdef VBOX_WS_MAC
|
---|
360 | /** @name Network variables.
|
---|
361 | * @{ */
|
---|
362 | /** Holds the name label. */
|
---|
363 | QLabel *m_pLabelName;
|
---|
364 | /** Holds the name editor. */
|
---|
365 | QILineEdit *m_pEditorName;
|
---|
366 |
|
---|
367 | /** Holds the mask label. */
|
---|
368 | QLabel *m_pLabelMask;
|
---|
369 | /** Holds the mask editor. */
|
---|
370 | QILineEdit *m_pEditorMask;
|
---|
371 |
|
---|
372 | /** Holds the lower bound label. */
|
---|
373 | QLabel *m_pLabelLBnd;
|
---|
374 | /** Holds the lower bound editor. */
|
---|
375 | QILineEdit *m_pEditorLBnd;
|
---|
376 |
|
---|
377 | /** Holds the upper bound label. */
|
---|
378 | QLabel *m_pLabelUBnd;
|
---|
379 | /** Holds the upper bound editor. */
|
---|
380 | QILineEdit *m_pEditorUBnd;
|
---|
381 |
|
---|
382 | /** Holds the button-box instance. */
|
---|
383 | QIDialogButtonBox *m_pButtonBox;
|
---|
384 |
|
---|
385 | /** Holds the list of names busy by other networks. */
|
---|
386 | QStringList m_busyNames;
|
---|
387 | /** @} */
|
---|
388 |
|
---|
389 | #else /* !VBOX_WS_MAC */
|
---|
390 |
|
---|
391 | /** @name Interface variables.
|
---|
392 | * @{ */
|
---|
393 | /** Holds the automatic interface configuration button. */
|
---|
394 | QRadioButton *m_pButtonAutomatic;
|
---|
395 |
|
---|
396 | /** Holds the manual interface configuration button. */
|
---|
397 | QRadioButton *m_pButtonManual;
|
---|
398 |
|
---|
399 | /** Holds the IPv4 address label. */
|
---|
400 | QLabel *m_pLabelIPv4;
|
---|
401 | /** Holds the IPv4 address editor. */
|
---|
402 | QILineEdit *m_pEditorIPv4;
|
---|
403 |
|
---|
404 | /** Holds the IPv4 network mask label. */
|
---|
405 | QLabel *m_pLabelNMv4;
|
---|
406 | /** Holds the IPv4 network mask editor. */
|
---|
407 | QILineEdit *m_pEditorNMv4;
|
---|
408 |
|
---|
409 | /** Holds the IPv6 address label. */
|
---|
410 | QLabel *m_pLabelIPv6;
|
---|
411 | /** Holds the IPv6 address editor. */
|
---|
412 | QILineEdit *m_pEditorIPv6;
|
---|
413 |
|
---|
414 | /** Holds the IPv6 network mask label. */
|
---|
415 | QLabel *m_pLabelNMv6;
|
---|
416 | /** Holds the IPv6 network mask editor. */
|
---|
417 | QILineEdit *m_pEditorNMv6;
|
---|
418 |
|
---|
419 | /** Holds the interface button-box instance. */
|
---|
420 | QIDialogButtonBox *m_pButtonBoxInterface;
|
---|
421 | /** @} */
|
---|
422 |
|
---|
423 | /** @name DHCP server variables.
|
---|
424 | * @{ */
|
---|
425 | /** Holds the DHCP server status chack-box. */
|
---|
426 | QCheckBox *m_pCheckBoxDHCP;
|
---|
427 |
|
---|
428 | /** Holds the DHCP address label. */
|
---|
429 | QLabel *m_pLabelDHCPAddress;
|
---|
430 | /** Holds the DHCP address editor. */
|
---|
431 | QILineEdit *m_pEditorDHCPAddress;
|
---|
432 |
|
---|
433 | /** Holds the DHCP network mask label. */
|
---|
434 | QLabel *m_pLabelDHCPMask;
|
---|
435 | /** Holds the DHCP network mask editor. */
|
---|
436 | QILineEdit *m_pEditorDHCPMask;
|
---|
437 |
|
---|
438 | /** Holds the DHCP lower address label. */
|
---|
439 | QLabel *m_pLabelDHCPLowerAddress;
|
---|
440 | /** Holds the DHCP lower address editor. */
|
---|
441 | QILineEdit *m_pEditorDHCPLowerAddress;
|
---|
442 |
|
---|
443 | /** Holds the DHCP upper address label. */
|
---|
444 | QLabel *m_pLabelDHCPUpperAddress;
|
---|
445 | /** Holds the DHCP upper address editor. */
|
---|
446 | QILineEdit *m_pEditorDHCPUpperAddress;
|
---|
447 |
|
---|
448 | /** Holds the server button-box instance. */
|
---|
449 | QIDialogButtonBox *m_pButtonBoxServer;
|
---|
450 | /** @} */
|
---|
451 | #endif /* !VBOX_WS_MAC */
|
---|
452 | };
|
---|
453 |
|
---|
454 | #endif /* !FEQT_INCLUDED_SRC_networkmanager_UIDetailsWidgetHostNetwork_h */
|
---|