Changeset 78974 in vbox for trunk/src/VBox/GuestHost
- Timestamp:
- Jun 4, 2019 4:51:48 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 131100
- Location:
- trunk/src/VBox/GuestHost/SharedClipboard
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/VBox/GuestHost/SharedClipboard/ClipboardDataObjectImpl-win.cpp ¶
r78897 r78974 45 45 #define VBOX_CLIPBOARD_WITH_UNICODE_SUPPORT 1 46 46 47 VBoxClipboardWinDataObject::VBoxClipboardWinDataObject( SharedClipboardProvider *pProvider,47 VBoxClipboardWinDataObject::VBoxClipboardWinDataObject(PSHAREDCLIPBOARDURITRANSFER pTransfer, 48 48 LPFORMATETC pFormatEtc, LPSTGMEDIUM pStgMed, ULONG cFormats) 49 49 : m_enmStatus(Uninitialized) 50 50 , m_lRefCount(0) 51 51 , m_cFormats(0) 52 , m_p Provider(pProvider)52 , m_pTransfer(pTransfer) 53 53 , m_pStream(NULL) 54 54 , m_uObjIdx(0) 55 55 { 56 AssertPtr( pProvider);56 AssertPtr(m_pTransfer); 57 57 58 58 HRESULT hr; … … 121 121 m_enmStatus = Initialized; 122 122 123 m_pProvider->AddRef(); 123 AssertPtr(m_pTransfer->pProvider); 124 m_pTransfer->pProvider->AddRef(); 124 125 } 125 126 … … 129 130 VBoxClipboardWinDataObject::~VBoxClipboardWinDataObject(void) 130 131 { 131 if (m_p Provider)132 m_p Provider->Release();132 if (m_pTransfer->pProvider) 133 m_pTransfer->pProvider->Release(); 133 134 134 135 if (m_pStream) … … 394 395 LogFlowFunc(("FormatIndex_FileDescriptor%s\n", fUnicode ? "W" : "A")); 395 396 396 int rc = m_p Provider->ReadMetaData(); /** @todo Do this asynchronously some time earlier? */397 int rc = m_pTransfer->pProvider->ReadMetaData(); /** @todo Do this asynchronously some time earlier? */ 397 398 if ( RT_SUCCESS(rc) 398 && !m_p Provider->GetURIList().IsEmpty())399 && !m_pTransfer->pProvider->GetURIList().IsEmpty()) 399 400 { 400 401 HGLOBAL hGlobal; 401 rc = createFileGroupDescriptorFromURIList(m_p Provider->GetURIList(), fUnicode, &hGlobal);402 rc = createFileGroupDescriptorFromURIList(m_pTransfer->pProvider->GetURIList(), fUnicode, &hGlobal); 402 403 if (RT_SUCCESS(rc)) 403 404 { … … 416 417 LogFlowFunc(("FormatIndex_FileContents: m_uObjIdx=%u\n", m_uObjIdx)); 417 418 418 SharedClipboardURIObject *pURIObj = m_p Provider->GetURIList().At(m_uObjIdx);419 SharedClipboardURIObject *pURIObj = m_pTransfer->pProvider->GetURIList().At(m_uObjIdx); 419 420 if (pURIObj) 420 421 { 421 422 /* Hand-in the provider so that our IStream implementation can continue working with it. */ 422 hr = VBoxClipboardWinStreamImpl::Create( m_pProvider, pURIObj, &m_pStream);423 hr = VBoxClipboardWinStreamImpl::Create(this /* pParent */, m_pTransfer, pURIObj, &m_pStream); 423 424 if (SUCCEEDED(hr)) 424 425 { … … 578 579 LogFlowFuncLeaveRC(VINF_SUCCESS); 579 580 return VINF_SUCCESS; 581 } 582 583 void VBoxClipboardWinDataObject::OnTransferComplete(int rc /* = VINF_SUCESS */) 584 { 585 RT_NOREF(rc); 586 587 LogFlowFuncLeaveRC(rc); 588 } 589 590 void VBoxClipboardWinDataObject::OnTransferCanceled(void) 591 { 592 LogFlowFuncLeave(); 580 593 } 581 594 -
TabularUnified trunk/src/VBox/GuestHost/SharedClipboard/ClipboardProvider-HostService.cpp ¶
r78942 r78974 43 43 } 44 44 45 int SharedClipboardProviderHostService::ReadMetaData(uint32_t fFlags /* = 0 */)46 {47 RT_NOREF(fFlags);48 return VERR_NOT_IMPLEMENTED;49 }50 51 int SharedClipboardProviderHostService::WriteMetaData(const void *pvBuf, size_t cbBuf, size_t *pcbWritten, uint32_t fFlags /* = 0 */)52 {53 RT_NOREF(pvBuf, cbBuf, pcbWritten, fFlags);54 return VERR_NOT_IMPLEMENTED;55 }56 57 int SharedClipboardProviderVbglR3::ReadDirectory(PVBOXCLIPBOARDDIRDATA pDirData)58 {59 RT_NOREF(pDirData);60 61 LogFlowFuncEnter();62 63 int rc = VERR_NOT_IMPLEMENTED;64 65 LogFlowFuncLeaveRC(rc);66 return rc;67 }68 69 int SharedClipboardProviderVbglR3::WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData)70 {71 RT_NOREF(pDirData);72 73 LogFlowFuncEnter();74 75 int rc = VERR_NOT_IMPLEMENTED;76 77 LogFlowFuncLeaveRC(rc);78 return rc;79 }80 81 int SharedClipboardProviderVbglR3::ReadFileHdr(PVBOXCLIPBOARDFILEHDR pFileHdr)82 {83 RT_NOREF(pFileHdr);84 85 LogFlowFuncEnter();86 87 int rc = VERR_NOT_IMPLEMENTED;88 89 LogFlowFuncLeaveRC(rc);90 return rc;91 }92 93 int SharedClipboardProviderVbglR3::WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr)94 {95 RT_NOREF(pFileHdr);96 97 LogFlowFuncEnter();98 99 int rc = VERR_NOT_IMPLEMENTED;100 101 LogFlowFuncLeaveRC(rc);102 return rc;103 }104 105 int SharedClipboardProviderVbglR3::ReadFileData(PVBOXCLIPBOARDFILEDATA pFileData)106 {107 RT_NOREF(pFileData);108 109 LogFlowFuncEnter();110 111 int rc = VERR_NOT_IMPLEMENTED;112 113 LogFlowFuncLeaveRC(rc);114 return rc;115 }116 117 int SharedClipboardProviderVbglR3::WriteFileData(const PVBOXCLIPBOARDFILEDATA pFileData)118 {119 RT_NOREF(pFileData);120 121 LogFlowFuncEnter();122 123 int rc = VERR_NOT_IMPLEMENTED;124 125 LogFlowFuncLeaveRC(rc);126 return rc;127 }128 129 void SharedClipboardProviderHostService::Reset(void)130 {131 }132 -
TabularUnified trunk/src/VBox/GuestHost/SharedClipboard/ClipboardProvider-VbglR3.cpp ¶
r78942 r78974 163 163 } 164 164 165 int SharedClipboardProviderVbglR3::ReadFileData(PVBOXCLIPBOARDFILEDATA pFileData) 166 { 167 LogFlowFuncEnter(); 168 169 int rc; 170 171 SharedClipboardURIObject *pObj = m_URIList.First(); 172 if (pObj) 173 { 174 rc = VbglR3ClipboardReadFileData(m_uClientID, pFileData->pvData, pFileData->cbData, &pFileData->cbData); 175 } 176 else 177 rc = VERR_WRONG_ORDER; 178 179 LogFlowFuncLeaveRC(rc); 180 return rc; 181 } 182 183 int SharedClipboardProviderVbglR3::WriteFileData(const PVBOXCLIPBOARDFILEDATA pFileData) 184 { 185 LogFlowFuncEnter(); 186 187 int rc; 188 189 SharedClipboardURIObject *pObj = m_URIList.First(); 190 if (pObj) 191 { 192 uint32_t cbWrittenIgnored; 193 rc = VbglR3ClipboardWriteFileData(m_uClientID, pFileData->pvData, pFileData->cbData, &cbWrittenIgnored); 165 int SharedClipboardProviderVbglR3::ReadFileData(PVBOXCLIPBOARDFILEDATA pFileData, uint32_t *pcbRead) 166 { 167 AssertPtrReturn(pcbRead, VERR_INVALID_POINTER); 168 169 LogFlowFuncEnter(); 170 171 int rc; 172 173 SharedClipboardURIObject *pObj = m_URIList.First(); 174 if (pObj) 175 { 176 rc = VbglR3ClipboardReadFileData(m_uClientID, pFileData->pvData, pFileData->cbData, pcbRead); 177 } 178 else 179 rc = VERR_WRONG_ORDER; 180 181 LogFlowFuncLeaveRC(rc); 182 return rc; 183 } 184 185 int SharedClipboardProviderVbglR3::WriteFileData(const PVBOXCLIPBOARDFILEDATA pFileData, uint32_t *pcbWritten) 186 { 187 AssertPtrReturn(pcbWritten, VERR_INVALID_POINTER); 188 189 LogFlowFuncEnter(); 190 191 int rc; 192 193 SharedClipboardURIObject *pObj = m_URIList.First(); 194 if (pObj) 195 { 196 rc = VbglR3ClipboardWriteFileData(m_uClientID, pFileData->pvData, pFileData->cbData, pcbWritten); 194 197 } 195 198 else -
TabularUnified trunk/src/VBox/GuestHost/SharedClipboard/ClipboardProvider.cpp ¶
r78897 r78974 71 71 #ifdef VBOX_WITH_SHARED_CLIPBOARD_HOST 72 72 case SHAREDCLIPBOARDPROVIDERSOURCE_HOSTSERVICE: 73 pProvider = new SharedClipboardProvider HostService();73 pProvider = new SharedClipboardProvider(); 74 74 break; 75 75 #endif … … 105 105 } 106 106 107 int SharedClipboardProvider::ReadMetaData(uint32_t fFlags /* = 0 */) 108 { 109 RT_NOREF(fFlags); 110 return VERR_NOT_IMPLEMENTED; 111 } 112 113 int SharedClipboardProvider::WriteMetaData(const void *pvBuf, size_t cbBuf, size_t *pcbWritten, uint32_t fFlags /* = 0 */) 114 { 115 RT_NOREF(pvBuf, cbBuf, pcbWritten, fFlags); 116 return VERR_NOT_IMPLEMENTED; 117 } 118 119 /* 120 * Stubs. 121 */ 122 123 int SharedClipboardProvider::ReadDirectory(PVBOXCLIPBOARDDIRDATA pDirData) 124 { 125 RT_NOREF(pDirData); 126 127 LogFlowFuncEnter(); 128 129 int rc = VERR_NOT_IMPLEMENTED; 130 131 LogFlowFuncLeaveRC(rc); 132 return rc; 133 } 134 135 int SharedClipboardProvider::ReadDirectoryObj(SharedClipboardURIObject &Obj) 136 { 137 RT_NOREF(Obj); 138 139 LogFlowFuncEnter(); 140 141 int rc = VERR_NOT_IMPLEMENTED; 142 143 LogFlowFuncLeaveRC(rc); 144 return rc; 145 } 146 147 int SharedClipboardProvider::WriteDirectory(const PVBOXCLIPBOARDDIRDATA pDirData) 148 { 149 RT_NOREF(pDirData); 150 151 LogFlowFuncEnter(); 152 153 int rc = VERR_NOT_IMPLEMENTED; 154 155 LogFlowFuncLeaveRC(rc); 156 return rc; 157 } 158 159 int SharedClipboardProvider::WriteDirectoryObj(const SharedClipboardURIObject &Obj) 160 { 161 RT_NOREF(Obj); 162 163 LogFlowFuncEnter(); 164 165 int rc = VERR_NOT_IMPLEMENTED; 166 167 LogFlowFuncLeaveRC(rc); 168 return rc; 169 } 170 171 int SharedClipboardProvider::ReadFileHdr(PVBOXCLIPBOARDFILEHDR pFileHdr) 172 { 173 RT_NOREF(pFileHdr); 174 175 LogFlowFuncEnter(); 176 177 int rc = VERR_NOT_IMPLEMENTED; 178 179 LogFlowFuncLeaveRC(rc); 180 return rc; 181 } 182 183 int SharedClipboardProvider::ReadFileHdrObj(SharedClipboardURIObject &Obj) 184 { 185 RT_NOREF(Obj); 186 187 LogFlowFuncEnter(); 188 189 int rc = VERR_NOT_IMPLEMENTED; 190 191 LogFlowFuncLeaveRC(rc); 192 return rc; 193 } 194 195 int SharedClipboardProvider::WriteFileHdr(const PVBOXCLIPBOARDFILEHDR pFileHdr) 196 { 197 RT_NOREF(pFileHdr); 198 199 LogFlowFuncEnter(); 200 201 int rc = VERR_NOT_IMPLEMENTED; 202 203 LogFlowFuncLeaveRC(rc); 204 return rc; 205 } 206 207 int SharedClipboardProvider::WriteFileHdrObj(const SharedClipboardURIObject &Obj) 208 { 209 RT_NOREF(Obj); 210 211 LogFlowFuncEnter(); 212 213 int rc = VERR_NOT_IMPLEMENTED; 214 215 LogFlowFuncLeaveRC(rc); 216 return rc; 217 } 218 219 int SharedClipboardProvider::ReadFileDataObj(SharedClipboardURIObject &Obj, uint32_t *pcbRead) 220 { 221 RT_NOREF(Obj, pcbRead); 222 223 LogFlowFuncEnter(); 224 225 int rc = VERR_NOT_IMPLEMENTED; 226 227 LogFlowFuncLeaveRC(rc); 228 return rc; 229 } 230 231 int SharedClipboardProvider::ReadFileData(PVBOXCLIPBOARDFILEDATA pFileData, uint32_t *pcbRead) 232 { 233 RT_NOREF(pFileData, pcbRead); 234 235 LogFlowFuncEnter(); 236 237 int rc = VERR_NOT_IMPLEMENTED; 238 239 LogFlowFuncLeaveRC(rc); 240 return rc; 241 } 242 243 int SharedClipboardProvider::WriteFileDataObj(const SharedClipboardURIObject &Obj, uint32_t *pcbWritten) 244 { 245 RT_NOREF(Obj, pcbWritten); 246 247 LogFlowFuncEnter(); 248 249 int rc = VERR_NOT_IMPLEMENTED; 250 251 LogFlowFuncLeaveRC(rc); 252 return rc; 253 } 254 255 int SharedClipboardProvider::WriteFileData(const PVBOXCLIPBOARDFILEDATA pFileData, uint32_t *pcbWritten) 256 { 257 RT_NOREF(pFileData, pcbWritten); 258 259 LogFlowFuncEnter(); 260 261 int rc = VERR_NOT_IMPLEMENTED; 262 263 LogFlowFuncLeaveRC(rc); 264 return rc; 265 } 266 267 void SharedClipboardProvider::Reset(void) 268 { 269 } 270 -
TabularUnified trunk/src/VBox/GuestHost/SharedClipboard/ClipboardStreamImpl-win.cpp ¶
r78897 r78974 46 46 47 47 48 VBoxClipboardWinStreamImpl::VBoxClipboardWinStreamImpl(SharedClipboardProvider *pProvider, SharedClipboardURIObject *pURIObj) 49 : m_lRefCount(1) 50 , m_pProvider(pProvider) 48 VBoxClipboardWinStreamImpl::VBoxClipboardWinStreamImpl(VBoxClipboardWinDataObject *pParent, 49 PSHAREDCLIPBOARDURITRANSFER pTransfer, SharedClipboardURIObject *pURIObj) 50 : m_pParent(pParent) 51 , m_lRefCount(1) 52 , m_pTransfer(pTransfer) 51 53 , m_pURIObj(pURIObj) 52 54 { 53 AssertPtr(m_pProvider); 55 AssertPtr(m_pTransfer); 56 AssertPtr(m_pTransfer->pProvider); 54 57 AssertPtr(m_pURIObj); 55 58 56 59 LogFunc(("szSrcPath=%s, cbSize=%RU64\n", m_pURIObj->GetSourcePathAbs().c_str(), m_pURIObj->GetSize())); 57 60 58 m_p Provider->AddRef();61 m_pTransfer->pProvider->AddRef(); 59 62 } 60 63 … … 62 65 { 63 66 LogFlowThisFuncEnter(); 64 m_pProvider->Release(); 67 68 if ( m_pTransfer 69 && m_pTransfer->pProvider) 70 m_pTransfer->pProvider->Release(); 65 71 } 66 72 … … 159 165 const uint64_t cbProcessed = m_pURIObj->GetProcessed(); 160 166 161 const size_t cbToRead = RT_MIN(cbSize - cbProcessed, nBytesToRead);162 size_t cbRead = 0;167 const uint32_t cbToRead = RT_MIN(cbSize - cbProcessed, nBytesToRead); 168 uint32_t cbRead = 0; 163 169 164 170 int rc = VINF_SUCCESS; 165 171 166 172 if (cbToRead) 167 rc = m_pProvider->ReadData(pvBuffer, cbToRead, &cbRead); 173 { 174 VBOXCLIPBOARDFILEDATA FileData; 175 RT_ZERO(FileData); 176 177 FileData.pvData = pvBuffer; 178 FileData.cbData = cbToRead; 179 180 rc = m_pTransfer->pProvider->ReadFileData(&FileData, &cbRead); 181 if (RT_SUCCESS(rc)) 182 { 183 if (m_pURIObj->IsComplete()) 184 m_pParent->OnTransferComplete(); 185 } 186 } 168 187 169 188 if (nBytesRead) … … 229 248 * 230 249 * @returns HRESULT 231 * @param pProvider Pointer to Shared Clipboard provider to use. 250 * @param pParent Pointer to the parent data object. 251 * @param pTransfer Pointer to URI transfer object to use. 232 252 * @param pURIObj Pointer to URI object to handle. 233 253 * @param ppStream Where to return the created stream object on success. 234 254 */ 235 255 /* static */ 236 HRESULT VBoxClipboardWinStreamImpl::Create(SharedClipboardProvider *pProvider, SharedClipboardURIObject *pURIObj, 256 HRESULT VBoxClipboardWinStreamImpl::Create(VBoxClipboardWinDataObject *pParent, 257 PSHAREDCLIPBOARDURITRANSFER pTransfer, SharedClipboardURIObject *pURIObj, 237 258 IStream **ppStream) 238 259 { 239 AssertPtrReturn(p Provider, E_POINTER);240 241 VBoxClipboardWinStreamImpl *pStream = new VBoxClipboardWinStreamImpl(pP rovider, pURIObj);260 AssertPtrReturn(pTransfer, E_POINTER); 261 262 VBoxClipboardWinStreamImpl *pStream = new VBoxClipboardWinStreamImpl(pParent, pTransfer, pURIObj); 242 263 if (pStream) 243 264 { -
TabularUnified trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp ¶
r78161 r78974 21 21 #include <iprt/assert.h> 22 22 #include <iprt/errcore.h> 23 23 24 #include <VBox/log.h> 24 25 #include <VBox/GuestHost/clipboard-helper.h> 26 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 27 # include <VBox/GuestHost/SharedClipboard-uri.h> 28 #endif 29 25 30 26 31 /** @todo use const where appropriate; delinuxify the code (*Lin* -> *Host*); use AssertLogRel*. */ … … 307 312 pFileHeader = (PBMFILEHEADER)pvDest; 308 313 pFileHeader->u16Type = BITMAPHEADERMAGIC; 309 pFileHeader->u32Size = RT_H2LE_U32(cb);314 pFileHeader->u32Size = (uint32_t)RT_H2LE_U32(cb); 310 315 pFileHeader->u16Reserved1 = pFileHeader->u16Reserved2 = 0; 311 pFileHeader->u32OffBits = RT_H2LE_U32(offPixel);316 pFileHeader->u32OffBits = (uint32_t)RT_H2LE_U32(offPixel); 312 317 memcpy((uint8_t *)pvDest + sizeof(BMFILEHEADER), pvSrc, cbSrc); 313 318 *ppvDest = pvDest; … … 336 341 } 337 342 343 #ifdef VBOX_WITH_SHARED_CLIPBOARD_URI_LIST 344 /** 345 * Initializes an URI clipboard transfer struct. 346 * 347 * @returns VBox status code. 348 * @param pCtx Shared Clipboard provider creation context to use. 349 * @param ppTransfer Where to return the created URI transfer struct. 350 * Must be free'd by SharedClipboardURITransferDestroy(). 351 */ 352 int SharedClipboardURITransferCreate(PSHAREDCLIPBOARDPROVIDERCREATIONCTX pCtx, 353 PSHAREDCLIPBOARDURITRANSFER *ppTransfer) 354 { 355 AssertPtrReturn(pCtx, VERR_INVALID_POINTER); 356 AssertPtrReturn(ppTransfer, VERR_INVALID_POINTER); 357 358 PSHAREDCLIPBOARDURITRANSFER pTransfer = (PSHAREDCLIPBOARDURITRANSFER)RTMemAlloc(sizeof(SHAREDCLIPBOARDURITRANSFER)); 359 if (!pTransfer) 360 return VERR_NO_MEMORY; 361 362 LogFlowFuncEnter(); 363 364 pTransfer->pProvider = SharedClipboardProvider::Create(pCtx); 365 if (!pTransfer->pProvider) 366 return VERR_NO_MEMORY; 367 368 pTransfer->Thread.fCancelled = false; 369 pTransfer->Thread.fStarted = false; 370 371 pTransfer->pvUser = NULL; 372 pTransfer->cbUser = 0; 373 374 *ppTransfer = pTransfer; 375 376 return VINF_SUCCESS; 377 } 378 379 /** 380 * Destroys an URI clipboard transfer context struct. 381 * 382 * @param pURI URI clipboard transfer struct to destroy. 383 */ 384 void SharedClipboardURITransferDestroy(PSHAREDCLIPBOARDURITRANSFER pTransfer) 385 { 386 if (!pTransfer) 387 return; 388 389 LogFlowFuncEnter(); 390 391 if (pTransfer->pProvider) 392 { 393 delete pTransfer->pProvider; 394 pTransfer->pProvider = NULL; 395 } 396 397 RTMemFree(pTransfer); 398 pTransfer = NULL; 399 } 400 401 /** 402 * Resets an URI clipboard context struct. 403 * 404 * @param pTransfer URI clipboard transfer struct to reset. 405 */ 406 void SharedClipboardURITransferReset(PSHAREDCLIPBOARDURITRANSFER pTransfer) 407 { 408 AssertPtrReturnVoid(pTransfer); 409 410 LogFlowFuncEnter(); 411 412 if (pTransfer->pProvider) 413 pTransfer->pProvider->Reset(); 414 } 415 416 /** 417 * Writes all URI objects using the connected provider. 418 * 419 * @returns VBox status code. 420 * @param pTransfer Transfer to write objects for. 421 */ 422 int SharedClipboardURITransferWrite(PSHAREDCLIPBOARDURITRANSFER pTransfer) 423 { 424 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 425 426 LogFlowFuncEnter(); 427 428 int rc = VINF_SUCCESS; 429 430 SharedClipboardURIList &lstURI = pTransfer->pProvider->GetURIList(); 431 432 while (!lstURI.IsEmpty()) 433 { 434 SharedClipboardURIObject *pObj = lstURI.First(); 435 AssertPtrBreakStmt(pObj, rc = VERR_INVALID_POINTER); 436 437 switch (pObj->GetType()) 438 { 439 case SharedClipboardURIObject::Type_Directory: 440 { 441 rc = pTransfer->pProvider->WriteDirectoryObj(*pObj); 442 break; 443 } 444 445 case SharedClipboardURIObject::Type_File: 446 { 447 rc = pTransfer->pProvider->WriteFileHdrObj(*pObj); 448 if (RT_FAILURE(rc)) 449 break; 450 451 while (!pObj->IsComplete()) 452 { 453 uint32_t cbWritten; 454 rc = pTransfer->pProvider->WriteFileDataObj(*pObj, &cbWritten); 455 if (RT_FAILURE(rc)) 456 break; 457 } 458 break; 459 } 460 461 default: 462 AssertFailed(); 463 break; 464 } 465 466 if (RT_FAILURE(rc)) 467 break; 468 469 /* Only remove current object on success. */ 470 lstURI.RemoveFirst(); 471 } 472 473 LogFlowFuncLeaveRC(rc); 474 return rc; 475 } 476 477 /** 478 * Thread for transferring (writing) URI objects from source to the target. 479 * For target to source transfers we utilize our own IDataObject / IStream implementations. 480 * 481 * @returns VBox status code. 482 * @param hThread Thread handle. 483 * @param pvUser User arguments; is PSHAREDCLIPBOARDURICTX. 484 */ 485 int SharedClipboardURITransferWriteThread(RTTHREAD hThread, void *pvUser) 486 { 487 AssertPtrReturn(pvUser, VERR_INVALID_POINTER); 488 489 LogFlowFuncEnter(); 490 491 PSHAREDCLIPBOARDURICTX pURICtx = (PSHAREDCLIPBOARDURICTX)pvUser; 492 AssertPtr(pURICtx); 493 494 /* At the moment we only support one transfer at a time. */ 495 PSHAREDCLIPBOARDURITRANSFER pTransfer = SharedClipboardURICtxGetTransfer(pURICtx, 0 /* Index*/); 496 AssertPtr(pTransfer->pProvider); 497 498 int rc = VINF_SUCCESS; 499 500 if (RT_SUCCESS(rc)) 501 pTransfer->Thread.fStarted = true; 502 503 int rc2 = RTThreadUserSignal(hThread); 504 const bool fSignalled = RT_SUCCESS(rc2); 505 506 if (RT_SUCCESS(rc)) 507 rc = SharedClipboardURITransferWrite(pTransfer); 508 509 if (!fSignalled) 510 { 511 rc2 = RTThreadUserSignal(hThread); 512 AssertRC(rc2); 513 } 514 515 LogFlowFuncLeaveRC(rc); 516 return rc; 517 } 518 519 /** 520 * Initializes an URI clipboard context struct. 521 * 522 * @returns VBox status code. 523 * @param pURI URI clipboard context to initialize. 524 * @param pTransfer Pointer to URI clipboard transfer struct to use. 525 */ 526 int SharedClipboardURICtxInit(PSHAREDCLIPBOARDURICTX pURI, PSHAREDCLIPBOARDURITRANSFER pTransfer) 527 { 528 AssertPtrReturn(pURI, VERR_INVALID_POINTER); 529 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 530 531 LogFlowFuncEnter(); 532 533 int rc = RTCritSectInit(&pURI->CritSect); 534 if (RT_SUCCESS(rc)) 535 { 536 RTListInit(&pURI->List); 537 538 SharedClipboardURICtxReset(pURI); 539 } 540 541 return VINF_SUCCESS; 542 } 543 544 /** 545 * Destroys an URI clipboard information context struct. 546 * 547 * @param pURI URI clipboard context to destroy. 548 */ 549 void SharedClipboardURICtxDestroy(PSHAREDCLIPBOARDURICTX pURI) 550 { 551 AssertPtrReturnVoid(pURI); 552 553 RTCritSectDelete(&pURI->CritSect); 554 555 PSHAREDCLIPBOARDURITRANSFER pTransfer, pTransferNext; 556 RTListForEachSafe(&pURI->List, pTransfer, pTransferNext, SHAREDCLIPBOARDURITRANSFER, Node) 557 { 558 SharedClipboardURITransferDestroy(pTransfer); 559 RTListNodeRemove(&pTransfer->Node); 560 } 561 562 LogFlowFuncEnter(); 563 } 564 565 /** 566 * Resets an URI clipboard context struct. 567 * 568 * @param pURI URI clipboard context to reset. 569 */ 570 void SharedClipboardURICtxReset(PSHAREDCLIPBOARDURICTX pURI) 571 { 572 AssertPtrReturnVoid(pURI); 573 574 LogFlowFuncEnter(); 575 576 pURI->cTransfers = 0; 577 578 PSHAREDCLIPBOARDURITRANSFER pTransfer; 579 RTListForEach(&pURI->List, pTransfer, SHAREDCLIPBOARDURITRANSFER, Node) 580 SharedClipboardURITransferReset(pTransfer); 581 } 582 583 /** 584 * Adds a new transfer to an URI clipboard context struct. 585 * 586 * @returns VBox status code. 587 * @param pURI URI clipboard context to add transfer to. 588 * @param pTransfer Pointer to URI clipboard transfer struct to add. 589 */ 590 int SharedClipboardURICtxTransferAdd(PSHAREDCLIPBOARDURICTX pURI, PSHAREDCLIPBOARDURITRANSFER pTransfer) 591 { 592 AssertPtrReturn(pURI, VERR_INVALID_POINTER); 593 AssertPtrReturn(pTransfer, VERR_INVALID_POINTER); 594 595 LogFlowFuncEnter(); 596 597 RTListAppend(&pURI->List, &pTransfer->Node); 598 599 return VINF_SUCCESS; 600 } 601 602 /** 603 * Returns a specific URI transfer. 604 * 605 * @returns URI transfer, or NULL if not found. 606 * @param pURI URI clipboard context to return transfer for. 607 * @param uIdx Index of the transfer to return. 608 */ 609 PSHAREDCLIPBOARDURITRANSFER SharedClipboardURICtxGetTransfer(PSHAREDCLIPBOARDURICTX pURI, uint32_t uIdx) 610 { 611 AssertReturn(uIdx == 0, NULL); /* Only one transfer allowed at the moment. */ 612 return RTListGetFirst(&pURI->List, SHAREDCLIPBOARDURITRANSFER, Node); 613 } 614 615 /** 616 * Returns the number of active URI transfers. 617 * 618 * @returns VBox status code. 619 * @param pURI URI clipboard context to return number for. 620 */ 621 uint32_t SharedClipboardURICtxGetActiveTransfers(PSHAREDCLIPBOARDURICTX pURI) 622 { 623 return pURI->cTransfers; 624 } 625 #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */ 626 -
TabularUnified trunk/src/VBox/GuestHost/SharedClipboard/clipboard-win.cpp ¶
r78897 r78974 743 743 return rc; 744 744 } 745 746 /**747 * Initializes a Windows-specific URI clipboard information struct.748 *749 * @returns VBox status code.750 * @param pURI URI clipboard information struct to initialize.751 * @param pCtx Shared Clipboard provider creation context to use.752 */753 int VBoxClipboardWinURIInit(PVBOXCLIPBOARDWINURI pURI, PSHAREDCLIPBOARDPROVIDERCREATIONCTX pCtx)754 {755 AssertPtrReturn(pURI, VERR_INVALID_POINTER);756 AssertPtrReturn(pCtx, VERR_INVALID_POINTER);757 758 LogFlowFuncEnter();759 760 pURI->Transfer.pProvider = SharedClipboardProvider::Create(pCtx);761 if (!pURI->Transfer.pProvider)762 return VERR_NO_MEMORY;763 764 VBoxClipboardWinURIReset(pURI);765 766 return VINF_SUCCESS;767 }768 769 /**770 * Destroys a Windows-specific URI clipboard information struct.771 *772 * @param pURI URI clipboard information struct to destroy.773 */774 void VBoxClipboardWinURIDestroy(PVBOXCLIPBOARDWINURI pURI)775 {776 AssertPtrReturnVoid(pURI);777 778 LogFlowFuncEnter();779 780 if (pURI->Transfer.pProvider)781 {782 delete pURI->Transfer.pProvider;783 pURI->Transfer.pProvider = NULL;784 }785 }786 787 /**788 * Resets a Windows-specific URI clipboard information struct.789 *790 * @param pURI URI clipboard information struct to reset.791 */792 void VBoxClipboardWinURIReset(PVBOXCLIPBOARDWINURI pURI)793 {794 AssertPtrReturnVoid(pURI);795 796 LogFlowFuncEnter();797 798 pURI->cTransfers = 0;799 800 if (pURI->Transfer.pProvider)801 pURI->Transfer.pProvider->Reset();802 }803 745 #endif /* VBOX_WITH_SHARED_CLIPBOARD_URI_LIST */ 804 746
Note:
See TracChangeset
for help on using the changeset viewer.