VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UINetworkManager.h@ 104158

Last change on this file since 104158 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.1 KB
Line 
1/* $Id: UINetworkManager.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UINetworkManager 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_UINetworkManager_h
29#define FEQT_INCLUDED_SRC_networkmanager_UINetworkManager_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QMainWindow>
36
37/* GUI includes: */
38#include "QIManagerDialog.h"
39#include "QIWithRetranslateUI.h"
40
41/* Forward declarations: */
42class CCloudNetwork;
43#ifdef VBOX_WS_MAC
44class CHostOnlyNetwork;
45#else
46class CHostNetworkInterface;
47#endif
48class CNATNetwork;
49class QAbstractButton;
50class QTreeWidgetItem;
51class QVBoxLayout;
52class QIDialogButtonBox;
53class QITabWidget;
54class QITreeWidget;
55class UIActionPool;
56class UIDetailsWidgetCloudNetwork;
57class UIDetailsWidgetHostNetwork;
58class UIDetailsWidgetNATNetwork;
59class UIItemCloudNetwork;
60class UIItemHostNetwork;
61class UIItemNATNetwork;
62class QIToolBar;
63struct UIDataCloudNetwork;
64struct UIDataHostNetwork;
65struct UIDataNATNetwork;
66
67
68/** QWidget extension providing GUI with the pane to control network related functionality. */
69class UINetworkManagerWidget : public QIWithRetranslateUI<QWidget>
70{
71 Q_OBJECT;
72
73signals:
74
75 /** Notifies listeners about details-widget @a fVisible. */
76 void sigDetailsVisibilityChanged(bool fVisible);
77
78 /** Notifies listeners about host network details data @a fDiffers. */
79 void sigDetailsDataChangedHostNetwork(bool fDiffers);
80 /** Notifies listeners about NAT network details data @a fDiffers. */
81 void sigDetailsDataChangedNATNetwork(bool fDiffers);
82 /** Notifies listeners about cloud network details data @a fDiffers. */
83 void sigDetailsDataChangedCloudNetwork(bool fDiffers);
84
85public:
86
87 /** Constructs Network Manager widget.
88 * @param enmEmbedding Brings the type of widget embedding.
89 * @param pActionPool Brings the action-pool reference.
90 * @param fShowToolbar Brings whether we should create/show toolbar. */
91 UINetworkManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool,
92 bool fShowToolbar = true, QWidget *pParent = 0);
93
94 /** Returns the menu. */
95 QMenu *menu() const;
96
97#ifdef VBOX_WS_MAC
98 /** Returns the toolbar. */
99 QIToolBar *toolbar() const { return m_pToolBar; }
100#endif
101
102protected:
103
104 /** @name Event-handling stuff.
105 * @{ */
106 /** Handles translation event. */
107 virtual void retranslateUi() RT_OVERRIDE;
108
109 /** Handles resize @a pEvent. */
110 virtual void resizeEvent(QResizeEvent *pEvent) RT_OVERRIDE;
111
112 /** Handles show @a pEvent. */
113 virtual void showEvent(QShowEvent *pEvent) RT_OVERRIDE;
114 /** @} */
115
116public slots:
117
118 /** @name Details-widget stuff.
119 * @{ */
120 /** Handles command to reset details changes. */
121 void sltResetDetailsChanges();
122 /** Handles command to apply details changes. */
123 void sltApplyDetailsChanges();
124 /** @} */
125
126private slots:
127
128 /** @name Menu/action stuff.
129 * @{ */
130 /** Handles command to create host network. */
131 void sltCreateHostNetwork();
132#ifndef VBOX_WS_MAC
133 /** Handles signal about host network @a comInterface created. */
134 void sigHandleHostOnlyNetworkInterfaceCreated(const CHostNetworkInterface &comInterface);
135#endif
136 /** Handles command to remove host network. */
137 void sltRemoveHostNetwork();
138#ifndef VBOX_WS_MAC
139 /** Handles signal about host network interface by the name of @a strInterfaceName was removed. */
140 void sigHandleHostOnlyNetworkInterfaceRemoved(const QString &strInterfaceName);
141#endif
142
143 /** Handles command to create NAT network. */
144 void sltCreateNATNetwork();
145 /** Handles command to remove NAT network. */
146 void sltRemoveNATNetwork();
147
148 /** Handles command to create cloud network. */
149 void sltCreateCloudNetwork();
150 /** Handles command to remove cloud network. */
151 void sltRemoveCloudNetwork();
152
153 /** Handles command to make details @a fVisible. */
154 void sltToggleDetailsVisibility(bool fVisible);
155 /** @} */
156
157 /** @name Tree-widget stuff.
158 * @{ */
159 /** Handles current tab-widget's index change. */
160 void sltHandleCurrentTabWidgetIndexChange();
161
162 /** Handles command to adjust tree-widget. */
163 void sltAdjustTreeWidgets();
164
165 /** Handles host network tree-widget current item change. */
166 void sltHandleCurrentItemChangeHostNetwork();
167 /** Handles host network context-menu request for tree-widget @a position. */
168 void sltHandleContextMenuRequestHostNetwork(const QPoint &position);
169 /** Handles command to apply host network details changes. */
170 void sltApplyDetailsChangesHostNetwork();
171
172 /** Handles NAT network tree-widget current item change.
173 * @param fHoldPosition Holds whether we should try to keep
174 * port forwarding rule position intact. */
175 void sltHandleCurrentItemChangeNATNetworkHoldingPosition(bool fHoldPosition);
176 /** Handles NAT network tree-widget current item change. */
177 void sltHandleCurrentItemChangeNATNetwork();
178 /** Handles NAT network context-menu request for tree-widget @a position. */
179 void sltHandleContextMenuRequestNATNetwork(const QPoint &position);
180 /** Handles command to apply NAT network details changes. */
181 void sltApplyDetailsChangesNATNetwork();
182
183 /** Handles cloud network tree-widget current item change. */
184 void sltHandleCurrentItemChangeCloudNetwork();
185 /** Handles cloud network context-menu request for tree-widget @a position. */
186 void sltHandleContextMenuRequestCloudNetwork(const QPoint &position);
187 /** Handles command to apply cloud network details changes. */
188 void sltApplyDetailsChangesCloudNetwork();
189 /** @} */
190
191private:
192
193 /** @name Prepare/cleanup cascade.
194 * @{ */
195 /** Prepares all. */
196 void prepare();
197 /** Prepares actions. */
198 void prepareActions();
199 /** Prepares widgets. */
200 void prepareWidgets();
201 /** Prepares toolbar. */
202 void prepareToolBar();
203 /** Prepares tab-widget. */
204 void prepareTabWidget();
205 /** Prepares host network tab. */
206 void prepareTabHostNetwork();
207 /** Prepares host network tree-widget. */
208 void prepareTreeWidgetHostNetwork();
209 /** Prepares host network details-widget. */
210 void prepareDetailsWidgetHostNetwork();
211 /** Prepares NAT network tab. */
212 void prepareTabNATNetwork();
213 /** Prepares NAT network tree-widget. */
214 void prepareTreeWidgetNATNetwork();
215 /** Prepares NAT network details-widget. */
216 void prepareDetailsWidgetNATNetwork();
217 /** Prepares cloud network tab. */
218 void prepareTabCloudNetwork();
219 /** Prepares cloud network tree-widget. */
220 void prepareTreeWidgetCloudNetwork();
221 /** Prepares cloud network details-widget. */
222 void prepareDetailsWidgetCloudNetwork();
223 /** Load settings: */
224 void loadSettings();
225 /** @} */
226
227 /** @name Loading stuff.
228 * @{ */
229 /** Loads host networks. */
230 void loadHostNetworks();
231#ifdef VBOX_WS_MAC
232 /** Loads host @a comNetwork data to passed @a data container. */
233 void loadHostNetwork(const CHostOnlyNetwork &comNetwork, UIDataHostNetwork &data);
234#else
235 /** Loads host @a comInterface data to passed @a data container. */
236 void loadHostNetwork(const CHostNetworkInterface &comInterface, UIDataHostNetwork &data);
237#endif
238
239 /** Loads NAT networks. */
240 void loadNATNetworks();
241 /** Loads NAT @a comNetwork data to passed @a data container. */
242 void loadNATNetwork(const CNATNetwork &comNetwork, UIDataNATNetwork &data);
243
244 /** Loads cloud networks. */
245 void loadCloudNetworks();
246 /** Loads cloud @a comNetwork data to passed @a data container. */
247 void loadCloudNetwork(const CCloudNetwork &comNetwork, UIDataCloudNetwork &data);
248 /** @} */
249
250 /** @name Actions stuff.
251 * @{ */
252 /** Updates action availability. */
253 void updateActionAvailability();
254 /** @} */
255
256 /** @name Tree-widget stuff.
257 * @{ */
258 /** Creates a new host network tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */
259 void createItemForHostNetwork(const UIDataHostNetwork &data, bool fChooseItem);
260 /** Updates passed host network tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */
261 void updateItemForHostNetwork(const UIDataHostNetwork &data, bool fChooseItem, UIItemHostNetwork *pItem);
262
263 /** Creates a new NAT network tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */
264 void createItemForNATNetwork(const UIDataNATNetwork &data, bool fChooseItem);
265 /** Updates passed NAT network tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */
266 void updateItemForNATNetwork(const UIDataNATNetwork &data, bool fChooseItem, UIItemNATNetwork *pItem);
267
268 /** Creates a new cloud network tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */
269 void createItemForCloudNetwork(const UIDataCloudNetwork &data, bool fChooseItem);
270 /** Updates passed cloud network tree-widget item on the basis of passed @a data, @a fChooseItem if requested. */
271 void updateItemForCloudNetwork(const UIDataCloudNetwork &data, bool fChooseItem, UIItemCloudNetwork *pItem);
272
273#ifdef VBOX_WS_MAC
274 /** Returns a list of busy host network names. */
275 QStringList busyNamesHost() const;
276#endif
277 /** Returns a list of busy NAT network names. */
278 QStringList busyNamesNAT() const;
279 /** Returns a list of busy cloud network names. */
280 QStringList busyNamesCloud() const;
281 /** @} */
282
283 /** @name General variables.
284 * @{ */
285 /** Holds the widget embedding type. */
286 const EmbedTo m_enmEmbedding;
287 /** Holds the action-pool reference. */
288 UIActionPool *m_pActionPool;
289 /** Holds whether we should create/show toolbar. */
290 const bool m_fShowToolbar;
291 /** @} */
292
293 /** @name Toolbar and menu variables.
294 * @{ */
295 /** Holds the toolbar instance. */
296 QIToolBar *m_pToolBar;
297 /** @} */
298
299 /** @name Splitter variables.
300 * @{ */
301 /** Holds the tab-widget instance. */
302 QITabWidget *m_pTabWidget;
303
304 /** Holds the host network tab. */
305 QWidget *m_pTabHostNetwork;
306 /** Holds the host network layout. */
307 QVBoxLayout *m_pLayoutHostNetwork;
308 /** Holds the host network tree-widget instance. */
309 QITreeWidget *m_pTreeWidgetHostNetwork;
310 /** Holds the host network details-widget instance. */
311 UIDetailsWidgetHostNetwork *m_pDetailsWidgetHostNetwork;
312
313 /** Holds the NAT network tab. */
314 QWidget *m_pTabNATNetwork;
315 /** Holds the NAT network tab layout. */
316 QVBoxLayout *m_pLayoutNATNetwork;
317 /** Holds the NAT network tree-widget instance. */
318 QITreeWidget *m_pTreeWidgetNATNetwork;
319 /** Holds the NAT network details-widget instance. */
320 UIDetailsWidgetNATNetwork *m_pDetailsWidgetNATNetwork;
321
322 /** Holds the cloud network tab. */
323 QWidget *m_pTabCloudNetwork;
324 /** Holds the cloud network tab layout. */
325 QVBoxLayout *m_pLayoutCloudNetwork;
326 /** Holds the cloud network tree-widget instance. */
327 QITreeWidget *m_pTreeWidgetCloudNetwork;
328 /** Holds the cloud network details-widget instance. */
329 UIDetailsWidgetCloudNetwork *m_pDetailsWidgetCloudNetwork;
330 /** @} */
331};
332
333
334/** QIManagerDialogFactory extension used as a factory for Network Manager dialog. */
335class UINetworkManagerFactory : public QIManagerDialogFactory
336{
337public:
338
339 /** Constructs Media Manager factory acquiring additional arguments.
340 * @param pActionPool Brings the action-pool reference. */
341 UINetworkManagerFactory(UIActionPool *pActionPool = 0);
342
343protected:
344
345 /** Creates derived @a pDialog instance.
346 * @param pCenterWidget Brings the widget reference to center according to. */
347 virtual void create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) RT_OVERRIDE;
348
349 /** Holds the action-pool reference. */
350 UIActionPool *m_pActionPool;
351};
352
353
354/** QIManagerDialog extension providing GUI with the dialog to control network related functionality. */
355class UINetworkManager : public QIWithRetranslateUI<QIManagerDialog>
356{
357 Q_OBJECT;
358
359signals:
360
361 /** Notifies listeners about data change rejected and should be reseted. */
362 void sigDataChangeRejected();
363 /** Notifies listeners about data change accepted and should be applied. */
364 void sigDataChangeAccepted();
365
366private slots:
367
368 /** @name Button-box stuff.
369 * @{ */
370 /** Handles button-box button click. */
371 void sltHandleButtonBoxClick(QAbstractButton *pButton);
372 /** @} */
373
374private:
375
376 /** Constructs Network Manager dialog.
377 * @param pCenterWidget Brings the widget reference to center according to.
378 * @param pActionPool Brings the action-pool reference. */
379 UINetworkManager(QWidget *pCenterWidget, UIActionPool *pActionPool);
380
381 /** @name Event-handling stuff.
382 * @{ */
383 /** Handles translation event. */
384 virtual void retranslateUi() RT_OVERRIDE;
385 /** @} */
386
387 /** @name Prepare/cleanup cascade.
388 * @{ */
389 /** Configures all. */
390 virtual void configure() RT_OVERRIDE;
391 /** Configures central-widget. */
392 virtual void configureCentralWidget() RT_OVERRIDE;
393 /** Configures button-box. */
394 virtual void configureButtonBox() RT_OVERRIDE;
395 /** Perform final preparations. */
396 virtual void finalize() RT_OVERRIDE;
397 /** @} */
398
399 /** @name Widget stuff.
400 * @{ */
401 /** Returns the widget. */
402 virtual UINetworkManagerWidget *widget() RT_OVERRIDE;
403 /** @} */
404
405 /** @name Action related variables.
406 * @{ */
407 /** Holds the action-pool reference. */
408 UIActionPool *m_pActionPool;
409 /** @} */
410
411 /** Allow factory access to private/protected members: */
412 friend class UINetworkManagerFactory;
413};
414
415#endif /* !FEQT_INCLUDED_SRC_networkmanager_UINetworkManager_h */
416
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette