Index: /trunk/src/VBox/Main/src-all/ProgressImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-all/ProgressImpl.cpp	(revision 44123)
+++ /trunk/src/VBox/Main/src-all/ProgressImpl.cpp	(revision 44124)
@@ -19,4 +19,5 @@
 #include <iprt/types.h>
 
+
 #if defined(VBOX_WITH_XPCOM)
 #include <nsIServiceManager.h>
@@ -25,5 +26,5 @@
 #endif /* defined(VBOX_WITH_XPCOM) */
 
-#include "ProgressCombinedImpl.h"
+#include "ProgressImpl.h"
 
 #include "VirtualBoxImpl.h"
@@ -37,4 +38,5 @@
 
 #include <VBox/err.h>
+#include "AutoCaller.h"
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -1322,570 +1324,2 @@
 }
 
-////////////////////////////////////////////////////////////////////////////////
-// CombinedProgress class
-////////////////////////////////////////////////////////////////////////////////
-
-HRESULT CombinedProgress::FinalConstruct()
-{
-    HRESULT rc = ProgressBase::FinalConstruct();
-    if (FAILED(rc)) return rc;
-
-    mProgress = 0;
-    mCompletedOperations = 0;
-
-    return BaseFinalConstruct();
-}
-
-void CombinedProgress::FinalRelease()
-{
-    uninit();
-    BaseFinalRelease();
-}
-
-// public initializer/uninitializer for internal purposes only
-////////////////////////////////////////////////////////////////////////////////
-
-/**
- * Initializes this object based on individual combined progresses.
- * Must be called only from #init()!
- *
- * @param aAutoInitSpan AutoInitSpan object instantiated by a subclass.
- * @param aParent       See ProgressBase::init().
- * @param aInitiator    See ProgressBase::init().
- * @param aDescription  See ProgressBase::init().
- * @param aId           See ProgressBase::init().
- */
-HRESULT CombinedProgress::protectedInit(AutoInitSpan &aAutoInitSpan,
-#if !defined(VBOX_COM_INPROC)
-                                        VirtualBox *aParent,
-#endif
-                                        IUnknown *aInitiator,
-                                        CBSTR aDescription, OUT_GUID aId)
-{
-    LogFlowThisFunc(("aDescription={%ls} mProgresses.size()=%d\n",
-                      aDescription, mProgresses.size()));
-
-    HRESULT rc = S_OK;
-
-    rc = ProgressBase::protectedInit(aAutoInitSpan,
-#if !defined(VBOX_COM_INPROC)
-                                     aParent,
-#endif
-                                     aInitiator, aDescription, aId);
-    if (FAILED(rc)) return rc;
-
-    mProgress = 0; /* the first object */
-    mCompletedOperations = 0;
-
-    mCompleted = FALSE;
-    mCancelable = TRUE; /* until any progress returns FALSE */
-    mCanceled = FALSE;
-
-    m_cOperations = 0; /* will be calculated later */
-
-    m_ulCurrentOperation = 0;
-    rc = mProgresses[0]->COMGETTER(OperationDescription)(m_bstrOperationDescription.asOutParam());
-    if (FAILED(rc)) return rc;
-
-    for (size_t i = 0; i < mProgresses.size(); i ++)
-    {
-        if (mCancelable)
-        {
-            BOOL cancelable = FALSE;
-            rc = mProgresses[i]->COMGETTER(Cancelable)(&cancelable);
-            if (FAILED(rc)) return rc;
-
-            if (!cancelable)
-                mCancelable = FALSE;
-        }
-
-        {
-            ULONG opCount = 0;
-            rc = mProgresses[i]->COMGETTER(OperationCount)(&opCount);
-            if (FAILED(rc)) return rc;
-
-            m_cOperations += opCount;
-        }
-    }
-
-    rc =  checkProgress();
-    if (FAILED(rc)) return rc;
-
-    return rc;
-}
-
-/**
- * Initializes the combined progress object given two normal progress
- * objects.
- *
- * @param aParent       See ProgressBase::init().
- * @param aInitiator    See ProgressBase::init().
- * @param aDescription  See ProgressBase::init().
- * @param aProgress1    First normal progress object.
- * @param aProgress2    Second normal progress object.
- * @param aId           See ProgressBase::init().
- */
-HRESULT CombinedProgress::init(
-#if !defined(VBOX_COM_INPROC)
-                               VirtualBox *aParent,
-#endif
-                               IUnknown *aInitiator,
-                               CBSTR aDescription,
-                               IProgress *aProgress1,
-                               IProgress *aProgress2,
-                               OUT_GUID aId /* = NULL */)
-{
-    /* Enclose the state transition NotReady->InInit->Ready */
-    AutoInitSpan autoInitSpan(this);
-    AssertReturn(autoInitSpan.isOk(), E_FAIL);
-
-    mProgresses.resize(2);
-    mProgresses[0] = aProgress1;
-    mProgresses[1] = aProgress2;
-
-    HRESULT rc =  protectedInit(autoInitSpan,
-#if !defined(VBOX_COM_INPROC)
-                                aParent,
-#endif
-                                aInitiator,
-                                aDescription,
-                                aId);
-
-    /* Confirm a successful initialization when it's the case */
-    if (SUCCEEDED(rc))
-        autoInitSpan.setSucceeded();
-
-    return rc;
-}
-
-/**
- * Uninitializes the instance and sets the ready flag to FALSE.
- *
- * Called either from FinalRelease() or by the parent when it gets destroyed.
- */
-void CombinedProgress::uninit()
-{
-    LogFlowThisFunc(("\n"));
-
-    /* Enclose the state transition Ready->InUninit->NotReady */
-    AutoUninitSpan autoUninitSpan(this);
-    if (autoUninitSpan.uninitDone())
-        return;
-
-    mProgress = 0;
-    mProgresses.clear();
-
-    ProgressBase::protectedUninit(autoUninitSpan);
-}
-
-// IProgress properties
-////////////////////////////////////////////////////////////////////////////////
-
-STDMETHODIMP CombinedProgress::COMGETTER(Percent)(ULONG *aPercent)
-{
-    CheckComArgOutPointerValid(aPercent);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    /* checkProgress needs a write lock */
-    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
-
-    if (mCompleted && SUCCEEDED(mResultCode))
-        *aPercent = 100;
-    else
-    {
-        HRESULT rc = checkProgress();
-        if (FAILED(rc)) return rc;
-
-        /* global percent =
-         *      (100 / m_cOperations) * mOperation +
-         *      ((100 / m_cOperations) / 100) * m_ulOperationPercent */
-        *aPercent = (100 * m_ulCurrentOperation + m_ulOperationPercent) / m_cOperations;
-    }
-
-    return S_OK;
-}
-
-STDMETHODIMP CombinedProgress::COMGETTER(Completed)(BOOL *aCompleted)
-{
-    CheckComArgOutPointerValid(aCompleted);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    /* checkProgress needs a write lock */
-    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
-
-    HRESULT rc = checkProgress();
-    if (FAILED(rc)) return rc;
-
-    return ProgressBase::COMGETTER(Completed)(aCompleted);
-}
-
-STDMETHODIMP CombinedProgress::COMGETTER(Canceled)(BOOL *aCanceled)
-{
-    CheckComArgOutPointerValid(aCanceled);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    /* checkProgress needs a write lock */
-    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
-
-    HRESULT rc = checkProgress();
-    if (FAILED(rc)) return rc;
-
-    return ProgressBase::COMGETTER(Canceled)(aCanceled);
-}
-
-STDMETHODIMP CombinedProgress::COMGETTER(ResultCode)(LONG *aResultCode)
-{
-    CheckComArgOutPointerValid(aResultCode);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    /* checkProgress needs a write lock */
-    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
-
-    HRESULT rc = checkProgress();
-    if (FAILED(rc)) return rc;
-
-    return ProgressBase::COMGETTER(ResultCode)(aResultCode);
-}
-
-STDMETHODIMP CombinedProgress::COMGETTER(ErrorInfo)(IVirtualBoxErrorInfo **aErrorInfo)
-{
-    CheckComArgOutPointerValid(aErrorInfo);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    /* checkProgress needs a write lock */
-    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
-
-    HRESULT rc = checkProgress();
-    if (FAILED(rc)) return rc;
-
-    return ProgressBase::COMGETTER(ErrorInfo)(aErrorInfo);
-}
-
-STDMETHODIMP CombinedProgress::COMGETTER(Operation)(ULONG *aOperation)
-{
-    CheckComArgOutPointerValid(aOperation);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    /* checkProgress needs a write lock */
-    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
-
-    HRESULT rc = checkProgress();
-    if (FAILED(rc)) return rc;
-
-    return ProgressBase::COMGETTER(Operation)(aOperation);
-}
-
-STDMETHODIMP CombinedProgress::COMGETTER(OperationDescription)(BSTR *aOperationDescription)
-{
-    CheckComArgOutPointerValid(aOperationDescription);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    /* checkProgress needs a write lock */
-    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
-
-    HRESULT rc = checkProgress();
-    if (FAILED(rc)) return rc;
-
-    return ProgressBase::COMGETTER(OperationDescription)(aOperationDescription);
-}
-
-STDMETHODIMP CombinedProgress::COMGETTER(OperationPercent)(ULONG *aOperationPercent)
-{
-    CheckComArgOutPointerValid(aOperationPercent);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    /* checkProgress needs a write lock */
-    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
-
-    HRESULT rc = checkProgress();
-    if (FAILED(rc)) return rc;
-
-    return ProgressBase::COMGETTER(OperationPercent)(aOperationPercent);
-}
-
-STDMETHODIMP CombinedProgress::COMSETTER(Timeout)(ULONG aTimeout)
-{
-    NOREF(aTimeout);
-    AssertFailed();
-    return E_NOTIMPL;
-}
-
-STDMETHODIMP CombinedProgress::COMGETTER(Timeout)(ULONG *aTimeout)
-{
-    CheckComArgOutPointerValid(aTimeout);
-
-    AssertFailed();
-    return E_NOTIMPL;
-}
-
-// IProgress methods
-/////////////////////////////////////////////////////////////////////////////
-
-/**
- * @note XPCOM: when this method is called not on the main XPCOM thread, it
- *       simply blocks the thread until mCompletedSem is signalled. If the
- *       thread has its own event queue (hmm, what for?) that it must run, then
- *       calling this method will definitely freeze event processing.
- */
-STDMETHODIMP CombinedProgress::WaitForCompletion(LONG aTimeout)
-{
-    LogFlowThisFuncEnter();
-    LogFlowThisFunc(("aTtimeout=%d\n", aTimeout));
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
-
-    /* if we're already completed, take a shortcut */
-    if (!mCompleted)
-    {
-        HRESULT rc = S_OK;
-        bool forever = aTimeout < 0;
-        int64_t timeLeft = aTimeout;
-        int64_t lastTime = RTTimeMilliTS();
-
-        while (!mCompleted && (forever || timeLeft > 0))
-        {
-            alock.release();
-            rc = mProgresses.back()->WaitForCompletion(forever ? -1 : (LONG) timeLeft);
-            alock.acquire();
-
-            if (SUCCEEDED(rc))
-                rc = checkProgress();
-
-            if (FAILED(rc)) break;
-
-            if (!forever)
-            {
-                int64_t now = RTTimeMilliTS();
-                timeLeft -= now - lastTime;
-                lastTime = now;
-            }
-        }
-
-        if (FAILED(rc)) return rc;
-    }
-
-    LogFlowThisFuncLeave();
-
-    return S_OK;
-}
-
-/**
- * @note XPCOM: when this method is called not on the main XPCOM thread, it
- *       simply blocks the thread until mCompletedSem is signalled. If the
- *       thread has its own event queue (hmm, what for?) that it must run, then
- *       calling this method will definitely freeze event processing.
- */
-STDMETHODIMP CombinedProgress::WaitForOperationCompletion(ULONG aOperation, LONG aTimeout)
-{
-    LogFlowThisFuncEnter();
-    LogFlowThisFunc(("aOperation=%d, aTimeout=%d\n", aOperation, aTimeout));
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
-
-    if (aOperation >= m_cOperations)
-        return setError(E_FAIL,
-                        tr("Operation number must be in range [0, %d]"), m_ulCurrentOperation - 1);
-
-    /* if we're already completed or if the given operation is already done,
-     * then take a shortcut */
-    if (!mCompleted && aOperation >= m_ulCurrentOperation)
-    {
-        HRESULT rc = S_OK;
-
-        /* find the right progress object to wait for */
-        size_t progress = mProgress;
-        ULONG operation = 0, completedOps = mCompletedOperations;
-        do
-        {
-            ULONG opCount = 0;
-            rc = mProgresses[progress]->COMGETTER(OperationCount)(&opCount);
-            if (FAILED(rc))
-                return rc;
-
-            if (completedOps + opCount > aOperation)
-            {
-                /* found the right progress object */
-                operation = aOperation - completedOps;
-                break;
-            }
-
-            completedOps += opCount;
-            progress ++;
-            ComAssertRet(progress < mProgresses.size(), E_FAIL);
-        }
-        while (1);
-
-        LogFlowThisFunc(("will wait for mProgresses [%d] (%d)\n",
-                          progress, operation));
-
-        bool forever = aTimeout < 0;
-        int64_t timeLeft = aTimeout;
-        int64_t lastTime = RTTimeMilliTS();
-
-        while (!mCompleted && aOperation >= m_ulCurrentOperation &&
-               (forever || timeLeft > 0))
-        {
-            alock.release();
-            /* wait for the appropriate progress operation completion */
-            rc = mProgresses[progress]-> WaitForOperationCompletion(operation,
-                                                                    forever ? -1 : (LONG) timeLeft);
-            alock.acquire();
-
-            if (SUCCEEDED(rc))
-                rc = checkProgress();
-
-            if (FAILED(rc)) break;
-
-            if (!forever)
-            {
-                int64_t now = RTTimeMilliTS();
-                timeLeft -= now - lastTime;
-                lastTime = now;
-            }
-        }
-
-        if (FAILED(rc)) return rc;
-    }
-
-    LogFlowThisFuncLeave();
-
-    return S_OK;
-}
-
-STDMETHODIMP CombinedProgress::Cancel()
-{
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
-
-    if (!mCancelable)
-        return setError(E_FAIL, tr("Operation cannot be canceled"));
-
-    if (!mCanceled)
-    {
-        LogThisFunc(("Canceling\n"));
-        mCanceled = TRUE;
-/** @todo Teleportation: Shouldn't this be propagated to mProgresses? If
- *        powerUp creates passes a combined progress object to the client, I
- *        won't get called back since I'm only getting the powerupProgress ...
- *        Or what? */
-        if (m_pfnCancelCallback)
-            m_pfnCancelCallback(m_pvCancelUserArg);
-
-    }
-    else
-        LogThisFunc(("Already canceled\n"));
-
-    return S_OK;
-}
-
-// private methods
-////////////////////////////////////////////////////////////////////////////////
-
-/**
- * Fetches the properties of the current progress object and, if it is
- * successfully completed, advances to the next uncompleted or unsuccessfully
- * completed object in the vector of combined progress objects.
- *
- * @note Must be called from under this object's write lock!
- */
-HRESULT CombinedProgress::checkProgress()
-{
-    /* do nothing if we're already marked ourselves as completed */
-    if (mCompleted)
-        return S_OK;
-
-    AssertReturn(mProgress < mProgresses.size(), E_FAIL);
-
-    ComPtr<IProgress> progress = mProgresses[mProgress];
-    ComAssertRet(!progress.isNull(), E_FAIL);
-
-    HRESULT rc = S_OK;
-    BOOL fCompleted = FALSE;
-
-    do
-    {
-        rc = progress->COMGETTER(Completed)(&fCompleted);
-        if (FAILED(rc))
-            return rc;
-
-        if (fCompleted)
-        {
-            rc = progress->COMGETTER(Canceled)(&mCanceled);
-            if (FAILED(rc))
-                return rc;
-
-            LONG iRc;
-            rc = progress->COMGETTER(ResultCode)(&iRc);
-            if (FAILED(rc))
-                return rc;
-            mResultCode = iRc;
-
-            if (FAILED(mResultCode))
-            {
-                rc = progress->COMGETTER(ErrorInfo)(mErrorInfo.asOutParam());
-                if (FAILED(rc))
-                    return rc;
-            }
-
-            if (FAILED(mResultCode) || mCanceled)
-            {
-                mCompleted = TRUE;
-            }
-            else
-            {
-                ULONG opCount = 0;
-                rc = progress->COMGETTER(OperationCount)(&opCount);
-                if (FAILED(rc))
-                    return rc;
-
-                mCompletedOperations += opCount;
-                mProgress ++;
-
-                if (mProgress < mProgresses.size())
-                    progress = mProgresses[mProgress];
-                else
-                    mCompleted = TRUE;
-            }
-        }
-    }
-    while (fCompleted && !mCompleted);
-
-    rc = progress->COMGETTER(OperationPercent)(&m_ulOperationPercent);
-    if (SUCCEEDED(rc))
-    {
-        ULONG operation = 0;
-        rc = progress->COMGETTER(Operation)(&operation);
-        if (SUCCEEDED(rc) && mCompletedOperations + operation > m_ulCurrentOperation)
-        {
-            m_ulCurrentOperation = mCompletedOperations + operation;
-            rc = progress->COMGETTER(OperationDescription)(m_bstrOperationDescription.asOutParam());
-        }
-    }
-
-    return rc;
-}
-/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Index: /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 44123)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 44124)
@@ -64,5 +64,5 @@
 # include "UsbCardReader.h"
 #endif
