Merge pull request #1118 from awakecoding/master

Split wfreerdp into library + executable
This commit is contained in:
Marc-André Moreau 2013-03-19 12:55:17 -07:00
commit 679ef8c328
27 changed files with 331 additions and 143 deletions

2
.gitignore vendored
View File

@ -53,6 +53,7 @@ DerivedData/
*.suo *.suo
*.ncb *.ncb
*.opensdf *.opensdf
Thumbs.db
ipch ipch
Debug Debug
RelWithDebInfo RelWithDebInfo
@ -78,6 +79,7 @@ xcode
*.dir *.dir
Release Release
Win32 Win32
build/
default.log default.log
*Amplifier XE* *Amplifier XE*

View File

@ -79,6 +79,14 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release") set(CMAKE_BUILD_TYPE "Release")
endif() endif()
if(NOT DEFINED WITH_CLIENT_INTERFACE)
set(WITH_CLIENT_INTERFACE ON)
endif()
if(NOT DEFINED WITH_SERVER_INTERFACE)
set(WITH_SERVER_INTERFACE ON)
endif()
if(NOT DEFINED BUILD_SHARED_LIBS) if(NOT DEFINED BUILD_SHARED_LIBS)
if(ANDROID OR IOS) if(ANDROID OR IOS)
set(BUILD_SHARED_LIBS OFF) set(BUILD_SHARED_LIBS OFF)

View File

@ -44,3 +44,5 @@ target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS) if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH}) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif() endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client/ALSA")

View File

@ -48,3 +48,5 @@ target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS) if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH}) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif() endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client/Mac")

View File

@ -39,3 +39,5 @@ target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS) if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH}) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif() endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client/Pulse")

View File

@ -43,3 +43,5 @@ target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
if(NOT STATIC_CHANNELS) if(NOT STATIC_CHANNELS)
install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH}) install(TARGETS ${MODULE_NAME} DESTINATION ${FREERDP_ADDIN_PATH})
endif() endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Channels/${CHANNEL_NAME}/Client/WinMM")

View File

@ -44,3 +44,5 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} PARENT_SCOPE) set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} PARENT_SCOPE)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/Common")

View File

