Changeset 73716 in vbox
- Timestamp:
- Aug 16, 2018 3:58:57 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 124395
- Location:
- trunk
- Files:
-
- 1 deleted
- 18 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/log.h
r73571 r73716 362 362 /** Main group, ICloudClient. */ 363 363 LOG_GROUP_MAIN_CLOUDCLIENT, 364 /** Main group, ICloudProfile. */ 365 LOG_GROUP_MAIN_CLOUDPROFILE, 364 366 /** Main group, ICloudProvider. */ 365 367 LOG_GROUP_MAIN_CLOUDPROVIDER, … … 998 1000 "MAIN_CLIPBOARDMODECHANGEDEVENT", \ 999 1001 "MAIN_CLOUDCLIENT", \ 1002 "MAIN_CLOUDPROFILE", \ 1000 1003 "MAIN_CLOUDPROVIDER", \ 1001 1004 "MAIN_CLOUDPROVIDERMANAGER", \ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r73029 r73716 1380 1380 fFirst ? "Property: " : " ", 1381 1381 names[i], value.raw()); 1382 fFirst = false; 1382 1383 } 1383 1384 } -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r73664 r73716 449 449 " hostinfo|hostcpuids|hddbackends|hdds|dvds|floppies|\n" 450 450 " usbhost|usbfilters|systemproperties|extpacks|\n" 451 " groups|webcams|screenshotformats\n" 451 " groups|webcams|screenshotformats|cloudproviders|\n" 452 " cloudprofiles\n" 452 453 "\n", SEP); 453 454 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp
r72976 r73716 900 900 } 901 901 902 /** 903 * List available cloud providers. 904 * 905 * @returns See produceList. 906 * @param pVirtualBox Reference to the IVirtualBox pointer. 907 */ 908 static 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 */ 942 static 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 902 991 903 992 /** … … 931 1020 kListNatNetworks, 932 1021 kListVideoInputDevices, 933 kListScreenShotFormats 1022 kListScreenShotFormats, 1023 kListCloudProviders, 1024 kListCloudProfiles, 934 1025 }; 935 1026 … … 1297 1388 break; 1298 1389 1390 case kListCloudProviders: 1391 rc = listCloudProviders(pVirtualBox); 1392 break; 1393 1394 case kListCloudProfiles: 1395 rc = listCloudProfiles(pVirtualBox, fOptLong); 1396 break; 1397 1299 1398 /* No default here, want gcc warnings. */ 1300 1399 … … 1349 1448 { "webcams", kListVideoInputDevices, RTGETOPT_REQ_NOTHING }, 1350 1449 { "screenshotformats", kListScreenShotFormats, RTGETOPT_REQ_NOTHING }, 1450 { "cloudproviders", kListCloudProviders, RTGETOPT_REQ_NOTHING }, 1451 { "cloudprofiles", kListCloudProfiles, RTGETOPT_REQ_NOTHING }, 1351 1452 }; 1352 1453 … … 1400 1501 case kListVideoInputDevices: 1401 1502 case kListScreenShotFormats: 1503 case kListCloudProviders: 1504 case kListCloudProfiles: 1402 1505 enmOptCommand = (enum enmListType)ch; 1403 1506 if (fOptMultiple) -
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackend.h
r73175 r73716 136 136 template<> SHARED_LIBRARY_STUFF bool canConvert<KChipsetType>(); 137 137 template<> SHARED_LIBRARY_STUFF bool canConvert<KNATProtocol>(); 138 template<> SHARED_LIBRARY_STUFF bool canConvert<KCloudProviderId>();139 138 140 139 … … 254 253 template<> SHARED_LIBRARY_STUFF QString toInternalString(const KNATProtocol &protocol); 255 254 template<> SHARED_LIBRARY_STUFF KNATProtocol fromInternalString<KNATProtocol>(const QString &strProtocol); 256 template<> SHARED_LIBRARY_STUFF QString toInternalString(const KCloudProviderId &enmProvider);257 255 258 256 -
trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendCOM.cpp
r73175 r73716 59 59 template<> bool canConvert<KChipsetType>() { return true; } 60 60 template<> bool canConvert<KNATProtocol>() { return true; } 61 template<> bool canConvert<KCloudProviderId>() { return true; }62 61 63 62 … … 655 654 return values.at(keys.indexOf(QRegExp(strProtocol, Qt::CaseInsensitive))); 656 655 } 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 71 71 /* Init Cloud Provider Manager: */ 72 72 CVirtualBox comVBox = vboxGlobal().virtualBox(); 73 m_comCloudProviderManager = comVBox. CreateCloudProviderManager();73 m_comCloudProviderManager = comVBox.GetCloudProviderManager(); 74 74 AssertMsg(comVBox.isOk() && m_comCloudProviderManager.isNotNull(), 75 75 ("Unable to acquire Cloud Provider Manager")); … … 117 117 AssertReturnVoid(m_pAccountComboBox->count() == 0); 118 118 119 /* Acquire provider IDlist: */120 QVector< QString> providerIds = m_comCloudProviderManager.GetSupportedProviders();119 /* Acquire provider list: */ 120 QVector<CCloudProvider> comProviders = m_comCloudProviderManager.GetProviders(); 121 121 /* 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 { 129 127 /* Skip if we have nothing to populate (file missing?): */ 130 128 if (comProvider.isNull()) 131 129 continue; 130 QString strProviderId = comProvider.GetId(); 131 QString strProviderShortName = comProvider.GetShortName(); 132 132 133 133 /* Iterate through profile names: */ 134 foreach (const QString &strProfileName, comProvider.Get StoredProfilesNames())134 foreach (const QString &strProfileName, comProvider.GetProfileNames()) 135 135 { 136 136 m_pAccountComboBox->addItem(QString()); 137 137 m_pAccountComboBox->setItemData(m_pAccountComboBox->count() - 1, strProviderId, ProviderID); 138 m_pAccountComboBox->setItemData(m_pAccountComboBox->count() - 1, strProviderShortName, ProviderName); 138 139 m_pAccountComboBox->setItemData(m_pAccountComboBox->count() - 1, strProfileName, ProfileName); 139 140 } … … 142 143 /* Set default: */ 143 144 if (m_pAccountComboBox->count() != 0) 144 setProviderById(" OCI");145 setProviderById("54e11de4-afcc-47fb-9c39-b24244cfa044"); 145 146 } 146 147 … … 148 149 { 149 150 /* 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()) 153 154 return; 155 156 m_comCloudProfile = comCloudProvider.GetProfileByName(profileName()); 157 /* Return if the profile has disappeared: */ 158 if (m_comCloudProfile.isNull()) 154 159 155 160 /* Clear table initially: */ … … 159 164 QVector<QString> keys; 160 165 QVector<QString> values; 161 values = m_comCloudPro vider.GetProfileProperties(profileName(), keys);166 values = m_comCloudProfile.GetProperties(QString(), keys); 162 167 163 168 /* Configure table: */ … … 177 182 178 183 /* Use non-translated description as tool-tip: */ 179 const QString strToolTip = m_comCloudPro vider.GetPropertyDescription(keys.at(i));184 const QString strToolTip = m_comCloudProfile.GetPropertyDescription(keys.at(i)); 180 185 pItemK->setData(Qt::UserRole, strToolTip); 181 186 … … 434 439 } 435 440 436 CCloudPro vider UIWizardExportAppPage2::provider() const437 { 438 return m_comCloudPro vider;441 CCloudProfile UIWizardExportAppPage2::profile() const 442 { 443 return m_comCloudProfile; 439 444 } 440 445 … … 786 791 for (int i = 0; i < m_pAccountComboBox->count(); ++i) 787 792 { 788 if (m_pAccountComboBox->itemData(i, ProviderID).toString() == " OCI")793 if (m_pAccountComboBox->itemData(i, ProviderID).toString() == "54e11de4-afcc-47fb-9c39-b24244cfa044") 789 794 { 790 795 m_pAccountComboBox->setItemText(i, UIWizardExportApp::tr("Oracle Cloud Infrastructure: %1", "provider: profile") … … 794 799 { 795 800 m_pAccountComboBox->setItemText(i, UIWizardExportApp::tr("%1: %2", "provider: profile") 796 .arg(m_pAccountComboBox->itemData(i, Provider ID).toString())801 .arg(m_pAccountComboBox->itemData(i, ProviderName).toString()) 797 802 .arg(m_pAccountComboBox->itemData(i, ProfileName).toString())); 798 803 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.h
r73580 r73716 27 27 /* COM includes: */ 28 28 #include "COMEnums.h" 29 #include "CCloudProfile.h" 29 30 #include "CCloudProvider.h" 30 31 #include "CCloudProviderManager.h" … … 55 56 enum 56 57 { 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 59 61 }; 60 62 … … 131 133 /** Returns profile name. */ 132 134 QString profileName() const; 133 /** Returns Cloud Pro viderobject. */134 CCloudPro vider provider() const;135 /** Returns Cloud Profile object. */ 136 CCloudProfile profile() const; 135 137 136 138 /** Holds the Cloud Provider Manager reference. */ 137 139 CCloudProviderManager m_comCloudProviderManager; 138 /** Holds the Cloud Pro viderobject reference. */139 CCloudPro vider m_comCloudProvider;140 /** Holds the Cloud Profile object reference. */ 141 CCloudProfile m_comCloudProfile; 140 142 141 143 /** Holds the default appliance name. */ … … 197 199 Q_PROPERTY(bool manifestSelected READ isManifestSelected WRITE setManifestSelected); 198 200 Q_PROPERTY(bool includeISOsSelected READ isIncludeISOsSelected WRITE setIncludeISOsSelected); 199 Q_PROPERTY(CCloudPro vider provider READ provider);201 Q_PROPERTY(CCloudProfile profile READ profile); 200 202 Q_PROPERTY(QString profileName READ profileName); 201 203 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic3.cpp
r73663 r73716 38 38 # include "CAppliance.h" 39 39 # include "CCloudClient.h" 40 # include "CCloudPro vider.h"40 # include "CCloudProfile.h" 41 41 # include "CMachine.h" 42 42 … … 57 57 m_listCloudClientParameters.clear(); 58 58 59 /* Acquire Cloud Pro vider: */60 CCloudPro vider comCloudProvider = fieldImp("provider").value<CCloudProvider>();61 AssertMsgReturnVoid(comCloudPro vider.isNotNull(),62 ("Cloud pro viderobject is undefined!"));59 /* Acquire Cloud Profile: */ 60 CCloudProfile comCloudProfile = fieldImp("profile").value<CCloudProfile>(); 61 AssertMsgReturnVoid(comCloudProfile.isNotNull(), 62 ("Cloud profile object is undefined!")); 63 63 64 64 /* Create Cloud Client: */ 65 CCloudClient comCloudClient = comCloudPro vider.CreateCloudClient(fieldImp("profileName").toString());66 AssertMsgReturnVoid(comCloudPro vider.isOk() && comCloudClient.isNotNull(),65 CCloudClient comCloudClient = comCloudProfile.CreateCloudClient(); 66 AssertMsgReturnVoid(comCloudProfile.isOk() && comCloudClient.isNotNull(), 67 67 ("Can't create Cloud Client object!")); 68 68 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.h
r73580 r73716 41 41 Q_PROPERTY(bool manifestSelected READ isManifestSelected WRITE setManifestSelected); 42 42 Q_PROPERTY(bool includeISOsSelected READ isIncludeISOsSelected WRITE setIncludeISOsSelected); 43 Q_PROPERTY(CCloudPro vider provider READ provider);43 Q_PROPERTY(CCloudProfile profile READ profile); 44 44 Q_PROPERTY(QString profileName READ profileName); 45 45 Q_PROPERTY(ExportAppliancePointer applianceWidget READ applianceWidget); -
trunk/src/VBox/Main/Makefile.kmk
r73551 r73716 456 456 src-server/ClientWatcher.cpp \ 457 457 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) \ 462 464 src-server/DHCPServerImpl.cpp \ 463 465 src-server/NetworkServiceRunner.cpp \ -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r73664 r73716 1954 1954 <interface 1955 1955 name="IVirtualBox" extends="$unknown" 1956 uuid=" 9570b9d5-f1a1-448a-10c5-e12f5285adad"1956 uuid="176b85cd-4bc2-453e-9228-f408c5282267" 1957 1957 wsmap="managed" 1958 1958 reservedMethods="7" reservedAttributes="12" … … 2165 2165 </attribute> 2166 2166 2167 <attribute name="cloudProviderManager" type="ICloudProviderManager" readonly="yes"> 2168 <desc> 2169 The cloud provider manager (singleton). 2170 </desc> 2171 </attribute> 2172 2167 2173 <method name="composeMachineFilename"> 2168 2174 <desc> … … 2448 2454 <param name="unattended" type="IUnattended" dir="return"> 2449 2455 <desc>New unattended object.</desc> 2450 </param>2451 </method>2452 2453 <method name="createCloudProviderManager">2454 <desc>2455 Creates a new cloud provider manager object2456 </desc>2457 <param name="manager" type="ICloudProviderManager" dir="return">2458 <desc>New cloud user profile manager</desc>2459 2456 </param> 2460 2457 </method> … … 24865 24862 24866 24863 <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 <enum24880 24864 name="CloudCommand" 24881 24865 uuid="1c5cfa19-7754-4071-bf3e-6d21ad432655" … … 25110 25094 25111 25095 <!-- 25112 // ICloudPro vider25096 // ICloudProfile 25113 25097 ////////////////////////////////////////////////////////////////////////// 25114 25098 --> 25115 25099 25116 25100 <interface 25117 name="ICloudPro vider" extends="$unknown"25118 uuid=" cfadfecb-ef89-41a9-abbd-9772d41baddb"25101 name="ICloudProfile" extends="$unknown" 25102 uuid="011d1e9a-a48b-4d15-91a0-6101b087155c" 25119 25103 wsmap="managed" reservedMethods="4" reservedAttributes="4" 25120 25104 > 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> 25177 25167 25178 25168 The method returns two arrays, the array of property names corresponding … … 25181 25171 given index in the first array corresponds to an element at the same 25182 25172 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. 25191 25177 </desc> 25192 25178 </param> … … 25199 25185 </method> 25200 25186 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. --> 25201 25219 <method name="getPropertyDescription" const="yes"> 25202 25220 <param name="name" type="wstring" dir="in"> 25203 <desc>Property name </desc>25221 <desc>Property name.</desc> 25204 25222 </param> 25205 25223 <param name="description" type="wstring" dir="return"> 25206 <desc>Property description </desc>25224 <desc>Property description.</desc> 25207 25225 </param> 25208 25226 </method> … … 25210 25228 <method name="createCloudClient"> 25211 25229 <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. 25213 25282 </desc> 25214 25283 <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"/> 25221 25299 </method> 25222 25300 … … 25229 25307 <interface 25230 25308 name="ICloudProviderManager" extends="$unknown" 25231 uuid=" 64e276a7-cfd1-48ed-aad3-19368197f3b2"25309 uuid="95533d5b-20ec-4089-b461-f2794c9512df" 25232 25310 wsmap="managed" reservedMethods="4" reservedAttributes="4" 25233 25311 > 25234 25312 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"/> 25257 25330 </method> 25258 25331 25259 25332 </interface> 25333 25260 25334 25261 25335 <module name="VBoxSVC" context="LocalServer"> -
trunk/src/VBox/Main/include/CloudProviderManagerImpl.h
r73710 r73716 5 5 6 6 /* 7 * Copyright (C) 20 06-2018 Oracle Corporation7 * Copyright (C) 2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 18 18 19 #ifndef ____H_CLOUD USERPROFILEMANAGERIMPL20 #define ____H_CLOUD USERPROFILEMANAGERIMPL19 #ifndef ____H_CLOUDPROVIDERMANAGERIMPL 20 #define ____H_CLOUDPROVIDERMANAGERIMPL 21 21 22 /* VBox includes */23 22 #include "CloudProviderManagerWrap.h" 24 #include "CloudUserProfilesImpl.h" 23 #ifdef VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK 24 class ExtPackManager; 25 #endif 25 26 26 /* VBox forward declarations */27 27 28 28 class ATL_NO_VTABLE CloudProviderManager … … 30 30 { 31 31 public: 32 33 32 DECLARE_EMPTY_CTOR_DTOR(CloudProviderManager) 34 33 … … 36 35 void FinalRelease(); 37 36 38 HRESULT init(VirtualBox *a VirtualBox);37 HRESULT init(VirtualBox *aParent); 39 38 void uninit(); 40 39 41 private:42 ComPtr<VirtualBox> const mParent; /**< Strong reference to the parent object (VirtualBox/IMachine). */43 40 #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(); 47 43 #endif 48 44 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); 45 private: 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 55 private: 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; 52 63 }; 53 64 54 #endif // !____H_CLOUDUSERPROFILEMANAGERIMPL 65 #endif // !____H_CLOUDPROVIDERMANAGERIMPL 66 55 67 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ 56 -
trunk/src/VBox/Main/include/ExtPackManagerImpl.h
r73548 r73716 209 209 HRESULT i_doUninstall(const Utf8Str *a_pstrName, bool a_fForcedRemoval, const Utf8Str *a_pstrDisplayInfo); 210 210 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); 212 212 #endif 213 213 #ifdef VBOX_COM_INPROC … … 228 228 bool i_isExtPackUsable(const char *a_pszExtPack); 229 229 void i_dumpAllToReleaseLog(void); 230 uint64_t i_getUpdateCounter(void); 230 231 /** @} */ 231 232 -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r73571 r73716 289 289 HRESULT getInternalNetworks(std::vector<com::Utf8Str> &aInternalNetworks); 290 290 HRESULT getGenericNetworkDrivers(std::vector<com::Utf8Str> &aGenericNetworkDrivers); 291 HRESULT getCloudProviderManager(ComPtr<ICloudProviderManager> &aCloudProviderManager); 291 292 292 293 // wrapped IVirtualBox methods … … 313 314 HRESULT createAppliance(ComPtr<IAppliance> &aAppliance); 314 315 HRESULT createUnattendedInstaller(ComPtr<IUnattended> &aUnattended); 315 HRESULT createCloudProviderManager(ComPtr<ICloudProviderManager> &aManager);316 316 HRESULT createMedium(const com::Utf8Str &aFormat, 317 317 const com::Utf8Str &aLocation, -
trunk/src/VBox/Main/src-all/ExtPackManagerImpl.cpp
r73562 r73716 155 155 struct ExtPackManager::Data 156 156 { 157 Data() 158 : cUpdate(0) 159 {} 160 157 161 /** The directory where the extension packs are installed. */ 158 162 Utf8Str strBaseDir; … … 168 172 /** The current context. */ 169 173 VBOXEXTPACKCTX enmContext; 174 /** Update counter for the installed extension packs, increased in every list update. */ 175 uint64_t cUpdate; 170 176 171 177 RTMEMEF_NEW_AND_DELETE_OPERATORS(); … … 2002 2008 delete pstrName; 2003 2009 if (SUCCEEDED(hrc2)) 2010 { 2004 2011 m->llInstalledExtPacks.push_back(NewExtPack); 2012 /* Paranoia, there should be no API clients before this method is finished. */ 2013 2014 m->cUpdate++; 2015 } 2005 2016 else if (SUCCEEDED(rc)) 2006 2017 hrc = hrc2; … … 2467 2478 { 2468 2479 m->llInstalledExtPacks.erase(it); 2480 m->cUpdate++; 2469 2481 return; 2470 2482 } … … 2582 2594 { 2583 2595 m->llInstalledExtPacks.push_back(ptrNewExtPack); 2596 m->cUpdate++; 2584 2597 if (ptrNewExtPack->m->fUsable) 2585 2598 LogRel(("ExtPackManager: Found extension pack '%s'.\n", a_pszName)); … … 2901 2914 * @param aObjUuid The UUID of the kind of objects we're querying. 2902 2915 * @param aObjects Where to return the objects. 2916 * @param a_pstrExtPackNames Where to return the corresponding extpack names (may be NULL). 2903 2917 * 2904 2918 * @remarks The caller must not hold any locks. 2905 2919 */ 2906 HRESULT ExtPackManager::i_queryObjects(const com::Utf8Str &aObjUuid, std::vector<ComPtr<IUnknown> > &aObjects )2920 HRESULT ExtPackManager::i_queryObjects(const com::Utf8Str &aObjUuid, std::vector<ComPtr<IUnknown> > &aObjects, std::vector<com::Utf8Str> *a_pstrExtPackNames) 2907 2921 { 2908 2922 aObjects.clear(); 2923 if (a_pstrExtPackNames) 2924 a_pstrExtPackNames->clear(); 2909 2925 2910 2926 AutoCaller autoCaller(this); … … 2922 2938 HRESULT hrc2 = (*it)->queryObject(aObjUuid, ptrIf); 2923 2939 if (SUCCEEDED(hrc2)) 2940 { 2924 2941 aObjects.push_back(ptrIf); 2942 if (a_pstrExtPackNames) 2943 a_pstrExtPackNames->push_back((*it)->m->Desc.strName); 2944 } 2925 2945 else if (hrc2 != E_NOINTERFACE) 2926 2946 hrc = hrc2; … … 3243 3263 } 3244 3264 3265 /** 3266 * Gets the update counter (reflecting extpack list updates). 3267 */ 3268 uint64_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 3245 3278 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/src-all/ProgressImpl.cpp
r73003 r73716 208 208 unconst(mId).create(); 209 209 210 #if !defined(VBOX_COM_INPROC) 210 #if !defined(VBOX_COM_INPROC) && !defined(VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK) 211 211 /* add to the global collection of progress operations (note: after 212 212 * creating mId) */ … … 327 327 unconst(mInitiator).setNull(); 328 328 329 #if !defined(VBOX_COM_INPROC) 329 #if !defined(VBOX_COM_INPROC) && !defined(VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK) 330 330 if (mParent) 331 331 { … … 471 471 mErrorInfo = aErrorInfo; 472 472 473 #if !defined VBOX_COM_INPROC473 #if !defined(VBOX_COM_INPROC) && !defined(VBOX_WITH_CLOUD_PROVIDERS_IN_EXTPACK) 474 474 /* remove from the global collection of pending progress operations */ 475 475 if (mParent) -
trunk/src/VBox/Main/src-server/CloudProviderManagerImpl.cpp
r73576 r73716 17 17 18 18 19 #include <iprt/path.h>20 #include <iprt/cpp/utils.h>21 19 #include <VBox/com/array.h> 22 #include <map> 23 24 #include "CloudUserProfileManagerImpl.h" 25 #include "CloudUserProfilesImpl.h" 20 26 21 #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 31 28 #include "AutoCaller.h" 32 29 #include "Logging.h" … … 40 37 // //////////////////////////////////////////////////////////////////////////////// 41 38 CloudProviderManager::CloudProviderManager() 42 : mParent(NULL)43 39 { 44 40 } … … 63 59 HRESULT CloudProviderManager::init(VirtualBox *aParent) 64 60 { 65 / * Enclose the state transition NotReady->InInit->Ready */61 // Enclose the state transition NotReady->InInit->Ready. 66 62 AutoInitSpan autoInitSpan(this); 67 63 AssertReturn(autoInitSpan.isOk(), E_FAIL); 68 64 69 unconst(mParent) = aParent;65 m_apCloudProviders.clear(); 70 66 71 67 #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. 75 70 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(); 85 78 } 86 79 #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); 91 88 #endif 92 89 … … 97 94 void CloudProviderManager::uninit() 98 95 { 99 / * Enclose the state transition Ready->InUninit->NotReady */96 // Enclose the state transition Ready->InUninit->NotReady. 100 97 AutoUninitSpan autoUninitSpan(this); 101 98 if (autoUninitSpan.uninitDone()) 102 99 return; 103 104 unconst(mParent) = NULL; 105 } 106 107 HRESULT CloudProviderManager::getSupportedProviders(std::vector<Utf8Str> &aSupportedProviders) 108 { 100 } 101 109 102 #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; 103 void 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 149 HRESULT CloudProviderManager::getProviders(std::vector<ComPtr<ICloudProvider> > &aProviders) 150 { 151 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 152 aProviders = m_apCloudProviders; 129 153 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 156 HRESULT 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 174 HRESULT 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 192 HRESULT 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 1 1 /* $Id$ */ 2 2 /** @file 3 * ICloudPro vider COM class implementations.3 * ICloudProfile COM class implementation (OCI). 4 4 */ 5 5 … … 16 16 */ 17 17 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 20 25 #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 32 27 33 28 //////////////////////////////////////////////////////////////////////////////// 34 29 // 35 // SimpleConfigFile implementation30 // OCIProfile implementation 36 31 // 37 32 //////////////////////////////////////////////////////////////////////////////// 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() 33 OCIProfile::OCIProfile() 34 : mVirtualBox(NULL), mParent(NULL) 35 { 36 } 37 38 OCIProfile::~OCIProfile() 39 { 40 LogRel(("OCIProfile::~OCIProfile()\n")); 41 unconst(mVirtualBox) = NULL; 42 unconst(mParent).setNull(); 43 } 44 45 HRESULT OCIProfile::FinalConstruct() 227 46 { 228 47 return BaseFinalConstruct(); 229 48 } 230 49 231 void CloudProvider::FinalRelease()50 void OCIProfile::FinalRelease() 232 51 { 233 52 uninit(); … … 236 55 } 237 56 238 void CloudProvider::uninit()239 { 240 / * Enclose the state transition Ready->InUninit->NotReady */57 void OCIProfile::uninit() 58 { 59 // Enclose the state transition Ready->InUninit->NotReady. 241 60 AutoUninitSpan autoUninitSpan(this); 242 61 if (autoUninitSpan.uninitDone()) 243 62 return; 244 63 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 68 HRESULT OCIProfile::initFromConfig(VirtualBox *aVirtualBox, 69 OCIProvider *aParent, 70 const com::Utf8Str &aProfileName) 71 { 72 // Enclose the state transition NotReady->InInit->Ready. 251 73 AutoInitSpan autoInitSpan(this); 252 74 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; 254 82 unconst(mParent) = aParent; 83 unconst(mName) = aProfileName; 255 84 256 85 autoInitSpan.setSucceeded(); … … 258 87 } 259 88 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 //////////////////////////////////////////////////////////////////////////////// 89 HRESULT 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 119 void 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 340 130 static struct 341 131 { … … 355 145 356 146 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; 147 HRESULT 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 154 HRESULT 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 161 HRESULT OCIProfile::getSupportedPropertyNames(std::vector<com::Utf8Str> &aSupportedPropertyNames) 162 { 163 // g_aOCIConfigEntryToDescription is constant during life time, no need to lock. 513 164 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 169 HRESULT 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 180 HRESULT 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 191 HRESULT 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 205 HRESULT 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 215 HRESULT OCIProfile::getPropertyDescription(const com::Utf8Str &aName, com::Utf8Str &aDescription) 216 { 217 // g_aOCIConfigEntryToDescription is constant during life time, no need to lock. 521 218 for (size_t i = 0; i < RT_ELEMENTS(g_aOCIConfigEntryToDescription); ++i) 522 219 if (aName.contains(g_aOCIConfigEntryToDescription[i].pszOCIConfigEntry, Utf8Str::CaseInsensitive)) … … 524 221 aDescription = g_aOCIConfigEntryToDescription[i].pszDesciption; 525 222 } 223 return S_OK; 224 } 225 226 227 HRESULT 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 526 237 return hrc; 527 238 } 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 else547 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 else575 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 196 196 return hrc; 197 197 } 198 199 #ifdef VBOX_WITH_UNATTENDED 198 200 199 201 ////////////////////////////////////////////////////////////////////////////////////////////////////// … … 636 638 } 637 639 640 #endif /* VBOX_WITH_UNATTENDED */ 641 638 642 639 643 ////////////////////////////////////////////////////////////////////////////////////////////////////// -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r73571 r73716 80 80 #include "Logging.h" 81 81 82 # include "Cloud UserProfileManagerImpl.h"82 # include "CloudProviderManagerImpl.h" 83 83 84 84 #include <QMTranslator.h> … … 300 300 #endif 301 301 302 /** The reference to the cloud provider manager singleton. */ 303 const ComObjPtr<CloudProviderManager> pCloudProviderManager; 304 302 305 /** The global autostart database for the user. */ 303 306 AutostartDb * const pAutostartDb; … … 472 475 473 476 /* 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); 476 480 ComAssertComRCThrowRC(rc); 477 481 … … 545 549 if (SUCCEEDED(rc = unconst(m->pEventSource).createObject())) 546 550 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); 547 558 if (FAILED(rc)) throw rc; 548 559 } … … 807 818 * uninitializing (as for example, mSystemProperties which owns 808 819 * MediumFormat objects which Medium objects refer to) */ 820 if (m->pCloudProviderManager) 821 { 822 m->pCloudProviderManager->uninit(); 823 unconst(m->pCloudProviderManager).setNull(); 824 } 825 809 826 if (m->pSystemProperties) 810 827 { … … 826 843 } 827 844 #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 828 853 829 854 LogFlowThisFunc(("Terminating the async event handler...\n")); … … 1235 1260 1236 1261 return S_OK; 1262 } 1263 1264 HRESULT VirtualBox::getCloudProviderManager(ComPtr<ICloudProviderManager> &aCloudProviderManager) 1265 { 1266 HRESULT hrc = m->pCloudProviderManager.queryInterfaceTo(aCloudProviderManager.asOutParam()); 1267 return hrc; 1237 1268 } 1238 1269 … … 1820 1851 } 1821 1852 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 1836 1853 HRESULT VirtualBox::createMedium(const com::Utf8Str &aFormat, 1837 1854 const com::Utf8Str &aLocation, … … 5197 5214 return rc; 5198 5215 #else 5199 NOREF(aN ame);5200 NOREF(aN atNetwork);5216 NOREF(aNetworkName); 5217 NOREF(aNetwork); 5201 5218 return E_NOTIMPL; 5202 5219 #endif … … 5233 5250 return rc; 5234 5251 #else 5235 NOREF(aName);5236 5252 NOREF(aNetworkName); 5253 NOREF(aNetwork); 5237 5254 return E_NOTIMPL; 5238 5255 #endif
Note:
See TracChangeset
for help on using the changeset viewer.