Changeset 98749 in vbox
- Timestamp:
- Feb 27, 2023 12:58:28 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 156054
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r98728 r98749 704 704 QApplication::translate("UIMessageCenter", "Audio adapter failure ..."), 705 705 QApplication::translate("UIMessageCenter", "Failed to acquire audio adapter parameter.") + 706 UIErrorString::formatErrorInfo(comAdapter)); 707 } 708 709 /* static */ 710 void UINotificationMessage::cannotAcquireNetworkAdapterParameter(const CNetworkAdapter &comAdapter) 711 { 712 createMessage( 713 QApplication::translate("UIMessageCenter", "Network adapter failure ..."), 714 QApplication::translate("UIMessageCenter", "Failed to acquire network adapter parameter.") + 706 715 UIErrorString::formatErrorInfo(comAdapter)); 707 716 } -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r98728 r98749 308 308 * @param comAdapter Brings the object parameter get acquired from. */ 309 309 static void cannotAcquireAudioAdapterParameter(const CAudioAdapter &comAdapter); 310 /** Notifies about inability to acquire INetworkAdapter parameter. 311 * @param comAdapter Brings the object parameter get acquired from. */ 312 static void cannotAcquireNetworkAdapterParameter(const CNetworkAdapter &comAdapter); 310 313 /** Notifies about inability to acquire IConsole parameter. 311 314 * @param comConsole Brings the object parameter get acquired from. */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp
r98746 r98749 742 742 { 743 743 return uisession()->webcamDetach(strPath, strName); 744 } 745 746 bool UIMachine::acquireWhetherNetworkAdapterEnabled(ulong uSlot, bool &fEnabled) 747 { 748 return uisession()->acquireWhetherNetworkAdapterEnabled(uSlot, fEnabled); 749 } 750 751 bool UIMachine::acquireWhetherNetworkCableConnected(ulong uSlot, bool &fConnected) 752 { 753 return uisession()->acquireWhetherNetworkCableConnected(uSlot, fConnected); 754 } 755 756 bool UIMachine::setNetworkCableConnected(ulong uSlot, bool fConnected) 757 { 758 return uisession()->setNetworkCableConnected(uSlot, fConnected); 744 759 } 745 760 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h
r98746 r98749 515 515 /** @} */ 516 516 517 /** @name Network stuff. 518 ** @{ */ 519 /** Acquires whether network adapter is enabled. */ 520 bool acquireWhetherNetworkAdapterEnabled(ulong uSlot, bool &fEnabled); 521 /** Acquires whether network adapter cable is connected. */ 522 bool acquireWhetherNetworkCableConnected(ulong uSlot, bool &fConnected); 523 /** Set whether network adapter cable is connected. */ 524 bool setNetworkCableConnected(ulong uSlot, bool fConnected); 525 /** @} */ 526 517 527 /** @name Virtualization stuff. 518 528 ** @{ */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r98746 r98749 2280 2280 } 2281 2281 2282 void UIMachineLogic::sltToggleNetworkAdapterConnection() 2283 { 2284 /* Do not process if window(s) missed! */ 2285 if (!isMachineWindowsCreated()) 2286 return; 2287 2282 void UIMachineLogic::sltToggleNetworkAdapterConnection(bool fChecked) 2283 { 2288 2284 /* Get and check 'the sender' action object: */ 2289 2285 QAction *pAction = qobject_cast<QAction*>(sender()); 2290 2286 AssertMsgReturnVoid(pAction, ("Sender action should NOT be null!\n")); 2291 2287 2292 /* Get operation target: */ 2293 CNetworkAdapter adapter = machine().GetNetworkAdapter((ULONG)pAction->property("slot").toInt()); 2294 AssertMsgReturnVoid(machine().isOk() && !adapter.isNull(), 2295 ("Network adapter should NOT be null!\n")); 2296 2297 /* Connect/disconnect cable to/from target: */ 2298 const bool fConnect = !adapter.GetCableConnected(); 2299 adapter.SetCableConnected(fConnect); 2300 if (!adapter.isOk()) 2301 return UINotificationMessage::cannotToggleNetworkCable(adapter, machineName(), fConnect); 2288 /* Acquire adapter slot: */ 2289 const ulong uSlot = pAction->property("slot").toUInt(); 2290 2291 /* Toggle network adapter cable connection: */ 2292 uimachine()->setNetworkCableConnected(uSlot, fChecked); 2302 2293 2303 2294 /* Save machine-settings: */ … … 2708 2699 { 2709 2700 /* Determine how many adapters we should display: */ 2710 const KChipsetType chipsetType = machine().GetChipsetType();2711 const ULONG uCount = qMin((ULONG)4, uiCommon().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(chipsetType));2701 const KChipsetType enmChipsetType = machine().GetChipsetType(); 2702 const ulong uCount = qMin((ulong)4, (ulong)uiCommon().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(enmChipsetType)); 2712 2703 2713 2704 /* Enumerate existing network adapters: */ 2714 QMap<int, bool> adapterData; 2715 for (ULONG uSlot = 0; uSlot < uCount; ++uSlot) 2716 { 2717 /* Get and check iterated adapter: */ 2718 const CNetworkAdapter adapter = machine().GetNetworkAdapter(uSlot); 2719 AssertReturnVoid(machine().isOk() && !adapter.isNull()); 2720 2705 QMap<ulong, bool> adapterData; 2706 for (ulong uSlot = 0; uSlot < uCount; ++uSlot) 2707 { 2721 2708 /* Skip disabled adapters: */ 2722 if (!adapter.GetEnabled()) 2709 bool fAdapterEnabled = false; 2710 uimachine()->acquireWhetherNetworkAdapterEnabled(uSlot, fAdapterEnabled); 2711 if (!fAdapterEnabled) 2723 2712 continue; 2724 2713 2725 2714 /* Remember adapter data: */ 2726 adapterData.insert((int)uSlot, (bool)adapter.GetCableConnected()); 2715 bool fCableConnected = false; 2716 uimachine()->acquireWhetherNetworkCableConnected(uSlot, fCableConnected); 2717 adapterData.insert(uSlot, fCableConnected); 2727 2718 } 2728 2719 … … 2732 2723 2733 2724 /* Add new actions: */ 2734 foreach ( int iSlot, adapterData.keys())2725 foreach (ulong uSlot, adapterData.keys()) 2735 2726 { 2736 2727 QAction *pAction = pMenu->addAction(UIIconPool::iconSetOnOff(":/connect_on_16px.png", ":/connect_16px.png"), 2737 2728 adapterData.size() == 1 ? UIActionPool::tr("&Connect Network Adapter") : 2738 UIActionPool::tr("Connect Network Adapter &%1").arg( iSlot + 1),2739 this, SLOT(sltToggleNetworkAdapterConnection( )));2740 pAction->setProperty("slot", iSlot);2729 UIActionPool::tr("Connect Network Adapter &%1").arg(uSlot + 1), 2730 this, SLOT(sltToggleNetworkAdapterConnection(bool))); 2731 pAction->setProperty("slot", (uint)uSlot); 2741 2732 pAction->setCheckable(true); 2742 pAction->setChecked(adapterData [iSlot]);2733 pAction->setChecked(adapterData.value(uSlot)); 2743 2734 } 2744 2735 } -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r98744 r98749 301 301 void sltAttachWebcamDevice(); 302 302 void sltChangeSharedClipboardType(QAction *pAction); 303 void sltToggleNetworkAdapterConnection( );303 void sltToggleNetworkAdapterConnection(bool fChecked); 304 304 void sltChangeDragAndDropType(QAction *pAction); 305 305 void sltInstallGuestAdditions(); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r98747 r98749 682 682 } 683 683 684 bool UISession::acquireWhetherNetworkAdapterEnabled(ulong uSlot, bool &fEnabled) 685 { 686 CMachine comMachine = machine(); 687 CNetworkAdapter comAdapter = comMachine.GetNetworkAdapter(uSlot); 688 bool fSuccess = comMachine.isOk(); 689 if (!fSuccess) 690 UINotificationMessage::cannotAcquireMachineParameter(comMachine); 691 else 692 { 693 const BOOL fAdapterEnabled = comAdapter.GetEnabled(); 694 fSuccess = comAdapter.isOk(); 695 if (!fSuccess) 696 UINotificationMessage::cannotAcquireNetworkAdapterParameter(comAdapter); 697 else 698 fEnabled = fAdapterEnabled == TRUE; 699 } 700 return fSuccess; 701 } 702 703 bool UISession::acquireWhetherNetworkCableConnected(ulong uSlot, bool &fConnected) 704 { 705 CMachine comMachine = machine(); 706 CNetworkAdapter comAdapter = comMachine.GetNetworkAdapter(uSlot); 707 bool fSuccess = comMachine.isOk(); 708 if (!fSuccess) 709 UINotificationMessage::cannotAcquireMachineParameter(comMachine); 710 else 711 { 712 const BOOL fCableConnected = comAdapter.GetCableConnected(); 713 fSuccess = comAdapter.isOk(); 714 if (!fSuccess) 715 UINotificationMessage::cannotAcquireNetworkAdapterParameter(comAdapter); 716 else 717 fConnected = fCableConnected == TRUE; 718 } 719 return fSuccess; 720 } 721 722 bool UISession::setNetworkCableConnected(ulong uSlot, bool fConnected) 723 { 724 CMachine comMachine = machine(); 725 CNetworkAdapter comAdapter = comMachine.GetNetworkAdapter(uSlot); 726 bool fSuccess = comMachine.isOk(); 727 if (!fSuccess) 728 UINotificationMessage::cannotAcquireMachineParameter(comMachine); 729 else 730 { 731 comAdapter.SetCableConnected(fConnected); 732 fSuccess = comAdapter.isOk(); 733 if (!fSuccess) 734 UINotificationMessage::cannotToggleNetworkCable(comAdapter, machineName(), fConnected); 735 } 736 return fSuccess; 737 } 738 684 739 bool UISession::guestAdditionsUpgradable() 685 740 { -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h
r98746 r98749 330 330 /** Detaches web cam device with passed @a strName and @a strPath. */ 331 331 bool webcamDetach(const QString &strPath, const QString &strName); 332 /** @} */ 333 334 /** @name Network stuff. 335 ** @{ */ 336 /** Acquires whether network adapter is enabled. */ 337 bool acquireWhetherNetworkAdapterEnabled(ulong uSlot, bool &fEnabled); 338 /** Acquires whether network adapter cable is connected. */ 339 bool acquireWhetherNetworkCableConnected(ulong uSlot, bool &fConnected); 340 /** Set whether network adapter cable is connected. */ 341 bool setNetworkCableConnected(ulong uSlot, bool fConnected); 332 342 /** @} */ 333 343
Note:
See TracChangeset
for help on using the changeset viewer.