@ -1181,6 +1181,8 @@ void mf_Pointer_Free(rdpContext* context, rdpPointer* pointer)
void mf_Pointer_Set(rdpContext* context, rdpPointer* pointer) void mf_Pointer_Set(rdpContext* context, rdpPointer* pointer)
{ {
NSMutableArray* ma = g_mrdpview->cursors; NSMutableArray* ma = g_mrdpview->cursors;
return; /* disable pointer until it is fixed */
if (!g_mrdpview->mouseInClientArea) if (!g_mrdpview->mouseInClientArea)
return; return;
@ -1201,6 +1203,7 @@ void mf_Pointer_Set(rdpContext* context, rdpPointer* pointer)
void mf_Pointer_SetNull(rdpContext* context) void mf_Pointer_SetNull(rdpContext* context)
{ {
} }
/** ********************************************************************* /** *********************************************************************
@ -1209,6 +1212,7 @@ void mf_Pointer_SetNull(rdpContext* context)
void mf_Pointer_SetDefault(rdpContext* context) void mf_Pointer_SetDefault(rdpContext* context)
{ {
} }
/** ********************************************************************* /** *********************************************************************
@ -1227,6 +1231,7 @@ void mac_context_new(freerdp* instance, rdpContext* context)
void mac_context_free(freerdp* instance, rdpContext* context) void mac_context_free(freerdp* instance, rdpContext* context)
{ {
} }
/** ********************************************************************* /** *********************************************************************
@ -1235,6 +1240,7 @@ void mac_context_free(freerdp* instance, rdpContext* context)
void mac_set_bounds(rdpContext* context, rdpBounds* bounds) void mac_set_bounds(rdpContext* context, rdpBounds* bounds)
{ {
} }
/** ********************************************************************* /** *********************************************************************
@ -1243,6 +1249,7 @@ void mac_set_bounds(rdpContext* context, rdpBounds* bounds)
void mac_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmap) void mac_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmap)
{ {
} }
/** ********************************************************************* /** *********************************************************************

View File

@ -15,8 +15,8 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
set(MODULE_NAME "wfreerdp") set(MODULE_NAME "wfreerdp-client")
set(MODULE_PREFIX "FREERDP_CLIENT_WINDOWS") set(MODULE_PREFIX "FREERDP_CLIENT_WINDOWS_CONTROL")
set(${MODULE_PREFIX}_SRCS set(${MODULE_PREFIX}_SRCS
wf_gdi.c wf_gdi.c
@ -31,10 +31,19 @@ set(${MODULE_PREFIX}_SRCS
wf_window.h wf_window.h
wf_rail.c wf_rail.c
wf_rail.h wf_rail.h
wfreerdp.c wf_interface.c
wfreerdp.h) wf_interface.h
wfreerdp.rc
resource.h)
if(WITH_CLIENT_INTERFACE)
add_library(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${FREERDP_VERSION} SOVERSION ${FREERDP_API_VERSION} PREFIX "lib")
else()
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} cli/wfreerdp.c cli/wfreerdp.h)
add_executable(${MODULE_NAME} WIN32 ${${MODULE_PREFIX}_SRCS})
endif()
add_executable(${MODULE_NAME} WIN32 ${${MODULE_PREFIX}_SRCS})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client)
@ -50,6 +59,11 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client) if(WITH_CLIENT_INTERFACE)
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
add_subdirectory(cli)
else()
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client)
endif()
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Windows") set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Windows")

BIN
client/Windows/FreeRDP.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -0,0 +1,36 @@
# FreeRDP: A Remote Desktop Protocol Implementation
# FreeRDP Windows cmake build script
#
# Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
#
# 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.
set(MODULE_NAME "wfreerdp")
set(MODULE_PREFIX "FREERDP_CLIENT_WINDOWS")
include_directories(..)
set(${MODULE_PREFIX}_SRCS
wfreerdp.c
wfreerdp.h
../wfreerdp.rc)
add_executable(${MODULE_NAME} WIN32 ${${MODULE_PREFIX}_SRCS})
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} wfreerdp-client)
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Windows")

View File

@ -0,0 +1,70 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* Windows Client
*
* Copyright 2009-2011 Jay Sorg
* Copyright 2010-2011 Vic Lee
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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 <winpr/windows.h>
#include <winpr/crt.h>
#include <winpr/credui.h>
#include <freerdp/freerdp.h>
#include <freerdp/constants.h>
#include <freerdp/utils/event.h>
#include <freerdp/utils/svc_plugin.h>
#include <freerdp/client/file.h>
#include <freerdp/client/cmdline.h>
#include <freerdp/client/channels.h>
#include <freerdp/channels/channels.h>
#include "resource.h"
#include "wf_interface.h"
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
int status;
wfInfo* wfi;
wf_global_init();
wfi = wf_new(hInstance, NULL, __argc, __argv);
status = wf_start(wfi);
if (status < 0)
{
MessageBox(GetConsoleWindow(),
_T("Failed to start wfreerdp.\n\nPlease check the debug output."),
_T("FreeRDP Error"), MB_ICONSTOP);
}
else
{
WaitForSingleObject(wfi->thread, INFINITE);
}
wf_free(wfi);
return 0;
}

View File

@ -0,0 +1,27 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* Windows Client
*
* Copyright 2009-2011 Jay Sorg
* Copyright 2010-2011 Vic Lee
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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 __WFREERDP_H
#define __WFREERDP_H
#include "wf_interface.h"
#endif

View File

@ -0,0 +1,2 @@
#define IDI_ICON1 101

View File

@ -19,7 +19,7 @@
#ifndef __WF_CLIPRDR_H #ifndef __WF_CLIPRDR_H
#define __WF_CLIPRDR_H #define __WF_CLIPRDR_H
#include "wfreerdp.h" #include "wf_interface.h"
void wf_cliprdr_init(wfInfo* wfi, rdpChannels* chanman); void wf_cliprdr_init(wfInfo* wfi, rdpChannels* chanman);
void wf_cliprdr_uninit(wfInfo* wfi); void wf_cliprdr_uninit(wfInfo* wfi);

View File

@ -27,16 +27,15 @@
#include <freerdp/freerdp.h> #include <freerdp/freerdp.h>
#include "wfreerdp.h" #include "wf_interface.h"
#include "wf_gdi.h" #include "wf_gdi.h"
#include "wf_event.h" #include "wf_event.h"
static HWND g_focus_hWnd; static HWND g_focus_hWnd;
extern HCURSOR g_default_cursor;
#define X_POS(lParam) (lParam & 0xffff) #define X_POS(lParam) (lParam & 0xFFFF)
#define Y_POS(lParam) ((lParam >> 16) & 0xffff) #define Y_POS(lParam) ((lParam >> 16) & 0xFFFF)
LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
{ {
@ -57,8 +56,10 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam)
case WM_SYSKEYUP: case WM_SYSKEYUP:
wfi = (wfInfo*) GetWindowLongPtr(g_focus_hWnd, GWLP_USERDATA); wfi = (wfInfo*) GetWindowLongPtr(g_focus_hWnd, GWLP_USERDATA);
p = (PKBDLLHOOKSTRUCT) lParam; p = (PKBDLLHOOKSTRUCT) lParam;
if (!wfi || !p) if (!wfi || !p)
return 1; return 1;
input = wfi->instance->input; input = wfi->instance->input;
rdp_scancode = MAKE_RDP_SCANCODE((BYTE) p->scanCode, p->flags & LLKHF_EXTENDED); rdp_scancode = MAKE_RDP_SCANCODE((BYTE) p->scanCode, p->flags & LLKHF_EXTENDED);
@ -233,7 +234,7 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam
case WM_SETCURSOR: case WM_SETCURSOR:
if (LOWORD(lParam) == HTCLIENT) if (LOWORD(lParam) == HTCLIENT)
SetCursor(g_default_cursor); SetCursor(wfi->hDefaultCursor);
else else
DefWindowProc(hWnd, Msg, wParam, lParam); DefWindowProc(hWnd, Msg, wParam, lParam);
break; break;

View File

@ -22,7 +22,7 @@
#ifndef __WF_EVENT_H #ifndef __WF_EVENT_H
#define __WF_EVENT_H #define __WF_EVENT_H
#include "wfreerdp.h" #include "wf_interface.h"
LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);

View File

@ -35,7 +35,7 @@
#include <freerdp/codec/rfx.h> #include <freerdp/codec/rfx.h>
#include <freerdp/codec/nsc.h> #include <freerdp/codec/nsc.h>
#include "wfreerdp.h" #include "wf_interface.h"
#include "wf_graphics.h" #include "wf_graphics.h"
const BYTE wf_rop2_table[] = const BYTE wf_rop2_table[] =

View File

@ -22,7 +22,7 @@
#ifndef __WF_GDI_H #ifndef __WF_GDI_H
#define __WF_GDI_H #define __WF_GDI_H
#include "wfreerdp.h" #include "wf_interface.h"
void wf_invalidate_region(wfInfo* wfi, int x, int y, int width, int height); void wf_invalidate_region(wfInfo* wfi, int x, int y, int width, int height);
wfBitmap* wf_image_new(wfInfo* wfi, int width, int height, int bpp, BYTE* data); wfBitmap* wf_image_new(wfInfo* wfi, int width, int height, int bpp, BYTE* data);

View File

@ -26,8 +26,6 @@
#include "wf_gdi.h" #include "wf_gdi.h"
#include "wf_graphics.h" #include "wf_graphics.h"
extern HINSTANCE g_hInstance; /* in wfreerdp.c */
HBITMAP wf_create_dib(wfInfo* wfi, int width, int height, int bpp, BYTE* data, BYTE** pdata) HBITMAP wf_create_dib(wfInfo* wfi, int width, int height, int bpp, BYTE* data, BYTE** pdata)
{ {
HDC hdc; HDC hdc;

View File

@ -20,7 +20,7 @@
#ifndef __WF_GRAPHICS_H #ifndef __WF_GRAPHICS_H
#define __WF_GRAPHICS_H #define __WF_GRAPHICS_H
#include "wfreerdp.h" #include "wf_interface.h"
HBITMAP wf_create_dib(wfInfo* wfi, int width, int height, int bpp, BYTE* data, BYTE** pdata); HBITMAP wf_create_dib(wfInfo* wfi, int width, int height, int bpp, BYTE* data, BYTE** pdata);
wfBitmap* wf_image_new(wfInfo* wfi, int width, int height, int bpp, BYTE* data); wfBitmap* wf_image_new(wfInfo* wfi, int width, int height, int bpp, BYTE* data);

View File

@ -53,29 +53,28 @@
#include "wf_graphics.h" #include "wf_graphics.h"
#include "wf_cliprdr.h" #include "wf_cliprdr.h"
#include "wfreerdp.h" #include "wf_interface.h"
struct _thread_data #include "resource.h"
{
freerdp* instance;
};
typedef struct _thread_data thread_data;
HANDLE g_done_event;
HINSTANCE g_hInstance;
HCURSOR g_default_cursor;
volatile int g_thread_count = 0;
LPCTSTR g_wnd_class_name = L"wfreerdp";
void wf_context_new(freerdp* instance, rdpContext* context) void wf_context_new(freerdp* instance, rdpContext* context)
{ {
wfInfo* wfi;
context->channels = freerdp_channels_new(); context->channels = freerdp_channels_new();
wfi = (wfInfo*) malloc(sizeof(wfInfo));
ZeroMemory(wfi, sizeof(wfInfo));
((wfContext*) context)->wfi = wfi;
wfi->instance = instance;
} }
void wf_context_free(freerdp* instance, rdpContext* context) void wf_context_free(freerdp* instance, rdpContext* context)
{ {
if (context->cache) if (context->cache)
cache_free(context->cache); cache_free(context->cache);
freerdp_channels_free(context->channels); freerdp_channels_free(context->channels);
} }
@ -178,6 +177,7 @@ void wf_hw_desktop_resize(rdpContext* context)
wfi->width = settings->DesktopWidth; wfi->width = settings->DesktopWidth;
wfi->height = settings->DesktopHeight; wfi->height = settings->DesktopHeight;
if (wfi->primary) if (wfi->primary)
{ {
same = (wfi->primary == wfi->drawing) ? TRUE : FALSE; same = (wfi->primary == wfi->drawing) ? TRUE : FALSE;
@ -189,6 +189,7 @@ void wf_hw_desktop_resize(rdpContext* context)
if (same) if (same)
wfi->drawing = wfi->primary; wfi->drawing = wfi->primary;
} }
if (wfi->fullscreen != TRUE) if (wfi->fullscreen != TRUE)
{ {
if (wfi->hwnd) if (wfi->hwnd)
@ -210,14 +211,10 @@ BOOL wf_pre_connect(freerdp* instance)
wfContext* context; wfContext* context;
rdpSettings* settings; rdpSettings* settings;
wfi = (wfInfo*) malloc(sizeof(wfInfo));
ZeroMemory(wfi, sizeof(wfInfo));
context = (wfContext*) instance->context; context = (wfContext*) instance->context;
wfi->instance = instance;
context->wfi = wfi;
settings = instance->settings; wfi = context->wfi;
wfi->instance = instance;
settings = instance->settings; settings = instance->settings;
@ -260,8 +257,6 @@ BOOL wf_pre_connect(freerdp* instance)
settings->GlyphSupportLevel = GLYPH_SUPPORT_NONE; settings->GlyphSupportLevel = GLYPH_SUPPORT_NONE;
wfi->cursor = g_default_cursor;
wfi->fullscreen = settings->Fullscreen; wfi->fullscreen = settings->Fullscreen;
wfi->fs_toggle = 1; wfi->fs_toggle = 1;
wfi->sw_gdi = settings->SoftwareGdi; wfi->sw_gdi = settings->SoftwareGdi;
@ -312,7 +307,7 @@ BOOL wf_post_connect(freerdp* instance)
wfInfo* wfi; wfInfo* wfi;
rdpCache* cache; rdpCache* cache;
wfContext* context; wfContext* context;
wchar_t win_title[64]; WCHAR lpWindowName[64];
rdpSettings* settings; rdpSettings* settings;
settings = instance->settings; settings = instance->settings;
@ -359,20 +354,22 @@ BOOL wf_post_connect(freerdp* instance)
} }
if (settings->NSCodec) if (settings->NSCodec)
{
wfi->nsc_context = nsc_context_new(); wfi->nsc_context = nsc_context_new();
}
} }
if (settings->WindowTitle != NULL) if (settings->WindowTitle != NULL)
_snwprintf(win_title, ARRAYSIZE(win_title), L"%S", settings->WindowTitle); _snwprintf(lpWindowName, ARRAYSIZE(lpWindowName), L"%S", settings->WindowTitle);
else if (settings->ServerPort == 3389) else if (settings->ServerPort == 3389)
_snwprintf(win_title, ARRAYSIZE(win_title), L"FreeRDP: %S", settings->ServerHostname); _snwprintf(lpWindowName, ARRAYSIZE(lpWindowName), L"FreeRDP: %S", settings->ServerHostname);
else else
_snwprintf(win_title, ARRAYSIZE(win_title), L"FreeRDP: %S:%d", settings->ServerHostname, settings->ServerPort); _snwprintf(lpWindowName, ARRAYSIZE(lpWindowName), L"FreeRDP: %S:%d", settings->ServerHostname, settings->ServerPort);
if (wfi->hwnd == 0) if (!wfi->hwnd)
{ {
wfi->hwnd = CreateWindowEx((DWORD) NULL, g_wnd_class_name, win_title, wfi->hwnd = CreateWindowEx((DWORD) NULL, wfi->wndClassName, lpWindowName,
0, 0, 0, 0, 0, NULL, NULL, g_hInstance, NULL); 0, 0, 0, 0, 0, wfi->hWndParent, NULL, wfi->hInstance, NULL);
SetWindowLongPtr(wfi->hwnd, GWLP_USERDATA, (LONG_PTR) wfi); SetWindowLongPtr(wfi->hwnd, GWLP_USERDATA, (LONG_PTR) wfi);
} }
@ -525,7 +522,7 @@ BOOL wf_check_fds(freerdp* instance)
return TRUE; return TRUE;
} }
int wfreerdp_run(freerdp* instance) DWORD WINAPI wf_thread(LPVOID lpParam)
{ {
MSG msg; MSG msg;
int index; int index;
@ -537,10 +534,13 @@ int wfreerdp_run(freerdp* instance)
void* wfds[32]; void* wfds[32];
int fds_count; int fds_count;
HANDLE fds[64]; HANDLE fds[64];
freerdp* instance;
rdpChannels* channels; rdpChannels* channels;
memset(rfds, 0, sizeof(rfds)); instance = (freerdp*) lpParam;
memset(wfds, 0, sizeof(wfds));
ZeroMemory(rfds, sizeof(rfds));
ZeroMemory(wfds, sizeof(wfds));
if (freerdp_connect(instance) != TRUE) if (freerdp_connect(instance) != TRUE)
return 0; return 0;
@ -615,6 +615,7 @@ int wfreerdp_run(freerdp* instance)
wf_process_channel_event(channels, instance); wf_process_channel_event(channels, instance);
quit_msg = FALSE; quit_msg = FALSE;
while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{ {
msg_ret = GetMessage(&msg, NULL, 0, 0); msg_ret = GetMessage(&msg, NULL, 0, 0);
@ -641,42 +642,20 @@ int wfreerdp_run(freerdp* instance)
return 0; return 0;
} }
static DWORD WINAPI thread_func(LPVOID lpParam) DWORD WINAPI wf_keyboard_thread(LPVOID lpParam)
{
wfInfo* wfi;
freerdp* instance;
thread_data* data;
data = (thread_data*) lpParam;
instance = data->instance;
wfi = (wfInfo*) malloc(sizeof(wfInfo));
ZeroMemory(wfi, sizeof(wfInfo));
((wfContext*) instance->context)->wfi = wfi;
wfi->instance = instance;
wfreerdp_run(instance);
g_thread_count--;
if (g_thread_count < 1)
SetEvent(g_done_event);
return (DWORD) NULL;
}
static DWORD WINAPI kbd_thread_func(LPVOID lpParam)
{ {
MSG msg; MSG msg;
BOOL status; BOOL status;
wfInfo* wfi;
HHOOK hook_handle; HHOOK hook_handle;
hook_handle = SetWindowsHookEx(WH_KEYBOARD_LL, wf_ll_kbd_proc, g_hInstance, 0); wfi = (wfInfo*) lpParam;
hook_handle = SetWindowsHookEx(WH_KEYBOARD_LL, wf_ll_kbd_proc, wfi->hInstance, 0);
if (hook_handle) if (hook_handle)
{ {
while ((status = GetMessage( &msg, NULL, 0, 0 )) != 0) while ((status = GetMessage(&msg, NULL, 0, 0)) != 0)
{ {
if (status == -1) if (status == -1)
{ {
@ -689,23 +668,22 @@ static DWORD WINAPI kbd_thread_func(LPVOID lpParam)
DispatchMessage(&msg); DispatchMessage(&msg);
} }
} }
UnhookWindowsHookEx(hook_handle); UnhookWindowsHookEx(hook_handle);
} }
else else
{
printf("failed to install keyboard hook\n"); printf("failed to install keyboard hook\n");
}
return (DWORD) NULL; return (DWORD) NULL;
} }
int wf_global_init()
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{ {
freerdp* instance; WSADATA wsaData;
thread_data* data;
WSADATA wsa_data;
WNDCLASSEX wnd_cls;
if (NULL == getenv("HOME")) if (!getenv("HOME"))
{ {
char home[MAX_PATH * 2] = "HOME="; char home[MAX_PATH * 2] = "HOME=";
strcat(home, getenv("HOMEDRIVE")); strcat(home, getenv("HOMEDRIVE"));
@ -713,34 +691,35 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
_putenv(home); _putenv(home);
} }
if (WSAStartup(0x101, &wsa_data) != 0) if (WSAStartup(0x101, &wsaData) != 0)
return 1; return 1;
g_done_event = CreateEvent(0, 1, 0, 0);
#if defined(WITH_DEBUG) || defined(_DEBUG) #if defined(WITH_DEBUG) || defined(_DEBUG)
wf_create_console(); wf_create_console();
#endif #endif
g_default_cursor = LoadCursor(NULL, IDC_ARROW);
wnd_cls.cbSize = sizeof(WNDCLASSEX);
wnd_cls.style = CS_HREDRAW | CS_VREDRAW;
wnd_cls.lpfnWndProc = wf_event_proc;
wnd_cls.cbClsExtra = 0;
wnd_cls.cbWndExtra = 0;
wnd_cls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wnd_cls.hCursor = g_default_cursor;
wnd_cls.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
wnd_cls.lpszMenuName = NULL;
wnd_cls.lpszClassName = g_wnd_class_name;
wnd_cls.hInstance = hInstance;
wnd_cls.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&wnd_cls);
g_hInstance = hInstance;
freerdp_channels_global_init(); freerdp_channels_global_init();
freerdp_register_addin_provider(freerdp_channels_load_static_addin_entry, 0);
return 0;
}
int wf_global_uninit()
{
WSACleanup();
return 0;
}
wfInfo* wf_new(HINSTANCE hInstance, HWND hWndParent, int argc, char** argv)
{
wfInfo* wfi;
freerdp* instance;
if (!hInstance)
hInstance = GetModuleHandle(NULL);
instance = freerdp_new(); instance = freerdp_new();
instance->PreConnect = wf_pre_connect; instance->PreConnect = wf_pre_connect;
instance->PostConnect = wf_post_connect; instance->PostConnect = wf_post_connect;
@ -753,55 +732,68 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
instance->ContextFree = wf_context_free; instance->ContextFree = wf_context_free;
freerdp_context_new(instance); freerdp_context_new(instance);
instance->context->argc = __argc; wfi = ((wfContext*) (instance->context))->wfi;
instance->context->argv = __argv; wfi->instance = instance;
if (!CreateThread(NULL, 0, kbd_thread_func, NULL, 0, NULL)) instance->context->argc = argc;
printf("error creating keyboard handler thread"); instance->context->argv = argv;
//while (1) wfi->hWndParent = hWndParent;
{ wfi->hInstance = hInstance;
int status; wfi->cursor = LoadCursor(NULL, IDC_ARROW);
wfi->icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1));
wfi->wndClassName = _tcsdup(_T("FreeRDP"));
data = (thread_data*) malloc(sizeof(thread_data)); wfi->wndClass.cbSize = sizeof(WNDCLASSEX);
ZeroMemory(data, sizeof(thread_data)); wfi->wndClass.style = CS_HREDRAW | CS_VREDRAW;
wfi->wndClass.lpfnWndProc = wf_event_proc;
wfi->wndClass.cbClsExtra = 0;
wfi->wndClass.cbWndExtra = 0;
wfi->wndClass.hCursor = wfi->cursor;
wfi->wndClass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
wfi->wndClass.lpszMenuName = NULL;
wfi->wndClass.lpszClassName = wfi->wndClassName;
wfi->wndClass.hInstance = hInstance;
wfi->wndClass.hIcon = wfi->icon;
wfi->wndClass.hIconSm = wfi->icon;
RegisterClassEx(&(wfi->wndClass));
data->instance = instance; return wfi;
}
freerdp_register_addin_provider(freerdp_channels_load_static_addin_entry, 0); int wf_start(wfInfo* wfi)
{
int status;
freerdp* instance = wfi->instance;
status = freerdp_client_parse_command_line_arguments(__argc, __argv, instance->settings); wfi->keyboardThread = CreateThread(NULL, 0, wf_keyboard_thread, (void*) wfi, 0, NULL);
freerdp_client_load_addins(instance->context->channels, instance->settings); if (!wfi->keyboardThread)
return -1;
if (status < 0) status = freerdp_client_parse_command_line_arguments(instance->context->argc, instance->context->argv, instance->settings);
{
printf("failed to parse arguments.\n");
#ifdef _DEBUG
system("pause");
#endif
exit(-1);
}
if (CreateThread(NULL, 0, thread_func, data, 0, NULL) != 0) freerdp_client_load_addins(instance->context->channels, instance->settings);
g_thread_count++;
}
if (g_thread_count > 0) wfi->thread = CreateThread(NULL, 0, wf_thread, (void*) instance, 0, NULL);
WaitForSingleObject(g_done_event, INFINITE);
else if (!wfi->thread)
MessageBox(GetConsoleWindow(), return -1;
L"Failed to start wfreerdp.\n\nPlease check the debug output.",
L"FreeRDP Error", MB_ICONSTOP); return 0;
}
int wf_stop(wfInfo* wfi)
{
return 0;
}
int wf_free(wfInfo* wfi)
{
freerdp* instance = wfi->instance;
freerdp_context_free(instance); freerdp_context_free(instance);
freerdp_free(instance); freerdp_free(instance);
WSACleanup();
#ifdef _DEBUG
system("pause");
#endif
return 0; return 0;
} }

