Changeset 82502 in vbox for trunk/src/VBox
- Timestamp:
- Dec 8, 2019 11:54:49 PM (5 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/Makefile.kmk
r81964 r82502 1033 1033 src-client/GuestDnDTargetImpl.cpp 1034 1034 endif 1035 ifdef VBOX_WITH_SHARED_CLIPBOARD1036 VBoxC_SOURCES += \1037 src-client/SharedClipboardPrivate.cpp1038 endif1039 1035 ifdef VBOX_WITH_XPCOM 1040 1036 VBoxC_SOURCES += \ -
trunk/src/VBox/Main/include/ConsoleImpl.h
r81964 r82502 884 884 #endif 885 885 886 #ifdef VBOX_WITH_SHARED_CLIPBOARD887 /** @name Shared Clipboard support888 * @{ */889 static DECLCALLBACK(int) i_sharedClipboardServiceCallback(void *pvExtension, uint32_t u32Function,890 void *pvParms, uint32_t cbParms);891 /** @} */892 #endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */893 894 886 /** @name Disk encryption support 895 887 * @{ */ … … 1065 1057 Bstr mstrUuid; 1066 1058 1067 #ifdef VBOX_WITH_SHARED_CLIPBOARD1068 HGCMSVCEXTHANDLE m_hHgcmSvcExtShrdClipboard;1069 #endif1070 1059 #ifdef VBOX_WITH_DRAG_AND_DROP 1071 1060 HGCMSVCEXTHANDLE m_hHgcmSvcExtDragAndDrop; -
trunk/src/VBox/Main/include/ConsoleVRDPServer.h
r80376 r82502 139 139 void SendAudioVolume (uint16_t left, uint16_t right) const; 140 140 void SendUSBRequest (uint32_t u32ClientId, void *pvParms, uint32_t cbParms) const; 141 void SendClipboard (uint32_t u32Function, uint32_t u32Format,142 void *pvData, uint32_t cbData, uint32_t *pcbActualRead) const;143 141 144 142 void QueryInfo (uint32_t index, void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut) const; … … 222 220 223 221 int mcClipboardRefs; 222 HGCMSVCEXTHANDLE mhClipboard; 224 223 PFNVRDPCLIPBOARDEXTCALLBACK mpfnClipboardCallback; 225 224 226 225 static DECLCALLBACK(int) ClipboardCallback (void *pvCallback, uint32_t u32ClientId, uint32_t u32Function, uint32_t u32Format, const void *pvData, uint32_t cbData); 226 static DECLCALLBACK(int) ClipboardServiceExtension(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms); 227 227 228 228 #ifdef VBOX_WITH_USB -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r81682 r82502 125 125 126 126 #ifdef VBOX_WITH_SHARED_CLIPBOARD 127 #include <VBox/HostServices/VBoxClipboardSvc.h> 128 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 129 # include "SharedClipboardPrivate.h" 130 # endif 127 # include <VBox/HostServices/VBoxClipboardSvc.h> 131 128 #endif 132 129 #include <VBox/HostServices/DragAndDropSvc.h> … … 8248 8245 alock.release(); 8249 8246 8250 # ifdef VBOX_WITH_SHARED_CLIPBOARD 8251 if (m_hHgcmSvcExtShrdClipboard) 8252 { 8253 HGCMHostUnregisterServiceExtension(m_hHgcmSvcExtShrdClipboard); 8254 m_hHgcmSvcExtShrdClipboard = NULL; 8255 } 8247 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 8248 /** @todo Deregister area callbacks? */ 8256 8249 # endif 8257 8250 # ifdef VBOX_WITH_DRAG_AND_DROP … … 8420 8413 return rc; 8421 8414 } 8422 8423 #ifdef VBOX_WITH_SHARED_CLIPBOARD8424 /* static */8425 DECLCALLBACK(int) Console::i_sharedClipboardServiceCallback(void *pvExtension, uint32_t u32Function,8426 void *pvParms, uint32_t cbParms)8427 {8428 LogFlowFunc(("pvExtension=%p, u32Function=%RU32, pvParms=%p, cbParms=%RU32\n",8429 pvExtension, u32Function, pvParms, cbParms));8430 8431 RT_NOREF(pvParms, cbParms);8432 8433 Console *pThis = reinterpret_cast<Console *>(pvExtension);8434 AssertPtrReturn(pThis, VERR_INVALID_POINTER);8435 8436 ComPtr<IInternalMachineControl> pControl = pThis->mControl;8437 8438 int rc = VINF_SUCCESS;8439 8440 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS8441 HRESULT hrc = S_OK;8442 # endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */8443 8444 LogFunc(("mConsoleVRDPServer=%p\n", pThis->mConsoleVRDPServer));8445 8446 switch (u32Function)8447 {8448 case VBOX_CLIPBOARD_EXT_FN_SET_CALLBACK:8449 {8450 LogFlowFunc(("VBOX_CLIPBOARD_EXT_FN_SET_CALLBACK\n"));8451 } break;8452 8453 case VBOX_CLIPBOARD_EXT_FN_FORMAT_ANNOUNCE:8454 {8455 LogFlowFunc(("VBOX_CLIPBOARD_EXT_FN_FORMAT_ANNOUNCE\n"));8456 8457 SHCLEXTPARMS *pParms = (SHCLEXTPARMS *)pvParms;8458 AssertPtrBreakStmt(pParms, rc = VERR_INVALID_POINTER);8459 8460 /* The guest announces clipboard formats. This must be delivered to all clients. */8461 if (pThis->mConsoleVRDPServer)8462 pThis->mConsoleVRDPServer->SendClipboard(VRDE_CLIPBOARD_FUNCTION_FORMAT_ANNOUNCE,8463 pParms->uFormat,8464 NULL,8465 0,8466 NULL);8467 } break;8468 8469 case VBOX_CLIPBOARD_EXT_FN_DATA_READ:8470 {8471 LogFlowFunc(("VBOX_CLIPBOARD_EXT_FN_DATA_READ\n"));8472 8473 SHCLEXTPARMS *pParms = (SHCLEXTPARMS *)pvParms;8474 AssertPtrBreakStmt(pParms, rc = VERR_INVALID_POINTER);8475 8476 /* The clipboard service expects that the pvData buffer will be filled8477 * with clipboard data. The server returns the data from the client that8478 * announced the requested format most recently.8479 */8480 if (pThis->mConsoleVRDPServer)8481 pThis->mConsoleVRDPServer->SendClipboard(VRDE_CLIPBOARD_FUNCTION_DATA_READ,8482 pParms->uFormat,8483 pParms->u.pvData,8484 pParms->cbData,8485 &pParms->cbData);8486 } break;8487 8488 case VBOX_CLIPBOARD_EXT_FN_DATA_WRITE:8489 {8490 LogFlowFunc(("VBOX_CLIPBOARD_EXT_FN_DATA_WRITE\n"));8491 8492 SHCLEXTPARMS *pParms = (SHCLEXTPARMS *)pvParms;8493 AssertPtrBreakStmt(pParms, rc = VERR_INVALID_POINTER);8494 8495 if (pThis->mConsoleVRDPServer)8496 pThis->mConsoleVRDPServer->SendClipboard(VRDE_CLIPBOARD_FUNCTION_DATA_WRITE,8497 pParms->uFormat,8498 pParms->u.pvData,8499 pParms->cbData,8500 NULL);8501 } break;8502 8503 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS8504 case VBOX_CLIPBOARD_EXT_FN_AREA_REGISTER:8505 {8506 com::SafeArray<BSTR> abstrParms; /* Empty for now. */8507 ULONG uID;8508 hrc = pControl->ClipboardAreaRegister(ComSafeArrayAsInParam(abstrParms), &uID);8509 if (SUCCEEDED(hrc))8510 {8511 PSHCLEXTAREAPARMS pParms = (PSHCLEXTAREAPARMS)pvParms;8512 AssertPtrBreakStmt(pParms, rc = VERR_INVALID_POINTER);8513 8514 /* Return the registered area ID back to the caller. */8515 pParms->uID = uID;8516 }8517 else8518 LogFunc(("Registering clipboard area failed with %Rhrc\n", hrc));8519 } break;8520 8521 case VBOX_CLIPBOARD_EXT_FN_AREA_UNREGISTER:8522 {8523 PSHCLEXTAREAPARMS pParms = (PSHCLEXTAREAPARMS)pvParms;8524 AssertPtrBreakStmt(pParms, rc = VERR_INVALID_POINTER);8525 8526 hrc = pControl->ClipboardAreaUnregister(pParms->uID);8527 if (FAILED(hrc))8528 LogFunc(("Unregistering clipboard area %RU32 failed with %Rhrc\n", pParms->uID, hrc));8529 } break;8530 8531 case VBOX_CLIPBOARD_EXT_FN_AREA_ATTACH:8532 {8533 PSHCLEXTAREAPARMS pParms = (PSHCLEXTAREAPARMS)pvParms;8534 AssertPtrBreakStmt(pParms, rc = VERR_INVALID_POINTER);8535 8536 hrc = pControl->ClipboardAreaAttach(pParms->uID);8537 if (FAILED(hrc))8538 LogFunc(("Attaching to clipboard area %RU32 failed with %Rhrc\n", pParms->uID, hrc));8539 } break;8540 8541 case VBOX_CLIPBOARD_EXT_FN_AREA_DETACH:8542 {8543 PSHCLEXTAREAPARMS pParms = (PSHCLEXTAREAPARMS)pvParms;8544 AssertPtrBreakStmt(pParms, rc = VERR_INVALID_POINTER);8545 8546 hrc = pControl->ClipboardAreaDetach(pParms->uID);8547 if (FAILED(hrc))8548 LogFunc(("Detaching from clipboard area %RU32 failed with %Rhrc\n", pParms->uID, hrc));8549 } break;8550 # endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */8551 8552 default:8553 {8554 rc = VERR_NOT_SUPPORTED;8555 } break;8556 }8557 8558 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS8559 if (FAILED(hrc))8560 {8561 LogRel(("Shared Clipboard: Area handling failed with %Rhrc\n", hrc));8562 rc = VERR_GENERAL_FAILURE; /** @todo Fudge; fix this. */8563 }8564 # endif8565 8566 LogFlowFuncLeaveRC(rc);8567 return rc;8568 }8569 #endif /* VBOX_WITH_SHARED_CLIPBOARD */8570 8415 8571 8416 /** -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r82410 r82502 76 76 #ifdef VBOX_WITH_SHARED_CLIPBOARD 77 77 # include <VBox/HostServices/VBoxClipboardSvc.h> 78 # include "SharedClipboardPrivate.h"79 78 #endif 80 79 #ifdef VBOX_WITH_GUEST_PROPS … … 3062 3061 */ 3063 3062 { 3064 if (SharedClipboard::createInstance(this /* pConsole */) == NULL) 3065 { 3066 rc = VERR_NO_MEMORY; 3063 ClipboardMode_T enmClipboardMode = ClipboardMode_Disabled; 3064 hrc = pMachine->COMGETTER(ClipboardMode)(&enmClipboardMode); H(); 3065 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 3066 BOOL fFileTransfersEnabled; 3067 hrc = pMachine->COMGETTER(ClipboardFileTransfersEnabled)(&fFileTransfersEnabled); H(); 3068 #endif 3069 3070 /* Load the service */ 3071 rc = pVMMDev->hgcmLoadService("VBoxSharedClipboard", "VBoxSharedClipboard"); 3072 if (RT_SUCCESS(rc)) 3073 { 3074 LogRel(("Shared Clipboard: Service loaded\n")); 3075 3076 /* Set initial clipboard mode. */ 3077 rc = i_changeClipboardMode(enmClipboardMode); 3078 AssertLogRelMsg(RT_SUCCESS(rc), ("Shared Clipboard: Failed to set initial clipboard mode (%d): rc=%Rrc\n", 3079 enmClipboardMode, rc)); 3080 3081 /* Setup the service. */ 3082 VBOXHGCMSVCPARM parm; 3083 HGCMSvcSetU32(&parm, !i_useHostClipboard()); 3084 rc = pVMMDev->hgcmHostCall("VBoxSharedClipboard", VBOX_SHCL_HOST_FN_SET_HEADLESS, 1, &parm); 3085 AssertLogRelMsg(RT_SUCCESS(rc), ("Shared Clipboard: Failed to set initial headless mode (%RTbool): rc=%Rrc\n", 3086 !i_useHostClipboard(), rc)); 3087 3088 # ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 3089 rc = i_changeClipboardFileTransferMode(RT_BOOL(fFileTransfersEnabled)); 3090 AssertLogRelMsg(RT_SUCCESS(rc), ("Shared Clipboard: Failed to set initial file transfers mode (%u): rc=%Rrc\n", 3091 fFileTransfersEnabled, rc)); 3092 3093 /** @todo Register area callbacks? (See also deregistration todo in Console::i_powerDown.) */ 3094 # endif 3067 3095 } 3068 3096 else 3069 {3070 /* Load the service */3071 rc = pVMMDev->hgcmLoadService("VBoxSharedClipboard", "VBoxSharedClipboard");3072 if (RT_SUCCESS(rc))3073 {3074 LogRel(("Shared Clipboard: Service loaded\n"));3075 rc = HGCMHostRegisterServiceExtension(&m_hHgcmSvcExtShrdClipboard, "VBoxSharedClipboard",3076 &Console::i_sharedClipboardServiceCallback,3077 this /* pvExtension */);3078 if (RT_FAILURE(rc))3079 {3080 LogRel(("Shared Clipboard: Cannot register service extension, rc=%Rrc\n", rc));3081 }3082 else3083 {3084 /* Set initial clipboard mode. */3085 ClipboardMode_T mode = ClipboardMode_Disabled;3086 hrc = pMachine->COMGETTER(ClipboardMode)(&mode); H();3087 3088 rc = i_changeClipboardMode(mode);3089 if (RT_SUCCESS(rc))3090 {3091 /* Setup the service. */3092 VBOXHGCMSVCPARM parm;3093 HGCMSvcSetU32(&parm, !i_useHostClipboard());3094 rc = SHAREDCLIPBOARDINST()->hostCall(VBOX_SHCL_HOST_FN_SET_HEADLESS, 1, &parm);3095 if (RT_FAILURE(rc))3096 LogRel(("Shared Clipboard: Unable to set initial headless mode, rc=%Rrc\n", rc));3097 3098 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS3099 /* Setup file transfer mode. */3100 BOOL fFileTransfersEnabled;3101 hrc = pMachine->COMGETTER(ClipboardFileTransfersEnabled)(&fFileTransfersEnabled); H();3102 int rc2 = i_changeClipboardFileTransferMode(RT_BOOL(fFileTransfersEnabled));3103 if (RT_FAILURE(rc2))3104 LogRel(("Shared Clipboard: Unable to set initial file transfers mode, rc=%Rrc\n", rc2));3105 /* Note: Don't let the Shared Clipboard fail as a whole if file transfers aren't available. */3106 #endif /* VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS */3107 }3108 else3109 LogRel(("Shared Clipboard: Unable to set initial clipboard mode, rc=%Rrc\n", rc));3110 }3111 }3112 }3113 3114 if (RT_FAILURE(rc))3115 {3116 3097 LogRel(("Shared Clipboard: Not available, rc=%Rrc\n", rc)); 3117 /* That is not a fatal failure. */ 3118 rc = VINF_SUCCESS; 3119 } 3098 rc = VINF_SUCCESS; /* None of the potential failures above are fatal. */ 3120 3099 } 3121 3100 #endif /* VBOX_WITH_SHARED_CLIPBOARD */ -
trunk/src/VBox/Main/src-client/ConsoleVRDPServer.cpp
r81964 r82502 1336 1336 1337 1337 ConsoleVRDPServer::ConsoleVRDPServer(Console *console) 1338 : mhClipboard(NULL) 1338 1339 { 1339 1340 mConsole = console; … … 3320 3321 } 3321 3322 3323 /*static*/ DECLCALLBACK(int) 3324 ConsoleVRDPServer::ClipboardServiceExtension(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms) 3325 { 3326 RT_NOREF(cbParms); 3327 LogFlowFunc(("pvExtension = %p, u32Function = %d, pvParms = %p, cbParms = %d\n", 3328 pvExtension, u32Function, pvParms, cbParms)); 3329 3330 int rc = VINF_SUCCESS; 3331 3332 ConsoleVRDPServer *pServer = static_cast <ConsoleVRDPServer *>(pvExtension); 3333 3334 SHCLEXTPARMS *pParms = (SHCLEXTPARMS *)pvParms; 3335 3336 switch (u32Function) 3337 { 3338 case VBOX_CLIPBOARD_EXT_FN_SET_CALLBACK: 3339 { 3340 pServer->mpfnClipboardCallback = pParms->u.pfnCallback; 3341 } break; 3342 3343 case VBOX_CLIPBOARD_EXT_FN_FORMAT_ANNOUNCE: 3344 { 3345 /* The guest announces clipboard formats. This must be delivered to all clients. */ 3346 if (mpEntryPoints && pServer->mhServer) 3347 { 3348 mpEntryPoints->VRDEClipboard(pServer->mhServer, 3349 VRDE_CLIPBOARD_FUNCTION_FORMAT_ANNOUNCE, 3350 pParms->uFormat, 3351 NULL, 3352 0, 3353 NULL); 3354 } 3355 } break; 3356 3357 case VBOX_CLIPBOARD_EXT_FN_DATA_READ: 3358 { 3359 /* The clipboard service expects that the pvData buffer will be filled 3360 * with clipboard data. The server returns the data from the client that 3361 * announced the requested format most recently. 3362 */ 3363 if (mpEntryPoints && pServer->mhServer) 3364 { 3365 mpEntryPoints->VRDEClipboard(pServer->mhServer, 3366 VRDE_CLIPBOARD_FUNCTION_DATA_READ, 3367 pParms->uFormat, 3368 pParms->u.pvData, 3369 pParms->cbData, 3370 &pParms->cbData); 3371 } 3372 } break; 3373 3374 case VBOX_CLIPBOARD_EXT_FN_DATA_WRITE: 3375 { 3376 if (mpEntryPoints && pServer->mhServer) 3377 { 3378 mpEntryPoints->VRDEClipboard(pServer->mhServer, 3379 VRDE_CLIPBOARD_FUNCTION_DATA_WRITE, 3380 pParms->uFormat, 3381 pParms->u.pvData, 3382 pParms->cbData, 3383 NULL); 3384 } 3385 } break; 3386 3387 default: 3388 rc = VERR_NOT_SUPPORTED; 3389 } 3390 3391 return rc; 3392 } 3393 3322 3394 void ConsoleVRDPServer::ClipboardCreate(uint32_t u32ClientId) 3323 3395 { … … 3328 3400 { 3329 3401 if (mcClipboardRefs == 0) 3402 { 3403 rc = HGCMHostRegisterServiceExtension(&mhClipboard, "VBoxSharedClipboard", ClipboardServiceExtension, this); 3404 AssertRC(rc); 3405 3330 3406 mcClipboardRefs++; 3407 } 3331 3408 3332 3409 unlockConsoleVRDPServer(); … … 3342 3419 { 3343 3420 Assert(mcClipboardRefs); 3344 mcClipboardRefs--; 3421 if (mcClipboardRefs > 0) 3422 { 3423 mcClipboardRefs--; 3424 3425 if (mcClipboardRefs == 0 && mhClipboard) 3426 { 3427 HGCMHostUnregisterServiceExtension(mhClipboard); 3428 mhClipboard = NULL; 3429 } 3430 } 3345 3431 3346 3432 unlockConsoleVRDPServer(); … … 3665 3751 { 3666 3752 mpEntryPoints->VRDEUSBRequest(mhServer, u32ClientId, pvParms, cbParms); 3667 }3668 }3669 3670 void ConsoleVRDPServer::SendClipboard(uint32_t u32Function, uint32_t u32Format,3671 void *pvData, uint32_t cbData, uint32_t *pcbActualRead) const3672 {3673 if (mpEntryPoints && mhServer)3674 {3675 mpEntryPoints->VRDEClipboard(mhServer, u32Function, u32Format, pvData, cbData, pcbActualRead);3676 3753 } 3677 3754 }
Note:
See TracChangeset
for help on using the changeset viewer.