VirtualBox

Changeset 35273 in vbox


Ignore:
Timestamp:
Dec 21, 2010 12:52:38 PM (14 years ago)
Author:
vboxsync
Message:

IExtPackFile,IExtPackManager: Added progress and display info to the Install and Uninstall methods. No progress object will be returned in 4.0.0 as that is too risky.

Location:
trunk/src/VBox
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r35100 r35273  
    859859        CHECK_ERROR2_RET(ptrExtPackMgr, OpenExtPackFile(bstrTarball.raw(), ptrExtPackFile.asOutParam()), RTEXITCODE_FAILURE);
    860860        CHECK_ERROR2_RET(ptrExtPackFile, COMGETTER(Name)(bstrName.asOutParam()), RTEXITCODE_FAILURE);
    861         CHECK_ERROR2_RET(ptrExtPackFile, Install(fReplace), RTEXITCODE_FAILURE);
     861        ComPtr<IProgress> ptrProgress;
     862        CHECK_ERROR2_RET(ptrExtPackFile, Install(fReplace, NULL, ptrProgress.asOutParam()), RTEXITCODE_FAILURE);
     863        if (!ptrProgress.isNull())
     864            CHECK_ERROR2_RET(ptrProgress, WaitForCompletion(-1), RTEXITCODE_FAILURE);
    862865        RTPrintf("Successfully installed \"%lS\".\n", bstrName.raw());
    863866    }
     
    895898
    896899        Bstr bstrName(pszName);
    897         CHECK_ERROR2_RET(ptrExtPackMgr, Uninstall(bstrName.raw(), fForced), RTEXITCODE_FAILURE);
     900        ComPtr<IProgress> ptrProgress;
     901        CHECK_ERROR2_RET(ptrExtPackMgr, Uninstall(bstrName.raw(), fForced, NULL, ptrProgress.asOutParam()), RTEXITCODE_FAILURE);
     902        if (!ptrProgress.isNull())
     903            CHECK_ERROR2_RET(ptrProgress, WaitForCompletion(-1), RTEXITCODE_FAILURE);
    898904        RTPrintf("Successfully uninstalled \"%s\".\n", pszName);
    899905    }
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp

    r35140 r35273  
    21422142}
    21432143
    2144 void VBoxProblemReporter::cannotInstallExtPack(const QString &strFilename, const CExtPackFile &extPackFile, QWidget *pParent)
    2145 {
    2146     message (pParent ? pParent : mainWindowShown(),
     2144void VBoxProblemReporter::cannotInstallExtPack(const QString &strFilename, const CExtPackFile &extPackFile, const CProgress &progress, QWidget *pParent)
     2145{
     2146    if (!pParent)
     2147        pParent = mainWindowShown();
     2148    QString strErrInfo = !extPackFile.isOk() ? formatErrorInfo(extPackFile) : formatErrorInfo(progress.GetErrorInfo());
     2149    message (pParent,
    21472150             Error,
    21482151             tr("Failed to install the Extension Pack <b>%1</b>.").arg(strFilename),
    2149              formatErrorInfo(extPackFile));
    2150 }
    2151 
    2152 void VBoxProblemReporter::cannotUninstallExtPack(const QString &strPackName, const CExtPackManager &extPackManager, QWidget *pParent)
    2153 {
    2154     message (pParent ? pParent : mainWindowShown(),
     2152             strErrInfo);
     2153}
     2154
     2155void VBoxProblemReporter::cannotUninstallExtPack(const QString &strPackName, const CExtPackManager &extPackManager,
     2156                                                 const CProgress &progress, QWidget *pParent)
     2157{
     2158    if (!pParent)
     2159        pParent = mainWindowShown();
     2160    QString strErrInfo = !extPackManager.isOk() ? formatErrorInfo(extPackManager) : formatErrorInfo(progress.GetErrorInfo());
     2161    message (pParent,
    21552162             Error,
    21562163             tr("Failed to uninstall the Extension Pack <b>%1</b>.").arg(strPackName),
    2157              formatErrorInfo(extPackManager));
     2164             strErrInfo);
    21582165}
    21592166
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h

    r35094 r35273  
    342342    void cannotOpenExtPack(const QString &strFilename, const CExtPackManager &extPackManager, QWidget *pParent);
    343343    void badExtPackFile(const QString &strFilename, const CExtPackFile &extPackFile, QWidget *pParent);
    344     void cannotInstallExtPack(const QString &strFilename, const CExtPackFile &extPackFile, QWidget *pParent);
    345     void cannotUninstallExtPack(const QString &strPackName, const CExtPackManager &extPackManager, QWidget *pParent);
     344    void cannotInstallExtPack(const QString &strFilename, const CExtPackFile &extPackFile, const CProgress &progress, QWidget *pParent);
     345    void cannotUninstallExtPack(const QString &strPackName, const CExtPackManager &extPackManager, const CProgress &progress, QWidget *pParent);
    346346    bool confirmInstallingPackage(const QString &strPackName, const QString &strPackVersion, const QString &strPackDescription, QWidget *pParent);
    347347    bool confirmReplacePackage(const QString &strPackName, const QString &strPackVersionNew, const QString &strPackVersionOld,
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsExtension.cpp

    r35103 r35273  
    177177     * do a refresh even on failure.
    178178     */
    179     extPackFile.Install(fReplaceIt);
     179    QString displayInfo;
     180    CProgress progress = extPackFile.Install(fReplaceIt, displayInfo);
    180181    if (extPackFile.isOk())
    181         vboxProblem().notifyAboutExtPackInstalled(strPackName, pParent);
     182    {
     183        if (progress.isNull())
     184            vboxProblem().notifyAboutExtPackInstalled(strPackName, pParent);
     185        else
     186        {
     187            vboxProblem().showModalProgressDialog(progress, tr("Extensions"));
     188            if (!progress.GetCanceled())
     189            {
     190                if (progress.isOk() && progress.GetResultCode() == 0)
     191                    vboxProblem().notifyAboutExtPackInstalled(strPackName, pParent);
     192                else
     193                    vboxProblem().cannotInstallExtPack(strFilePath, extPackFile, progress, pParent);
     194            }
     195        }
     196    }
    182197    else
    183         vboxProblem().cannotInstallExtPack(strFilePath, extPackFile, pParent);
     198        vboxProblem().cannotInstallExtPack(strFilePath, extPackFile, progress, pParent);
    184199
    185200    if (pstrExtPackName)
     
    374389        if (vboxProblem().confirmRemovingPackage(strSelectedPackageName, this))
    375390        {
    376             /* Get package manager: */
     391            /*
     392             * Uninstall the package.
     393             */
    377394            CExtPackManager manager = vboxGlobal().virtualBox().GetExtensionPackManager();
    378             /* Uninstall package: */
    379395            /** @todo Refuse this if any VMs are running. */
    380             manager.Uninstall(strSelectedPackageName, false /* forced removal? */);
     396            QString displayInfo;
     397            CProgress progress = manager.Uninstall(strSelectedPackageName, false /* forced removal? */, displayInfo);
    381398            if (manager.isOk())
    382399            {
    383                 /* Remove selected package from cache: */
    384                 for (int i = 0; i < m_cache.m_items.size(); ++i)
     400                bool fOk = true;
     401                if (!progress.isNull())
    385402                {
    386                     if (!strSelectedPackageName.compare(m_cache.m_items[i].m_strName, Qt::CaseInsensitive))
     403                    vboxProblem().showModalProgressDialog(progress, tr("Extensions"));
     404                    fOk = progress.isOk() && progress.GetResultCode() == 0;
     405                }
     406                if (fOk)
     407                {
     408                    /* Remove selected package from cache: */
     409                    for (int i = 0; i < m_cache.m_items.size(); ++i)
    387410                    {
    388                         m_cache.m_items.removeAt(i);
    389                         break;
     411                        if (!strSelectedPackageName.compare(m_cache.m_items[i].m_strName, Qt::CaseInsensitive))
     412                        {
     413                            m_cache.m_items.removeAt(i);
     414                            break;
     415                        }
    390416                    }
     417
     418                    /* Remove selected package from tree: */
     419                    delete pItem;
    391420                }
    392                 /* Remove selected package from tree: */
    393                 delete pItem;
     421                else
     422                    vboxProblem().cannotUninstallExtPack(strSelectedPackageName, manager, progress, this);
    394423            }
    395             else vboxProblem().cannotUninstallExtPack(strSelectedPackageName, manager, this);
     424            else
     425                vboxProblem().cannotUninstallExtPack(strSelectedPackageName, manager, progress, this);
    396426        }
    397427    }
  • trunk/src/VBox/Main/ExtPackManagerImpl.cpp

    r35237 r35273  
    585585}
    586586
    587 STDMETHODIMP ExtPackFile::Install(BOOL a_fReplace)
    588 {
     587STDMETHODIMP ExtPackFile::Install(BOOL a_fReplace, IN_BSTR a_bstrDisplayInfo, IProgress **a_ppProgress)
     588{
     589    if (a_ppProgress)
     590        *a_ppProgress = NULL;
     591    Utf8Str strDisplayInfo(a_bstrDisplayInfo);
     592
    589593    AutoCaller autoCaller(this);
    590594    HRESULT hrc = autoCaller.rc();
     
    592596    {
    593597        if (m->fUsable)
    594             hrc = m->ptrExtPackMgr->doInstall(this, RT_BOOL(a_fReplace));
     598            hrc = m->ptrExtPackMgr->doInstall(this, RT_BOOL(a_fReplace), &strDisplayInfo, a_ppProgress);
    595599        else
    596600            hrc = setError(E_FAIL, "%s", m->strWhyUnusable.c_str());
     
    19241928}
    19251929
    1926 STDMETHODIMP ExtPackManager::Uninstall(IN_BSTR a_bstrName, BOOL a_fForcedRemoval)
     1930STDMETHODIMP ExtPackManager::Uninstall(IN_BSTR a_bstrName, BOOL a_fForcedRemoval, IN_BSTR a_bstrDisplayInfo,
     1931                                       IProgress **a_ppProgress)
    19271932{
    19281933    CheckComArgNotNull(a_bstrName);
    19291934    Utf8Str strName(a_bstrName);
     1935    Utf8Str strDisplayInfo(a_bstrDisplayInfo);
     1936    if (a_ppProgress)
     1937        *a_ppProgress = NULL;
    19301938    Assert(m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON);
    19311939
     
    19651973                     */
    19661974                    const char *pszForcedOpt = a_fForcedRemoval ? "--forced" : NULL;
    1967                     hrc = runSetUidToRootHelper("uninstall",
     1975                    hrc = runSetUidToRootHelper(&strDisplayInfo,
     1976                                                "uninstall",
    19681977                                                "--base-dir", m->strBaseDir.c_str(),
    19691978                                                "--name",     strName.c_str(),
     
    20212030         */
    20222031        AutoWriteLock autoLock(this COMMA_LOCKVAL_SRC_POS);
    2023         hrc = runSetUidToRootHelper("cleanup",
     2032        hrc = runSetUidToRootHelper(NULL,
     2033                                    "cleanup",
    20242034                                    "--base-dir", m->strBaseDir.c_str(),
    20252035                                    (const char *)NULL);
     
    20782088 *
    20792089 * @returns S_OK or a failure status with error information set.
     2090 * @param   a_pstrDisplayInfo   Platform specific display info hacks.
    20802091 * @param   a_pszCommand        The command to execute.
    20812092 * @param   ...                 The argument strings that goes along with the
     
    20832094 *                              NULL.
    20842095 */
    2085 HRESULT ExtPackManager::runSetUidToRootHelper(const char *a_pszCommand, ...)
     2096HRESULT ExtPackManager::runSetUidToRootHelper(Utf8Str const *a_pstrDisplayInfo, const char *a_pszCommand, ...)
    20862097{
    20872098    /*
     
    21002111    const char *apszArgs[20];
    21012112    unsigned    cArgs = 0;
     2113
     2114    LogRel(("ExtPack: Executing '%s'", szExecName));
    21022115    apszArgs[cArgs++] = &szExecName[0];
     2116
     2117    if (   a_pstrDisplayInfo
     2118        && a_pstrDisplayInfo->isNotEmpty())
     2119    {
     2120        LogRel((" '--display-info-hack' '%s'", a_pstrDisplayInfo->c_str()));
     2121        apszArgs[cArgs++] = "--display-info-hack";
     2122        apszArgs[cArgs++] = a_pstrDisplayInfo->c_str();
     2123    }
     2124
     2125    LogRel(("'%s'", a_pszCommand));
    21032126    apszArgs[cArgs++] = a_pszCommand;
    21042127
     
    21062129    va_start(va, a_pszCommand);
    21072130    const char *pszLastArg;
    2108     LogRel(("ExtPack: Executing '%s'", szExecName));
    2109     do
    2110     {
    2111         LogRel((" '%s'", apszArgs[cArgs - 1]));
     2131    for (;;)
     2132    {
    21122133        AssertReturn(cArgs < RT_ELEMENTS(apszArgs) - 1, E_UNEXPECTED);
    21132134        pszLastArg = va_arg(va, const char *);
     2135        if (!pszLastArg)
     2136            break;
     2137        LogRel((" '%s'", pszLastArg));
    21142138        apszArgs[cArgs++] = pszLastArg;
    2115     } while (pszLastArg != NULL);
     2139    };
     2140    va_end(va);
     2141
    21162142    LogRel(("\n"));
    2117     va_end(va);
    21182143    apszArgs[cArgs] = NULL;
    21192144
     
    24502475 *
    24512476 * @returns COM status code.
    2452  * @param   a_pExtPackFile  The extension pack file, caller checks that it's
    2453  *                          usable.
    2454  * @param   a_fReplace      Whether to replace any existing extpack or just
    2455  *                          fail.
    2456  */
    2457 HRESULT ExtPackManager::doInstall(ExtPackFile *a_pExtPackFile, bool a_fReplace)
     2477 * @param   a_pExtPackFile      The extension pack file, caller checks that
     2478 *                              it's usable.
     2479 * @param   a_fReplace          Whether to replace any existing extpack or just
     2480 *                              fail.
     2481 * @param   a_pstrDisplayInfo   Host specific display information hacks.
     2482 * @param   a_ppProgress        Where to return a progress object some day. Can
     2483 *                              be NULL.
     2484 */
     2485HRESULT ExtPackManager::doInstall(ExtPackFile *a_pExtPackFile, bool a_fReplace, Utf8Str const *a_pstrDisplayInfo,
     2486                                  IProgress **a_ppProgress)
    24582487{
    24592488    AssertReturn(m->enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON, E_UNEXPECTED);
    24602489    iprt::MiniString const * const pStrName     = &a_pExtPackFile->m->Desc.strName;
    24612490    iprt::MiniString const * const pStrTarball  = &a_pExtPackFile->m->strExtPackFile;
     2491    NOREF(a_ppProgress); /** @todo implement progress object */
    24622492
    24632493    AutoCaller autoCaller(this);
     
    24912521             */
    24922522            /** @todo add a hash (SHA-256) of the tarball or maybe just the manifest. */
    2493             hrc = runSetUidToRootHelper("install",
     2523            hrc = runSetUidToRootHelper(a_pstrDisplayInfo,
     2524                                        "install",
    24942525                                        "--base-dir",   m->strBaseDir.c_str(),
    24952526                                        "--cert-dir",   m->strCertificatDirPath.c_str(),
     
    25172548                         */
    25182549                        if (ErrInfo.Core.rc == VERR_EXTPACK_UNSUPPORTED_HOST_UNINSTALL)
    2519                             runSetUidToRootHelper("uninstall",
     2550                            runSetUidToRootHelper(a_pstrDisplayInfo,
     2551                                                  "uninstall",
    25202552                                                  "--base-dir", m->strBaseDir.c_str(),
    25212553                                                  "--name",     pStrName->c_str(),
  • trunk/src/VBox/Main/VBoxExtPackHelperApp.cpp

    r35256 r35273  
    8989# define OPT_STDERR         1092
    9090#endif
     91#define OPT_DISP_INFO_HACK  1093
    9192/** @}  */
    9293
     
    14631464 * @param   argv                The arguments.
    14641465 * @param   iCmd                The command that is being executed.
    1465  */
    1466 static RTEXITCODE RelaunchElevated(int argc, char **argv, int iCmd)
     1466 * @param   pszDisplayInfoHack  Display information hack.  Platform specific++.
     1467 */
     1468static RTEXITCODE RelaunchElevated(int argc, char **argv, int iCmd, const char *pszDisplayInfoHack)
    14671469{
    14681470    /*
     
    16941696     * Elevation check.
    16951697     */
    1696     RTEXITCODE rcExit;
     1698    const char *pszDisplayInfoHack = NULL;
     1699    RTEXITCODE  rcExit;
    16971700#ifdef WITH_ELEVATION
    1698     bool fElevated;
     1701    bool        fElevated;
    16991702    rcExit = ElevationCheck(&fElevated);
    17001703    if (rcExit != RTEXITCODE_SUCCESS)
     
    17071710    static const RTGETOPTDEF s_aOptions[] =
    17081711    {
    1709         { "install",    CMD_INSTALL,    RTGETOPT_REQ_NOTHING },
    1710         { "uninstall",  CMD_UNINSTALL,  RTGETOPT_REQ_NOTHING },
    1711         { "cleanup",    CMD_CLEANUP,    RTGETOPT_REQ_NOTHING },
     1712        { "install",                CMD_INSTALL,        RTGETOPT_REQ_NOTHING },
     1713        { "uninstall",              CMD_UNINSTALL,      RTGETOPT_REQ_NOTHING },
     1714        { "cleanup",                CMD_CLEANUP,        RTGETOPT_REQ_NOTHING },
    17121715#ifdef WITH_ELEVATION
    1713         { "--elevated", OPT_ELEVATED,   RTGETOPT_REQ_NOTHING },
    1714         { "--stdout",   OPT_STDOUT,     RTGETOPT_REQ_STRING  },
    1715         { "--stderr",   OPT_STDERR,     RTGETOPT_REQ_STRING  },
     1716        { "--elevated",             OPT_ELEVATED,       RTGETOPT_REQ_NOTHING },
     1717        { "--stdout",               OPT_STDOUT,         RTGETOPT_REQ_STRING  },
     1718        { "--stderr",               OPT_STDERR,         RTGETOPT_REQ_STRING  },
    17161719#endif
     1720        { "--display-info-hack",    OPT_DISP_INFO_HACK, RTGETOPT_REQ_STRING  },
    17171721    };
    17181722    RTGETOPTSTATE GetState;
     
    17351739#ifdef WITH_ELEVATION
    17361740                if (!fElevated)
    1737                     return RelaunchElevated(argc, argv, ch);
     1741                    return RelaunchElevated(argc, argv, ch, pszDisplayInfoHack);
    17381742#endif
    17391743                int         cCmdargs     = argc - GetState.iNext;
     
    17931797#endif
    17941798
     1799            case OPT_DISP_INFO_HACK:
     1800                if (pszDisplayInfoHack)
     1801                    return RTMsgErrorExit(RTEXITCODE_SYNTAX, "--display-info-hack shall only occur once");
     1802                pszDisplayInfoHack = ValueUnion.psz;
     1803                break;
     1804
    17951805            case 'h':
    17961806            case 'V':
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r35251 r35273  
    1477914779  <interface
    1478014780    name="IExtPackFile" extends="IExtPackBase"
    14781     uuid="64b65bda-eedf-442c-9fd2-d179a021031a"
     14781    uuid="b6b49f55-efcc-4f08-b486-56e8d8afb10b"
    1478214782    wsmap="suppress"
    1478314783    >
     
    1480414804        </desc>
    1480514805      </param>
     14806      <param name="displayInfo" type="wstring" dir="in">
     14807        <desc>
     14808          Platform specific display information.  Reserved for future hacks.
     14809        </desc>
     14810      </param>
     14811      <param name="progess" type="IProgress" dir="return">
     14812        <desc>
     14813          Progress object for the operation if it was decided that it should
     14814          be executed asynchronously - i.e. never in 4.0.0, but maybe in 4.0.x.
     14815        </desc>
     14816      </param>
    1480614817    </method>
    1480714818  </interface>
     
    1480914820  <interface
    1481014821    name="IExtPackManager" extends="$unknown"
    14811     uuid="70d808a9-176f-4d45-adad-7c509b8309b3"
     14822    uuid="2451b1ba-ab1c-42fb-b453-c58433bea8c7"
    1481214823    wsmap="suppress"
    1481314824    >
     
    1486314874          Forced removal of the extension pack.  This means that the uninstall
    1486414875          hook will not be called.
     14876        </desc>
     14877      </param>
     14878      <param name="displayInfo" type="wstring" dir="in">
     14879        <desc>
     14880          Platform specific display information.  Reserved for future hacks.
     14881        </desc>
     14882      </param>
     14883      <param name="progess" type="IProgress" dir="return">
     14884        <desc>
     14885          Progress object for the operation if it was decided that it should
     14886          be executed asynchronously - i.e. never in 4.0.0, but maybe in 4.0.x.
    1486514887        </desc>
    1486614888      </param>
  • trunk/src/VBox/Main/include/ExtPackManagerImpl.h

    r35184 r35273  
    7070     * @{ */
    7171    STDMETHOD(COMGETTER(FilePath))(BSTR *a_pbstrPath);
    72     STDMETHOD(Install)(BOOL a_fReplace);
     72    STDMETHOD(Install)(BOOL a_fReplace, IN_BSTR a_bstrDisplayInfo, IProgress **a_ppProgress);
    7373    /** @}  */
    7474
     
    211211    STDMETHOD(Find)(IN_BSTR a_bstrName, IExtPack **a_pExtPack);
    212212    STDMETHOD(OpenExtPackFile)(IN_BSTR a_bstrTarball, IExtPackFile **a_ppExtPackFile);
    213     STDMETHOD(Uninstall)(IN_BSTR a_bstrName, BOOL a_fForcedRemoval);
     213    STDMETHOD(Uninstall)(IN_BSTR a_bstrName, BOOL a_fForcedRemoval, IN_BSTR a_bstrDisplayInfo, IProgress **a_ppProgress);
    214214    STDMETHOD(Cleanup)(void);
    215215    STDMETHOD(QueryAllPlugInsForFrontend)(IN_BSTR a_bstrFrontend, ComSafeArrayOut(BSTR, a_pabstrPlugInModules));
     
    219219    /** @name Internal interfaces used by other Main classes.
    220220     * @{ */
    221     HRESULT     doInstall(ExtPackFile *a_pExtPackFile, bool a_fReplace);
     221    HRESULT     doInstall(ExtPackFile *a_pExtPackFile, bool a_fReplace, Utf8Str const *a_pstrDisplayInfo,
     222                          IProgress **a_ppProgress);
    222223    void        callAllVirtualBoxReadyHooks(void);
    223224    void        callAllConsoleReadyHooks(IConsole *a_pConsole);
     
    233234
    234235private:
    235     HRESULT     runSetUidToRootHelper(const char *a_pszCommand, ...);
     236    HRESULT     runSetUidToRootHelper(Utf8Str const *a_pstrDisplayInfo, const char *a_pszCommand, ...);
    236237    ExtPack    *findExtPack(const char *a_pszName);
    237238    void        removeExtPack(const char *a_pszName);
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