From 58d83c9c1e02983e524cb6809612c3ec4bd0e003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andre=CC=81=20Moreau?= Date: Tue, 15 Jul 2014 23:01:56 -0400 Subject: [PATCH] shadow: stub Mac subsystem --- server/Mac/mf_event.h | 2 +- server/Mac/mf_rdpsnd.c | 9 +- server/shadow/CMakeLists.txt | 17 +++- server/shadow/Mac/mac_shadow.c | 163 +++++++++++++++++++++++++++++++++ server/shadow/Mac/mac_shadow.h | 49 ++++++++++ server/shadow/shadow_server.c | 12 ++- 6 files changed, 243 insertions(+), 9 deletions(-) create mode 100644 server/shadow/Mac/mac_shadow.c create mode 100644 server/shadow/Mac/mac_shadow.h diff --git a/server/Mac/mf_event.h b/server/Mac/mf_event.h index edf648332..a9111a67f 100644 --- a/server/Mac/mf_event.h +++ b/server/Mac/mf_event.h @@ -18,7 +18,7 @@ */ #ifndef __MF_EVENT_H -#define __XMF_EVENT_H +#define __MF_EVENT_H typedef struct mf_event mfEvent; typedef struct mf_event_queue mfEventQueue; diff --git a/server/Mac/mf_rdpsnd.c b/server/Mac/mf_rdpsnd.c index 3333795af..f3fe8dcb5 100644 --- a/server/Mac/mf_rdpsnd.c +++ b/server/Mac/mf_rdpsnd.c @@ -21,6 +21,9 @@ #include "config.h" #endif +#include +#include + #include #include "mf_info.h" @@ -30,8 +33,8 @@ AQRecorderState recorderState; static const AUDIO_FORMAT supported_audio_formats[] = { - { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, NULL }, - { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, NULL } + { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, NULL }, + { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, NULL } }; static void mf_peer_rdpsnd_activated(RdpsndServerContext* context) @@ -161,7 +164,7 @@ BOOL mf_peer_rdpsnd_init(mfPeerContext* context) context->rdpsnd->Activated = mf_peer_rdpsnd_activated; - context->rdpsnd->Initialize(context->rdpsnd); + context->rdpsnd->Initialize(context->rdpsnd, TRUE); return TRUE; } diff --git a/server/shadow/CMakeLists.txt b/server/shadow/CMakeLists.txt index cf843ade4..aa737e35e 100644 --- a/server/shadow/CMakeLists.txt +++ b/server/shadow/CMakeLists.txt @@ -139,9 +139,24 @@ set(${MODULE_PREFIX}_X11_SRCS X11/x11_shadow.c X11/x11_shadow.h) -if(X11_FOUND) +set(${MODULE_PREFIX}_MAC_SRCS + Mac/mac_shadow.c + Mac/mac_shadow.h) + +if(X11_FOUND AND NOT APPLE) + set(WITH_SHADOW_X11 1) +elseif(APPLE AND NOT IOS) + set(WITH_SHADOW_MAC 1) +endif() + +if(WITH_SHADOW_X11) + add_definitions(-DWITH_SHADOW_X11) list(APPEND ${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_X11_SRCS}) list(APPEND ${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_X11_LIBS}) +elseif(WITH_SHADOW_MAC) + add_definitions(-DWITH_SHADOW_MAC) + list(APPEND ${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_MAC_SRCS}) + list(APPEND ${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_MAC_LIBS}) endif() add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS}) diff --git a/server/shadow/Mac/mac_shadow.c b/server/shadow/Mac/mac_shadow.c new file mode 100644 index 000000000..a303277b2 --- /dev/null +++ b/server/shadow/Mac/mac_shadow.c @@ -0,0 +1,163 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * + * Copyright 2011-2014 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. + */ + +#include +#include +#include + +#include +#include + +#include "../shadow_screen.h" +#include "../shadow_surface.h" + +#include "mac_shadow.h" + +void mac_shadow_input_synchronize_event(macShadowSubsystem* subsystem, UINT32 flags) +{ + +} + +void mac_shadow_input_keyboard_event(macShadowSubsystem* subsystem, UINT16 flags, UINT16 code) +{ + +} + +void mac_shadow_input_unicode_keyboard_event(macShadowSubsystem* subsystem, UINT16 flags, UINT16 code) +{ + +} + +void mac_shadow_input_mouse_event(macShadowSubsystem* subsystem, UINT16 flags, UINT16 x, UINT16 y) +{ + +} + +void mac_shadow_input_extended_mouse_event(macShadowSubsystem* subsystem, UINT16 flags, UINT16 x, UINT16 y) +{ + +} + +int mac_shadow_surface_copy(macShadowSubsystem* subsystem) +{ + return 1; +} + +void* mac_shadow_subsystem_thread(macShadowSubsystem* subsystem) +{ + DWORD status; + DWORD nCount; + HANDLE events[32]; + HANDLE StopEvent; + + StopEvent = subsystem->server->StopEvent; + + nCount = 0; + events[nCount++] = StopEvent; + + while (1) + { + status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE); + + if (WaitForSingleObject(StopEvent, 0) == WAIT_OBJECT_0) + { + break; + } + } + + ExitThread(0); + return NULL; +} + +int mac_shadow_subsystem_init(macShadowSubsystem* subsystem) +{ + return 1; +} + +int mac_shadow_subsystem_uninit(macShadowSubsystem* subsystem) +{ + if (!subsystem) + return -1; + + return 1; +} + +int mac_shadow_subsystem_start(macShadowSubsystem* subsystem) +{ + HANDLE thread; + + if (!subsystem) + return -1; + + thread = CreateThread(NULL, 0, + (LPTHREAD_START_ROUTINE) mac_shadow_subsystem_thread, + (void*) subsystem, 0, NULL); + + return 1; +} + +int mac_shadow_subsystem_stop(macShadowSubsystem* subsystem) +{ + if (!subsystem) + return -1; + + return 1; +} + +void mac_shadow_subsystem_free(macShadowSubsystem* subsystem) +{ + if (!subsystem) + return; + + mac_shadow_subsystem_uninit(subsystem); + + free(subsystem); +} + +macShadowSubsystem* mac_shadow_subsystem_new(rdpShadowServer* server) +{ + macShadowSubsystem* subsystem; + + subsystem = (macShadowSubsystem*) calloc(1, sizeof(macShadowSubsystem)); + + if (!subsystem) + return NULL; + + subsystem->server = server; + + subsystem->Init = (pfnShadowSubsystemInit) mac_shadow_subsystem_init; + subsystem->Uninit = (pfnShadowSubsystemInit) mac_shadow_subsystem_uninit; + subsystem->Start = (pfnShadowSubsystemStart) mac_shadow_subsystem_start; + subsystem->Stop = (pfnShadowSubsystemStop) mac_shadow_subsystem_stop; + subsystem->Free = (pfnShadowSubsystemFree) mac_shadow_subsystem_free; + + subsystem->SurfaceCopy = (pfnShadowSurfaceCopy) mac_shadow_surface_copy; + + subsystem->SynchronizeEvent = (pfnShadowSynchronizeEvent) mac_shadow_input_synchronize_event; + subsystem->KeyboardEvent = (pfnShadowKeyboardEvent) mac_shadow_input_keyboard_event; + subsystem->UnicodeKeyboardEvent = (pfnShadowUnicodeKeyboardEvent) mac_shadow_input_unicode_keyboard_event; + subsystem->MouseEvent = (pfnShadowMouseEvent) mac_shadow_input_mouse_event; + subsystem->ExtendedMouseEvent = (pfnShadowExtendedMouseEvent) mac_shadow_input_extended_mouse_event; + + return subsystem; +} + +rdpShadowSubsystem* Mac_ShadowCreateSubsystem(rdpShadowServer* server) +{ + return (rdpShadowSubsystem*) mac_shadow_subsystem_new(server); +} diff --git a/server/shadow/Mac/mac_shadow.h b/server/shadow/Mac/mac_shadow.h new file mode 100644 index 000000000..88dbf2593 --- /dev/null +++ b/server/shadow/Mac/mac_shadow.h @@ -0,0 +1,49 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * + * Copyright 2011-2014 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_SHADOW_SERVER_MAC_H +#define FREERDP_SHADOW_SERVER_MAC_H + +#include + +typedef struct mac_shadow_subsystem macShadowSubsystem; + +#include +#include +#include +#include +#include + +struct mac_shadow_subsystem +{ + RDP_SHADOW_SUBSYSTEM_COMMON(); + + +}; + +#ifdef __cplusplus +extern "C" { +#endif + + + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_SHADOW_SERVER_MAC_H */ diff --git a/server/shadow/shadow_server.c b/server/shadow/shadow_server.c index 4ae7cf0c3..4601d4dd8 100644 --- a/server/shadow/shadow_server.c +++ b/server/shadow/shadow_server.c @@ -32,14 +32,14 @@ #include "shadow.h" -#ifdef WITH_X11 -#define WITH_SHADOW_X11 -#endif - #ifdef WITH_SHADOW_X11 extern rdpShadowSubsystem* X11_ShadowCreateSubsystem(rdpShadowServer* server); #endif +#ifdef WITH_SHADOW_MAC +extern rdpShadowSubsystem* Mac_ShadowCreateSubsystem(rdpShadowServer* server); +#endif + static COMMAND_LINE_ARGUMENT_A shadow_args[] = { { "port", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Server port" }, @@ -324,6 +324,10 @@ int shadow_server_init(rdpShadowServer* server) server->CreateSubsystem = X11_ShadowCreateSubsystem; #endif +#ifdef WITH_SHADOW_MAC + server->CreateSubsystem = Mac_ShadowCreateSubsystem; +#endif + if (server->CreateSubsystem) server->subsystem = server->CreateSubsystem(server);