Changeset 81212 in vbox for trunk/src/VBox/Additions/WINNT/VBoxTray
- Timestamp:
- Oct 10, 2019 12:22:34 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
r81134 r81212 154 154 if (enmDir == SHCLTRANSFERDIR_WRITE) 155 155 { 156 Assert(SharedClipboardTransferGetSource(pTransfer) == SHCLSOURCE_LOCAL); /* Sanity. */ 157 158 rc = SharedClipboardWinOpen(pCtx->Win.hWnd); 159 if (RT_SUCCESS(rc)) 160 { 161 /* The data data in CF_HDROP format, as the files are locally present and don't need to be 162 * presented as a IDataObject or IStream. */ 163 HANDLE hClip = hClip = GetClipboardData(CF_HDROP); 164 if (hClip) 165 { 166 HDROP hDrop = (HDROP)GlobalLock(hClip); 167 if (hDrop) 168 { 169 char *papszList = NULL; 170 uint32_t cbList; 171 rc = SharedClipboardWinDropFilesToStringList((DROPFILES *)hDrop, &papszList, &cbList); 172 173 GlobalUnlock(hClip); 174 175 if (RT_SUCCESS(rc)) 176 { 177 rc = SharedClipboardTransferRootsSet(pTransfer, 178 papszList, cbList + 1 /* Include termination */); 179 RTStrFree(papszList); 180 } 181 } 182 else 183 LogRel(("Shared Clipboard: Unable to lock clipboard data, last error: %ld\n", GetLastError())); 184 } 185 else 186 LogRel(("Shared Clipboard: Unable to retrieve clipboard data from clipboard (CF_HDROP), last error: %ld\n", 187 GetLastError())); 188 189 SharedClipboardWinClose(); 190 } 156 rc = SharedClipboardWinGetRoots(&pCtx->Win, pTransfer); 191 157 } 192 158 /* The guest wants to read data from a remote source. */ 193 159 else if (enmDir == SHCLTRANSFERDIR_READ) 194 160 { 195 Assert(SharedClipboardTransferGetSource(pTransfer) == SHCLSOURCE_REMOTE); /* Sanity. */ 196 197 rc = SharedClipboardWinTransferCreate(&pCtx->Win, pTransfer); 161 /* The IDataObject *must* be created on the same thread as our (proxy) window, so post a message to it 162 * to do the stuff for us. */ 163 const SHCLEVENTID uEvent = SharedClipboardEventIDGenerate(&pTransfer->Events); 164 165 rc = SharedClipboardEventRegister(&pTransfer->Events, uEvent); 166 if (RT_SUCCESS(rc)) 167 { 168 /* Don't want to rely on SendMessage (synchronous) here, so just post and wait the event getting signalled. */ 169 ::PostMessage(pCtx->Win.hWnd, SHCL_WIN_WM_TRANSFER_START, (WPARAM)pTransfer, (LPARAM)uEvent); 170 171 PSHCLEVENTPAYLOAD pPayload; 172 rc = SharedClipboardEventWait(&pTransfer->Events, uEvent, 30 * 1000 /* Timeout in ms */, &pPayload); 173 if (RT_SUCCESS(rc)) 174 { 175 Assert(pPayload->cbData == sizeof(int)); 176 rc = *(int *)pPayload->pvData; 177 178 SharedClipboardPayloadFree(pPayload); 179 } 180 181 SharedClipboardEventUnregister(&pTransfer->Events, uEvent); 182 } 198 183 } 199 184 else 200 185 AssertFailedStmt(rc = VERR_NOT_SUPPORTED); 186 187 if (RT_FAILURE(rc)) 188 LogRel(("Shared Clipboard: Starting transfer failed, rc=%Rrc\n", rc)); 201 189 202 190 LogFlowFunc(("LEAVE: idTransfer=%RU16, rc=%Rrc\n", SharedClipboardTransferGetID(pTransfer), rc)); … … 651 639 } 652 640 653 #if 0654 641 case SHCL_WIN_WM_TRANSFER_START: 655 642 { 656 643 LogFunc(("SHCL_WIN_WM_TRANSFER_START\n")); 657 644 658 PSHCLTRANSFER pTransfer = (PSHCLTRANSFER)lParam;645 PSHCLTRANSFER pTransfer = (PSHCLTRANSFER)wParam; 659 646 AssertPtr(pTransfer); 660 647 648 const SHCLEVENTID uEvent = (SHCLEVENTID)lParam; 649 661 650 Assert(SharedClipboardTransferGetSource(pTransfer) == SHCLSOURCE_REMOTE); /* Sanity. */ 662 651 663 int rc2 = SharedClipboardWinTransferCreate(pWinCtx, pTransfer); 664 AssertRC(rc2); 665 break; 666 } 667 #endif 652 int rcTransfer = SharedClipboardWinTransferCreate(pWinCtx, pTransfer); 653 654 PSHCLEVENTPAYLOAD pPayload = NULL; 655 int rc = SharedClipboardPayloadAlloc(uEvent, &rcTransfer, sizeof(rcTransfer), &pPayload); 656 if (RT_SUCCESS(rc)) 657 { 658 rc = SharedClipboardEventSignal(&pTransfer->Events, uEvent, pPayload); 659 if (RT_FAILURE(rc)) 660 SharedClipboardPayloadFree(pPayload); 661 } 662 663 break; 664 } 668 665 669 666 case WM_DESTROY:
Note:
See TracChangeset
for help on using the changeset viewer.