VirtualBox

Changeset 73549 in vbox for trunk/src


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

CloudProviderManager: Sketched how to put the cloud stuff in the extension pack by using pfnQueryObject. To keep it simple, ICloudProviderManager is duplicated in each extpack and the main implementation just aggregate the results. bugref:9152

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/CloudUserProfileManagerImpl.h

    r73337 r73549  
    4141private:
    4242    ComPtr<VirtualBox> const mParent;       /**< Strong reference to the parent object (VirtualBox/IMachine). */
     43#ifdef CLOUD_PROVIDERS_IN_EXTPACK
     44    std::vector<ComPtr<ICloudUserProfileManager>> mUserProfileManagers;
     45#else
    4346    std::vector<CloudProviderId_T> mSupportedProviders;
     47#endif
    4448
    4549    HRESULT getSupportedProviders(std::vector<CloudProviderId_T> &aProviderTypes);
  • trunk/src/VBox/Main/src-server/CloudUserProfileManagerImpl.cpp

    r73337 r73549  
    2525#include "CloudUserProfilesImpl.h"
    2626#include "VirtualBoxImpl.h"
     27#include "ExtPackManagerImpl.h"
    2728#include "Global.h"
    2829#include "ProgressImpl.h"
     
    6768
    6869    unconst(mParent) = aParent;
     70
     71#ifdef CLOUD_PROVIDERS_IN_EXTPACK
     72    /*
     73     * Engage the extension pack manager and get all the implementations of this class.
     74     */
     75    ExtPackManager *pExtPackMgr = aParent->i_getExtPackManager();
     76    std::vector<ComPtr<IUnknown> > Objects;
     77    com::Guid idObj(COM_IIDOF(ICloudUserProfileManager));
     78    pExtPackMgr->i_queryObjects(idObj.toString(), Objects);
     79    for (unsigned i = 0; i < Objects.size(); i++)
     80    {
     81        ComPtr<ICloudUserProfileManager> ptrTmp;
     82        HRESULT hrc = Objects[i].queryInterfaceTo(ptrTmp.asOutParam());
     83        if (SUCCEEDED(hrc))
     84            mUserProfileManagers.push_back(ptrTmp);
     85    }
     86#else
     87
    6988    mSupportedProviders.clear();
    7089    mSupportedProviders.push_back(CloudProviderId_OCI);
     90#endif
    7191
    7292    autoInitSpan.setSucceeded();
     
    86106HRESULT CloudUserProfileManager::getSupportedProviders(std::vector<CloudProviderId_T> &aSupportedProviders)
    87107{
     108#ifdef CLOUD_PROVIDERS_IN_EXTPACK
     109    /*
     110     * Collect all the provider names from all the extension pack objects.
     111     */
     112    HRESULT hrc = S_OK;
     113    for (unsigned i = 0; i < mUserProfileManagers.size(); i++)
     114    {
     115        SafeArray<CloudProviderId_T> FromCurrent;
     116        HRESULT hrc2 = mUserProfileManagers[i]->COMGETTER(SupportedProviders)(ComSafeArrayAsOutParam(FromCurrent));
     117        if (SUCCEEDED(hrc2))
     118            for (size_t i = 0; i < FromCurrent.size(); i++)
     119                aSupportedProviders.push_back(FromCurrent[i]);
     120        else if (SUCCEEDED(hrc))
     121            hrc = hrc2;
     122    }
     123    if (aSupportedProviders.size() > 0)
     124        hrc = S_OK;
     125    return hrc;
     126#else
    88127    aSupportedProviders = mSupportedProviders;
    89128    return S_OK;
     129#endif
    90130}
    91131
    92132HRESULT CloudUserProfileManager::getAllProfiles(std::vector<ComPtr<ICloudUserProfiles> > &aProfilesList)
    93133{
     134#ifdef CLOUD_PROVIDERS_IN_EXTPACK
     135    /*
     136     * Collect all the cloud providers from all the extension pack objects.
     137     */
     138    HRESULT hrc = S_OK;
     139    for (unsigned i = 0; i < mUserProfileManagers.size(); i++)
     140    {
     141        SafeIfaceArray<ICloudUserProfiles> FromCurrent;
     142        HRESULT hrc2 = mUserProfileManagers[i]->GetAllProfiles(ComSafeArrayAsOutParam(FromCurrent));
     143        if (SUCCEEDED(hrc2))
     144            for (size_t i = 0; i < FromCurrent.size(); i++)
     145                aProfilesList.push_back(FromCurrent[i]);
     146        else if (SUCCEEDED(hrc))
     147            hrc = hrc2;
     148    }
     149    if (aProfilesList.size() > 0)
     150        hrc = S_OK;
     151    return hrc;
     152
     153#else
    94154    HRESULT hrc = S_OK;
    95155    std::vector<ComPtr<ICloudUserProfiles> > lProfilesList;
     
    108168
    109169    return hrc;
     170#endif
    110171}
    111172
     
    113174                                                       ComPtr<ICloudUserProfiles> &aProfiles)
    114175{
     176#ifdef CLOUD_PROVIDERS_IN_EXTPACK
     177    /*
     178     * Return the first provider we get.
     179     */
     180    HRESULT hrc = VBOX_E_OBJECT_NOT_FOUND;
     181    for (unsigned i = 0; i < mUserProfileManagers.size(); i++)
     182    {
     183        hrc = mUserProfileManagers[i]->GetProfilesByProvider(aProviderType, aProfiles.asOutParam());
     184        if (SUCCEEDED(hrc))
     185            break;
     186    }
     187    return hrc;
     188
     189#else
     190
    115191    ComObjPtr<CloudUserProfiles> ptrCloudUserProfiles;
    116192    HRESULT hrc = ptrCloudUserProfiles.createObject();
     
    158234
    159235    return hrc;
    160 }
    161 
     236#endif
     237}
     238
Note: See TracChangeset for help on using the changeset viewer.

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