[48270] | 1 | /* $Id: UITaskCloudGetSettingsForm.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
[84020] | 3 | * VBox Qt GUI - UITaskCloudGetSettingsForm 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 |
|
---|
[84098] | 28 | /* Qt includes: */
|
---|
| 29 | #include <QWidget>
|
---|
| 30 |
|
---|
[48270] | 31 | /* GUI includes: */
|
---|
[84020] | 32 | #include "UICommon.h"
|
---|
[83111] | 33 | #include "UICloudNetworkingStuff.h"
|
---|
[91165] | 34 | #include "UINotificationCenter.h"
|
---|
[84020] | 35 | #include "UITaskCloudGetSettingsForm.h"
|
---|
| 36 | #include "UIThreadPool.h"
|
---|
[48270] | 37 |
|
---|
[83008] | 38 |
|
---|
[84020] | 39 | /*********************************************************************************************************************************
|
---|
| 40 | * Class UITaskCloudGetSettingsForm implementation. *
|
---|
| 41 | *********************************************************************************************************************************/
|
---|
| 42 |
|
---|
| 43 | UITaskCloudGetSettingsForm::UITaskCloudGetSettingsForm(const CCloudMachine &comCloudMachine)
|
---|
| 44 | : UITask(Type_CloudGetSettingsForm)
|
---|
| 45 | , m_comCloudMachine(comCloudMachine)
|
---|
[48270] | 46 | {
|
---|
| 47 | }
|
---|
[83008] | 48 |
|
---|
[84020] | 49 | CForm UITaskCloudGetSettingsForm::result() const
|
---|
[83008] | 50 | {
|
---|
| 51 | m_mutex.lock();
|
---|
[84020] | 52 | const CForm comResult = m_comResult;
|
---|
[83008] | 53 | m_mutex.unlock();
|
---|
[84020] | 54 | return comResult;
|
---|
[83008] | 55 | }
|
---|
| 56 |
|
---|
[84020] | 57 | QString UITaskCloudGetSettingsForm::errorInfo() const
|
---|
[83008] | 58 | {
|
---|
| 59 | m_mutex.lock();
|
---|
[83212] | 60 | QString strErrorInfo = m_strErrorInfo;
|
---|
[83008] | 61 | m_mutex.unlock();
|
---|
[83212] | 62 | return strErrorInfo;
|
---|
[83008] | 63 | }
|
---|
| 64 |
|
---|
[84020] | 65 | void UITaskCloudGetSettingsForm::run()
|
---|
[83008] | 66 | {
|
---|
| 67 | m_mutex.lock();
|
---|
[84020] | 68 | cloudMachineSettingsForm(m_comCloudMachine, m_comResult, m_strErrorInfo);
|
---|
[83008] | 69 | m_mutex.unlock();
|
---|
| 70 | }
|
---|
[84020] | 71 |
|
---|
| 72 |
|
---|
| 73 | /*********************************************************************************************************************************
|
---|
| 74 | * Class UIReceiverCloudGetSettingsForm implementation. *
|
---|
| 75 | *********************************************************************************************************************************/
|
---|
| 76 |
|
---|
[84098] | 77 | UIReceiverCloudGetSettingsForm::UIReceiverCloudGetSettingsForm(QWidget *pParent)
|
---|
[84020] | 78 | : QObject(pParent)
|
---|
[84098] | 79 | , m_pParent(pParent)
|
---|
[84020] | 80 | {
|
---|
| 81 | /* Connect receiver: */
|
---|
| 82 | connect(uiCommon().threadPoolCloud(), &UIThreadPool::sigTaskComplete,
|
---|
| 83 | this, &UIReceiverCloudGetSettingsForm::sltHandleTaskComplete);
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | void UIReceiverCloudGetSettingsForm::sltHandleTaskComplete(UITask *pTask)
|
---|
| 87 | {
|
---|
| 88 | /* Skip unrelated tasks: */
|
---|
| 89 | if (!pTask || pTask->type() != UITask::Type_CloudGetSettingsForm)
|
---|
| 90 | return;
|
---|
| 91 |
|
---|
| 92 | /* Cast task to corresponding sub-class: */
|
---|
| 93 | UITaskCloudGetSettingsForm *pSettingsTask = static_cast<UITaskCloudGetSettingsForm*>(pTask);
|
---|
| 94 |
|
---|
| 95 | /* Redirect to another listeners: */
|
---|
[84098] | 96 | if (pSettingsTask->errorInfo().isNull())
|
---|
| 97 | emit sigTaskComplete(pSettingsTask->result());
|
---|
| 98 | else
|
---|
| 99 | {
|
---|
[91165] | 100 | UINotificationMessage::cannotAcquireCloudMachineSettings(pSettingsTask->errorInfo());
|
---|
[84098] | 101 | emit sigTaskFailed(pSettingsTask->errorInfo());
|
---|
| 102 | }
|
---|
[84020] | 103 | }
|
---|