-#include "ProgressCombinedImpl.h"
+#include "ProgressImpl.h"
 #include "ConsoleVRDPServer.h"
 #include "VMMDev.h"
@@ -6697,14 +6697,43 @@
             else
             {
-                /* create a combined progress object */
-                ComObjPtr<CombinedProgress> pProgress;
+                // Create a simple progress object
+                ComObjPtr<Progress> pProgress;
                 pProgress.createObject();
+
+                // Assign hard disk progresses to the progresses list
                 VMPowerUpTask::ProgressList progresses(task->hardDiskProgresses);
-                progresses.push_back(ComPtr<IProgress> (pPowerupProgress));
+
+                // Setup params to be used to initialize Progress object properties.
+                ULONG cOperations = 1;
+                ULONG ulTotalOperationsWeight = 1;
+
+                // Go round them and set number of operations and weight.
+                for (VMPowerUpTask::ProgressList::const_iterator it = progresses.begin(); it !=  progresses.end(); ++it)
+                {
+                    ++cOperations;
+                    ulTotalOperationsWeight += 1;
+                }
+
                 rc = pProgress->init(static_cast<IConsole *>(this),
-                                     progressDesc.raw(), progresses.begin(),
-                                     progresses.end());
+                                     progressDesc.raw(),
+                                     TRUE, // Cancelable
+                                     cOperations,
+                                     ulTotalOperationsWeight,
+                                     Bstr(tr("Starting Hard Disk operations")).raw(), // first sub-op decription
+                                     1 );
                 AssertComRCReturnRC(rc);
