Changeset 103615 in vbox
- Timestamp:
- Feb 29, 2024 6:36:37 PM (9 months ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/GuestHost/SharedClipboard-win.h
r103450 r103615 499 499 void SharedClipboardWinTransferDestroy(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer); 500 500 501 int SharedClipboardWinTransferHandOffToDataObject(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer);502 501 int SharedClipboardWinTransferCreateAndSetDataObject(PSHCLWINCTX pWinCtx, PSHCLCONTEXT pCtx, SharedClipboardWinDataObject::PCALLBACKS pCallbacks); 502 int SharedClipboardWinTransferInitialize(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer); 503 int SharedClipboardWinTransferStart(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer); 503 504 # endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */ 504 505 #endif /* !VBOX_INCLUDED_GuestHost_SharedClipboard_win_h */ -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
r103450 r103615 165 165 * 166 166 * Called by ShClTransferInit via VbglR3. 167 * For G->H: Called on transfer intialization to notify the "in-flight" IDataObject abouta data transfer.168 * For H->G: Called on transfer intialization to populate the transfer's root list.167 * For H->G: Called on transfer intialization to initialize the "in-flight" IDataObject for a data transfer. 168 * For G->H: Called on transfer intialization to populate the transfer's root list. 169 169 * 170 170 * @thread Clipboard main thread. … … 184 184 switch(ShClTransferGetDir(pTransfer)) 185 185 { 186 case SHCLTRANSFERDIR_FROM_REMOTE: /* G->H*/187 { 188 rc = SharedClipboardWinTransfer HandOffToDataObject(&pCtx->Win, pTransfer);189 break; 190 } 191 192 case SHCLTRANSFERDIR_TO_REMOTE: /* H->G*/186 case SHCLTRANSFERDIR_FROM_REMOTE: /* H->G */ 187 { 188 rc = SharedClipboardWinTransferInitialize(&pCtx->Win, pTransfer); 189 break; 190 } 191 192 case SHCLTRANSFERDIR_TO_REMOTE: /* G->H */ 193 193 { 194 194 rc = SharedClipboardWinTransferGetRootsFromClipboard(&pCtx->Win, pTransfer); … … 202 202 LogFlowFuncLeaveRC(rc); 203 203 return rc; 204 } 205 206 /** 207 * @copydoc SHCLTRANSFERCALLBACKS::pfnOnInitialized 208 * 209 * Called by ShClTransferInit via VbglR3. 210 * For H->G: Called on transfer intialization to start the data transfer for the "in-flight" IDataObject. 211 * For G->H: Nothing to do here. 212 * 213 * @thread Clipboard main thread. 214 */ 215 static DECLCALLBACK(void) vbtrShClTransferInitializedCallback(PSHCLTRANSFERCALLBACKCTX pCbCtx) 216 { 217 LogFlowFuncEnter(); 218 219 int rc = VINF_SUCCESS; 220 221 PSHCLCONTEXT pCtx = (PSHCLCONTEXT)pCbCtx->pvUser; 222 AssertPtr(pCtx); 223 224 PSHCLTRANSFER pTransfer = pCbCtx->pTransfer; 225 AssertPtr(pTransfer); 226 227 switch(ShClTransferGetDir(pTransfer)) 228 { 229 case SHCLTRANSFERDIR_FROM_REMOTE: /* H->G */ 230 { 231 rc = SharedClipboardWinTransferStart(&pCtx->Win, pTransfer); 232 break; 233 } 234 235 case SHCLTRANSFERDIR_TO_REMOTE: /* G->H */ 236 break; 237 238 default: 239 break; 240 } 241 242 LogFlowFuncLeaveRC(rc); 204 243 } 205 244 … … 973 1012 pCtx->CmdCtx.Transfers.Callbacks.pfnOnDestroy = vbtrShClTransferDestroyCallback; 974 1013 pCtx->CmdCtx.Transfers.Callbacks.pfnOnInitialize = vbtrShClTransferInitializeCallback; 1014 pCtx->CmdCtx.Transfers.Callbacks.pfnOnInitialized = vbtrShClTransferInitializedCallback; 975 1015 pCtx->CmdCtx.Transfers.Callbacks.pfnOnStarted = vbtrShClTransferStartedCallback; 976 1016 pCtx->CmdCtx.Transfers.Callbacks.pfnOnCompleted = vbtrShClTransferCompletedCallback; -
trunk/src/VBox/GuestHost/SharedClipboard/ClipboardDataObjectImpl-win.cpp
r103484 r103615 219 219 220 220 lock(); 221 222 /* Make sure to release the transfer. */ 223 setTransferLocked(NULL);224 }221 } 222 223 /* Make sure to release the transfer in any state. */ 224 setTransferLocked(NULL); 225 225 226 226 unlock(); … … 280 280 m_pStgMedium = NULL; 281 281 } 282 283 if (m_pTransfer)284 ShClTransferRelease(m_pTransfer);285 282 286 283 FsObjEntryList::const_iterator itRoot = m_lstEntries.cbegin(); … … 566 563 if (RT_SUCCESS(rc)) 567 564 { 568 pThis->lock();569 570 565 AssertReleaseMsg(pThis->m_lstEntries.size(), 571 566 ("Shared Clipboard: No transfer root entries found -- should not happen, please file a bug report\n")); … … 578 573 break; 579 574 580 pThis->unlock();581 582 575 /* Transferring stuff can take a while, so don't use any timeout here. */ 583 576 rc = RTSemEventWait(pThis->m_EventStatusChanged, RT_INDEFINITE_WAIT); 584 585 pThis->lock();586 587 577 if (RT_FAILURE(rc)) 588 578 break; … … 620 610 break; 621 611 } 622 623 pThis->unlock();624 612 625 613 if (pThis->m_Callbacks.pfnTransferEnd) … … 630 618 } 631 619 632 pThis->lock();633 634 620 break; 635 } 636 637 pThis->unlock(); 621 } /* for */ 638 622 } 639 623 } … … 806 790 int rc = VINF_SUCCESS; 807 791 808 /* Pre-check -- see if the data object still is alive. */809 if (m_enmStatus == Uninitialized)810 rc = VERR_OBJECT_DESTROYED;811 812 792 if ( RT_SUCCESS(rc) 813 793 && ( pFormatEtc->cfFormat == m_cfFileDescriptorA … … 841 821 lock(); 842 822 823 LogFunc(("Wait resulted in %Rrc and status %#x\n", rc, m_enmStatus)); 824 843 825 if (RT_FAILURE(rc)) 844 826 { … … 864 846 const bool fUnicode = pFormatEtc->cfFormat == m_cfFileDescriptorW; 865 847 848 /* Leave lock while waiting. */ 849 unlock(); 850 866 851 SHCLTRANSFERSTATUS const enmTransferStatus = ShClTransferGetStatus(m_pTransfer); 867 RT_NOREF(enmTransferStatus);868 852 869 853 LogFlowFunc(("FormatIndex_FileDescriptor%s, enmTransferStatus=%s\n", … … 871 855 872 856 /* The caller can call GetData() several times, so make sure we don't do the same transfer multiple times. */ 873 if ( ShClTransferGetStatus(m_pTransfer)!= SHCLTRANSFERSTATUS_STARTED)857 if (enmTransferStatus != SHCLTRANSFERSTATUS_STARTED) 874 858 { 875 859 /* Start the transfer + run it asynchronously in a separate thread. */ … … 880 864 if (RT_SUCCESS(rc)) 881 865 { 882 /* Leave lock while waiting. */883 unlock();884 885 866 /* Don't block for too long here, as this also will screw other apps running on the OS. */ 886 867 LogRel2(("Shared Clipboard: Waiting for IDataObject listing to arrive ...\n")); … … 893 874 || m_enmStatus != Running) /* Still in running state? */ 894 875 { 895 rc = VERR_ OBJECT_DESTROYED;876 rc = VERR_SHCLPB_NO_DATA; 896 877 break; 897 878 } 879 880 unlock(); 898 881 } 899 882 } 900 883 } 884 885 lock(); 901 886 902 887 if (RT_SUCCESS(rc)) … … 1147 1132 * @returns VBox status code. 1148 1133 * @param pTransfer Transfer to assign. 1149 * Must be in INITIALIZED state.1150 1134 * When set to NULL, the transfer will be released from the object. 1151 1135 */ … … 1154 1138 AssertReturn(RTCritSectIsOwned(&m_CritSect), VERR_WRONG_ORDER); 1155 1139 1156 LogF lowFunc(("pTransfer=%p\n", pTransfer));1140 LogFunc(("pTransfer=%p\n", pTransfer)); 1157 1141 1158 1142 int rc = VINF_SUCCESS; … … 1164 1148 if (m_enmStatus == Initialized) 1165 1149 { 1166 SHCLTRANSFERSTATUS const enmSts = ShClTransferGetStatus(pTransfer); 1167 AssertMsgStmt(enmSts == SHCLTRANSFERSTATUS_INITIALIZED, /* Transfer must not be started yet. */ 1168 ("Transfer has wrong status (%#x)\n", enmSts), rc = VERR_WRONG_ORDER); 1169 if (RT_SUCCESS(rc)) 1170 { 1171 m_pTransfer = pTransfer; 1172 1173 SharedClipboardWinTransferCtx *pWinURITransferCtx = (SharedClipboardWinTransferCtx *)pTransfer->pvUser; 1174 AssertPtr(pWinURITransferCtx); 1175 1176 pWinURITransferCtx->pDataObj = this; /* Save a backref to this object. */ 1177 1178 ShClTransferAcquire(pTransfer); 1179 } 1150 m_pTransfer = pTransfer; 1151 1152 SharedClipboardWinTransferCtx *pWinURITransferCtx = (SharedClipboardWinTransferCtx *)pTransfer->pvUser; 1153 AssertPtr(pWinURITransferCtx); 1154 1155 pWinURITransferCtx->pDataObj = this; /* Save a backref to this object. */ 1156 1157 ShClTransferAcquire(pTransfer); 1180 1158 } 1181 1159 else … … 1208 1186 * @returns VBox status code. 1209 1187 * @param pTransfer Transfer to assign. 1210 * Must be in INITIALIZED state.1211 1188 * When set to NULL, the transfer will be released from the object. 1212 1189 */ -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-transfers.cpp
r103480 r103615 1234 1234 1235 1235 int rc = VINF_SUCCESS; 1236 1236 1237 if (pTransfer->Callbacks.pfnOnInitialize) 1237 1238 rc = pTransfer->Callbacks.pfnOnInitialize(&pTransfer->CallbackCtx); 1238 1239 1239 if (RT_SUCCESS(rc)) 1240 1240 { … … 1244 1244 AssertMsgStmt(ShClTransferRootsCount(pTransfer), ("Transfer has no root entries set\n"), rc = VERR_WRONG_ORDER); 1245 1245 1246 rc = shClTransferSetStatus(pTransfer, SHCLTRANSFERSTATUS_INITIALIZED); 1247 1248 if ( RT_SUCCESS(rc) 1249 && pTransfer->Callbacks.pfnOnInitialized) 1250 pTransfer->Callbacks.pfnOnInitialized(&pTransfer->CallbackCtx); 1246 if (RT_SUCCESS(rc)) 1247 rc = shClTransferSetStatus(pTransfer, SHCLTRANSFERSTATUS_INITIALIZED); 1251 1248 } 1252 1249 1253 1250 shClTransferUnlock(pTransfer); 1254 1251 1252 /* Note: Callback will be called after we unlocked the transfer, as the caller might access the transfer right away. */ 1253 if ( RT_SUCCESS(rc) 1254 && pTransfer->Callbacks.pfnOnInitialized) 1255 pTransfer->Callbacks.pfnOnInitialized(&pTransfer->CallbackCtx); 1256 1255 1257 if (RT_FAILURE(rc)) 1256 LogRel 2(("Shared Clipboard: Initialziation of transfer failed with %Rrc\n", rc));1258 LogRel(("Shared Clipboard: Initialziation of transfer failed with %Rrc\n", rc)); 1257 1259 1258 1260 LogFlowFuncLeaveRC(rc); -
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp
r103452 r103615 1192 1192 1193 1193 /** 1194 * Hands off a transfer to the current data object in-flight.1194 * Initializes a Windows transfer for a given data object. 1195 1195 * 1196 1196 * @returns VBox status code. 1197 1197 * @param pWinCtx Windows context to use. 1198 * @param pTransfer Transfer to hand off to the data object. 1199 * 1200 * @note The data object will be put into running state on success and handed over to Windows. 1201 * Our data object pointer will be invalid afterwards. 1202 */ 1203 int SharedClipboardWinTransferHandOffToDataObject(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer) 1198 * @param pTransfer Transfer to initialize for the data object. 1199 * @param pObj Data object to initialize transfer for. 1200 */ 1201 static int sharedClipboardWinTransferInitializeInternal(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer, 1202 SharedClipboardWinDataObject *pObj) 1203 { 1204 RT_NOREF(pWinCtx); 1205 1206 return pObj->SetTransfer(pTransfer); 1207 } 1208 1209 /** 1210 * Initializes a Windows transfer for the current data object in-flight. 1211 * 1212 * @returns VBox status code. 1213 * @retval VERR_WRONG_ORDER if no current in-flight data object is available. 1214 * @param pWinCtx Windows context to use. 1215 * @param pTransfer Transfer to initialize for the data object. 1216 */ 1217 int SharedClipboardWinTransferInitialize(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer) 1204 1218 { 1205 1219 int rc = RTCritSectEnter(&pWinCtx->CritSect); … … 1209 1223 if (pObj) 1210 1224 { 1211 rc = pObj->SetTransfer(pTransfer); 1225 rc = sharedClipboardWinTransferInitializeInternal(pWinCtx, pTransfer, pObj); 1226 } 1227 else /* No current in-flight data object. */ 1228 rc = VERR_WRONG_ORDER; 1229 1230 int rc2 = RTCritSectLeave(&pWinCtx->CritSect); 1231 AssertRC(rc2); 1232 } 1233 1234 return rc; 1235 } 1236 1237 /** 1238 * Starts a Windows transfer for a given data object. 1239 * 1240 * @returns VBox status code. 1241 * @param pWinCtx Windows context to use. 1242 * @param pObj Data object to start transfer for. 1243 */ 1244 static int sharedClipboardWinTransferStartInternal(PSHCLWINCTX pWinCtx, SharedClipboardWinDataObject *pObj) 1245 { 1246 RT_NOREF(pWinCtx); 1247 1248 return pObj->SetStatus(SharedClipboardWinDataObject::Running); 1249 } 1250 1251 /** 1252 * Starts a Windows transfer for the current data object in-flight. 1253 * 1254 * This hands off the data object in-flight to Windows on success. 1255 * 1256 * @returns VBox status code. 1257 * @retval VERR_WRONG_ORDER if no current in-flight data object is available. 1258 * @param pWinCtx Windows context to use. 1259 * @param pTransfer Transfer to initialize for the data object. 1260 */ 1261 int SharedClipboardWinTransferStart(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer) 1262 { 1263 RT_NOREF(pTransfer); 1264 1265 int rc = RTCritSectEnter(&pWinCtx->CritSect); 1266 if (RT_SUCCESS(rc)) 1267 { 1268 SharedClipboardWinDataObject *pObj = pWinCtx->pDataObjInFlight; 1269 if (pObj) 1270 { 1271 rc = sharedClipboardWinTransferStartInternal(pWinCtx, pObj); 1212 1272 if (RT_SUCCESS(rc)) 1213 rc = pObj->SetStatus(SharedClipboardWinDataObject::Running); 1214 1215 pWinCtx->pDataObjInFlight = NULL; /* Hand off to Windows. */ 1216 } 1217 else 1218 { 1219 AssertMsgFailed(("No data object in flight (yet)!\n")); 1273 pWinCtx->pDataObjInFlight = NULL; /* Hand off to Windows on success. */ 1274 } 1275 else /* No current in-flight data object. */ 1220 1276 rc = VERR_WRONG_ORDER; 1221 }1222 1277 1223 1278 int rc2 = RTCritSectLeave(&pWinCtx->CritSect); -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-win.cpp
r103453 r103615 312 312 case SHCLTRANSFERDIR_FROM_REMOTE: /* G->H */ 313 313 { 314 rc = SharedClipboardWinTransfer HandOffToDataObject(&pCtx->Win, pTransfer);314 rc = SharedClipboardWinTransferInitialize(&pCtx->Win, pTransfer); 315 315 break; 316 316 } … … 329 329 LogFlowFuncLeaveRC(rc); 330 330 return rc; 331 } 332 333 /** 334 * @copydoc SHCLTRANSFERCALLBACKS::pfnOnInitialized 335 * 336 * Called by ShClTransferInit via VbglR3. 337 * For H->G: Called on transfer intialization to start the data transfer for the "in-flight" IDataObject. 338 * For G->H: Nothing to do here. 339 * 340 * @thread Clipboard main thread. 341 */ 342 static DECLCALLBACK(void) shClSvcWinTransferOnInitializedCallback(PSHCLTRANSFERCALLBACKCTX pCbCtx) 343 { 344 LogFlowFuncEnter(); 345 346 int rc = VINF_SUCCESS; 347 348 PSHCLCONTEXT pCtx = (PSHCLCONTEXT)pCbCtx->pvUser; 349 AssertPtr(pCtx); 350 351 PSHCLTRANSFER pTransfer = pCbCtx->pTransfer; 352 AssertPtr(pTransfer); 353 354 switch(ShClTransferGetDir(pTransfer)) 355 { 356 case SHCLTRANSFERDIR_FROM_REMOTE: /* H->G */ 357 { 358 rc = SharedClipboardWinTransferStart(&pCtx->Win, pTransfer); 359 break; 360 } 361 362 case SHCLTRANSFERDIR_TO_REMOTE: /* G->H */ 363 break; 364 365 default: 366 break; 367 } 368 369 LogFlowFuncLeaveRC(rc); 331 370 } 332 371 … … 840 879 pClient->Transfers.Callbacks.cbUser = sizeof(SHCLCONTEXT); 841 880 842 pClient->Transfers.Callbacks.pfnOnCreated = shClSvcWinTransferOnCreatedCallback; 843 pClient->Transfers.Callbacks.pfnOnInitialize = shClSvcWinTransferOnInitializeCallback; 844 pClient->Transfers.Callbacks.pfnOnDestroy = shClSvcWinTransferOnDestroyCallback; 881 pClient->Transfers.Callbacks.pfnOnCreated = shClSvcWinTransferOnCreatedCallback; 882 pClient->Transfers.Callbacks.pfnOnInitialize = shClSvcWinTransferOnInitializeCallback; 883 pClient->Transfers.Callbacks.pfnOnInitialized = shClSvcWinTransferOnInitializedCallback; 884 pClient->Transfers.Callbacks.pfnOnDestroy = shClSvcWinTransferOnDestroyCallback; 845 885 #endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */ 846 886 }
Note:
See TracChangeset
for help on using the changeset viewer.