Changeset 86795 in vbox
- Timestamp:
- Nov 3, 2020 12:29:09 PM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 5 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r86783 r86795 580 580 src/hostnetwork/UIHostNetworkManager.h \ 581 581 src/manager/UIErrorPane.h \ 582 src/manager/UIProgressTaskReadCloudMachineList.h \ 582 583 src/manager/UITaskCloudGetSettingsForm.h \ 583 src/manager/UITaskCloudListMachines.h \584 584 src/manager/UIToolPaneGlobal.h \ 585 585 src/manager/UIToolPaneMachine.h \ … … 1060 1060 src/manager/UICloudEntityKey.cpp \ 1061 1061 src/manager/UIErrorPane.cpp \ 1062 src/manager/UIProgressTaskReadCloudMachineList.cpp \ 1062 1063 src/manager/UITaskCloudGetSettingsForm.cpp \ 1063 src/manager/UITaskCloudListMachines.cpp \1064 1064 src/manager/UIToolPaneGlobal.cpp \ 1065 1065 src/manager/UIToolPaneMachine.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIProgressTaskReadCloudMachineList.cpp
r86794 r86795 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI TaskCloudListMachinesclass implementation.3 * VBox Qt GUI - UIProgressTaskReadCloudMachineList class implementation. 4 4 */ 5 5 … … 18 18 /* GUI includes: */ 19 19 #include "UICloudNetworkingStuff.h" 20 #include "UITaskCloudListMachines.h" 21 22 /* COM includes: */ 23 #include "CCloudClient.h" 20 #include "UIMessageCenter.h" 21 #include "UIProgressTaskReadCloudMachineList.h" 24 22 25 23 26 UITaskCloudListMachines::UITaskCloudListMachines(const QString &strProviderShortName, 27 const QString &strProfileName, 28 bool fWithRefresh) 29 : UITask(Type_CloudListMachines) 30 , m_strProviderShortName(strProviderShortName) 31 , m_strProfileName(strProfileName) 24 UIProgressTaskReadCloudMachineList::UIProgressTaskReadCloudMachineList(QObject *pParent, 25 const UICloudEntityKey &guiCloudProfileKey, 26 bool fWithRefresh) 27 : UIProgressTask(pParent) 28 , m_guiCloudProfileKey(guiCloudProfileKey) 32 29 , m_fWithRefresh(fWithRefresh) 33 30 { 34 31 } 35 32 36 QVector<CCloudMachine> UITaskCloudListMachines::result() const33 UICloudEntityKey UIProgressTaskReadCloudMachineList::cloudProfileKey() const 37 34 { 38 m_mutex.lock(); 39 const QVector<CCloudMachine> resultVector = m_result; 40 m_mutex.unlock(); 41 return resultVector; 35 return m_guiCloudProfileKey; 42 36 } 43 37 44 Q String UITaskCloudListMachines::errorInfo() const38 QVector<CCloudMachine> UIProgressTaskReadCloudMachineList::machines() const 45 39 { 46 m_mutex.lock(); 47 QString strErrorInfo = m_strErrorInfo; 48 m_mutex.unlock(); 49 return strErrorInfo; 40 return m_machines; 50 41 } 51 42 52 void UITaskCloudListMachines::run()43 CProgress UIProgressTaskReadCloudMachineList::createProgress() 53 44 { 54 m_mutex.lock(); 55 CCloudClient comCloudClient = cloudClientByName(m_strProviderShortName, m_strProfileName, m_strErrorInfo); 56 if (m_strErrorInfo.isNull()) 57 m_result = m_fWithRefresh 58 ? listCloudMachines(comCloudClient, m_strErrorInfo) 59 : listCloudMachineStubs(comCloudClient, m_strErrorInfo); 60 m_mutex.unlock(); 45 /* Create cloud client: */ 46 m_comCloudClient = cloudClientByName(m_guiCloudProfileKey.m_strProviderShortName, 47 m_guiCloudProfileKey.m_strProfileName); 48 49 /* Prepare resulting progress-wrapper: */ 50 CProgress comResult; 51 52 /* Initialize actual progress-wrapper: */ 53 if (m_fWithRefresh) 54 { 55 CProgress comProgress = m_comCloudClient.ReadCloudMachineList(); 56 if (!m_comCloudClient.isOk()) 57 msgCenter().cannotAcquireCloudClientParameter(m_comCloudClient); 58 else 59 comResult = comProgress; 60 } 61 else 62 { 63 CProgress comProgress = m_comCloudClient.ReadCloudMachineStubList(); 64 if (!m_comCloudClient.isOk()) 65 msgCenter().cannotAcquireCloudClientParameter(m_comCloudClient); 66 else 67 comResult = comProgress; 68 } 69 70 /* Return progress-wrapper in any case: */ 71 return comResult; 61 72 } 73 74 void UIProgressTaskReadCloudMachineList::handleProgressFinished(CProgress &comProgress) 75 { 76 /* Handle progress-wrapper errors: */ 77 if (!comProgress.GetCanceled() && (!comProgress.isOk() || comProgress.GetResultCode() != 0)) 78 msgCenter().cannotAcquireCloudClientParameter(comProgress); 79 { 80 /* Fill the result: */ 81 m_machines = m_fWithRefresh ? m_comCloudClient.GetCloudMachineList() : m_comCloudClient.GetCloudMachineStubList(); 82 if (!m_comCloudClient.isOk()) 83 msgCenter().cannotAcquireCloudClientParameter(m_comCloudClient); 84 } 85 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIProgressTaskReadCloudMachineList.h
r86794 r86795 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UI TaskCloudListMachinesclass declaration.3 * VBox Qt GUI - UIProgressTaskReadCloudMachineList class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_manager_UI TaskCloudListMachines_h19 #define FEQT_INCLUDED_SRC_manager_UI TaskCloudListMachines_h18 #ifndef FEQT_INCLUDED_SRC_manager_UIProgressTaskReadCloudMachineList_h 19 #define FEQT_INCLUDED_SRC_manager_UIProgressTaskReadCloudMachineList_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once 22 22 #endif 23 23 24 /* Qt includes: */25 #include <QMutex>26 27 24 /* GUI includes: */ 28 #include "UITask.h" 25 #include "UICloudEntityKey.h" 26 #include "UIProgressTask.h" 29 27 30 28 /* COM includes: */ 31 29 #include "COMEnums.h" 30 #include "CCloudClient.h" 32 31 #include "CCloudMachine.h" 33 32 34 /** UI Task extension used to list cloud machines. */35 class UI TaskCloudListMachines : public UITask33 /** UIProgressTask extension performing read cloud machine list task. */ 34 class UIProgressTaskReadCloudMachineList : public UIProgressTask 36 35 { 37 36 Q_OBJECT; … … 39 38 public: 40 39 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 * @param fWithRefresh Brings whether the task includes refresh. */ 45 UITaskCloudListMachines(const QString &strProviderShortName, 46 const QString &strProfileName, 47 bool fWithRefresh); 40 /** Constructs read cloud machine list task passing @a pParent to the base-class. 41 * @param guiCloudProfileKey Brings cloud profile description key. 42 * @param fWithRefresh Brings whether cloud machine should be refreshed as well. */ 43 UIProgressTaskReadCloudMachineList(QObject *pParent, const UICloudEntityKey &guiCloudProfileKey, bool fWithRefresh); 48 44 49 /** Returns provider short name. */ 50 QString providerShortName() const { return m_strProviderShortName; } 51 /** Returns profile name. */ 52 QString profileName() const { return m_strProfileName; } 53 /** Returns whether the task includes refresh. */ 54 bool withRefresh() const { return m_fWithRefresh; } 45 /** Returns cloud profile description key. */ 46 UICloudEntityKey cloudProfileKey() const; 55 47 56 /** Returns error info. */ 57 QString errorInfo() const; 58 59 /** Returns the task result. */ 60 QVector<CCloudMachine> result() const; 48 /** Returns resulting cloud machine-wrapper vector. */ 49 QVector<CCloudMachine> machines() const; 61 50 62 51 protected: 63 52 64 /** Contains the task body. */ 65 virtual void run() /* override */; 53 /** Creates and returns started progress-wrapper required to init UIProgressObject. */ 54 virtual CProgress createProgress() /* override */; 55 /** Handles finished @a comProgress wrapper. */ 56 virtual void handleProgressFinished(CProgress &comProgress) /* override */; 66 57 67 58 private: 68 59 69 /** Holds the mutex to access result. */ 70 mutable QMutex m_mutex; 60 /** Holds the cloud profile description key. */ 61 UICloudEntityKey m_guiCloudProfileKey; 62 /** Holds whether cloud machine should be refreshed as well. */ 63 bool m_fWithRefresh; 71 64 72 /** Holds the provider short name. */ 73 const QString m_strProviderShortName; 74 /** Holds the profile name. */ 75 const QString m_strProfileName; 76 /** Holds whether the task includes refresh. */ 77 const bool m_fWithRefresh; 78 79 /** Holds the error info. */ 80 QString m_strErrorInfo; 81 82 /** Holds the task result. */ 83 QVector<CCloudMachine> m_result; 65 /** Holds the cloud client-wrapper. */ 66 CCloudClient m_comCloudClient; 67 /** Holds the resulting cloud machine-wrapper vector. */ 68 QVector<CCloudMachine> m_machines; 84 69 }; 85 70 86 #endif /* !FEQT_INCLUDED_SRC_manager_UI TaskCloudListMachines_h */71 #endif /* !FEQT_INCLUDED_SRC_manager_UIProgressTaskReadCloudMachineList_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.cpp
r86788 r86795 30 30 #include "UIExtraDataManager.h" 31 31 #include "UIMessageCenter.h" 32 #include "UITaskCloudListMachines.h" 33 #include "UIThreadPool.h" 32 #include "UIProgressTaskReadCloudMachineList.h" 34 33 #include "UIVirtualBoxEventHandler.h" 35 34 #include "UIVirtualMachineItemCloud.h" … … 590 589 void UIChooserAbstractModel::insertCloudEntityKey(const UICloudEntityKey &key) 591 590 { 592 //printf("Cloud entity with key %s being updated..\n", key.toString().toUtf8().constData());591 printf("Cloud entity with key %s being updated..\n", key.toString().toUtf8().constData()); 593 592 m_cloudEntityKeysBeingUpdated.insert(key); 594 593 emit sigCloudUpdateStateChanged(); … … 597 596 void UIChooserAbstractModel::removeCloudEntityKey(const UICloudEntityKey &key) 598 597 { 599 //printf("Cloud entity with key %s is updated!\n", key.toString().toUtf8().constData());598 printf("Cloud entity with key %s is updated!\n", key.toString().toUtf8().constData()); 600 599 m_cloudEntityKeysBeingUpdated.remove(key); 601 600 emit sigCloudUpdateStateChanged(); … … 848 847 } 849 848 850 void UIChooserAbstractModel::sltHandleCloudListMachinesTaskComplete(UITask *pTask) 851 { 852 /* Skip unrelated tasks: */ 853 AssertPtrReturnVoid(pTask); 854 if (pTask->type() != UITask::Type_CloudListMachines) 849 void UIChooserAbstractModel::sltHandleReadCloudMachineListTaskComplete() 850 { 851 /* Parse task result: */ 852 UIProgressTaskReadCloudMachineList *pSender = qobject_cast<UIProgressTaskReadCloudMachineList*>(sender()); 853 AssertPtrReturnVoid(pSender); 854 const UICloudEntityKey guiCloudProfileKey = pSender->cloudProfileKey(); 855 const QVector<CCloudMachine> machines = pSender->machines(); 856 857 /* Delete task: */ 858 delete pSender; 859 860 /* Check whether this task was expected: */ 861 if (!containsCloudEntityKey(guiCloudProfileKey)) 855 862 return; 856 UITaskCloudListMachines *pAcquiringTask = qobject_cast<UITaskCloudListMachines*>(pTask);857 AssertPtrReturnVoid(pAcquiringTask);858 const QString strProviderShortName = pAcquiringTask->providerShortName();859 const QString strProfileName = pAcquiringTask->profileName();860 863 861 864 /* Search for profile node: */ 862 UIChooserNode *pProfileNode = searchProfileNode(strProviderShortName, strProfileName); 865 UIChooserNode *pProfileNode = searchProfileNode(guiCloudProfileKey.m_strProviderShortName, 866 guiCloudProfileKey.m_strProfileName); 863 867 if (!pProfileNode) 864 868 return; … … 878 882 QSet<QUuid> newIDs; 879 883 QMap<QUuid, CCloudMachine> newMachines; 880 foreach (const CCloudMachine &comMachine, pAcquiringTask->result())884 foreach (const CCloudMachine &comMachine, machines) 881 885 { 882 886 QUuid uId; … … 895 899 /* Remove unregistered cloud VM nodes: */ 896 900 if (!unregisteredIDs.isEmpty()) 897 sltCloudMachinesUnregistered(strProviderShortName, strProfileName, unregisteredIDs.toList()); 901 sltCloudMachinesUnregistered(guiCloudProfileKey.m_strProviderShortName, 902 guiCloudProfileKey.m_strProfileName, 903 unregisteredIDs.toList()); 898 904 /* Add registered cloud VM nodes: */ 899 905 if (!registeredMachines.isEmpty()) 900 sltCloudMachinesRegistered(strProviderShortName, strProfileName, registeredMachines); 906 sltCloudMachinesRegistered(guiCloudProfileKey.m_strProviderShortName, 907 guiCloudProfileKey.m_strProfileName, 908 registeredMachines); 901 909 /* If we changed nothing and have nothing currently: */ 902 910 if (unregisteredIDs.isEmpty() && newIDs.isEmpty()) … … 910 918 911 919 /* Remove cloud entity key from the list of keys currently being updated: */ 912 const UICloudEntityKey guiCloudEntityKey = UICloudEntityKey(strProviderShortName, strProfileName); 913 removeCloudEntityKey(guiCloudEntityKey); 920 removeCloudEntityKey(guiCloudProfileKey); 914 921 } 915 922 … … 922 929 void UIChooserAbstractModel::createReadCloudMachineListTask(const UICloudEntityKey &guiCloudProfileKey, bool fWithRefresh) 923 930 { 924 /* Create list cloud machines task: */ 925 UITaskCloudListMachines *pTask = new UITaskCloudListMachines(guiCloudProfileKey.m_strProviderShortName, 926 guiCloudProfileKey.m_strProfileName, 927 fWithRefresh); 928 AssertPtrReturnVoid(pTask); 929 uiCommon().threadPoolCloud()->enqueueTask(pTask); 931 /* Do not create task if already registered: */ 932 if (containsCloudEntityKey(guiCloudProfileKey)) 933 return; 934 935 /* Create task: */ 936 UIProgressTaskReadCloudMachineList *pTask = new UIProgressTaskReadCloudMachineList(this, 937 guiCloudProfileKey, 938 fWithRefresh); 939 if (pTask) 940 { 941 /* Insert cloud profile key into a list of keys currently being updated: */ 942 insertCloudEntityKey(guiCloudProfileKey); 943 944 /* Connect and start it finally: */ 945 connect(pTask, &UIProgressTaskReadCloudMachineList::sigProgressFinished, 946 this, &UIChooserAbstractModel::sltHandleReadCloudMachineListTaskComplete); 947 pTask->start(); 948 } 930 949 } 931 950 … … 943 962 void UIChooserAbstractModel::prepareConnections() 944 963 { 945 /* Cloud thread-pool connections: */946 connect(uiCommon().threadPoolCloud(), &UIThreadPool::sigTaskComplete,947 this, &UIChooserAbstractModel::sltHandleCloudListMachinesTaskComplete);948 949 964 /* Cloud VM registration connections: */ 950 965 connect(&uiCommon(), &UICommon::sigCloudMachineUnregistered, … … 989 1004 } 990 1005 1006 void UIChooserAbstractModel::cleanupTasks() 1007 { 1008 foreach (UIProgressTaskReadCloudMachineList *pTask, findChildren<UIProgressTaskReadCloudMachineList*>()) 1009 delete pTask; 1010 } 1011 991 1012 void UIChooserAbstractModel::cleanupConnections() 992 1013 { 993 /* Cloud thread-pool connections: */994 disconnect(uiCommon().threadPoolCloud(), &UIThreadPool::sigTaskComplete,995 this, &UIChooserAbstractModel::sltHandleCloudListMachinesTaskComplete);996 997 1014 /* Cloud VM registration connections: */ 998 1015 disconnect(&uiCommon(), &UICommon::sigCloudMachineUnregistered, … … 1038 1055 void UIChooserAbstractModel::cleanup() 1039 1056 { 1057 cleanupTasks(); 1040 1058 cleanupConnections(); 1041 1059 } … … 1178 1196 createCloudMachineNode(pProfileNode, UIFakeCloudVirtualMachineItemState_Loading); 1179 1197 1180 /* Insert cloud profile key into a list of keys currently being updated: */1198 /* Create read cloud machine list task: */ 1181 1199 const UICloudEntityKey guiCloudProfileKey = UICloudEntityKey(strProviderShortName, strProfileName); 1182 insertCloudEntityKey(guiCloudProfileKey);1183 1184 /* Create list cloud machines task: */1185 1200 createReadCloudMachineListTask(guiCloudProfileKey, true /* with refresh? */); 1186 1201 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserAbstractModel.h
r86788 r86795 37 37 class UIChooser; 38 38 class UIChooserNode; 39 class UITask;40 39 class CCloudMachine; 41 40 class CMachine; … … 217 216 const QVector<CCloudMachine> &machines); 218 217 219 /** Handles list cloud machinestask complete signal. */220 virtual void sltHandle CloudListMachinesTaskComplete(UITask *pTask);218 /** Handles read cloud machine list task complete signal. */ 219 virtual void sltHandleReadCloudMachineListTaskComplete(); 221 220 222 221 /** Handles Cloud Profile Manager cumulative change. */ … … 250 249 void prepareConnections(); 251 250 251 /** Cleanups tasks. */ 252 void cleanupTasks(); 252 253 /** Cleanups connections. */ 253 254 void cleanupConnections(); -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r86787 r86795 44 44 #include "UIMessageCenter.h" 45 45 #include "UIModalWindowManager.h" 46 #include "UITaskCloudListMachines.h"47 #include "UIThreadPool.h"48 46 #include "UIVirtualBoxManagerWidget.h" 49 47 #include "UIVirtualMachineItemCloud.h" … … 940 938 AssertPtrReturnVoid(pParentOfParent); 941 939 942 /* Insert cloud profile key into a list of keys currently being updated: */940 /* Create read cloud machine list task: */ 943 941 const UICloudEntityKey guiCloudProfileKey = UICloudEntityKey(pParentOfParent->name(), pParent->name()); 944 insertCloudEntityKey(guiCloudProfileKey);945 946 /* Create list cloud machines task: */947 942 createReadCloudMachineListTask(guiCloudProfileKey, true /* with refresh? */); 948 943 … … 1219 1214 } 1220 1215 1221 void UIChooserModel::sltHandleCloudListMachinesTaskComplete(UITask *pTask) 1222 { 1223 /* Skip unrelated tasks: */ 1224 if (!pTask || pTask->type() != UITask::Type_CloudListMachines) 1225 return; 1226 1216 void UIChooserModel::sltHandleReadCloudMachineListTaskComplete() 1217 { 1227 1218 /* Call to base-class: */ 1228 UIChooserAbstractModel::sltHandle CloudListMachinesTaskComplete(pTask);1219 UIChooserAbstractModel::sltHandleReadCloudMachineListTaskComplete(); 1229 1220 1230 1221 /* Restart cloud profile update timer: */ … … 1357 1348 /* Restart List Cloud Machines task for selected profile keys: */ 1358 1349 foreach (const UICloudEntityKey &guiCloudProfileKey, selectedCloudProfileKeys) 1359 {1360 /* Skip cloud profile keys already being updated: */1361 if (containsCloudEntityKey(guiCloudProfileKey))1362 continue;1363 insertCloudEntityKey(guiCloudProfileKey);1364 1365 /* Create a task for particular cloud entity key: */1366 1350 createReadCloudMachineListTask(guiCloudProfileKey, false /* with refresh? */); 1367 }1368 1351 } 1369 1352 … … 1952 1935 /* Restart List Cloud Machines task for required profile keys: */ 1953 1936 foreach (const UICloudEntityKey &guiCloudProfileKey, changedCloudEntityKeys) 1954 {1955 /* Skip cloud profile keys already being updated: */1956 if (containsCloudEntityKey(guiCloudProfileKey))1957 continue;1958 insertCloudEntityKey(guiCloudProfileKey);1959 1960 /* Create a task for particular cloud entity key: */1961 1937 createReadCloudMachineListTask(guiCloudProfileKey, false /* with refresh? */); 1962 }1963 1938 } 1964 1939 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h
r86705 r86795 304 304 const QVector<CCloudMachine> &machines) /* override */; 305 305 306 /** Handles list cloud machinestask complete signal. */307 virtual void sltHandle CloudListMachinesTaskComplete(UITask *pTask) /* override */;306 /** Handles read cloud machine list task complete signal. */ 307 virtual void sltHandleReadCloudMachineListTaskComplete() /* override */; 308 308 309 309 /** Handles Cloud Profile Manager cumulative changes. */
Note:
See TracChangeset
for help on using the changeset viewer.