VirtualBox

Ignore:
Timestamp:
Dec 8, 2010 1:37:55 PM (14 years ago)
Author:
vboxsync
Message:

GuestControl/Copy: Use a thread (guest task) for displaying real progress and fixes for proper cancellation. Raised send buffers to _1M.

File:
1 edited

Legend:

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

    r34769 r34831  
    201201static int ctrlPrintProgressError(ComPtr<IProgress> progress)
    202202{
    203     com::ProgressErrorInfo ErrInfo(progress);
    204     return ctrlPrintError(ErrInfo);
     203    int rc;
     204    BOOL fCanceled;
     205    if (   SUCCEEDED(progress->COMGETTER(Canceled(&fCanceled)))
     206        && fCanceled)
     207    {
     208        rc = VERR_CANCELLED;
     209    }
     210    else
     211    {
     212        com::ProgressErrorInfo ErrInfo(progress);
     213        rc = ctrlPrintError(ErrInfo);
     214    }
     215    return rc;
    205216}
    206217
     
    954965 * @return  IPRT status code.
    955966 * @param   pGuest          IGuest interface pointer.
     967 * @param   fVerbose        Verbose flag.
    956968 * @param   pszSource       Source path of existing host file to copy.
    957969 * @param   pszDest         Destination path on guest to copy the file to.
     
    960972 * @param   uFlags          Copy flags.
    961973 */
    962 static int ctrlCopyFileToGuest(IGuest *pGuest, const char *pszSource, const char *pszDest,
     974static int ctrlCopyFileToGuest(IGuest *pGuest, bool fVerbose, const char *pszSource, const char *pszDest,
    963975                               const char *pszUserName, const char *pszPassword,
    964976                               uint32_t uFlags)
     
    978990    else
    979991    {
    980         /* Setup signal handling if cancelable. */
    981         ASSERT(progress);
    982         bool fCanceledAlready = false;
    983         BOOL fCancelable = FALSE;
    984         HRESULT hrc = progress->COMGETTER(Cancelable)(&fCancelable);
    985         if (fCancelable)
    986             ctrlSignalHandlerInstall();
    987 
    988         /* Wait for process to exit ... */
    989         BOOL fCompleted = FALSE;
    990         BOOL fCanceled = FALSE;
    991         while (   SUCCEEDED(progress->COMGETTER(Completed(&fCompleted)))
    992                && !fCompleted)
    993         {
    994             /* Process async cancelation */
    995             if (g_fGuestCtrlCanceled && !fCanceledAlready)
    996             {
    997                 hrc = progress->Cancel();
    998                 if (SUCCEEDED(hrc))
    999                     fCanceledAlready = TRUE;
    1000                 else
    1001                     g_fGuestCtrlCanceled = false;
    1002             }
    1003 
    1004             /* Progress canceled by Main API? */
    1005             if (   SUCCEEDED(progress->COMGETTER(Canceled(&fCanceled)))
    1006                 && fCanceled)
    1007             {
    1008                 break;
    1009             }
    1010         }
    1011 
    1012         /* Undo signal handling. */
    1013         if (fCancelable)
    1014             ctrlSignalHandlerUninstall();
    1015 
    1016         if (fCanceled)
    1017         {
    1018             /* Nothing to do here right now. */
    1019         }
    1020         else if (   fCompleted
    1021                  && SUCCEEDED(rc))
    1022         {
    1023             LONG iRc;
    1024             CHECK_ERROR_RET(progress, COMGETTER(ResultCode)(&iRc), rc);
    1025             if (FAILED(iRc))
    1026                 vrc = ctrlPrintProgressError(progress);
    1027         }
     992        rc = showProgress(progress);
     993        if (FAILED(rc))
     994            vrc = ctrlPrintProgressError(progress);
    1028995    }
    1029996    return vrc;
     
    12081175                        /* Finally copy the desired file (if no dry run selected). */
    12091176                        if (!fDryRun)
    1210                             vrc = ctrlCopyFileToGuest(guest, pNode->pszSourcePath, pNode->pszDestPath,
     1177                            vrc = ctrlCopyFileToGuest(guest, fVerbose, pNode->pszSourcePath, pNode->pszDestPath,
    12111178                                                      Utf8UserName.c_str(), Utf8Password.c_str(), uFlags);
    12121179                    }
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