VirtualBox

Ignore:
Timestamp:
Mar 13, 2015 5:03:28 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: 7676: Runtime UI: Disk Encryption (DE) support: Move 'ask for passwords' trigger to 'DEK missing' runtime error handler.

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  
    9696      * @param pParent          being passed to the base-class,
    9797      * @param encryptedMediums contains the lists of medium ids (values) encrypted with passwords with ids (keys). */
    98     UIEncryptionDataModel(QObject *pParent, const EncryptedMediumsMap &encryptedMediums);
     98    UIEncryptionDataModel(QObject *pParent, const EncryptedMediumMap &encryptedMediums);
    9999
    100100    /** Returns the shallow copy of the encryption password map instance. */
     
    123123
    124124    /** Holds the encrypted medium map reference. */
    125     const EncryptedMediumsMap &m_encryptedMediums;
     125    const EncryptedMediumMap &m_encryptedMediums;
    126126
    127127    /** Holds the encryption password map instance. */
     
    140140    /** Constructor.
    141141      * @param pParent being passed to the base-class. */
    142     UIEncryptionDataTable(const EncryptedMediumsMap &encryptedMediums);
     142    UIEncryptionDataTable(const EncryptedMediumMap &encryptedMediums);
    143143
    144144    /** Returns the shallow copy of the encryption password map
     
    152152
    153153    /** Holds the encrypted medium map reference. */
    154     const EncryptedMediumsMap &m_encryptedMediums;
     154    const EncryptedMediumMap &m_encryptedMediums;
    155155
    156156    /** Holds the encryption-data model instance. */
     
    183183}
    184184
    185 UIEncryptionDataModel::UIEncryptionDataModel(QObject *pParent, const EncryptedMediumsMap &encryptedMediums)
     185UIEncryptionDataModel::UIEncryptionDataModel(QObject *pParent, const EncryptedMediumMap &encryptedMediums)
    186186    : QAbstractTableModel(pParent)
    187187    , m_encryptedMediums(encryptedMediums)
     
    312312}
    313313
    314 UIEncryptionDataTable::UIEncryptionDataTable(const EncryptedMediumsMap &encryptedMediums)
     314UIEncryptionDataTable::UIEncryptionDataTable(const EncryptedMediumMap &encryptedMediums)
    315315    : m_encryptedMediums(encryptedMediums)
    316316    , m_pModelEncryptionData(0)
     
    374374}
    375375
    376 UIAddDiskEncryptionPasswordDialog::UIAddDiskEncryptionPasswordDialog(QWidget *pParent, const EncryptedMediumsMap &encryptedMediums)
     376UIAddDiskEncryptionPasswordDialog::UIAddDiskEncryptionPasswordDialog(QWidget *pParent, const EncryptedMediumMap &encryptedMediums)
    377377    : QIWithRetranslateUI<QDialog>(pParent)
    378378    , m_encryptedMediums(encryptedMediums)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIAddDiskEncryptionPasswordDialog.h

    r54733 r54753  
    3131
    3232/* Type definitions: */
    33 typedef QMultiMap<QString, QString> EncryptedMediumsMap;
     33typedef QMultiMap<QString, QString> EncryptedMediumMap;
    3434typedef QMap<QString, QString> EncryptionPasswordsMap;
    3535
     
    4545      * @param pParent          being passed to the base-class,
    4646      * @param encryptedMediums contains the lists of medium ids (values) encrypted with passwords with ids (keys). */
    47     UIAddDiskEncryptionPasswordDialog(QWidget *pParent, const EncryptedMediumsMap &encryptedMediums);
     47    UIAddDiskEncryptionPasswordDialog(QWidget *pParent, const EncryptedMediumMap &encryptedMediums);
    4848
    4949    /** Returns the shallow copy of the encryption password map
     
    6060
    6161    /** Holds the encrypted medium map reference. */
    62     const EncryptedMediumsMap &m_encryptedMediums;
     62    const EncryptedMediumMap &m_encryptedMediums;
    6363
    6464    /** Holds the description label instance. */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r54648 r54753  
    6565# include "UIMedium.h"
    6666# include "UIExtraDataManager.h"
     67# include "UIAddDiskEncryptionPasswordDialog.h"
    6768# ifdef Q_WS_MAC
    6869#  include "DockIconPreview.h"
     
    653654void UIMachineLogic::sltRuntimeError(bool fIsFatal, const QString &strErrorId, const QString &strMessage)
    654655{
     656    /* Preprocess known runtime error types: */
     657    if (strErrorId == "DrvVD_DEKMISSING")
     658        return askUserForTheDiskEncryptionPasswords();
     659
     660    /* Show runtime error: */
    655661    msgCenter().showRuntimeError(console(), fIsFatal, strErrorId, strMessage);
    656662}
     
    24072413}
    24082414
     2415void 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
    24092460int UIMachineLogic::searchMaxSnapshotIndex(const CMachine &machine,
    24102461                                           const CSnapshot &snapshot,
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r54648 r54753  
    336336    void showGlobalPreferences(const QString &strCategory = QString(), const QString &strControl = QString());
    337337
     338    /** Asks user for the disks encryption passwords. */
     339    void askUserForTheDiskEncryptionPasswords();
     340
    338341    /* Helpers: */
    339342    static int searchMaxSnapshotIndex(const CMachine &machine, const CSnapshot &snapshot, const QString &strNameTemplate);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r54742 r54753  
    4444# include "UIFrameBuffer.h"
    4545# include "UISettingsDialogSpecific.h"
    46 # include "UIAddDiskEncryptionPasswordDialog.h"
    4746# ifdef VBOX_WITH_VIDEOHWACCEL
    4847#  include "VBoxFBOverlay.h"
     
    252251bool UISession::powerUp()
    253252{
    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 
    282253    /* Power UP machine: */
    283254#ifdef VBOX_WITH_DEBUGGER_GUI
     
    316287            msgCenter().cannotStartMachine(progress, machineName());
    317288        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         }
    329289    }
    330290
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette