VirtualBox

Changeset 83111 in vbox for trunk


Ignore:
Timestamp:
Feb 18, 2020 4:09:49 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9653: VirtualBox Manager: Moving listInstances functionality from UITaskCloudAcquireInstances to UICloudNetworkingStuff to make it possible to reuse it; Besides that, extending it with possibility to be executed in sync/async way on demand.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UICloudNetworkingStuff.cpp

    r83107 r83111  
    2323/* COM includes: */
    2424#include "CAppliance.h"
     25#include "CProgress.h"
     26#include "CStringArray.h"
    2527#include "CVirtualBox.h"
    2628#include "CVirtualSystemDescription.h"
    2729
     30
     31QList<UICloudMachine> UICloudNetworkingStuff::listInstances(const CCloudClient &comCloudClient,
     32                                                            QWidget *pParent /* = 0 */)
     33{
     34    /* Prepare VM names, ids and states.
     35     * Currently we are interested in Running and Stopped VMs only. */
     36    CStringArray comNames;
     37    CStringArray comIDs;
     38    const QVector<KCloudMachineState> cloudMachineStates  = QVector<KCloudMachineState>()
     39                                                         << KCloudMachineState_Running
     40                                                         << KCloudMachineState_Stopped;
     41
     42    /* Now execute ListInstances async method: */
     43    CProgress comProgress = comCloudClient.ListInstances(cloudMachineStates, comNames, comIDs);
     44    if (!comCloudClient.isOk())
     45    {
     46        if (pParent)
     47            msgCenter().cannotAcquireCloudClientParameter(comCloudClient, pParent);
     48        else
     49        {
     50            /// @todo fetch error info
     51        }
     52    }
     53    else
     54    {
     55        /* Show "Acquire cloud instances" progress: */
     56        if (pParent)
     57            msgCenter().showModalProgressDialog(comProgress,
     58                                                UICommon::tr("Acquire cloud instances ..."),
     59                                                ":/progress_reading_appliance_90px.png", pParent, 0);
     60        else
     61            comProgress.WaitForCompletion(-1);
     62        if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     63        {
     64            if (pParent)
     65                msgCenter().cannotAcquireCloudClientParameter(comProgress, pParent);
     66            else
     67            {
     68                /// @todo fetch error info
     69            }
     70        }
     71        else
     72        {
     73            /* Fetch acquired objects to lists: */
     74            const QVector<QString> instanceIds = comIDs.GetValues();
     75            const QVector<QString> instanceNames = comNames.GetValues();
     76            QList<UICloudMachine> resultList;
     77            for (int i = 0; i < instanceIds.size(); ++i)
     78                resultList << UICloudMachine(comCloudClient, instanceIds.at(i), instanceNames.at(i));
     79            return resultList;
     80        }
     81    }
     82
     83    /* Return empty list by default: */
     84    return QList<UICloudMachine>();
     85}
    2886
    2987QString UICloudNetworkingStuff::getInstanceInfo(KVirtualSystemDescriptionType enmType,
     
    81139                /* Show "Acquire instance info" progress: */
    82140                if (pParent)
    83                     msgCenter().showModalProgressDialog(comProgress, UICommon::tr("Acquire instance info ..."),
     141                    msgCenter().showModalProgressDialog(comProgress,
     142                                                        UICommon::tr("Acquire cloud instance info ..."),
    84143                                                        ":/progress_reading_appliance_90px.png", pParent, 0);
    85144                else
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UICloudNetworkingStuff.h

    r83107 r83111  
    2222#endif
    2323
     24/* GUI includes: */
     25#include "UICloudMachine.h"
     26
    2427/* COM includes: */
    2528#include "COMEnums.h"
    2629#include "CCloudClient.h"
    2730
    28 /* Forward declarations: */
    29 class QString;
    30 class QWidget;
    31 
    3231/** Cloud networking stuff namespace. */
    3332namespace UICloudNetworkingStuff
    3433{
     34    /** Acquires instance list.
     35      * @param  comCloudClient  Brings cloud client object.
     36      * @param  pWidget         Brings parent widget to show messages according to,
     37      *                         if no parent set, progress will be executed in blocking way. */
     38    QList<UICloudMachine> listInstances(const CCloudClient &comCloudClient,
     39                                        QWidget *pParent = 0);
     40
    3541    /** Acquires instance info of certain @a enmType.
    3642      * @param  comCloudClient  Brings cloud client object.
    3743      * @param  strId           Brings cloud VM id.
    38       * @param  pWidget         Brings parent widget to show messages according to. */
     44      * @param  pWidget         Brings parent widget to show messages according to,
     45      *                         if no parent set, progress will be executed in blocking way. */
    3946    QString getInstanceInfo(KVirtualSystemDescriptionType enmType,
    4047                            const CCloudClient &comCloudClient,
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UITaskCloudAcquireInstances.cpp

    r83099 r83111  
    1717
    1818/* GUI includes: */
     19#include "UICloudNetworkingStuff.h"
    1920#include "UITaskCloudAcquireInstances.h"
    20 
    21 /* COM includes: */
    22 #include "CProgress.h"
    23 #include "CStringArray.h"
    2421
    2522
     
    5047{
    5148    m_mutex.lock();
    52 
    53     /* Gather VM names, ids and states.
    54      * Currently we are interested in Running and Stopped VMs only. */
    55     CStringArray comNames;
    56     CStringArray comIDs;
    57     const QVector<KCloudMachineState> cloudMachineStates  = QVector<KCloudMachineState>()
    58                                                          << KCloudMachineState_Running
    59                                                          << KCloudMachineState_Stopped;
    60 
    61     /* Ask for cloud instance list: */
    62     CProgress comProgress = m_comCloudClient.ListInstances(cloudMachineStates, comNames, comIDs);
    63     if (!m_comCloudClient.isOk())
    64     {
    65         /// @todo pack error info to m_comErrorInfo
    66     }
    67     else
    68     {
    69         /* Wait for "Acquire cloud instances" progress: */
    70         comProgress.WaitForCompletion(-1);
    71         if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    72         {
    73             /// @todo pack error info to m_comErrorInfo
    74         }
    75         else
    76         {
    77             /* Fetch acquired objects to lists: */
    78             const QVector<QString> instanceIds = comIDs.GetValues();
    79             const QVector<QString> instanceNames = comNames.GetValues();
    80             for (int i = 0; i < instanceIds.size(); ++i)
    81                 m_result << UICloudMachine(m_comCloudClient, instanceIds.at(i), instanceNames.at(i));
    82         }
    83     }
    84 
     49    m_result = listInstances(m_comCloudClient);
    8550    m_mutex.unlock();
    8651}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UITaskCloudAcquireInstances.h

    r83099 r83111  
    4444public:
    4545
    46     /** Constructs update task taking @a comCloudClient and @a pParentNode as data. */
     46    /** Constructs update task taking @a comCloudClient and @a pParentNode as data.
     47      * @param  comCloudClient  Brings the cloud client object.
     48      * @param  m_pParentNode   Brings the parent node reference. */
    4749    UITaskCloudAcquireInstances(const CCloudClient &comCloudClient, UIChooserNode *pParentNode);
    4850
Note: See TracChangeset for help on using the changeset viewer.

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