Changeset 66482 in vbox
- Timestamp:
- Apr 7, 2017 4:08:08 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r66476 r66482 1179 1179 tr("Cannot save remote display server settings."), 1180 1180 formatErrorInfo(comServer)); 1181 } 1182 1183 void UIMessageCenter::cannotSaveGeneralSettings(const CMachine &comMachine, QWidget *pParent /* = 0 */) 1184 { 1185 error(pParent, MessageType_Error, 1186 tr("Cannot save general settings."), 1187 formatErrorInfo(comMachine)); 1188 } 1189 1190 void UIMessageCenter::cannotSaveStorageAttachmentSettings(const CMediumAttachment &comAttachment, QWidget *pParent /* = 0 */) 1191 { 1192 error(pParent, MessageType_Error, 1193 tr("Cannot save storage attachment settings."), 1194 formatErrorInfo(comAttachment)); 1195 } 1196 1197 void UIMessageCenter::cannotSaveStorageMediumSettings(const CMedium &comMedium, QWidget *pParent /* = 0 */) 1198 { 1199 error(pParent, MessageType_Error, 1200 tr("Cannot save storage medium settings."), 1201 formatErrorInfo(comMedium)); 1181 1202 } 1182 1203 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r66476 r66482 243 243 void cannotSaveDisplaySettings(const CMachine &comMachine, QWidget *pParent = 0); 244 244 void cannotSaveRemoteDisplayServerSettings(const CVRDEServer &comServer, QWidget *pParent = 0); 245 void cannotSaveGeneralSettings(const CMachine &comMachine, QWidget *pParent = 0); 246 void cannotSaveStorageAttachmentSettings(const CMediumAttachment &comAttachment, QWidget *pParent = 0); 247 void cannotSaveStorageMediumSettings(const CMedium &comMedium, QWidget *pParent = 0); 245 248 void cannotAttachDevice(const CMachine &machine, UIMediumType type, const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent = 0); 246 249 bool warnAboutIncorrectPort(QWidget *pParent = 0) const; -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.cpp
r66481 r66482 341 341 UISettingsPageMachine::fetchData(data); 342 342 343 /* Make sure machine is in valid mode & general data was changed: */ 344 if (isMachineInValidMode() && m_pCache->wasChanged()) 345 { 346 /* Get old general data from the cache: */ 347 const UIDataSettingsMachineGeneral &oldGeneralData = m_pCache->base(); 348 /* Get new general data from the cache: */ 349 const UIDataSettingsMachineGeneral &newGeneralData = m_pCache->data(); 350 351 /* Store machine OS type ID: */ 352 if (isMachineOffline() && newGeneralData.m_strGuestOsTypeId != oldGeneralData.m_strGuestOsTypeId) 353 { 354 m_machine.SetOSTypeId(newGeneralData.m_strGuestOsTypeId); 355 // Must update long mode CPU feature bit when os type changed: 356 CVirtualBox vbox = vboxGlobal().virtualBox(); 357 const CGuestOSType enmNewType = vbox.GetGuestOSType(newGeneralData.m_strGuestOsTypeId); 358 m_machine.SetCPUProperty(KCPUPropertyType_LongMode, enmNewType.GetIs64Bit()); 359 } 360 361 /* Store machine clipboard mode: */ 362 if (newGeneralData.m_clipboardMode != oldGeneralData.m_clipboardMode) 363 m_machine.SetClipboardMode(newGeneralData.m_clipboardMode); 364 /* Store machine D&D mode: */ 365 if (newGeneralData.m_dndMode != oldGeneralData.m_dndMode) 366 m_machine.SetDnDMode(newGeneralData.m_dndMode); 367 /* Store machine snapshot folder: */ 368 if (isMachineOffline() && newGeneralData.m_strSnapshotsFolder != oldGeneralData.m_strSnapshotsFolder) 369 m_machine.SetSnapshotFolder(newGeneralData.m_strSnapshotsFolder); 370 371 // VM name should go after the snapshot folder from the 'Advanced' data 372 // as otherwise VM rename magic can collide with the snapshot folder one. 373 /* Store machine name: */ 374 if (isMachineOffline() && newGeneralData.m_strName != oldGeneralData.m_strName) 375 m_machine.SetName(newGeneralData.m_strName); 376 377 /* Store machine description: */ 378 if (newGeneralData.m_strDescription != oldGeneralData.m_strDescription) 379 m_machine.SetDescription(newGeneralData.m_strDescription); 380 381 if (isMachineOffline()) 382 { 383 /* Make sure it either encryption is changed itself, 384 * or the encryption was already enabled and either cipher or password is changed. */ 385 if ( newGeneralData.m_fEncryptionEnabled != oldGeneralData.m_fEncryptionEnabled 386 || ( oldGeneralData.m_fEncryptionEnabled 387 && ( newGeneralData.m_fEncryptionCipherChanged != oldGeneralData.m_fEncryptionCipherChanged 388 || newGeneralData.m_fEncryptionPasswordChanged != oldGeneralData.m_fEncryptionPasswordChanged))) 389 { 390 /* Cipher attribute changed? */ 391 QString strNewCipher; 392 if (newGeneralData.m_fEncryptionCipherChanged) 393 { 394 strNewCipher = newGeneralData.m_fEncryptionEnabled ? 395 m_encryptionCiphers.at(newGeneralData.m_iEncryptionCipherIndex) : QString(); 396 } 397 /* Password attribute changed? */ 398 QString strNewPassword; 399 QString strNewPasswordId; 400 if (newGeneralData.m_fEncryptionPasswordChanged) 401 { 402 strNewPassword = newGeneralData.m_fEncryptionEnabled ? 403 newGeneralData.m_strEncryptionPassword : QString(); 404 strNewPasswordId = newGeneralData.m_fEncryptionEnabled ? 405 m_machine.GetName() : QString(); 406 } 407 408 /* Get the maps of encrypted mediums and their passwords: */ 409 const EncryptedMediumMap &encryptedMedium = newGeneralData.m_encryptedMediums; 410 const EncryptionPasswordMap &encryptionPasswords = newGeneralData.m_encryptionPasswords; 411 /* Enumerate attachments: */ 412 foreach (const CMediumAttachment &attachment, m_machine.GetMediumAttachments()) 413 { 414 /* Enumerate hard-drives only: */ 415 if (attachment.GetType() == KDeviceType_HardDisk) 416 { 417 /* Get corresponding medium: */ 418 CMedium comMedium = attachment.GetMedium(); 419 420 /* Check if old password exists/provided: */ 421 const QString strOldPasswordId = encryptedMedium.key(comMedium.GetId()); 422 const QString strOldPassword = encryptionPasswords.value(strOldPasswordId); 423 424 /* Update encryption: */ 425 CProgress cprogress = comMedium.ChangeEncryption(strOldPassword, 426 strNewCipher, 427 strNewPassword, 428 strNewPasswordId); 429 if (!comMedium.isOk()) 430 { 431 QMetaObject::invokeMethod(this, "sigOperationProgressError", Qt::BlockingQueuedConnection, 432 Q_ARG(QString, UIMessageCenter::formatErrorInfo(comMedium))); 433 continue; 434 } 435 UIProgress uiprogress(cprogress); 436 connect(&uiprogress, SIGNAL(sigProgressChange(ulong, QString, ulong, ulong)), 437 this, SIGNAL(sigOperationProgressChange(ulong, QString, ulong, ulong)), 438 Qt::QueuedConnection); 439 connect(&uiprogress, SIGNAL(sigProgressError(QString)), 440 this, SIGNAL(sigOperationProgressError(QString)), 441 Qt::BlockingQueuedConnection); 442 uiprogress.run(350); 443 } 444 } 445 } 446 } 447 } 343 /* Update general data and failing state: */ 344 setFailed(!saveGeneralData()); 448 345 449 346 /* Upload machine to data: */ … … 763 660 } 764 661 662 bool UIMachineSettingsGeneral::saveGeneralData() 663 { 664 /* Prepare result: */ 665 bool fSuccess = true; 666 /* Save general settings from the cache: */ 667 if (fSuccess && isMachineInValidMode() && m_pCache->wasChanged()) 668 { 669 /* Save 'Basic' data from the cache: */ 670 if (fSuccess) 671 fSuccess = saveBasicData(); 672 /* Save 'Advanced' data from the cache: */ 673 if (fSuccess) 674 fSuccess = saveAdvancedData(); 675 /* Save 'Description' data from the cache: */ 676 if (fSuccess) 677 fSuccess = saveDescriptionData(); 678 /* Save 'Encryption' data from the cache: */ 679 if (fSuccess) 680 fSuccess = saveEncryptionData(); 681 } 682 /* Return result: */ 683 return fSuccess; 684 } 685 686 bool UIMachineSettingsGeneral::saveBasicData() 687 { 688 /* Prepare result: */ 689 bool fSuccess = true; 690 /* Save 'Basic' data from the cache: */ 691 if (fSuccess) 692 { 693 /* Get old general data from the cache: */ 694 const UIDataSettingsMachineGeneral &oldGeneralData = m_pCache->base(); 695 /* Get new general data from the cache: */ 696 const UIDataSettingsMachineGeneral &newGeneralData = m_pCache->data(); 697 698 /* Save machine OS type ID: */ 699 if (isMachineOffline() && newGeneralData.m_strGuestOsTypeId != oldGeneralData.m_strGuestOsTypeId) 700 { 701 if (fSuccess) 702 { 703 m_machine.SetOSTypeId(newGeneralData.m_strGuestOsTypeId); 704 fSuccess = m_machine.isOk(); 705 } 706 if (fSuccess) 707 { 708 // Must update long mode CPU feature bit when os type changed: 709 CVirtualBox vbox = vboxGlobal().virtualBox(); 710 // Should we check global object getters? 711 const CGuestOSType &comNewType = vbox.GetGuestOSType(newGeneralData.m_strGuestOsTypeId); 712 m_machine.SetCPUProperty(KCPUPropertyType_LongMode, comNewType.GetIs64Bit()); 713 fSuccess = m_machine.isOk(); 714 } 715 /* Show error message if necessary: */ 716 if (!fSuccess) 717 msgCenter().cannotSaveGeneralSettings(m_machine, this); 718 } 719 } 720 /* Return result: */ 721 return fSuccess; 722 } 723 724 bool UIMachineSettingsGeneral::saveAdvancedData() 725 { 726 /* Prepare result: */ 727 bool fSuccess = true; 728 /* Save 'Advanced' data from the cache: */ 729 if (fSuccess) 730 { 731 /* Get old general data from the cache: */ 732 const UIDataSettingsMachineGeneral &oldGeneralData = m_pCache->base(); 733 /* Get new general data from the cache: */ 734 const UIDataSettingsMachineGeneral &newGeneralData = m_pCache->data(); 735 736 /* Save machine clipboard mode: */ 737 if (fSuccess && newGeneralData.m_clipboardMode != oldGeneralData.m_clipboardMode) 738 { 739 m_machine.SetClipboardMode(newGeneralData.m_clipboardMode); 740 fSuccess = m_machine.isOk(); 741 } 742 /* Save machine D&D mode: */ 743 if (fSuccess && newGeneralData.m_dndMode != oldGeneralData.m_dndMode) 744 { 745 m_machine.SetDnDMode(newGeneralData.m_dndMode); 746 fSuccess = m_machine.isOk(); 747 } 748 /* Save machine snapshot folder: */ 749 if (fSuccess && isMachineOffline() && newGeneralData.m_strSnapshotsFolder != oldGeneralData.m_strSnapshotsFolder) 750 { 751 m_machine.SetSnapshotFolder(newGeneralData.m_strSnapshotsFolder); 752 fSuccess = m_machine.isOk(); 753 } 754 // VM name from 'Basic' data should go after the snapshot folder from the 'Advanced' data 755 // as otherwise VM rename magic can collide with the snapshot folder one. 756 /* Save machine name: */ 757 if (fSuccess && isMachineOffline() && newGeneralData.m_strName != oldGeneralData.m_strName) 758 { 759 m_machine.SetName(newGeneralData.m_strName); 760 fSuccess = m_machine.isOk(); 761 } 762 /* Show error message if necessary: */ 763 if (!fSuccess) 764 msgCenter().cannotSaveGeneralSettings(m_machine, this); 765 } 766 /* Return result: */ 767 return fSuccess; 768 } 769 770 bool UIMachineSettingsGeneral::saveDescriptionData() 771 { 772 /* Prepare result: */ 773 bool fSuccess = true; 774 /* Save 'Description' data from the cache: */ 775 if (fSuccess) 776 { 777 /* Get old general data from the cache: */ 778 const UIDataSettingsMachineGeneral &oldGeneralData = m_pCache->base(); 779 /* Get new general data from the cache: */ 780 const UIDataSettingsMachineGeneral &newGeneralData = m_pCache->data(); 781 782 /* Save machine description: */ 783 if (fSuccess && newGeneralData.m_strDescription != oldGeneralData.m_strDescription) 784 { 785 m_machine.SetDescription(newGeneralData.m_strDescription); 786 fSuccess = m_machine.isOk(); 787 } 788 /* Show error message if necessary: */ 789 if (!fSuccess) 790 msgCenter().cannotSaveGeneralSettings(m_machine, this); 791 } 792 /* Return result: */ 793 return fSuccess; 794 } 795 796 bool UIMachineSettingsGeneral::saveEncryptionData() 797 { 798 /* Prepare result: */ 799 bool fSuccess = true; 800 /* Save 'Encryption' data from the cache: */ 801 if (fSuccess) 802 { 803 /* Get old general data from the cache: */ 804 const UIDataSettingsMachineGeneral &oldGeneralData = m_pCache->base(); 805 /* Get new general data from the cache: */ 806 const UIDataSettingsMachineGeneral &newGeneralData = m_pCache->data(); 807 808 /* Make sure it either encryption state is changed itself, 809 * or the encryption was already enabled and either cipher or password is changed. */ 810 if ( isMachineOffline() 811 && ( newGeneralData.m_fEncryptionEnabled != oldGeneralData.m_fEncryptionEnabled 812 || ( oldGeneralData.m_fEncryptionEnabled 813 && ( newGeneralData.m_fEncryptionCipherChanged != oldGeneralData.m_fEncryptionCipherChanged 814 || newGeneralData.m_fEncryptionPasswordChanged != oldGeneralData.m_fEncryptionPasswordChanged)))) 815 { 816 /* Get machine name for further activities: */ 817 QString strMachineName; 818 if (fSuccess) 819 { 820 strMachineName = m_machine.GetName(); 821 fSuccess = m_machine.isOk(); 822 } 823 /* Get machine attachments for further activities: */ 824 CMediumAttachmentVector attachments; 825 if (fSuccess) 826 { 827 attachments = m_machine.GetMediumAttachments(); 828 fSuccess = m_machine.isOk(); 829 } 830 /* Show error message if necessary: */ 831 if (!fSuccess) 832 msgCenter().cannotSaveGeneralSettings(m_machine, this); 833 834 /* Enumerate attachments: */ 835 for (int iIndex = 0; fSuccess && iIndex < attachments.size(); ++iIndex) 836 { 837 /* Get current attachment: */ 838 const CMediumAttachment &comAttachment = attachments.at(iIndex); 839 840 /* Get attachment type for further activities: */ 841 KDeviceType enmType = KDeviceType_Null; 842 if (fSuccess) 843 { 844 enmType = comAttachment.GetType(); 845 fSuccess = comAttachment.isOk(); 846 } 847 /* Get attachment medium for further activities: */ 848 CMedium comMedium; 849 if (fSuccess) 850 { 851 comMedium = comAttachment.GetMedium(); 852 fSuccess = comAttachment.isOk(); 853 } 854 /* Show error message if necessary: */ 855 if (!fSuccess) 856 msgCenter().cannotSaveStorageAttachmentSettings(comAttachment, this); 857 858 /* Enumerate hard-drives only: */ 859 if (enmType != KDeviceType_HardDisk) 860 continue; 861 862 /* Get medium id for further activities: */ 863 QString strMediumId; 864 if (fSuccess) 865 { 866 strMediumId = comMedium.GetId(); 867 fSuccess = comMedium.isOk(); 868 } 869 870 /* Create encryption update progress: */ 871 CProgress comProgress; 872 if (fSuccess) 873 { 874 /* Cipher attribute changed? */ 875 QString strNewCipher; 876 if (newGeneralData.m_fEncryptionCipherChanged) 877 { 878 strNewCipher = newGeneralData.m_fEncryptionEnabled ? 879 m_encryptionCiphers.at(newGeneralData.m_iEncryptionCipherIndex) : QString(); 880 } 881 882 /* Password attribute changed? */ 883 QString strNewPassword; 884 QString strNewPasswordId; 885 if (newGeneralData.m_fEncryptionPasswordChanged) 886 { 887 strNewPassword = newGeneralData.m_fEncryptionEnabled ? 888 newGeneralData.m_strEncryptionPassword : QString(); 889 strNewPasswordId = newGeneralData.m_fEncryptionEnabled ? 890 strMachineName : QString(); 891 } 892 893 /* Get the maps of encrypted mediums and their passwords: */ 894 const EncryptedMediumMap &encryptedMedium = newGeneralData.m_encryptedMediums; 895 const EncryptionPasswordMap &encryptionPasswords = newGeneralData.m_encryptionPasswords; 896 897 /* Check if old password exists/provided: */ 898 const QString strOldPasswordId = encryptedMedium.key(strMediumId); 899 const QString strOldPassword = encryptionPasswords.value(strOldPasswordId); 900 901 /* Create encryption progress: */ 902 comProgress = comMedium.ChangeEncryption(strOldPassword, 903 strNewCipher, 904 strNewPassword, 905 strNewPasswordId); 906 fSuccess = comMedium.isOk(); 907 } 908 909 // TODO: Decide what to do with it (also below). 910 // if (!comMedium.isOk()) 911 // { 912 // QMetaObject::invokeMethod(this, "sigOperationProgressError", Qt::BlockingQueuedConnection, 913 // Q_ARG(QString, UIMessageCenter::formatErrorInfo(comMedium))); 914 // continue; 915 // } 916 917 /* Create encryption update progress dialog: */ 918 QPointer<UIProgress> pDlg; 919 if (fSuccess) 920 { 921 // TODO: Decide what to do with it (also above). 922 // This dialog connected to settings serializer, not to message-center directly. 923 // What's the better approach in that case? Probably connect everything to serializer? 924 pDlg = new UIProgress(comProgress); 925 connect(pDlg, SIGNAL(sigProgressChange(ulong, QString, ulong, ulong)), 926 this, SIGNAL(sigOperationProgressChange(ulong, QString, ulong, ulong)), 927 Qt::QueuedConnection); 928 connect(pDlg, SIGNAL(sigProgressError(QString)), 929 this, SIGNAL(sigOperationProgressError(QString)), 930 Qt::BlockingQueuedConnection); 931 pDlg->run(350); 932 if (pDlg) 933 delete pDlg; 934 else 935 { 936 // Premature application shutdown, 937 // exit immediately: 938 return true; 939 } 940 } 941 942 /* Show error message if necessary: */ 943 if (!fSuccess) 944 msgCenter().cannotSaveStorageMediumSettings(comMedium, this); 945 } 946 } 947 } 948 /* Return result: */ 949 return fSuccess; 950 } 951 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsGeneral.h
r66345 r66482 109 109 void cleanup(); 110 110 111 /** Saves existing general data from the cache. */ 112 bool saveGeneralData(); 113 /** Saves existing 'Basic' data from the cache. */ 114 bool saveBasicData(); 115 /** Saves existing 'Advanced' data from the cache. */ 116 bool saveAdvancedData(); 117 /** Saves existing 'Description' data from the cache. */ 118 bool saveDescriptionData(); 119 /** Saves existing 'Encryption' data from the cache. */ 120 bool saveEncryptionData(); 121 111 122 /** Holds whether HW virtualization extension is enabled. */ 112 123 bool m_fHWVirtExEnabled;
Note:
See TracChangeset
for help on using the changeset viewer.