Changeset 43350 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Sep 18, 2012 2:39:14 PM (12 years ago)
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r43256 r43350 2459 2459 2460 2460 Log(("Set VBoxSharedClipboard mode\n")); 2461 } 2462 } 2463 } 2464 2465 /* 2466 * HGCM HostChannel 2467 */ 2468 { 2469 Bstr value; 2470 hrc = pMachine->GetExtraData(Bstr("HGCM/HostChannel").raw(), 2471 value.asOutParam()); 2472 2473 if ( hrc == S_OK 2474 && value == "1") 2475 { 2476 rc = pVMMDev->hgcmLoadService("VBoxHostChannel", "VBoxHostChannel"); 2477 2478 if (RT_FAILURE(rc)) 2479 { 2480 LogRel(("VBoxHostChannel is not available. rc = %Rrc\n", rc)); 2481 /* That is not a fatal failure. */ 2482 rc = VINF_SUCCESS; 2461 2483 } 2462 2484 } -
trunk/src/VBox/Main/src-client/ConsoleVRDPServer.cpp
r42248 r43350 5 5 6 6 /* 7 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2012 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 1379 1379 RT_ZERO(m_interfaceSCard); 1380 1380 RT_ZERO(m_interfaceCallbacksSCard); 1381 RT_ZERO(m_interfaceTSMF); 1382 RT_ZERO(m_interfaceCallbacksTSMF); 1381 1383 } 1382 1384 … … 1631 1633 } 1632 1634 1635 /* Raw TSMF interface. */ 1636 m_interfaceTSMF.header.u64Version = 1; 1637 m_interfaceTSMF.header.u64Size = sizeof(m_interfaceTSMF); 1638 1639 m_interfaceCallbacksTSMF.header.u64Version = 1; 1640 m_interfaceCallbacksTSMF.header.u64Size = sizeof(m_interfaceCallbacksTSMF); 1641 m_interfaceCallbacksTSMF.VRDETSMFCbNotify = VRDETSMFCbNotify; 1642 1643 vrc = mpEntryPoints->VRDEGetInterface(mhServer, 1644 VRDE_TSMF_INTERFACE_NAME, 1645 &m_interfaceTSMF.header, 1646 &m_interfaceCallbacksTSMF.header, 1647 this); 1648 if (RT_SUCCESS(vrc)) 1649 { 1650 LogRel(("VRDE: [%s]\n", VRDE_TSMF_INTERFACE_NAME)); 1651 } 1652 else 1653 { 1654 RT_ZERO(m_interfaceTSMF); 1655 } 1656 1633 1657 /* Since these interfaces are optional, it is always a success here. */ 1634 1658 vrc = VINF_SUCCESS; … … 2059 2083 } 2060 2084 2085 typedef struct TSMFHOSTCHANNELCTX 2086 { 2087 ConsoleVRDPServer *pThis; 2088 2089 VBOXHOSTCHANNELCALLBACKS *pCallbacks; 2090 void *pvCallbacks; 2091 2092 uint32_t u32ChannelHandle; 2093 2094 void *pvDataReceived; 2095 uint32_t cbDataReceived; 2096 uint32_t cbDataAllocated; 2097 } TSMFHOSTCHANNELCTX; 2098 2099 /* static */ DECLCALLBACK(int) ConsoleVRDPServer::tsmfHostChannelAttach(void *pvProvider, 2100 void **ppvChannel, 2101 uint32_t u32Flags, 2102 VBOXHOSTCHANNELCALLBACKS *pCallbacks, 2103 void *pvCallbacks) 2104 { 2105 LogFlowFunc(("\n")); 2106 2107 ConsoleVRDPServer *pThis = static_cast<ConsoleVRDPServer*>(pvProvider); 2108 2109 TSMFHOSTCHANNELCTX *pCtx = (TSMFHOSTCHANNELCTX *)RTMemAllocZ(sizeof(TSMFHOSTCHANNELCTX)); 2110 if (!pCtx) 2111 { 2112 return VERR_NO_MEMORY; 2113 } 2114 2115 pCtx->pThis = pThis; 2116 pCtx->pCallbacks = pCallbacks; 2117 pCtx->pvCallbacks = pvCallbacks; 2118 2119 int rc = pThis->m_interfaceTSMF.VRDETSMFChannelCreate(pThis->mhServer, pCtx, u32Flags); 2120 2121 if (RT_SUCCESS(rc)) 2122 { 2123 *ppvChannel = pCtx; 2124 } 2125 else 2126 { 2127 RTMemFree(pCtx); 2128 } 2129 2130 return rc; 2131 } 2132 2133 /* static */ DECLCALLBACK(void) ConsoleVRDPServer::tsmfHostChannelDetach(void *pvChannel) 2134 { 2135 LogFlowFunc(("\n")); 2136 2137 TSMFHOSTCHANNELCTX *pCtx = (TSMFHOSTCHANNELCTX *)pvChannel; 2138 /* @todo */ 2139 } 2140 2141 /* static */ DECLCALLBACK(int) ConsoleVRDPServer::tsmfHostChannelSend(void *pvChannel, 2142 const void *pvData, 2143 uint32_t cbData) 2144 { 2145 LogFlowFunc(("\n")); 2146 TSMFHOSTCHANNELCTX *pCtx = (TSMFHOSTCHANNELCTX *)pvChannel; 2147 2148 int rc = pCtx->pThis->m_interfaceTSMF.VRDETSMFChannelSend(pCtx->pThis->mhServer, pCtx->u32ChannelHandle, 2149 pvData, cbData); 2150 2151 return rc; 2152 } 2153 2154 /* static */ DECLCALLBACK(int) ConsoleVRDPServer::tsmfHostChannelRecv(void *pvChannel, 2155 void *pvData, 2156 uint32_t cbData, 2157 uint32_t *pcbReceived, 2158 uint32_t *pcbRemaining) 2159 { 2160 LogFlowFunc(("\n")); 2161 2162 TSMFHOSTCHANNELCTX *pCtx = (TSMFHOSTCHANNELCTX *)pvChannel; 2163 int rc = VINF_SUCCESS; 2164 2165 uint32_t cbToCopy = RT_MIN(cbData, pCtx->cbDataReceived); 2166 uint32_t cbRemaining = pCtx->cbDataReceived - cbToCopy; 2167 2168 LogFlowFunc(("cbToCopy %d, cbRemaining %d\n", cbToCopy, cbRemaining)); 2169 2170 if (cbToCopy != 0) 2171 { 2172 memcpy(pvData, pCtx->pvDataReceived, cbToCopy); 2173 2174 if (cbRemaining != 0) 2175 { 2176 memmove(pCtx->pvDataReceived, (uint8_t *)pCtx->pvDataReceived + cbToCopy, cbRemaining); 2177 } 2178 2179 pCtx->cbDataReceived = cbRemaining; 2180 } 2181 2182 *pcbRemaining = cbRemaining; 2183 *pcbReceived = cbToCopy; 2184 2185 return VINF_SUCCESS; 2186 } 2187 2188 /* static */ DECLCALLBACK(int) ConsoleVRDPServer::tsmfHostChannelControl(void *pvChannel, 2189 uint32_t u32Code, 2190 const void *pvParm, 2191 uint32_t cbParm, 2192 const void *pvData, 2193 uint32_t cbData, 2194 uint32_t *pcbDataReturned) 2195 { 2196 LogFlowFunc(("\n")); 2197 return VERR_NOT_IMPLEMENTED; 2198 } 2199 2200 2201 void ConsoleVRDPServer::setupTSMF(void) 2202 { 2203 if (m_interfaceTSMF.header.u64Size == 0) 2204 { 2205 return; 2206 } 2207 2208 /* Register with the host channel service. */ 2209 VBOXHOSTCHANNELINTERFACE hostChannelInterface = 2210 { 2211 this, 2212 tsmfHostChannelAttach, 2213 tsmfHostChannelDetach, 2214 tsmfHostChannelSend, 2215 tsmfHostChannelRecv, 2216 tsmfHostChannelControl 2217 }; 2218 2219 VBoxHostChannelHostRegister parms; 2220 2221 static char szProviderName[] = "/vrde/tsmf"; 2222 2223 parms.name.type = VBOX_HGCM_SVC_PARM_PTR; 2224 parms.name.u.pointer.addr = &szProviderName[0]; 2225 parms.name.u.pointer.size = sizeof(szProviderName); 2226 2227 parms.iface.type = VBOX_HGCM_SVC_PARM_PTR; 2228 parms.iface.u.pointer.addr = &hostChannelInterface; 2229 parms.iface.u.pointer.size = sizeof(hostChannelInterface); 2230 2231 VMMDev *pVMMDev = mConsole->getVMMDev(); 2232 2233 if (!pVMMDev) 2234 { 2235 AssertMsgFailed(("setupTSMF no vmmdev\n")); 2236 return; 2237 } 2238 2239 AssertCompile(RT_OFFSETOF(VBoxHostChannelHostRegister, name) == 0); 2240 int rc = pVMMDev->hgcmHostCall("VBoxHostChannel", 2241 VBOX_HOST_CHANNEL_HOST_FN_REGISTER, 2242 2, 2243 &parms.name); 2244 2245 if (!RT_SUCCESS(rc)) 2246 { 2247 Log(("VBOX_HOST_CHANNEL_HOST_FN_REGISTER failed with %Rrc\n", rc)); 2248 return; 2249 } 2250 2251 LogRel(("VRDE: Enabled TSMF channel.\n")); 2252 2253 return; 2254 } 2255 2256 /* @todo these defines must be in a header, which is used by guest component as well. */ 2257 #define VBOX_TSMF_HCH_CREATE_ACCEPTED (VBOX_HOST_CHANNEL_EVENT_USER + 0) 2258 #define VBOX_TSMF_HCH_CREATE_DECLINED (VBOX_HOST_CHANNEL_EVENT_USER + 1) 2259 #define VBOX_TSMF_HCH_DISCONNECTED (VBOX_HOST_CHANNEL_EVENT_USER + 2) 2260 2261 /* static */ DECLCALLBACK(void) ConsoleVRDPServer::VRDETSMFCbNotify(void *pvContext, 2262 uint32_t u32Notification, 2263 void *pvChannel, 2264 const void *pvParm, 2265 uint32_t cbParm) 2266 { 2267 ConsoleVRDPServer *pThis = static_cast<ConsoleVRDPServer*>(pvContext); 2268 2269 TSMFHOSTCHANNELCTX *pCtx = (TSMFHOSTCHANNELCTX *)pvChannel; 2270 2271 Assert(pCtx->pThis == pThis); 2272 2273 switch(u32Notification) 2274 { 2275 case VRDE_TSMF_N_CREATE_ACCEPTED: 2276 { 2277 VRDETSMFNOTIFYCREATEACCEPTED *p = (VRDETSMFNOTIFYCREATEACCEPTED *)pvParm; 2278 Assert(cbParm == sizeof(VRDETSMFNOTIFYCREATEACCEPTED)); 2279 2280 LogFlowFunc(("VRDE_TSMF_N_CREATE_ACCEPTED: p->u32ChannelHandle %d\n", p->u32ChannelHandle)); 2281 2282 pCtx->u32ChannelHandle = p->u32ChannelHandle; 2283 2284 pCtx->pCallbacks->HostChannelCallbackEvent(pCtx->pvCallbacks, pCtx, 2285 VBOX_TSMF_HCH_CREATE_ACCEPTED, 2286 NULL, 0); 2287 } break; 2288 2289 case VRDE_TSMF_N_CREATE_DECLINED: 2290 { 2291 pCtx->pCallbacks->HostChannelCallbackEvent(pCtx->pvCallbacks, pCtx, 2292 VBOX_TSMF_HCH_CREATE_DECLINED, 2293 NULL, 0); 2294 } break; 2295 2296 case VRDE_TSMF_N_DATA: 2297 { 2298 /* Save the data in the intermediate buffer and send the event. */ 2299 VRDETSMFNOTIFYDATA *p = (VRDETSMFNOTIFYDATA *)pvParm; 2300 Assert(cbParm == sizeof(VRDETSMFNOTIFYDATA)); 2301 2302 LogFlowFunc(("VRDE_TSMF_N_DATA: p->cbData %d\n", p->cbData)); 2303 2304 if (pCtx->pvDataReceived) 2305 { 2306 uint32_t cbAlloc = p->cbData + pCtx->cbDataReceived; 2307 pCtx->pvDataReceived = RTMemRealloc(pCtx->pvDataReceived, cbAlloc); 2308 memcpy((uint8_t *)pCtx->pvDataReceived + pCtx->cbDataReceived, p->pvData, p->cbData); 2309 2310 pCtx->cbDataReceived += p->cbData; 2311 pCtx->cbDataAllocated = cbAlloc; 2312 } 2313 else 2314 { 2315 pCtx->pvDataReceived = RTMemAlloc(p->cbData); 2316 memcpy(pCtx->pvDataReceived, p->pvData, p->cbData); 2317 2318 pCtx->cbDataReceived = p->cbData; 2319 pCtx->cbDataAllocated = p->cbData; 2320 } 2321 2322 VBOXHOSTCHANNELEVENTRECV ev; 2323 ev.u32SizeAvailable = pCtx->cbDataReceived; 2324 2325 pCtx->pCallbacks->HostChannelCallbackEvent(pCtx->pvCallbacks, pCtx, 2326 VBOX_HOST_CHANNEL_EVENT_RECV, 2327 &ev, sizeof(ev)); 2328 } break; 2329 2330 case VRDE_TSMF_N_DISCONNECTED: 2331 { 2332 pCtx->pCallbacks->HostChannelCallbackEvent(pCtx->pvCallbacks, pCtx, 2333 VBOX_TSMF_HCH_DISCONNECTED, 2334 NULL, 0); 2335 } break; 2336 2337 default: 2338 { 2339 AssertFailed(); 2340 } break; 2341 } 2342 } 2343 2061 2344 void ConsoleVRDPServer::EnableConnections(void) 2062 2345 { … … 2067 2350 /* Redirect 3D output if it is enabled. */ 2068 2351 remote3DRedirect(); 2352 2353 /* Setup the generic TSMF channel. */ 2354 setupTSMF(); 2069 2355 } 2070 2356 }
Note:
See TracChangeset
for help on using the changeset viewer.