[90290] | 1 | /* $Id: UINotificationProgressTask.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * VBox Qt GUI - UINotificationProgressTask class implementation.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2021-2023 Oracle and/or its affiliates.
|
---|
[90290] | 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
|
---|
[90290] | 26 | */
|
---|
| 27 |
|
---|
| 28 | /* GUI includes: */
|
---|
| 29 | #include "UIErrorString.h"
|
---|
| 30 | #include "UINotificationObject.h"
|
---|
| 31 | #include "UINotificationProgressTask.h"
|
---|
| 32 |
|
---|
| 33 |
|
---|
| 34 | UINotificationProgressTask::UINotificationProgressTask(UINotificationProgress *pParent)
|
---|
| 35 | : UIProgressTask(pParent)
|
---|
| 36 | , m_pParent(pParent)
|
---|
| 37 | {
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | QString UINotificationProgressTask::errorMessage() const
|
---|
| 41 | {
|
---|
| 42 | return m_strErrorMessage;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | CProgress UINotificationProgressTask::createProgress()
|
---|
| 46 | {
|
---|
| 47 | /* Call to sub-class to create progress-wrapper: */
|
---|
| 48 | COMResult comResult;
|
---|
| 49 | CProgress comProgress = m_pParent->createProgress(comResult);
|
---|
| 50 | if (!comResult.isOk())
|
---|
| 51 | {
|
---|
| 52 | m_strErrorMessage = UIErrorString::formatErrorInfo(comResult);
|
---|
| 53 | return CProgress();
|
---|
| 54 | }
|
---|
| 55 | /* Return progress-wrapper: */
|
---|
| 56 | return comProgress;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | void UINotificationProgressTask::handleProgressFinished(CProgress &comProgress)
|
---|
| 60 | {
|
---|
| 61 | /* Handle progress-wrapper errors: */
|
---|
[90476] | 62 | if (comProgress.isNotNull() && !comProgress.GetCanceled() && (!comProgress.isOk() || comProgress.GetResultCode() != 0))
|
---|
[90290] | 63 | m_strErrorMessage = UIErrorString::formatErrorInfo(comProgress);
|
---|
| 64 | }
|
---|