/* Save data from cache to corresponding external object(s), * this task COULD be performed in other than GUI thread: */ void UIMachineSettingsGeneral::saveFromCacheTo(QVariant &data) { /* Fetch data to machine: */ UISettingsPageMachine::fetchData(data); /* Check if general data was changed: */ if (m_cache.wasChanged()) { /* Get general data from cache: */ const UIDataSettingsMachineGeneral &generalData = m_cache.data(); /* Store general data: */ if (isMachineInValidMode()) { /* Advanced tab: */ m_machine.SetClipboardMode(generalData.m_clipboardMode); m_machine.SetDragAndDropMode(generalData.m_dragAndDropMode); m_machine.SetExtraData(GUI_SaveMountedAtRuntime, generalData.m_fSaveMountedAtRuntime ? "yes" : "no"); m_machine.SetExtraData(GUI_ShowMiniToolBar, generalData.m_fShowMiniToolBar ? "yes" : "no"); m_machine.SetExtraData(GUI_MiniToolBarAlignment, generalData.m_fMiniToolBarAtTop ? "top" : "bottom"); /* Description tab: */ m_machine.SetDescription(generalData.m_strDescription); } if (isMachineOffline()) { /* Basic tab: Must update long mode CPU feature bit when os type changes. */ if (generalData.m_strGuestOsTypeId != m_cache.base().m_strGuestOsTypeId) { m_machine.SetOSTypeId(generalData.m_strGuestOsTypeId); CVirtualBox vbox = vboxGlobal().virtualBox(); CGuestOSType newType = vbox.GetGuestOSType(generalData.m_strGuestOsTypeId); m_machine.SetCPUProperty(KCPUPropertyType_LongMode, newType.GetIs64Bit()); } /* Advanced tab: */ m_machine.SetSnapshotFolder(generalData.m_strSnapshotsFolder); /* Basic (again) tab: */ /* VM name must be last as otherwise its VM rename magic can collide with other settings in the config, * especially with the snapshot folder: */ m_machine.SetName(generalData.m_strName); } } /* Upload machine to data: */ UISettingsPageMachine::uploadData(data); }
void UIMachineSettingsGeneral::saveFromCacheTo(QVariant &data) { /* Fetch data to machine: */ UISettingsPageMachine::fetchData(data); /* Check if general data was changed: */ if (m_cache.wasChanged()) { /* Get general data from cache: */ const UIDataSettingsMachineGeneral &generalData = m_cache.data(); if (isMachineInValidMode()) { /* 'Advanced' tab data: */ if (generalData.m_clipboardMode != m_cache.base().m_clipboardMode) m_machine.SetClipboardMode(generalData.m_clipboardMode); if (generalData.m_dndMode != m_cache.base().m_dndMode) m_machine.SetDnDMode(generalData.m_dndMode); /* 'Description' tab: */ if (generalData.m_strDescription != m_cache.base().m_strDescription) m_machine.SetDescription(generalData.m_strDescription); } if (isMachineOffline()) { /* 'Basic' tab data: Must update long mode CPU feature bit when os type changes. */ if (generalData.m_strGuestOsTypeId != m_cache.base().m_strGuestOsTypeId) { m_machine.SetOSTypeId(generalData.m_strGuestOsTypeId); CVirtualBox vbox = vboxGlobal().virtualBox(); CGuestOSType newType = vbox.GetGuestOSType(generalData.m_strGuestOsTypeId); m_machine.SetCPUProperty(KCPUPropertyType_LongMode, newType.GetIs64Bit()); } /* 'Advanced' tab data: */ if (generalData.m_strSnapshotsFolder != m_cache.base().m_strSnapshotsFolder) m_machine.SetSnapshotFolder(generalData.m_strSnapshotsFolder); /* 'Basic' (again) tab data: */ /* VM name must be last as otherwise its VM rename magic * can collide with other settings in the config, * especially with the snapshot folder: */ if (generalData.m_strName != m_cache.base().m_strName) m_machine.SetName(generalData.m_strName); /* Encryption tab data: */ if (generalData.m_fEncryptionEnabled != m_cache.base().m_fEncryptionEnabled || generalData.m_fEncryptionCipherChanged != m_cache.base().m_fEncryptionCipherChanged || generalData.m_fEncryptionPasswordChanged != m_cache.base().m_fEncryptionPasswordChanged) { /* Cipher attribute changed? */ QString strNewCipher; if (generalData.m_fEncryptionCipherChanged) { strNewCipher = generalData.m_fEncryptionEnabled ? m_encryptionCiphers.at(generalData.m_iEncryptionCipherIndex) : QString(); } /* Password attribute changed? */ QString strNewPassword; QString strNewPasswordId; if (generalData.m_fEncryptionPasswordChanged) { strNewPassword = generalData.m_fEncryptionEnabled ? generalData.m_strEncryptionPassword : QString(); strNewPasswordId = generalData.m_fEncryptionEnabled ? m_machine.GetName() : QString(); } /* Get the maps of encrypted mediums and their passwords: */ const EncryptedMediumMap &encryptedMedium = generalData.m_encryptedMediums; const EncryptionPasswordMap &encryptionPasswords = generalData.m_encryptionPasswords; /* Enumerate attachments: */ foreach (const CMediumAttachment &attachment, m_machine.GetMediumAttachments()) { /* Enumerate hard-drives only: */ if (attachment.GetType() == KDeviceType_HardDisk) { /* Get corresponding medium: */ CMedium medium = attachment.GetMedium(); /* Check if old password exists/provided: */ QString strOldPasswordId = encryptedMedium.key(medium.GetId()); QString strOldPassword = encryptionPasswords.value(strOldPasswordId); /* Update encryption: */ CProgress cprogress = medium.ChangeEncryption(strOldPassword, strNewCipher, strNewPassword, strNewPasswordId); if (!medium.isOk()) { QMetaObject::invokeMethod(this, "sigOperationProgressError", Qt::BlockingQueuedConnection, Q_ARG(QString, UIMessageCenter::formatErrorInfo(medium))); continue; } UIProgress uiprogress(cprogress); connect(&uiprogress, SIGNAL(sigProgressChange(ulong, QString, ulong, ulong)), this, SIGNAL(sigOperationProgressChange(ulong, QString, ulong, ulong)), Qt::QueuedConnection); connect(&uiprogress, SIGNAL(sigProgressError(QString)), this, SIGNAL(sigOperationProgressError(QString)), Qt::BlockingQueuedConnection); uiprogress.run(350); } } } } }