VirtualBox

Changeset 84998 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jun 29, 2020 4:34:22 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
138893
Message:

DnD: Greatly simplified usage / API of the DnDURIObject class.

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

Legend:

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

    r82968 r84998  
    780780                && !pObj->IsComplete())
    781781            {
    782                 AssertMsgFailed(("Object '%s' not complete yet\n", pObj->GetDestPathAbs().c_str()));
     782                AssertMsgFailed(("Object '%s' not complete yet\n", pObj->GetPath().c_str()));
    783783                rc = VERR_WRONG_ORDER;
    784784                break;
     
    787787            if (pObj->IsOpen()) /* File already opened? */
    788788            {
    789                 AssertMsgFailed(("Current opened object is '%s', close this first\n", pObj->GetDestPathAbs().c_str()));
     789                AssertMsgFailed(("Current opened object is '%s', close this first\n", pObj->GetPath().c_str()));
    790790                rc = VERR_WRONG_ORDER;
    791791                break;
     
    825825            LogRel2(("DnD: Absolute file path for guest file on the host is now '%s'\n", pszPathAbs));
    826826
    827             /** @todo Add sparse file support based on fFlags? (Use Open(..., fFlags | SPARSE). */
    828             rc = pObj->OpenEx(pszPathAbs, DnDURIObject::View_Target,
    829                               RTFILE_O_CREATE_REPLACE | RTFILE_O_WRITE | RTFILE_O_DENY_WRITE,
    830                               (fMode & RTFS_UNIX_MASK) | RTFS_UNIX_IRUSR | RTFS_UNIX_IWUSR);
     827            rc = pObj->Init(DnDURIObject::Type_File, pszPathAbs);
    831828            if (RT_SUCCESS(rc))
    832829            {
    833                 /* Add for having a proper rollback. */
    834                 int rc2 = pCtx->mURI.getDroppedFiles().AddFile(pszPathAbs);
    835                 AssertRC(rc2);
     830                /** @todo Add sparse file support based on fFlags? (Use Open(..., fFlags | SPARSE). */
     831                rc = pObj->Open(RTFILE_O_CREATE_REPLACE | RTFILE_O_WRITE | RTFILE_O_DENY_WRITE,
     832                                (fMode & RTFS_UNIX_MASK) | RTFS_UNIX_IRUSR | RTFS_UNIX_IWUSR);
     833                if (RT_SUCCESS(rc))
     834                {
     835                    /* Add for having a proper rollback. */
     836                    int rc2 = pCtx->mURI.getDroppedFiles().AddFile(pszPathAbs);
     837                    AssertRC(rc2);
     838                }
    836839            }
    837             else
     840
     841            if (RT_FAILURE(rc))
    838842                LogRel(("DnD: Error opening/creating guest file '%s' on host, rc=%Rrc\n", pszPathAbs, rc));
    839843        }
     
    847851            /** @todo Unescape path before printing. */
    848852            LogRel2(("DnD: Transferring guest file '%s' to host (%RU64 bytes, mode 0x%x)\n",
    849                      pObj->GetDestPathAbs().c_str(), pObj->GetSize(), pObj->GetMode()));
     853                     pObj->GetPath().c_str(), pObj->GetSize(), pObj->GetMode()));
    850854
    851855            /** @todo Set progress object title to current file being transferred? */
     
    853857            if (pObj->IsComplete()) /* 0-byte file? We're done already. */
    854858            {
    855                 /** @todo Sanitize path. */
    856                 LogRel2(("DnD: Transferring guest file '%s' (0 bytes) to host complete\n", pObj->GetDestPathAbs().c_str()));
     859                LogRel2(("DnD: Transferring guest file '%s' (0 bytes) to host complete\n", pObj->GetPath().c_str()));
    857860
    858861                pCtx->mURI.processObject(*pObj);
     
    902905        if (pObj->IsComplete())
    903906        {
    904             LogFlowFunc(("Warning: Object '%s' already completed\n", pObj->GetDestPathAbs().c_str()));
     907            LogFlowFunc(("Warning: Object '%s' already completed\n", pObj->GetPath().c_str()));
    905908            rc = VERR_WRONG_ORDER;
    906909            break;
     
    909912        if (!pObj->IsOpen()) /* File opened on host? */
    910913        {
    911             LogFlowFunc(("Warning: Object '%s' not opened\n", pObj->GetDestPathAbs().c_str()));
     914            LogFlowFunc(("Warning: Object '%s' not opened\n", pObj->GetPath().c_str()));
    912915            rc = VERR_WRONG_ORDER;
    913916            break;
     
    921924            if (cbWritten < cbData)
    922925            {
    923                 /** @todo What to do when the host's disk is full? */
    924                 rc = VERR_DISK_FULL;
     926                LogRel(("DnD: Only written %RU32 of %RU32 bytes of guest file '%s' -- disk full?\n",
     927                        cbWritten, cbData, pObj->GetPath().c_str()));
     928                rc = VERR_IO_GEN_FAILURE; /** @todo Find a better rc. */
    925929            }
    926930
     
    929933        }
    930934        else
    931             LogRel(("DnD: Error writing guest file data for '%s', rc=%Rrc\n", pObj->GetDestPathAbs().c_str(), rc));
     935            LogRel(("DnD: Error writing guest file data for '%s', rc=%Rrc\n", pObj->GetPath().c_str(), rc));
    932936
    933937        if (RT_SUCCESS(rc))
     
    936940            {
    937941                /** @todo Sanitize path. */
    938                 LogRel2(("DnD: Transferring guest file '%s' to host complete\n", pObj->GetDestPathAbs().c_str()));
     942                LogRel2(("DnD: Transferring guest file '%s' to host complete\n", pObj->GetPath().c_str()));
    939943                pCtx->mURI.processObject(*pObj);
    940944                objCtx.reset();
  • trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp

    r82968 r84998  
    882882    AssertPtr(pObj);
    883883
    884     RTCString strPath = pObj->GetDestPathAbs();
     884    RTCString strPath = pObj->GetPath();
    885885    if (strPath.isEmpty())
    886886        return VERR_INVALID_PARAMETER;
     
    909909    AssertPtr(pObj);
    910910
    911     RTCString strPathSrc = pObj->GetSourcePathAbs();
     911    RTCString strPathSrc = pObj->GetPath();
    912912    if (strPathSrc.isEmpty())
    913913        return VERR_INVALID_PARAMETER;
     
    922922    {
    923923        LogRel2(("DnD: Opening host file '%s' for transferring to guest\n", strPathSrc.c_str()));
    924         rc = pObj->OpenEx(strPathSrc, DnDURIObject::View_Source,
    925                           RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
     924        rc = pObj->Init(DnDURIObject::Type_File, strPathSrc);
     925        if (RT_SUCCESS(rc))
     926            rc = pObj->Open(RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
     927
    926928        if (RT_FAILURE(rc))
    927929            LogRel(("DnD: Opening host file '%s' failed, rc=%Rrc\n", strPathSrc.c_str(), rc));
     
    943945                pMsg->setType(HOST_DND_HG_SND_FILE_HDR);
    944946                pMsg->setNextUInt32(0); /** @todo ContextID not used yet. */
    945                 pMsg->setNextString(pObj->GetDestPathAbs().c_str());                  /* pvName */
    946                 pMsg->setNextUInt32((uint32_t)(pObj->GetDestPathAbs().length() + 1)); /* cbName */
    947                 pMsg->setNextUInt32(0);                                            /* uFlags */
    948                 pMsg->setNextUInt32(pObj->GetMode());                              /* fMode */
    949                 pMsg->setNextUInt64(pObj->GetSize());                              /* uSize */
     947                pMsg->setNextString(pObj->GetPath().c_str());                  /* pvName */
     948                pMsg->setNextUInt32((uint32_t)(pObj->GetPath().length() + 1)); /* cbName */
     949                pMsg->setNextUInt32(0);                                        /* uFlags */
     950                pMsg->setNextUInt32(pObj->GetMode());                          /* fMode */
     951                pMsg->setNextUInt64(pObj->GetSize());                          /* uSize */
    950952
    951953                LogFlowFunc(("Sending file header ...\n"));
    952                 LogRel2(("DnD: Transferring host file to guest: %s (%RU64 bytes, mode 0x%x)\n",
    953                          strPathSrc.c_str(), pObj->GetSize(), pObj->GetMode()));
     954                LogRel2(("DnD: Transferring host file '%s' to guest (%RU64 bytes, mode 0x%x)\n",
     955                         pObj->GetPath().c_str(), pObj->GetSize(), pObj->GetMode()));
    954956
    955957                /** @todo Set progress object title to current file being transferred? */
     
    10071009    if (mDataBase.m_uProtocolVersion <= 1)
    10081010    {
    1009         pMsg->setNextString(pObj->GetDestPathAbs().c_str());                  /* pvName */
    1010         pMsg->setNextUInt32((uint32_t)(pObj->GetDestPathAbs().length() + 1)); /* cbName */
     1011        pMsg->setNextString(pObj->GetPath().c_str());                  /* pvName */
     1012        pMsg->setNextUInt32((uint32_t)(pObj->GetPath().length() + 1)); /* cbName */
    10111013    }
    10121014    else if (mDataBase.m_uProtocolVersion >= 2)
     
    10441046        if (pObj->IsComplete()) /* Done reading? */
    10451047        {
    1046             LogRel2(("DnD: Transferring file '%s' to guest complete\n", pObj->GetSourcePathAbs().c_str()));
    1047             LogFlowFunc(("File '%s' complete\n", pObj->GetSourcePathAbs().c_str()));
     1048            LogRel2(("DnD: Transferring file '%s' to guest complete\n", pObj->GetPath().c_str()));
     1049            LogFlowFunc(("File '%s' complete\n", pObj->GetPath().c_str()));
    10481050
    10491051            /* DnDURIObject::Read() returns VINF_EOF when finished reading the entire fire,
     
    10541056
    10551057    if (RT_FAILURE(rc))
    1056         LogRel(("DnD: Reading from host file '%s' failed, rc=%Rrc\n", pObj->GetSourcePathAbs().c_str(), rc));
     1058        LogRel(("DnD: Reading from host file '%s' failed, rc=%Rrc\n", pObj->GetPath().c_str(), rc));
    10571059
    10581060    LogFlowFuncLeaveRC(rc);
     
    14491451    AssertPtr(pCurObj);
    14501452
    1451     DnDURIObject::Type enmType = pCurObj->GetType();
     1453    const DnDURIObject::Type enmType = pCurObj->GetType();
     1454
    14521455    LogRel3(("DnD: Processing: srcPath=%s, dstPath=%s, enmType=%RU32, cbSize=%RU32\n",
    1453              pCurObj->GetSourcePathAbs().c_str(), pCurObj->GetDestPathAbs().c_str(),
     1456             pCurObj->GetPath().c_str(), pCurObj->GetPath().c_str(),
    14541457             enmType, pCurObj->GetSize()));
    14551458
     
    14651468    {
    14661469        AssertMsgFailed(("enmType=%RU32 is not supported for srcPath=%s, dstPath=%s\n",
    1467                          enmType, pCurObj->GetSourcePathAbs().c_str(), pCurObj->GetDestPathAbs().c_str()));
     1470                         enmType, pCurObj->GetPath().c_str(), pCurObj->GetPath().c_str()));
    14681471        rc = VERR_NOT_SUPPORTED;
    14691472    }
     
    14781481    if (fRemove)
    14791482    {
    1480         LogFlowFunc(("Removing \"%s\" from list, rc=%Rrc\n", pCurObj->GetSourcePathAbs().c_str(), rc));
     1483        LogFlowFunc(("Removing \"%s\" from list, rc=%Rrc\n", pCurObj->GetPath().c_str(), rc));
    14811484        pCtx->mURI.removeObjCurrent();
    14821485    }
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