VirtualBox

Changeset 71448 in vbox for trunk/src


Ignore:
Timestamp:
Mar 22, 2018 10:58:10 AM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9049: Detach UIUpdateManager from the UIGlobalSettingsExtension stuff.

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  
    3030# include "QIProcess.h"
    3131# include "VBoxGlobal.h"
     32# include "VBoxLicenseViewer.h"
    3233# include "VBoxUtils.h"
    3334# include "UIDownloaderExtensionPack.h"
    3435# include "UIExtraDataManager.h"
    35 # include "UIGlobalSettingsExtension.h"
    3636# include "UIMessageCenter.h"
    3737# include "UIModalWindowManager.h"
     
    4444/* COM includes: */
    4545# include "CExtPack.h"
     46# include "CExtPackFile.h"
    4647# include "CExtPackManager.h"
     48# include "CSystemProperties.h"
    4749
    4850/* Other VBox includes: */
     
    490492    /* Warn the user about extension pack was downloaded and saved, propose to install it: */
    491493    if (msgCenter().proposeInstallExtentionPack(GUI_ExtPackName, strSource, QDir::toNativeSeparators(strTarget)))
    492         UIGlobalSettingsExtension::doInstallation(strTarget, strDigest, windowManager().networkManagerOrMainWindowShown(), 0);
     494        UIUpdateManager::doExtPackInstallation(strTarget, strDigest, windowManager().networkManagerOrMainWindowShown(), NULL);
    493495    /* Propose to delete the downloaded extension pack: */
    494496    if (msgCenter().proposeDeleteExtentionPack(QDir::toNativeSeparators(strTarget)))
     
    570572}
    571573
     574/* static */
     575void 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
    572662void UIUpdateManager::sltForceCheck()
    573663{
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.h

    r71447 r71448  
    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
    4757public slots:
    4858
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsExtension.cpp

    r71355 r71448  
    2626/* GUI includes: */
    2727# include "QIFileDialog.h"
     28# include "VBoxGlobal.h"
    2829# include "UIGlobalSettingsExtension.h"
    2930# include "UIIconPool.h"
    3031# include "UIMessageCenter.h"
    31 # include "VBoxGlobal.h"
    32 # include "VBoxLicenseViewer.h"
     32# include "UIUpdateManager.h"
    3333
    3434/* COM includes: */
    3535# include "CExtPack.h"
    36 # include "CExtPackFile.h"
    3736# include "CExtPackManager.h"
    3837
     
    185184}
    186185
    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     else
    197     {
    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 already
    218      * 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     else
    229     {
    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 doing
    245      * this as the caller should do a refresh even on failure. */
    246     QString displayInfo;
    247 #ifdef VBOX_WS_WIN
    248     if (pParent)
    249         displayInfo.sprintf("hwnd=%#llx", (uint64_t)(uintptr_t)pParent->winId());
    250 #endif
    251     /* 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             else
    262                 msgCenter().cannotInstallExtPack(progress, strFilePath, pParent);
    263         }
    264     }
    265     else
    266         msgCenter().cannotInstallExtPack(extPackFile, strFilePath, pParent);
    267 
    268     if (pstrExtPackName)
    269         *pstrExtPackName = strPackName;
    270 }
    271 
    272186void UIGlobalSettingsExtension::loadToCacheFrom(QVariant &data)
    273187{
     
    394308    {
    395309        QString strExtPackName;
    396         doInstallation(strFilePath, QString(), this, &strExtPackName);
     310        UIUpdateManager::doExtPackInstallation(strFilePath, QString(), this, &strExtPackName);
    397311
    398312        /* Since we might be reinstalling an existing package, we have to
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsExtension.h

    r71027 r71448  
    4141    /** Destructs Extension settings page. */
    4242    ~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);
    5043
    5144protected:
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