Changeset 51811 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jul 2, 2014 2:10:14 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 94655
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r51693 r51811 542 542 void UISession::sltInstallGuestAdditionsFrom(const QString &strSource) 543 543 { 544 CMachine machine = session().GetMachine(); 545 CVirtualBox vbox = vboxGlobal().virtualBox(); 546 547 /* 548 * Flag indicating whether we want to do the usual .ISO mounting or not. 549 * First try updating the Guest Additions directly without mounting the .ISO. 550 */ 544 /* This flag indicates whether we want to do the usual .ISO mounting or not. 545 * First try updating the Guest Additions directly without mounting the .ISO. */ 551 546 bool fDoMount = false; 547 552 548 /* Auto-update in GUI currently is disabled. */ 553 549 #ifndef VBOX_WITH_ADDITIONS_AUTOUPDATE_UI 554 550 fDoMount = true; 555 #else 551 #else /* VBOX_WITH_ADDITIONS_AUTOUPDATE_UI */ 556 552 CGuest guest = session().GetConsole().GetGuest(); 557 553 QVector<KAdditionsUpdateFlag> aFlagsUpdate; … … 589 585 #endif /* VBOX_WITH_ADDITIONS_AUTOUPDATE_UI */ 590 586 591 if (fDoMount) /* Fallback to only mounting the .ISO file. */ 592 { 593 QString strUuid; 594 CMedium image = vbox.OpenMedium(strSource, KDeviceType_DVD, KAccessMode_ReadWrite, false /* fForceNewUuid */); 595 if (image.isNull()) 596 { 597 image = vbox.OpenMedium(strSource, KDeviceType_DVD, KAccessMode_ReadWrite, false /* fForceNewUuid */); 598 if (vbox.isOk()) 599 strUuid = image.GetId(); 600 } 601 else 602 strUuid = image.GetId(); 603 604 if (!vbox.isOk()) 605 { 606 msgCenter().cannotOpenMedium(vbox, UIMediumType_DVD, strSource, mainMachineWindow()); 607 return; 608 } 609 610 AssertMsg(!strUuid.isNull(), ("Guest Additions image UUID should be valid!\n")); 611 612 QString strCntName; 613 LONG iCntPort = -1, iCntDevice = -1; 614 /* Searching for the first suitable slot */ 615 { 616 CStorageControllerVector controllers = machine.GetStorageControllers(); 617 int i = 0; 618 while (i < controllers.size() && strCntName.isNull()) 587 /* Do we still want mounting? */ 588 if (!fDoMount) 589 return; 590 591 /* Open corresponding medium: */ 592 QString strMediumID; 593 CVirtualBox vbox = vboxGlobal().virtualBox(); 594 CMedium image = vbox.OpenMedium(strSource, KDeviceType_DVD, KAccessMode_ReadWrite, false /* fForceNewUuid */); 595 if (vbox.isOk() && !image.isNull()) 596 strMediumID = image.GetId(); 597 else 598 { 599 msgCenter().cannotOpenMedium(vbox, UIMediumType_DVD, strSource, mainMachineWindow()); 600 return; 601 } 602 603 /* Make sure GA medium ID is valid: */ 604 AssertReturnVoid(!strMediumID.isNull()); 605 606 /* Get machine: */ 607 CMachine machine = session().GetMachine(); 608 609 /* Searching for the first suitable controller/slot: */ 610 QString strControllerName; 611 LONG iCntPort = -1, iCntDevice = -1; 612 foreach (const CStorageController &controller, machine.GetStorageControllers()) 613 { 614 foreach (const CMediumAttachment &attachment, machine.GetMediumAttachmentsOfController(controller.GetName())) 615 { 616 if (attachment.GetType() == KDeviceType_DVD) 619 617 { 620 CStorageController controller = controllers[i]; 621 CMediumAttachmentVector attachments = machine.GetMediumAttachmentsOfController(controller.GetName()); 622 int j = 0; 623 while (j < attachments.size() && strCntName.isNull()) 624 { 625 CMediumAttachment attachment = attachments[j]; 626 if (attachment.GetType() == KDeviceType_DVD) 627 { 628 strCntName = controller.GetName(); 629 iCntPort = attachment.GetPort(); 630 iCntDevice = attachment.GetDevice(); 631 } 632 ++ j; 633 } 634 ++ i; 618 strControllerName = controller.GetName(); 619 iCntPort = attachment.GetPort(); 620 iCntDevice = attachment.GetDevice(); 621 break; 635 622 } 636 623 } 637 638 if (!strCntName.isNull()) 639 { 640 /* Create new UIMedium: */ 641 UIMedium medium(image, UIMediumType_DVD, KMediumState_Created); 642 643 /* Inform VBoxGlobal about it: */ 644 vboxGlobal().createMedium(medium); 645 646 /* Mount medium to the predefined port/device: */ 647 machine.MountMedium(strCntName, iCntPort, iCntDevice, medium.medium(), false /* force */); 624 if (!strControllerName.isNull()) 625 break; 626 } 627 628 /* Make sure suitable controller/slot were found: */ 629 if (strControllerName.isNull()) 630 { 631 msgCenter().cannotMountGuestAdditions(machine.GetName()); 632 return; 633 } 634 635 /* Try to find UIMedium among cached: */ 636 UIMedium medium = vboxGlobal().medium(strMediumID); 637 if (medium.isNull()) 638 { 639 /* Create new one if necessary: */ 640 medium = UIMedium(image, UIMediumType_DVD, KMediumState_Created); 641 vboxGlobal().createMedium(medium); 642 } 643 644 /* Mount medium to corresponding controller/slot: */ 645 machine.MountMedium(strControllerName, iCntPort, iCntDevice, medium.medium(), false /* force */); 646 if (!machine.isOk()) 647 { 648 /* Ask for force mounting: */ 649 if (msgCenter().cannotRemountMedium(machine, medium, true /* mount? */, 650 true /* retry? */, mainMachineWindow())) 651 { 652 /* Force mount medium to the predefined port/device: */ 653 machine.MountMedium(strControllerName, iCntPort, iCntDevice, medium.medium(), true /* force */); 648 654 if (!machine.isOk()) 649 { 650 /* Ask for force mounting: */ 651 if (msgCenter().cannotRemountMedium(machine, medium, true /* mount? */, 652 true /* retry? */, mainMachineWindow())) 653 { 654 /* Force mount medium to the predefined port/device: */ 655 machine.MountMedium(strCntName, iCntPort, iCntDevice, medium.medium(), true /* force */); 656 if (!machine.isOk()) 657 msgCenter().cannotRemountMedium(machine, medium, true /* mount? */, 658 false /* retry? */, mainMachineWindow()); 659 } 660 } 661 } 662 else 663 msgCenter().cannotMountGuestAdditions(machine.GetName()); 655 msgCenter().cannotRemountMedium(machine, medium, true /* mount? */, 656 false /* retry? */, mainMachineWindow()); 657 } 664 658 } 665 659 }
Note:
See TracChangeset
for help on using the changeset viewer.