VirtualBox

Changeset 71461 in vbox for trunk/src


Ignore:
Timestamp:
Mar 22, 2018 3:07:08 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9049: Reworking r121417 as update manager is not always part of application, had to move the code to VBoxGlobal.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r71371 r71461  
    8686
    8787/* COM includes: */
     88# include "CExtPack.h"
     89# include "CExtPackFile.h"
     90# include "CExtPackManager.h"
    8891# include "CMachine.h"
    8992# include "CSystemProperties.h"
     
    34413444#endif /* VBOX_WS_X11 */
    34423445
     3446/* static */
     3447void VBoxGlobal::doExtPackInstallation(QString const &strFilePath, QString const &strDigest,
     3448                                       QWidget *pParent, QString *pstrExtPackName)
     3449{
     3450    /* Open the extpack tarball via IExtPackManager: */
     3451    CExtPackManager comManager = vboxGlobal().virtualBox().GetExtensionPackManager();
     3452    CExtPackFile comExtPackFile;
     3453    if (strDigest.isEmpty())
     3454        comExtPackFile = comManager.OpenExtPackFile(strFilePath);
     3455    else
     3456    {
     3457        QString strFileAndHash = QString("%1::SHA-256=%2").arg(strFilePath).arg(strDigest);
     3458        comExtPackFile = comManager.OpenExtPackFile(strFileAndHash);
     3459    }
     3460    if (!comManager.isOk())
     3461    {
     3462        msgCenter().cannotOpenExtPack(strFilePath, comManager, pParent);
     3463        return;
     3464    }
     3465
     3466    if (!comExtPackFile.GetUsable())
     3467    {
     3468        msgCenter().warnAboutBadExtPackFile(strFilePath, comExtPackFile, pParent);
     3469        return;
     3470    }
     3471
     3472    const QString strPackName = comExtPackFile.GetName();
     3473    const QString strPackDescription = comExtPackFile.GetDescription();
     3474    const QString strPackVersion = QString("%1r%2%3").arg(comExtPackFile.GetVersion()).arg(comExtPackFile.GetRevision()).arg(comExtPackFile.GetEdition());
     3475
     3476    /* Check if there is a version of the extension pack already
     3477     * installed on the system and let the user decide what to do about it. */
     3478    CExtPack comExtPackCur = comManager.Find(strPackName);
     3479    bool fReplaceIt = comExtPackCur.isOk();
     3480    if (fReplaceIt)
     3481    {
     3482        QString strPackVersionCur = QString("%1r%2%3").arg(comExtPackCur.GetVersion()).arg(comExtPackCur.GetRevision()).arg(comExtPackCur.GetEdition());
     3483        if (!msgCenter().confirmReplaceExtensionPack(strPackName, strPackVersion, strPackVersionCur, strPackDescription, pParent))
     3484            return;
     3485    }
     3486    /* If it's a new package just ask for general confirmation. */
     3487    else
     3488    {
     3489        if (!msgCenter().confirmInstallExtensionPack(strPackName, strPackVersion, strPackDescription, pParent))
     3490            return;
     3491    }
     3492
     3493    /* Display the license dialog if required by the extension pack. */
     3494    if (comExtPackFile.GetShowLicense())
     3495    {
     3496        QString strLicense = comExtPackFile.GetLicense();
     3497        VBoxLicenseViewer licenseViewer(pParent);
     3498        if (licenseViewer.showLicenseFromString(strLicense) != QDialog::Accepted)
     3499            return;
     3500    }
     3501
     3502    /* Install the selected package.
     3503     * Set the package name return value before doing
     3504     * this as the caller should do a refresh even on failure. */
     3505    QString strDisplayInfo;
     3506#ifdef VBOX_WS_WIN
     3507    if (pParent)
     3508        strDisplayInfo.sprintf("hwnd=%#llx", (uint64_t)(uintptr_t)pParent->winId());
     3509#endif
     3510    /* Prepare installation progress: */
     3511    CProgress comProgress = comExtPackFile.Install(fReplaceIt, strDisplayInfo);
     3512    if (comExtPackFile.isOk())
     3513    {
     3514        /* Show installation progress: */
     3515        /** @todo move this tr into UIUpdateManager context */
     3516        msgCenter().showModalProgressDialog(comProgress, QApplication::translate("UIGlobalSettingsExtension",
     3517                                                                              "Extensions"),
     3518                                            ":/progress_install_guest_additions_90px.png", pParent);
     3519        if (!comProgress.GetCanceled())
     3520        {
     3521            if (comProgress.isOk() && comProgress.GetResultCode() == 0)
     3522                msgCenter().warnAboutExtPackInstalled(strPackName, pParent);
     3523            else
     3524                msgCenter().cannotInstallExtPack(comProgress, strFilePath, pParent);
     3525        }
     3526    }
     3527    else
     3528        msgCenter().cannotInstallExtPack(comExtPackFile, strFilePath, pParent);
     3529
     3530    if (pstrExtPackName)
     3531        *pstrExtPackName = strPackName;
     3532}
     3533
    34433534// Public slots
    34443535////////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r71371 r71461  
    444444    static void setWMClass(QWidget *pWidget, const QString &strNameString, const QString &strClassString);
    445445#endif
     446
     447    /** Initiates the extension pack installation process.
     448      * @param  strFilePath      Brings the extension pack file path.
     449      * @param  strDigest        Brings the extension pack file digest.
     450      * @param  pParent          Brings the parent dialog reference.
     451      * @param  pstrExtPackName  Brings the extension pack name. */
     452    static void doExtPackInstallation(QString const &strFilePath,
     453                                      QString const &strDigest,
     454                                      QWidget *pParent,
     455                                      QString *pstrExtPackName);
    446456
    447457signals:
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.cpp

    r71448 r71461  
    4444/* COM includes: */
    4545# include "CExtPack.h"
    46 # include "CExtPackFile.h"
    4746# include "CExtPackManager.h"
    4847# include "CSystemProperties.h"
     
    492491    /* Warn the user about extension pack was downloaded and saved, propose to install it: */
    493492    if (msgCenter().proposeInstallExtentionPack(GUI_ExtPackName, strSource, QDir::toNativeSeparators(strTarget)))
    494         UIUpdateManager::doExtPackInstallation(strTarget, strDigest, windowManager().networkManagerOrMainWindowShown(), NULL);
     493        VBoxGlobal::doExtPackInstallation(strTarget, strDigest, windowManager().networkManagerOrMainWindowShown(), NULL);
    495494    /* Propose to delete the downloaded extension pack: */
    496495    if (msgCenter().proposeDeleteExtentionPack(QDir::toNativeSeparators(strTarget)))
     
    572571}
    573572
    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 
    662573void UIUpdateManager::sltForceCheck()
    663574{
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.h

    r71448 r71461  
    4545    static UIUpdateManager *instance() { return s_pInstance; }
    4646
    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 
    5747public slots:
    5848
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r71449 r71461  
    3636# include "UIExtraDataManager.h"
    3737# include "UIGChooser.h"
    38 # include "UIUpdateManager.h"
    3938# include "UIHostNetworkManager.h"
    4039# include "UIMedium.h"
     
    402401                vboxGlobal().setEPInstallationRequested(true);
    403402                /* Propose the user to install EP described by the arguments @a list. */
    404                 UIUpdateManager::doExtPackInstallation(strFile, QString(), this, NULL);
     403                VBoxGlobal::doExtPackInstallation(strFile, QString(), this, NULL);
    405404                /* Allow update manager to propose us to update EP: */
    406405                vboxGlobal().setEPInstallationRequested(false);
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsExtension.cpp

    r71448 r71461  
    3030# include "UIIconPool.h"
    3131# include "UIMessageCenter.h"
    32 # include "UIUpdateManager.h"
    3332
    3433/* COM includes: */
     
    308307    {
    309308        QString strExtPackName;
    310         UIUpdateManager::doExtPackInstallation(strFilePath, QString(), this, &strExtPackName);
     309        VBoxGlobal::doExtPackInstallation(strFilePath, QString(), this, &strExtPackName);
    311310
    312311        /* Since we might be reinstalling an existing package, we have to
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette