- Timestamp:
- Mar 22, 2018 10:58:10 AM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.cpp
r71447 r71448 30 30 # include "QIProcess.h" 31 31 # include "VBoxGlobal.h" 32 # include "VBoxLicenseViewer.h" 32 33 # include "VBoxUtils.h" 33 34 # include "UIDownloaderExtensionPack.h" 34 35 # include "UIExtraDataManager.h" 35 # include "UIGlobalSettingsExtension.h"36 36 # include "UIMessageCenter.h" 37 37 # include "UIModalWindowManager.h" … … 44 44 /* COM includes: */ 45 45 # include "CExtPack.h" 46 # include "CExtPackFile.h" 46 47 # include "CExtPackManager.h" 48 # include "CSystemProperties.h" 47 49 48 50 /* Other VBox includes: */ … … 490 492 /* Warn the user about extension pack was downloaded and saved, propose to install it: */ 491 493 if (msgCenter().proposeInstallExtentionPack(GUI_ExtPackName, strSource, QDir::toNativeSeparators(strTarget))) 492 UI GlobalSettingsExtension::doInstallation(strTarget, strDigest, windowManager().networkManagerOrMainWindowShown(), 0);494 UIUpdateManager::doExtPackInstallation(strTarget, strDigest, windowManager().networkManagerOrMainWindowShown(), NULL); 493 495 /* Propose to delete the downloaded extension pack: */ 494 496 if (msgCenter().proposeDeleteExtentionPack(QDir::toNativeSeparators(strTarget))) … … 570 572 } 571 573 574 /* static */ 575 void UIUpdateManager::doExtPackInstallation(QString const &strFilePath, QString const &strDigest, 576 QWidget *pParent, QString *pstrExtPackName) 577 { 578 /* Open the extpack tarball via IExtPackManager: */ 579 CExtPackManager comManager = vboxGlobal().virtualBox().GetExtensionPackManager(); 580 CExtPackFile comExtPackFile; 581 if (strDigest.isEmpty()) 582 comExtPackFile = comManager.OpenExtPackFile(strFilePath); 583 else 584 { 585 QString strFileAndHash = QString("%1::SHA-256=%2").arg(strFilePath).arg(strDigest); 586 comExtPackFile = comManager.OpenExtPackFile(strFileAndHash); 587 } 588 if (!comManager.isOk()) 589 { 590 msgCenter().cannotOpenExtPack(strFilePath, comManager, pParent); 591 return; 592 } 593 594 if (!comExtPackFile.GetUsable()) 595 { 596 msgCenter().warnAboutBadExtPackFile(strFilePath, comExtPackFile, pParent); 597 return; 598 } 599 600 const QString strPackName = comExtPackFile.GetName(); 601 const QString strPackDescription = comExtPackFile.GetDescription(); 602 const QString strPackVersion = QString("%1r%2%3").arg(comExtPackFile.GetVersion()).arg(comExtPackFile.GetRevision()).arg(comExtPackFile.GetEdition()); 603 604 /* Check if there is a version of the extension pack already 605 * installed on the system and let the user decide what to do about it. */ 606 CExtPack comExtPackCur = comManager.Find(strPackName); 607 bool fReplaceIt = comExtPackCur.isOk(); 608 if (fReplaceIt) 609 { 610 QString strPackVersionCur = QString("%1r%2%3").arg(comExtPackCur.GetVersion()).arg(comExtPackCur.GetRevision()).arg(comExtPackCur.GetEdition()); 611 if (!msgCenter().confirmReplaceExtensionPack(strPackName, strPackVersion, strPackVersionCur, strPackDescription, pParent)) 612 return; 613 } 614 /* If it's a new package just ask for general confirmation. */ 615 else 616 { 617 if (!msgCenter().confirmInstallExtensionPack(strPackName, strPackVersion, strPackDescription, pParent)) 618 return; 619 } 620 621 /* Display the license dialog if required by the extension pack. */ 622 if (comExtPackFile.GetShowLicense()) 623 { 624 QString strLicense = comExtPackFile.GetLicense(); 625 VBoxLicenseViewer licenseViewer(pParent); 626 if (licenseViewer.showLicenseFromString(strLicense) != QDialog::Accepted) 627 return; 628 } 629 630 /* Install the selected package. 631 * Set the package name return value before doing 632 * this as the caller should do a refresh even on failure. */ 633 QString strDisplayInfo; 634 #ifdef VBOX_WS_WIN 635 if (pParent) 636 strDisplayInfo.sprintf("hwnd=%#llx", (uint64_t)(uintptr_t)pParent->winId()); 637 #endif 638 /* Prepare installation progress: */ 639 CProgress comProgress = comExtPackFile.Install(fReplaceIt, strDisplayInfo); 640 if (comExtPackFile.isOk()) 641 { 642 /* Show installation progress: */ 643 /** @todo move this tr into UIUpdateManager context */ 644 msgCenter().showModalProgressDialog(comProgress, QApplication::translate("UIGlobalSettingsExtension", 645 "Extensions"), 646 ":/progress_install_guest_additions_90px.png", pParent); 647 if (!comProgress.GetCanceled()) 648 { 649 if (comProgress.isOk() && comProgress.GetResultCode() == 0) 650 msgCenter().warnAboutExtPackInstalled(strPackName, pParent); 651 else 652 msgCenter().cannotInstallExtPack(comProgress, strFilePath, pParent); 653 } 654 } 655 else 656 msgCenter().cannotInstallExtPack(comExtPackFile, strFilePath, pParent); 657 658 if (pstrExtPackName) 659 *pstrExtPackName = strPackName; 660 } 661 572 662 void UIUpdateManager::sltForceCheck() 573 663 { -
trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.h
r71447 r71448 45 45 static UIUpdateManager *instance() { return s_pInstance; } 46 46 47 /** Initiates the extension pack installation process. 48 * @param strFilePath Brings the extension pack file path. 49 * @param strDigest Brings the extension pack file digest. 50 * @param pParent Brings the parent dialog reference. 51 * @param pstrExtPackName Brings the extension pack name. */ 52 static void doExtPackInstallation(QString const &strFilePath, 53 QString const &strDigest, 54 QWidget *pParent, 55 QString *pstrExtPackName); 56 47 57 public slots: 48 58 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsExtension.cpp
r71355 r71448 26 26 /* GUI includes: */ 27 27 # include "QIFileDialog.h" 28 # include "VBoxGlobal.h" 28 29 # include "UIGlobalSettingsExtension.h" 29 30 # include "UIIconPool.h" 30 31 # include "UIMessageCenter.h" 31 # include "VBoxGlobal.h" 32 # include "VBoxLicenseViewer.h" 32 # include "UIUpdateManager.h" 33 33 34 34 /* COM includes: */ 35 35 # include "CExtPack.h" 36 # include "CExtPackFile.h"37 36 # include "CExtPackManager.h" 38 37 … … 185 184 } 186 185 187 /* static */188 void UIGlobalSettingsExtension::doInstallation(QString const &strFilePath, QString const &strDigest,189 QWidget *pParent, QString *pstrExtPackName)190 {191 /* Open the extpack tarball via IExtPackManager: */192 CExtPackManager manager = vboxGlobal().virtualBox().GetExtensionPackManager();193 CExtPackFile extPackFile;194 if (strDigest.isEmpty())195 extPackFile = manager.OpenExtPackFile(strFilePath);196 else197 {198 QString strFileAndHash = QString("%1::SHA-256=%2").arg(strFilePath).arg(strDigest);199 extPackFile = manager.OpenExtPackFile(strFileAndHash);200 }201 if (!manager.isOk())202 {203 msgCenter().cannotOpenExtPack(strFilePath, manager, pParent);204 return;205 }206 207 if (!extPackFile.GetUsable())208 {209 msgCenter().warnAboutBadExtPackFile(strFilePath, extPackFile, pParent);210 return;211 }212 213 const QString strPackName = extPackFile.GetName();214 const QString strPackDescription = extPackFile.GetDescription();215 const QString strPackVersion = QString("%1r%2%3").arg(extPackFile.GetVersion()).arg(extPackFile.GetRevision()).arg(extPackFile.GetEdition());216 217 /* Check if there is a version of the extension pack already218 * installed on the system and let the user decide what to do about it. */219 CExtPack extPackCur = manager.Find(strPackName);220 bool fReplaceIt = extPackCur.isOk();221 if (fReplaceIt)222 {223 QString strPackVersionCur = QString("%1r%2%3").arg(extPackCur.GetVersion()).arg(extPackCur.GetRevision()).arg(extPackCur.GetEdition());224 if (!msgCenter().confirmReplaceExtensionPack(strPackName, strPackVersion, strPackVersionCur, strPackDescription, pParent))225 return;226 }227 /* If it's a new package just ask for general confirmation. */228 else229 {230 if (!msgCenter().confirmInstallExtensionPack(strPackName, strPackVersion, strPackDescription, pParent))231 return;232 }233 234 /* Display the license dialog if required by the extension pack. */235 if (extPackFile.GetShowLicense())236 {237 QString strLicense = extPackFile.GetLicense();238 VBoxLicenseViewer licenseViewer(pParent);239 if (licenseViewer.showLicenseFromString(strLicense) != QDialog::Accepted)240 return;241 }242 243 /* Install the selected package.244 * Set the package name return value before doing245 * this as the caller should do a refresh even on failure. */246 QString displayInfo;247 #ifdef VBOX_WS_WIN248 if (pParent)249 displayInfo.sprintf("hwnd=%#llx", (uint64_t)(uintptr_t)pParent->winId());250 #endif251 /* Prepare installation progress: */252 CProgress progress = extPackFile.Install(fReplaceIt, displayInfo);253 if (extPackFile.isOk())254 {255 /* Show installation progress: */256 msgCenter().showModalProgressDialog(progress, tr("Extensions"), ":/progress_install_guest_additions_90px.png", pParent);257 if (!progress.GetCanceled())258 {259 if (progress.isOk() && progress.GetResultCode() == 0)260 msgCenter().warnAboutExtPackInstalled(strPackName, pParent);261 else262 msgCenter().cannotInstallExtPack(progress, strFilePath, pParent);263 }264 }265 else266 msgCenter().cannotInstallExtPack(extPackFile, strFilePath, pParent);267 268 if (pstrExtPackName)269 *pstrExtPackName = strPackName;270 }271 272 186 void UIGlobalSettingsExtension::loadToCacheFrom(QVariant &data) 273 187 { … … 394 308 { 395 309 QString strExtPackName; 396 doInstallation(strFilePath, QString(), this, &strExtPackName);310 UIUpdateManager::doExtPackInstallation(strFilePath, QString(), this, &strExtPackName); 397 311 398 312 /* Since we might be reinstalling an existing package, we have to -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsExtension.h
r71027 r71448 41 41 /** Destructs Extension settings page. */ 42 42 ~UIGlobalSettingsExtension(); 43 44 /** Initiates the extension pack installation process.45 * @param strFilePath Brings the extension pack file path.46 * @param strDigest Brings the extension pack file digest.47 * @param pParent Brings the parent dialog reference.48 * @param pstrExtPackName Brings the extension pack name. */49 static void doInstallation(QString const &strFilePath, QString const &strDigest, QWidget *pParent, QString *pstrExtPackName);50 43 51 44 protected:
Note:
See TracChangeset
for help on using the changeset viewer.