VirtualBox

Changeset 73716 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Aug 16, 2018 3:58:57 PM (6 years ago)
Author:
vboxsync
Message:

Main/CloudProviderManager+CloudProvider+CloudProfile: Introduce CloudProfile as separate interface, and do a big cleanup. Adding synchronization and incomplete support for moving to an extension pack. Updated VBoxManage to list providers and touched up the GUI code slightly to deal with the changed interfaces.

Location:
trunk/src/VBox/Frontends
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp

    r73029 r73716  
    13801380                         fFirst ? "Property:       " : "                ",
    13811381                         names[i], value.raw());
     1382                fFirst = false;
    13821383            }
    13831384        }
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r73664 r73716  
    449449                     "                            hostinfo|hostcpuids|hddbackends|hdds|dvds|floppies|\n"
    450450                     "                            usbhost|usbfilters|systemproperties|extpacks|\n"
    451                      "                            groups|webcams|screenshotformats\n"
     451                     "                            groups|webcams|screenshotformats|cloudproviders|\n"
     452                     "                            cloudprofiles\n"
    452453                     "\n", SEP);
    453454
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp

    r72976 r73716  
    900900}
    901901
     902/**
     903 * List available cloud providers.
     904 *
     905 * @returns See produceList.
     906 * @param   pVirtualBox         Reference to the IVirtualBox pointer.
     907 */
     908static HRESULT listCloudProviders(const ComPtr<IVirtualBox> pVirtualBox)
     909{
     910    HRESULT rc = S_OK;
     911    ComPtr<ICloudProviderManager> pCloudProviderManager;
     912    CHECK_ERROR(pVirtualBox, COMGETTER(CloudProviderManager)(pCloudProviderManager.asOutParam()));
     913    com::SafeIfaceArray<ICloudProvider> apCloudProviders;
     914    CHECK_ERROR(pCloudProviderManager, COMGETTER(Providers)(ComSafeArrayAsOutParam(apCloudProviders)));
     915
     916    RTPrintf("Supported %d cloud providers:\n", apCloudProviders.size());
     917    for (size_t i = 0; i < apCloudProviders.size(); ++i)
     918    {
     919        ComPtr<ICloudProvider> pCloudProvider = apCloudProviders[i];
     920        Bstr bstrProviderName;
     921        pCloudProvider->COMGETTER(Name)(bstrProviderName.asOutParam());
     922        RTPrintf("Name:            %ls\n", bstrProviderName.raw());
     923        pCloudProvider->COMGETTER(ShortName)(bstrProviderName.asOutParam());
     924        RTPrintf("Short Name:      %ls\n", bstrProviderName.raw());
     925        Bstr bstrProviderID;
     926        pCloudProvider->COMGETTER(Id)(bstrProviderID.asOutParam());
     927        RTPrintf("GUID:            %ls\n", bstrProviderID.raw());
     928
     929        RTPrintf("\n");
     930    }
     931    return rc;
     932}
     933
     934
     935/**
     936 * List all available cloud profiles (by iterating over the cloud providers).
     937 *
     938 * @returns See produceList.
     939 * @param   pVirtualBox         Reference to the IVirtualBox pointer.
     940 * @param   fOptLong            If true, list all profile properties.
     941 */
     942static HRESULT listCloudProfiles(const ComPtr<IVirtualBox> pVirtualBox, bool fOptLong)
     943{
     944    HRESULT rc = S_OK;
     945    ComPtr<ICloudProviderManager> pCloudProviderManager;
     946    CHECK_ERROR(pVirtualBox, COMGETTER(CloudProviderManager)(pCloudProviderManager.asOutParam()));
     947    com::SafeIfaceArray<ICloudProvider> apCloudProviders;
     948    CHECK_ERROR(pCloudProviderManager, COMGETTER(Providers)(ComSafeArrayAsOutParam(apCloudProviders)));
     949
     950    for (size_t i = 0; i < apCloudProviders.size(); ++i)
     951    {
     952        ComPtr<ICloudProvider> pCloudProvider = apCloudProviders[i];
     953        com::SafeIfaceArray<ICloudProfile> apCloudProfiles;
     954        CHECK_ERROR(pCloudProvider, COMGETTER(Profiles)(ComSafeArrayAsOutParam(apCloudProfiles)));
     955        for (size_t j = 0; j < apCloudProfiles.size(); ++j)
     956        {
     957            ComPtr<ICloudProfile> pCloudProfile = apCloudProfiles[j];
     958            Bstr bstrProfileName;
     959            pCloudProfile->COMGETTER(Name)(bstrProfileName.asOutParam());
     960            RTPrintf("Name:          %ls\n", bstrProfileName.raw());
     961            Bstr bstrProviderID;
     962            pCloudProfile->COMGETTER(ProviderId)(bstrProviderID.asOutParam());
     963            RTPrintf("Provider GUID: %ls\n", bstrProviderID.raw());
     964
     965            if (fOptLong)
     966            {
     967                com::SafeArray<BSTR> names;
     968                com::SafeArray<BSTR> values;
     969                pCloudProfile->GetProperties(Bstr().raw(), ComSafeArrayAsOutParam(names), ComSafeArrayAsOutParam(values));
     970                size_t cNames = names.size();
     971                size_t cValues = values.size();
     972                bool fFirst = true;
     973                for (size_t k = 0; k < cNames; k++)
     974                {
     975                    Bstr value;
     976                    if (k < cValues)
     977                        value = values[k];
     978                    RTPrintf("%s%ls=%ls\n",
     979                             fFirst ? "Property:      " : "               ",
     980                             names[k], value.raw());
     981                    fFirst = false;
     982                }
     983            }
     984
     985            RTPrintf("\n");
     986        }
     987    }
     988    return rc;
     989}
     990
    902991
    903992/**
     
    9311020    kListNatNetworks,
    9321021    kListVideoInputDevices,
    933     kListScreenShotFormats
     1022    kListScreenShotFormats,
     1023    kListCloudProviders,
     1024    kListCloudProfiles,
    9341025};
    9351026
     
    12971388            break;
    12981389
     1390        case kListCloudProviders:
     1391            rc = listCloudProviders(pVirtualBox);
     1392            break;
     1393
     1394        case kListCloudProfiles:
     1395            rc = listCloudProfiles(pVirtualBox, fOptLong);
     1396            break;
     1397
    12991398        /* No default here, want gcc warnings. */
    13001399
     
    13491448        { "webcams",            kListVideoInputDevices,  RTGETOPT_REQ_NOTHING },
    13501449        { "screenshotformats",  kListScreenShotFormats,  RTGETOPT_REQ_NOTHING },
     1450        { "cloudproviders",     kListCloudProviders,     RTGETOPT_REQ_NOTHING },
     1451        { "cloudprofiles",      kListCloudProfiles,      RTGETOPT_REQ_NOTHING },
    13511452    };
    13521453
     
    14001501            case kListVideoInputDevices:
    14011502            case kListScreenShotFormats:
     1503            case kListCloudProviders:
     1504            case kListCloudProfiles:
    14021505                enmOptCommand = (enum enmListType)ch;
    14031506                if (fOptMultiple)
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h

    r73175 r73716  
    136136template<> SHARED_LIBRARY_STUFF bool canConvert<KChipsetType>();
    137137template<> SHARED_LIBRARY_STUFF bool canConvert<KNATProtocol>();
    138 template<> SHARED_LIBRARY_STUFF bool canConvert<KCloudProviderId>();
    139138
    140139
     
    254253template<> SHARED_LIBRARY_STUFF QString toInternalString(const KNATProtocol &protocol);
    255254template<> SHARED_LIBRARY_STUFF KNATProtocol fromInternalString<KNATProtocol>(const QString &strProtocol);
    256 template<> SHARED_LIBRARY_STUFF QString toInternalString(const KCloudProviderId &enmProvider);
    257255
    258256
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendCOM.cpp

    r73175 r73716  
    5959template<> bool canConvert<KChipsetType>() { return true; }
    6060template<> bool canConvert<KNATProtocol>() { return true; }
    61 template<> bool canConvert<KCloudProviderId>() { return true; }
    6261
    6362
     
    655654    return values.at(keys.indexOf(QRegExp(strProtocol, Qt::CaseInsensitive)));
    656655}
    657 
    658 /* QString <= KCloudProviderId: */
    659 template<> QString toInternalString(const KCloudProviderId &enmProvider)
    660 {
    661     switch (enmProvider)
    662     {
    663         case KCloudProviderId_OCI:            return "OCI";
    664         case KCloudProviderId_GCP:            return "GCP";
    665         case KCloudProviderId_AWS:            return "AWS";
    666         case KCloudProviderId_MicrosoftAzure: return "Microsoft Azure";
    667         case KCloudProviderId_IBMCloud:       return "IBM Cloud";
    668         case KCloudProviderId_DigitalOcean:   return "Digital Ocean";
    669         default: AssertMsgFailed(("No text for %d", enmProvider)); break;
    670     }
    671     return QString();
    672 }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.cpp

    r73580 r73716  
    7171    /* Init Cloud Provider Manager: */
    7272    CVirtualBox comVBox = vboxGlobal().virtualBox();
    73     m_comCloudProviderManager = comVBox.CreateCloudProviderManager();
     73    m_comCloudProviderManager = comVBox.GetCloudProviderManager();
    7474    AssertMsg(comVBox.isOk() && m_comCloudProviderManager.isNotNull(),
    7575              ("Unable to acquire Cloud Provider Manager"));
     
    117117    AssertReturnVoid(m_pAccountComboBox->count() == 0);
    118118
    119     /* Acquire provider ID list: */
    120     QVector<QString> providerIds = m_comCloudProviderManager.GetSupportedProviders();
     119    /* Acquire provider list: */
     120    QVector<CCloudProvider> comProviders = m_comCloudProviderManager.GetProviders();
    121121    /* Make sure at least one provider is supported: */
    122     AssertReturnVoid(!providerIds.isEmpty());
    123 
    124     /* Iterate through provider IDs: */
    125     foreach (const QString &strProviderId, providerIds)
    126     {
    127         /* Acquire Cloud Provider: */
    128         const CCloudProvider comProvider = m_comCloudProviderManager.GetProfilesByProvider(strProviderId);
     122    AssertReturnVoid(!comProviders.isEmpty());
     123
     124    /* Iterate through providers: */
     125    foreach (const CCloudProvider &comProvider, comProviders)
     126    {
    129127        /* Skip if we have nothing to populate (file missing?): */
    130128        if (comProvider.isNull())
    131129            continue;
     130        QString strProviderId = comProvider.GetId();
     131        QString strProviderShortName = comProvider.GetShortName();
    132132
    133133        /* Iterate through profile names: */
    134         foreach (const QString &strProfileName, comProvider.GetStoredProfilesNames())
     134        foreach (const QString &strProfileName, comProvider.GetProfileNames())
    135135        {
    136136            m_pAccountComboBox->addItem(QString());
    137137            m_pAccountComboBox->setItemData(m_pAccountComboBox->count() - 1, strProviderId, ProviderID);
     138            m_pAccountComboBox->setItemData(m_pAccountComboBox->count() - 1, strProviderShortName, ProviderName);
    138139            m_pAccountComboBox->setItemData(m_pAccountComboBox->count() - 1, strProfileName, ProfileName);
    139140        }
     
    142143    /* Set default: */
    143144    if (m_pAccountComboBox->count() != 0)
    144         setProviderById("OCI");
     145        setProviderById("54e11de4-afcc-47fb-9c39-b24244cfa044");
    145146}
    146147
     
    148149{
    149150    /* Acquire Cloud Provider: */
    150     m_comCloudProvider = m_comCloudProviderManager.GetProfilesByProvider(providerId());
    151     /* Return if we have nothing to populate (file missing?): */
    152     if (m_comCloudProvider.isNull())
     151    CCloudProvider comCloudProvider = m_comCloudProviderManager.GetProviderById(providerId());
     152    /* Return if the provider has disappeared: */
     153    if (comCloudProvider.isNull())
    153154        return;
     155
     156    m_comCloudProfile = comCloudProvider.GetProfileByName(profileName());
     157    /* Return if the profile has disappeared: */
     158    if (m_comCloudProfile.isNull())
    154159
    155160    /* Clear table initially: */
     
    159164    QVector<QString> keys;
    160165    QVector<QString> values;
    161     values = m_comCloudProvider.GetProfileProperties(profileName(), keys);
     166    values = m_comCloudProfile.GetProperties(QString(), keys);
    162167
    163168    /* Configure table: */
     
    177182
    178183            /* Use non-translated description as tool-tip: */
    179             const QString strToolTip = m_comCloudProvider.GetPropertyDescription(keys.at(i));
     184            const QString strToolTip = m_comCloudProfile.GetPropertyDescription(keys.at(i));
    180185            pItemK->setData(Qt::UserRole, strToolTip);
    181186
     
    434439}
    435440
    436 CCloudProvider UIWizardExportAppPage2::provider() const
    437 {
    438     return m_comCloudProvider;
     441CCloudProfile UIWizardExportAppPage2::profile() const
     442{
     443    return m_comCloudProfile;
    439444}
    440445
     
    786791    for (int i = 0; i < m_pAccountComboBox->count(); ++i)
    787792    {
    788         if (m_pAccountComboBox->itemData(i, ProviderID).toString() == "OCI")
     793        if (m_pAccountComboBox->itemData(i, ProviderID).toString() == "54e11de4-afcc-47fb-9c39-b24244cfa044")
    789794        {
    790795            m_pAccountComboBox->setItemText(i, UIWizardExportApp::tr("Oracle Cloud Infrastructure: %1", "provider: profile")
     
    794799        {
    795800            m_pAccountComboBox->setItemText(i, UIWizardExportApp::tr("%1: %2", "provider: profile")
    796                 .arg(m_pAccountComboBox->itemData(i, ProviderID).toString())
     801                .arg(m_pAccountComboBox->itemData(i, ProviderName).toString())
    797802                .arg(m_pAccountComboBox->itemData(i, ProfileName).toString()));
    798803        }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.h

    r73580 r73716  
    2727/* COM includes: */
    2828#include "COMEnums.h"
     29#include "CCloudProfile.h"
    2930#include "CCloudProvider.h"
    3031#include "CCloudProviderManager.h"
     
    5556enum
    5657{
    57     ProviderID  = Qt::UserRole + 1,
    58     ProfileName = Qt::UserRole + 2
     58    ProviderID      = Qt::UserRole + 1,
     59    ProviderName    = Qt::UserRole + 2,
     60    ProfileName     = Qt::UserRole + 3
    5961};
    6062
     
    131133    /** Returns profile name. */
    132134    QString profileName() const;
    133     /** Returns Cloud Provider object. */
    134     CCloudProvider provider() const;
     135    /** Returns Cloud Profile object. */
     136    CCloudProfile profile() const;
    135137
    136138    /** Holds the Cloud Provider Manager reference. */
    137139    CCloudProviderManager  m_comCloudProviderManager;
    138     /** Holds the Cloud Provider object reference. */
    139     CCloudProvider         m_comCloudProvider;
     140    /** Holds the Cloud Profile object reference. */
     141    CCloudProfile          m_comCloudProfile;
    140142
    141143    /** Holds the default appliance name. */
     
    197199    Q_PROPERTY(bool manifestSelected READ isManifestSelected WRITE setManifestSelected);
    198200    Q_PROPERTY(bool includeISOsSelected READ isIncludeISOsSelected WRITE setIncludeISOsSelected);
    199     Q_PROPERTY(CCloudProvider provider READ provider);
     201    Q_PROPERTY(CCloudProfile profile READ profile);
    200202    Q_PROPERTY(QString profileName READ profileName);
    201203
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic3.cpp

    r73663 r73716  
    3838# include "CAppliance.h"
    3939# include "CCloudClient.h"
    40 # include "CCloudProvider.h"
     40# include "CCloudProfile.h"
    4141# include "CMachine.h"
    4242
     
    5757    m_listCloudClientParameters.clear();
    5858
    59     /* Acquire Cloud Provider: */
    60     CCloudProvider comCloudProvider = fieldImp("provider").value<CCloudProvider>();
    61     AssertMsgReturnVoid(comCloudProvider.isNotNull(),
    62                         ("Cloud provider object is undefined!"));
     59    /* Acquire Cloud Profile: */
     60    CCloudProfile comCloudProfile = fieldImp("profile").value<CCloudProfile>();
     61    AssertMsgReturnVoid(comCloudProfile.isNotNull(),
     62                        ("Cloud profile object is undefined!"));
    6363
    6464    /* Create Cloud Client: */
    65     CCloudClient comCloudClient = comCloudProvider.CreateCloudClient(fieldImp("profileName").toString());
    66     AssertMsgReturnVoid(comCloudProvider.isOk() && comCloudClient.isNotNull(),
     65    CCloudClient comCloudClient = comCloudProfile.CreateCloudClient();
     66    AssertMsgReturnVoid(comCloudProfile.isOk() && comCloudClient.isNotNull(),
    6767                        ("Can't create Cloud Client object!"));
    6868
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.h

    r73580 r73716  
    4141    Q_PROPERTY(bool manifestSelected READ isManifestSelected WRITE setManifestSelected);
    4242    Q_PROPERTY(bool includeISOsSelected READ isIncludeISOsSelected WRITE setIncludeISOsSelected);
    43     Q_PROPERTY(CCloudProvider provider READ provider);
     43    Q_PROPERTY(CCloudProfile profile READ profile);
    4444    Q_PROPERTY(QString profileName READ profileName);
    4545    Q_PROPERTY(ExportAppliancePointer applianceWidget READ applianceWidget);
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