-                pProgress.queryInterfaceTo(aProgress);
+
+                // Perform all the necessary operations.
+                for (VMPowerUpTask::ProgressList::const_iterator it = progresses.begin(); it !=  progresses.end(); ++it)
+                {
+                    rc = pProgress->SetNextOperation(BstrFmt(tr("Disk Image Reset Operation - Immutable Image")).raw(), 1);
+                    AssertComRCReturnRC(rc);
+                    rc = pProgress.queryInterfaceTo(aProgress);
+                    AssertComRCReturnRC(rc);
+                }
+
+                // Now do the power up.
+                rc = pPowerupProgress.queryInterfaceTo(aProgress);
+                AssertComRCReturnRC(rc);
             }
         }
Index: /trunk/src/VBox/Main/src-client/xpcom/module.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/xpcom/module.cpp	(revision 44123)
+++ /trunk/src/VBox/Main/src-client/xpcom/module.cpp	(revision 44124)
@@ -49,5 +49,4 @@
 #include "NATEngineImpl.h"
 #include "NetworkAdapterImpl.h"
-#include "ProgressCombinedImpl.h"
 #include "ProgressImpl.h"
 #include "RemoteUSBDeviceImpl.h"
@@ -85,6 +84,4 @@
 NS_DECL_CLASSINFO(Progress)
 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Progress, IProgress)
-NS_DECL_CLASSINFO(CombinedProgress)
-NS_IMPL_THREADSAFE_ISUPPORTS1_CI(CombinedProgress, IProgress)
 NS_DECL_CLASSINFO(OUSBDevice)
 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(OUSBDevice, IUSBDevice)
Index: /trunk/src/VBox/Main/src-server/xpcom/server.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/xpcom/server.cpp	(revision 44123)
+++ /trunk/src/VBox/Main/src-server/xpcom/server.cpp	(revision 44124)
@@ -78,5 +78,4 @@
 #include "NetworkAdapterImpl.h"
 #include "ParallelPortImpl.h"
-#include "ProgressCombinedImpl.h"
 #include "ProgressProxyImpl.h"
 #include "SerialPortImpl.h"
@@ -135,7 +134,4 @@
 NS_DECL_CLASSINFO(Progress)
 NS_IMPL_THREADSAFE_ISUPPORTS1_CI(Progress, IProgress)
-
-NS_DECL_CLASSINFO(CombinedProgress)
-NS_IMPL_THREADSAFE_ISUPPORTS1_CI(CombinedProgress, IProgress)
 
 NS_DECL_CLASSINFO(ProgressProxy)
