VirtualBox

Changeset 89972 in vbox


Ignore:
Timestamp:
Jun 30, 2021 10:28:16 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9996: Extending UICloudNetworkingStuff with API to aquire cloud images and source boot volumes; Using that stuff from New Cloud VM wizard.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
3 edited

Legend:

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

    r86738 r89972  
    399399        return true;
    400400    }
     401    return false;
     402}
     403
     404bool UICloudNetworkingStuff::listCloudImages(const CCloudClient &comCloudClient,
     405                                             CStringArray &comNames,
     406                                             CStringArray &comIDs,
     407                                             QWidget *pParent /* = 0 */)
     408{
     409    /* Currently we are interested in Available images only: */
     410    const QVector<KCloudImageState> cloudImageStates  = QVector<KCloudImageState>()
     411                                                     << KCloudImageState_Available;
     412    /* Execute ListImages async method: */
     413    CProgress comProgress = comCloudClient.ListImages(cloudImageStates, comNames, comIDs);
     414    if (!comCloudClient.isOk())
     415        msgCenter().cannotAcquireCloudClientParameter(comCloudClient, pParent);
     416    else
     417    {
     418        /* Show "Acquire cloud images" progress: */
     419        msgCenter().showModalProgressDialog(comProgress,
     420                                            QString(),
     421                                            ":/progress_reading_appliance_90px.png", pParent, 0);
     422        if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     423            msgCenter().cannotAcquireCloudClientParameter(comProgress, pParent);
     424        else
     425            return true;
     426    }
     427    /* Return false by default: */
     428    return false;
     429}
     430
     431bool UICloudNetworkingStuff::listCloudImages(const CCloudClient &comCloudClient,
     432                                             CStringArray &comNames,
     433                                             CStringArray &comIDs,
     434                                             QString &strErrorMessage)
     435{
     436    /* Currently we are interested in Available images only: */
     437    const QVector<KCloudImageState> cloudImageStates  = QVector<KCloudImageState>()
     438                                                     << KCloudImageState_Available;
     439    /* Execute ListImages async method: */
     440    CProgress comProgress = comCloudClient.ListImages(cloudImageStates, comNames, comIDs);
     441    if (!comCloudClient.isOk())
     442        strErrorMessage = UIErrorString::formatErrorInfo(comCloudClient);
     443    else
     444    {
     445        /* Wait for "Acquire cloud images" progress: */
     446        comProgress.WaitForCompletion(-1);
     447        if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     448            strErrorMessage = UIErrorString::formatErrorInfo(comProgress);
     449        else
     450            return true;
     451    }
     452    /* Return false by default: */
     453    return false;
     454}
     455
     456bool UICloudNetworkingStuff::listCloudSourceBootVolumes(const CCloudClient &comCloudClient,
     457                                                        CStringArray &comNames,
     458                                                        CStringArray &comIDs,
     459                                                        QWidget *pParent /* = 0 */)
     460{
     461    /* Execute ListSourceBootVolumes async method: */
     462    CProgress comProgress = comCloudClient.ListSourceBootVolumes(comNames, comIDs);
     463    if (!comCloudClient.isOk())
     464        msgCenter().cannotAcquireCloudClientParameter(comCloudClient, pParent);
     465    else
     466    {
     467        /* Show "Acquire cloud source boot volumes" progress: */
     468        msgCenter().showModalProgressDialog(comProgress,
     469                                            QString(),
     470                                            ":/progress_reading_appliance_90px.png", pParent, 0);
     471        if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     472            msgCenter().cannotAcquireCloudClientParameter(comProgress, pParent);
     473        else
     474            return true;
     475    }
     476    /* Return false by default: */
     477    return false;
     478}
     479
     480bool UICloudNetworkingStuff::listCloudSourceBootVolumes(const CCloudClient &comCloudClient,
     481                                                        CStringArray &comNames,
     482                                                        CStringArray &comIDs,
     483                                                        QString &strErrorMessage)
     484{
     485    /* Execute ListSourceBootVolumes async method: */
     486    CProgress comProgress = comCloudClient.ListSourceBootVolumes(comNames, comIDs);
     487    if (!comCloudClient.isOk())
     488        strErrorMessage = UIErrorString::formatErrorInfo(comCloudClient);
     489    else
     490    {
     491        /* Wait for "Acquire cloud source boot volumes" progress: */
     492        comProgress.WaitForCompletion(-1);
     493        if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
     494            strErrorMessage = UIErrorString::formatErrorInfo(comProgress);
     495        else
     496            return true;
     497    }
     498    /* Return false by default: */
    401499    return false;
    402500}
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICloudNetworkingStuff.h

    r86738 r89972  
    126126                                                     QVector<QString> &values,
    127127                                                     QWidget *pParent = 0);
     128
     129    /** Acquires cloud images of certain @a comCloudClient, using @a pParent to show messages according to. */
     130    SHARED_LIBRARY_STUFF bool listCloudImages(const CCloudClient &comCloudClient,
     131                                              CStringArray &comNames,
     132                                              CStringArray &comIDs,
     133                                              QWidget *pParent = 0);
     134    /** Acquires cloud images of certain @a comCloudClient, using @a strErrorMessage to store messages to. */
     135    SHARED_LIBRARY_STUFF bool listCloudImages(const CCloudClient &comCloudClient,
     136                                              CStringArray &comNames,
     137                                              CStringArray &comIDs,
     138                                              QString &strErrorMessage);
     139    /** Acquires cloud source boot volumes of certain @a comCloudClient, using @a pParent to show messages according to. */
     140    SHARED_LIBRARY_STUFF bool listCloudSourceBootVolumes(const CCloudClient &comCloudClient,
     141                                                         CStringArray &comNames,
     142                                                         CStringArray &comIDs,
     143                                                         QWidget *pParent = 0);
     144    /** Acquires cloud source boot volumes of certain @a comCloudClient, using @a strErrorMessage to store messages to. */
     145    SHARED_LIBRARY_STUFF bool listCloudSourceBootVolumes(const CCloudClient &comCloudClient,
     146                                                         CStringArray &comNames,
     147                                                         CStringArray &comIDs,
     148                                                         QString &strErrorMessage);
    128149
    129150    /** Acquires cloud machines of certain @a comCloudClient, using @a pParent to show messages according to. */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newcloudvm/UIWizardNewCloudVMPageBasic1.cpp

    r88103 r89972  
    2929#include "QIRichTextLabel.h"
    3030#include "QIToolButton.h"
     31#include "UICloudNetworkingStuff.h"
    3132#include "UIIconPool.h"
    3233#include "UIMessageCenter.h"
     
    232233            CStringArray comNames;
    233234            CStringArray comIDs;
    234             CProgress comProgress;
     235            bool fResult = false;
    235236            switch (m_pSourceTabBar->currentIndex())
    236237            {
    237                 case 0:
     238                /* Ask for cloud images, currently we are interested in Available images only: */
     239                case 0: fResult = listCloudImages(comCloudClient, comNames, comIDs, wizardImp()); break;
     240                /* Ask for cloud boot-volumes, currently we are interested in Source boot-volumes only: */
     241                case 1: fResult = listCloudSourceBootVolumes(comCloudClient, comNames, comIDs, wizardImp()); break;
     242                default: break;
     243            }
     244
     245            /* Push acquired names to list rows: */
     246            if (fResult)
     247            {
     248                const QVector<QString> names = comNames.GetValues();
     249                const QVector<QString> ids = comIDs.GetValues();
     250                for (int i = 0; i < names.size(); ++i)
    238251                {
    239                     /* Ask for cloud images, currently we are interested in Available images only: */
    240                     const QVector<KCloudImageState> cloudImageStates  = QVector<KCloudImageState>()
    241                                                                      << KCloudImageState_Available;
    242                     comProgress = comCloudClient.ListImages(cloudImageStates, comNames, comIDs);
    243                     break;
    244                 }
    245                 case 1:
    246                 {
    247                     /* Ask for cloud boot-volumes, currently we are interested in Source boot-volumes only: */
    248                     comProgress = comCloudClient.ListSourceBootVolumes(comNames, comIDs);
    249                     break;
    250                 }
    251                 default:
    252                     break;
    253             }
    254             if (!comCloudClient.isOk())
    255             {
    256                 msgCenter().cannotAcquireCloudClientParameter(comCloudClient);
    257                 break;
    258             }
    259 
    260             /* Show "Acquire cloud images" progress: */
    261             msgCenter().showModalProgressDialog(comProgress, QString(),
    262                                                 ":/progress_reading_appliance_90px.png", 0, 0);
    263             if (comProgress.GetCanceled())
    264             {
    265                 wizardImp()->reject();
    266                 break;
    267             }
    268             if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    269             {
    270                 msgCenter().cannotAcquireCloudClientParameter(comProgress);
    271                 break;
    272             }
    273 
    274             /* Push acquired names to list rows: */
    275             const QVector<QString> names = comNames.GetValues();
    276             const QVector<QString> ids = comIDs.GetValues();
    277             for (int i = 0; i < names.size(); ++i)
    278             {
    279                 /* Create list item: */
    280                 QListWidgetItem *pItem = new QListWidgetItem(names.at(i), m_pSourceImageList);
    281                 if (pItem)
    282                 {
    283                     pItem->setFlags(pItem->flags() & ~Qt::ItemIsEditable);
    284                     pItem->setData(Qt::UserRole, ids.at(i));
     252                    /* Create list item: */
     253                    QListWidgetItem *pItem = new QListWidgetItem(names.at(i), m_pSourceImageList);
     254                    if (pItem)
     255                    {
     256                        pItem->setFlags(pItem->flags() & ~Qt::ItemIsEditable);
     257                        pItem->setData(Qt::UserRole, ids.at(i));
     258                    }
    285259                }
    286260            }
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