Changeset 84058 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Apr 28, 2020 4:42:35 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 137637
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UITaskCloudListMachines.cpp
r83691 r84058 20 20 #include "UITaskCloudListMachines.h" 21 21 22 /* COM includes: */ 23 #include "CCloudClient.h" 22 24 23 UITaskCloudListMachines::UITaskCloudListMachines(const CCloudClient &comCloudClient, UIChooserNode *pParentNode) 25 26 UITaskCloudListMachines::UITaskCloudListMachines(const QString &strProviderShortName, const QString &strProfileName) 24 27 : UITask(Type_CloudListMachines) 25 , m_ comCloudClient(comCloudClient)26 , m_ pParentNode(pParentNode)28 , m_strProviderShortName(strProviderShortName) 29 , m_strProfileName(strProfileName) 27 30 { 28 31 } … … 47 50 { 48 51 m_mutex.lock(); 49 m_result = listCloudMachines(m_comCloudClient, m_strErrorInfo); 52 CCloudClient comCloudClient = cloudClientByName(m_strProviderShortName, m_strProfileName, m_strErrorInfo); 53 if (m_strErrorInfo.isNull()) 54 m_result = listCloudMachines(comCloudClient, m_strErrorInfo); 50 55 m_mutex.unlock(); 51 56 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UITaskCloudListMachines.h
r83659 r84058 30 30 /* COM includes: */ 31 31 #include "COMEnums.h" 32 #include "CCloudClient.h"33 32 #include "CCloudMachine.h" 34 35 /* Forward declaratiuons: */36 class UIChooserNode;37 33 38 34 /** UITask extension used to list cloud machines. */ … … 43 39 public: 44 40 45 /** Constructs update task taking @a comCloudClient and @a pParentNode as data.46 * @param comCloudClient Brings the cloud client object.47 * @param m_pParentNode Brings the parent node reference. */48 UITaskCloudListMachines(const CCloudClient &comCloudClient, UIChooserNode *pParentNode);41 /** Constructs task taking @a strProviderShortName and @a strProfileName as data. 42 * @param strProviderShortName Brings the provider short name. 43 * @param strProfileName Brings the profile name. */ 44 UITaskCloudListMachines(const QString &strProviderShortName, const QString &strProfileName); 49 45 50 /** Returns cloud client object. */51 CCloudClient cloudClient() const { return m_comCloudClient; }52 /** Returns p arent node reference. */53 UIChooserNode *parentNode() const { return m_pParentNode; }46 /** Returns provider short name. */ 47 QString providerShortName() const { return m_strProviderShortName; } 48 /** Returns profile name. */ 49 QString profileName() const { return m_strProfileName; } 54 50 55 51 /** Returns error info. */ … … 69 65 mutable QMutex m_mutex; 70 66 71 /** Holds the cloud client object. */72 CCloudClient m_comCloudClient;73 /** Holds the p arent node reference. */74 UIChooserNode *m_pParentNode;67 /** Holds the provider short name. */ 68 const QString m_strProviderShortName; 69 /** Holds the profile name. */ 70 const QString m_strProfileName; 75 71 76 72 /** Holds the error info. */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
r83946 r84058 125 125 /* Add cloud providers/profiles: */ 126 126 LogRelFlow(("UIChooserAbstractModel: Loading cloud providers/profiles...\n")); 127 /* Acquire cloud provider manager: */ 128 const CCloudProviderManager comCloudProviderManager = comVBox.GetCloudProviderManager(); 129 /* Show error message if necessary: */ 130 if (!comVBox.isOk()) 131 msgCenter().cannotAcquireCloudProviderManager(comVBox); 132 else 127 /* Iterate through existing providers: */ 128 foreach (CCloudProvider comCloudProvider, listCloudProviders()) 133 129 { 134 /* Acquire existing providers: */ 135 const QVector<CCloudProvider> providers = comCloudProviderManager.GetProviders(); 136 /* Show error message if necessary: */ 137 if (!comCloudProviderManager.isOk()) 138 msgCenter().cannotAcquireCloudProviderManagerParameter(comCloudProviderManager); 139 else 130 /* Skip if we have nothing to populate: */ 131 if (comCloudProvider.isNull()) 132 continue; 133 134 /* Acquire provider short name: */ 135 QString strProviderShortName; 136 if (!cloudProviderShortName(comCloudProvider, strProviderShortName)) 137 continue; 138 139 /* Add provider group node: */ 140 UIChooserNodeGroup *pProviderNode = 141 new UIChooserNodeGroup(invisibleRoot() /* parent */, 142 false /* favorite */, 143 getDesiredNodePosition(invisibleRoot(), 144 UIChooserNodeType_Group, 145 strProviderShortName), 146 strProviderShortName, 147 UIChooserNodeGroupType_Provider, 148 shouldGroupNodeBeOpened(invisibleRoot(), 149 strProviderShortName)); 150 151 /* Iterate through provider's profiles: */ 152 foreach (CCloudProfile comCloudProfile, listCloudProfiles(comCloudProvider)) 140 153 { 141 /* Iterate through existing providers: */ 142 foreach (CCloudProvider comCloudProvider, providers) 154 /* Skip if we have nothing to populate: */ 155 if (comCloudProfile.isNull()) 156 continue; 157 158 /* Acquire profile name: */ 159 QString strProfileName; 160 if (!cloudProfileName(comCloudProfile, strProfileName)) 161 continue; 162 163 /* Add profile sub-group node: */ 164 UIChooserNodeGroup *pProfileNode = 165 new UIChooserNodeGroup(pProviderNode /* parent */, 166 false /* favorite */, 167 getDesiredNodePosition(pProviderNode, 168 UIChooserNodeType_Group, 169 strProfileName), 170 strProfileName, 171 UIChooserNodeGroupType_Profile, 172 shouldGroupNodeBeOpened(pProviderNode, 173 strProfileName)); 174 175 /* Add fake cloud VM item: */ 176 new UIChooserNodeMachine(pProfileNode /* parent */, 177 false /* favorite */, 178 0 /* position */); 179 180 /* Create list cloud machines task: */ 181 UITaskCloudListMachines *pTask = new UITaskCloudListMachines(strProviderShortName, 182 strProfileName); 183 if (pTask) 143 184 { 144 /* Skip if we have nothing to populate (file missing?): */ 145 if (comCloudProvider.isNull()) 146 continue; 147 148 /* Get profile names: */ 149 const QVector<QString> profileNames = comCloudProvider.GetProfileNames(); 150 /* Show error message if necessary: */ 151 if (!comCloudProvider.isOk()) 152 { 153 msgCenter().cannotAcquireCloudProviderParameter(comCloudProvider); 154 continue; 155 } 156 157 /* Skip if we have nothing to populate (profiles missing?): */ 158 if (profileNames.isEmpty()) 159 continue; 160 161 /* Get provider name: */ 162 const QString strProviderName = comCloudProvider.GetShortName(); 163 /* Show error message if necessary: */ 164 if (!comCloudProvider.isOk()) 165 { 166 msgCenter().cannotAcquireCloudProviderParameter(comCloudProvider); 167 continue; 168 } 169 170 /* Add provider group node: */ 171 UIChooserNodeGroup *pProviderNode = 172 new UIChooserNodeGroup(invisibleRoot() /* parent */, 173 false /* favorite */, 174 getDesiredNodePosition(invisibleRoot(), 175 UIChooserNodeType_Group, 176 strProviderName), 177 strProviderName, 178 UIChooserNodeGroupType_Provider, 179 shouldGroupNodeBeOpened(invisibleRoot(), 180 strProviderName)); 181 182 /* Iterate through provider's profile names: */ 183 foreach (const QString &strProfileName, profileNames) 184 { 185 /* Skip if we have nothing to show (wtf happened?): */ 186 if (strProfileName.isEmpty()) 187 continue; 188 189 /* Acquire cloud profile: */ 190 CCloudProfile comCloudProfile = comCloudProvider.GetProfileByName(strProfileName); 191 /* Show error message if necessary: */ 192 if (!comCloudProvider.isOk()) 193 { 194 msgCenter().cannotFindCloudProfile(comCloudProvider, strProfileName); 195 continue; 196 } 197 198 /* Create cloud client: */ 199 CCloudClient comCloudClient = comCloudProfile.CreateCloudClient(); 200 /* Show error message if necessary: */ 201 if (!comCloudProfile.isOk()) 202 { 203 msgCenter().cannotCreateCloudClient(comCloudProfile); 204 continue; 205 } 206 207 /* Add profile sub-group node: */ 208 UIChooserNodeGroup *pProfileNode = 209 new UIChooserNodeGroup(pProviderNode /* parent */, 210 false /* favorite */, 211 getDesiredNodePosition(pProviderNode, 212 UIChooserNodeType_Group, 213 strProfileName), 214 strProfileName, 215 UIChooserNodeGroupType_Profile, 216 shouldGroupNodeBeOpened(pProviderNode, 217 strProfileName)); 218 /* Add fake cloud VM item: */ 219 new UIChooserNodeMachine(pProfileNode /* parent */, 220 false /* favorite */, 221 0 /* position */); 222 223 /* Create cloud list machines task: */ 224 UITaskCloudListMachines *pTask = new UITaskCloudListMachines(comCloudClient, 225 pProfileNode); 226 if (pTask) 227 { 228 connect(uiCommon().threadPoolCloud(), &UIThreadPool::sigTaskComplete, 229 this, &UIChooserAbstractModel::sltHandleCloudListMachinesTaskComplete); 230 uiCommon().threadPoolCloud()->enqueueTask(pTask); 231 } 232 } 185 connect(uiCommon().threadPoolCloud(), &UIThreadPool::sigTaskComplete, 186 this, &UIChooserAbstractModel::sltHandleCloudListMachinesTaskComplete); 187 uiCommon().threadPoolCloud()->enqueueTask(pTask); 233 188 } 234 189 } … … 502 457 return msgCenter().cannotAcquireCloudInstanceList(pAcquiringTask->errorInfo()); 503 458 504 /* Acquire parent node and make sure it has children: */505 /// @todo rework task to bring parent by id instead of pointer506 /// to object which maybe deleted to this moment already507 UIChooserNode *pParentNode = pAcquiringTask->parentNode();508 AssertPtrReturnVoid(pParentNode);509 Assert ReturnVoid(pParentNode->hasNodes());510 511 /* Make sure this node have first child: */512 UIChooserNode *pFirstChildNode = pParentNode->nodes().first();513 AssertPtrReturnVoid(pFirstChildNode);514 515 /* Which is machine node and has cache of fake-cloud-item type: */516 UIChooserNodeMachine *pF irstChildNodeMachine = pFirstChildNode->toMachineNode();517 AssertPtrReturnVoid(pF irstChildNodeMachine);518 AssertReturnVoid(pF irstChildNodeMachine->cacheType() == UIVirtualMachineItemType_CloudFake);459 /* Search for profile node: */ 460 const QString strProfileNodeName = QString("/%1/%2").arg(pAcquiringTask->providerShortName(), pAcquiringTask->profileName()); 461 QList<UIChooserNode*> profileNodes; 462 invisibleRoot()->searchForNodes(strProfileNodeName, UIChooserItemSearchFlag_Group | UIChooserItemSearchFlag_ExactId, profileNodes); 463 UIChooserNode *pProfileNode = profileNodes.value(0); 464 AssertPtrReturnVoid(pProfileNode); 465 466 /* Search for fake node: */ 467 QList<UIChooserNode*> fakeNodes; 468 pProfileNode->searchForNodes(toOldStyleUuid(QUuid()), UIChooserItemSearchFlag_Machine | UIChooserItemSearchFlag_ExactId, fakeNodes); 469 UIChooserNode *pFakeNode = fakeNodes.value(0); 470 AssertPtrReturnVoid(pFakeNode); 471 UIChooserNodeMachine *pFakeMachineNode = pFakeNode->toMachineNode(); 472 AssertPtrReturnVoid(pFakeMachineNode); 473 AssertReturnVoid(pFakeMachineNode->cacheType() == UIVirtualMachineItemType_CloudFake); 519 474 520 475 /* And if we have at least one cloud machine: */ … … 522 477 if (!machines.isEmpty()) 523 478 { 524 /* Remove the "Empty"node: */525 delete pF irstChildNodeMachine;479 /* Remove fake node: */ 480 delete pFakeMachineNode; 526 481 527 482 /* Add real cloud VM nodes: */ 528 483 foreach (const CCloudMachine &comCloudMachine, machines) 529 createCloudMachineNode(pP arentNode, comCloudMachine);484 createCloudMachineNode(pProfileNode, comCloudMachine); 530 485 } 531 486 else 532 487 { 533 488 /* Otherwise toggle and update "Empty" node: */ 534 UIVirtualMachineItemCloud *pFakeCloudMachineItem = pF irstChildNodeMachine->cache()->toCloud();489 UIVirtualMachineItemCloud *pFakeCloudMachineItem = pFakeMachineNode->cache()->toCloud(); 535 490 AssertPtrReturnVoid(pFakeCloudMachineItem); 536 491 pFakeCloudMachineItem->setFakeCloudItemState(UIFakeCloudVirtualMachineItemState_Done);
Note:
See TracChangeset
for help on using the changeset viewer.