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