VirtualBox

Changeset 56215 in vbox


Ignore:
Timestamp:
Jun 3, 2015 11:02:03 AM (9 years ago)
Author:
vboxsync
Message:

DnD: GuestDnDSourceImpl: Simpler guest->host accounting; some logging adjustments.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestDnDSourceImpl.h

    r55963 r56215  
    9393    int i_receiveRawData(PRECVDATACTX pCtx, RTMSINTERVAL msTimeout);
    9494    int i_receiveURIData(PRECVDATACTX pCtx, RTMSINTERVAL msTimeout);
    95     int i_updateProcess(PRECVDATACTX pCtx, uint32_t cbDataAdd);
     95    int i_updateProcess(PRECVDATACTX pCtx, uint64_t cbDataAdd);
    9696
    9797protected:
  • trunk/src/VBox/Main/src-client/GuestDnDSourceImpl.cpp

    r55965 r56215  
    526526                    if (RT_SUCCESS(rc))
    527527                    {
     528                        /* Reset processed bytes. */
    528529                        pCtx->mData.cbProcessed = 0;
    529530
     
    534535                        pCtx->mData.cbToProcess = cbTotalSize;
    535536
    536                         LogFlowFunc(("URI data => cbToProcess=%RU64\n", pCtx->mData.cbToProcess));
     537                        /* Update our process with the data we already received.
     538                         * Note: The total size will consist of the meta data (in vecData) and
     539                         *       the actual accumulated file/directory data from the guest. */
     540                        rc = i_updateProcess(pCtx, (uint64_t)pCtx->mData.vecData.size());
     541
     542                        LogFlowFunc(("URI data => cbProcessed=%RU64, cbToProcess=%RU64, rc=%Rrc\n",
     543                                     pCtx->mData.cbProcessed, pCtx->mData.cbToProcess, rc));
    537544                    }
    538545                }
     
    563570        rc = RTDirCreateFullPath(pszDir, fMode);
    564571        if (RT_FAILURE(rc))
    565             LogRel2(("DnD: Error creating guest directory \"%s\" on the host, rc=%Rrc\n", pszDir, rc));
     572            LogRel2(("DnD: Error creating guest directory '%s' on the host, rc=%Rrc\n", pszDir, rc));
    566573
    567574        RTStrFree(pszDir);
     
    569576    else
    570577         rc = VERR_NO_MEMORY;
    571 
    572     if (RT_SUCCESS(rc))
    573     {
    574         if (mDataBase.mProtocolVersion <= 2)
    575         {
    576             /*
    577              * Protocols v1/v2 do *not* send root element names (files/directories)
    578              * in URI format. The initial GUEST_DND_GH_SND_DATA message(s) however
    579              * did take those element names into account, but *with* URI decoration
    580              * when it comes to communicating the total bytes being sent.
    581              *
    582              * So translate the path into a valid URI path and add the resulting
    583              * length (+ "\r\n" and termination) to the total bytes received
    584              * to keep the accounting right.
    585              */
    586             char *pszPathURI = RTUriCreate("file" /* pszScheme */, "/" /* pszAuthority */,
    587                                            pszPath /* pszPath */,
    588                                            NULL /* pszQuery */, NULL /* pszFragment */);
    589             if (pszPathURI)
    590             {
    591                 bool fHasPath = RTPathHasPath(pszPath); /* Use original data received. */
    592                 if (!fHasPath) /* Root path? */
    593                 {
    594                     cbPath  = strlen(pszPathURI);
    595                     cbPath += 3;                  /* Include "\r" + "\n" + termination -- see above. */
    596 
    597                     rc = i_updateProcess(pCtx, cbPath);
    598                 }
    599 
    600                 LogFlowFunc(("URI pszPathURI=%s, fHasPath=%RTbool, cbPath=%RU32\n", pszPathURI, fHasPath, cbPath));
    601                 RTStrFree(pszPathURI);
    602             }
    603             else
    604                 rc = VERR_NO_MEMORY;
    605         }
    606     }
    607578
    608579    LogFlowFuncLeaveRC(rc);
     
    625596    do
    626597    {
    627         if (!pCtx->mURI.objURI.IsComplete())
    628         {
    629             LogFlowFunc(("Warning: Object \"%s\" not complete yet\n", pCtx->mURI.objURI.GetDestPath().c_str()));
     598        if (    pCtx->mURI.objURI.IsOpen()
     599            && !pCtx->mURI.objURI.IsComplete())
     600        {
     601            LogFlowFunc(("Warning: Object '%s' not complete yet\n", pCtx->mURI.objURI.GetDestPath().c_str()));
    630602            rc = VERR_INVALID_PARAMETER;
    631603            break;
     
    634606        if (pCtx->mURI.objURI.IsOpen()) /* File already opened? */
    635607        {
    636             LogFlowFunc(("Warning: Current opened object is \"%s\"\n", pCtx->mURI.objURI.GetDestPath().c_str()));
     608            LogFlowFunc(("Warning: Current opened object is '%s'\n", pCtx->mURI.objURI.GetDestPath().c_str()));
    637609            rc = VERR_WRONG_ORDER;
    638610            break;
     
    682654        }
    683655
    684         if (mDataBase.mProtocolVersion <= 2)
    685         {
    686             /*
    687              * Protocols v1/v2 do *not* send root element names (files/directories)
    688              * in URI format. The initial GUEST_DND_GH_SND_DATA message(s) however
    689              * did take those element names into account, but *with* URI decoration
    690              * when it comes to communicating the total bytes being sent.
    691              *
    692              * So translate the path into a valid URI path and add the resulting
    693              * length (+ "\r\n" and termination) to the total bytes received
    694              * to keep the accounting right.
    695              */
    696             char *pszPathURI = RTUriCreate("file" /* pszScheme */, "/" /* pszAuthority */,
    697                                            pszPath /* pszPath */,
    698                                            NULL /* pszQuery */, NULL /* pszFragment */);
    699             if (pszPathURI)
    700             {
    701                 bool fHasPath = RTPathHasPath(pszPath); /* Use original data received. */
    702                 if (!fHasPath) /* Root path? */
    703                 {
    704                     cbPath  = strlen(pszPathURI);
    705                     cbPath += 3;                  /* Include "\r" + "\n" + termination -- see above. */
    706 
    707                     rc = i_updateProcess(pCtx, cbPath);
    708                 }
    709 
    710                 LogFlowFunc(("URI pszPathURI=%s, fHasPath=%RTbool, cbPath=%RU32\n", pszPathURI, fHasPath, cbPath));
    711                 RTStrFree(pszPathURI);
    712             }
    713             else
    714             {
    715                 rc = VERR_NO_MEMORY;
    716                 break;
    717             }
    718         }
    719 
    720656    } while (0);
    721657
     
    736672        if (pCtx->mURI.objURI.IsComplete())
    737673        {
    738             LogFlowFunc(("Warning: Object \"%s\" already completed\n", pCtx->mURI.objURI.GetDestPath().c_str()));
     674            LogFlowFunc(("Warning: Object '%s' already completed\n", pCtx->mURI.objURI.GetDestPath().c_str()));
    739675            rc = VERR_WRONG_ORDER;
    740676            break;
     
    743679        if (!pCtx->mURI.objURI.IsOpen()) /* File opened on host? */
    744680        {
    745             LogFlowFunc(("Warning: Object \"%s\" not opened\n", pCtx->mURI.objURI.GetDestPath().c_str()));
     681            LogFlowFunc(("Warning: Object '%s' not opened\n", pCtx->mURI.objURI.GetDestPath().c_str()));
    746682            rc = VERR_WRONG_ORDER;
    747683            break;
     
    776712        }
    777713        else
    778             LogRel(("DnD: Error writing guest file to host to \"%s\": %Rrc\n", pCtx->mURI.objURI.GetDestPath().c_str(), rc));
     714        {
     715            /** @todo What to do when the host's disk is full? */
     716            LogRel(("DnD: Error writing guest file to host to '%s': %Rrc\n", pCtx->mURI.objURI.GetDestPath().c_str(), rc));
     717        }
    779718
    780719    } while (0);
     
    12611200}
    12621201
    1263 int GuestDnDSource::i_updateProcess(PRECVDATACTX pCtx, uint32_t cbDataAdd)
     1202int GuestDnDSource::i_updateProcess(PRECVDATACTX pCtx, uint64_t cbDataAdd)
    12641203{
    12651204    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     1205
     1206    LogFlowFunc(("cbProcessed=%RU64 (+ %RU64 = %RU64), cbToProcess=%RU64\n",
     1207                 pCtx->mData.cbProcessed, cbDataAdd, pCtx->mData.cbProcessed + cbDataAdd, pCtx->mData.cbToProcess));
    12661208
    12671209    pCtx->mData.cbProcessed += cbDataAdd;
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