From 6dfa196966cbd01a3debfb990429fbeeb5f2c0e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 8 Apr 2013 22:10:59 -0400 Subject: [PATCH] wfreerdp: unify client interface --- client/Windows/cli/wfreerdp.c | 8 ++++---- client/Windows/wf_interface.c | 20 +++++++++++--------- client/Windows/wf_interface.h | 16 ++++++++++------ winpr/include/winpr/thread.h | 4 ++-- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/client/Windows/cli/wfreerdp.c b/client/Windows/cli/wfreerdp.c index 00920d926..87601279f 100644 --- a/client/Windows/cli/wfreerdp.c +++ b/client/Windows/cli/wfreerdp.c @@ -47,11 +47,11 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine int status; wfInfo* wfi; - wf_global_init(); + freerdp_client_global_init(); - wfi = wf_new(hInstance, NULL, __argc, __argv); + wfi = freerdp_client_new(__argc, __argv); - status = wf_start(wfi); + status = freerdp_client_start(wfi); if (status < 0) { @@ -64,7 +64,7 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine WaitForSingleObject(wfi->thread, INFINITE); } - wf_free(wfi); + freerdp_client_free(wfi); return 0; } diff --git a/client/Windows/wf_interface.c b/client/Windows/wf_interface.c index 0791d0e0d..055f93591 100644 --- a/client/Windows/wf_interface.c +++ b/client/Windows/wf_interface.c @@ -685,7 +685,7 @@ DWORD WINAPI wf_keyboard_thread(LPVOID lpParam) return (DWORD) NULL; } -int wf_global_init() +int freerdp_client_global_init() { WSADATA wsaData; @@ -711,21 +711,21 @@ int wf_global_init() return 0; } -int wf_global_uninit() +int freerdp_client_global_uninit() { WSACleanup(); return 0; } -wfInfo* wf_new(HINSTANCE hInstance, HWND hWndParent, int argc, char** argv) +wfInfo* freerdp_client_new(int argc, char** argv) { int index; wfInfo* wfi; freerdp* instance; + HINSTANCE hInstance; - if (!hInstance) - hInstance = GetModuleHandle(NULL); + hInstance = GetModuleHandle(NULL); instance = freerdp_new(); instance->PreConnect = wf_pre_connect; @@ -740,7 +740,9 @@ wfInfo* wf_new(HINSTANCE hInstance, HWND hWndParent, int argc, char** argv) freerdp_context_new(instance); wfi = ((wfContext*) (instance->context))->wfi; + wfi->instance = instance; + wfi->client = instance->context->client; instance->context->argc = argc; instance->context->argv = argv; @@ -752,7 +754,7 @@ wfInfo* wf_new(HINSTANCE hInstance, HWND hWndParent, int argc, char** argv) instance->context->argv[index] = _strdup(argv[index]); } - wfi->hWndParent = hWndParent; + wfi->hWndParent = NULL; wfi->hInstance = hInstance; wfi->cursor = LoadCursor(NULL, IDC_ARROW); wfi->icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1)); @@ -775,7 +777,7 @@ wfInfo* wf_new(HINSTANCE hInstance, HWND hWndParent, int argc, char** argv) return wfi; } -int wf_start(wfInfo* wfi) +int freerdp_client_start(wfInfo* wfi) { int status; freerdp* instance = wfi->instance; @@ -797,12 +799,12 @@ int wf_start(wfInfo* wfi) return 0; } -int wf_stop(wfInfo* wfi) +int freerdp_client_stop(wfInfo* wfi) { return 0; } -int wf_free(wfInfo* wfi) +int freerdp_client_free(wfInfo* wfi) { freerdp* instance = wfi->instance; diff --git a/client/Windows/wf_interface.h b/client/Windows/wf_interface.h index 44d47f783..9e4da8fd5 100644 --- a/client/Windows/wf_interface.h +++ b/client/Windows/wf_interface.h @@ -67,6 +67,8 @@ typedef struct wf_context wfContext; struct wf_info { + rdpClient* client; + int width; int height; int offset_x; @@ -107,13 +109,15 @@ struct wf_info BOOL sw_gdi; }; -FREERDP_API int wf_global_init(); -FREERDP_API int wf_global_uninit(); +#define cfInfo wfInfo -FREERDP_API int wf_start(wfInfo* wfi); -FREERDP_API int wf_stop(wfInfo* wfi); +FREERDP_API int freerdp_client_global_init(); +FREERDP_API int freerdp_client_global_uninit(); -FREERDP_API wfInfo* wf_new(HINSTANCE hInstance, HWND hWndParent, int argc, char** argv); -FREERDP_API int wf_free(wfInfo* wfi); +FREERDP_API int freerdp_client_start(wfInfo* cfi); +FREERDP_API int freerdp_client_stop(wfInfo* cfi); + +FREERDP_API cfInfo* freerdp_client_new(int argc, char** argv); +FREERDP_API int freerdp_client_free(wfInfo* cfi); #endif diff --git a/winpr/include/winpr/thread.h b/winpr/include/winpr/thread.h index fd611cb1a..5fe7adab0 100644 --- a/winpr/include/winpr/thread.h +++ b/winpr/include/winpr/thread.h @@ -26,12 +26,12 @@ #include #include -#ifndef _WIN32 - #ifdef __cplusplus extern "C" { #endif +#ifndef _WIN32 + typedef struct _STARTUPINFOA { DWORD cb;