VirtualBox

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

Last change on this file since 99186 was 99186, checked in by vboxsync, 15 months ago

FE/Qt: bugref:9653: VirtualBox Manager: While handling cloud related async tasks we need to check whether progress was initially NULL because cloud client can be NULL as well.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1/* $Id: UIProgressTaskReadCloudMachineList.cpp 99186 2023-03-27 15:09:34Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIProgressTaskReadCloudMachineList class implementation.
4 */
5
6/*
7 * Copyright (C) 2020-2023 Oracle and/or its affiliates.
8 *
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
26 */
27
28/* GUI includes: */
29#include "UICloudNetworkingStuff.h"
30#include "UIErrorString.h"
31#include "UIProgressTaskReadCloudMachineList.h"
32
33
34UIProgressTaskReadCloudMachineList::UIProgressTaskReadCloudMachineList(QObject *pParent,
35 const UICloudEntityKey &guiCloudProfileKey,
36 bool fWithRefresh)
37 : UIProgressTask(pParent)
38 , m_guiCloudProfileKey(guiCloudProfileKey)
39 , m_fWithRefresh(fWithRefresh)
40{
41}
42
43UICloudEntityKey UIProgressTaskReadCloudMachineList::cloudProfileKey() const
44{
45 return m_guiCloudProfileKey;
46}
47
48QVector<CCloudMachine> UIProgressTaskReadCloudMachineList::machines() const
49{
50 return m_machines;
51}
52
53QString UIProgressTaskReadCloudMachineList::errorMessage() const
54{
55 return m_strErrorMessage;
56}
57
58CProgress UIProgressTaskReadCloudMachineList::createProgress()
59{
60 /* Create cloud client: */
61 m_comCloudClient = cloudClientByName(m_guiCloudProfileKey.m_strProviderShortName,
62 m_guiCloudProfileKey.m_strProfileName,
63 m_strErrorMessage);
64 if (m_comCloudClient.isNull())
65 return CProgress();
66
67 /* Initialize progress-wrapper: */
68 CProgress comProgress = m_fWithRefresh
69 ? m_comCloudClient.ReadCloudMachineList()
70 : m_comCloudClient.ReadCloudMachineStubList();
71 if (!m_comCloudClient.isOk())
72 {
73 m_strErrorMessage = UIErrorString::formatErrorInfo(m_comCloudClient);
74 return CProgress();
75 }
76
77 /* Return progress-wrapper: */
78 return comProgress;
79}
80
81void UIProgressTaskReadCloudMachineList::handleProgressFinished(CProgress &comProgress)
82{
83 /* Handle progress-wrapper errors: */
84 if (comProgress.isNotNull() && !comProgress.GetCanceled() && (!comProgress.isOk() || comProgress.GetResultCode() != 0))
85 {
86 m_strErrorMessage = UIErrorString::formatErrorInfo(comProgress);
87 return;
88 }
89
90 /* Fill the result: */
91 m_machines = m_fWithRefresh
92 ? m_comCloudClient.GetCloudMachineList()
93 : m_comCloudClient.GetCloudMachineStubList();
94 if (!m_comCloudClient.isOk())
95 m_strErrorMessage = UIErrorString::formatErrorInfo(m_comCloudClient);
96}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use