VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/manager/UIProgressTaskReadCloudMachineList.cpp

Last change on this file was 99187, checked in by vboxsync, 18 months ago

FE/Qt: bugref:9653: VirtualBox Manager: While handling cloud machine list read async task we need to check for error-message from initial step, because progress can be initially NULL.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
RevLine 
[48270]1/* $Id: UIProgressTaskReadCloudMachineList.cpp 99187 2023-03-27 15:11:13Z vboxsync $ */
2/** @file
[86795]3 * VBox Qt GUI - UIProgressTaskReadCloudMachineList class implementation.
[48270]4 */
5
6/*
[98103]7 * Copyright (C) 2020-2023 Oracle and/or its affiliates.
[48270]8 *
[96407]9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
[48270]26 */
27
28/* GUI includes: */
[83111]29#include "UICloudNetworkingStuff.h"
[86910]30#include "UIErrorString.h"
[86795]31#include "UIProgressTaskReadCloudMachineList.h"
[48270]32
[83008]33
[86795]34UIProgressTaskReadCloudMachineList::UIProgressTaskReadCloudMachineList(QObject *pParent,
35 const UICloudEntityKey &guiCloudProfileKey,
36 bool fWithRefresh)
37 : UIProgressTask(pParent)
38 , m_guiCloudProfileKey(guiCloudProfileKey)
[86609]39 , m_fWithRefresh(fWithRefresh)
[48270]40{
41}
[83008]42
[86795]43UICloudEntityKey UIProgressTaskReadCloudMachineList::cloudProfileKey() const
[83008]44{
[86795]45 return m_guiCloudProfileKey;
[83008]46}
47
[86795]48QVector<CCloudMachine> UIProgressTaskReadCloudMachineList::machines() const
[83008]49{
[86795]50 return m_machines;
[83008]51}
52
[86910]53QString UIProgressTaskReadCloudMachineList::errorMessage() const
54{
55 return m_strErrorMessage;
56}
57
[86795]58CProgress UIProgressTaskReadCloudMachineList::createProgress()
[83008]59{
[86795]60 /* Create cloud client: */
61 m_comCloudClient = cloudClientByName(m_guiCloudProfileKey.m_strProviderShortName,
[86910]62 m_guiCloudProfileKey.m_strProfileName,
63 m_strErrorMessage);
64 if (m_comCloudClient.isNull())
65 return CProgress();
[86795]66
[86910]67 /* Initialize progress-wrapper: */
68 CProgress comProgress = m_fWithRefresh
69 ? m_comCloudClient.ReadCloudMachineList()
70 : m_comCloudClient.ReadCloudMachineStubList();
71 if (!m_comCloudClient.isOk())
[86795]72 {
[86910]73 m_strErrorMessage = UIErrorString::formatErrorInfo(m_comCloudClient);
74 return CProgress();
[86795]75 }
76
[86910]77 /* Return progress-wrapper: */
78 return comProgress;
[83008]79}
[86795]80
81void UIProgressTaskReadCloudMachineList::handleProgressFinished(CProgress &comProgress)
82{
[99187]83 /* Check if we already have error-mesage: */
84 if (!m_strErrorMessage.isEmpty())
85 return;
86
[86795]87 /* Handle progress-wrapper errors: */
[99186]88 if (comProgress.isNotNull() && !comProgress.GetCanceled() && (!comProgress.isOk() || comProgress.GetResultCode() != 0))
[86795]89 {
[86910]90 m_strErrorMessage = UIErrorString::formatErrorInfo(comProgress);
91 return;
[86795]92 }
[86910]93
94 /* Fill the result: */
95 m_machines = m_fWithRefresh
96 ? m_comCloudClient.GetCloudMachineList()
97 : m_comCloudClient.GetCloudMachineStubList();
98 if (!m_comCloudClient.isOk())
99 m_strErrorMessage = UIErrorString::formatErrorInfo(m_comCloudClient);
[86795]100}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle
ContactPrivacy/Do Not Sell My InfoTerms of Use