Changeset 50561 in vbox for trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp
- Timestamp:
- Feb 24, 2014 9:07:22 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp
r50508 r50561 278 278 279 279 /* Allocate temp buffer. */ 280 uint32_t cbTmpData = _ 1M * 10; /** @todo r=andy 10MB, uh, really?? */280 uint32_t cbTmpData = _64K; /** @todo Make this configurable? */ 281 281 void *pvTmpData = RTMemAlloc(cbTmpData); 282 282 if (!pvTmpData) … … 311 311 RTCList<RTCString> guestDirList; 312 312 RTCList<RTCString> guestFileList; 313 char pszPathName[RTPATH_MAX]; 314 uint32_t cbPathname = 0; 313 314 char szPathName[RTPATH_MAX]; 315 uint32_t cbPathName = 0; 316 315 317 bool fLoop = RT_SUCCESS(rc); /* No error occurred yet? */ 316 318 while (fLoop) … … 327 329 uint32_t fMode = 0; 328 330 rc = vbglR3DnDHGProcessSendDirMessage(uClientId, 329 pszPathName,330 sizeof( pszPathName),331 &cbPath name,331 szPathName, 332 sizeof(szPathName), 333 &cbPathName, 332 334 &fMode); 335 #ifdef DEBUG_andy 336 LogFlowFunc(("HOST_DND_HG_SND_DIR pszPathName=%s, cbPathName=%RU32, fMode=0x%x, rc=%Rrc\n", 337 szPathName, cbPathName, fMode, rc)); 338 #endif 333 339 if (RT_SUCCESS(rc)) 334 rc = DnDPathSanitize( pszPathName, sizeof(pszPathName));340 rc = DnDPathSanitize(szPathName, sizeof(szPathName)); 335 341 if (RT_SUCCESS(rc)) 336 342 { 337 char *pszNewDir = RTPathJoinA(pszDropDir, pszPathName);343 char *pszNewDir = RTPathJoinA(pszDropDir, szPathName); 338 344 if (pszNewDir) 339 345 { … … 354 360 uint32_t fMode = 0; 355 361 rc = vbglR3DnDHGProcessSendFileMessage(uClientId, 356 pszPathName,357 sizeof( pszPathName),358 &cbPath name,362 szPathName, 363 sizeof(szPathName), 364 &cbPathName, 359 365 pvTmpData, 360 366 cbTmpData, 361 367 &cbDataRecv, 362 368 &fMode); 369 #ifdef DEBUG_andy 370 LogFlowFunc(("HOST_DND_HG_SND_FILE pszPathName=%s, cbPathName=%RU32, pvData=0x%p, cbDataRecv=%RU32, fMode=0x%x, rc=%Rrc\n", 371 szPathName, cbPathName, pvTmpData, cbDataRecv, fMode, rc)); 372 #endif 363 373 if (RT_SUCCESS(rc)) 364 rc = DnDPathSanitize( pszPathName, sizeof(pszPathName));374 rc = DnDPathSanitize(szPathName, sizeof(szPathName)); 365 375 if (RT_SUCCESS(rc)) 366 376 { 367 char *psz NewFile = RTPathJoinA(pszDropDir, pszPathName);368 if (psz NewFile)377 char *pszPathAbs = RTPathJoinA(pszDropDir, szPathName); 378 if (pszPathAbs) 369 379 { 370 380 RTFILE hFile; … … 372 382 * create all sorts of funny races because we don't know if the guest has 373 383 * modified the file in between the file data send calls. */ 374 rc = RTFileOpen(&hFile, psz NewFile,384 rc = RTFileOpen(&hFile, pszPathAbs, 375 385 RTFILE_O_WRITE | RTFILE_O_APPEND | RTFILE_O_DENY_ALL | RTFILE_O_OPEN_CREATE); 376 386 if (RT_SUCCESS(rc)) … … 386 396 rc = RTFileSetMode(hFile, (fMode & RTFS_UNIX_MASK) | RTFS_UNIX_IRUSR | RTFS_UNIX_IWUSR); 387 397 } 398 388 399 RTFileClose(hFile); 389 if (!guestFileList.contains(pszNewFile)) 390 guestFileList.append(pszNewFile); 400 401 if (!guestFileList.contains(pszPathAbs)) 402 guestFileList.append(pszPathAbs); 391 403 } 392 393 RTStrFree(pszNewFile); 404 #ifdef DEBUG 405 else 406 LogFlowFunc(("Opening file failed with rc=%Rrc\n", rc)); 407 #endif 408 RTStrFree(pszPathAbs); 394 409 } 395 410 else … … 416 431 break; 417 432 } 433 434 if (RT_FAILURE(rc)) 435 break; 436 418 437 } /* while */ 419 438 … … 430 449 RTDirRemove(guestDirList.at(i).c_str()); 431 450 RTDirRemove(pszDropDir); 451 452 LogFlowFunc(("Failed with rc=%Rrc\n", rc)); 432 453 } 433 454 … … 473 494 rc = Msg.uScreenId.GetUInt32(puScreenId); AssertRC(rc); 474 495 rc = Msg.cFormat.GetUInt32(pcbFormatRecv); AssertRC(rc); 475 rc = Msg.cbData.GetUInt32(pcbDataTotal); 496 rc = Msg.cbData.GetUInt32(pcbDataTotal); AssertRC(rc); 476 497 477 498 AssertReturn(cbFormat >= *pcbFormatRecv, VERR_TOO_MUCH_DATA); … … 789 810 break; 790 811 } 812 case DragAndDropSvc::HOST_DND_HG_SND_MORE_DATA: 813 case DragAndDropSvc::HOST_DND_HG_SND_DIR: 814 case DragAndDropSvc::HOST_DND_HG_SND_FILE: 815 { 816 pEvent->uType = uMsg; 817 818 /* All messages in this case are handled internally 819 * by vbglR3DnDHGProcessSendDataMessage() and must 820 * be specified by a preceding HOST_DND_HG_SND_DATA call. */ 821 rc = VERR_WRONG_ORDER; 822 break; 823 } 791 824 case DragAndDropSvc::HOST_DND_HG_EVT_CANCEL: 792 825 { … … 1107 1140 rc = vbglR3DnDGHSendDataInternal(u32ClientId, pvData, cbData, 1108 1141 0 /* cbAdditionalData */); 1109 1110 return rc; 1111 } 1112 1113 VBGLR3DECL(int) VbglR3DnDGHErrorEvent(uint32_t u32ClientId, int rcOp) 1142 if (RT_FAILURE(rc)) 1143 { 1144 int rc2 = VbglR3DnDGHSendError(u32ClientId, rc); 1145 if (RT_SUCCESS(rc2)) 1146 rc2 = rc; 1147 } 1148 1149 return rc; 1150 } 1151 1152 VBGLR3DECL(int) VbglR3DnDGHSendError(uint32_t u32ClientId, int rcErr) 1114 1153 { 1115 1154 DragAndDropSvc::VBOXDNDGHEVTERRORMSG Msg; … … 1120 1159 Msg.hdr.cParms = 1; 1121 1160 1122 Msg.uRC.SetUInt32(rcOp); 1123 1124 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 1125 if (RT_SUCCESS(rc)) 1126 rc = Msg.hdr.result; 1127 1128 return rc; 1129 } 1130 1161 Msg.uRC.SetUInt32((uint32_t)rcErr); /* uint32_t vs. int. */ 1162 1163 int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 1164 if (RT_SUCCESS(rc)) 1165 rc = Msg.hdr.result; 1166 1167 LogFlowFunc(("Sending error %Rrc returned with rc=%Rrc\n", rcErr, rc)); 1168 return rc; 1169 } 1170
Note:
See TracChangeset
for help on using the changeset viewer.