VirtualBox

Changeset 98787 in vbox


Ignore:
Timestamp:
Feb 28, 2023 3:58:27 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
156098
Message:

FE/Qt: bugref:10322: Runtime UI: Reworking CMachine wrapper usage step-by-step; Remaining stuff for disk encryption logic.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r98786 r98787  
    744744{
    745745    return uisession()->storageDevices(enmDeviceType, guiStorageDevices);
     746}
     747
     748bool UIMachine::acquireEncryptedMedia(EncryptedMediumMap &media)
     749{
     750    return uisession()->acquireEncryptedMedia(media);
    746751}
    747752
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.h

    r98786 r98787  
    3737
    3838/* GUI includes: */
     39#include "UIAddDiskEncryptionPasswordDialog.h"
    3940#include "UIExtraDataDefs.h"
    4041#include "UIMachineDefs.h"
     
    513514        bool storageDevices(KDeviceType enmDeviceType, QList<StorageDeviceInfo> &guiStorageDevices);
    514515
     516        /** Acquires encrypted media map. */
     517        bool acquireEncryptedMedia(EncryptedMediumMap &media);
    515518        /** Adds encryption password. */
    516519        bool addEncryptionPassword(const QString &strId, const QString &strPassword, bool fClearOnSuspend);
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r98784 r98787  
    29142914    /* Prepare the map of the encrypted media: */
    29152915    EncryptedMediumMap encryptedMedia;
    2916     foreach (const CMediumAttachment &attachment, machine().GetMediumAttachments())
    2917     {
    2918         /* Acquire hard-drive attachments only: */
    2919         if (attachment.GetType() == KDeviceType_HardDisk)
    2920         {
    2921             /* Get the attachment medium base: */
    2922             const CMedium medium = attachment.GetMedium();
    2923             /* Update the map with this medium if it's encrypted: */
    2924             QString strCipher;
    2925             const QString strPasswordId = medium.GetEncryptionSettings(strCipher);
    2926             if (medium.isOk())
    2927                 encryptedMedia.insert(strPasswordId, medium.GetId());
    2928         }
    2929     }
     2916    if (!uimachine()->acquireEncryptedMedia(encryptedMedia))
     2917        return;
    29302918
    29312919    /* Ask for the disk encryption passwords if necessary: */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r98786 r98787  
    638638}
    639639
     640bool UISession::acquireEncryptedMedia(EncryptedMediumMap &media)
     641{
     642    EncryptedMediumMap encryptedMedia;
     643    CMachine comMachine = machine();
     644    const CMediumAttachmentVector comAttachments = comMachine.GetMediumAttachments();
     645    bool fSuccess = comMachine.isOk();
     646    if (!fSuccess)
     647        UINotificationMessage::cannotAcquireMachineParameter(comMachine);
     648    else
     649    {
     650        foreach (const CMediumAttachment &comAttachment, comAttachments)
     651        {
     652            const KDeviceType enmType = comAttachment.GetType();
     653            fSuccess = comAttachment.isOk();
     654            if (!fSuccess)
     655            {
     656                UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
     657                break;
     658            }
     659
     660            /* Look for hard-drive attachments only: */
     661            if (enmType != KDeviceType_HardDisk)
     662                continue;
     663
     664            /* Get the attachment medium: */
     665            const CMedium comMedium = comAttachment.GetMedium();
     666            fSuccess = comAttachment.isOk();
     667            if (!fSuccess)
     668            {
     669                UINotificationMessage::cannotAcquireMediumAttachmentParameter(comAttachment);
     670                break;
     671            }
     672
     673            /* Get the medium ID: */
     674            const QUuid uId = comMedium.GetId();
     675            fSuccess = comMedium.isOk();
     676            if (!fSuccess)
     677            {
     678                UINotificationMessage::cannotAcquireMediumParameter(comMedium);
     679                break;
     680            }
     681
     682            /* Update the map with this medium if it's encrypted: */
     683            QString strCipher;
     684            const QString strPasswordId = comMedium.GetEncryptionSettings(strCipher);
     685            if (comMedium.isOk()) // GetEncryptionSettings failure is a valid case
     686                encryptedMedia.insert(strPasswordId, uId);
     687        }
     688    }
     689
     690    if (fSuccess)
     691        media = encryptedMedia;
     692    return fSuccess;
     693}
     694
    640695bool UISession::addEncryptionPassword(const QString &strId, const QString &strPassword, bool fClearOnSuspend)
    641696{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.h

    r98786 r98787  
    3939
    4040/* GUI includes: */
     41#include "UIAddDiskEncryptionPasswordDialog.h"
    4142#include "UIExtraDataDefs.h"
    4243#include "UIMachineDefs.h"
     
    326327        bool storageDevices(KDeviceType enmDeviceType, QList<StorageDeviceInfo> &guiStorageDevices);
    327328
     329        /** Acquires encrypted media map. */
     330        bool acquireEncryptedMedia(EncryptedMediumMap &media);
    328331        /** Adds encryption password. */
    329332        bool addEncryptionPassword(const QString &strId, const QString &strPassword, bool fClearOnSuspend);
Note: See TracChangeset for help on using the changeset viewer.

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