VirtualBox

Changeset 18269 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Mar 25, 2009 6:01:07 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
45017
Message:

Main: rework IProgress internals to optionally handle weighted operations; rename some internal IProgress methods; change percentage APIs to use ULONGs instead of LONGs

Location:
trunk/src/VBox/Main
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r18263 r18269  
    210210
    211211    list<Utf8Str> llWarnings;
     212
     213    ULONG                   ulWeightPerOperation;   // for progress calculations
    212214};
    213215
     
    13941396                                       strNetwork,      // orig
    13951397                                       Utf8StrFmt("%RI32", (uint32_t)nwAdapterVBox),   // conf
     1398                                       0,
    13961399                                       Utf8StrFmt("type=%s", strNetwork.c_str()));       // extra conf
    13971400                }
     
    15521555                                           di.strHref,
    15531556                                           strPath,
     1557                                           (uint32_t)(di.iPopulatedSize / _1M),
    15541558                                           strExtraConfig);
    15551559                    }
     
    16191623    try
    16201624    {
    1621         uint32_t opCount = calcMaxProgress();
    16221625        Bstr progressDesc = BstrFmt(tr("Import appliance '%s'"),
    16231626                                    m->strPath.raw());
    1624         /* Create the progress object */
    1625         progress.createObject();
    1626         rc = progress->init(mVirtualBox, static_cast<IAppliance*>(this),
    1627                             progressDesc,
    1628                             FALSE /* aCancelable */,
    1629                             opCount,
    1630                             progressDesc);
     1627        rc = setUpProgress(progress, progressDesc);
    16311628        if (FAILED(rc)) throw rc;
    16321629
     
    17151712        {
    17161713            if (!task->progress.isNull())
    1717                 task->progress->advanceOperation(BstrFmt(tr("Importing Virtual System %d"), i + 1));
     1714                task->progress->setNextOperation(BstrFmt(tr("Importing virtual system %d"), i + 1),
     1715                                                 pAppliance->m->ulWeightPerOperation);
    17181716
    17191717            /* How many sub notifications are necessary? */
     
    17561754
    17571755            if (!task->progress.isNull())
    1758                 rc = task->progress->notifyProgress((uint32_t)(opCountMax * opCount++));
     1756                rc = task->progress->setCurrentOperationProgress((uint32_t)(opCountMax * opCount++));
    17591757
    17601758            /* CPU count (ignored for now) */
     
    17801778
    17811779            if (!task->progress.isNull())
    1782                 task->progress->notifyProgress((uint32_t)(opCountMax * opCount++));
     1780                task->progress->setCurrentOperationProgress((uint32_t)(opCountMax * opCount++));
    17831781
    17841782            /* Audio Adapter */
     
    18161814
    18171815            if (!task->progress.isNull())
    1818                 task->progress->notifyProgress((uint32_t)(opCountMax * opCount++));
     1816                task->progress->setCurrentOperationProgress((uint32_t)(opCountMax * opCount++));
    18191817
    18201818            /* Change the network adapters */
     
    19291927
    19301928            if (!task->progress.isNull())
    1931                 task->progress->notifyProgress((uint32_t)(opCountMax * opCount++));
     1929                task->progress->setCurrentOperationProgress((uint32_t)(opCountMax * opCount++));
    19321930
    19331931            /* CDROM drive */
     
    20152013
    20162014            if (!task->progress.isNull())
    2017                 task->progress->notifyProgress((uint32_t)(opCountMax * opCount++));
     2015                task->progress->setCurrentOperationProgress((uint32_t)(opCountMax * opCount++));
    20182016
    20192017            // store new machine for roll-back in case of errors
     
    21012099                            /* Advance to the next operation */
    21022100                            if (!task->progress.isNull())
    2103                                 task->progress->advanceOperation (BstrFmt(tr("Creating virtual disk image '%s'"), pcszDstFilePath));
     2101                                task->progress->setNextOperation(BstrFmt(tr("Creating virtual disk image '%s'"), pcszDstFilePath),
     2102                                                                 vsdeHD->ulSizeMB);     // operation's weight, as set up with the IProgress originally
    21042103                        }
    21052104                        else
     
    21382137                            /* Advance to the next operation */
    21392138                            if (!task->progress.isNull())
    2140                                 task->progress->advanceOperation (BstrFmt(tr("Importing virtual disk image '%s'"), strSrcFilePath.c_str()));
     2139                                task->progress->setNextOperation(BstrFmt(tr("Importing virtual disk image '%s'"), strSrcFilePath.c_str()),
     2140                                                                 vsdeHD->ulSizeMB);     // operation's weight, as set up with the IProgress originally);
    21412141                        }
    21422142
     
    21442144                        // report its result
    21452145                        BOOL fCompleted;
    2146                         LONG currentPercent;
     2146                        ULONG currentPercent;
    21472147                        while (SUCCEEDED(progress->COMGETTER(Completed(&fCompleted))))
    21482148                        {
     
    21502150                            if (FAILED(rc)) throw rc;
    21512151                            if (!task->progress.isNull())
    2152                                 task->progress->notifyProgress(currentPercent);
     2152                                task->progress->setCurrentOperationProgress(currentPercent);
    21532153                            if (fCompleted)
    21542154                                break;
     
    23992399    try
    24002400    {
    2401         uint32_t opCount = calcMaxProgress();
    2402         Bstr progressDesc = BstrFmt(tr("Write appliance '%s'"),
     2401        Bstr progressDesc = BstrFmt(tr("Export appliance '%s'"),
    24032402                                    m->strPath.raw());
    2404         /* Create the progress object */
    2405         progress.createObject();
    2406         rc = progress->init(mVirtualBox, static_cast<IAppliance*>(this),
    2407                             progressDesc,
    2408                             FALSE /* aCancelable */,
    2409                             opCount,
    2410                             progressDesc);
    2411         CheckComRCThrowRC(rc);
     2403        rc = setUpProgress(progress, progressDesc);
     2404        if (FAILED(rc)) throw rc;
    24122405
    24132406        /* Initialize our worker task */
     
    30293022                // advance to the next operation
    30303023                if (!task->progress.isNull())
    3031                     task->progress->advanceOperation(BstrFmt(tr("Exporting virtual disk image '%s'"), strSrcFilePath.c_str()));
     3024                    task->progress->setNextOperation(BstrFmt(tr("Exporting virtual disk image '%s'"), strSrcFilePath.c_str()),
     3025                                                     pDiskEntry->ulSizeMB);     // operation's weight, as set up with the IProgress originally);
    30323026
    30333027                // now loop until the asynchronous operation completes and then
    30343028                // report its result
    30353029                BOOL fCompleted;
    3036                 LONG currentPercent;
     3030                ULONG currentPercent;
    30373031                while (SUCCEEDED(pProgress2->COMGETTER(Completed(&fCompleted))))
    30383032                {
     
    30403034                    if (FAILED(rc)) throw rc;
    30413035                    if (!task->progress.isNull())
    3042                         task->progress->notifyProgress(currentPercent);
     3036                        task->progress->setCurrentOperationProgress(currentPercent);
    30433037                    if (fCompleted)
    30443038                        break;
     
    32073201
    32083202/**
    3209  * Calculates the maximum progress value for importMachines() and write().
     3203 * Calculates the no. of operations for the IProgress objects in importMachines() and write().
    32103204 * @return
    32113205 */
    3212 uint32_t Appliance::calcMaxProgress()
    3213 {
    3214     /* Figure out how many sub operation the import will need */
    3215     /* One for the appliance */
    3216     uint32_t opCount = 1;
     3206HRESULT Appliance::setUpProgress(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription)
     3207{
     3208    HRESULT rc;
     3209
     3210    /* Create the progress object */
     3211    pProgress.createObject();
     3212
     3213    // use one percent for parsing the XML and one percent for each virtual system
     3214    // in the XML; use the rest (e.g. 97%) for the disk images
     3215    ULONG cFixed = 1 + m->virtualSystemDescriptions.size();
     3216    ULONG ulPercentForDisks = 100 - cFixed;
     3217
     3218    // weigh the disk images according to their sizes
     3219    uint32_t ulTotalMB = 0;
     3220    uint32_t cDisks = 0;
    32173221    list< ComObjPtr<VirtualSystemDescription> >::const_iterator it;
    32183222    for (it = m->virtualSystemDescriptions.begin();
     
    32203224         ++it)
    32213225    {
    3222         /* One for every Virtual System */
    3223         ++opCount;
    32243226        ComObjPtr<VirtualSystemDescription> vsdescThis = (*it);
    32253227        /* One for every hard disk of the Virtual System */
    32263228        std::list<VirtualSystemDescriptionEntry*> avsdeHDs = vsdescThis->findByType(VirtualSystemDescriptionType_HardDiskImage);
    3227         opCount += (uint32_t)avsdeHDs.size();
     3229        std::list<VirtualSystemDescriptionEntry*>::const_iterator itH;
     3230        for (itH = avsdeHDs.begin();
     3231                itH != avsdeHDs.end();
     3232                ++itH)
     3233        {
     3234            ulTotalMB += (**itH).ulSizeMB;
     3235            ++cDisks;
     3236        }
    32283237    }
    32293238
    3230     return opCount;
     3239    ULONG ulTotalOperationsWeight = ulTotalMB * 100 / ulPercentForDisks;
     3240    m->ulWeightPerOperation = ulTotalOperationsWeight / 100;
     3241
     3242    Log(("Setting up progress object: ulTotalMB = %d, cFixed = %d, cDisks = %d, => cOperations = %d, ulTotalOperationsWeight = %d, m->ulWeightPerOperation = %d\n",
     3243         ulTotalMB, cFixed, cDisks, cFixed + (ULONG)cDisks, ulTotalOperationsWeight, m->ulWeightPerOperation));
     3244
     3245    rc = pProgress->init(mVirtualBox, static_cast<IAppliance*>(this),
     3246                         bstrDescription,
     3247                         FALSE /* aCancelable */,
     3248                         cFixed + (ULONG)cDisks, // ULONG cOperations,
     3249                         ulTotalOperationsWeight, // ULONG ulTotalOperationsWeight,
     3250                         bstrDescription, // CBSTR bstrFirstOperationDescription,
     3251                         m->ulWeightPerOperation); // ULONG ulFirstOperationWeight,
     3252    return rc;
    32313253}
    32323254
     
    35363558    AutoWriteLock alock(this);
    35373559
    3538     addEntry(aType, "", aVboxValue, aVboxValue, aExtraConfigValue);
     3560    addEntry(aType, "", aVboxValue, aVboxValue, 0, aExtraConfigValue);
    35393561
    35403562    return S_OK;
     
    35533575                                        const Utf8Str &aOrigValue,
    35543576                                        const Utf8Str &aAutoValue,
     3577                                        uint32_t ulSizeMB,
    35553578                                        const Utf8Str &strExtraConfig /*= ""*/)
    35563579{
     
    35623585    vsde.strVbox = aAutoValue;
    35633586    vsde.strExtraConfig = strExtraConfig;
     3587    vsde.ulSizeMB = ulSizeMB;
    35643588
    35653589    m->llDescriptions.push_back(vsde);
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r18116 r18269  
    46134613    /* advance percent count */
    46144614    if (aProgress)
    4615         aProgress->notifyProgress (99 * (++ step) / StepCount );
     4615        aProgress->setCurrentOperationProgress(99 * (++ step) / StepCount );
    46164616
    46174617#ifdef VBOX_WITH_HGCM
     
    46804680    /* advance percent count */
    46814681    if (aProgress)
    4682         aProgress->notifyProgress (99 * (++ step) / StepCount );
     4682        aProgress->setCurrentOperationProgress(99 * (++ step) / StepCount );
    46834683
    46844684# endif /* VBOX_WITH_GUEST_PROPS defined */
     
    47004700    /* advance percent count */
    47014701    if (aProgress)
    4702         aProgress->notifyProgress (99 * (++ step) / StepCount );
     4702        aProgress->setCurrentOperationProgress(99 * (++ step) / StepCount );
    47034703
    47044704#endif /* VBOX_WITH_HGCM */
     
    47314731    /* advance percent count */
    47324732    if (aProgress)
    4733         aProgress->notifyProgress (99 * (++ step) / StepCount );
     4733        aProgress->setCurrentOperationProgress(99 * (++ step) / StepCount );
    47344734
    47354735    vrc = VINF_SUCCESS;
     
    47604760    /* advance percent count */
    47614761    if (aProgress)
    4762         aProgress->notifyProgress (99 * (++ step) / StepCount );
     4762        aProgress->setCurrentOperationProgress(99 * (++ step) / StepCount );
    47634763
    47644764    LogFlowThisFunc (("Ready for VM destruction.\n"));
     
    48044804        /* advance percent count */
    48054805        if (aProgress)
    4806             aProgress->notifyProgress (99 * (++ step) / StepCount );
     4806            aProgress->setCurrentOperationProgress(99 * (++ step) / StepCount );
    48074807
    48084808        if (VBOX_SUCCESS (vrc))
     
    48324832        /* advance percent count */
    48334833        if (aProgress)
    4834             aProgress->notifyProgress (99 * (++ step) / StepCount );
     4834            aProgress->setCurrentOperationProgress(99 * (++ step) / StepCount );
    48354835    }
    48364836    else
     
    59375937    /* update the progress object */
    59385938    if (task->mProgress)
    5939         task->mProgress->notifyProgress (uPercent);
     5939        task->mProgress->setCurrentOperationProgress(uPercent);
    59405940
    59415941    return VINF_SUCCESS;
  • trunk/src/VBox/Main/HardDiskImpl.cpp

    r18162 r18269  
    20982098        AssertComRCReturnRC (autoCaller.rc());
    20992099
    2100         aProgress->advanceOperation (BstrFmt (
    2101             tr ("Discarding hard disk '%s'"), name().raw()));
     2100        aProgress->setNextOperation(BstrFmt(tr("Discarding hard disk '%s'"), name().raw()),
     2101                                    1);        // weight
    21022102
    21032103        if (aChain == NULL)
     
    34403440        /* update the progress object, capping it at 99% as the final percent
    34413441         * is used for additional operations like setting the UUIDs and similar. */
    3442         HRESULT rc = that->mm.vdProgress->notifyProgress (uPercent * 99 / 100);
     3442        HRESULT rc = that->mm.vdProgress->setCurrentOperationProgress(uPercent * 99 / 100);
    34433443        if (FAILED(rc))
    34443444        {
  • trunk/src/VBox/Main/MachineImpl.cpp

    r18265 r18269  
    119119static DECLCALLBACK(int) progressCallback (unsigned uPercentage, void *pvUser)
    120120{
    121     Progress *progress = static_cast <Progress *> (pvUser);
     121    Progress *progress = static_cast<Progress*>(pvUser);
    122122
    123123    /* update the progress object */
    124124    if (progress)
    125         progress->notifyProgress (uPercentage);
     125        progress->setCurrentOperationProgress(uPercentage);
    126126
    127127    return VINF_SUCCESS;
     
    72257225                Assert (hd->type() == HardDiskType_Writethrough);
    72267226
    7227                 rc = aProgress->advanceOperation (
    7228                     BstrFmt (tr ("Skipping writethrough hard disk '%s'"),
    7229                              hd->root()->name().raw()));
     7227                rc = aProgress->setNextOperation(BstrFmt(tr("Skipping writethrough hard disk '%s'"),
     7228                                                         hd->root()->name().raw()),
     7229                                                 1);        // weight
    72307230                CheckComRCThrowRC (rc);
    72317231
     
    72367236            /* need a diff */
    72377237
    7238             rc = aProgress->advanceOperation (
    7239                 BstrFmt (tr ("Creating differencing hard disk for '%s'"),
    7240                          hd->root()->name().raw()));
     7238            rc = aProgress->setNextOperation(BstrFmt(tr("Creating differencing hard disk for '%s'"),
     7239                                                     hd->root()->name().raw()),
     7240                                             1);        // weight
    72417241            CheckComRCThrowRC (rc);
    72427242
     
    1014710147                          stateFrom.raw(), stateTo.raw()));
    1014810148
    10149         mSnapshotData.mServerProgress->advanceOperation (
    10150             Bstr (tr ("Copying the execution state")));
     10149        mSnapshotData.mServerProgress->setNextOperation(Bstr(tr("Copying the execution state")),
     10150                                                        1);        // weight
    1015110151
    1015210152        /* Leave the lock before a lengthy operation (mMachineState is
     
    1030010300                Assert (hd->type() == HardDiskType_Writethrough);
    1030110301
    10302                 rc = aTask.progress->advanceOperation (
    10303                     BstrFmt (tr ("Skipping writethrough hard disk '%s'"),
    10304                              hd->root()->name().raw()));
     10302                rc = aTask.progress->setNextOperation(BstrFmt(tr("Skipping writethrough hard disk '%s'"),
     10303                                                              hd->root()->name().raw()),
     10304                                                      1); // weight
    1030510305                CheckComRCThrowRC (rc);
    1030610306
     
    1045510455            if (stateFilePath)
    1045610456            {
    10457                 aTask.progress->advanceOperation (
    10458                     Bstr (tr ("Discarding the execution state")));
     10457                aTask.progress->setNextOperation(Bstr(tr("Discarding the execution state")),
     10458                                                 1);        // weight
    1045910459
    1046010460                RTFileDelete (Utf8Str (stateFilePath));
     
    1070010700                                  snapStateFilePath.raw(), stateFilePath.raw()));
    1070110701
    10702                 aTask.progress->advanceOperation (
    10703                     Bstr (tr ("Restoring the execution state")));
     10702                aTask.progress->setNextOperation(Bstr(tr("Restoring the execution state")),
     10703                                                 1);        // weight
    1070410704
    1070510705                /* leave the lock before the potentially lengthy operation */
  • trunk/src/VBox/Main/ProgressImpl.cpp

    r18252 r18269  
    5959    mCanceled = FALSE;
    6060    mResultCode = S_OK;
    61     mOperationCount = 0;
    62     mOperation = 0;
    63     mOperationPercent = 0;
     61
     62    m_cOperations =
     63    m_ulTotalOperationsWeight =
     64    m_ulOperationsCompletedWeight =
     65    m_ulCurrentOperation =
     66    m_ulCurrentOperationWeight =
     67    m_ulOperationPercent = 0;
    6468
    6569    return S_OK;
     
    9599    NOREF (aAutoInitSpan);
    96100
    97     AutoCaller autoCaller (this);
     101    AutoCaller autoCaller(this);
    98102    AssertReturn (autoCaller.state() == InInit, E_FAIL);
    99103
     
    197201    CheckComArgOutPointerValid(aId);
    198202
    199     AutoCaller autoCaller (this);
    200     CheckComRCReturnRC (autoCaller.rc());
     203    AutoCaller autoCaller(this);
     204    CheckComRCReturnRC(autoCaller.rc());
    201205
    202206    /* mId is constant during life time, no need to lock */
     
    210214    CheckComArgOutPointerValid(aDescription);
    211215
    212     AutoCaller autoCaller (this);
    213     CheckComRCReturnRC (autoCaller.rc());
     216    AutoCaller autoCaller(this);
     217    CheckComRCReturnRC(autoCaller.rc());
    214218
    215219    /* mDescription is constant during life time, no need to lock */
     
    223227    CheckComArgOutPointerValid(aInitiator);
    224228
    225     AutoCaller autoCaller (this);
    226     CheckComRCReturnRC (autoCaller.rc());
     229    AutoCaller autoCaller(this);
     230    CheckComRCReturnRC(autoCaller.rc());
    227231
    228232    /* mInitiator/mParent are constant during life time, no need to lock */
     
    244248    CheckComArgOutPointerValid(aCancelable);
    245249
    246     AutoCaller autoCaller (this);
    247     CheckComRCReturnRC (autoCaller.rc());
     250    AutoCaller autoCaller(this);
     251    CheckComRCReturnRC(autoCaller.rc());
    248252
    249253    AutoReadLock alock (this);
     
    254258}
    255259
    256 STDMETHODIMP ProgressBase::COMGETTER(Percent) (LONG *aPercent)
     260STDMETHODIMP ProgressBase::COMGETTER(Percent)(ULONG *aPercent)
    257261{
    258262    CheckComArgOutPointerValid(aPercent);
    259263
    260     AutoCaller autoCaller (this);
    261     CheckComRCReturnRC (autoCaller.rc());
    262 
    263     AutoReadLock alock (this);
     264    AutoCaller autoCaller(this);
     265    CheckComRCReturnRC(autoCaller.rc());
     266
     267    AutoReadLock alock(this);
    264268
    265269    if (mCompleted && SUCCEEDED (mResultCode))
     
    268272    {
    269273        /* global percent =
    270          *      (100 / mOperationCount) * mOperation +
    271          *      ((100 / mOperationCount) / 100) * mOperationPercent */
    272         *aPercent = (100 * mOperation + mOperationPercent) / mOperationCount;
     274         *      (100 / m_cOperations) * mOperation +
     275         *      ((100 / m_cOperations) / 100) * m_ulOperationPercent */
     276//         *aPercent = (100 * mOperation + m_ulOperationPercent) / m_cOperations;
     277
     278        *aPercent = (ULONG)(    (    (double)m_ulOperationsCompletedWeight                                              // weight of operations that have been completed
     279                                   + ((double)m_ulOperationPercent * (double)m_ulCurrentOperationWeight / (double)100)  // plus partial weight of the current operation
     280                                ) * (double)100 / (double)m_ulTotalOperationsWeight);
    273281    }
    274282
     
    280288    CheckComArgOutPointerValid(aCompleted);
    281289
    282     AutoCaller autoCaller (this);
    283     CheckComRCReturnRC (autoCaller.rc());
     290    AutoCaller autoCaller(this);
     291    CheckComRCReturnRC(autoCaller.rc());
    284292
    285293    AutoReadLock alock (this);
     
    294302    CheckComArgOutPointerValid(aCanceled);
    295303
    296     AutoCaller autoCaller (this);
    297     CheckComRCReturnRC (autoCaller.rc());
     304    AutoCaller autoCaller(this);
     305    CheckComRCReturnRC(autoCaller.rc());
    298306
    299307    AutoReadLock alock (this);
     
    308316    CheckComArgOutPointerValid(aResultCode);
    309317
    310     AutoCaller autoCaller (this);
    311     CheckComRCReturnRC (autoCaller.rc());
     318    AutoCaller autoCaller(this);
     319    CheckComRCReturnRC(autoCaller.rc());
    312320
    313321    AutoReadLock alock (this);
     
    326334    CheckComArgOutPointerValid(aErrorInfo);
    327335
    328     AutoCaller autoCaller (this);
    329     CheckComRCReturnRC (autoCaller.rc());
     336    AutoCaller autoCaller(this);
     337    CheckComRCReturnRC(autoCaller.rc());
    330338
    331339    AutoReadLock alock (this);
     
    344352    CheckComArgOutPointerValid(aOperationCount);
    345353
    346     AutoCaller autoCaller (this);
    347     CheckComRCReturnRC (autoCaller.rc());
     354    AutoCaller autoCaller(this);
     355    CheckComRCReturnRC(autoCaller.rc());
    348356
    349357    AutoReadLock alock (this);
    350358
    351     *aOperationCount = mOperationCount;
     359    *aOperationCount = m_cOperations;
    352360
    353361    return S_OK;
     
    358366    CheckComArgOutPointerValid(aOperation);
    359367
    360     AutoCaller autoCaller (this);
    361     CheckComRCReturnRC (autoCaller.rc());
     368    AutoCaller autoCaller(this);
     369    CheckComRCReturnRC(autoCaller.rc());
    362370
    363371    AutoReadLock alock (this);
    364372
    365     *aOperation = mOperation;
     373    *aOperation = m_ulCurrentOperation;
    366374
    367375    return S_OK;
     
    372380    CheckComArgOutPointerValid(aOperationDescription);
    373381
    374     AutoCaller autoCaller (this);
    375     CheckComRCReturnRC (autoCaller.rc());
     382    AutoCaller autoCaller(this);
     383    CheckComRCReturnRC(autoCaller.rc());
    376384
    377385    AutoReadLock alock (this);
    378386
    379     mOperationDescription.cloneTo (aOperationDescription);
    380 
    381     return S_OK;
    382 }
    383 
    384 STDMETHODIMP ProgressBase::COMGETTER(OperationPercent) (LONG *aOperationPercent)
     387    m_bstrOperationDescription.cloneTo(aOperationDescription);
     388
     389    return S_OK;
     390}
     391
     392STDMETHODIMP ProgressBase::COMGETTER(OperationPercent)(ULONG *aOperationPercent)
    385393{
    386394    CheckComArgOutPointerValid(aOperationPercent);
    387395
    388     AutoCaller autoCaller (this);
    389     CheckComRCReturnRC (autoCaller.rc());
     396    AutoCaller autoCaller(this);
     397    CheckComRCReturnRC(autoCaller.rc());
    390398
    391399    AutoReadLock alock (this);
     
    394402        *aOperationPercent = 100;
    395403    else
    396         *aOperationPercent = mOperationPercent;
     404        *aOperationPercent = m_ulOperationPercent;
    397405
    398406    return S_OK;
     
    481489                        IUnknown *aInitiator,
    482490                        CBSTR aDescription, BOOL aCancelable,
    483                         ULONG aOperationCount, CBSTR aOperationDescription,
     491                        ULONG cOperations, ULONG ulTotalOperationsWeight,
     492                        CBSTR bstrFirstOperationDescription, ULONG ulFirstOperationWeight,
    484493                        OUT_GUID aId /* = NULL */)
    485494{
    486495    LogFlowThisFunc (("aDescription=\"%ls\"\n", aDescription));
    487496
    488     AssertReturn (aOperationDescription, E_INVALIDARG);
    489     AssertReturn (aOperationCount >= 1, E_INVALIDARG);
     497    AssertReturn(bstrFirstOperationDescription, E_INVALIDARG);
     498    AssertReturn(ulTotalOperationsWeight >= 1, E_INVALIDARG);
    490499
    491500    /* Enclose the state transition NotReady->InInit->Ready */
     
    504513    mCancelable = aCancelable;
    505514
    506     mOperationCount = aOperationCount;
    507     mOperation = 0; /* the first operation */
    508     mOperationDescription = aOperationDescription;
     515    m_cOperations = cOperations;
     516    m_ulTotalOperationsWeight = ulTotalOperationsWeight;
     517    m_ulOperationsCompletedWeight = 0;
     518    m_ulCurrentOperation = 0;
     519    m_bstrOperationDescription = bstrFirstOperationDescription;
     520    m_ulCurrentOperationWeight = ulFirstOperationWeight;
     521    m_ulOperationPercent = 0;
    509522
    510523    int vrc = RTSemEventMultiCreate (&mCompletedSem);
     
    535548 * @param aOperationDescription Description of the individual operation.
    536549 */
    537 HRESULT Progress::init (BOOL aCancelable, ULONG aOperationCount,
    538                         CBSTR aOperationDescription)
     550HRESULT Progress::init(BOOL aCancelable,
     551                       ULONG aOperationCount,
     552                       CBSTR aOperationDescription)
    539553{
    540554    LogFlowThisFunc (("aOperationDescription=\"%ls\"\n", aOperationDescription));
     
    551565    mCancelable = aCancelable;
    552566
    553     mOperationCount = aOperationCount;
    554     mOperation = 0; /* the first operation */
    555     mOperationDescription = aOperationDescription;
     567    // for this variant we assume for now that all operations are weighed "1"
     568    // and equal total weight = operation count
     569    m_cOperations = aOperationCount;
     570    m_ulTotalOperationsWeight = aOperationCount;
     571    m_ulOperationsCompletedWeight = 0;
     572    m_ulCurrentOperation = 0;
     573    m_bstrOperationDescription = aOperationDescription;
     574    m_ulCurrentOperationWeight = 1;
     575    m_ulOperationPercent = 0;
    556576
    557577    int vrc = RTSemEventMultiCreate (&mCompletedSem);
     
    611631    LogFlowThisFunc (("aTimeout=%d\n", aTimeout));
    612632
    613     AutoCaller autoCaller (this);
    614     CheckComRCReturnRC (autoCaller.rc());
    615 
    616     AutoWriteLock alock (this);
     633    AutoCaller autoCaller(this);
     634    CheckComRCReturnRC(autoCaller.rc());
     635
     636    AutoWriteLock alock(this);
    617637
    618638    /* if we're already completed, take a shortcut */
     
    667687 *       calling this method will definitey freese event processing.
    668688 */
    669 STDMETHODIMP Progress::WaitForOperationCompletion (ULONG aOperation, LONG aTimeout)
     689STDMETHODIMP Progress::WaitForOperationCompletion(ULONG aOperation, LONG aTimeout)
    670690{
    671691    LogFlowThisFuncEnter();
    672692    LogFlowThisFunc (("aOperation=%d, aTimeout=%d\n", aOperation, aTimeout));
    673693
    674     AutoCaller autoCaller (this);
    675     CheckComRCReturnRC (autoCaller.rc());
    676 
    677     AutoWriteLock alock (this);
    678 
    679     CheckComArgExpr(aOperation, aOperation < mOperationCount);
     694    AutoCaller autoCaller(this);
     695    CheckComRCReturnRC(autoCaller.rc());
     696
     697    AutoWriteLock alock(this);
     698
     699    CheckComArgExpr(aOperation, aOperation < m_cOperations);
    680700
    681701    /* if we're already completed or if the given operation is already done,
    682702     * then take a shortcut */
    683     if (!mCompleted && aOperation >= mOperation)
     703    if (    !mCompleted
     704         && aOperation >= m_ulCurrentOperation)
    684705    {
    685706        RTTIMESPEC time;
     
    691712        int64_t lastTime = RTTimeSpecGetMilli (&time);
    692713
    693         while (!mCompleted && aOperation >= mOperation &&
     714        while (!mCompleted && aOperation >= m_ulCurrentOperation &&
    694715               (forever || timeLeft > 0))
    695716        {
     
    729750STDMETHODIMP Progress::Cancel()
    730751{
    731     AutoCaller autoCaller (this);
    732     CheckComRCReturnRC (autoCaller.rc());
    733 
    734     AutoWriteLock alock (this);
     752    AutoCaller autoCaller(this);
     753    CheckComRCReturnRC(autoCaller.rc());
     754
     755    AutoWriteLock alock(this);
    735756
    736757    if (!mCancelable)
     
    751772 *                  (in range [0, 100]).
    752773 */
    753 HRESULT Progress::notifyProgress (LONG aPercent)
    754 {
    755     AutoCaller autoCaller (this);
     774HRESULT Progress::setCurrentOperationProgress(ULONG aPercent)
     775{
     776    AutoCaller autoCaller(this);
    756777    AssertComRCReturnRC (autoCaller.rc());
    757778
    758     AutoWriteLock alock (this);
    759 
    760     AssertReturn (aPercent >= 0 && aPercent <= 100, E_INVALIDARG);
     779    AutoWriteLock alock(this);
     780
     781    AssertReturn(aPercent <= 100, E_INVALIDARG);
    761782
    762783    if (mCancelable && mCanceled)
     
    768789        AssertReturn (!mCompleted && !mCanceled, E_FAIL);
    769790
    770 
    771     mOperationPercent = aPercent;
     791    m_ulOperationPercent = aPercent;
    772792
    773793    return S_OK;
     
    782802 * @note The current operation must not be the last one.
    783803 */
    784 HRESULT Progress::advanceOperation (CBSTR aOperationDescription)
    785 {
    786     AssertReturn (aOperationDescription, E_INVALIDARG);
    787 
    788     AutoCaller autoCaller (this);
     804HRESULT Progress::setNextOperation(CBSTR bstrNextOperationDescription, ULONG ulNextOperationsWeight)
     805{
     806    AssertReturn(bstrNextOperationDescription, E_INVALIDARG);
     807
     808    AutoCaller autoCaller(this);
    789809    AssertComRCReturnRC (autoCaller.rc());
    790810
    791     AutoWriteLock alock (this);
     811    AutoWriteLock alock(this);
    792812
    793813    AssertReturn (!mCompleted && !mCanceled, E_FAIL);
    794     AssertReturn (mOperation + 1 < mOperationCount, E_FAIL);
    795 
    796     mOperation ++;
    797     mOperationDescription = aOperationDescription;
    798     mOperationPercent = 0;
     814    AssertReturn (m_ulCurrentOperation + 1 < m_cOperations, E_FAIL);
     815
     816    ++m_ulCurrentOperation;
     817    m_ulOperationsCompletedWeight += m_ulCurrentOperationWeight;
     818
     819    m_bstrOperationDescription = bstrNextOperationDescription;
     820    m_ulCurrentOperationWeight = ulNextOperationsWeight;
     821    m_ulOperationPercent = 0;
     822
     823    Log(("Progress::setNextOperation(%ls): ulNextOperationsWeight = %d; m_ulCurrentOperation is now %d, m_ulOperationsCompletedWeightis now %d\n",
     824         m_bstrOperationDescription.raw(), ulNextOperationsWeight, m_ulCurrentOperation, m_ulOperationsCompletedWeight));
    799825
    800826    /* wake up all waiting threads */
     
    823849HRESULT Progress::notifyComplete (HRESULT aResultCode)
    824850{
    825     AutoCaller autoCaller (this);
     851    AutoCaller autoCaller(this);
    826852    AssertComRCReturnRC (autoCaller.rc());
    827853
    828     AutoWriteLock alock (this);
     854    AutoWriteLock alock(this);
    829855
    830856    AssertReturn (mCompleted == FALSE, E_FAIL);
     
    880906    else
    881907    {
    882         mOperation = mOperationCount - 1; /* last operation */
    883         mOperationPercent = 100;
     908        m_ulCurrentOperation = m_cOperations - 1; /* last operation */
     909        m_ulOperationPercent = 100;
    884910    }
    885911
     
    939965                                      const Bstr &aComponent, const Bstr &aText)
    940966{
    941     AutoCaller autoCaller (this);
     967    AutoCaller autoCaller(this);
    942968    AssertComRCReturnRC (autoCaller.rc());
    943969
    944     AutoWriteLock alock (this);
     970    AutoWriteLock alock(this);
    945971
    946972    AssertReturn (mCompleted == FALSE, E_FAIL);
     
    10351061    mCanceled = FALSE;
    10361062
    1037     mOperationCount = 0; /* will be calculated later */
    1038 
    1039     mOperation = 0;
     1063    m_cOperations = 0; /* will be calculated later */
     1064
     1065    m_ulCurrentOperation = 0;
    10401066    rc = mProgresses [0]->COMGETTER(OperationDescription) (
    1041         mOperationDescription.asOutParam());
     1067        m_bstrOperationDescription.asOutParam());
    10421068    CheckComRCReturnRC (rc);
    10431069
     
    10591085            CheckComRCReturnRC (rc);
    10601086
    1061             mOperationCount += opCount;
     1087            m_cOperations += opCount;
    10621088        }
    10631089    }
     
    11331159////////////////////////////////////////////////////////////////////////////////
    11341160
    1135 STDMETHODIMP CombinedProgress::COMGETTER(Percent) (LONG *aPercent)
     1161STDMETHODIMP CombinedProgress::COMGETTER(Percent)(ULONG *aPercent)
    11361162{
    11371163    CheckComArgOutPointerValid(aPercent);
    11381164
    1139     AutoCaller autoCaller (this);
    1140     CheckComRCReturnRC (autoCaller.rc());
     1165    AutoCaller autoCaller(this);
     1166    CheckComRCReturnRC(autoCaller.rc());
    11411167
    11421168    /* checkProgress needs a write lock */
    1143     AutoWriteLock alock (this);
     1169    AutoWriteLock alock(this);
    11441170
    11451171    if (mCompleted && SUCCEEDED (mResultCode))
     
    11511177
    11521178        /* global percent =
    1153          *      (100 / mOperationCount) * mOperation +
    1154          *      ((100 / mOperationCount) / 100) * mOperationPercent */
    1155         *aPercent = (100 * mOperation + mOperationPercent) / mOperationCount;
     1179         *      (100 / m_cOperations) * mOperation +
     1180         *      ((100 / m_cOperations) / 100) * m_ulOperationPercent */
     1181        *aPercent = (100 * m_ulCurrentOperation + m_ulOperationPercent) / m_cOperations;
    11561182    }
    11571183
     
    11631189    CheckComArgOutPointerValid(aCompleted);
    11641190
    1165     AutoCaller autoCaller (this);
    1166     CheckComRCReturnRC (autoCaller.rc());
     1191    AutoCaller autoCaller(this);
     1192    CheckComRCReturnRC(autoCaller.rc());
    11671193
    11681194    /* checkProgress needs a write lock */
    1169     AutoWriteLock alock (this);
     1195    AutoWriteLock alock(this);
    11701196
    11711197    HRESULT rc = checkProgress();
     
    11791205    CheckComArgOutPointerValid(aCanceled);
    11801206
    1181     AutoCaller autoCaller (this);
    1182     CheckComRCReturnRC (autoCaller.rc());
     1207    AutoCaller autoCaller(this);
     1208    CheckComRCReturnRC(autoCaller.rc());
    11831209
    11841210    /* checkProgress needs a write lock */
    1185     AutoWriteLock alock (this);
     1211    AutoWriteLock alock(this);
    11861212
    11871213    HRESULT rc = checkProgress();
     
    11951221    CheckComArgOutPointerValid(aResultCode);
    11961222
    1197     AutoCaller autoCaller (this);
    1198     CheckComRCReturnRC (autoCaller.rc());
     1223    AutoCaller autoCaller(this);
     1224    CheckComRCReturnRC(autoCaller.rc());
    11991225
    12001226    /* checkProgress needs a write lock */
    1201     AutoWriteLock alock (this);
     1227    AutoWriteLock alock(this);
    12021228
    12031229    HRESULT rc = checkProgress();
     
    12111237    CheckComArgOutPointerValid(aErrorInfo);
    12121238
    1213     AutoCaller autoCaller (this);
    1214     CheckComRCReturnRC (autoCaller.rc());
     1239    AutoCaller autoCaller(this);
     1240    CheckComRCReturnRC(autoCaller.rc());
    12151241
    12161242    /* checkProgress needs a write lock */
    1217     AutoWriteLock alock (this);
     1243    AutoWriteLock alock(this);
    12181244
    12191245    HRESULT rc = checkProgress();
     
    12271253    CheckComArgOutPointerValid(aOperation);
    12281254
    1229     AutoCaller autoCaller (this);
    1230     CheckComRCReturnRC (autoCaller.rc());
     1255    AutoCaller autoCaller(this);
     1256    CheckComRCReturnRC(autoCaller.rc());
    12311257
    12321258    /* checkProgress needs a write lock */
    1233     AutoWriteLock alock (this);
     1259    AutoWriteLock alock(this);
    12341260
    12351261    HRESULT rc = checkProgress();
     
    12431269    CheckComArgOutPointerValid(aOperationDescription);
    12441270
    1245     AutoCaller autoCaller (this);
    1246     CheckComRCReturnRC (autoCaller.rc());
     1271    AutoCaller autoCaller(this);
     1272    CheckComRCReturnRC(autoCaller.rc());
    12471273
    12481274    /* checkProgress needs a write lock */
    1249     AutoWriteLock alock (this);
     1275    AutoWriteLock alock(this);
    12501276
    12511277    HRESULT rc = checkProgress();
     
    12551281}
    12561282
    1257 STDMETHODIMP CombinedProgress::COMGETTER(OperationPercent) (LONG *aOperationPercent)
     1283STDMETHODIMP CombinedProgress::COMGETTER(OperationPercent)(ULONG *aOperationPercent)
    12581284{
    12591285    CheckComArgOutPointerValid(aOperationPercent);
    12601286
    1261     AutoCaller autoCaller (this);
    1262     CheckComRCReturnRC (autoCaller.rc());
     1287    AutoCaller autoCaller(this);
     1288    CheckComRCReturnRC(autoCaller.rc());
    12631289
    12641290    /* checkProgress needs a write lock */
    1265     AutoWriteLock alock (this);
     1291    AutoWriteLock alock(this);
    12661292
    12671293    HRESULT rc = checkProgress();
     
    12851311    LogFlowThisFunc (("aTtimeout=%d\n", aTimeout));
    12861312
    1287     AutoCaller autoCaller (this);
    1288     CheckComRCReturnRC (autoCaller.rc());
    1289 
    1290     AutoWriteLock alock (this);
     1313    AutoCaller autoCaller(this);
     1314    CheckComRCReturnRC(autoCaller.rc());
     1315
     1316    AutoWriteLock alock(this);
    12911317
    12921318    /* if we're already completed, take a shortcut */
     
    13401366    LogFlowThisFunc (("aOperation=%d, aTimeout=%d\n", aOperation, aTimeout));
    13411367
    1342     AutoCaller autoCaller (this);
    1343     CheckComRCReturnRC (autoCaller.rc());
    1344 
    1345     AutoWriteLock alock (this);
    1346 
    1347     if (aOperation >= mOperationCount)
     1368    AutoCaller autoCaller(this);
     1369    CheckComRCReturnRC(autoCaller.rc());
     1370
     1371    AutoWriteLock alock(this);
     1372
     1373    if (aOperation >= m_cOperations)
    13481374        return setError (E_FAIL,
    1349             tr ("Operation number must be in range [0, %d]"), mOperation - 1);
     1375            tr ("Operation number must be in range [0, %d]"), m_ulCurrentOperation - 1);
    13501376
    13511377    /* if we're already completed or if the given operation is already done,
    13521378     * then take a shortcut */
    1353     if (!mCompleted && aOperation >= mOperation)
     1379    if (!mCompleted && aOperation >= m_ulCurrentOperation)
    13541380    {
    13551381        HRESULT rc = S_OK;
     
    13881414        int64_t lastTime = RTTimeSpecGetMilli (&time);
    13891415
    1390         while (!mCompleted && aOperation >= mOperation &&
     1416        while (!mCompleted && aOperation >= m_ulCurrentOperation &&
    13911417               (forever || timeLeft > 0))
    13921418        {
     
    14201446STDMETHODIMP CombinedProgress::Cancel()
    14211447{
    1422     AutoCaller autoCaller (this);
    1423     CheckComRCReturnRC (autoCaller.rc());
    1424 
    1425     AutoWriteLock alock (this);
     1448    AutoCaller autoCaller(this);
     1449    CheckComRCReturnRC(autoCaller.rc());
     1450
     1451    AutoWriteLock alock(this);
    14261452
    14271453    if (!mCancelable)
     
    15021528    while (completed && !mCompleted);
    15031529
    1504     rc = progress->COMGETTER(OperationPercent) (&mOperationPercent);
     1530    rc = progress->COMGETTER(OperationPercent) (&m_ulOperationPercent);
    15051531    if (SUCCEEDED (rc))
    15061532    {
    15071533        ULONG operation = 0;
    15081534        rc = progress->COMGETTER(Operation) (&operation);
    1509         if (SUCCEEDED (rc) && mCompletedOperations + operation > mOperation)
     1535        if (SUCCEEDED (rc) && mCompletedOperations + operation > m_ulCurrentOperation)
    15101536        {
    1511             mOperation = mCompletedOperations + operation;
     1537            m_ulCurrentOperation = mCompletedOperations + operation;
    15121538            rc = progress->COMGETTER(OperationDescription) (
    1513                 mOperationDescription.asOutParam());
     1539                m_bstrOperationDescription.asOutParam());
    15141540        }
    15151541    }
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r18258 r18269  
    78167816  <interface
    78177817     name="IProgress" extends="$unknown"
    7818      uuid="d3aa5417-6103-41fc-9e54-01ee1d08f42f"
     7818     uuid="ee1aa091-fda8-47a9-8f1c-4bba002a3229"
    78197819     wsmap="managed"
    78207820     >
     
    78717871    </attribute>
    78727872
    7873     <attribute name="percent" type="long" readonly="yes">
     7873    <attribute name="percent" type="unsigned long" readonly="yes">
    78747874      <desc>
    78757875        Current progress value of the task as a whole, in percent.
    78767876        This value depends on how many operations are already complete.
     7877        Returns 100 if <link to="#completed" /> is true.
    78777878      </desc>
    78787879    </attribute>
     
    79207921    </attribute>
    79217922
    7922     <attribute name="operationPercent" type="long" readonly="yes">
     7923    <attribute name="operationPercent" type="unsigned long" readonly="yes">
    79237924        <desc>Progress value of the current sub-operation only, in percent.</desc>
    79247925    </attribute>
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r18214 r18269  
    3434
    3535class VirtualBox;
     36class Progress;
    3637
    3738class ATL_NO_VTABLE Appliance :
     
    9697    HRESULT searchUniqueVMName(Utf8Str& aName) const;
    9798    HRESULT searchUniqueDiskImageFilePath(Utf8Str& aName) const;
    98     uint32_t calcMaxProgress();
     99    HRESULT setUpProgress(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription);
    99100    void addWarning(const char* aWarning, ...);
    100101
     
    116117    Utf8Str strVbox;                        // configuration value (type-dependent)
    117118    Utf8Str strExtraConfig;                 // extra configuration key=value strings (type-dependent)
     119
     120    uint32_t ulSizeMB;                      // hard disk images only: size of the uncompressed image in MB
    118121};
    119122
     
    187190                  const Utf8Str &aOrigValue,
    188191                  const Utf8Str &aAutoValue,
     192                  uint32_t ulSizeMB = 0,
    189193                  const Utf8Str &strExtraConfig = "");
    190194
  • trunk/src/VBox/Main/include/ProgressImpl.h

    r17684 r18269  
    7272    // IProgress properties
    7373    STDMETHOD(COMGETTER(Cancelable)) (BOOL *aCancelable);
    74     STDMETHOD(COMGETTER(Percent)) (LONG *aPercent);
     74    STDMETHOD(COMGETTER(Percent)) (ULONG *aPercent);
    7575    STDMETHOD(COMGETTER(Completed)) (BOOL *aCompleted);
    7676    STDMETHOD(COMGETTER(Canceled)) (BOOL *aCanceled);
     
    8080    STDMETHOD(COMGETTER(Operation)) (ULONG *aCount);
    8181    STDMETHOD(COMGETTER(OperationDescription)) (BSTR *aOperationDescription);
    82     STDMETHOD(COMGETTER(OperationPercent)) (LONG *aOperationPercent);
     82    STDMETHOD(COMGETTER(OperationPercent)) (ULONG *aOperationPercent);
    8383
    8484    // public methods only for internal purposes
     
    112112    ComPtr <IVirtualBoxErrorInfo> mErrorInfo;
    113113
    114     ULONG mOperationCount;
    115     ULONG mOperation;
    116     Bstr mOperationDescription;
    117     LONG mOperationPercent;
     114    ULONG m_cOperations;                            // number of operations (so that progress dialog can display something like 1/3)
     115    ULONG m_ulTotalOperationsWeight;                // sum of weights of all operations, given to constructor
     116
     117    ULONG m_ulOperationsCompletedWeight;            // summed-up weight of operations that have been completed; initially 0
     118
     119    ULONG m_ulCurrentOperation;                     // operations counter, incremented with each setNextOperation()
     120    Bstr m_bstrOperationDescription;                // name of current operation; initially from constructor, changed with setNextOperation()
     121    ULONG m_ulCurrentOperationWeight;               // weight of current operation, given to setNextOperation()
     122    ULONG m_ulOperationPercent;                     // percentage of current operation, set with setCurrentOperationProgress()
    118123};
    119124
     
    148153    // public initializer/uninitializer for internal purposes only
    149154
    150     HRESULT init (
     155    /**
     156     * Simplified constructor for progress objects that have only one
     157     * operation as a task.
     158     * @param aParent
     159     * @param aInitiator
     160     * @param aDescription
     161     * @param aCancelable
     162     * @param aId
     163     * @return
     164     */
     165    HRESULT init(
    151166#if !defined (VBOX_COM_INPROC)
    152167                  VirtualBox *aParent,
     
    156171                  OUT_GUID aId = NULL)
    157172    {
    158         return init (
     173        return init(
    159174#if !defined (VBOX_COM_INPROC)
    160175            aParent,
    161176#endif
    162             aInitiator, aDescription, aCancelable, 1, aDescription, aId);
     177            aInitiator,
     178            aDescription,
     179            aCancelable,
     180            1,      // cOperations
     181            1,      // ulTotalOperationsWeight
     182            aDescription, // bstrFirstOperationDescription
     183            1,      // ulFirstOperationWeight
     184            aId);
    163185    }
    164186
    165     HRESULT init (
     187    /**
     188     * Not quite so simplified constructor for progress objects that have
     189     * more than one operation, but all sub-operations are weighed the same.
     190     * @param aParent
     191     * @param aInitiator
     192     * @param aDescription
     193     * @param aCancelable
     194     * @param cOperations
     195     * @param bstrFirstOperationDescription
     196     * @param aId
     197     * @return
     198     */
     199    HRESULT init(
    166200#if !defined (VBOX_COM_INPROC)
    167201                  VirtualBox *aParent,
     
    169203                  IUnknown *aInitiator,
    170204                  CBSTR aDescription, BOOL aCancelable,
    171                   ULONG aOperationCount, CBSTR aOperationDescription,
     205                  ULONG cOperations,
     206                  CBSTR bstrFirstOperationDescription,
     207                  OUT_GUID aId = NULL)
     208    {
     209        return init(
     210#if !defined (VBOX_COM_INPROC)
     211            aParent,
     212#endif
     213            aInitiator,
     214            aDescription,
     215            aCancelable,
     216            cOperations,      // cOperations
     217            cOperations,      // ulTotalOperationsWeight = cOperations
     218            bstrFirstOperationDescription, // bstrFirstOperationDescription
     219            1,      // ulFirstOperationWeight: weigh them all the same
     220            aId);
     221    }
     222
     223    HRESULT init(
     224#if !defined (VBOX_COM_INPROC)
     225                  VirtualBox *aParent,
     226#endif
     227                  IUnknown *aInitiator,
     228                  CBSTR aDescription, BOOL aCancelable,
     229                  ULONG cOperations, ULONG ulTotalOperationsWeight,
     230                  CBSTR bstrFirstOperationDescription, ULONG ulFirstOperationWeight,
    172231                  OUT_GUID aId = NULL);
    173232
     
    178237
    179238    // IProgress methods
    180     STDMETHOD(WaitForCompletion) (LONG aTimeout);
    181     STDMETHOD(WaitForOperationCompletion) (ULONG aOperation, LONG aTimeout);
     239    STDMETHOD(WaitForCompletion)(LONG aTimeout);
     240    STDMETHOD(WaitForOperationCompletion)(ULONG aOperation, LONG aTimeout);
    182241    STDMETHOD(Cancel)();
    183242
    184243    // public methods only for internal purposes
    185244
    186     HRESULT notifyProgress (LONG aPercent);
    187     HRESULT advanceOperation (CBSTR aOperationDescription);
    188 
    189     HRESULT notifyComplete (HRESULT aResultCode);
    190     HRESULT notifyComplete (HRESULT aResultCode, const GUID &aIID,
    191                             const Bstr &aComponent,
    192                             const char *aText, ...);
    193     HRESULT notifyCompleteBstr (HRESULT aResultCode, const GUID &aIID,
    194                                 const Bstr &aComponent, const Bstr &aText);
     245    HRESULT setCurrentOperationProgress(ULONG aPercent);
     246    HRESULT setNextOperation(CBSTR bstrNextOperationDescription, ULONG ulNextOperationsWeight);
     247
     248    HRESULT notifyComplete(HRESULT aResultCode);
     249    HRESULT notifyComplete(HRESULT aResultCode, const GUID &aIID,
     250                           const Bstr &aComponent,
     251                           const char *aText, ...);
     252    HRESULT notifyCompleteBstr(HRESULT aResultCode, const GUID &aIID,
     253                               const Bstr &aComponent, const Bstr &aText);
    195254
    196255    /** For com::SupportErrorInfoImpl. */
     
    328387
    329388    // IProgress properties
    330     STDMETHOD(COMGETTER(Percent)) (LONG *aPercent);
     389    STDMETHOD(COMGETTER(Percent)) (ULONG *aPercent);
    331390    STDMETHOD(COMGETTER(Completed)) (BOOL *aCompleted);
    332391    STDMETHOD(COMGETTER(Canceled)) (BOOL *aCanceled);
     
    335394    STDMETHOD(COMGETTER(Operation)) (ULONG *aCount);
    336395    STDMETHOD(COMGETTER(OperationDescription)) (BSTR *aOperationDescription);
    337     STDMETHOD(COMGETTER(OperationPercent)) (LONG *aOperationPercent);
     396    STDMETHOD(COMGETTER(OperationPercent)) (ULONG *aOperationPercent);
    338397
    339398    // IProgress methods
     
    359418
    360419#endif /* ____H_PROGRESSIMPL */
    361 /* vi: set tabstop=4 shiftwidth=4 expandtab: */
     420
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