- Timestamp:
- Feb 14, 2020 2:14:09 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.cpp
r83069 r83076 30 30 31 31 32 UIVirtualMachineItemCloud::UIVirtualMachineItemCloud() 33 : UIVirtualMachineItem(ItemType_CloudFake) 34 , m_pCloudMachine(0) 35 , m_enmFakeCloudItemState(FakeCloudItemState_Loading) 36 { 37 recache(); 38 } 39 40 UIVirtualMachineItemCloud::UIVirtualMachineItemCloud(const UICloudMachine &guiCloudMachine) 41 : UIVirtualMachineItem(ItemType_CloudReal) 42 , m_pCloudMachine(new UICloudMachine(guiCloudMachine)) 43 , m_enmFakeCloudItemState(FakeCloudItemState_NotApplicable) 44 { 45 recache(); 46 } 47 48 UIVirtualMachineItemCloud::~UIVirtualMachineItemCloud() 49 { 50 delete m_pCloudMachine; 51 } 52 53 void UIVirtualMachineItemCloud::updateState(QWidget *pParent) 54 { 55 /* Make sure item is of real cloud type: */ 56 AssertReturnVoid(itemType() == ItemType_CloudReal); 57 58 /* Update state: */ 59 const QString strState = acquireInstanceInfo(KVirtualSystemDescriptionType_CloudInstanceState, pParent); 60 QMap<QString, KMachineState> states; 61 states["RUNNING"] = KMachineState_Running; 62 states["STOPPED"] = KMachineState_Paused; 63 states["STOPPING"] = KMachineState_Stopping; 64 states["STARTING"] = KMachineState_Starting; 65 m_enmMachineState = states.value(strState, KMachineState_PoweredOff); 66 67 /* Recache: */ 68 recache(); 69 70 /* Notify listeners finally: */ 71 emit sigStateChange(); 72 } 73 74 QString UIVirtualMachineItemCloud::acquireInstanceInfo(KVirtualSystemDescriptionType enmType, QWidget *pParent) 75 { 76 /* Make sure item is of real cloud type and is initialized: */ 77 AssertReturn(itemType() == ItemType_CloudReal, QString()); 78 AssertPtrReturn(m_pCloudMachine, QString()); 79 32 /** GetInstanceInfo namespace. */ 33 namespace GetInstanceInfo 34 { 35 /** Acquires instance info of certain @a enmType. 36 * @param comCloudClient Brings cloud client object. 37 * @param strId Brings cloud VM id. 38 * @param pWidget Brings parent widget to show messages according to. */ 39 QString getInstanceInfo(KVirtualSystemDescriptionType enmType, 40 const CCloudClient &comCloudClient, 41 const QString &strId, 42 QWidget *pParent = 0); 43 } 44 45 /* Using across module: */ 46 using namespace GetInstanceInfo; 47 48 49 /********************************************************************************************************************************* 50 * Namespace GetInstanceInfo implementation. * 51 *********************************************************************************************************************************/ 52 53 QString GetInstanceInfo::getInstanceInfo(KVirtualSystemDescriptionType enmType, 54 const CCloudClient &comCloudClient, 55 const QString &strId, 56 QWidget *pParent /* = 0 */) 57 { 80 58 /* Get VirtualBox object: */ 81 59 CVirtualBox comVBox = uiCommon().virtualBox(); … … 84 62 CAppliance comAppliance = comVBox.CreateAppliance(); 85 63 if (!comVBox.isOk()) 86 msgCenter().cannotCreateAppliance(comVBox); 64 { 65 if (pParent) 66 msgCenter().cannotCreateAppliance(comVBox, pParent); 67 else 68 { 69 /// @todo fetch error info 70 } 71 } 87 72 else 88 73 { … … 90 75 comAppliance.CreateVirtualSystemDescriptions(1); 91 76 if (!comAppliance.isOk()) 92 msgCenter().cannotCreateVirtualSystemDescription(comAppliance); 77 { 78 if (pParent) 79 msgCenter().cannotCreateVirtualSystemDescription(comAppliance, pParent); 80 else 81 { 82 /// @todo fetch error info 83 } 84 } 93 85 else 94 86 { … … 98 90 CVirtualSystemDescription comDescription = descriptions.at(0); 99 91 100 /* Acquire cloud client: */101 CCloudClient comCloudClient = m_pCloudMachine->client();102 103 92 /* Now execute GetInstanceInfo async method: */ 104 CProgress comProgress = comCloudClient.GetInstanceInfo( m_strId, comDescription);93 CProgress comProgress = comCloudClient.GetInstanceInfo(strId, comDescription); 105 94 if (!comCloudClient.isOk()) 106 msgCenter().cannotAcquireCloudClientParameter(comCloudClient); 95 { 96 if (pParent) 97 msgCenter().cannotAcquireCloudClientParameter(comCloudClient, pParent); 98 else 99 { 100 /// @todo fetch error info 101 } 102 } 107 103 else 108 104 { 109 105 /* Show "Acquire instance info" progress: */ 110 msgCenter().showModalProgressDialog(comProgress, UICommon::tr("Acquire instance info ..."), 111 ":/progress_reading_appliance_90px.png", pParent, 0); 106 if (pParent) 107 msgCenter().showModalProgressDialog(comProgress, UICommon::tr("Acquire instance info ..."), 108 ":/progress_reading_appliance_90px.png", pParent, 0); 109 else 110 comProgress.WaitForCompletion(-1); 112 111 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 113 msgCenter().cannotAcquireCloudClientParameter(comProgress); 112 { 113 if (pParent) 114 msgCenter().cannotAcquireCloudClientParameter(comProgress, pParent); 115 else 116 { 117 /// @todo fetch error info 118 } 119 } 114 120 else 115 121 { … … 131 137 } 132 138 139 140 /********************************************************************************************************************************* 141 * Class UIVirtualMachineItemCloud implementation. * 142 *********************************************************************************************************************************/ 143 144 UIVirtualMachineItemCloud::UIVirtualMachineItemCloud() 145 : UIVirtualMachineItem(ItemType_CloudFake) 146 , m_pCloudMachine(0) 147 , m_enmFakeCloudItemState(FakeCloudItemState_Loading) 148 { 149 recache(); 150 } 151 152 UIVirtualMachineItemCloud::UIVirtualMachineItemCloud(const UICloudMachine &guiCloudMachine) 153 : UIVirtualMachineItem(ItemType_CloudReal) 154 , m_pCloudMachine(new UICloudMachine(guiCloudMachine)) 155 , m_enmFakeCloudItemState(FakeCloudItemState_NotApplicable) 156 { 157 recache(); 158 } 159 160 UIVirtualMachineItemCloud::~UIVirtualMachineItemCloud() 161 { 162 delete m_pCloudMachine; 163 } 164 165 void UIVirtualMachineItemCloud::updateState(QWidget *pParent) 166 { 167 /* Make sure item is of real cloud type and is initialized: */ 168 AssertReturnVoid(itemType() == ItemType_CloudReal); 169 AssertPtrReturnVoid(m_pCloudMachine); 170 171 /* Acquire state: */ 172 const QString strState = getInstanceInfo(KVirtualSystemDescriptionType_CloudInstanceState, 173 m_pCloudMachine->client(), 174 m_strId, 175 pParent); 176 177 /* Update state: */ 178 updateState(strState); 179 } 180 133 181 void UIVirtualMachineItemCloud::pause(QWidget *pParent) 134 182 { … … 348 396 } 349 397 } 398 399 void UIVirtualMachineItemCloud::updateState(const QString &strState) 400 { 401 /* Prepare a map of known states: */ 402 QMap<QString, KMachineState> states; 403 states["RUNNING"] = KMachineState_Running; 404 states["STOPPED"] = KMachineState_Paused; 405 states["STOPPING"] = KMachineState_Stopping; 406 states["STARTING"] = KMachineState_Starting; 407 408 /* Update our state value: */ 409 m_enmMachineState = states.value(strState, KMachineState_PoweredOff); 410 411 /* Recache: */ 412 recache(); 413 414 /* Notify listeners finally: */ 415 emit sigStateChange(); 416 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualMachineItemCloud.h
r83065 r83076 65 65 * @param pWidget Brings parent widget to show messages according to. */ 66 66 void updateState(QWidget *pParent); 67 /** Acquires instance info of certain @a enmType.68 * @param pWidget Brings parent widget to show messages according to. */69 QString acquireInstanceInfo(KVirtualSystemDescriptionType enmType, QWidget *pParent);70 67 71 68 /** Puts cloud VM on pause. … … 119 116 private: 120 117 118 /** @name State attributes. 119 * @{ */ 120 /** Updates cloud VM state on the basis of string @a strState value. */ 121 void updateState(const QString &strState); 122 /** @} */ 123 121 124 /** @name Arguments. 122 125 * @{ */
Note:
See TracChangeset
for help on using the changeset viewer.