View File

@ -19,11 +19,12 @@
* limitations under the License. * limitations under the License.
*/ */
#ifndef __WFREERDP_H #ifndef __WF_INTERFACE_H
#define __WFREERDP_H #define __WF_INTERFACE_H
#include <winpr/windows.h> #include <winpr/windows.h>
#include <freerdp/api.h>
#include <freerdp/freerdp.h> #include <freerdp/freerdp.h>
#include <freerdp/gdi/gdi.h> #include <freerdp/gdi/gdi.h>
#include <freerdp/gdi/dc.h> #include <freerdp/gdi/dc.h>
@ -75,6 +76,16 @@ struct wf_info
int percentscreen; int percentscreen;
char window_title[64]; char window_title[64];
HANDLE thread;
HANDLE keyboardThread;
HICON icon;
HWND hWndParent;
HINSTANCE hInstance;
WNDCLASSEX wndClass;
LPCTSTR wndClassName;
HCURSOR hDefaultCursor;
HWND hwnd; HWND hwnd;
POINT diff; POINT diff;
HGDI_DC hdc; HGDI_DC hdc;
@ -96,4 +107,13 @@ struct wf_info
BOOL sw_gdi; BOOL sw_gdi;
}; };
FREERDP_API int wf_global_init();
FREERDP_API int wf_global_uninit();
FREERDP_API int wf_start(wfInfo* wfi);
FREERDP_API int wf_stop(wfInfo* wfi);
FREERDP_API wfInfo* wf_new(HINSTANCE hInstance, HWND hWndParent, int argc, char** argv);
FREERDP_API int wf_free(wfInfo* wfi);
#endif #endif

View File

@ -19,7 +19,7 @@
#ifndef __WF_RAIL_H #ifndef __WF_RAIL_H
#define __WF_RAIL_H #define __WF_RAIL_H
#include "wfreerdp.h" #include "wf_interface.h"
void wf_rail_paint(wfInfo* wfi, rdpRail* rail, INT32 uleft, INT32 utop, UINT32 uright, UINT32 ubottom); void wf_rail_paint(wfInfo* wfi, rdpRail* rail, INT32 uleft, INT32 utop, UINT32 uright, UINT32 ubottom);
void wf_rail_register_callbacks(wfInfo* wfi, rdpRail* rail); void wf_rail_register_callbacks(wfInfo* wfi, rdpRail* rail);

View File

@ -16,11 +16,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef __WF_WINDOW_H #ifndef __WF_WINDOW_H
#define __WF_WINDOW_H #define __WF_WINDOW_H
#include <freerdp/freerdp.h> #include <freerdp/freerdp.h>
#include "wfreerdp.h" #include "wf_interface.h"
#endif #endif

BIN
client/Windows/wfreerdp.aps Normal file

Binary file not shown.

BIN
client/Windows/wfreerdp.rc Normal file

Binary file not shown.