VirtualBox

Changeset 39475 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Nov 30, 2011 1:20:06 PM (13 years ago)
Author:
vboxsync
Message:

GuestCtrl: More bugfixing, use ComPtr/ComObjPtr.

Location:
trunk/src/VBox/Main/src-client
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp

    r39446 r39475  
    203203    AssertReturn(uContextID, VERR_INVALID_PARAMETER);
    204204    /* pEnmType is optional. */
    205     AssertPtrReturn(ppvData, VERR_INVALID_PARAMETER);
     205    /* ppvData is optional. */
    206206    /* pcbData is optional. */
    207207
     
    209209
    210210    CallbackMapIterConst it = mCallbackMap.find(uContextID);
    211     if (it != mCallbackMap.end())
    212     {
    213         if (pEnmType)
    214             *pEnmType = it->second.mType;
    215 
     211    if (it == mCallbackMap.end())
     212        return VERR_NOT_FOUND;
     213
     214    if (pEnmType)
     215        *pEnmType = it->second.mType;
     216
     217    if (   ppvData
     218        && it->second.cbData)
     219    {
    216220        void *pvData = RTMemAlloc(it->second.cbData);
    217221        AssertPtrReturn(pvData, VERR_NO_MEMORY);
    218222        memcpy(pvData, it->second.pvData, it->second.cbData);
    219223        *ppvData = pvData;
    220 
    221         if (pcbData)
    222             *pcbData = it->second.cbData;
    223 
    224         return VINF_SUCCESS;
    225     }
    226 
    227     return VERR_NOT_FOUND;
     224    }
     225
     226    if (pcbData)
     227        *pcbData = it->second.cbData;
     228
     229    return VINF_SUCCESS;
    228230}
    229231
     
    252254    /* Everything else is optional. */
    253255
    254     int rc = VINF_SUCCESS;
     256    int vrc = VINF_SUCCESS;
    255257    switch (enmType)
    256258    {
     
    279281            PCALLBACKDATAEXECINSTATUS pData = (PCALLBACKDATAEXECINSTATUS)RTMemAlloc(sizeof(CALLBACKDATAEXECINSTATUS));
    280282            AssertPtrReturn(pData, VERR_NO_MEMORY);
    281             RT_BZERO(pData, sizeof(PCALLBACKDATAEXECINSTATUS));
    282             pCallback->cbData = sizeof(PCALLBACKDATAEXECINSTATUS);
     283            RT_BZERO(pData, sizeof(CALLBACKDATAEXECINSTATUS));
     284            pCallback->cbData = sizeof(CALLBACKDATAEXECINSTATUS);
    283285            pCallback->pvData = pData;
    284286            break;
     
    286288
    287289        default:
    288             rc = VERR_INVALID_PARAMETER;
     290            vrc = VERR_INVALID_PARAMETER;
    289291            break;
    290292    }
    291293
    292     if (RT_SUCCESS(rc))
     294    if (RT_SUCCESS(vrc))
    293295    {
    294296        /* Init/set common stuff. */
     
    297299    }
    298300
    299     return rc;
     301    return vrc;
    300302}
    301303
     
    15171519                                          ExecuteProcessStatus_T *pRetStatus, ULONG *puRetExitCode)
    15181520{
    1519     if (uTimeoutMS == 0)
    1520         uTimeoutMS = UINT32_MAX;
    1521 
    1522     uint64_t u64StartMS = RTTimeMilliTS();
    1523 
    1524     HRESULT hRC;
    15251521    ULONG uExitCode, uRetFlags;
    15261522    ExecuteProcessStatus_T curStatus;
    1527     hRC = GetProcessStatus(uPID, &uExitCode, &uRetFlags, &curStatus);
     1523    HRESULT hRC = GetProcessStatus(uPID, &uExitCode, &uRetFlags, &curStatus);
    15281524    if (FAILED(hRC))
    15291525        return hRC;
    15301526
    1531     do
    1532     {
    1533         if (   uTimeoutMS != UINT32_MAX
    1534             && RTTimeMilliTS() - u64StartMS > uTimeoutMS)
    1535         {
    1536             hRC = setError(VBOX_E_IPRT_ERROR,
    1537                            tr("The process (PID %u) did not change its status within time (%ums)"),
    1538                            uPID, uTimeoutMS);
    1539             break;
    1540         }
    1541         hRC = GetProcessStatus(uPID, &uExitCode, &uRetFlags, &curStatus);
    1542         if (FAILED(hRC))
    1543             break;
    1544         RTThreadSleep(100);
    1545     } while(*pRetStatus == curStatus);
     1527    /* We only want to wait for started processes. All other statuses
     1528     * won't be found anyway anymore (see processGetStatus() to know why). */
     1529    if (curStatus == ExecuteProcessStatus_Started)
     1530    {
     1531        uint64_t u64StartMS = RTTimeMilliTS();
     1532        if (uTimeoutMS == 0)
     1533            uTimeoutMS = UINT32_MAX;
     1534
     1535        do
     1536        {
     1537            if (   uTimeoutMS != UINT32_MAX
     1538                && RTTimeMilliTS() - u64StartMS > uTimeoutMS)
     1539            {
     1540                hRC = setError(VBOX_E_IPRT_ERROR,
     1541                               tr("The process (PID %u) did not change its status within time (%ums)"),
     1542                               uPID, uTimeoutMS);
     1543                break;
     1544            }
     1545            hRC = GetProcessStatus(uPID, &uExitCode, &uRetFlags, &curStatus);
     1546            if (FAILED(hRC))
     1547                break;
     1548            RTThreadSleep(100);
     1549        } while(*pRetStatus == curStatus);
     1550    }
    15461551
    15471552    if (SUCCEEDED(hRC))
     
    18521857                          Guest::tr("Cannot inject input to non-existent process (PID %u)"), aPID);
    18531858
    1854         if (SUCCEEDED(rc))
     1859        if (RT_SUCCESS(vrc))
    18551860        {
    18561861            uint32_t uContextID = 0;
     
    19221927                        vrc = pVMMDev->hgcmHostCall("VBoxGuestControlSvc", HOST_EXEC_SET_INPUT,
    19231928                                                   i, paParms);
     1929                        if (RT_FAILURE(vrc))
     1930                            rc = handleErrorHGCM(vrc);
    19241931                    }
    19251932                }
     
    19301937                LogFlowFunc(("Waiting for HGCM callback ...\n"));
    19311938
    1932                 /*
    1933                  * Wait for the HGCM low level callback until the process
    1934                  * has been started (or something went wrong). This is necessary to
    1935                  * get the PID.
     1939                 /*
     1940                 * Wait for getting back the input response from the guest.
    19361941                 */
    1937 
    1938                 PCALLBACKDATAEXECINSTATUS pExecStatusIn = NULL;
    1939 
    1940                  /*
    1941                  * Wait for the first stage (=0) to complete (that is starting the process).
    1942                  */
    1943                 vrc = callbackWaitForCompletion(uContextID, 0 /* Stage */, aTimeoutMS);
     1942                vrc = callbackWaitForCompletion(uContextID, -1 /* No staging required */, aTimeoutMS);
    19441943                if (RT_SUCCESS(vrc))
    19451944                {
     1945                    PCALLBACKDATAEXECINSTATUS pExecStatusIn;
    19461946                    vrc = callbackGetUserData(uContextID, NULL /* We know the type. */,
    19471947                                              (void**)&pExecStatusIn, NULL /* Don't need the size. */);
    19481948                    if (RT_SUCCESS(vrc))
    19491949                    {
     1950                        AssertPtr(pExecStatusIn);
    19501951                        switch (pExecStatusIn->u32Status)
    19511952                        {
     
    19541955                                break;
    19551956
     1957                            case INPUT_STS_ERROR:
     1958                                rc = setError(VBOX_E_IPRT_ERROR,
     1959                                              tr("Client reported error %Rrc while processing input data"),
     1960                                              pExecStatusIn->u32Flags);
     1961                                break;
     1962
     1963                            case INPUT_STS_TERMINATED:
     1964                                rc = setError(VBOX_E_IPRT_ERROR,
     1965                                              tr("Client terminated while processing input data"));
     1966                                break;
     1967
     1968                            case INPUT_STS_OVERFLOW:
     1969                                rc = setError(VBOX_E_IPRT_ERROR,
     1970                                              tr("Client reported buffer overflow while processing input data"));
     1971                                break;
     1972
    19561973                            default:
    1957                                 rc = setError(VBOX_E_IPRT_ERROR,
    1958                                               tr("Client error %u while processing input data"), pExecStatusIn->u32Status);
     1974                                /*AssertReleaseMsgFailed(("Client reported unknown input error, status=%u, flags=%u\n",
     1975                                                        pExecStatusIn->u32Status, pExecStatusIn->u32Flags));*/
    19591976                                break;
    19601977                        }
     
    19701987                else
    19711988                    rc = handleErrorCompletion(vrc);
    1972             }
    1973             else
    1974                 rc = handleErrorHGCM(vrc);
    1975 
    1976             if (SUCCEEDED(rc))
    1977             {
    1978                 /* Nothing to do here yet. */
    19791989            }
    19801990
  • trunk/src/VBox/Main/src-client/GuestCtrlImplTasks.cpp

    r39418 r39475  
    4343    : taskType(aTaskType),
    4444      pGuest(aThat),
    45       progress(aProgress),
     45      pProgress(aProgress),
    4646      rc(S_OK)
    4747{
     
    6767    AssertReturn(task.get(), VERR_GENERAL_FAILURE);
    6868
    69     Guest *pGuest = task->pGuest;
     69    ComObjPtr<Guest> pGuest = task->pGuest;
    7070
    7171    LogFlowFuncEnter();
     
    110110
    111111    if (    pTask
    112         && !pTask->progress.isNull())
     112        && !pTask->pProgress.isNull())
    113113    {
    114114        BOOL fCanceled;
    115         pTask->progress->COMGETTER(Canceled)(&fCanceled);
     115        pTask->pProgress->COMGETTER(Canceled)(&fCanceled);
    116116        if (fCanceled)
    117117            return -1;
    118         pTask->progress->SetCurrentOperationProgress(uPercent);
     118        pTask->pProgress->SetCurrentOperationProgress(uPercent);
    119119    }
    120120    return VINF_SUCCESS;
     
    173173    try
    174174    {
    175         Guest *pGuest = aTask->pGuest;
    176         AssertPtr(pGuest);
     175        ComObjPtr<Guest> pGuest = aTask->pGuest;
    177176
    178177        /* Does our source file exist? */
    179178        if (!RTFileExists(aTask->strSource.c_str()))
    180179        {
    181             rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     180            rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    182181                                                 Guest::tr("Source file \"%s\" does not exist, or is not a file"),
    183182                                                 aTask->strSource.c_str());
     
    190189            if (RT_FAILURE(vrc))
    191190            {
    192                 rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     191                rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    193192                                                     Guest::tr("Could not open source file \"%s\" for reading (%Rrc)"),
    194193                                                     aTask->strSource.c_str(),  vrc);
     
    200199                if (RT_FAILURE(vrc))
    201200                {
    202                     rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     201                    rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    203202                                                         Guest::tr("Could not query file size of \"%s\" (%Rrc)"),
    204203                                                         aTask->strSource.c_str(), vrc);
     
    234233                    else
    235234                    {
    236                         rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     235                        rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    237236                                                             Guest::tr("Error preparing command line"));
    238237                    }
     
    248247                         * actual copying, start the guest part now.
    249248                         */
    250                         rc = pGuest->ExecuteProcess(Bstr(VBOXSERVICE_TOOL_CAT).raw(),
    251                                                       ExecuteProcessFlag_Hidden
    252                                                     | ExecuteProcessFlag_WaitForProcessStartOnly,
    253                                                     ComSafeArrayAsInParam(args),
    254                                                     ComSafeArrayAsInParam(env),
    255                                                     Bstr(aTask->strUserName).raw(),
    256                                                     Bstr(aTask->strPassword).raw(),
    257                                                     5 * 1000 /* Wait 5s for getting the process started. */,
    258                                                     &uPID, execProgress.asOutParam());
     249                        rc = pGuest->executeAndWaitForTool(Bstr(VBOXSERVICE_TOOL_CAT).raw(),
     250                                                           Bstr("Copying file to guest").raw(),
     251                                                           ComSafeArrayAsInParam(args),
     252                                                           ComSafeArrayAsInParam(env),
     253                                                           Bstr(aTask->strUserName).raw(),
     254                                                           Bstr(aTask->strPassword).raw(),
     255                                                           ExecuteProcessFlag_None,
     256                                                           NULL, NULL,
     257                                                           execProgress.asOutParam(), &uPID);
    259258                        if (FAILED(rc))
    260                             rc = GuestTask::setProgressErrorInfo(rc, aTask->progress, pGuest);
     259                            rc = GuestTask::setProgressErrorInfo(rc, aTask->pProgress, pGuest);
    261260                    }
    262261
     
    267266
    268267                        size_t cbToRead = cbSize;
    269                         size_t cbTransfered = 0;
     268                        uint64_t cbTransferedTotal = 0;
     269
    270270                        size_t cbRead;
     271
    271272                        SafeArray<BYTE> aInputData(_64K);
    272273                        while (   SUCCEEDED(execProgress->COMGETTER(Completed(&fCompleted)))
    273274                               && !fCompleted)
    274275                        {
    275                             if (!cbToRead)
    276                                 cbRead = 0;
    277                             else
     276                            /** @todo Not very efficient, but works for now. */
     277                            vrc = RTFileSeek(fileSource, cbTransferedTotal,
     278                                             RTFILE_SEEK_BEGIN, NULL /* poffActual */);
     279                            if (RT_SUCCESS(vrc))
    278280                            {
    279281                                vrc = RTFileRead(fileSource, (uint8_t*)aInputData.raw(),
     
    286288                                if (RT_FAILURE(vrc))
    287289                                {
    288                                     rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     290                                    rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    289291                                                                         Guest::tr("Could not read from file \"%s\" (%Rrc)"),
    290292                                                                         aTask->strSource.c_str(), vrc);
     
    292294                                }
    293295                            }
    294 
     296                            else
     297                                rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
     298                                                                     Guest::tr("Seeking file \"%s\" failed; offset = %RU64 (%Rrc)"),
     299                                                                     aTask->strSource.c_str(), cbTransferedTotal, vrc);
    295300                            /* Resize buffer to reflect amount we just have read.
    296301                             * Size 0 is allowed! */
     
    303308                                || (cbToRead - cbRead == 0)
    304309                                /* ... or does the user want to cancel? */
    305                                 || (   SUCCEEDED(aTask->progress->COMGETTER(Canceled(&fCanceled)))
     310                                || (   SUCCEEDED(aTask->pProgress->COMGETTER(Canceled(&fCanceled)))
    306311                                    && fCanceled)
    307312                               )
     
    310315                            }
    311316
    312                             /* Transfer the current chunk ... */
    313317                            ULONG uBytesWritten;
    314318                            rc = pGuest->SetProcessInput(uPID, uFlags,
    315                                                          10 * 1000 /* Wait 10s for getting the input data transfered. */,
     319                                                         0 /* Infinite timeout */,
    316320                                                         ComSafeArrayAsInParam(aInputData), &uBytesWritten);
    317321                            if (FAILED(rc))
    318322                            {
    319                                 rc = GuestTask::setProgressErrorInfo(rc, aTask->progress, pGuest);
     323                                rc = GuestTask::setProgressErrorInfo(rc, aTask->pProgress, pGuest);
    320324                                break;
    321325                            }
     
    325329                            cbToRead -= cbRead;
    326330
    327                             cbTransfered += uBytesWritten;
    328                             Assert(cbTransfered <= cbSize);
    329                             aTask->progress->SetCurrentOperationProgress(cbTransfered / (cbSize / 100.0));
     331                            cbTransferedTotal += uBytesWritten;
     332                            Assert(cbTransferedTotal <= cbSize);
     333                            aTask->pProgress->SetCurrentOperationProgress(cbTransferedTotal / (cbSize / 100.0));
    330334
    331335                            /* End of file reached? */
     
    341345                                && fCanceled)
    342346                            {
    343                                 rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     347                                rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    344348                                                                     Guest::tr("Copy operation of file \"%s\" was canceled on guest side"),
    345349                                                                     aTask->strSource.c_str());
     
    356360                            ExecuteProcessStatus_T retStatus;
    357361                            ULONG uRetExitCode;
    358                             rc = pGuest->executeWaitForStatusChange(uPID, 10 * 1000 /* 10s timeout. */,
     362                            rc = pGuest->executeWaitForStatusChange(uPID, 0 /* No timeout. */,
    359363                                                                    &retStatus, &uRetExitCode);
    360364                            if (FAILED(rc))
    361365                            {
    362                                 rc = GuestTask::setProgressErrorInfo(rc, aTask->progress, pGuest);
     366                                rc = GuestTask::setProgressErrorInfo(rc, aTask->pProgress, pGuest);
    363367                            }
    364368                            else
     
    367371                                    || retStatus    != ExecuteProcessStatus_TerminatedNormally)
    368372                                {
    369                                     rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     373                                    rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    370374                                                                         Guest::tr("Guest reported error %u while copying file \"%s\" to \"%s\""),
    371375                                                                         uRetExitCode, aTask->strSource.c_str(), aTask->strDest.c_str());
     
    382386                                 * notify the object with a complete event when it's canceled.
    383387                                 */
    384                                 aTask->progress->notifyComplete(VBOX_E_IPRT_ERROR,
     388                                aTask->pProgress->notifyComplete(VBOX_E_IPRT_ERROR,
    385389                                                                COM_IIDOF(IGuest),
    386390                                                                Guest::getStaticComponentName(),
     
    394398                                 */
    395399                                if (   cbSize > 0
    396                                     && cbTransfered == 0)
     400                                    && cbTransferedTotal == 0)
    397401                                {
    398402                                    /* If nothing was transfered but the file size was > 0 then "vbox_cat" wasn't able to write
    399403                                     * to the destination -> access denied. */
    400                                     rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     404                                    rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    401405                                                                         Guest::tr("Access denied when copying file \"%s\" to \"%s\""),
    402406                                                                         aTask->strSource.c_str(), aTask->strDest.c_str());
    403407                                }
    404                                 else if (cbTransfered < cbSize)
     408                                else if (cbTransferedTotal < cbSize)
    405409                                {
    406410                                    /* If we did not copy all let the user know. */
    407                                     rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     411                                    rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    408412                                                                         Guest::tr("Copying file \"%s\" failed (%u/%u bytes transfered)"),
    409                                                                          aTask->strSource.c_str(), cbTransfered, cbSize);
     413                                                                         aTask->strSource.c_str(), cbTransferedTotal, cbSize);
    410414                                }
    411415                                else /* Yay, all went fine! */
    412                                     aTask->progress->notifyComplete(S_OK);
     416                                    aTask->pProgress->notifyComplete(S_OK);
    413417                            }
    414418                        }
     
    450454    try
    451455    {
    452         Guest *pGuest = aTask->pGuest;
    453         AssertPtr(pGuest);
     456        ComObjPtr<Guest> pGuest = aTask->pGuest;
    454457
    455458        /* Does our source file exist? */
     
    461464        {
    462465            if (!fFileExists)
    463                 rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     466                rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    464467                                                     Guest::tr("Source file \"%s\" does not exist, or is not a file"),
    465468                                                     aTask->strSource.c_str());
    466469        }
    467470        else
    468             rc = GuestTask::setProgressErrorInfo(rc, aTask->progress, pGuest);
     471            rc = GuestTask::setProgressErrorInfo(rc, aTask->pProgress, pGuest);
    469472
    470473        /* Query file size to make an estimate for our progress object. */
     
    476479                                       &lFileSize);
    477480            if (FAILED(rc))
    478                 rc = GuestTask::setProgressErrorInfo(rc, aTask->progress, pGuest);
     481                rc = GuestTask::setProgressErrorInfo(rc, aTask->pProgress, pGuest);
    479482
    480483            com::SafeArray<IN_BSTR> args;
     
    507510                }
    508511                else
    509                     rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     512                    rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    510513                                                         Guest::tr("Error preparing command line"));
    511514            }
     
    532535                                                   execProgress.asOutParam(), &uPID);
    533536                if (FAILED(rc))
    534                     rc = GuestTask::setProgressErrorInfo(rc, aTask->progress, pGuest);
     537                    rc = GuestTask::setProgressErrorInfo(rc, aTask->pProgress, pGuest);
    535538            }
    536539
     
    544547                                     RTFILE_O_WRITE | RTFILE_O_OPEN_CREATE | RTFILE_O_DENY_WRITE);
    545548                if (RT_FAILURE(vrc))
    546                     rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     549                    rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    547550                                                         Guest::tr("Unable to create/open destination file \"%s\", rc=%Rrc"),
    548551                                                         aTask->strDest.c_str(), vrc);
     
    565568                                if (RT_FAILURE(vrc))
    566569                                {
    567                                     rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     570                                    rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    568571                                                                         Guest::tr("Error writing to file \"%s\" (%u bytes left), rc=%Rrc"),
    569572                                                                         aTask->strSource.c_str(), cbToRead, vrc);
     
    575578                                cbTransfered += aOutputData.size();
    576579
    577                                 aTask->progress->SetCurrentOperationProgress(cbTransfered / (lFileSize / 100.0));
     580                                aTask->pProgress->SetCurrentOperationProgress(cbTransfered / (lFileSize / 100.0));
    578581                            }
    579582
     
    582585                        else
    583586                        {
    584                             rc = GuestTask::setProgressErrorInfo(rc, aTask->progress, pGuest);
     587                            rc = GuestTask::setProgressErrorInfo(rc, aTask->pProgress, pGuest);
    585588                            break;
    586589                        }
     
    597600                         * be (almost) sure that this file is not meant to be read by the specified user.
    598601                         */
    599                         rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     602                        rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    600603                                                             Guest::tr("Unexpected end of file \"%s\" (%u bytes total, %u bytes transferred)"),
    601604                                                             aTask->strSource.c_str(), lFileSize, cbTransfered);
     
    603606
    604607                    if (SUCCEEDED(rc))
    605                         aTask->progress->notifyComplete(S_OK);
     608                        aTask->pProgress->notifyComplete(S_OK);
    606609                }
    607610            }
     
    641644    try
    642645    {
    643         Guest *pGuest = aTask->pGuest;
    644         AssertPtr(pGuest);
    645 
    646         aTask->progress->SetCurrentOperationProgress(10);
     646        ComObjPtr<Guest> pGuest = aTask->pGuest;
     647
     648        aTask->pProgress->SetCurrentOperationProgress(10);
    647649
    648650        /*
     
    667669            }
    668670            else /* Everything else is not supported (yet). */
    669                 throw GuestTask::setProgressErrorInfo(VBOX_E_NOT_SUPPORTED, aTask->progress,
     671                throw GuestTask::setProgressErrorInfo(VBOX_E_NOT_SUPPORTED, aTask->pProgress,
    670672                                                      Guest::tr("Detected guest OS (%s) does not support automatic Guest Additions updating, please update manually"),
    671673                                                      osTypeIdUtf8.c_str());
    672674        }
    673675        else
    674             throw GuestTask::setProgressErrorInfo(VBOX_E_NOT_SUPPORTED, aTask->progress,
     676            throw GuestTask::setProgressErrorInfo(VBOX_E_NOT_SUPPORTED, aTask->pProgress,
    675677                                                  Guest::tr("Could not detected guest OS type/version, please update manually"));
    676678        Assert(!installerImage.isEmpty());
     
    683685        if (RT_FAILURE(vrc))
    684686        {
    685             rc = GuestTask::setProgressErrorInfo(VBOX_E_FILE_ERROR, aTask->progress,
     687            rc = GuestTask::setProgressErrorInfo(VBOX_E_FILE_ERROR, aTask->pProgress,
    686688                                                 Guest::tr("Invalid installation medium detected: \"%s\""),
    687689                                                 aTask->strSource.c_str());
     
    698700                vrc = RTFileSeek(iso.file, cbOffset, RTFILE_SEEK_BEGIN, NULL);
    699701                if (RT_FAILURE(vrc))
    700                     rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     702                    rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    701703                                                         Guest::tr("Could not seek to setup file on installation medium \"%s\" (%Rrc)"),
    702704                                                         aTask->strSource.c_str(), vrc);
     
    707709                {
    708710                    case VERR_FILE_NOT_FOUND:
    709                         rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     711                        rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    710712                                                             Guest::tr("Setup file was not found on installation medium \"%s\""),
    711713                                                             aTask->strSource.c_str());
     
    713715
    714716                    default:
    715                         rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     717                        rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    716718                                                             Guest::tr("An unknown error (%Rrc) occured while retrieving information of setup file on installation medium \"%s\""),
    717719                                                             vrc, aTask->strSource.c_str());
     
    726728            {
    727729                /* Okay, we're ready to start our copy routine on the guest! */
    728                 aTask->progress->SetCurrentOperationProgress(15);
     730                aTask->pProgress->SetCurrentOperationProgress(15);
    729731
    730732                /* Prepare command line args. */
     
    768770                            case VERR_NOT_FOUND:
    769771                                LogRel(("Guest Additions seem not to be installed yet\n"));
    770                                 rc = GuestTask::setProgressErrorInfo(VBOX_E_NOT_SUPPORTED, aTask->progress,
     772                                rc = GuestTask::setProgressErrorInfo(VBOX_E_NOT_SUPPORTED, aTask->pProgress,
    771773                                                                     Guest::tr("Guest Additions seem not to be installed or are not ready to update yet"));
    772774                                break;
     
    776778                            case VERR_INVALID_PARAMETER:
    777779                                LogRel(("Guest Additions are installed but don't supported automatic updating\n"));
    778                                 rc = GuestTask::setProgressErrorInfo(VBOX_E_NOT_SUPPORTED, aTask->progress,
     780                                rc = GuestTask::setProgressErrorInfo(VBOX_E_NOT_SUPPORTED, aTask->pProgress,
    779781                                                                     Guest::tr("Installed Guest Additions do not support automatic updating"));
    780782                                break;
     
    782784                            case VERR_TIMEOUT:
    783785                                LogRel(("Guest was unable to start copying the Guest Additions setup within time\n"));
    784                                 rc = GuestTask::setProgressErrorInfo(E_FAIL, aTask->progress,
     786                                rc = GuestTask::setProgressErrorInfo(E_FAIL, aTask->pProgress,
    785787                                                                     Guest::tr("Guest was unable to start copying the Guest Additions setup within time"));
    786788                                break;
    787789
    788790                            default:
    789                                 rc = GuestTask::setProgressErrorInfo(E_FAIL, aTask->progress,
     791                                rc = GuestTask::setProgressErrorInfo(E_FAIL, aTask->pProgress,
    790792                                                                     Guest::tr("Error copying Guest Additions setup file to guest path \"%s\" (%Rrc)"),
    791793                                                                     strInstallerPath.c_str(), vrc);
     
    798800                        LogRel(("Copying Guest Additions installer \"%s\" to \"%s\" on guest ...\n",
    799801                                installerImage.c_str(), strInstallerPath.c_str()));
    800                         aTask->progress->SetCurrentOperationProgress(20);
     802                        aTask->pProgress->SetCurrentOperationProgress(20);
    801803
    802804                        /* Wait for process to exit ... */
     
    825827                                        || (cbToRead - cbRead == 0)
    826828                                        /* ... or does the user want to cancel? */
    827                                         || (   SUCCEEDED(aTask->progress->COMGETTER(Canceled(&fCanceled)))
     829                                        || (   SUCCEEDED(aTask->pProgress->COMGETTER(Canceled(&fCanceled)))
    828830                                            && fCanceled)
    829831                                       )
     
    842844                                    if (FAILED(rc))
    843845                                    {
    844                                         rc = GuestTask::setProgressErrorInfo(rc, aTask->progress, pGuest);
     846                                        rc = GuestTask::setProgressErrorInfo(rc, aTask->pProgress, pGuest);
    845847                                        break;
    846848                                    }
     
    858860                                else if (RT_FAILURE(vrc))
    859861                                {
    860                                     rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     862                                    rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    861863                                                                         Guest::tr("Error while reading setup file \"%s\" (To read: %u, Size: %u) from installation medium (%Rrc)"),
    862864                                                                         installerImage.c_str(), cbToRead, cbLength, vrc);
     
    868870                                && fCanceled)
    869871                            {
    870                                 aTask->progress->Cancel();
     872                                aTask->pProgress->Cancel();
    871873                                break;
    872874                            }
     
    878880
    879881            if (   SUCCEEDED(rc)
    880                 && (   SUCCEEDED(aTask->progress->COMGETTER(Canceled(&fCanceled)))
     882                && (   SUCCEEDED(aTask->pProgress->COMGETTER(Canceled(&fCanceled)))
    881883                    && !fCanceled
    882884                   )
     
    888890                 */
    889891                LogRel(("Preparing to execute Guest Additions update ...\n"));
    890                 aTask->progress->SetCurrentOperationProgress(66);
     892                aTask->pProgress->SetCurrentOperationProgress(66);
    891893
    892894                /* Prepare command line args for installer. */
     
    931933                     * complete the progress object now so that the caller can do other work. */
    932934                    if (aTask->uFlags & AdditionsUpdateFlag_WaitForUpdateStartOnly)
    933                         aTask->progress->notifyComplete(S_OK);
     935                        aTask->pProgress->notifyComplete(S_OK);
    934936                    else
    935                         aTask->progress->SetCurrentOperationProgress(70);
     937                        aTask->pProgress->SetCurrentOperationProgress(70);
    936938
    937939                    /* Wait until the Guest Additions installer finishes ... */
     
    939941                           && !fCompleted)
    940942                    {
    941                         if (   SUCCEEDED(aTask->progress->COMGETTER(Canceled(&fCanceled)))
     943                        if (   SUCCEEDED(aTask->pProgress->COMGETTER(Canceled(&fCanceled)))
    942944                            && fCanceled)
    943945                        {
     
    964966                            {
    965967                                LogRel(("Guest Additions update successful!\n"));
    966                                 if (   SUCCEEDED(aTask->progress->COMGETTER(Completed(&fCompleted)))
     968                                if (   SUCCEEDED(aTask->pProgress->COMGETTER(Completed(&fCompleted)))
    967969                                    && !fCompleted)
    968                                     aTask->progress->notifyComplete(S_OK);
     970                                    aTask->pProgress->notifyComplete(S_OK);
    969971                            }
    970972                            else
     
    972974                                LogRel(("Guest Additions update failed (Exit code=%u, Status=%u, Flags=%u)\n",
    973975                                        uRetExitCode, retStatus, uRetFlags));
    974                                 rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     976                                rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    975977                                                                     Guest::tr("Guest Additions update failed with exit code=%u (status=%u, flags=%u)"),
    976978                                                                     uRetExitCode, retStatus, uRetFlags);
     
    981983                        {
    982984                            LogRel(("Guest Additions update was canceled\n"));
    983                             rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     985                            rc = GuestTask::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->pProgress,
    984986                                                                 Guest::tr("Guest Additions update was canceled by the guest with exit code=%u (status=%u, flags=%u)"),
    985987                                                                 uRetExitCode, retStatus, uRetFlags);
     
    991993                    }
    992994                    else
    993                         rc = GuestTask::setProgressErrorInfo(rc, aTask->progress, pGuest);
     995                        rc = GuestTask::setProgressErrorInfo(rc, aTask->pProgress, pGuest);
    994996                }
    995997                else
    996                     rc = GuestTask::setProgressErrorInfo(rc, aTask->progress, pGuest);
     998                    rc = GuestTask::setProgressErrorInfo(rc, aTask->pProgress, pGuest);
    997999            }
    9981000        }
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