VirtualBox

Changeset 34881 in vbox


Ignore:
Timestamp:
Dec 9, 2010 12:29:01 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
68694
Message:

Automatic Guest Additions update/Main: Pass error information to external progress object.

File:
1 edited

Legend:

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

    r34862 r34881  
    329329
    330330                            /* Resize buffer to reflect amount we just have read. */
    331                             aInputData.resize(cbRead);
     331                            if (cbRead > 0)
     332                                aInputData.resize(cbRead);
    332333
    333334                            ULONG uFlags = ProcessInputFlag_None;
     
    429430        }
    430431        else /* Everything else is not supported (yet). */
    431             throw setError(VBOX_E_NOT_SUPPORTED, tr("Guest OS not supported for automatic Guest Additions updating"));
     432            throw TaskGuest::setProgressErrorInfo(VBOX_E_NOT_SUPPORTED, aTask->progress,
     433                                                  Guest::tr("Detected guest OS (%s) does not support automatic Guest Additions updating, please update manually"),
     434                                                  osType.c_str());
    432435
    433436        /*
     
    460463        if (RT_FAILURE(vrc))
    461464        {
    462             rc = setError(VBOX_E_FILE_ERROR, tr("Invalid installation medium detected"));
     465            rc = TaskGuest::setProgressErrorInfo(VBOX_E_FILE_ERROR, aTask->progress,
     466                                                 Guest::tr("Invalid installation medium (%s) detected"),
     467                                                 aTask->strSource.c_str());
    463468        }
    464469        else
     
    472477            {
    473478                vrc = RTFileSeek(iso.file, cbOffset, RTFILE_SEEK_BEGIN, NULL);
     479                if (RT_FAILURE(vrc))
     480                    rc = TaskGuest::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     481                                                         Guest::tr("Could not seek to setup file on installation medium (%Rrc)"), vrc);
    474482            }
    475 
    476             /* Specify the ouput path on the guest side. */
    477             Utf8Str strInstallerPath = "%TEMP%\\VBoxWindowsAdditions.exe";
    478 
    479             if (RT_FAILURE(vrc))
     483            else
    480484            {
    481485                switch (vrc)
    482486                {
    483487                    case VERR_FILE_NOT_FOUND:
    484                         rc = setError(VBOX_E_IPRT_ERROR, tr("Setup file was not found on installation medium"));
     488                        rc = TaskGuest::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     489                                                             Guest::tr("Setup file was not found on installation medium"));
    485490                        break;
    486491
    487492                    default:
    488                         rc = setError(VBOX_E_IPRT_ERROR, tr("An unknown error occured (%Rrc)"), vrc);
     493                        rc = TaskGuest::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     494                                                             Guest::tr("An unknown error occured while retrieving information of setup file (%Rrc)"), vrc);
    489495                        break;
    490496                }
    491497            }
    492             else
     498
     499            /* Specify the ouput path on the guest side. */
     500            Utf8Str strInstallerPath = "%TEMP%\\VBoxWindowsAdditions.exe";
     501
     502            if (RT_SUCCESS(vrc))
    493503            {
    494504                /* Okay, we're ready to start our copy routine on the guest! */
     
    536546                             * support the guest execution feature in this version). */
    537547                            case VERR_NOT_FOUND:
    538                                 rc = setError(VBOX_E_NOT_SUPPORTED,
    539                                               tr("Guest Additions seem not to be installed or are not ready to update yet"));
     548                                rc = TaskGuest::setProgressErrorInfo(VBOX_E_NOT_SUPPORTED, aTask->progress,
     549                                                                     Guest::tr("Guest Additions seem not to be installed or are not ready to update yet"));
    540550                                break;
    541551
     
    543553                             * execution but not the built-in "vbox_cat" tool of VBoxService (< 4.0). */
    544554                            case VERR_INVALID_PARAMETER:
    545                                 rc = setError(VBOX_E_NOT_SUPPORTED,
    546                                               tr("Installed Guest Additions do not support automatic updating"));
     555                                rc = TaskGuest::setProgressErrorInfo(VBOX_E_NOT_SUPPORTED, aTask->progress,
     556                                                                     Guest::tr("Installed Guest Additions do not support automatic updating"));
    547557                                break;
    548558
    549559                            default:
    550                                 rc = setError(E_FAIL,
    551                                               tr("Error copying Guest Additions installer (%Rrc)"), vrc);
     560                                rc = TaskGuest::setProgressErrorInfo(E_FAIL, aTask->progress,
     561                                                                     Guest::tr("Error copying Guest Additions setup file to guest path \"%s\" (%Rrc)"),
     562                                                                     strInstallerPath.c_str(), vrc);
    552563                                break;
    553564                        }
     
    573584                                    && RT_SUCCESS(vrc))
    574585                                {
    575                                     /* Did we reach the end of the content
    576                                      * we want to transfer (last chunk)? */
     586                                    /* Resize buffer to reflect amount we just have read. */
     587                                    if (cbRead > 0)
     588                                        aInputData.resize(cbRead);
     589
     590                                    /* Did we reach the end of the content we want to transfer (last chunk)? */
    577591                                    ULONG uFlags = ProcessInputFlag_None;
    578                                     if (cbRead < _1M)
    579                                     {
    580                                         uFlags |= ProcessInputFlag_EndOfFile;
    581                                         if (cbRead > 0) /* Don't allow an empty array! */
    582                                             aInputData.resize(cbRead); /* Adjust array size (less than 64K read). */
    583                                     }
    584 
    585                                     /*
    586                                      * Task canceled by caller?
    587                                      * Then let the started process (cat) know by specifying end-of-file
    588                                      * for the netxt input event that hopefully leads to a graceful exit ...
    589                                      */
    590                                     if (   SUCCEEDED(aTask->progress->COMGETTER(Canceled(&fCanceled)))
    591                                         && fCanceled)
     592                                    if (   (cbRead < _1M)
     593                                        /* ... or does the user want to cancel? */
     594                                        || (   SUCCEEDED(aTask->progress->COMGETTER(Canceled(&fCanceled)))
     595                                            && fCanceled)
     596                                       )
    592597                                    {
    593598                                        uFlags |= ProcessInputFlag_EndOfFile;
     
    602607                                                                 ComSafeArrayAsInParam(aInputData), &uBytesWritten);
    603608                                    if (FAILED(rc))
     609                                    {
     610                                        rc = TaskGuest::setProgressErrorInfo(rc, aTask->progress, pGuest);
    604611                                        break;
     612                                    }
    605613
    606614                                    /* If task was canceled above also cancel the process execution. */
     
    714722                            else
    715723                            {
    716                                 rc = setError(VBOX_E_IPRT_ERROR,
    717                                               tr("Guest Additions update failed with exit code=%u (Status=%u, Flags=%u)"),
    718                                               uRetExitCode, uRetStatus, uRetFlags);
     724                                rc = TaskGuest::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     725                                                                     Guest::tr("Guest Additions update failed with exit code=%u (status=%u, flags=%u)"),
     726                                                                     uRetExitCode, uRetStatus, uRetFlags);
    719727                            }
    720728                        }
    721729                        else if (fCanceled)
    722730                        {
    723                             rc = setError(VBOX_E_IPRT_ERROR,
    724                                           tr("Guest Additions update was canceled with exit code=%u (Status=%u, Flags=%u)"),
    725                                           uRetExitCode, uRetStatus, uRetFlags);
     731                            rc = TaskGuest::setProgressErrorInfo(VBOX_E_IPRT_ERROR, aTask->progress,
     732                                                                 Guest::tr("Guest Additions update was canceled by the guest with exit code=%u (status=%u, flags=%u)"),
     733                                                                 uRetExitCode, uRetStatus, uRetFlags);
    726734                        }
    727735                        else
    728                             AssertMsgFailed(("Unknown Guest Additions update status!"));
     736                            AssertMsgFailed(("Unknown Guest Additions update status!\n"));
    729737                    }
    730738                }
     739                else
     740                    rc = TaskGuest::setProgressErrorInfo(rc, aTask->progress, pGuest);
    731741            }
    732742        }
     
    739749    /* Clean up */
    740750    aTask->rc = rc;
    741 
    742     if (   SUCCEEDED(aTask->progress->COMGETTER(Canceled(&fCanceled)))
    743         && !fCanceled
    744         && SUCCEEDED(aTask->progress->COMGETTER(Completed(&fCompleted)))
    745         && !fCompleted)
    746     {
    747         if (FAILED(rc))
    748         {
    749             aTask->progress->notifyComplete(rc,
    750                                             COM_IIDOF(IGuest),
    751                                             Guest::getStaticComponentName(),
    752                                             rc == VBOX_E_NOT_SUPPORTED
    753                                             ? Guest::tr("Automatic Guest Additions update not supported")
    754                                             : Guest::tr("Automatic Guest Additions update failed"));
    755         }
    756         else
    757             AssertMsgFailed(("Automatic Guest Additions update neither canceled nor completed and did *not* fail!? D'oh!\n"));
    758     }
    759751
    760752    LogFlowFunc(("rc=%Rhrc\n", rc));
     
    13601352
    13611353        default:
    1362             AssertMsgFailed(("Unknown guest control notification received, u32Function=%u", u32Function));
     1354            AssertMsgFailed(("Unknown guest control notification received, u32Function=%u\n", u32Function));
    13631355            rc = VERR_INVALID_PARAMETER;
    13641356            break;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette