Changeset 81443 in vbox for trunk/src/VBox/HostServices
- Timestamp:
- Oct 22, 2019 9:52:40 AM (5 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedClipboard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc-internal.h
r81441 r81443 198 198 int shclSvcMsgGet(PSHCLCLIENT pClient, VBOXHGCMCALLHANDLE hCall, uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 199 199 200 int shclSvcClientInit(PSHCLCLIENT pClient, uint32_t uClientID); 201 void shclSvcClientReset(PSHCLCLIENT pClient); 202 203 int shclSvcClientStateInit(PSHCLCLIENTSTATE pClientState, uint32_t uClientID); 204 int shclSvcClientStateDestroy(PSHCLCLIENTSTATE pClientState); 205 void shclSvcClientStateReset(PSHCLCLIENTSTATE pClientState); 206 200 207 int shclSvcClientWakeup(PSHCLCLIENT pClient); 201 208 -
trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp
r81352 r81443 239 239 240 240 /********************************************************************************************************************************* 241 * Prototypes *242 *********************************************************************************************************************************/243 static int shclSvcClientStateInit(PSHCLCLIENTSTATE pClientState, uint32_t uClientID);244 static int shclSvcClientStateDestroy(PSHCLCLIENTSTATE pClientState);245 static void shclSvcClientStateReset(PSHCLCLIENTSTATE pClientState);246 247 248 /*********************************************************************************************************************************249 241 * Global Variables * 250 242 *********************************************************************************************************************************/ … … 508 500 509 501 return VINF_SUCCESS; 502 } 503 504 /** 505 * Initializes a Shared Clipboard client. 506 * 507 * @param pClient Client to initialize. 508 * @param uClientID HGCM client ID to assign client to. 509 */ 510 int shclSvcClientInit(PSHCLCLIENT pClient, uint32_t uClientID) 511 { 512 AssertPtrReturn(pClient, VERR_INVALID_POINTER); 513 514 /* Assign the client ID. */ 515 pClient->State.uClientID = uClientID; 516 517 LogFlowFunc(("[Client %RU32]\n", pClient->State.uClientID)); 518 519 /* Create the client's own event source. */ 520 int rc = ShClEventSourceCreate(&pClient->Events, 0 /* ID, ignored */); 521 if (RT_SUCCESS(rc)) 522 { 523 LogFlowFunc(("[Client %RU32] Using event source %RU32\n", uClientID, pClient->Events.uID)); 524 525 /* Reset the client state. */ 526 shclSvcClientStateReset(&pClient->State); 527 528 /* (Re-)initialize the client state. */ 529 rc = shclSvcClientStateInit(&pClient->State, uClientID); 530 531 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 532 if (RT_SUCCESS(rc)) 533 rc = ShClTransferCtxInit(&pClient->TransferCtx); 534 #endif 535 } 536 537 LogFlowFuncLeaveRC(rc); 538 return rc; 539 } 540 541 /** 542 * Resets a Shared Clipboard client. 543 * 544 * @param pClient Client to reset. 545 */ 546 void shclSvcClientReset(PSHCLCLIENT pClient) 547 { 548 if (!pClient) 549 return; 550 551 LogFlowFunc(("[Client %RU32]\n", pClient->State.uClientID)); 552 553 /* Reset message queue. */ 554 shclSvcMsgQueueReset(pClient); 555 556 /* Reset event source. */ 557 ShClEventSourceReset(&pClient->Events); 558 559 /* Reset pending state. */ 560 RT_ZERO(pClient->Pending); 561 562 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 563 shclSvcClientTransfersReset(pClient); 564 #endif 565 566 shclSvcClientStateReset(&pClient->State); 510 567 } 511 568 … … 1273 1330 } 1274 1331 1275 shclSvcClientStateReset(&pClient->State);1276 1332 shclSvcClientStateDestroy(&pClient->State); 1277 1278 1333 ShClEventSourceDestroy(&pClient->Events); 1279 1334 … … 1296 1351 AssertPtr(pvClient); 1297 1352 1298 /* Assign the client ID. */ 1299 pClient->State.uClientID = u32ClientID; 1300 1301 /* Create the client's own event source. */ 1302 int rc = ShClEventSourceCreate(&pClient->Events, 0 /* ID, ignored */); 1353 int rc = shclSvcClientInit(pClient, u32ClientID); 1303 1354 if (RT_SUCCESS(rc)) 1304 1355 { 1305 LogFlowFunc(("[Client %RU32] Using event source %RU32\n", u32ClientID, pClient->Events.uID)); 1306 1307 /* Reset the client state. */ 1308 shclSvcClientStateReset(&pClient->State); 1309 1310 /* (Re-)initialize the client state. */ 1311 rc = shclSvcClientStateInit(&pClient->State, u32ClientID); 1356 rc = ShClSvcImplConnect(pClient, ShClSvcGetHeadless()); 1312 1357 if (RT_SUCCESS(rc)) 1313 1358 { 1314 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 1315 rc = ShClTransferCtxInit(&pClient->TransferCtx); 1316 #endif 1317 if (RT_SUCCESS(rc)) 1318 rc = ShClSvcImplConnect(pClient, ShClSvcGetHeadless()); 1319 if (RT_SUCCESS(rc)) 1320 { 1321 /* Assign weak pointer to client map .*/ 1322 g_mapClients[u32ClientID] = pClient; /** @todo Handle OOM / collisions? */ 1323 1324 /* For now we ASSUME that the first client ever connected is in charge for 1325 * communicating withe the service extension. 1326 * 1327 ** @todo This needs to be fixed ASAP w/o breaking older guest / host combos. */ 1328 if (g_ExtState.uClientID == 0) 1329 g_ExtState.uClientID = u32ClientID; 1330 } 1359 /* Assign weak pointer to client map .*/ 1360 g_mapClients[u32ClientID] = pClient; /** @todo Handle OOM / collisions? */ 1361 1362 /* For now we ASSUME that the first client ever connected is in charge for 1363 * communicating withe the service extension. 1364 * 1365 ** @todo This needs to be fixed ASAP w/o breaking older guest / host combos. */ 1366 if (g_ExtState.uClientID == 0) 1367 g_ExtState.uClientID = u32ClientID; 1331 1368 } 1332 1369 } … … 1684 1721 * @param uClientID Client ID (HGCM) to use for this client state. 1685 1722 */ 1686 staticint shclSvcClientStateInit(PSHCLCLIENTSTATE pClientState, uint32_t uClientID)1723 int shclSvcClientStateInit(PSHCLCLIENTSTATE pClientState, uint32_t uClientID) 1687 1724 { 1688 1725 LogFlowFuncEnter(); … … 1702 1739 * @param pClientState Client state to destroy. 1703 1740 */ 1704 staticint shclSvcClientStateDestroy(PSHCLCLIENTSTATE pClientState)1741 int shclSvcClientStateDestroy(PSHCLCLIENTSTATE pClientState) 1705 1742 { 1706 1743 RT_NOREF(pClientState); … … 1716 1753 * @param pClientState Client state to reset. 1717 1754 */ 1718 staticvoid shclSvcClientStateReset(PSHCLCLIENTSTATE pClientState)1755 void shclSvcClientStateReset(PSHCLCLIENTSTATE pClientState) 1719 1756 { 1720 1757 LogFlowFuncEnter(); … … 1728 1765 #ifdef VBOX_WITH_SHARED_CLIPBOARD_TRANSFERS 1729 1766 pClientState->Transfers.enmTransferDir = SHCLTRANSFERDIR_UNKNOWN; 1730 #else1731 RT_NOREF(pClientState);1732 1767 #endif 1733 1768 }
Note:
See TracChangeset
for help on using the changeset viewer.