From fb752b3aaec47b37cffb165d7c80506c547f6c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 21 Oct 2013 22:53:55 -0400 Subject: [PATCH] channels/rdpgfx: create empty channel client stub --- channels/rdpgfx/CMakeLists.txt | 23 +++ channels/rdpgfx/ChannelOptions.cmake | 13 ++ channels/rdpgfx/client/CMakeLists.txt | 49 ++++++ channels/rdpgfx/client/rdpgfx_common.c | 29 ++++ channels/rdpgfx/client/rdpgfx_common.h | 29 ++++ channels/rdpgfx/client/rdpgfx_main.c | 198 +++++++++++++++++++++++++ channels/rdpgfx/client/rdpgfx_main.h | 36 +++++ include/freerdp/channels/rdpgfx.h | 2 + include/freerdp/client/rdpgfx.h | 41 +++++ 9 files changed, 420 insertions(+) create mode 100644 channels/rdpgfx/CMakeLists.txt create mode 100644 channels/rdpgfx/ChannelOptions.cmake create mode 100644 channels/rdpgfx/client/CMakeLists.txt create mode 100644 channels/rdpgfx/client/rdpgfx_common.c create mode 100644 channels/rdpgfx/client/rdpgfx_common.h create mode 100644 channels/rdpgfx/client/rdpgfx_main.c create mode 100644 channels/rdpgfx/client/rdpgfx_main.h create mode 100644 include/freerdp/client/rdpgfx.h diff --git a/channels/rdpgfx/CMakeLists.txt b/channels/rdpgfx/CMakeLists.txt new file mode 100644 index 000000000..acc50da70 --- /dev/null +++ b/channels/rdpgfx/CMakeLists.txt @@ -0,0 +1,23 @@ +# FreeRDP: A Remote Desktop Protocol Implementation +# FreeRDP cmake build script +# +# Copyright 2012 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +define_channel("rdpgfx") + +if(WITH_CLIENT_CHANNELS) + add_channel_client(${MODULE_PREFIX} ${CHANNEL_NAME}) +endif() + diff --git a/channels/rdpgfx/ChannelOptions.cmake b/channels/rdpgfx/ChannelOptions.cmake new file mode 100644 index 000000000..acb8de851 --- /dev/null +++ b/channels/rdpgfx/ChannelOptions.cmake @@ -0,0 +1,13 @@ + +set(OPTION_DEFAULT OFF) +set(OPTION_CLIENT_DEFAULT ON) +set(OPTION_SERVER_DEFAULT OFF) + +define_channel_options(NAME "rdpgfx" TYPE "dynamic" + DESCRIPTION "Graphics Pipeline Extension" + SPECIFICATIONS "[MS-RDPEGFX]" + DEFAULT ${OPTION_DEFAULT}) + +define_channel_client_options(${OPTION_CLIENT_DEFAULT}) +define_channel_server_options(${OPTION_SERVER_DEFAULT}) + diff --git a/channels/rdpgfx/client/CMakeLists.txt b/channels/rdpgfx/client/CMakeLists.txt new file mode 100644 index 000000000..282a85838 --- /dev/null +++ b/channels/rdpgfx/client/CMakeLists.txt @@ -0,0 +1,49 @@ +# FreeRDP: A Remote Desktop Protocol Implementation +# FreeRDP cmake build script +# +# Copyright 2013 Marc-Andre Moreau +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +define_channel_client("rdpgfx") + +set(${MODULE_PREFIX}_SRCS + rdpgfx_main.c + rdpgfx_main.h + rdpgfx_common.c + rdpgfx_common.h) + +include_directories(..) + +add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} TRUE "DVCPluginEntry") + +set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "") + +set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS + MONOLITHIC ${MONOLITHIC_BUILD} + MODULE freerdp + MODULES freerdp-common freerdp-utils) + +set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS + MONOLITHIC ${MONOLITHIC_BUILD} + MODULE winpr + MODULES winpr-sysinfo) + +target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) + +if(NOT STATIC_CHANNELS) + install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_PLUGIN_PATH}) +endif() + +set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client") + diff --git a/channels/rdpgfx/client/rdpgfx_common.c b/channels/rdpgfx/client/rdpgfx_common.c new file mode 100644 index 000000000..bd0a76fa2 --- /dev/null +++ b/channels/rdpgfx/client/rdpgfx_common.c @@ -0,0 +1,29 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Graphics Pipeline Extension + * + * Copyright 2013 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#include "rdpgfx_common.h" + + diff --git a/channels/rdpgfx/client/rdpgfx_common.h b/channels/rdpgfx/client/rdpgfx_common.h new file mode 100644 index 000000000..20fd72251 --- /dev/null +++ b/channels/rdpgfx/client/rdpgfx_common.h @@ -0,0 +1,29 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Graphics Pipeline Extension + * + * Copyright 2013 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_CHANNEL_RDPGFX_CLIENT_COMMON_H +#define FREERDP_CHANNEL_RDPGFX_CLIENT_COMMON_H + +#include +#include + + + +#endif /* FREERDP_CHANNEL_RDPGFX_CLIENT_COMMON_H */ + diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c new file mode 100644 index 000000000..889da5ffd --- /dev/null +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -0,0 +1,198 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Graphics Pipeline Extension + * + * Copyright 2013 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "rdpgfx_common.h" + +#include "rdpgfx_main.h" + +struct _RDPGFX_CHANNEL_CALLBACK +{ + IWTSVirtualChannelCallback iface; + + IWTSPlugin* plugin; + IWTSVirtualChannelManager* channel_mgr; + IWTSVirtualChannel* channel; +}; +typedef struct _RDPGFX_CHANNEL_CALLBACK RDPGFX_CHANNEL_CALLBACK; + +struct _RDPGFX_LISTENER_CALLBACK +{ + IWTSListenerCallback iface; + + IWTSPlugin* plugin; + IWTSVirtualChannelManager* channel_mgr; + RDPGFX_CHANNEL_CALLBACK* channel_callback; +}; +typedef struct _RDPGFX_LISTENER_CALLBACK RDPGFX_LISTENER_CALLBACK; + +struct _RDPGFX_PLUGIN +{ + IWTSPlugin iface; + + IWTSListener* listener; + RDPGFX_LISTENER_CALLBACK* listener_callback; +}; +typedef struct _RDPGFX_PLUGIN RDPGFX_PLUGIN; + +int rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) +{ + return 0; +} + +static int rdpgfx_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, UINT32 cbSize, BYTE* pBuffer) +{ + wStream* s; + int status = 0; + RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*) pChannelCallback; + + s = Stream_New(pBuffer, cbSize); + + status = rdpgfx_recv_pdu(callback, s); + + Stream_Free(s, FALSE); + + return status; +} + +static int rdpgfx_on_close(IWTSVirtualChannelCallback* pChannelCallback) +{ + RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*) pChannelCallback; + + free(callback); + + return 0; +} + +static int rdpgfx_on_new_channel_connection(IWTSListenerCallback* pListenerCallback, + IWTSVirtualChannel* pChannel, BYTE* Data, int* pbAccept, + IWTSVirtualChannelCallback** ppCallback) +{ + RDPGFX_CHANNEL_CALLBACK* callback; + RDPGFX_LISTENER_CALLBACK* listener_callback = (RDPGFX_LISTENER_CALLBACK*) pListenerCallback; + + callback = (RDPGFX_CHANNEL_CALLBACK*) malloc(sizeof(RDPGFX_CHANNEL_CALLBACK)); + ZeroMemory(callback, sizeof(RDPGFX_CHANNEL_CALLBACK)); + + callback->iface.OnDataReceived = rdpgfx_on_data_received; + callback->iface.OnClose = rdpgfx_on_close; + callback->plugin = listener_callback->plugin; + callback->channel_mgr = listener_callback->channel_mgr; + callback->channel = pChannel; + listener_callback->channel_callback = callback; + + *ppCallback = (IWTSVirtualChannelCallback*) callback; + + return 0; +} + +static int rdpgfx_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr) +{ + int status; + RDPGFX_PLUGIN* rdpgfx = (RDPGFX_PLUGIN*) pPlugin; + + rdpgfx->listener_callback = (RDPGFX_LISTENER_CALLBACK*) malloc(sizeof(RDPGFX_LISTENER_CALLBACK)); + ZeroMemory(rdpgfx->listener_callback, sizeof(RDPGFX_LISTENER_CALLBACK)); + + rdpgfx->listener_callback->iface.OnNewChannelConnection = rdpgfx_on_new_channel_connection; + rdpgfx->listener_callback->plugin = pPlugin; + rdpgfx->listener_callback->channel_mgr = pChannelMgr; + + status = pChannelMgr->CreateListener(pChannelMgr, RDPGFX_DVC_CHANNEL_NAME, 0, + (IWTSListenerCallback*) rdpgfx->listener_callback, &(rdpgfx->listener)); + + rdpgfx->listener->pInterface = rdpgfx->iface.pInterface; + + return status; +} + +static int rdpgfx_plugin_terminated(IWTSPlugin* pPlugin) +{ + RDPGFX_PLUGIN* rdpgfx = (RDPGFX_PLUGIN*) pPlugin; + + if (rdpgfx->listener_callback) + free(rdpgfx->listener_callback); + + free(rdpgfx); + + return 0; +} + +/** + * Channel Client Interface + */ + +UINT32 rdpgfx_get_version(RdpgfxClientContext* context) +{ + //RDPGFX_PLUGIN* rdpgfx = (RDPGFX_PLUGIN*) context->handle; + return 0; +} + +#ifdef STATIC_CHANNELS +#define DVCPluginEntry rdpgfx_DVCPluginEntry +#endif + +int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) +{ + int error = 0; + RDPGFX_PLUGIN* rdpgfx; + RdpgfxClientContext* context; + + rdpgfx = (RDPGFX_PLUGIN*) pEntryPoints->GetPlugin(pEntryPoints, "rdpgfx"); + + if (!rdpgfx) + { + rdpgfx = (RDPGFX_PLUGIN*) malloc(sizeof(RDPGFX_PLUGIN)); + ZeroMemory(rdpgfx, sizeof(RDPGFX_PLUGIN)); + + rdpgfx->iface.Initialize = rdpgfx_plugin_initialize; + rdpgfx->iface.Connected = NULL; + rdpgfx->iface.Disconnected = NULL; + rdpgfx->iface.Terminated = rdpgfx_plugin_terminated; + + context = (RdpgfxClientContext*) malloc(sizeof(RdpgfxClientContext)); + + context->handle = (void*) rdpgfx; + context->GetVersion = rdpgfx_get_version; + + rdpgfx->iface.pInterface = (void*) context; + + error = pEntryPoints->RegisterPlugin(pEntryPoints, "rdpgfx", (IWTSPlugin*) rdpgfx); + } + + return error; +} diff --git a/channels/rdpgfx/client/rdpgfx_main.h b/channels/rdpgfx/client/rdpgfx_main.h new file mode 100644 index 000000000..74cfcbef3 --- /dev/null +++ b/channels/rdpgfx/client/rdpgfx_main.h @@ -0,0 +1,36 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Graphics Pipeline Extension + * + * Copyright 2013 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_CHANNEL_RDPGFX_CLIENT_MAIN_H +#define FREERDP_CHANNEL_RDPGFX_CLIENT_MAIN_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include + + + +#endif /* FREERDP_CHANNEL_RDPGFX_CLIENT_MAIN_H */ + diff --git a/include/freerdp/channels/rdpgfx.h b/include/freerdp/channels/rdpgfx.h index b9919e156..ef38bf0a3 100644 --- a/include/freerdp/channels/rdpgfx.h +++ b/include/freerdp/channels/rdpgfx.h @@ -24,6 +24,8 @@ #include #include +#define RDPGFX_DVC_CHANNEL_NAME "Microsoft::Windows::RDS::Graphics" + /** * Common Data Types */ diff --git a/include/freerdp/client/rdpgfx.h b/include/freerdp/client/rdpgfx.h new file mode 100644 index 000000000..b9e7c70e8 --- /dev/null +++ b/include/freerdp/client/rdpgfx.h @@ -0,0 +1,41 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * Graphics Pipeline Extension + * + * Copyright 2013 Marc-Andre Moreau + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FREERDP_CHANNEL_CLIENT_RDPGFX_H +#define FREERDP_CHANNEL_CLIENT_RDPGFX_H + +#include + +/** + * Client Interface + */ + +typedef struct _rdpgfx_client_context RdpgfxClientContext; + +typedef UINT32 (*pcRdpgfxGetVersion)(RdpgfxClientContext* context); + +struct _rdpgfx_client_context +{ + void* handle; + void* custom; + + pcRdpgfxGetVersion GetVersion; +}; + +#endif /* FREERDP_CHANNEL_CLIENT_RDPGFX_H */