VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIExtension.cpp@ 93115

Last change on this file since 93115 was 93115, checked in by vboxsync, 2 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/* $Id: UIExtension.cpp 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIExtension namespace implementation.
4 */
5
6/*
7 * Copyright (C) 2006-2022 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/* GUI includes: */
19#include "UICommon.h"
20#include "UIExtension.h"
21#include "UINotificationCenter.h"
22#include "UIMessageCenter.h"
23#include "VBoxLicenseViewer.h"
24
25/* COM includes: */
26#include "CExtPack.h"
27
28
29void UIExtension::install(QString const &strFilePath,
30 QString const &strDigest,
31 QWidget *pParent,
32 QString *pstrExtPackName)
33{
34 /* If the extension pack manager isn't available, skip any attempts to install: */
35 CExtPackManager comExtPackManager = uiCommon().virtualBox().GetExtensionPackManager();
36 if (comExtPackManager.isNull())
37 return;
38 /* Open the extpack tarball via IExtPackManager: */
39 CExtPackFile comExtPackFile;
40 if (strDigest.isEmpty())
41 comExtPackFile = comExtPackManager.OpenExtPackFile(strFilePath);
42 else
43 {
44 QString strFileAndHash = QString("%1::SHA-256=%2").arg(strFilePath).arg(strDigest);
45 comExtPackFile = comExtPackManager.OpenExtPackFile(strFileAndHash);
46 }
47 if (!comExtPackManager.isOk())
48 {
49 UINotificationMessage::cannotOpenExtPack(comExtPackManager, strFilePath);
50 return;
51 }
52
53 if (!comExtPackFile.GetUsable())
54 {
55 UINotificationMessage::cannotOpenExtPackFile(comExtPackFile, strFilePath);
56 return;
57 }
58
59 const QString strPackName = comExtPackFile.GetName();
60 const QString strPackDescription = comExtPackFile.GetDescription();
61 const QString strPackVersion = QString("%1r%2%3").arg(comExtPackFile.GetVersion()).arg(comExtPackFile.GetRevision()).arg(comExtPackFile.GetEdition());
62
63 /* Check if there is a version of the extension pack already
64 * installed on the system and let the user decide what to do about it. */
65 CExtPack comExtPackCur = comExtPackManager.Find(strPackName);
66 bool fReplaceIt = comExtPackCur.isOk();
67 if (fReplaceIt)
68 {
69 QString strPackVersionCur = QString("%1r%2%3").arg(comExtPackCur.GetVersion()).arg(comExtPackCur.GetRevision()).arg(comExtPackCur.GetEdition());
70 if (!msgCenter().confirmReplaceExtensionPack(strPackName, strPackVersion, strPackVersionCur, strPackDescription, pParent))
71 return;
72 }
73 /* If it's a new package just ask for general confirmation. */
74 else
75 {
76 if (!msgCenter().confirmInstallExtensionPack(strPackName, strPackVersion, strPackDescription, pParent))
77 return;
78 }
79
80 /* Display the license dialog if required by the extension pack. */
81 if (comExtPackFile.GetShowLicense())
82 {
83 QString strLicense = comExtPackFile.GetLicense();
84 VBoxLicenseViewer licenseViewer(pParent);
85 if (licenseViewer.showLicenseFromString(strLicense) != QDialog::Accepted)
86 return;
87 }
88
89 /* Install the selected package.
90 * Set the package name return value before doing
91 * this as the caller should do a refresh even on failure. */
92 QString strDisplayInfo;
93#ifdef VBOX_WS_WIN
94 if (pParent)
95 strDisplayInfo.sprintf("hwnd=%#llx", (uint64_t)(uintptr_t)pParent->winId());
96#endif
97
98 /* Install extension pack: */
99 UINotificationProgressExtensionPackInstall *pNotification =
100 new UINotificationProgressExtensionPackInstall(comExtPackFile,
101 fReplaceIt,
102 strPackName,
103 strDisplayInfo);
104 QObject::connect(pNotification, &UINotificationProgressExtensionPackInstall::sigExtensionPackInstalled,
105 &uiCommon(), &UICommon::sigExtensionPackInstalled);
106 gpNotificationCenter->append(pNotification);
107
108 /* Store the name: */
109 if (pstrExtPackName)
110 *pstrExtPackName = strPackName;
111}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use