Changeset 80444 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Aug 27, 2019 5:47:44 PM (5 years ago)
- Location:
- trunk/src/VBox/Additions/common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibClipboard.cpp
r80374 r80444 54 54 55 55 /** 56 * Connects to the Shared Clipboard service .56 * Connects to the Shared Clipboard service, legacy version, do not use anymore. 57 57 * 58 58 * @returns VBox status code … … 82 82 if (RT_SUCCESS(rc)) 83 83 { 84 pCtx->uProtocol = 0; /** @todo Makke this dynamic. */ 85 pCtx->cbChunkSize = _64K; /** @todo Makke this dynamic. */ 84 VBoxClipboardConnect Msg; 85 RT_ZERO(Msg); 86 87 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, 88 VBOX_SHARED_CLIPBOARD_GUEST_FN_CONNECT, VBOX_SHARED_CLIPBOARD_CPARMS_CONNECT); 89 90 VbglHGCMParmUInt32Set(&Msg.uProtocolVer, 0); 91 VbglHGCMParmUInt32Set(&Msg.uProtocolFlags, 0); 92 VbglHGCMParmUInt32Set(&Msg.cbChunkSize, 0); 93 VbglHGCMParmUInt32Set(&Msg.enmCompression, 0); 94 VbglHGCMParmUInt32Set(&Msg.enmChecksumType, 0); 95 96 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 97 if (RT_SUCCESS(rc)) 98 { 99 rc = VbglHGCMParmUInt32Get(&Msg.uProtocolVer, &pCtx->uProtocolVer); 100 if (RT_SUCCESS(rc)) 101 rc = VbglHGCMParmUInt32Get(&Msg.uProtocolFlags, &pCtx->uProtocolFlags); 102 if (RT_SUCCESS(rc)) 103 rc = VbglHGCMParmUInt32Get(&Msg.cbChunkSize, &pCtx->cbChunkSize); 104 105 /** @todo Add / handle checksum + compression type. */ 106 } 107 else 108 { 109 /* If the above call fails, make sure to use some sane defaults for 110 * the old (legacy) protocol. */ 111 pCtx->uProtocolVer = 0; 112 pCtx->uProtocolFlags = 0; 113 pCtx->cbChunkSize = _64K; 114 115 rc = VINF_SUCCESS; /* Failing above is not fatal. */ 116 } 117 118 LogFlowFunc(("uProtocolVer=%RU32, cbChunkSize=%RU32\n", pCtx->uProtocolVer, pCtx->cbChunkSize)); 86 119 } 87 120 … … 92 125 93 126 /** 94 * Disconnects from the Shared Clipboard service .127 * Disconnects from the Shared Clipboard service, legacy version, do not use anymore. 95 128 * 96 129 * @returns VBox status code. … … 122 155 123 156 157 VBGLR3DECL(int) VbglR3ClipboardFormatsWriteRecv(PVBGLR3SHCLCMDCTX pCtx, PSHAREDCLIPBOARDFORMATDATA pFormats) 158 { 159 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 160 AssertPtrReturn(pFormats, VERR_INVALID_POINTER); 161 162 VBoxClipboardFormatsMsg Msg; 163 RT_ZERO(Msg); 164 165 if (pCtx->uProtocolVer >= 1) 166 { 167 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, 168 VBOX_SHARED_CLIPBOARD_GUEST_FN_MSG_GET, 3); 169 170 Msg.uContext.SetUInt32(VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS_WRITE); 171 Msg.uFormats.SetUInt32(0); 172 Msg.fFlags.SetUInt32(0); 173 } 174 175 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 176 if (RT_SUCCESS(rc)) 177 { 178 rc = Msg.uContext.GetUInt32(&pCtx->uContextID); 179 if (RT_SUCCESS(rc)) 180 rc = Msg.uFormats.GetUInt32(&pFormats->uFormats); 181 if (RT_SUCCESS(rc)) 182 rc = Msg.fFlags.GetUInt32(&pFormats->fFlags); 183 } 184 185 LogFlowFuncLeaveRC(rc); 186 return rc; 187 } 188 189 190 VBGLR3DECL(int) VbglR3ClipboardReadDataRecv(PVBGLR3SHCLCMDCTX pCtx, PSHAREDCLIPBOARDDATAREQ pDataReq) 191 { 192 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 193 AssertPtrReturn(pDataReq, VERR_INVALID_POINTER); 194 195 VBoxClipboardReadDataReqMsg Msg; 196 197 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, 198 VBOX_SHARED_CLIPBOARD_GUEST_FN_MSG_GET, VBOX_SHARED_CLIPBOARD_CPARMS_READ_DATA); 199 200 Msg.uContext.SetUInt32(VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA); 201 Msg.uFormat.SetUInt32(0); 202 Msg.cbSize.SetUInt32(0); 203 204 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 205 if (RT_SUCCESS(rc)) 206 { 207 rc = Msg.uContext.GetUInt32(&pCtx->uContextID); 208 if (RT_SUCCESS(rc)) 209 rc = Msg.uFormat.GetUInt32(&pDataReq->uFmt); 210 if (RT_SUCCESS(rc)) 211 rc = Msg.cbSize.GetUInt32(&pDataReq->cbSize); 212 } 213 214 LogFlowFuncLeaveRC(rc); 215 return rc; 216 } 217 218 124 219 /** 125 * Get a host message, old version.220 * Get a host message, legacy version (protocol v0). Do not use anymore. 126 221 * 127 222 * Note: This is the old message which still is being used for the non-URI Shared Clipboard transfers, … … 179 274 VBoxClipboardReadDataMsg Msg; 180 275 181 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, VBOX_SHARED_CLIPBOARD_GUEST_FN_ READ_DATA, VBOX_SHARED_CLIPBOARD_CPARMS_READ_DATA);276 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, VBOX_SHARED_CLIPBOARD_GUEST_FN_DATA_READ, VBOX_SHARED_CLIPBOARD_CPARMS_READ_DATA); 182 277 VbglHGCMParmUInt32Set(&Msg.format, fFormat); 183 278 VbglHGCMParmPtrSet(&Msg.ptr, pv, cb); … … 201 296 } 202 297 203 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST204 #if 0205 static int vbglR3ClipboardPeekMsg(HGCMCLIENTID idClient, uint32_t *puMsg, uint32_t *pcParms, bool fWait)206 {207 AssertPtrReturn(puMsg, VERR_INVALID_POINTER);208 AssertPtrReturn(pcParms, VERR_INVALID_POINTER);209 210 VBoxClipboardPeekMsg Msg;211 RT_ZERO(Msg);212 213 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient,214 VBOX_SHARED_CLIPBOARD_GUEST_FN_GET_HOST_MSG, VBOX_SHARED_CLIPBOARD_CPARMS_GET_HOST_MSG);215 216 Msg.uMsg.SetUInt32(0);217 Msg.cParms.SetUInt32(0);218 Msg.fBlock.SetUInt32(fWait ? 1 : 0);219 220 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg));221 if (RT_SUCCESS(rc))222 {223 rc = Msg.uMsg.GetUInt32(puMsg);224 if (RT_SUCCESS(rc))225 rc = Msg.cParms.GetUInt32(pcParms);226 }227 228 LogFlowFuncLeaveRC(rc);229 return rc;230 }231 #else232 298 /** 233 299 * Peeks at the next host message, waiting for one to turn up. … … 264 330 VbglHGCMParmUInt32Set(&Msg.cParameters, 0); 265 331 rc = VbglR3HGCMCall(&Msg.Hdr, sizeof(Msg)); 266 Log Rel2(("VbglR3GuestCtrlMsgPeekWait-> %Rrc\n", rc));332 LogFlowFunc(("VbglR3HGCMCall -> %Rrc\n", rc)); 267 333 if (RT_SUCCESS(rc)) 268 334 { … … 297 363 return rc; 298 364 } 299 #endif 300 301 VBGLR3DECL(int) VbglR3ClipboardTransferSendStatus(PVBGLR3SHCLCMDCTX pCtx, SHAREDCLIPBOARDURITRANSFERSTATUS uStatus) 302 { 303 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 365 366 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 367 VBGLR3DECL(int) VbglR3ClipboardTransferSendStatus(PVBGLR3SHCLCMDCTX pCtx, 368 PSHAREDCLIPBOARDURITRANSFER pTransfer, SHAREDCLIPBOARDURITRANSFERSTATUS uStatus) 369 { 370 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 371 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 304 372 305 373 VBoxClipboardStatusMsg Msg; … … 309 377 VBOX_SHARED_CLIPBOARD_GUEST_FN_STATUS, VBOX_SHARED_CLIPBOARD_CPARMS_STATUS); 310 378 311 Msg.uContext.SetUInt32( pCtx->uContextID);379 Msg.uContext.SetUInt32(VBOX_SHARED_CLIPBOARD_CONTEXTID_MAKE(pTransfer->State.uID, 0 /* Event, ignored */)); 312 380 Msg.uStatus.SetUInt32(uStatus); 313 381 Msg.cbPayload.SetUInt32(0); … … 332 400 333 401 Msg.ReqParms.uContext.SetUInt32(pCtx->uContextID); 334 Msg.ReqParms.fRoots.SetUInt32( pRootListHdr->fRoots);402 Msg.ReqParms.fRoots.SetUInt32(0); 335 403 336 404 Msg.cRoots.SetUInt32(0); 337 Msg.enmCompression.SetUInt32(0); /** @todo Not implemented yet. */338 Msg.enmChecksumType.SetUInt32(0); /** @todo Not implemented yet. */339 405 340 406 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); … … 375 441 if (RT_SUCCESS(rc)) 376 442 { 377 uint32_t cbInfo ;443 uint32_t cbInfo = 0; 378 444 rc = Msg.cbInfo.GetUInt32(&cbInfo); AssertRC(rc); 379 445 if (pRootListEntry->cbInfo != cbInfo) … … 476 542 477 543 Msg.cRoots.SetUInt32(pRootListHdr->cRoots); 478 Msg.enmCompression.SetUInt32(0); /** @todo Not implemented yet. */479 Msg.enmChecksumType.SetUInt32(0); /** @todo Not implemented yet. */480 544 481 545 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); … … 515 579 } 516 580 517 VBGLR3DECL(int) VbglR3ClipboardRootListEntryReadReply(PVBGLR3SHCLCMDCTX pCtx, uint32_t uIndex, PVBOXCLIPBOARD LISTENTRY pEntry)581 VBGLR3DECL(int) VbglR3ClipboardRootListEntryReadReply(PVBGLR3SHCLCMDCTX pCtx, uint32_t uIndex, PVBOXCLIPBOARDROOTLISTENTRY pEntry) 518 582 { 519 583 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); … … 619 683 Msg.rc.SetUInt32((uint32_t)rcReply); /** int vs. uint32_t */ 620 684 Msg.cbPayload.SetUInt32(0); 621 Msg.pvPayload.SetPtr( 0, NULL);685 Msg.pvPayload.SetPtr(NULL, 0); 622 686 623 687 Msg.u.ListOpen.uHandle.SetUInt64(hList); … … 669 733 Msg.rc.SetUInt32((uint32_t)rcReply); /** int vs. uint32_t */ 670 734 Msg.cbPayload.SetUInt32(0); 671 Msg.pvPayload.SetPtr( 0, NULL);735 Msg.pvPayload.SetPtr(NULL, 0); 672 736 673 737 Msg.u.ListOpen.uHandle.SetUInt64(hList); … … 719 783 Msg.cTotalObjects.SetUInt64(0); 720 784 Msg.cbTotalSize.SetUInt64(0); 721 Msg.enmCompression.SetUInt32(0);722 Msg.enmChecksumType.SetUInt32(0);723 785 724 786 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); … … 730 792 if (RT_SUCCESS(rc)) 731 793 rc = Msg.cbTotalSize.GetUInt64(&pListHdr->cbTotalSize); 732 if (RT_SUCCESS(rc))733 rc = Msg.enmCompression.GetUInt32(&pListHdr->enmCompression);734 if (RT_SUCCESS(rc))735 rc = Msg.enmChecksumType.GetUInt32(&pListHdr->enmChecksumType);736 794 } 737 795 … … 790 848 Msg.cTotalObjects.SetUInt64(pListHdr->cTotalObjects); 791 849 Msg.cbTotalSize.SetUInt64(pListHdr->cbTotalSize); 792 Msg.enmCompression.SetUInt32(pListHdr->enmCompression);793 Msg.enmChecksumType.SetUInt32(pListHdr->enmChecksumType);794 850 795 851 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); … … 930 986 Msg.rc.SetUInt32((uint32_t)rcReply); /** int vs. uint32_t */ 931 987 Msg.cbPayload.SetUInt32(0); 932 Msg.pvPayload.SetPtr( 0, NULL);988 Msg.pvPayload.SetPtr(NULL, 0); 933 989 934 990 Msg.u.ObjOpen.uHandle.SetUInt64(hObj); … … 1009 1065 Msg.rc.SetUInt32((uint32_t)rcReply); /** int vs. uint32_t */ 1010 1066 Msg.cbPayload.SetUInt32(0); 1011 Msg.pvPayload.SetPtr( 0, NULL);1067 Msg.pvPayload.SetPtr(NULL, 0); 1012 1068 1013 1069 Msg.u.ObjClose.uHandle.SetUInt64(hObj); … … 1144 1200 } 1145 1201 1146 VBGLR3DECL(int) VbglR3ClipboardEventGetNext(PVBGLR3SHCLCMDCTX pCtx, PSHAREDCLIPBOARDURITRANSFER pTransfer, 1147 PVBGLR3CLIPBOARDEVENT *ppEvent) 1202 VBGLR3DECL(int) VbglR3ClipboardTransferEvent(PVBGLR3SHCLCMDCTX pCtx, uint32_t uMsg, uint32_t cParms, 1203 PSHAREDCLIPBOARDURITRANSFER pTransfer) 1204 { 1205 RT_NOREF(cParms); 1206 1207 LogFunc(("Handling uMsg=%RU32 (%s), cParms=%RU32\n", uMsg, VBoxClipboardHostMsgToStr(uMsg), cParms)); 1208 1209 int rc; 1210 1211 switch (uMsg) 1212 { 1213 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_ROOT_LIST_HDR_READ: 1214 { 1215 uint32_t fRoots; 1216 rc = VbglR3ClipboardRootListHdrReadReq(pCtx, &fRoots); 1217 1218 /** @todo Validate / handle fRoots. */ 1219 1220 if (RT_SUCCESS(rc)) 1221 { 1222 VBOXCLIPBOARDROOTLISTHDR rootListHdr; 1223 RT_ZERO(rootListHdr); 1224 1225 rootListHdr.cRoots = SharedClipboardURILTransferRootsCount(pTransfer); 1226 1227 LogFlowFunc(("cRoots=%RU32\n", rootListHdr.cRoots)); 1228 1229 rc = VbglR3ClipboardRootListHdrReadReply(pCtx, &rootListHdr); 1230 } 1231 break; 1232 } 1233 1234 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_ROOT_LIST_ENTRY_READ: 1235 { 1236 uint32_t uIndex; 1237 uint32_t fInfo; 1238 rc = VbglR3ClipboardRootListEntryReadReq(pCtx, &uIndex, &fInfo); 1239 if (RT_SUCCESS(rc)) 1240 { 1241 VBOXCLIPBOARDROOTLISTENTRY rootListEntry; 1242 rc = SharedClipboardURILTransferRootsEntry(pTransfer, uIndex, &rootListEntry); 1243 if (RT_SUCCESS(rc)) 1244 rc = VbglR3ClipboardRootListEntryReadReply(pCtx, uIndex, &rootListEntry); 1245 } 1246 break; 1247 } 1248 1249 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_OPEN: 1250 { 1251 VBOXCLIPBOARDLISTOPENPARMS openParmsList; 1252 rc = SharedClipboardURIListOpenParmsInit(&openParmsList); 1253 if (RT_SUCCESS(rc)) 1254 { 1255 rc = VbglR3ClipboardListOpenRecv(pCtx, &openParmsList); 1256 if (RT_SUCCESS(rc)) 1257 { 1258 LogFlowFunc(("pszPath=%s\n", openParmsList.pszPath)); 1259 1260 SHAREDCLIPBOARDLISTHANDLE hList = SHAREDCLIPBOARDLISTHANDLE_INVALID; 1261 rc = SharedClipboardURITransferListOpen(pTransfer, &openParmsList, &hList); 1262 1263 /* Reply in any case. */ 1264 int rc2 = VbglR3ClipboardListOpenReply(pCtx, rc, hList); 1265 AssertRC(rc2); 1266 } 1267 1268 SharedClipboardURIListOpenParmsDestroy(&openParmsList); 1269 } 1270 1271 break; 1272 } 1273 1274 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_CLOSE: 1275 { 1276 SHAREDCLIPBOARDLISTHANDLE hList; 1277 rc = VbglR3ClipboardListCloseRecv(pCtx, &hList); 1278 if (RT_SUCCESS(rc)) 1279 { 1280 rc = SharedClipboardURITransferListClose(pTransfer, hList); 1281 1282 /* Reply in any case. */ 1283 int rc2 = VbglR3ClipboardListCloseReply(pCtx, rc, hList); 1284 AssertRC(rc2); 1285 } 1286 1287 break; 1288 } 1289 1290 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_HDR_READ: 1291 { 1292 /** @todo Handle filter + list features. */ 1293 1294 SHAREDCLIPBOARDLISTHANDLE hList = SHAREDCLIPBOARDLISTHANDLE_INVALID; 1295 uint32_t fFlags = 0; 1296 rc = VbglR3ClipboardListHdrReadRecvReq(pCtx, &hList, &fFlags); 1297 if (RT_SUCCESS(rc)) 1298 { 1299 VBOXCLIPBOARDLISTHDR hdrList; 1300 rc = SharedClipboardURITransferListGetHeader(pTransfer, hList, &hdrList); 1301 if (RT_SUCCESS(rc)) 1302 { 1303 rc = VbglR3ClipboardListHdrWrite(pCtx, hList, &hdrList); 1304 1305 SharedClipboardURIListHdrDestroy(&hdrList); 1306 } 1307 } 1308 1309 break; 1310 } 1311 1312 #if 0 1313 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_HDR_WRITE: 1314 { 1315 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_HDR_WRITE\n")); 1316 1317 VBOXCLIPBOARDLISTHDR hdrList; 1318 rc = SharedClipboardURIListHdrInit(&hdrList); 1319 if (RT_SUCCESS(rc)) 1320 { 1321 rc = VBglR3ClipboardListHdrRecv(pCtx, ) 1322 } 1323 break; 1324 } 1325 #endif 1326 1327 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_ENTRY_READ: 1328 { 1329 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_ENTRY_READ\n")); 1330 1331 VBOXCLIPBOARDLISTENTRY entryList; 1332 rc = SharedClipboardURIListEntryInit(&entryList); 1333 if (RT_SUCCESS(rc)) 1334 { 1335 SHAREDCLIPBOARDLISTHANDLE hList; 1336 uint32_t fInfo; 1337 rc = VbglR3ClipboardListEntryReadRecvReq(pCtx, &hList, &fInfo); 1338 if (RT_SUCCESS(rc)) 1339 { 1340 rc = SharedClipboardURITransferListRead(pTransfer, hList, &entryList); 1341 if (RT_SUCCESS(rc)) 1342 { 1343 PSHAREDCLIPBOARDFSOBJINFO pObjInfo = (PSHAREDCLIPBOARDFSOBJINFO)entryList.pvInfo; 1344 Assert(entryList.cbInfo == sizeof(SHAREDCLIPBOARDFSOBJINFO)); 1345 1346 RT_NOREF(pObjInfo); 1347 1348 LogFlowFunc(("\t%s (%RU64 bytes)\n", entryList.pszName, pObjInfo->cbObject)); 1349 1350 rc = VbglR3ClipboardListEntryWrite(pCtx, hList, &entryList); 1351 } 1352 } 1353 1354 SharedClipboardURIListEntryDestroy(&entryList); 1355 } 1356 1357 break; 1358 } 1359 1360 #if 0 1361 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_ENTRY_WRITE: 1362 { 1363 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_ENTRY_WRITE\n")); 1364 pEvent->enmType = VBGLR3CLIPBOARDEVENTTYPE_URI_LIST_ENTRY_WRITE; 1365 break; 1366 } 1367 #endif 1368 1369 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_OPEN: 1370 { 1371 VBOXCLIPBOARDOBJOPENCREATEPARMS openParms; 1372 rc = SharedClipboardURIObjectOpenParmsInit(&openParms); 1373 if (RT_SUCCESS(rc)) 1374 { 1375 rc = VbglR3ClipboardObjOpenRecv(pCtx, &openParms); 1376 if (RT_SUCCESS(rc)) 1377 { 1378 SHAREDCLIPBOARDOBJHANDLE hObj; 1379 rc = SharedClipboardURIObjectOpen(pTransfer, &openParms, &hObj); 1380 1381 /* Reply in any case. */ 1382 int rc2 = VbglR3ClipboardObjOpenReply(pCtx, rc, hObj); 1383 AssertRC(rc2); 1384 } 1385 1386 SharedClipboardURIObjectOpenParmsDestroy(&openParms); 1387 } 1388 1389 break; 1390 } 1391 1392 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_CLOSE: 1393 { 1394 SHAREDCLIPBOARDOBJHANDLE hObj; 1395 rc = VbglR3ClipboardObjCloseRecv(pCtx, &hObj); 1396 if (RT_SUCCESS(rc)) 1397 { 1398 rc = SharedClipboardURIObjectClose(pTransfer, hObj); 1399 1400 /* Reply in any case. */ 1401 int rc2 = VbglR3ClipboardObjCloseReply(pCtx, rc, hObj); 1402 AssertRC(rc2); 1403 } 1404 1405 break; 1406 } 1407 1408 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_READ: 1409 { 1410 SHAREDCLIPBOARDOBJHANDLE hObj; 1411 uint32_t cbBuf; 1412 uint32_t fFlags; 1413 rc = VbglR3ClipboardObjReadRecv(pCtx, &hObj, &cbBuf, &fFlags); 1414 if (RT_SUCCESS(rc)) 1415 { 1416 AssertBreakStmt(pCtx->cbChunkSize, rc = VERR_INVALID_PARAMETER); 1417 1418 const uint32_t cbToRead = RT_MIN(cbBuf, pCtx->cbChunkSize); 1419 1420 LogFlowFunc(("hObj=%RU64, cbBuf=%RU32, fFlags=0x%x -> cbChunkSize=%RU32, cbToRead=%RU32\n", 1421 hObj, cbBuf, fFlags, pCtx->cbChunkSize, cbToRead)); 1422 1423 void *pvBuf = RTMemAlloc(cbToRead); 1424 if (pvBuf) 1425 { 1426 uint32_t cbRead; 1427 rc = SharedClipboardURIObjectRead(pTransfer, hObj, pvBuf, cbToRead, &cbRead, fFlags); 1428 if (RT_SUCCESS(rc)) 1429 rc = VbglR3ClipboardObjWrite(pCtx, hObj, pvBuf, cbRead, NULL /* pcbWritten */); 1430 1431 RTMemFree(pvBuf); 1432 } 1433 else 1434 rc = VERR_NO_MEMORY; 1435 } 1436 1437 break; 1438 } 1439 1440 #if 0 1441 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_WRITE: 1442 { 1443 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_WRITE\n")); 1444 break; 1445 } 1446 #endif 1447 1448 default: 1449 rc = VERR_NOT_SUPPORTED; 1450 break; 1451 } 1452 1453 LogFlowFuncLeaveRC(rc); 1454 return rc; 1455 } 1456 #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */ 1457 1458 VBGLR3DECL(int) VbglR3ClipboardEventGetNext(PVBGLR3SHCLCMDCTX pCtx, PVBGLR3CLIPBOARDEVENT *ppEvent) 1148 1459 { 1149 1460 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 1150 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);1151 1461 AssertPtrReturn(ppEvent, VERR_INVALID_POINTER); 1152 1462 … … 1155 1465 return VERR_NO_MEMORY; 1156 1466 1467 pEvent->cmdCtx = *pCtx; /* Use the handed-in context as the base. */ 1468 1157 1469 uint32_t uMsg = 0; 1158 1470 uint32_t cParms = 0; 1159 int rc = vbglR3ClipboardMsgPeekWait( pCtx, &uMsg, &cParms, NULL /* pidRestoreCheck */);1471 int rc = vbglR3ClipboardMsgPeekWait(&pEvent->cmdCtx, &uMsg, &cParms, NULL /* pidRestoreCheck */); 1160 1472 if (RT_SUCCESS(rc)) 1161 1473 { … … 1165 1477 switch (uMsg) 1166 1478 { 1167 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 1168 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_ROOT_LIST_HDR_READ: 1479 case VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS_WRITE: 1169 1480 { 1170 uint32_t fRoots; 1171 rc = VbglR3ClipboardRootListHdrReadReq(pCtx, &fRoots); 1172 1173 /** @todo Validate / handle fRoots. */ 1174 1481 rc = VbglR3ClipboardFormatsWriteRecv(&pEvent->cmdCtx, &pEvent->u.ReportFormats); 1175 1482 if (RT_SUCCESS(rc)) 1176 { 1177 VBOXCLIPBOARDROOTLISTHDR rootListHdr; 1178 RT_ZERO(rootListHdr); 1179 1180 rootListHdr.cRoots = SharedClipboardURILTransferRootsCount(pTransfer); 1181 1182 LogFlowFunc(("cRoots=%RU32\n", rootListHdr.cRoots)); 1183 1184 rc = VbglR3ClipboardRootListHdrReadReply(pCtx, &rootListHdr); 1185 } 1483 pEvent->enmType = VBGLR3CLIPBOARDEVENTTYPE_REPORT_FORMATS; 1186 1484 break; 1187 1485 } 1188 1486 1189 case VBOX_SHARED_CLIPBOARD_HOST_MSG_ URI_ROOT_LIST_ENTRY_READ:1487 case VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA: 1190 1488 { 1191 uint32_t uIndex; 1192 uint32_t fInfo; 1193 rc = VbglR3ClipboardRootListEntryReadReq(pCtx, &uIndex, &fInfo); 1489 rc = VbglR3ClipboardReadDataRecv(&pEvent->cmdCtx, &pEvent->u.ReadData); 1194 1490 if (RT_SUCCESS(rc)) 1195 { 1196 VBOXCLIPBOARDLISTENTRY rootListEntry; 1197 rc = SharedClipboardURILTransferRootsEntry(pTransfer, uIndex, &rootListEntry); 1198 if (RT_SUCCESS(rc)) 1199 rc = VbglR3ClipboardRootListEntryReadReply(pCtx, uIndex, &rootListEntry); 1200 } 1491 pEvent->enmType = VBGLR3CLIPBOARDEVENTTYPE_READ_DATA; 1201 1492 break; 1202 1493 } 1203 1494 1204 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_OPEN:1495 default: 1205 1496 { 1206 VBOXCLIPBOARDLISTOPENPARMS openParmsList; 1207 rc = SharedClipboardURIListOpenParmsInit(&openParmsList); 1208 if (RT_SUCCESS(rc)) 1209 { 1210 rc = VbglR3ClipboardListOpenRecv(pCtx, &openParmsList); 1211 if (RT_SUCCESS(rc)) 1212 { 1213 LogFlowFunc(("pszPath=%s\n", openParmsList.pszPath)); 1214 1215 SHAREDCLIPBOARDLISTHANDLE hList = SHAREDCLIPBOARDLISTHANDLE_INVALID; 1216 rc = SharedClipboardURITransferListOpen(pTransfer, &openParmsList, &hList); 1217 1218 /* Reply in any case. */ 1219 int rc2 = VbglR3ClipboardListOpenReply(pCtx, rc, hList); 1220 AssertRC(rc2); 1221 } 1222 1223 SharedClipboardURIListOpenParmsDestroy(&openParmsList); 1224 } 1225 1497 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 1498 rc = VbglR3ClipboardTransferEvent(&pEvent->cmdCtx, uMsg, cParms, NULL /* pTransfer */ ); /**** @todo FIX !!! */ 1499 #endif 1500 rc = VERR_NOT_SUPPORTED; 1226 1501 break; 1227 1502 } 1228 1229 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_CLOSE:1230 {1231 SHAREDCLIPBOARDLISTHANDLE hList;1232 rc = VbglR3ClipboardListCloseRecv(pCtx, &hList);1233 if (RT_SUCCESS(rc))1234 {1235 rc = SharedClipboardURITransferListClose(pTransfer, hList);1236 1237 /* Reply in any case. */1238 int rc2 = VbglR3ClipboardListCloseReply(pCtx, rc, hList);1239 AssertRC(rc2);1240 }1241 1242 break;1243 }1244 1245 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_HDR_READ:1246 {1247 /** @todo Handle filter + list features. */1248 1249 SHAREDCLIPBOARDLISTHANDLE hList = SHAREDCLIPBOARDLISTHANDLE_INVALID;1250 uint32_t fFlags = 0;1251 rc = VbglR3ClipboardListHdrReadRecvReq(pCtx, &hList, &fFlags);1252 if (RT_SUCCESS(rc))1253 {1254 VBOXCLIPBOARDLISTHDR hdrList;1255 rc = SharedClipboardURITransferListGetHeader(pTransfer, hList, &hdrList);1256 if (RT_SUCCESS(rc))1257 {1258 rc = VbglR3ClipboardListHdrWrite(pCtx, hList, &hdrList);1259 1260 SharedClipboardURIListHdrDestroy(&hdrList);1261 }1262 }1263 1264 break;1265 }1266 1267 #if 01268 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_HDR_WRITE:1269 {1270 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_HDR_WRITE\n"));1271 1272 VBOXCLIPBOARDLISTHDR hdrList;1273 rc = SharedClipboardURIListHdrInit(&hdrList);1274 if (RT_SUCCESS(rc))1275 {1276 rc = VBglR3ClipboardListHdrRecv(pCtx, )1277 }1278 break;1279 }1280 #endif1281 1282 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_ENTRY_READ:1283 {1284 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_ENTRY_READ\n"));1285 1286 VBOXCLIPBOARDLISTENTRY entryList;1287 rc = SharedClipboardURIListEntryInit(&entryList);1288 if (RT_SUCCESS(rc))1289 {1290 SHAREDCLIPBOARDLISTHANDLE hList;1291 uint32_t fInfo;1292 rc = VbglR3ClipboardListEntryReadRecvReq(pCtx, &hList, &fInfo);1293 if (RT_SUCCESS(rc))1294 {1295 rc = SharedClipboardURITransferListRead(pTransfer, hList, &entryList);1296 if (RT_SUCCESS(rc))1297 {1298 PSHAREDCLIPBOARDFSOBJINFO pObjInfo = (PSHAREDCLIPBOARDFSOBJINFO)entryList.pvInfo;1299 Assert(entryList.cbInfo == sizeof(SHAREDCLIPBOARDFSOBJINFO));1300 1301 RT_NOREF(pObjInfo);1302 1303 LogFlowFunc(("\t%s (%RU64 bytes)\n", entryList.pszName, pObjInfo->cbObject));1304 1305 rc = VbglR3ClipboardListEntryWrite(pCtx, hList, &entryList);1306 }1307 }1308 1309 SharedClipboardURIListEntryDestroy(&entryList);1310 }1311 1312 break;1313 }1314 1315 #if 01316 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_ENTRY_WRITE:1317 {1318 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_LIST_ENTRY_WRITE\n"));1319 pEvent->enmType = VBGLR3CLIPBOARDEVENTTYPE_URI_LIST_ENTRY_WRITE;1320 break;1321 }1322 #endif1323 1324 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_OPEN:1325 {1326 VBOXCLIPBOARDOBJOPENCREATEPARMS openParms;1327 rc = SharedClipboardURIObjectOpenParmsInit(&openParms);1328 if (RT_SUCCESS(rc))1329 {1330 rc = VbglR3ClipboardObjOpenRecv(pCtx, &openParms);1331 if (RT_SUCCESS(rc))1332 {1333 SHAREDCLIPBOARDOBJHANDLE hObj;1334 rc = SharedClipboardURIObjectOpen(pTransfer, &openParms, &hObj);1335 1336 /* Reply in any case. */1337 int rc2 = VbglR3ClipboardObjOpenReply(pCtx, rc, hObj);1338 AssertRC(rc2);1339 }1340 1341 SharedClipboardURIObjectOpenParmsDestroy(&openParms);1342 }1343 1344 break;1345 }1346 1347 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_CLOSE:1348 {1349 SHAREDCLIPBOARDOBJHANDLE hObj;1350 rc = VbglR3ClipboardObjCloseRecv(pCtx, &hObj);1351 if (RT_SUCCESS(rc))1352 {1353 rc = SharedClipboardURIObjectClose(pTransfer, hObj);1354 1355 /* Reply in any case. */1356 int rc2 = VbglR3ClipboardObjCloseReply(pCtx, rc, hObj);1357 AssertRC(rc2);1358 }1359 break;1360 }1361 1362 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_READ:1363 {1364 SHAREDCLIPBOARDOBJHANDLE hObj;1365 uint32_t cbBuf;1366 uint32_t fFlags;1367 rc = VbglR3ClipboardObjReadRecv(pCtx, &hObj, &cbBuf, &fFlags);1368 if (RT_SUCCESS(rc))1369 {1370 AssertBreakStmt(pCtx->cbChunkSize, rc = VERR_INVALID_PARAMETER);1371 1372 const uint32_t cbToRead = RT_MIN(cbBuf, pCtx->cbChunkSize);1373 1374 LogFlowFunc(("hObj=%RU64, cbBuf=%RU32, fFlags=0x%x -> cbChunkSize=%RU32, cbToRead=%RU32\n",1375 hObj, cbBuf, fFlags, pCtx->cbChunkSize, cbToRead));1376 1377 void *pvBuf = RTMemAlloc(cbToRead);1378 if (pvBuf)1379 {1380 uint32_t cbRead;1381 rc = SharedClipboardURIObjectRead(pTransfer, hObj, pvBuf, cbToRead, &cbRead, fFlags);1382 if (RT_SUCCESS(rc))1383 rc = VbglR3ClipboardObjWrite(pCtx, hObj, pvBuf, cbRead, NULL /* pcbWritten */);1384 1385 RTMemFree(pvBuf);1386 }1387 else1388 rc = VERR_NO_MEMORY;1389 }1390 break;1391 }1392 1393 #if 01394 case VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_WRITE:1395 {1396 LogFlowFunc(("VBOX_SHARED_CLIPBOARD_HOST_MSG_URI_OBJ_WRITE\n"));1397 break;1398 }1399 #endif1400 #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */1401 1402 default:1403 rc = VERR_NOT_SUPPORTED;1404 break;1405 1503 } 1406 1504 } … … 1537 1635 } 1538 1636 #endif 1539 #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */ 1637 1638 /** 1639 * Sends (reports) guest clipboard formats to the host. 1640 * 1641 * @returns VBox status code. 1642 * @param pCtx The command context returned by VbglR3ClipboardConnect(). 1643 * @param pFormats The formats to send (report). 1644 */ 1645 VBGLR3DECL(int) VbglR3ClipboardFormatsSend(PVBGLR3SHCLCMDCTX pCtx, PSHAREDCLIPBOARDFORMATDATA pFormats) 1646 { 1647 VBoxClipboardFormatsMsg Msg; 1648 1649 if (pCtx->uProtocolVer == 0) 1650 { 1651 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, VBOX_SHARED_CLIPBOARD_GUEST_FN_FORMATS_WRITE, 1); 1652 VbglHGCMParmUInt32Set(&Msg.uFormats, pFormats->uFormats); 1653 } 1654 else 1655 { 1656 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, VBOX_SHARED_CLIPBOARD_GUEST_FN_FORMATS_WRITE, 3); 1657 1658 Msg.uContext.SetUInt32(pCtx->uContextID); 1659 Msg.uFormats.SetUInt32(pFormats->uFormats); 1660 Msg.fFlags.SetUInt32(pFormats->fFlags); 1661 } 1662 1663 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 1664 1665 LogFlowFuncLeaveRC(rc); 1666 return rc; 1667 } 1540 1668 1541 1669 /** 1542 1670 * Reports (advertises) guest clipboard formats to the host. 1671 * 1672 * Legacy function, do not use anymore. 1543 1673 * 1544 1674 * @returns VBox status code. … … 1548 1678 VBGLR3DECL(int) VbglR3ClipboardReportFormats(HGCMCLIENTID idClient, uint32_t fFormats) 1549 1679 { 1550 VBoxClipboard ReportFormatsMsg Msg;1551 1552 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, VBOX_SHARED_CLIPBOARD_GUEST_FN_ REPORT_FORMATS, VBOX_SHARED_CLIPBOARD_CPARMS_REPORT_FORMATS);1553 VbglHGCMParmUInt32Set(&Msg. formats, fFormats);1680 VBoxClipboardFormatsMsg Msg; 1681 1682 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, VBOX_SHARED_CLIPBOARD_GUEST_FN_FORMATS_WRITE, 1); 1683 VbglHGCMParmUInt32Set(&Msg.uFormats, fFormats); 1554 1684 1555 1685 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); … … 1557 1687 1558 1688 /** 1559 * Sends guest clipboard data to the host. 1560 * 1561 * This is usually called in reply to a VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA message 1562 * from the host. 1563 * 1564 * @returns VBox status code. 1565 * @param idClient The client id returned by VbglR3ClipboardConnect(). 1566 * @param fFormat The format of the data. 1567 * @param pv The data. 1568 * @param cb The size of the data. 1569 */ 1570 static int vbglR3ClipboardWriteDataRaw(HGCMCLIENTID idClient, uint32_t fFormat, void *pv, uint32_t cb) 1571 { 1572 VBoxClipboardWriteDataMsg Msg; 1573 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, VBOX_SHARED_CLIPBOARD_GUEST_FN_WRITE_DATA, VBOX_SHARED_CLIPBOARD_CPARMS_WRITE_DATA); 1574 VbglHGCMParmUInt32Set(&Msg.format, fFormat); 1575 VbglHGCMParmPtrSet(&Msg.ptr, pv, cb); 1576 1577 return VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 1578 } 1579 1580 /** 1581 * Send guest clipboard data to the host. 1689 * Sends guest clipboard data to the host. Legacy function kept for compatibility, do not use anymore. 1582 1690 * 1583 1691 * This is usually called in reply to a VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA message … … 1592 1700 VBGLR3DECL(int) VbglR3ClipboardWriteData(HGCMCLIENTID idClient, uint32_t fFormat, void *pv, uint32_t cb) 1593 1701 { 1594 int rc = vbglR3ClipboardWriteDataRaw(idClient, fFormat, pv, cb); 1595 1596 return rc; 1597 } 1598 1599 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 1702 VBoxClipboardWriteDataMsg Msg; 1703 RT_ZERO(Msg); 1704 1705 VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, 1706 VBOX_SHARED_CLIPBOARD_GUEST_FN_DATA_WRITE, 2); 1707 1708 VbglHGCMParmUInt32Set(&Msg.v0.format, fFormat); 1709 VbglHGCMParmPtrSet(&Msg.v0.ptr, pv, cb); 1710 1711 int rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 1712 1713 LogFlowFuncLeaveRC(rc); 1714 return rc; 1715 } 1716 1717 /** 1718 * Sends guest clipboard data to the host. 1719 * 1720 * This is usually called in reply to a VBOX_SHARED_CLIPBOARD_HOST_MSG_READ_DATA message 1721 * from the host. 1722 * 1723 * @returns VBox status code. 1724 * @param pCtx The command context returned by VbglR3ClipboardConnect(). 1725 * @param pData Clipboard data to send. 1726 */ 1727 VBGLR3DECL(int) VbglR3ClipboardWriteDataEx(PVBGLR3SHCLCMDCTX pCtx, PSHAREDCLIPBOARDDATABLOCK pData) 1728 { 1729 int rc; 1730 1731 if (pCtx->uProtocolVer == 0) 1732 { 1733 rc = VbglR3ClipboardWriteData(pCtx->uClientID, pData->uFormat, pData->pvData, pData->cbData); 1734 } 1735 else 1736 { 1737 VBoxClipboardWriteDataMsg Msg; 1738 RT_ZERO(Msg); 1739 1740 VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, 1741 VBOX_SHARED_CLIPBOARD_GUEST_FN_DATA_WRITE, VBOX_SHARED_CLIPBOARD_CPARMS_WRITE_DATA); 1742 1743 LogFlowFunc(("CID=%RU32\n", pCtx->uContextID)); 1744 1745 Msg.v1.uContext.SetUInt32(pCtx->uContextID); 1746 Msg.v1.uFormat.SetUInt32(pData->uFormat); 1747 Msg.v1.cbData.SetUInt32(pData->cbData); 1748 Msg.v1.pvData.SetPtr(pData->pvData, pData->cbData); 1749 1750 rc = VbglR3HGCMCall(&Msg.hdr, sizeof(Msg)); 1751 } 1752 1753 LogFlowFuncLeaveRC(rc); 1754 return rc; 1755 } 1756 1600 1757 /** 1601 1758 * Writes an error to the host. … … 1629 1786 return rc; 1630 1787 } 1631 #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */ 1632 1788 -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceClipboard-os2.cpp
r79497 r80444 775 775 * Listener message - the host has new formats to offer. 776 776 */ 777 case WM_USER + VBOX_SHARED_CLIPBOARD_HOST_MSG_ REPORT_FORMATS:777 case WM_USER + VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS_WRITE: 778 778 vgsvcClipboardOs2AdvertiseHostFormats(LONGFROMMP(mp1)); 779 779 break; … … 895 895 * respond do WM_RENDERFORMAT message. 896 896 */ 897 case VBOX_SHARED_CLIPBOARD_HOST_MSG_ REPORT_FORMATS:898 if (!WinPostMsg(g_hwndWorker, WM_USER + VBOX_SHARED_CLIPBOARD_HOST_MSG_ REPORT_FORMATS,897 case VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS_WRITE: 898 if (!WinPostMsg(g_hwndWorker, WM_USER + VBOX_SHARED_CLIPBOARD_HOST_MSG_FORMATS_WRITE, 899 899 MPFROMLONG(fFormats), 0)) 900 900 VGSvcError("WinPostMsg(%lx, FORMATS,,) failed, lasterr=%#lx\n",
Note:
See TracChangeset
for help on using the changeset viewer.