Changeset 54753 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Mar 13, 2015 5:03:28 PM (10 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/runtime
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIAddDiskEncryptionPasswordDialog.cpp
r54733 r54753 96 96 * @param pParent being passed to the base-class, 97 97 * @param encryptedMediums contains the lists of medium ids (values) encrypted with passwords with ids (keys). */ 98 UIEncryptionDataModel(QObject *pParent, const EncryptedMedium sMap &encryptedMediums);98 UIEncryptionDataModel(QObject *pParent, const EncryptedMediumMap &encryptedMediums); 99 99 100 100 /** Returns the shallow copy of the encryption password map instance. */ … … 123 123 124 124 /** Holds the encrypted medium map reference. */ 125 const EncryptedMedium sMap &m_encryptedMediums;125 const EncryptedMediumMap &m_encryptedMediums; 126 126 127 127 /** Holds the encryption password map instance. */ … … 140 140 /** Constructor. 141 141 * @param pParent being passed to the base-class. */ 142 UIEncryptionDataTable(const EncryptedMedium sMap &encryptedMediums);142 UIEncryptionDataTable(const EncryptedMediumMap &encryptedMediums); 143 143 144 144 /** Returns the shallow copy of the encryption password map … … 152 152 153 153 /** Holds the encrypted medium map reference. */ 154 const EncryptedMedium sMap &m_encryptedMediums;154 const EncryptedMediumMap &m_encryptedMediums; 155 155 156 156 /** Holds the encryption-data model instance. */ … … 183 183 } 184 184 185 UIEncryptionDataModel::UIEncryptionDataModel(QObject *pParent, const EncryptedMedium sMap &encryptedMediums)185 UIEncryptionDataModel::UIEncryptionDataModel(QObject *pParent, const EncryptedMediumMap &encryptedMediums) 186 186 : QAbstractTableModel(pParent) 187 187 , m_encryptedMediums(encryptedMediums) … … 312 312 } 313 313 314 UIEncryptionDataTable::UIEncryptionDataTable(const EncryptedMedium sMap &encryptedMediums)314 UIEncryptionDataTable::UIEncryptionDataTable(const EncryptedMediumMap &encryptedMediums) 315 315 : m_encryptedMediums(encryptedMediums) 316 316 , m_pModelEncryptionData(0) … … 374 374 } 375 375 376 UIAddDiskEncryptionPasswordDialog::UIAddDiskEncryptionPasswordDialog(QWidget *pParent, const EncryptedMedium sMap &encryptedMediums)376 UIAddDiskEncryptionPasswordDialog::UIAddDiskEncryptionPasswordDialog(QWidget *pParent, const EncryptedMediumMap &encryptedMediums) 377 377 : QIWithRetranslateUI<QDialog>(pParent) 378 378 , m_encryptedMediums(encryptedMediums) -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIAddDiskEncryptionPasswordDialog.h
r54733 r54753 31 31 32 32 /* Type definitions: */ 33 typedef QMultiMap<QString, QString> EncryptedMedium sMap;33 typedef QMultiMap<QString, QString> EncryptedMediumMap; 34 34 typedef QMap<QString, QString> EncryptionPasswordsMap; 35 35 … … 45 45 * @param pParent being passed to the base-class, 46 46 * @param encryptedMediums contains the lists of medium ids (values) encrypted with passwords with ids (keys). */ 47 UIAddDiskEncryptionPasswordDialog(QWidget *pParent, const EncryptedMedium sMap &encryptedMediums);47 UIAddDiskEncryptionPasswordDialog(QWidget *pParent, const EncryptedMediumMap &encryptedMediums); 48 48 49 49 /** Returns the shallow copy of the encryption password map … … 60 60 61 61 /** Holds the encrypted medium map reference. */ 62 const EncryptedMedium sMap &m_encryptedMediums;62 const EncryptedMediumMap &m_encryptedMediums; 63 63 64 64 /** Holds the description label instance. */ -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp
r54648 r54753 65 65 # include "UIMedium.h" 66 66 # include "UIExtraDataManager.h" 67 # include "UIAddDiskEncryptionPasswordDialog.h" 67 68 # ifdef Q_WS_MAC 68 69 # include "DockIconPreview.h" … … 653 654 void UIMachineLogic::sltRuntimeError(bool fIsFatal, const QString &strErrorId, const QString &strMessage) 654 655 { 656 /* Preprocess known runtime error types: */ 657 if (strErrorId == "DrvVD_DEKMISSING") 658 return askUserForTheDiskEncryptionPasswords(); 659 660 /* Show runtime error: */ 655 661 msgCenter().showRuntimeError(console(), fIsFatal, strErrorId, strMessage); 656 662 } … … 2407 2413 } 2408 2414 2415 void UIMachineLogic::askUserForTheDiskEncryptionPasswords() 2416 { 2417 /* Prepare the map of the encrypted mediums: */ 2418 EncryptedMediumMap encryptedMediums; 2419 foreach (const CMediumAttachment &attachment, machine().GetMediumAttachments()) 2420 { 2421 /* Acquire hard-drive attachments only: */ 2422 if (attachment.GetType() == KDeviceType_HardDisk) 2423 { 2424 /* Get the attachment medium: */ 2425 const CMedium medium = attachment.GetMedium(); 2426 /* Update the map with this medium if necessary: */ 2427 const QString strKeyId = medium.GetProperty("CRYPT/KeyId"); 2428 if (!strKeyId.isEmpty()) 2429 encryptedMediums.insert(strKeyId, medium.GetId()); 2430 } 2431 } 2432 2433 /* Ask for the disk encryption passwords if necessary: */ 2434 EncryptionPasswordsMap encryptionPasswords; 2435 if (!encryptedMediums.isEmpty()) 2436 { 2437 /* Create corresponding dialog: */ 2438 QPointer<UIAddDiskEncryptionPasswordDialog> pDlg = 2439 new UIAddDiskEncryptionPasswordDialog(activeMachineWindow(), encryptedMediums); 2440 /* Execute it and acquire the result: */ 2441 if (pDlg->exec() == QDialog::Accepted) 2442 encryptionPasswords = pDlg->encryptionPasswords(); 2443 /* Delete dialog if still valid: */ 2444 if (pDlg) 2445 delete pDlg; 2446 } 2447 2448 /* Add the disk encryption passwords if necessary: */ 2449 if (!encryptionPasswords.isEmpty()) 2450 { 2451 foreach (const QString &strKey, encryptionPasswords.keys()) 2452 { 2453 console().AddDiskEncryptionPassword(strKey, encryptionPasswords.value(strKey), false); 2454 if (!console().isOk()) 2455 msgCenter().cannotAddDiskEncryptionPassword(console()); 2456 } 2457 } 2458 } 2459 2409 2460 int UIMachineLogic::searchMaxSnapshotIndex(const CMachine &machine, 2410 2461 const CSnapshot &snapshot, -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r54648 r54753 336 336 void showGlobalPreferences(const QString &strCategory = QString(), const QString &strControl = QString()); 337 337 338 /** Asks user for the disks encryption passwords. */ 339 void askUserForTheDiskEncryptionPasswords(); 340 338 341 /* Helpers: */ 339 342 static int searchMaxSnapshotIndex(const CMachine &machine, const CSnapshot &snapshot, const QString &strNameTemplate); -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r54742 r54753 44 44 # include "UIFrameBuffer.h" 45 45 # include "UISettingsDialogSpecific.h" 46 # include "UIAddDiskEncryptionPasswordDialog.h"47 46 # ifdef VBOX_WITH_VIDEOHWACCEL 48 47 # include "VBoxFBOverlay.h" … … 252 251 bool UISession::powerUp() 253 252 { 254 /* Prepare map of the encrypted ids: */255 EncryptedMediumsMap encryptedPasswordIds;256 foreach (const CMediumAttachment &attachment, machine().GetMediumAttachments())257 {258 /* Acquire hard-drives only: */259 if (attachment.GetType() == KDeviceType_HardDisk)260 {261 /* Get attachment medium: */262 const CMedium medium = attachment.GetMedium();263 /* Append our map if this medium has encryption: */264 const QString strKeyId = medium.GetProperty("CRYPT/KeyId");265 if (!strKeyId.isEmpty())266 encryptedPasswordIds.insert(strKeyId, medium.GetId());267 }268 }269 /* Ask for disk encryption passwords if necessary: */270 EncryptionPasswordsMap encryptionPasswords;271 if (!encryptedPasswordIds.isEmpty())272 {273 QPointer<UIAddDiskEncryptionPasswordDialog> pDlg =274 new UIAddDiskEncryptionPasswordDialog(machineLogic()->activeMachineWindow(),275 encryptedPasswordIds);276 if (pDlg->exec() == QDialog::Accepted)277 encryptionPasswords = pDlg->encryptionPasswords();278 if (pDlg)279 delete pDlg;280 }281 282 253 /* Power UP machine: */ 283 254 #ifdef VBOX_WITH_DEBUGGER_GUI … … 316 287 msgCenter().cannotStartMachine(progress, machineName()); 317 288 return false; 318 }319 320 /* Add the disk encryption passwords: */321 if (!encryptionPasswords.isEmpty())322 {323 foreach (const QString &strKey, encryptionPasswords.keys())324 {325 console().AddDiskEncryptionPassword(strKey, encryptionPasswords.value(strKey), true);326 if (!console().isOk())327 msgCenter().cannotAddDiskEncryptionPassword(console());328 }329 289 } 330 290
Note:
See TracChangeset
for help on using the changeset viewer.