Changeset 100413 in vbox for trunk/src/VBox
- Timestamp:
- Jul 6, 2023 2:10:35 PM (17 months ago)
- Location:
- trunk/src/VBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp
r100403 r100413 1126 1126 } 1127 1127 1128 #if 01129 /**1130 * Creates an Shared Clipboard transfer by announcing transfer data (via IDataObject) to Windows.1131 *1132 * This creates the necessary IDataObject + IStream implementations and initiates the actual transfers required for getting1133 * the meta data. Whether or not the actual (file++) transfer(s) are happening is up to the user (at some point) later then.1134 *1135 * @returns VBox status code.1136 * @param pWinCtx Windows context to use.1137 * @param pTransferCtxCtx Transfer contextto use.1138 * @param pTransfer Shared Clipboard transfer to use.1139 */1140 int SharedClipboardWinTransferCreate(PSHCLWINCTX pWinCtx, PSHCLTRANSFER pTransfer)1141 {1142 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);1143 1144 LogFlowFunc(("pWinCtx=%p\n", pWinCtx));1145 1146 AssertReturn(pTransfer->pvUser == NULL, VERR_WRONG_ORDER);1147 1148 /* Make sure to enter the critical section before setting the clipboard data, as otherwise WM_CLIPBOARDUPDATE1149 * might get called *before* we had the opportunity to set pWinCtx->hWndClipboardOwnerUs below. */1150 int rc = RTCritSectEnter(&pWinCtx->CritSect);1151 if (RT_SUCCESS(rc))1152 {1153 SharedClipboardWinTransferCtx *pWinURITransferCtx = new SharedClipboardWinTransferCtx();1154 if (pWinURITransferCtx)1155 {1156 pTransfer->pvUser = pWinURITransferCtx;1157 pTransfer->cbUser = sizeof(SharedClipboardWinTransferCtx);1158 1159 pWinURITransferCtx->pDataObj = new SharedClipboardWinDataObject();1160 if (pWinURITransferCtx->pDataObj)1161 {1162 rc = pWinURITransferCtx->pDataObj->Init(pCtx);1163 if (RT_SUCCESS(rc))1164 {1165 SharedClipboardWinClose();1166 /* Note: Clipboard must be closed first before calling OleSetClipboard(). */1167 1168 /** @todo There is a potential race between SharedClipboardWinClose() and OleSetClipboard(),1169 * where another application could own the clipboard (open), and thus the call to1170 * OleSetClipboard() will fail. Needs (better) fixing. */1171 HRESULT hr = S_OK;1172 1173 for (unsigned uTries = 0; uTries < 3; uTries++)1174 {1175 hr = OleSetClipboard(pWinURITransferCtx->pDataObj);1176 if (SUCCEEDED(hr))1177 {1178 Assert(OleIsCurrentClipboard(pWinURITransferCtx->pDataObj) == S_OK); /* Sanity. */1179 1180 /*1181 * Calling OleSetClipboard() changed the clipboard owner, which in turn will let us receive1182 * a WM_CLIPBOARDUPDATE message. To not confuse ourselves with our own clipboard owner changes,1183 * save a new window handle and deal with it in WM_CLIPBOARDUPDATE.1184 */1185 pWinCtx->hWndClipboardOwnerUs = GetClipboardOwner();1186 1187 LogFlowFunc(("hWndClipboardOwnerUs=%p\n", pWinCtx->hWndClipboardOwnerUs));1188 break;1189 }1190 1191 LogFlowFunc(("Failed with %Rhrc (try %u/3)\n", hr, uTries + 1));1192 RTThreadSleep(500); /* Wait a bit. */1193 }1194 1195 if (FAILED(hr))1196 {1197 rc = VERR_ACCESS_DENIED; /** @todo Fudge; fix this. */1198 LogRel(("Shared Clipboard: Failed with %Rhrc when setting data object to clipboard\n", hr));1199 }1200 }1201 }1202 else1203 rc = VERR_NO_MEMORY;1204 }1205 else1206 rc = VERR_NO_MEMORY;1207 1208 int rc2 = RTCritSectLeave(&pWinCtx->CritSect);1209 AssertRC(rc2);1210 }1211 1212 LogFlowFuncLeaveRC(rc);1213 return rc;1214 }1215 #endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */1216 1217 1128 /** 1218 1129 * Destroys implementation-specific data for an Shared Clipboard transfer. -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
r100367 r100413 1335 1335 } 1336 1336 1337 #if 0 /* ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */1338 /*1339 * When the host wants to read URI data from the guest:1340 * - Initialize a transfer locally.1341 * - Request URI data from the guest; this tells the guest to initialize a transfer on the guest side.1342 * - Start the transfer locally once we receive the transfer INITIALIZED status from the guest via VBOX_SHCL_GUEST_FN_REPLY.1343 *1344 * When this function returns, the X11 clipboard will try reading the data, so we need to make sure that1345 * - the local HTTP server is up and running (will be done in ShClBackendTransferCreate() on X11)1346 * - the right (HTTP) URL data is filled into the clipboard1347 * by then.1348 */1349 if ( RT_SUCCESS(rc)1350 && (fFormat & VBOX_SHCL_FMT_URI_LIST))1351 {1352 PSHCLTRANSFER pTransfer;1353 rc = ShClSvcTransferInit(pClient, SHCLTRANSFERDIR_FROM_REMOTE, SHCLSOURCE_REMOTE, &pTransfer);1354 if (RT_SUCCESS(rc))1355 rc = shClSvcSetSource(pClient, SHCLSOURCE_REMOTE);1356 1357 if (RT_FAILURE(rc))1358 LogRel(("Shared Clipboard: Initializing guest -> host transfer failed with %Rrc\n", rc));1359 }1360 #endif1361 1337 /* Remove event from list if caller did not request event handle or in case 1362 1338 * of failure (in this case caller should not release event). */
Note:
See TracChangeset
for help on using the changeset viewer.