VirtualBox

Changeset 73716 in vbox


Ignore:
Timestamp:
Aug 16, 2018 3:58:57 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
124395
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
Files:
1 deleted
18 edited
3 moved

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/log.h

    r73571 r73716  
    362362    /** Main group, ICloudClient. */
    363363    LOG_GROUP_MAIN_CLOUDCLIENT,
     364    /** Main group, ICloudProfile. */
     365    LOG_GROUP_MAIN_CLOUDPROFILE,
    364366    /** Main group, ICloudProvider. */
    365367    LOG_GROUP_MAIN_CLOUDPROVIDER,
     
    9981000    "MAIN_CLIPBOARDMODECHANGEDEVENT", \
    9991001    "MAIN_CLOUDCLIENT", \
     1002    "MAIN_CLOUDPROFILE", \
    10001003    "MAIN_CLOUDPROVIDER", \
    10011004    "MAIN_CLOUDPROVIDERMANAGER", \
  • 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);
  • trunk/src/VBox/Main/Makefile.kmk

    r73551 r73716  
    456456        src-server/ClientWatcher.cpp \
    457457        src-server/ClientToken.cpp \
    458         src-server/CloudAPI.cpp \
    459         src-server/CloudClientImpl.cpp \
    460         src-server/CloudUserProfilesImpl.cpp \
    461         src-server/CloudUserProfileManagerImpl.cpp \
     458        src-server/CloudProviderManagerImpl.cpp \
     459        $(if $(VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK),, \
     460                src-server/CloudAPI.cpp \
     461                src-server/CloudClientImpl.cpp \
     462                src-server/OCIProvider.cpp \
     463                src-server/OCIProfile.cpp) \
    462464        src-server/DHCPServerImpl.cpp \
    463465        src-server/NetworkServiceRunner.cpp \
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r73664 r73716  
    19541954  <interface
    19551955    name="IVirtualBox" extends="$unknown"
    1956     uuid="9570b9d5-f1a1-448a-10c5-e12f5285adad"
     1956    uuid="176b85cd-4bc2-453e-9228-f408c5282267"
    19571957    wsmap="managed"
    19581958    reservedMethods="7" reservedAttributes="12"
     
    21652165    </attribute>
    21662166
     2167    <attribute name="cloudProviderManager" type="ICloudProviderManager" readonly="yes">
     2168      <desc>
     2169        The cloud provider manager (singleton).
     2170      </desc>
     2171    </attribute>
     2172
    21672173    <method name="composeMachineFilename">
    21682174      <desc>
     
    24482454      <param name="unattended" type="IUnattended" dir="return">
    24492455        <desc>New unattended object.</desc>
    2450       </param>
    2451     </method>
    2452 
    2453     <method name="createCloudProviderManager">
    2454       <desc>
    2455         Creates a new cloud provider manager object
    2456       </desc>
    2457       <param name="manager" type="ICloudProviderManager" dir="return">
    2458         <desc>New cloud user profile manager</desc>
    24592456      </param>
    24602457    </method>
     
    2486524862
    2486624863  <enum
    24867     name="CloudProviderId"
    24868     uuid="c3856743-aa5d-404d-847d-14b6cf523677"
    24869     >
    24870     <const name="Unknown" value="0"/>
    24871     <const name="OCI" value="1"/>
    24872     <const name="GCP" value="2"/>
    24873     <const name="AWS" value="3"/>
    24874     <const name="MicrosoftAzure" value="4"/>
    24875     <const name="IBMCloud" value="5"/>
    24876     <const name="DigitalOcean" value="6"/>
    24877   </enum>
    24878 
    24879   <enum
    2488024864    name="CloudCommand"
    2488124865    uuid="1c5cfa19-7754-4071-bf3e-6d21ad432655"
     
    2511025094
    2511125095  <!--
    25112   // ICloudProvider
     25096  // ICloudProfile
    2511325097  //////////////////////////////////////////////////////////////////////////
    2511425098  -->
    2511525099
    2511625100  <interface
    25117     name="ICloudProvider" extends="$unknown"
    25118     uuid="cfadfecb-ef89-41a9-abbd-9772d41baddb"
     25101    name="ICloudProfile" extends="$unknown"
     25102    uuid="011d1e9a-a48b-4d15-91a0-6101b087155c"
    2511925103    wsmap="managed" reservedMethods="4" reservedAttributes="4"
    2512025104    >
    25121     <method name="getProvider">
    25122       <desc>
    25123         Returns provider Id tied with these profiles
    25124       </desc>
    25125       <param name="provider" type="CloudProviderId" dir="return">
    25126       </param>
    25127     </method>
    25128 
    25129     <method name="createProfile">
    25130       <desc>
    25131         Creates an empty profile
    25132       </desc>
    25133       <param name="profileName" type="wstring" dir="in">
    25134         <desc>
    25135           The profile's name
    25136         </desc>
    25137       </param>
    25138       <param name="names" type="wstring" safearray="yes" dir="in">
    25139         <desc>Names of properties.</desc>
    25140       </param>
    25141       <param name="values" type="wstring" safearray="yes" dir="in">
    25142         <desc>Values of set properties.</desc>
    25143       </param>
    25144     </method>
    25145 
    25146     <method name="updateProfile">
    25147       <desc>
    25148         Updates active profile in memory
    25149       </desc>
    25150       <param name="profileName" type="wstring" dir="in">
    25151         <desc>
    25152           The profile's name
    25153         </desc>
    25154       </param>
    25155       <param name="names" type="wstring" safearray="yes" dir="in">
    25156         <desc>Names of properties.</desc>
    25157       </param>
    25158       <param name="values" type="wstring" safearray="yes" dir="in">
    25159         <desc>Values of set properties.</desc>
    25160       </param>
    25161     </method>
    25162 
    25163     <method name="getStoredProfilesNames" const="yes">
    25164       <desc>
    25165         Returns the names\IDs for the existing profiles in one call.
    25166       </desc>
    25167       <param name="profilesNames" type="wstring" safearray="yes" dir="return">
    25168         <desc>Names of the existing profiles.</desc>
    25169       </param>
    25170     </method>
    25171 
    25172     <method name="getProfileProperties" const="yes">
    25173       <desc>
    25174         Returns values for a profile's properties in one call.
    25175 
    25176         The list of all properties supported by the given profile.
     25105
     25106    <attribute name="name" type="wstring" readonly="yes">
     25107      <desc>
     25108        Returns the profile name.
     25109      </desc>
     25110    </attribute>
     25111
     25112    <attribute name="providerId" type="uuid" mod="string" readonly="yes">
     25113      <desc>
     25114        Returns provider identifier tied with this profile.
     25115      </desc>
     25116    </attribute>
     25117
     25118    <attribute name="supportedPropertyNames" type="wstring" safearray="yes" readonly="yes">
     25119      <desc>
     25120        Returns the supported property names.
     25121      </desc>
     25122    </attribute>
     25123
     25124    <method name="getProperty" const="yes">
     25125      <desc>
     25126        Returns the value of the cloud profile property with the given name.
     25127
     25128        If the requested data @a name does not exist, this function will
     25129        succeed and return an empty string in the @a value argument.
     25130
     25131        <result name="E_INVALIDARG">@a name is @c null or empty.</result>
     25132      </desc>
     25133      <param name="name" type="wstring" dir="in">
     25134        <desc>Name of the property to get.</desc>
     25135      </param>
     25136      <param name="value" type="wstring" dir="return">
     25137        <desc>Current property value.</desc>
     25138      </param>
     25139    </method>
     25140
     25141    <method name="setProperty" const="yes">
     25142      <desc>
     25143        Sets the value of the cloud profile property with the given name.
     25144
     25145        Setting the property value to @c null or an empty string is equivalent
     25146        to deleting the existing value.
     25147
     25148        <result name="E_INVALIDARG">@a name is @c null or empty.</result>
     25149      </desc>
     25150      <param name="name" type="wstring" dir="in">
     25151        <desc>Name of the property to set.</desc>
     25152      </param>
     25153      <param name="value" type="wstring" dir="in">
     25154        <desc>Property value to set.</desc>
     25155      </param>
     25156    </method>
     25157
     25158    <method name="getProperties" const="yes">
     25159      <desc>
     25160        Returns values for a group of properties in one call.
     25161
     25162        The names of the properties to get are specified using the @a names
     25163        argument which is a list of comma-separated property names or
     25164        an empty string if all properties are to be returned.
     25165        <note>Currently the value of this argument is ignored and the method
     25166        always returns all existing properties.</note>
    2517725167
    2517825168        The method returns two arrays, the array of property names corresponding
     
    2518125171        given index in the first array corresponds to an element at the same
    2518225172        index in the second array.
    25183 
    25184         For properties that do not have assigned values, an empty string is
    25185         returned at the appropriate index in the @a returnValues array.
    25186 
    25187       </desc>
    25188       <param name="profileName" type="wstring" dir="in">
    25189         <desc>
    25190           Name of profile.
     25173      </desc>
     25174      <param name="names" type="wstring" dir="in">
     25175        <desc>
     25176          Names of properties to get.
    2519125177        </desc>
    2519225178      </param>
     
    2519925185    </method>
    2520025186
     25187    <method name="setProperties">
     25188      <desc>
     25189        Updates profile, changing/adding/removing properties.
     25190
     25191        The names of the properties to set are passed in the @a names
     25192        array along with the new values for them in the @a values array. Both
     25193        arrays have the same number of elements with each element at the given
     25194        index in the first array corresponding to an element at the same index
     25195        in the second array.
     25196
     25197        If there is at least one property name in @a names that is not valid,
     25198        the method will fail before changing the values of any other properties
     25199        from the @a names array.
     25200
     25201        Using this method over <link to="#setProperty"/> is preferred if you
     25202        need to set several properties at once since it is more efficient.
     25203
     25204        Setting the property value to @c null or an empty string is equivalent
     25205        to deleting the existing value.
     25206      </desc>
     25207      <param name="names" type="wstring" safearray="yes" dir="in">
     25208        <desc>Names of properties.</desc>
     25209      </param>
     25210      <param name="values" type="wstring" safearray="yes" dir="in">
     25211        <desc>Values of set properties.</desc>
     25212      </param>
     25213    </method>
     25214
     25215    <!--- @todo r=klaus Is this the best placement of this method? To me it's
     25216         not obvious that it processes the object's state at all, and could be
     25217         moved up to ICloudProvider unless there's any chance that the
     25218         description changes with the profile. -->
    2520125219    <method name="getPropertyDescription" const="yes">
    2520225220      <param name="name" type="wstring" dir="in">
    25203         <desc>Property name</desc>
     25221        <desc>Property name.</desc>
    2520425222      </param>
    2520525223      <param name="description" type="wstring" dir="return">
    25206         <desc>Property description</desc>
     25224        <desc>Property description.</desc>
    2520725225      </param>
    2520825226    </method>
     
    2521025228    <method name="createCloudClient">
    2521125229      <desc>
    25212         Creates a cloud client for this cloud provider
     25230        Creates a cloud client for this cloud profile.
     25231      </desc>
     25232      <param name="cloudClient" type="ICloudClient" dir="return">
     25233        <desc>
     25234          The cloud client object reference.
     25235        </desc>
     25236      </param>
     25237    </method>
     25238
     25239  </interface>
     25240
     25241  <!--
     25242  // ICloudProvider
     25243  //////////////////////////////////////////////////////////////////////////
     25244  -->
     25245
     25246  <interface
     25247    name="ICloudProvider" extends="$unknown"
     25248    uuid="6e500583-602c-49bc-894d-2f53b8e371e9"
     25249    wsmap="managed" reservedMethods="4" reservedAttributes="4"
     25250    >
     25251
     25252    <attribute name="name" type="wstring" readonly="yes">
     25253      <desc>Returns the long name of the provider. Includes vendor and precise
     25254        product name spelled out in the preferred way.</desc>
     25255    </attribute>
     25256
     25257    <attribute name="shortName" type="wstring" readonly="yes">
     25258      <desc>Returns the short name of the provider. Less than 8 ASCII chars,
     25259        using acronyms. No vendor name, but can contain a hint if it's a 3rd
     25260        party implementation for this cloud provider, to keep it unique.</desc>
     25261    </attribute>
     25262
     25263    <attribute name="id" type="uuid" mod="string" readonly="yes">
     25264      <desc>Returns the UUID of this cloud provider.</desc>
     25265    </attribute>
     25266
     25267    <!-- if there are any generally useful, static pieces of information about
     25268         a particular cloud provider, please add them here. Maybe a description
     25269         of the functionality of the cloud provider implementation?-->
     25270
     25271    <attribute name="profiles" type="ICloudProfile" safearray="yes" readonly="yes">
     25272      <desc>Returns all profiles for this cloud provider.</desc>
     25273    </attribute>
     25274
     25275    <attribute name="profileNames" type="wstring" safearray="yes" readonly="yes">
     25276      <desc>Returns all profile names for this cloud provider.</desc>
     25277    </attribute>
     25278
     25279    <method name="createProfile">
     25280      <desc>
     25281        Creates a new profile.
    2521325282      </desc>
    2521425283      <param name="profileName" type="wstring" dir="in">
    25215       </param>
    25216       <param name="cloudClient" type="ICloudClient" dir="return">
    25217         <desc>
    25218           returns interface to the cloud client object
    25219         </desc>
    25220       </param>
     25284        <desc>
     25285          The profile name. Must not exist, otherwise an error is raised.
     25286        </desc>
     25287      </param>
     25288      <param name="names" type="wstring" safearray="yes" dir="in">
     25289        <desc>Names of properties.</desc>
     25290      </param>
     25291      <param name="values" type="wstring" safearray="yes" dir="in">
     25292        <desc>Values of set properties.</desc>
     25293      </param>
     25294    </method>
     25295
     25296    <method name="getProfileByName">
     25297      <param name="profileName" type="wstring" dir="in"/>
     25298      <param name="profile" type="ICloudProfile" dir="return"/>
    2522125299    </method>
    2522225300
     
    2522925307  <interface
    2523025308    name="ICloudProviderManager" extends="$unknown"
    25231     uuid="64e276a7-cfd1-48ed-aad3-19368197f3b2"
     25309    uuid="95533d5b-20ec-4089-b461-f2794c9512df"
    2523225310    wsmap="managed" reservedMethods="4" reservedAttributes="4"
    2523325311    >
    2523425312
    25235     <attribute name="supportedProviders" type="wstring" readonly="yes" safearray="yes">
    25236       <desc>Returns a predefined list of all supported cloud providers.</desc>
    25237     </attribute>
    25238 
    25239     <method name="getAllProfiles" const="yes">
    25240       <desc>
    25241         Returns the list of the ICloudProvider in one call.
    25242       </desc>
    25243       <param name="profileList" type="ICloudProvider" safearray="yes" dir="return">
    25244         <desc>Returns the list of ICloudProvider.</desc>
    25245       </param>
    25246     </method>
    25247 
    25248     <method name="getProfilesByProvider" const="yes">
    25249       <desc>
    25250         Returns the ICloudProvider for the particular provider.
    25251       </desc>
    25252       <param name="providerName" type="wstring" dir="in">
    25253       </param>
    25254       <param name="profile" type="ICloudProvider" dir="return">
    25255         <desc>Returns the ICloudProvider.</desc>
    25256       </param>
     25313    <attribute name="providers" type="ICloudProvider" safearray="yes" readonly="yes">
     25314      <desc>Returns all supported cloud providers.</desc>
     25315    </attribute>
     25316
     25317    <method name="getProviderById">
     25318      <param name="providerId" type="uuid" mod="string" dir="in"/>
     25319      <param name="provider" type="ICloudProvider" dir="return"/>
     25320    </method>
     25321
     25322    <method name="getProviderByShortName">
     25323      <param name="providerName" type="wstring" dir="in"/>
     25324      <param name="provider" type="ICloudProvider" dir="return"/>
     25325    </method>
     25326
     25327    <method name="getProviderByName">
     25328      <param name="providerName" type="wstring" dir="in"/>
     25329      <param name="provider" type="ICloudProvider" dir="return"/>
    2525725330    </method>
    2525825331
    2525925332  </interface>
     25333
    2526025334
    2526125335  <module name="VBoxSVC" context="LocalServer">
  • trunk/src/VBox/Main/include/CloudProviderManagerImpl.h

    r73710 r73716  
    55
    66/*
    7  * Copyright (C) 2006-2018 Oracle Corporation
     7 * Copyright (C) 2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1717
    1818
    19 #ifndef ____H_CLOUDUSERPROFILEMANAGERIMPL
    20 #define ____H_CLOUDUSERPROFILEMANAGERIMPL
     19#ifndef ____H_CLOUDPROVIDERMANAGERIMPL
     20#define ____H_CLOUDPROVIDERMANAGERIMPL
    2121
    22 /* VBox includes */
    2322#include "CloudProviderManagerWrap.h"
    24 #include "CloudUserProfilesImpl.h"
     23#ifdef VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK
     24class ExtPackManager;
     25#endif
    2526
    26 /* VBox forward declarations */
    2727
    2828class ATL_NO_VTABLE CloudProviderManager
     
    3030{
    3131public:
    32 
    3332    DECLARE_EMPTY_CTOR_DTOR(CloudProviderManager)
    3433
     
    3635    void FinalRelease();
    3736
    38     HRESULT init(VirtualBox *aVirtualBox);
     37    HRESULT init(VirtualBox *aParent);
    3938    void uninit();
    4039
    41 private:
    42     ComPtr<VirtualBox> const mParent;       /**< Strong reference to the parent object (VirtualBox/IMachine). */
    4340#ifdef VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK
    44     std::vector<ComPtr<ICloudProviderManager>> mUserProfileManagers;
    45 #else
    46     std::vector<Utf8Str> mSupportedProviders;
     41    // Safe helpers, take care of caller and lock themselves.
     42    void i_refreshProviders();
    4743#endif
    4844
    49     HRESULT getSupportedProviders(std::vector<Utf8Str> &aProviderTypes);
    50     HRESULT getAllProfiles(std::vector< ComPtr<ICloudProvider> > &aProfilesList);
    51     HRESULT getProfilesByProvider(const com::Utf8Str &aProviderName, ComPtr<ICloudProvider> &aProfiles);
     45private:
     46    // wrapped ICloudProviderManager attributes and methods
     47    HRESULT getProviders(std::vector<ComPtr<ICloudProvider> > &aProviders);
     48    HRESULT getProviderById(const com::Guid &aProviderId,
     49                            ComPtr<ICloudProvider> &aProvider);
     50    HRESULT getProviderByShortName(const com::Utf8Str &aProviderName,
     51                                   ComPtr<ICloudProvider> &aProvider);
     52    HRESULT getProviderByName(const com::Utf8Str &aProviderName,
     53                              ComPtr<ICloudProvider> &aProvider);
     54
     55private:
     56#ifdef VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK
     57    ComObjPtr<ExtPackManager> mpExtPackMgr;
     58    uint64_t mcExtPackMgrUpdate;
     59    std::map<com::Utf8Str, ComPtr<ICloudProviderManager> > m_mapCloudProviderManagers;
     60#endif
     61
     62    std::vector<ComPtr<ICloudProvider> > m_apCloudProviders;
    5263};
    5364
    54 #endif // !____H_CLOUDUSERPROFILEMANAGERIMPL
     65#endif // !____H_CLOUDPROVIDERMANAGERIMPL
     66
    5567/* vi: set tabstop=4 shiftwidth=4 expandtab: */
    56 
  • trunk/src/VBox/Main/include/ExtPackManagerImpl.h

    r73548 r73716  
    209209    HRESULT     i_doUninstall(const Utf8Str *a_pstrName, bool a_fForcedRemoval, const Utf8Str *a_pstrDisplayInfo);
    210210    void        i_callAllVirtualBoxReadyHooks(void);
    211     HRESULT     i_queryObjects(const com::Utf8Str &aObjUuid, std::vector<ComPtr<IUnknown> > &aObjects);
     211    HRESULT     i_queryObjects(const com::Utf8Str &aObjUuid, std::vector<ComPtr<IUnknown> > &aObjects, std::vector<com::Utf8Str> *a_pstrExtPackNames);
    212212#endif
    213213#ifdef VBOX_COM_INPROC
     
    228228    bool        i_isExtPackUsable(const char *a_pszExtPack);
    229229    void        i_dumpAllToReleaseLog(void);
     230    uint64_t    i_getUpdateCounter(void);
    230231    /** @}  */
    231232
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r73571 r73716  
    289289    HRESULT getInternalNetworks(std::vector<com::Utf8Str> &aInternalNetworks);
    290290    HRESULT getGenericNetworkDrivers(std::vector<com::Utf8Str> &aGenericNetworkDrivers);
     291    HRESULT getCloudProviderManager(ComPtr<ICloudProviderManager> &aCloudProviderManager);
    291292
    292293   // wrapped IVirtualBox methods
     
    313314    HRESULT createAppliance(ComPtr<IAppliance> &aAppliance);
    314315    HRESULT createUnattendedInstaller(ComPtr<IUnattended> &aUnattended);
    315     HRESULT createCloudProviderManager(ComPtr<ICloudProviderManager> &aManager);
    316316    HRESULT createMedium(const com::Utf8Str &aFormat,
    317317                         const com::Utf8Str &aLocation,
  • trunk/src/VBox/Main/src-all/ExtPackManagerImpl.cpp

    r73562 r73716  
    155155struct ExtPackManager::Data
    156156{
     157    Data()
     158        : cUpdate(0)
     159    {}
     160
    157161    /** The directory where the extension packs are installed. */
    158162    Utf8Str             strBaseDir;
     
    168172    /** The current context. */
    169173    VBOXEXTPACKCTX      enmContext;
     174    /** Update counter for the installed extension packs, increased in every list update. */
     175    uint64_t            cUpdate;
    170176
    171177    RTMEMEF_NEW_AND_DELETE_OPERATORS();
     
    20022008                        delete pstrName;
    20032009                        if (SUCCEEDED(hrc2))
     2010                        {
    20042011                            m->llInstalledExtPacks.push_back(NewExtPack);
     2012                            /* Paranoia, there should be no API clients before this method is finished. */
     2013
     2014                            m->cUpdate++;
     2015                        }
    20052016                        else if (SUCCEEDED(rc))
    20062017                            hrc = hrc2;
     
    24672478        {
    24682479            m->llInstalledExtPacks.erase(it);
     2480            m->cUpdate++;
    24692481            return;
    24702482        }
     
    25822594            {
    25832595                m->llInstalledExtPacks.push_back(ptrNewExtPack);
     2596                m->cUpdate++;
    25842597                if (ptrNewExtPack->m->fUsable)
    25852598                    LogRel(("ExtPackManager: Found extension pack '%s'.\n", a_pszName));
     
    29012914 * @param   aObjUuid        The UUID of the kind of objects we're querying.
    29022915 * @param   aObjects        Where to return the objects.
     2916 * @param   a_pstrExtPackNames Where to return the corresponding extpack names (may be NULL).
    29032917 *
    29042918 * @remarks The caller must not hold any locks.
    29052919 */
    2906 HRESULT ExtPackManager::i_queryObjects(const com::Utf8Str &aObjUuid, std::vector<ComPtr<IUnknown> > &aObjects)
     2920HRESULT ExtPackManager::i_queryObjects(const com::Utf8Str &aObjUuid, std::vector<ComPtr<IUnknown> > &aObjects, std::vector<com::Utf8Str> *a_pstrExtPackNames)
    29072921{
    29082922    aObjects.clear();
     2923    if (a_pstrExtPackNames)
     2924        a_pstrExtPackNames->clear();
    29092925
    29102926    AutoCaller autoCaller(this);
     
    29222938            HRESULT hrc2 = (*it)->queryObject(aObjUuid, ptrIf);
    29232939            if (SUCCEEDED(hrc2))
     2940            {
    29242941                aObjects.push_back(ptrIf);
     2942                if (a_pstrExtPackNames)
     2943                    a_pstrExtPackNames->push_back((*it)->m->Desc.strName);
     2944            }
    29252945            else if (hrc2 != E_NOINTERFACE)
    29262946                hrc = hrc2;
     
    32433263}
    32443264
     3265/**
     3266 * Gets the update counter (reflecting extpack list updates).
     3267 */
     3268uint64_t ExtPackManager::i_getUpdateCounter(void)
     3269{
     3270    AutoCaller autoCaller(this);
     3271    HRESULT hrc = autoCaller.rc();
     3272    if (FAILED(hrc))
     3273        return 0;
     3274    AutoReadLock autoLock(this COMMA_LOCKVAL_SRC_POS);
     3275    return m->cUpdate;
     3276}
     3277
    32453278/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/src-all/ProgressImpl.cpp

    r73003 r73716  
    208208    unconst(mId).create();
    209209
    210 #if !defined(VBOX_COM_INPROC)
     210#if !defined(VBOX_COM_INPROC) && !defined(VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK)
    211211    /* add to the global collection of progress operations (note: after
    212212     * creating mId) */
     
    327327    unconst(mInitiator).setNull();
    328328
    329 #if !defined(VBOX_COM_INPROC)
     329#if !defined(VBOX_COM_INPROC) && !defined(VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK)
    330330    if (mParent)
    331331    {
     
    471471    mErrorInfo = aErrorInfo;
    472472
    473 #if !defined VBOX_COM_INPROC
     473#if !defined(VBOX_COM_INPROC) && !defined(VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK)
    474474    /* remove from the global collection of pending progress operations */
    475475    if (mParent)
  • trunk/src/VBox/Main/src-server/CloudProviderManagerImpl.cpp

    r73576 r73716  
    1717
    1818
    19 #include <iprt/path.h>
    20 #include <iprt/cpp/utils.h>
    2119#include <VBox/com/array.h>
    22 #include <map>
    23 
    24 #include "CloudUserProfileManagerImpl.h"
    25 #include "CloudUserProfilesImpl.h"
     20
    2621#include "VirtualBoxImpl.h"
    27 #include "ExtPackManagerImpl.h"
    28 #include "Global.h"
    29 #include "ProgressImpl.h"
    30 #include "MachineImpl.h"
     22#include "CloudProviderManagerImpl.h"
     23#ifdef VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK
     24# include "ExtPackManagerImpl.h"
     25#else
     26# include "OCIProvider.h"
     27#endif
    3128#include "AutoCaller.h"
    3229#include "Logging.h"
     
    4037// ////////////////////////////////////////////////////////////////////////////////
    4138CloudProviderManager::CloudProviderManager()
    42     : mParent(NULL)
    4339{
    4440}
     
    6359HRESULT CloudProviderManager::init(VirtualBox *aParent)
    6460{
    65     /* Enclose the state transition NotReady->InInit->Ready */
     61    // Enclose the state transition NotReady->InInit->Ready.
    6662    AutoInitSpan autoInitSpan(this);
    6763    AssertReturn(autoInitSpan.isOk(), E_FAIL);
    6864
    69     unconst(mParent) = aParent;
     65    m_apCloudProviders.clear();
    7066
    7167#ifdef VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK
    72     /*
    73      * Engage the extension pack manager and get all the implementations of this class.
    74      */
     68    // Engage the extension pack manager and get all the implementations of
     69    // this class and all implemented cloud providers.
    7570    ExtPackManager *pExtPackMgr = aParent->i_getExtPackManager();
    76     std::vector<ComPtr<IUnknown> > Objects;
    77     com::Guid idObj(COM_IIDOF(ICloudProviderManager));
    78     pExtPackMgr->i_queryObjects(idObj.toString(), Objects);
    79     for (unsigned i = 0; i < Objects.size(); i++)
    80     {
    81         ComPtr<ICloudProviderManager> ptrTmp;
    82         HRESULT hrc = Objects[i].queryInterfaceTo(ptrTmp.asOutParam());
    83         if (SUCCEEDED(hrc))
    84             mUserProfileManagers.push_back(ptrTmp);
     71    mpExtPackMgr = pExtPackMgr;
     72    if (pExtPackMgr)
     73    {
     74        mcExtPackMgrUpdate = pExtPackMgr->i_getUpdateCounter();
     75        // Make sure that the current value doesn't match, forcing a refresh.
     76        mcExtPackMgrUpdate--;
     77        iRefreshProviders();
    8578    }
    8679#else
    87 
    88     mSupportedProviders.clear();
    89     mSupportedProviders.push_back("OCI");
    90 
     80    ComObjPtr<OCIProvider> pOCIProvider;
     81    HRESULT hrc = pOCIProvider.createObject();
     82    if (FAILED(hrc))
     83        return hrc;
     84    hrc = pOCIProvider->init(aParent);
     85    if (FAILED(hrc))
     86        return hrc;
     87    m_apCloudProviders.push_back(pOCIProvider);
    9188#endif
    9289
     
    9794void CloudProviderManager::uninit()
    9895{
    99     /* Enclose the state transition Ready->InUninit->NotReady */
     96    // Enclose the state transition Ready->InUninit->NotReady.
    10097    AutoUninitSpan autoUninitSpan(this);
    10198    if (autoUninitSpan.uninitDone())
    10299        return;
    103 
    104     unconst(mParent) = NULL;
    105 }
    106 
    107 HRESULT CloudProviderManager::getSupportedProviders(std::vector<Utf8Str> &aSupportedProviders)
    108 {
     100}
     101
    109102#ifdef VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK
    110     /*
    111      * Collect all the provider names from all the extension pack objects.
    112      */
    113     HRESULT hrc = S_OK;
    114     for (unsigned i = 0; i < mUserProfileManagers.size(); i++)
    115     {
    116         SafeArray<Utf8Str> FromCurrent;
    117         HRESULT hrc2 = mUserProfileManagers[i]->COMGETTER(SupportedProviders)(ComSafeArrayAsOutParam(FromCurrent));
    118         if (SUCCEEDED(hrc2))
    119             for (size_t j = 0; j < FromCurrent.size(); j++)
    120                 aSupportedProviders.push_back(FromCurrent[j]);
    121         else if (SUCCEEDED(hrc))
    122             hrc = hrc2;
    123     }
    124     if (aSupportedProviders.size() > 0)
    125         hrc = S_OK;
    126     return hrc;
    127 #else
    128     aSupportedProviders = mSupportedProviders;
     103void CloudProviderManager::i_refreshProviders()
     104{
     105    {
     106        AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     107        uint64_t cExtPackMgrUpdate = mpExtPackMgr->i_getUpdateCounter();
     108        if (cExtPackMgrUpdate == mcExtPackMgrUpdate)
     109            return;
     110    }
     111
     112    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     113    // Reread the current value to figure out if some other thead did the work
     114    // already before this thread got hold of the write lock.
     115    cExtPackMgrUpdate = pExtPackMgr->i_getUpdateCounter();
     116    if (cExtPackMgrUpdate == mcExtPackMgrUpdate)
     117        return;
     118    mcExtPackMgrUpdate = cExtPackMgrUpdate;
     119
     120    if (!m_mapCloudProviderManagers.empty())
     121    {
     122        /// @todo The code below will need to be extended to handle extpack
     123        // install and uninstall safely (and the latter needs non-trivial
     124        // checks if any extpack related cloud activity is pending.
     125        return;
     126    }
     127
     128    std::vector<ComPtr<IUnknown> > apObjects;
     129    std::vector<com::Utf8Str> astrExtPackNames;
     130    com::Guid idObj(COM_IIDOF(ICloudProviderManager));
     131    pExtPackMgr->i_queryObjects(idObj.toString(), apObjects, &astrExtPackNames);
     132    for (unsigned i = 0; i < apObjects.size(); i++)
     133    {
     134        ComPtr<ICloudProviderManager> pTmp;
     135        HRESULT hrc = apObjects[i].queryInterfaceTo(pTmp.asOutParam());
     136        if (SUCCEEDED(hrc))
     137            m_mapCloudProviderManagers[astrExtPackNames[i]] = pTmp;
     138        SafeIfaceArray<ICloudProvider> apProvidersFromCurrExtPack;
     139        hrc = pTmp->COMGETTER(Providers)(ComSafeArrayAsOutParam(apProvidersFromCurrExtPack));
     140        if (SUCCEEDED(hrc))
     141        {
     142            for (unsigned j = 0; j < apProvidersFromCurrExtPack.size(); j++)
     143                m_apCloudProviders.push_back(apProvidersFromCurrExtPack[i]);
     144        }
     145    }
     146}
     147#endif
     148
     149HRESULT CloudProviderManager::getProviders(std::vector<ComPtr<ICloudProvider> > &aProviders)
     150{
     151    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     152    aProviders = m_apCloudProviders;
    129153    return S_OK;
    130 #endif
    131 }
    132 
    133 HRESULT CloudProviderManager::getAllProfiles(std::vector<ComPtr<ICloudProvider> > &aProfilesList)
    134 {
    135 #ifdef VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK
    136     /*
    137      * Collect all the cloud providers from all the extension pack objects.
    138      */
    139     HRESULT hrc = S_OK;
    140     for (unsigned i = 0; i < mUserProfileManagers.size(); i++)
    141     {
    142         SafeIfaceArray<ICloudProvider> FromCurrent;
    143         HRESULT hrc2 = mUserProfileManagers[i]->GetAllProfiles(ComSafeArrayAsOutParam(FromCurrent));
    144         if (SUCCEEDED(hrc2))
    145             for (size_t j = 0; j < FromCurrent.size(); j++)
    146                 aProfilesList.push_back(FromCurrent[j]);
    147         else if (SUCCEEDED(hrc))
    148             hrc = hrc2;
    149     }
    150     if (aProfilesList.size() > 0)
    151         hrc = S_OK;
    152     return hrc;
    153 
    154 #else
    155     HRESULT hrc = S_OK;
    156     std::vector<ComPtr<ICloudProvider> > lProfilesList;
    157     for (size_t i=0;i<mSupportedProviders.size();++i)
    158     {
    159         ComPtr<ICloudProvider> lProfiles;
    160         hrc = getProfilesByProvider(mSupportedProviders.at(i), lProfiles);
    161         if (FAILED(hrc))
    162             break;
    163 
    164         lProfilesList.push_back(lProfiles);
    165     }
    166 
    167     if (SUCCEEDED(hrc))
    168         aProfilesList = lProfilesList;
    169 
    170     return hrc;
    171 #endif
    172 }
    173 
    174 HRESULT CloudProviderManager::getProfilesByProvider(const com::Utf8Str &aProviderName,
    175                                                     ComPtr<ICloudProvider> &aProfiles)
    176 {
    177 #ifdef VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK
    178     /*
    179      * Return the first provider we get.
    180      */
    181     HRESULT hrc = VBOX_E_OBJECT_NOT_FOUND;
    182     for (unsigned i = 0; i < mUserProfileManagers.size(); i++)
    183     {
    184         hrc = mUserProfileManagers[i]->GetProfilesByProvider(aProviderType, aProfiles.asOutParam());
    185         if (SUCCEEDED(hrc))
    186             break;
    187     }
    188     return hrc;
    189 
    190 #else
    191 
    192     ComObjPtr<CloudProvider> ptrCloudProvider;
    193     HRESULT hrc = ptrCloudProvider.createObject();
    194     if (aProviderName.equals("OCI"))
    195     {
    196         ComObjPtr<OCIUserProfiles> ptrOCIUserProfiles;
    197         hrc = ptrOCIUserProfiles.createObject();
    198         if (SUCCEEDED(hrc))
    199         {
    200             AutoReadLock wlock(this COMMA_LOCKVAL_SRC_POS);
    201 
    202             hrc = ptrOCIUserProfiles->init(mParent);
    203             if (SUCCEEDED(hrc))
    204             {
    205                 char szOciConfigPath[RTPATH_MAX];
    206                 int vrc = RTPathUserHome(szOciConfigPath, sizeof(szOciConfigPath));
    207                 if (RT_SUCCESS(vrc))
    208                     vrc = RTPathAppend(szOciConfigPath, sizeof(szOciConfigPath), ".oci" RTPATH_SLASH_STR "config");
    209                 if (RT_SUCCESS(vrc))
    210                 {
    211                     LogRel(("config = %s\n", szOciConfigPath));
    212                     if (RTFileExists(szOciConfigPath))
    213                     {
    214                         hrc = ptrOCIUserProfiles->readProfiles(szOciConfigPath);
    215                         if (SUCCEEDED(hrc))
    216                             LogRel(("Reading profiles from %s has been done\n", szOciConfigPath));
    217                         else
    218                             LogRel(("Reading profiles from %s hasn't been done\n", szOciConfigPath));
    219 
    220                         ptrCloudProvider = ptrOCIUserProfiles;
    221                         hrc = ptrCloudProvider.queryInterfaceTo(aProfiles.asOutParam());
    222                     }
    223                     else
    224                         hrc = setErrorBoth(E_FAIL, VERR_FILE_NOT_FOUND, tr("Could not locate the config file '%s'"),
    225                                            szOciConfigPath);
    226                 }
    227                 else
    228                     hrc = setErrorVrc(vrc);
    229             }
    230         }
    231     }
    232 
    233     return hrc;
    234 #endif
    235 }
    236 
     154}
     155
     156HRESULT CloudProviderManager::getProviderById(const com::Guid &aProviderId,
     157                                              ComPtr<ICloudProvider> &aProvider)
     158{
     159    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     160    for (size_t i = 0; i < m_apCloudProviders.size(); i++)
     161    {
     162        Bstr bstrId;
     163        HRESULT hrc = m_apCloudProviders[i]->COMGETTER(Id)(bstrId.asOutParam());
     164        if (SUCCEEDED(hrc) && aProviderId == bstrId)
     165        {
     166            aProvider = m_apCloudProviders[i];
     167            return S_OK;
     168        }
     169    }
     170    return setError(VBOX_E_OBJECT_NOT_FOUND, tr("Could not find a cloud provider with UUID {%RTuuid}"),
     171                    aProviderId.raw());
     172}
     173
     174HRESULT CloudProviderManager::getProviderByShortName(const com::Utf8Str &aProviderName,
     175                                                     ComPtr<ICloudProvider> &aProvider)
     176{
     177    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     178    for (size_t i = 0; i < m_apCloudProviders.size(); i++)
     179    {
     180        Bstr bstrName;
     181        HRESULT hrc = m_apCloudProviders[i]->COMGETTER(ShortName)(bstrName.asOutParam());
     182        if (SUCCEEDED(hrc) && bstrName.equals(aProviderName))
     183        {
     184            aProvider = m_apCloudProviders[i];
     185            return S_OK;
     186        }
     187    }
     188    return setError(VBOX_E_OBJECT_NOT_FOUND, tr("Could not find a cloud provider with short name '%s'"),
     189                    aProviderName.c_str());
     190}
     191
     192HRESULT CloudProviderManager::getProviderByName(const com::Utf8Str &aProviderName,
     193                                                ComPtr<ICloudProvider> &aProvider)
     194{
     195    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     196    for (size_t i = 0; i < m_apCloudProviders.size(); i++)
     197    {
     198        Bstr bstrName;
     199        HRESULT hrc = m_apCloudProviders[i]->COMGETTER(Name)(bstrName.asOutParam());
     200        if (SUCCEEDED(hrc) && bstrName.equals(aProviderName))
     201        {
     202            aProvider = m_apCloudProviders[i];
     203            return S_OK;
     204        }
     205    }
     206    return setError(VBOX_E_OBJECT_NOT_FOUND, tr("Could not find a cloud provider with name '%s'"),
     207                    aProviderName.c_str());
     208}
     209
  • trunk/src/VBox/Main/src-server/OCIProfile.cpp

    r73576 r73716  
    11/* $Id$ */
    22/** @file
    3  * ICloudProvider COM class implementations.
     3 * ICloudProfile COM class implementation (OCI).
    44 */
    55
     
    1616 */
    1717
    18 
    19 #include <iprt/path.h>
     18#include "OCIProfile.h"
     19#include "OCIProvider.h"
     20#include "CloudClientImpl.h"
     21#include "AutoCaller.h"
     22#define LOG_GROUP_MAIN_OVERRIDE LOG_GROUP_MAIN_CLOUDPROFILE
     23#include "Logging.h"
     24
    2025#include <iprt/cpp/utils.h>
    21 #include <VBox/com/array.h>
    22 
    23 #include "CloudUserProfilesImpl.h"
    24 #include "VirtualBoxImpl.h"
    25 #include "Global.h"
    26 #include "ProgressImpl.h"
    27 #include "MachineImpl.h"
    28 #include "AutoCaller.h"
    29 #include "Logging.h"
    30 
    31 using namespace std;
     26
    3227
    3328////////////////////////////////////////////////////////////////////////////////
    3429//
    35 // SimpleConfigFile implementation
     30// OCIProfile implementation
    3631//
    3732////////////////////////////////////////////////////////////////////////////////
    38 SimpleConfigFile::SimpleConfigFile(VirtualBoxBase *pSetError, const char *pszFilename)
    39     : GeneralTextScript(pSetError, pszFilename)
    40 {
    41     LogRel(("SimpleConfigFile::SimpleConfigFile(VirtualBoxBase *pSetError,...)\n"));
    42 }
    43 
    44 SimpleConfigFile::~SimpleConfigFile()
    45 {
    46     LogRel(("SimpleConfigFile::~SimpleConfigFile()\n"));
    47 }
    48 
    49 HRESULT SimpleConfigFile::parse()
    50 {
    51     LogRel(("Starting to parse the existing profiles\n"));
    52     HRESULT hrc = S_OK;
    53     hrc = GeneralTextScript::parse();
    54     if (SUCCEEDED(hrc))
    55     {
    56         size_t lines = getLineNumbersOfScript();
    57         LogRel(("Initial parsing (GeneralTextScript::parse()) was succeeded \n"));
    58         LogRel(("Read lines is %d \n", lines));
    59         size_t startSectionPos=0;
    60         bool fInSection = false;
    61         std::map <Utf8Str, Utf8Str> sectionConfiguration;
    62         Utf8Str strSectionName("Default section ");
    63 
    64         for (size_t i=0; i<lines; ++i)
    65         {
    66             //find the beginning of section, it starts from the line like "[section name]"
    67             //next find the end of section, it ends up when we find the beginning
    68             //of the next section or reach the end of the contents.
    69             //Go through the found lines and split each of them up by "=".
    70             //Each correct line must look like "key=value"
    71             //if there is not the character "=" in the line one is skipped
    72             //class Utf8Str contains the function parseKeyValue() for this action
    73             LogRel(("Parsing the line %d \n", i));
    74             Utf8Str strLineContent = getContentOfLine(i);
    75             if (strLineContent.isEmpty() || strLineContent.startsWith("#"))
    76                 continue;
    77 
    78             LogRel(("Content of the line %d is %s \n", i, strLineContent.c_str()));
    79 
    80             //strips the white-space characters from the string. It's needed for strings on Windows with "\n\r".
    81             strLineContent = strLineContent.strip();
    82             if ( strLineContent.startsWith("[") && strLineContent.endsWith("]") )
    83             {
    84                 LogRel(("Found section in the line %d\n", i));
    85                 if ( fInSection == true )
    86                 {
    87                     if ( i > startSectionPos )//at least we can have here 1 line in the section
    88                     {
    89                         LogRel(("Add section \"%s\" to the map \n", strSectionName.c_str()));
    90                         mSections.insert(make_pair(strSectionName, sectionConfiguration));
    91                         sectionConfiguration.clear();
    92                         strSectionName.append(Utf8StrFmt("%d",i).c_str());
    93                     }
    94                 }
    95 
    96                 strSectionName = strLineContent.substr(strLineContent.find("[")+1,
    97                                                        strLineContent.find("]")-1);
    98                 LogRel(("Section name is \"%s\" \n", strSectionName.c_str()));
    99                 fInSection = true;
    100                 startSectionPos = i+1;
    101             }
    102             else
    103             {
    104                 if ( fInSection == true )
    105                 {
    106                     LogRel(("Continue to parse section \"%s\" \n", strSectionName.c_str()));
    107                     if ( i >= startSectionPos )
    108                     {
    109                         LogRel(("Extracting key and value:\n"));
    110                         Utf8Str key, value;
    111                         size_t offEnd = strLineContent.parseKeyValue(key, value);
    112                         if (offEnd == strLineContent.length())
    113                         {
    114                             LogRel(("%s=%s \n", key.c_str(), value.c_str()));
    115                             sectionConfiguration.insert(make_pair(key,value));
    116                         }
    117                         else
    118                         {
    119                             //else something goes wrong, skip the line
    120                             LogRel(("Coudn't extract key and value from the line %d\n", i));
    121                         }
    122                     }
    123                 }
    124                 else
    125                 {
    126                     LogRel(("Goes to the next line %d\n", i+1));
    127                 }
    128             }
    129         }
    130 
    131         if (fInSection == false)//there is not any section
    132         {
    133             LogRel(("There are not any sections in the config\n"));
    134             hrc = E_FAIL;
    135         }
    136         else //the last section hasn't a close tag (the close tag is just the beginning of next section)
    137         {
    138             //just insert the last section into the map
    139             LogRel(("Add the last section %s to the map \n", strSectionName.c_str()));
    140             mSections.insert(make_pair(strSectionName, sectionConfiguration));
    141         }
    142     }
    143 
    144     return hrc;
    145 }
    146 
    147 HRESULT SimpleConfigFile::addSection(const Utf8Str &aSectionName, const std::map <Utf8Str, Utf8Str>& section)
    148 {
    149     HRESULT hrc = S_OK;
    150     if (aSectionName.isEmpty())
    151         hrc = E_FAIL;
    152     else
    153         mSections.insert(make_pair(aSectionName, section));
    154 
    155     return hrc;
    156 }
    157 
    158 std::vector <Utf8Str> SimpleConfigFile::getSectionsNames() const
    159 {
    160     std::vector <Utf8Str> res;
    161     std::map < Utf8Str, std::map <Utf8Str, Utf8Str> >::const_iterator cit = mSections.begin();
    162     while (cit!=mSections.end())
    163     {
    164         res.push_back(cit->first);
    165         ++cit;
    166     }
    167     return res;
    168 }
    169 
    170 std::map <Utf8Str, Utf8Str> SimpleConfigFile::getSectionByName (const Utf8Str &strSectionName) const
    171 {
    172     std::map <Utf8Str, Utf8Str> res;
    173     std::map < Utf8Str, std::map <Utf8Str, Utf8Str> >::const_iterator cit;
    174     if ( (cit=mSections.find(strSectionName)) != mSections.end() )
    175     {
    176         res=cit->second;
    177     }
    178     return res;
    179 }
    180 
    181 HRESULT SimpleConfigFile::updateSection (const Utf8Str &strSectionName,
    182                                          const std::map <Utf8Str, Utf8Str> &newSection)
    183 {
    184     HRESULT hrc = S_OK;
    185     std::map <Utf8Str, Utf8Str> oldSection = getSectionByName(strSectionName);
    186     if (oldSection.empty())
    187     {
    188         //add new section
    189         hrc = addSection(strSectionName, newSection);
    190     }
    191     else
    192     {
    193         //update old section by new values or add new pair key/value if there isn't such key
    194         std::map <Utf8Str, Utf8Str>::const_iterator cit = newSection.begin();
    195         while (cit != newSection.end())
    196         {
    197             oldSection[cit->first] = cit->second;
    198             ++cit;
    199         }
    200 
    201     }
    202     return hrc;
    203 }
    204 
    205 bool SimpleConfigFile::isSectionExist(const Utf8Str &strSectionName) const
    206 {
    207     return ((mSections.find(strSectionName) == mSections.end()) ? false : true);
    208 }
    209 
    210 ////////////////////////////////////////////////////////////////////////////////
    211 //
    212 // ICloudProvider implementation
    213 //
    214 ////////////////////////////////////////////////////////////////////////////////
    215 CloudProvider::CloudProvider()
    216     : mParent(NULL)
    217 {
    218 }
    219 
    220 CloudProvider::~CloudProvider()
    221 {
    222     LogRel(("CloudProvider::~CloudProvider()\n"));
    223     unconst(mParent) = NULL;
    224 }
    225 
    226 HRESULT CloudProvider::FinalConstruct()
     33OCIProfile::OCIProfile()
     34    : mVirtualBox(NULL), mParent(NULL)
     35{
     36}
     37
     38OCIProfile::~OCIProfile()
     39{
     40    LogRel(("OCIProfile::~OCIProfile()\n"));
     41    unconst(mVirtualBox) = NULL;
     42    unconst(mParent).setNull();
     43}
     44
     45HRESULT OCIProfile::FinalConstruct()
    22746{
    22847    return BaseFinalConstruct();
    22948}
    23049
    231 void CloudProvider::FinalRelease()
     50void OCIProfile::FinalRelease()
    23251{
    23352    uninit();
     
    23655}
    23756
    238 void CloudProvider::uninit()
    239 {
    240     /* Enclose the state transition Ready->InUninit->NotReady */
     57void OCIProfile::uninit()
     58{
     59    // Enclose the state transition Ready->InUninit->NotReady.
    24160    AutoUninitSpan autoUninitSpan(this);
    24261    if (autoUninitSpan.uninitDone())
    24362        return;
    24463
    245     unconst(mParent) = NULL;
    246 }
    247 
    248 HRESULT CloudProvider::init(VirtualBox *aParent)
    249 {
    250     /* Enclose the state transition NotReady->InInit->Ready */
     64    unconst(mVirtualBox) = NULL;
     65    unconst(mParent).setNull();
     66}
     67
     68HRESULT OCIProfile::initFromConfig(VirtualBox *aVirtualBox,
     69                                   OCIProvider *aParent,
     70                                   const com::Utf8Str &aProfileName)
     71{
     72    // Enclose the state transition NotReady->InInit->Ready.
    25173    AutoInitSpan autoInitSpan(this);
    25274    AssertReturn(autoInitSpan.isOk(), E_FAIL);
    253 
     75#ifndef VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK
     76    AssertReturn(aVirtualBox, E_INVALIDARG);
     77#endif
     78    AssertReturn(aParent, E_INVALIDARG);
     79    AssertReturn(!aProfileName.isEmpty(), E_INVALIDARG);
     80
     81    unconst(mVirtualBox) = aVirtualBox;
    25482    unconst(mParent) = aParent;
     83    unconst(mName) = aProfileName;
    25584
    25685    autoInitSpan.setSucceeded();
     
    25887}
    25988
    260 
    261 HRESULT CloudProvider::getSupportedPropertiesNames(std::vector<com::Utf8Str> &aPropertiesNames)
    262 {
    263     LogRel(("CloudProvider::getSupportedPropertiesNames:\n"));
    264     aPropertiesNames.clear();
    265     return setErrorBoth(E_FAIL, VERR_NOT_IMPLEMENTED, tr("Not implemented"));
    266 }
    267 
    268 HRESULT CloudProvider::readProfiles(const Utf8Str &strConfigPath)
    269 {
    270     LogRel(("CloudProvider::readProfiles: %s\n", strConfigPath.c_str()));
    271     return setErrorBoth(E_FAIL, VERR_NOT_IMPLEMENTED, tr("Not implemented"));
    272 }
    273 
    274 HRESULT CloudProvider::getProvider(CloudProviderId_T *aProvider)
    275 {
    276     *aProvider = CloudProviderId_Unknown;
    277     LogRel(("CloudProvider::getProvider: %d\n", *aProvider));
    278     return setErrorBoth(E_FAIL, VERR_NOT_IMPLEMENTED, tr("Not implemented"));
    279 }
    280 
    281 HRESULT CloudProvider::createProfile(const com::Utf8Str &aProfileName,
    282                                             const std::vector<com::Utf8Str> &aNames,
    283                                             const std::vector<com::Utf8Str> &aValues)
    284 {
    285     LogRel(("CloudProvider::createProfile: %s, %d, %d\n", aProfileName.c_str(), aNames.size(), aValues.size()));
    286     return setErrorBoth(E_FAIL, VERR_NOT_IMPLEMENTED, tr("Not implemented"));
    287 }
    288 
    289 HRESULT CloudProvider::updateProfile(const com::Utf8Str &aProfileName,
    290                                             const std::vector<com::Utf8Str> &aNames,
    291                                             const std::vector<com::Utf8Str> &aValues)
    292 {
    293     LogRel(("CloudProvider::updateProfile: %s, %d, %d\n", aProfileName.c_str(), aNames.size(), aValues.size()));
    294     return setErrorBoth(E_FAIL, VERR_NOT_IMPLEMENTED, tr("Not implemented"));
    295 }
    296 
    297 HRESULT CloudProvider::getStoredProfilesNames(std::vector<com::Utf8Str> &aProfilesNames)
    298 {
    299 
    300     LogRel(("CloudProvider::getStoredProfilesNames:\n"));
    301     aProfilesNames.clear();
    302     return setErrorBoth(E_FAIL, VERR_NOT_IMPLEMENTED, tr("Not implemented"));
    303 }
    304 
    305 HRESULT CloudProvider::getProfileProperties(const com::Utf8Str &aProfileName,
    306                                               std::vector<com::Utf8Str> &aReturnNames,
    307                                               std::vector<com::Utf8Str> &aReturnValues)
    308 {
    309     LogRel(("CloudProvider::getProfileProperties: %s\n", aProfileName.c_str()));
    310     aReturnNames.clear();
    311     aReturnValues.clear();
    312     return setErrorBoth(E_FAIL, VERR_NOT_IMPLEMENTED, tr("Not implemented"));
    313 }
    314 
    315 HRESULT CloudProvider::getPropertyDescription(const com::Utf8Str &aName,
    316                                                      com::Utf8Str &aDescription)
    317 {
    318     LogRel(("CloudProvider::getPropertyDescription: %s, %s\n", aName.c_str(), aDescription.c_str()));
    319     return setErrorBoth(E_FAIL, VERR_NOT_IMPLEMENTED, tr("Not implemented"));
    320 }
    321 
    322 HRESULT CloudProvider::createCloudClient(const com::Utf8Str &aProfileName,
    323                                                 ComPtr<ICloudClient> &aCloudClient)
    324 {
    325     LogRel(("CloudProvider::createCloudClient: %s\n", aProfileName.c_str()));
    326 
    327     if (aCloudClient.isNull())
    328     {
    329         LogRel(("aCloudClient is NULL\n"));
    330     }
    331 
    332     return setErrorBoth(E_FAIL, VERR_NOT_IMPLEMENTED, tr("Not implemented"));
    333 }
    334 
    335 ////////////////////////////////////////////////////////////////////////////////
    336 //
    337 // CloudConnectionOCI implementation
    338 //
    339 ////////////////////////////////////////////////////////////////////////////////
     89HRESULT OCIProfile::initNew(VirtualBox *aVirtualBox,
     90                            OCIProvider *aParent,
     91                            const com::Utf8Str &aProfileName,
     92                            const std::vector<com::Utf8Str> &aNames,
     93                            const std::vector<com::Utf8Str> &aValues)
     94{
     95    // Enclose the state transition NotReady->InInit->Ready.
     96    AutoInitSpan autoInitSpan(this);
     97    AssertReturn(autoInitSpan.isOk(), E_FAIL);
     98#ifndef VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK
     99    AssertReturn(aVirtualBox, E_INVALIDARG);
     100#endif
     101    AssertReturn(aParent, E_INVALIDARG);
     102    AssertReturn(!aProfileName.isEmpty(), E_INVALIDARG);
     103
     104    unconst(mVirtualBox) = aVirtualBox;
     105    unconst(mParent) = aParent;
     106    unconst(mName) = aProfileName;
     107
     108    HRESULT hrc = S_OK;
     109    if (!aParent->i_existsProfile(aProfileName))
     110        hrc = aParent->i_addProfile(aProfileName, aNames, aValues);
     111    else
     112        hrc = setError(E_FAIL, tr("Profile '%s' already exists"), aProfileName.c_str());
     113
     114    if (SUCCEEDED(hrc))
     115        autoInitSpan.setSucceeded();
     116    return hrc;
     117}
     118
     119void OCIProfile::i_getProfile(StringMap &aProfile) const
     120{
     121    AutoCaller autoCaller(mParent);
     122    if (FAILED(autoCaller.rc()))
     123        return;
     124    AutoReadLock plock(mParent COMMA_LOCKVAL_SRC_POS);
     125
     126    mParent->i_getProfileMap(mName, aProfile);
     127}
     128
     129
    340130static struct
    341131{
     
    355145
    356146
    357 OCIUserProfiles::OCIUserProfiles()
    358 {
    359     LogRel(("OCIUserProfiles::OCIUserProfiles()\n"));
    360     mpProfiles = new SimpleConfigFile(mParent);
    361     LogRel(("Succeeded create SimpleConfigFile\n"));
    362 }
    363 
    364 OCIUserProfiles::~OCIUserProfiles()
    365 {
    366     LogRel(("OCIUserProfiles::~OCIUserProfiles()\n"));
    367     if (mpProfiles)
    368         delete mpProfiles;
    369 }
    370 
    371 HRESULT OCIUserProfiles::createCloudClient(const com::Utf8Str &aProfileName,
    372                                               ComPtr<ICloudClient> &aCloudClient)
    373 {
    374     HRESULT hrc = S_OK;
    375     CloudProviderId_T providerId;
    376     hrc = getProvider(&providerId);
    377 
    378     ComObjPtr<CloudClient> ptrCloudClient;
    379     hrc = ptrCloudClient.createObject();
    380     if (SUCCEEDED(hrc))
    381     {
    382         ComObjPtr<CloudClientOCI> ptrCloudClientOCI;
    383         hrc = ptrCloudClientOCI.createObject();
    384         AutoReadLock wlock(this COMMA_LOCKVAL_SRC_POS);
    385         hrc = ptrCloudClientOCI->initCloudClient(this, mParent, providerId, aProfileName);
    386         if (SUCCEEDED(hrc))
    387         {
    388             ptrCloudClient = ptrCloudClientOCI;
    389             hrc = ptrCloudClient.queryInterfaceTo(aCloudClient.asOutParam());
    390         }
    391     }
    392 
    393     return hrc;
    394 }
    395 
    396 HRESULT OCIUserProfiles::readProfiles(const Utf8Str &strConfigPath)
    397 {
    398     LogRel(("Reading profiles from %s\n", strConfigPath.c_str()));
    399     HRESULT hrc = S_OK;
    400     if ( !strConfigPath.isEmpty() )
    401     {
    402         mStrConfigPath = strConfigPath;
    403         hrc = mpProfiles->read(mStrConfigPath);
    404         if (SUCCEEDED(hrc))
    405         {
    406             LogRel(("Successfully read the profiles from the config %s\n", mStrConfigPath.c_str()));
    407             hrc = mpProfiles->parse();
    408             if (FAILED(hrc))
    409             {
    410                 return hrc;
    411             }
    412             LogRel(("Successfully parsed %d profiles\n", mpProfiles->getNumberOfSections()));
    413         }
    414     }
    415     else
    416     {
    417         LogRel(("Empty path to config file\n"));
    418         hrc = setErrorBoth(E_FAIL, VERR_INVALID_PARAMETER, tr("Empty path to config file"));
    419     }
    420 
    421     return hrc;
    422 }
    423 
    424 HRESULT OCIUserProfiles::createProfile(const com::Utf8Str &aProfileName,
    425                                           const std::vector<com::Utf8Str> &aNames,
    426                                           const std::vector<com::Utf8Str> &aValues)
    427 {
    428     HRESULT hrc = S_OK;
    429 
    430     if (!mpProfiles->isSectionExist(aProfileName))
    431     {
    432         std::map <Utf8Str, Utf8Str> newProfile;
    433 
    434         for (size_t i=0;i<aNames.size();++i)
    435         {
    436             com::Utf8Str newValue = (i<aValues.size()) ? aValues.at(i) : "";
    437             newProfile[aNames.at(i)] = newValue;
    438         }
    439 
    440         hrc = mpProfiles->addSection(aProfileName, newProfile);
    441     }
    442     else
    443         hrc = setErrorBoth(E_FAIL, VERR_ALREADY_EXISTS, tr("Profile '%s' has already exested"), aProfileName.c_str());
    444 
    445     return hrc;
    446 }
    447 
    448 HRESULT OCIUserProfiles::updateProfile(const com::Utf8Str &aProfileName,
    449                                           const std::vector<com::Utf8Str> &aNames,
    450                                           const std::vector<com::Utf8Str> &aValues)
    451 {
    452     HRESULT hrc = S_OK;
    453     if (mpProfiles->isSectionExist(aProfileName))
    454     {
    455         std::map <Utf8Str, Utf8Str> newProfile;
    456 
    457         for (size_t i=0;i<aNames.size();++i)
    458         {
    459             com::Utf8Str newValue = (i<aValues.size()) ? aValues.at(i) : "";
    460             newProfile[aNames.at(i)] = newValue;
    461         }
    462 
    463         hrc = mpProfiles->updateSection(aProfileName, newProfile);
    464     }
    465     else
    466         hrc = setErrorBoth(E_FAIL, VERR_NOT_FOUND, tr("Profile '%s' wasn't found"), aProfileName.c_str());
    467 
    468     return hrc;
    469 }
    470 
    471 HRESULT OCIUserProfiles::getStoredProfilesNames(std::vector<com::Utf8Str> &aProfilesNames)
    472 {
    473     HRESULT hrc = S_OK;
    474     aProfilesNames = mpProfiles->getSectionsNames();
    475     if (aProfilesNames.empty())
    476         hrc = setErrorBoth(E_FAIL, VERR_NOT_FOUND, tr("There aren't any profiles in the config"));
    477 
    478     return hrc;
    479 }
    480 
    481 HRESULT OCIUserProfiles::getProfileProperties(const com::Utf8Str &aProfileName,
    482                                                  std::vector<com::Utf8Str> &aReturnNames,
    483                                                  std::vector<com::Utf8Str> &aReturnValues)
    484 {
    485     HRESULT hrc = S_OK;
    486 
    487     if (mpProfiles->isSectionExist(aProfileName))
    488     {
    489         std::map <Utf8Str, Utf8Str> profile;
    490         hrc = i_getProfileProperties(aProfileName, profile);
    491         if (SUCCEEDED(hrc))
    492         {
    493             aReturnNames.clear();
    494             aReturnValues.clear();
    495             std::map <Utf8Str, Utf8Str>::const_iterator cit = profile.begin();
    496             while (cit!=profile.end())
    497             {
    498                 aReturnNames.push_back(cit->first);
    499                 aReturnValues.push_back(cit->second);
    500                 ++cit;
    501             }
    502         }
    503     }
    504     else
    505         hrc = setErrorBoth(E_FAIL, VERR_NOT_FOUND, tr("Profile '%s' wasn't found"), aProfileName.c_str());
    506 
    507     return hrc;
    508 }
    509 
    510 HRESULT OCIUserProfiles::getSupportedPropertiesNames(std::vector<com::Utf8Str> &aPropertiesNames)
    511 {
    512     HRESULT hrc = S_OK;
     147HRESULT OCIProfile::getName(com::Utf8Str &aName)
     148{
     149    // mName is constant during life time, no need to lock.
     150    aName = mName;
     151    return S_OK;
     152}
     153
     154HRESULT OCIProfile::getProviderId(com::Guid &aProviderId)
     155{
     156    // provider id is constant during life time, no need to lock.
     157    aProviderId = mParent->i_getId();
     158    return S_OK;
     159}
     160
     161HRESULT OCIProfile::getSupportedPropertyNames(std::vector<com::Utf8Str> &aSupportedPropertyNames)
     162{
     163    // g_aOCIConfigEntryToDescription is constant during life time, no need to lock.
    513164    for (size_t i = 0; i < RT_ELEMENTS(g_aOCIConfigEntryToDescription); ++i)
    514         aPropertiesNames.push_back(g_aOCIConfigEntryToDescription[i].pszOCIConfigEntry);
    515     return hrc;
    516 }
    517 
    518 HRESULT OCIUserProfiles::getPropertyDescription(const com::Utf8Str &aName, com::Utf8Str &aDescription)
    519 {
    520     HRESULT hrc = S_OK;
     165        aSupportedPropertyNames.push_back(g_aOCIConfigEntryToDescription[i].pszOCIConfigEntry);
     166    return S_OK;
     167}
     168
     169HRESULT OCIProfile::getProperty(const com::Utf8Str &aName,
     170                                Utf8Str &aReturnValue)
     171{
     172    AutoCaller autoCaller(mParent);
     173    if (FAILED(autoCaller.rc()))
     174        return autoCaller.rc();
     175    AutoReadLock alock(mParent COMMA_LOCKVAL_SRC_POS);
     176    mParent->i_getProfileProperty(mName, aName, aReturnValue);
     177    return S_OK;
     178}
     179
     180HRESULT OCIProfile::setProperty(const com::Utf8Str &aName,
     181                                const com::Utf8Str &aValue)
     182{
     183    AutoCaller autoCaller(mParent);
     184    if (FAILED(autoCaller.rc()))
     185        return autoCaller.rc();
     186    AutoWriteLock alock(mParent COMMA_LOCKVAL_SRC_POS);
     187    mParent->i_updateProfileProperty(mName, aName, aValue);
     188    return S_OK;
     189}
     190
     191HRESULT OCIProfile::getProperties(const com::Utf8Str &aNames,
     192                                  std::vector<com::Utf8Str> &aReturnNames,
     193                                  std::vector<com::Utf8Str> &aReturnValues)
     194{
     195    AutoCaller autoCaller(mParent);
     196    if (FAILED(autoCaller.rc()))
     197        return autoCaller.rc();
     198    AutoReadLock alock(mParent COMMA_LOCKVAL_SRC_POS);
     199    /// @todo: implement name filtering (everywhere... lots of similar code in many places handling properties. */
     200    RT_NOREF(aNames);
     201    mParent->i_getProfile(mName, aReturnNames, aReturnValues);
     202    return S_OK;
     203}
     204
     205HRESULT OCIProfile::setProperties(const std::vector<com::Utf8Str> &aNames,
     206                                  const std::vector<com::Utf8Str> &aValues)
     207{
     208    AutoCaller autoCaller(mParent);
     209    if (FAILED(autoCaller.rc()))
     210        return autoCaller.rc();
     211    AutoWriteLock alock(mParent COMMA_LOCKVAL_SRC_POS);
     212    return mParent->i_updateProfile(mName, aNames, aValues);
     213}
     214
     215HRESULT OCIProfile::getPropertyDescription(const com::Utf8Str &aName, com::Utf8Str &aDescription)
     216{
     217    // g_aOCIConfigEntryToDescription is constant during life time, no need to lock.
    521218    for (size_t i = 0; i < RT_ELEMENTS(g_aOCIConfigEntryToDescription); ++i)
    522219        if (aName.contains(g_aOCIConfigEntryToDescription[i].pszOCIConfigEntry, Utf8Str::CaseInsensitive))
     
    524221            aDescription = g_aOCIConfigEntryToDescription[i].pszDesciption;
    525222        }
     223    return S_OK;
     224}
     225
     226
     227HRESULT OCIProfile::createCloudClient(ComPtr<ICloudClient> &aCloudClient)
     228{
     229    ComObjPtr<CloudClientOCI> pCloudClientOCI;
     230    HRESULT hrc = pCloudClientOCI.createObject();
     231    if (FAILED(hrc))
     232        return hrc;
     233    hrc = pCloudClientOCI->initCloudClient(mVirtualBox, this);
     234    if (SUCCEEDED(hrc))
     235        hrc = pCloudClientOCI.queryInterfaceTo(aCloudClient.asOutParam());
     236
    526237    return hrc;
    527238}
    528 
    529 
    530 HRESULT OCIUserProfiles::i_createProfile(const com::Utf8Str &aProfileName,
    531                                            const std::map <Utf8Str, Utf8Str> &aProfile)
    532 {
    533     HRESULT hrc = S_OK;
    534 
    535     hrc = mpProfiles->addSection(aProfileName, aProfile);
    536 
    537     return hrc;
    538 }
    539 
    540 HRESULT OCIUserProfiles::i_updateProfile(const com::Utf8Str &aProfileName,
    541                                            const std::map <Utf8Str, Utf8Str> &aProfile)
    542 {
    543     HRESULT hrc = S_OK;
    544     if (mpProfiles->isSectionExist(aProfileName))
    545         hrc = mpProfiles->updateSection(aProfileName, aProfile);
    546     else
    547         hrc = setErrorBoth(E_FAIL, VERR_NOT_FOUND, tr("Profile '%s' wasn't found"), aProfileName.c_str());
    548 
    549 
    550     return hrc;
    551 }
    552 
    553 HRESULT OCIUserProfiles::i_getProfileProperties(const com::Utf8Str &aProfileName,
    554                                                   std::map <Utf8Str, Utf8Str> &aProfile)
    555 {
    556     HRESULT hrc = S_OK;
    557     std::map <Utf8Str, Utf8Str> defProfile = mpProfiles->getSectionByName("DEFAULT");
    558     std::map <Utf8Str, Utf8Str> reqProfile = mpProfiles->getSectionByName(aProfileName);
    559 
    560     std::map <Utf8Str, Utf8Str>::iterator itDefProfile = defProfile.begin();
    561     while (itDefProfile != defProfile.end())
    562     {
    563         std::map <Utf8Str, Utf8Str>::iterator itProfile = reqProfile.find(itDefProfile->first);
    564         if (itProfile == reqProfile.end())
    565         {
    566             //Add a key=value pair from defProfile into the reqProfile if the key doesn't exist in the reqProfile.
    567             reqProfile.insert(*itDefProfile);
    568         }
    569         ++itDefProfile;
    570     }
    571 
    572     if (!reqProfile.empty())
    573         aProfile = reqProfile;
    574     else
    575         hrc = setErrorBoth(E_FAIL, VERR_NOT_FOUND, tr("Profile '%s' wasn't found"), aProfileName.c_str());
    576 
    577     return hrc;
    578 }
    579 
  • trunk/src/VBox/Main/src-server/UnattendedScript.cpp

    r73505 r73716  
    196196    return hrc;
    197197}
     198
     199#ifdef VBOX_WITH_UNATTENDED
    198200
    199201//////////////////////////////////////////////////////////////////////////////////////////////////////
     
    636638}
    637639
     640#endif /* VBOX_WITH_UNATTENDED */
     641
    638642
    639643//////////////////////////////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp

    r73571 r73716  
    8080#include "Logging.h"
    8181
    82 # include "CloudUserProfileManagerImpl.h"
     82# include "CloudProviderManagerImpl.h"
    8383
    8484#include <QMTranslator.h>
     
    300300#endif
    301301
     302    /** The reference to the cloud provider manager singleton. */
     303    const ComObjPtr<CloudProviderManager> pCloudProviderManager;
     304
    302305    /** The global autostart database for the user. */
    303306    AutostartDb * const                 pAutostartDb;
     
    472475
    473476        /* create the system properties object, someone may need it too */
    474         unconst(m->pSystemProperties).createObject();
    475         rc = m->pSystemProperties->init(this);
     477        rc = unconst(m->pSystemProperties).createObject();
     478        if (SUCCEEDED(rc))
     479            rc = m->pSystemProperties->init(this);
    476480        ComAssertComRCThrowRC(rc);
    477481
     
    545549        if (SUCCEEDED(rc = unconst(m->pEventSource).createObject()))
    546550            rc = m->pEventSource->init();
     551        if (FAILED(rc)) throw rc;
     552
     553        /* cloud provider manager */
     554        rc = unconst(m->pCloudProviderManager).createObject();
     555        if (SUCCEEDED(rc))
     556            rc = m->pCloudProviderManager->init(this);
     557        ComAssertComRCThrowRC(rc);
    547558        if (FAILED(rc)) throw rc;
    548559    }
     
    807818     * uninitializing (as for example, mSystemProperties which owns
    808819     * MediumFormat objects which Medium objects refer to) */
     820    if (m->pCloudProviderManager)
     821    {
     822        m->pCloudProviderManager->uninit();
     823        unconst(m->pCloudProviderManager).setNull();
     824    }
     825
    809826    if (m->pSystemProperties)
    810827    {
     
    826843    }
    827844#endif /* VBOX_WITH_RESOURCE_USAGE_API */
     845
     846#ifdef VBOX_WITH_EXTPACK
     847    if (m->ptrExtPackManager)
     848    {
     849        m->ptrExtPackManager->uninit();
     850        unconst(m->ptrExtPackManager).setNull();
     851    }
     852#endif
    828853
    829854    LogFlowThisFunc(("Terminating the async event handler...\n"));
     
    12351260
    12361261    return S_OK;
     1262}
     1263
     1264HRESULT VirtualBox::getCloudProviderManager(ComPtr<ICloudProviderManager> &aCloudProviderManager)
     1265{
     1266    HRESULT hrc = m->pCloudProviderManager.queryInterfaceTo(aCloudProviderManager.asOutParam());
     1267    return hrc;
    12371268}
    12381269
     
    18201851}
    18211852
    1822 HRESULT VirtualBox::createCloudProviderManager(ComPtr<ICloudProviderManager> &aManager)
    1823 {
    1824     ComObjPtr<CloudProviderManager> ptrCloudProviderManager;
    1825     HRESULT hrc = ptrCloudProviderManager.createObject();
    1826     if (SUCCEEDED(hrc))
    1827     {
    1828         AutoReadLock wlock(this COMMA_LOCKVAL_SRC_POS);
    1829         hrc = ptrCloudProviderManager->init(this);
    1830         if (SUCCEEDED(hrc))
    1831             hrc = ptrCloudProviderManager.queryInterfaceTo(aManager.asOutParam());
    1832     }
    1833     return hrc;
    1834 }
    1835 
    18361853HRESULT VirtualBox::createMedium(const com::Utf8Str &aFormat,
    18371854                                 const com::Utf8Str &aLocation,
     
    51975214    return rc;
    51985215#else
    5199     NOREF(aName);
    5200     NOREF(aNatNetwork);
     5216    NOREF(aNetworkName);
     5217    NOREF(aNetwork);
    52015218    return E_NOTIMPL;
    52025219#endif
     
    52335250    return rc;
    52345251#else
    5235     NOREF(aName);
    52365252    NOREF(aNetworkName);
     5253    NOREF(aNetwork);
    52375254    return E_NOTIMPL;
    52385255#endif
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