mfreerdp: integrate benoit's refactored mac client

This commit is contained in:
Marc-André Moreau 2013-05-31 12:48:40 -04:00
parent 2a08093e60
commit 12a46784dd
30 changed files with 4042 additions and 1570 deletions

View File

@ -312,8 +312,8 @@ if(APPLE)
set(DIRECTFB_FEATURE_TYPE "DISABLED") set(DIRECTFB_FEATURE_TYPE "DISABLED")
set(FFMPEG_FEATURE_TYPE "OPTIONAL") set(FFMPEG_FEATURE_TYPE "OPTIONAL")
set(GSTREAMER_FEATURE_TYPE "OPTIONAL") set(GSTREAMER_FEATURE_TYPE "OPTIONAL")
if(IOS)
set(X11_FEATURE_TYPE "DISABLED") set(X11_FEATURE_TYPE "DISABLED")
if(IOS)
set(ALSA_FEATURE_TYPE "DISABLED") set(ALSA_FEATURE_TYPE "DISABLED")
set(PULSE_FEATURE_TYPE "DISABLED") set(PULSE_FEATURE_TYPE "DISABLED")
set(CUPS_FEATURE_TYPE "DISABLED") set(CUPS_FEATURE_TYPE "DISABLED")

View File

@ -1,2 +1,3 @@
*.app *.app
*.framework

View File

@ -1,29 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* MacFreeRDP
*
* Copyright 2012 Thomas Goddard
*
* 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.
*/
#import <Cocoa/Cocoa.h>
#import "MRDPView.h"
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet MRDPView *mrdpView;
@property (assign) IBOutlet NSWindow *window;
int rdp_connect(void);
@end

View File

@ -1,38 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* MacFreeRDP
*
* Copyright 2012 Thomas Goddard
*
* 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.
*/
#import "AppDelegate.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize mrdpView;
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification
{
rdp_connect();
}
- (void) applicationWillTerminate:(NSNotification*)notification
{
//[mrdpView releaseResources];
}
@end

View File

@ -1,74 +1,56 @@
project(MacFreeRDP) project(MacFreeRDP-library)
set(MODULE_NAME "MacFreeRDP") # add directory for App
set(MODULE_PREFIX "FREERDP_CLIENT_MAC") add_subdirectory(cli)
set(FRAMEWORK_HEADERS_PATH /System/Library/Frameworks/Cocoa.framework/Versions/A/Headers/) set(MODULE_NAME "MacFreeRDP-library")
include_directories(${FRAMEWORK_HEADERS_PATH} /System/Library/Frameworks) set(MODULE_PREFIX "FREERDP_CLIENT_MAC-LIB")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mmacosx-version-min=10.4")
set(GUI_TYPE MACOSX_BUNDLE)
# Import libraries
find_library(FOUNDATION_LIBRARY Foundation) find_library(FOUNDATION_LIBRARY Foundation)
find_library(COCOA_LIBRARY Cocoa) find_library(COCOA_LIBRARY Cocoa)
find_library(APPKIT_LIBRARY AppKit) find_library(APPKIT_LIBRARY AppKit)
set(MACOSX_BUNDLE_INFO_STRING "MacFreeRDP") set(MACOSX_BUNDLE_INFO_STRING "MacFreeRDP-library")
set(MACOSX_BUNDLE_ICON_FILE "FreeRDP.icns")
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.freerdp.mac") set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.freerdp.mac")
set(MACOSX_BUNDLE_BUNDLE_IDENTIFIER "FreeRDP.Mac") set(MACOSX_BUNDLE_BUNDLE_IDENTIFIER "FreeRDP-library.Mac")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "MacFreeRDP Version 1.0.1") set(MACOSX_BUNDLE_LONG_VERSION_STRING "MacFreeRDP library Version 1.1")
set(MACOSX_BUNDLE_BUNDLE_NAME "MacFreeRDP") set(MACOSX_BUNDLE_BUNDLE_NAME "MacFreeRDP-library")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING 1.0.1) set(MACOSX_BUNDLE_SHORT_VERSION_STRING 1.1.0)
set(MACOSX_BUNDLE_BUNDLE_VERSION 1.0.1) set(MACOSX_BUNDLE_BUNDLE_VERSION 1.1.0)
set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2012. All Rights Reserved.") set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2013. All Rights Reserved.")
set(MACOSX_BUNDLE_NSMAIN_NIB_FILE "MainMenu")
set(MACOSX_BUNDLE_NSPRINCIPAL_CLASS "NSApplication")
mark_as_advanced(COCOA_LIBRARY FOUNDATION_LIBRARY APPKIT_LIBRARY) mark_as_advanced(COCOA_LIBRARY FOUNDATION_LIBRARY APPKIT_LIBRARY)
set(EXTRA_LIBS ${COCOA_LIBRARY} ${FOUNDATION_LIBRARY} ${APPKIT_LIBRARY}) set(EXTRA_LIBS ${COCOA_LIBRARY} ${FOUNDATION_LIBRARY} ${APPKIT_LIBRARY})
set(APP_TYPE MACOSX_BUNDLE)
set(${MODULE_NAME}_XIBS set(${MODULE_NAME}_RESOURCES "en.lproj/InfoPlist.strings")
MainMenu.xib
PasswordDialog.xib)
set(${MODULE_NAME}_RESOURCES # OS X Interface Builder files
${${MODULE_NAME}_XIBS} file(GLOB ${MODULE_NAME}_XIBS *.xib)
${MACOSX_BUNDLE_ICON_FILE})
set(${MODULE_NAME}_HEADERS # Include XIB file in Xcode resources.
AppDelegate.h if("${CMAKE_GENERATOR}" MATCHES "Xcode")
MRDPCursor.h message(STATUS "Adding Xcode XIB resources for ${MODULE_NAME}")
MRDPRailView.h set(${MODULE_NAME}_RESOURCES ${${MODULE_NAME}_RESOURCES} ${${MODULE_NAME}_XIBS})
MRDPRailWindow.h endif("${CMAKE_GENERATOR}" MATCHES "Xcode")
add_library(${MODULE_NAME}
SHARED
MRDPView.h MRDPView.h
MRDPWindow.h
PasswordDialog.h)
set(${MODULE_NAME}_SOURCES
main.m
AppDelegate.m
MRDPCursor.m
MRDPRailView.m
MRDPRailWindow.m
MRDPView.m MRDPView.m
MRDPWindow.m MRDPCursor.m
PasswordDialog.m) PasswordDialog.m
add_executable(${MODULE_NAME}
${APP_TYPE}
${${MODULE_NAME}_HEADERS}
${${MODULE_NAME}_SOURCES}
${${MODULE_NAME}_RESOURCES}) ${${MODULE_NAME}_RESOURCES})
# This is necessary for the xib file part below # configures the framework to always be looked for in the application bundle in the Frameworks sub-folder.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Info.plist ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) SET_TARGET_PROPERTIES( ${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_INSTALL_PATH @executable_path/../Frameworks/ )
# This allows for automatic xib to nib ibitool set_target_properties( ${MODULE_NAME} PROPERTIES
set_target_properties(${MODULE_NAME} PROPERTIES RESOURCE "${${MODULE_NAME}_RESOURCES}") RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH}
)
# Automatic ref counting # Automatic ref counting
# temporary turn off for x86_64 build issue # temporary turn off for x86_64 build issue
@ -77,14 +59,90 @@ set_target_properties(${MODULE_NAME} PROPERTIES RESOURCE "${${MODULE_NAME}_RESOU
# Support for automatic reference counting requires non-fragile abi. # Support for automatic reference counting requires non-fragile abi.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fobjc-nonfragile-abi") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fobjc-nonfragile-abi")
# XCode project architecture to native architecture of build machine
# -----------------------------------------------------------------------------------------------------
# Issue: Had some issues with FreeRDP project building only 64 bit and
# MacFreeRDP attempting to link to both 32 and 64 for dual target.
# In the future the FreeRDP Xcode project should be pulled in for a couple of reasons:
# 1) better step-into debugging 2) automatic dependency compilation and multi-arch compilation + linkage
# If you know the solutions for 1 and 2, please add below.
set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_ARCHS "$(NATIVE_ARCH_ACTUAL)") set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_ARCHS "$(NATIVE_ARCH_ACTUAL)")
# Set the info plist to the custom instance # Set the info plist to the custom instance
set_target_properties(${MODULE_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) # MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${EXTRA_LIBS}) set(MODULE_VERSION, 1.1.0)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} freerdp-client) set_target_properties(${MODULE_NAME} PROPERTIES
FRAMEWORK TRUE
MACOSX_FRAMEWORK_IDENTIFIER com.awakecoding.${MODULE_NAME}
FRAMEWORK_VERSION 1.1.0
MACOSX_FRAMEWORK_SHORT_VERSION_STRING 1.1.0
MACOSX_FRAMEWORK_BUNDLE_VERSION 1.1.0
PUBLIC_HEADER "MRDPView.h"
INSTALL_NAME_DIR "@executable_path/../../Frameworks"
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist
BUILD_WITH_INSTALL_RPATH 1
)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${EXTRA_LIBS} freerdp-client)
# Set a list of the dependent targets used by the application. There should be a way to get this list automatically
# from cmake, but for now I put it down manually. I got the references by calling
# otool -L MacFreeRDP-client
set(DEPENDENCIES
winpr-asn1
winpr-heap
winpr-sspi
winpr-bcrypt
winpr-input
winpr-sspicli
winpr-credentials
winpr-interlocked
winpr-synch
winpr-credui
winpr-io
winpr-sysinfo
winpr-crt
winpr-library
winpr-thread
winpr-crypto
winpr-timezone
winpr-dsparse
winpr-path
winpr-utils
winpr-environment
winpr-pipe
winpr-winhttp
winpr-error
winpr-pool
winpr-winsock
winpr-file
winpr-registry
winpr-handle
winpr-rpc
freerdp-utils
freerdp-gdi
freerdp-rail
freerdp-cache
freerdp-codec
freerdp-primitives
freerdp-core
freerdp-crypto
freerdp-client
freerdp-locale
freerdp-common
)
## Modify the install name path of the dependent libraries so that they can be located by the bundling app.
# foreach(LIB ${DEPENDENCIES})
# set_target_properties(${LIB} PROPERTIES
# INSTALL_NAME_DIR "@executable_path/../Frameworks/${MODULE_NAME}.framework/Contents"
# BUILD_WITH_INSTALL_RPATH 1
# )
# endforeach()
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD}
MODULE freerdp MODULE freerdp
@ -94,6 +152,67 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHI
MODULE winpr MODULE winpr
MODULES winpr-input winpr-crt winpr-utils) MODULES winpr-input winpr-crt winpr-utils)
set_target_properties(${MODULE_NAME} PROPERTIES LINK_INTERFACE_LIBRARIES "")
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Mac") set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Mac")
# Add a post-build event to copy the dependent libraries in the framework bundle
# Call install_name_tool to reassign the library install name
foreach(LIB ${DEPENDENCIES})
# message("adding post-build dependency: ${LIB}")
add_custom_command(TARGET ${MODULE_NAME} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:${LIB}>"
"${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.framework/Contents/$<TARGET_FILE_NAME:${LIB}>"
COMMENT "Copying ${LIB} to output directory"
COMMAND install_name_tool -change "$<TARGET_SONAME_FILE:${LIB}>" "@executable_path/../Frameworks/${MODULE_NAME}.framework/Contents/$<TARGET_FILE_NAME:${LIB}>" "${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.framework/${MODULE_NAME}"
COMMENT Setting install name for ${LIB}
COMMAND "${CMAKE_COMMAND}" -E echo install_name_tool -change "$<TARGET_SONAME_FILE:${LIB}>" "@executable_path/../Frameworks/${MODULE_NAME}.framework/Contents/$<TARGET_FILE_NAME:${LIB}>" "${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.framework/${MODULE_NAME}"
)
endforeach()
# Call install_name_tool to reassign the library install names in dependent libraries
foreach(DEST ${DEPENDENCIES})
foreach(LIB ${DEPENDENCIES})
# message("adding post-build dependency: ${LIB}")
add_custom_command(TARGET ${MODULE_NAME} POST_BUILD
COMMAND install_name_tool -change "$<TARGET_SONAME_FILE:${LIB}>" "@executable_path/../Frameworks/${MODULE_NAME}.framework/Contents/$<TARGET_FILE_NAME:${LIB}>" "${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.framework/Contents/$<TARGET_FILE_NAME:${DEST}>"
COMMENT Setting install name for ${LIB} in module ${DEST}
)
# COMMAND "${CMAKE_COMMAND}" -E echo install_name_tool -change "$<TARGET_SONAME_FILE:${LIB}>" #"@executable_path/../Frameworks/${MODULE_NAME}.framework/Contents/$<TARGET_FILE_NAME:${LIB}>" #"${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.framework/Contents/$<TARGET_FILE_NAME:${DEST}>"
# )
endforeach()
endforeach()
# Add post-build NIB file generation in unix makefiles. XCode handles this implicitly.
if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
message(STATUS "Adding post-build NIB file generation event for ${MODULE_NAME}")
# Make sure we can find the 'ibtool' program. If we can NOT find it we
# skip generation of this project
find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
if (${IBTOOL} STREQUAL "IBTOOL-NOTFOUND")
message(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files. It should have been installed with
the Apple developer tools. The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin")
endif()
# Make sure the 'Resources' Directory is correctly created before we build
add_custom_command (TARGET ${MODULE_NAME} PRE_BUILD
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.app/Contents/Resources)
# Compile the .xib files using the 'ibtool' program with the destination being the app package
foreach(xib ${${MODULE_NAME}_XIBS})
get_filename_component(XIB_WE ${xib} NAME_WE)
add_custom_command (TARGET ${MODULE_NAME} POST_BUILD
COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text
--compile ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.app/Contents/Resources/${XIB_WE}.nib ${xib}
COMMENT "Compiling ${xib}")
endforeach()
endif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")

View File

@ -3,11 +3,9 @@
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>English</string>
<key>CFBundleExecutable</key>
<string></string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>FreeRDP</string> <string></string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>FreeRDP.Mac</string> <string>FreeRDP.Mac</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
@ -15,20 +13,14 @@
<key>CFBundleName</key> <key>CFBundleName</key>
<string></string> <string></string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.0</string> <string>1.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1</string> <string>1</string>
<key>LSMinimumSystemVersion</key>
<string></string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012 FreeRDP Open Source Project.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>
<string>NSApplication</string> <string></string>
</dict> </dict>
</plist> </plist>

View File

@ -1,76 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* MacFreeRDP
*
* Copyright 2012 Thomas Goddard
*
* 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.
*/
#import <Cocoa/Cocoa.h>
#import "freerdp/gdi/gdi.h"
#import "freerdp/rail/rail.h"
#import "MRDPRailWindow.h"
@interface MRDPRailView : NSView
{
freerdp* rdp_instance;
rdpContext* context;
NSBitmapImageRep* bmiRep;
NSPoint savedDragLocation;
char* pixelData;
BOOL mouseInClientArea;
BOOL titleBarClicked;
BOOL gestureEventInProgress;
int width;
int height;
int savedWindowId;
int scrollWheelCount;
int kdlshift;
int kdrshift;
int kdlctrl;
int kdrctrl;
int kdlalt;
int kdralt;
int kdlmeta;
int kdrmeta;
int kdcapslock;
@public
BOOL isMoveSizeInProgress;
BOOL saveInitialDragLoc;
BOOL skipMoveWindowOnce;
int localMoveType;
}
@property (assign) MRDPRailWindow* mrdpRailWindow;
@property (assign) int windowIndex;
@property (assign) BOOL activateWindow;
- (void) windowDidMove:(NSNotification*) notification;
- (void) updateDisplay;
- (void) setRdpInstance:(freerdp*) instance width:(int) w andHeight:(int) h windowID:(int) windowID;
- (void) setupBmiRep:(int) width :(int) height;
- (void) releaseResources;
void mac_rail_MoveWindow(rdpRail* rail, rdpWindow* window);
void apple_to_windowMove(NSRect* r, RAIL_WINDOW_MOVE_ORDER* windowMove);
void mac_send_rail_client_event(rdpChannels* channels, UINT16 event_type, void* param);
void windows_to_apple_cords(NSRect* r);
void rail_MoveWindow(rdpRail* rail, rdpWindow* window);
void mac_rail_send_activate(int window_id);
@end

View File

@ -1,930 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* MacFreeRDP
*
* Copyright 2012 Thomas Goddard
*
* 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 "MRDPRailView.h"
#define USE_RAIL_CVT
@implementation MRDPRailView
@synthesize mrdpRailWindow, windowIndex, activateWindow;
MRDPRailView* g_mrdpRailView;
- (void) updateDisplay
{
BOOL moveWindow = NO;
NSRect srcRectOuter;
NSRect destRectOuter;
rdpGdi* gdi;
if ((context == 0) || (context->gdi == 0))
return;
if (context->gdi->primary->hdc->hwnd->invalid->null)
return;
if (context->gdi->drawing != context->gdi->primary)
return;
gdi = context->gdi;
srcRectOuter = NSMakeRect(0, 0, self->width, self->height);
destRectOuter = [[self window] frame];
// cannot be bigger than our current screen size
NSRect screenSize = [[NSScreen mainScreen] frame];
if (destRectOuter.size.width > screenSize.size.width)
{
destRectOuter.size.width = screenSize.size.width;
moveWindow = YES;
}
if (destRectOuter.size.height > screenSize.size.height)
{
destRectOuter.size.height = screenSize.size.height;
moveWindow = YES;
}
if (destRectOuter.origin.x + destRectOuter.size.width > width)
destRectOuter.size.width = width - destRectOuter.origin.x;
[self setupBmiRep:destRectOuter.size.width :destRectOuter.size.height];
if (moveWindow)
{
moveWindow = NO;
RAIL_WINDOW_MOVE_ORDER newWndLoc;
apple_to_windowMove(&destRectOuter, &newWndLoc);
newWndLoc.windowId = savedWindowId;
//skipMoveWindowOnce = TRUE;
//mac_send_rail_client_event(g_mrdpRailView->rdp_instance->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &newWndLoc);
}
destRectOuter.origin.y = height - destRectOuter.origin.y - destRectOuter.size.height;
rail_convert_color_space(pixelData, (char *) gdi->primary_buffer,
&destRectOuter, self->width, self->height);
if (moveWindow)
[self setNeedsDisplayInRect:destRectOuter];
else
[self setNeedsDisplayInRect:[self frame]];
gdi->primary->hdc->hwnd->ninvalid = 0;
}
/** *********************************************************************
* called when our view needs to be redrawn
***********************************************************************/
- (void) drawRect:(NSRect)dirtyRect
{
[bmiRep drawInRect:dirtyRect fromRect:dirtyRect operation:NSCompositeCopy fraction:1.0 respectFlipped:NO hints:nil];
if (pixelData)
{
free(pixelData);
pixelData = NULL;
}
bmiRep = nil;
}
/** *********************************************************************
* become first responder so we can get keyboard and mouse events
***********************************************************************/
- (BOOL)acceptsFirstResponder
{
return YES;
}
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
{
return NO;
}
/** *********************************************************************
* called when a mouse move event occurs
*
* ideally we want to be called when the mouse moves over NSView client area,
* but in reality we get called any time the mouse moves anywhere on the screen;
* we could use NSTrackingArea class to handle this but this class is available
* on Mac OS X v10.5 and higher; since we want to be compatible with older
* versions, we do this manually.
*
* TODO: here is how it can be done using legacy methods
* http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/MouseTrackingEvents/MouseTrackingEvents.html#//apple_ref/doc/uid/10000060i-CH11-SW1
***********************************************************************/
- (void) mouseMoved:(NSEvent *)event
{
[super mouseMoved:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y);
y = height - y;
/* send mouse motion event to RDP server */
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y);
}
/** *********************************************************************
* called when left mouse button is pressed down
***********************************************************************/
- (void)mouseDown:(NSEvent *) event
{
[super mouseDown:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y);
int yPos = (int) (winFrame.size.height - loc.y);
y = height - y;
if ((yPos >= 4) && (yPos <= 20))
titleBarClicked = YES;
else
titleBarClicked = NO;
savedDragLocation.x = loc.x;
savedDragLocation.y = loc.y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, x, y);
}
/** *********************************************************************
* called when left mouse button is released
***********************************************************************/
- (void) mouseUp:(NSEvent *) event
{
[super mouseUp:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y);
y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON1, x, y);
titleBarClicked = NO;
}
/** *********************************************************************
* called when right mouse button is pressed down
***********************************************************************/
- (void) rightMouseDown:(NSEvent *)event
{
[super rightMouseDown:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y);
y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, x, y);
}
/** *********************************************************************
* called when right mouse button is released
***********************************************************************/
- (void) rightMouseUp:(NSEvent *)event
{
[super rightMouseUp:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y);
y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON2, x, y);
}
/** *********************************************************************
* called when middle mouse button is pressed
***********************************************************************/
- (void) otherMouseDown:(NSEvent *)event
{
[super otherMouseDown:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y);
y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON3, x, y);
}
/** *********************************************************************
* called when middle mouse button is released
***********************************************************************/
- (void) otherMouseUp:(NSEvent *)event
{
[super otherMouseUp:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) (winFrame.origin.x + loc.x);
int y = (int) (winFrame.origin.y + loc.y);
y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON3, x, y);
}
- (void) scrollWheel:(NSEvent *)event
{
uint16 flags;
[super scrollWheel:event];
// we get more two finger trackpad scroll events
// than scrollWheel events, so we drop some
if (gestureEventInProgress)
{
scrollWheelCount++;
if (scrollWheelCount % 8 != 0)
return;
}
if ([event scrollingDeltaY] < 0)
{
flags = PTR_FLAGS_WHEEL | PTR_FLAGS_WHEEL_NEGATIVE | 0x0088;
}
else
{
flags = PTR_FLAGS_WHEEL | 0x78;
}
rdp_instance->input->MouseEvent(rdp_instance->input, flags, 0, 0);
}
/** *********************************************************************
* called when mouse is moved with left button pressed
* note: invocation order is: mouseDown, mouseDragged, mouseUp
***********************************************************************/
- (void) mouseDragged:(NSEvent *)event
{
[super mouseDragged:event];
NSRect winFrame = [[self window] frame];
NSPoint loc = [event locationInWindow];
int x = (int) loc.x;
int y = (int) loc.y;
if (titleBarClicked)
{
// window is being dragged to a new location
int newX = x - savedDragLocation.x;
int newY = y - savedDragLocation.y;
if ((newX == 0) && (newY == 0))
return;
winFrame.origin.x += newX;
winFrame.origin.y += newY;
[[self window] setFrame:winFrame display:YES];
return;
}
if (localMoveType == RAIL_WMSZ_LEFT)
{
// left border resize taking place
int diff = (int) (loc.x - savedDragLocation.x);
if (diff == 0)
return;
if (diff < 0)
{
diff = abs(diff);
winFrame.origin.x -= diff;
winFrame.size.width += diff;
}
else
{
winFrame.origin.x += diff;
winFrame.size.width -= diff;
}
[[self window] setFrame:winFrame display:YES];
return;
}
if (localMoveType == RAIL_WMSZ_RIGHT)
{
// right border resize taking place
int diff = (int) (loc.x - savedDragLocation.x);
if (diff == 0)
return;
savedDragLocation.x = loc.x;
savedDragLocation.y = loc.y;
winFrame.size.width += diff;
[[self window] setFrame:winFrame display:YES];
return;
}
if (localMoveType == RAIL_WMSZ_TOP)
{
// top border resize taking place
int diff = (int) (loc.y - savedDragLocation.y);
if (diff == 0)
return;
savedDragLocation.x = loc.x;
savedDragLocation.y = loc.y;
winFrame.size.height += diff;
[[self window] setFrame:winFrame display:YES];
return;
}
if (localMoveType == RAIL_WMSZ_BOTTOM)
{
// bottom border resize taking place
int diff = (int) (loc.y - savedDragLocation.y);
if (diff == 0)
return;
if (diff < 0)
{
diff = abs(diff);
winFrame.origin.y -= diff;
winFrame.size.height += diff;
}
else
{
winFrame.origin.y += diff;
winFrame.size.height -= diff;
}
[[self window] setFrame:winFrame display:YES];
return;
}
if (localMoveType == RAIL_WMSZ_TOPLEFT)
{
// top left border resize taking place
int diff = (int) (loc.x - savedDragLocation.x);
if (diff != 0)
{
if (diff < 0)
{
diff = abs(diff);
winFrame.origin.x -= diff;
winFrame.size.width += diff;
}
else
{
winFrame.origin.x += diff;
winFrame.size.width -= diff;
}
}
diff = (int) (loc.y - savedDragLocation.y);
if (diff != 0)
{
savedDragLocation.y = loc.y;
winFrame.size.height += diff;
}
[[self window] setFrame:winFrame display:YES];
return;
}
if (localMoveType == RAIL_WMSZ_TOPRIGHT)
{
// top right border resize taking place
int diff = (int) (loc.x - savedDragLocation.x);
if (diff != 0)
winFrame.size.width += diff;
diff = (int) (loc.y - savedDragLocation.y);
if (diff != 0)
winFrame.size.height += diff;
savedDragLocation.x = loc.x;
savedDragLocation.y = loc.y;
[[self window] setFrame:winFrame display:YES];
return;
}
if (localMoveType == RAIL_WMSZ_BOTTOMLEFT)
{
// bottom left border resize taking place
int diff = (int) (loc.x - savedDragLocation.x);
if (diff != 0)
{
if (diff < 0)
{
diff = abs(diff);
winFrame.origin.x -= diff;
winFrame.size.width += diff;
}
else
{
winFrame.origin.x += diff;
winFrame.size.width -= diff;
}
}
diff = (int) (loc.y - savedDragLocation.y);
if (diff != 0)
{
if (diff < 0)
{
diff = abs(diff);
winFrame.origin.y -= diff;
winFrame.size.height += diff;
}
else
{
winFrame.origin.y += diff;
winFrame.size.height -= diff;
}
}
[[self window] setFrame:winFrame display:YES];
return;
}
if (localMoveType == RAIL_WMSZ_BOTTOMRIGHT)
{
// bottom right border resize taking place
int diff = (int) (loc.x - savedDragLocation.x);
if (diff != 0)
{
savedDragLocation.x = loc.x;
//savedDragLocation.y = loc.y;
winFrame.size.width += diff;
}
diff = (int) (loc.y - savedDragLocation.y);
if (diff != 0)
{
if (diff < 0)
{
diff = abs(diff);
winFrame.origin.y -= diff;
winFrame.size.height += diff;
}
else
{
winFrame.origin.y += diff;
winFrame.size.height -= diff;
}
}
[[self window] setFrame:winFrame display:YES];
return;
}
x = (int) (winFrame.origin.x + loc.x);
y = (int) (winFrame.origin.y + loc.y);
y = height - y;
// send mouse motion event to RDP server
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y);
}
/** *********************************************************************
* called when a key is pressed
***********************************************************************/
- (void) keyDown:(NSEvent *) event
{
int key;
USHORT extended;
DWORD vkcode;
DWORD scancode;
key = [event keyCode] + 8;
vkcode = GetVirtualKeyCodeFromKeycode(key, KEYCODE_TYPE_APPLE);
scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4);
extended = (scancode & KBDEXT) ? KBDEXT : 0;
rdp_instance->input->KeyboardEvent(rdp_instance->input, extended | KBD_FLAGS_DOWN, scancode & 0xFF);
}
/** *********************************************************************
* called when a key is released
***********************************************************************/
- (void) keyUp:(NSEvent *) event
{
int key;
USHORT extended;
DWORD vkcode;
DWORD scancode;
key = [event keyCode] + 8;
vkcode = GetVirtualKeyCodeFromKeycode(key, KEYCODE_TYPE_APPLE);
scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4);
extended = (scancode & KBDEXT) ? TRUE : FALSE;
rdp_instance->input->KeyboardEvent(rdp_instance->input, extended | KBD_FLAGS_RELEASE, scancode & 0xFF);
}
/** *********************************************************************
* called when shift, control, alt and meta keys are pressed/released
***********************************************************************/
- (void) flagsChanged:(NSEvent *) event
{
NSUInteger mf = [event modifierFlags];
// caps lock
if (mf == 0x10100) {
printf("TODO: caps lock is on\n");
kdcapslock = 1;
}
if (kdcapslock && (mf == 0x100)) {
kdcapslock = 0;
printf("TODO: caps lock is off\n");
}
// left shift
if ((kdlshift == 0) && ((mf & 2) != 0)) {
// left shift went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x2a);
kdlshift = 1;
}
if ((kdlshift != 0) && ((mf & 2) == 0)) {
// left shift went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x2a);
kdlshift = 0;
}
// right shift
if ((kdrshift == 0) && ((mf & 4) != 0)) {
// right shift went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x36);
kdrshift = 1;
}
if ((kdrshift != 0) && ((mf & 4) == 0)) {
// right shift went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x36);
kdrshift = 0;
}
// left ctrl
if ((kdlctrl == 0) && ((mf & 1) != 0)) {
// left ctrl went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x1d);
kdlctrl = 1;
}
if ((kdlctrl != 0) && ((mf & 1) == 0)) {
// left ctrl went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x1d);
kdlctrl = 0;
}
// right ctrl
if ((kdrctrl == 0) && ((mf & 0x2000) != 0)) {
// right ctrl went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x1d);
kdrctrl = 1;
}
if ((kdrctrl != 0) && ((mf & 0x2000) == 0)) {
// right ctrl went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x1d);
kdrctrl = 0;
}
// left alt
if ((kdlalt == 0) && ((mf & 0x20) != 0)) {
// left alt went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x38);
kdlalt = 1;
}
if ((kdlalt != 0) && ((mf & 0x20) == 0)) {
// left alt went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x38);
kdlalt = 0;
}
// right alt
if ((kdralt == 0) && ((mf & 0x40) != 0)) {
// right alt went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x38);
kdralt = 1;
}
if ((kdralt != 0) && ((mf & 0x40) == 0)) {
// right alt went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x38);
kdralt = 0;
}
// left meta
if ((kdlmeta == 0) && ((mf & 0x08) != 0)) {
// left meta went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x5b);
kdlmeta = 1;
}
if ((kdlmeta != 0) && ((mf & 0x08) == 0)) {
// left meta went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x5b);
kdlmeta = 0;
}
// right meta
if ((kdrmeta == 0) && ((mf & 0x10) != 0)) {
// right meta went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x5c);
kdrmeta = 1;
}
if ((kdrmeta != 0) && ((mf & 0x10) == 0)) {
// right meta went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x5c);
kdrmeta = 0;
}
}
- (void) setRdpInstance:(freerdp *) instance width:(int) w andHeight:(int) h windowID:(int) windowID
{
rdp_instance = instance;
context = instance->context;
width = w;
height = h;
savedWindowId = windowID;
NSRect tr = NSMakeRect(0, 0,
[[NSScreen mainScreen] frame].size.width,
[[NSScreen mainScreen] frame].size.height);
NSTrackingArea * trackingArea = [[NSTrackingArea alloc] initWithRect:tr options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag | NSTrackingActiveAlways owner:self userInfo:nil];
[self addTrackingArea:trackingArea];
g_mrdpRailView = self;
[self becomeFirstResponder];
[self setAcceptsTouchEvents:YES];
// we want to be notified when window resizes....
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:nil];
// ...moves
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidMove:) name:NSWindowDidMoveNotification object:nil];
// ...and becomes the key window
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:nil];
}
- (void) setupBmiRep:(int) frameWidth :(int) frameHeight
{
struct rgba_data
{
char red;
char green;
char blue;
char alpha;
};
if (pixelData)
free(pixelData);
pixelData = (char *) malloc(frameWidth * frameHeight * sizeof(struct rgba_data));
bmiRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned char **) &pixelData
pixelsWide:frameWidth
pixelsHigh:frameHeight
bitsPerSample:8
samplesPerPixel:sizeof(struct rgba_data)
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bitmapFormat:0
bytesPerRow:frameWidth * sizeof(struct rgba_data)
bitsPerPixel:0];
}
- (void) beginGestureWithEvent:(NSEvent *)event
{
gestureEventInProgress = YES;
}
- (void) endGestureWithEvent:(NSEvent *)event
{
gestureEventInProgress = NO;
}
/**
* called when a bordered window changes size
*/
- (void) windowDidResize:(NSNotification *) notification
{
// if we are not the source of this notification, just return
if ([notification object] != [self mrdpRailWindow])
return;
// let RDP server know that window has moved
RAIL_WINDOW_MOVE_ORDER windowMove;
NSRect r = [[self window] frame];
int diffInHeight = [[self window] frame].size.height - [self frame].size.height;
r.size.height -= diffInHeight;
apple_to_windowMove(&r, &windowMove);
windowMove.windowId = self->savedWindowId;
mac_send_rail_client_event(self->context->channels, RailChannel_ClientWindowMove, &windowMove);
}
/**
* called when user moves a bordered window
*/
- (void) windowDidMove:(NSNotification *) notification
{
// if we are not the source of this notification, just return
if ([notification object] != [self mrdpRailWindow])
return;
// let RDP server know that window has moved
RAIL_WINDOW_MOVE_ORDER windowMove;
NSRect r = [[self window] frame];
int diffInHeight = [[self window] frame].size.height - [self frame].size.height;
r.size.height -= diffInHeight;
apple_to_windowMove(&r, &windowMove);
windowMove.windowId = self->savedWindowId;
mac_send_rail_client_event(self->context->channels, RailChannel_ClientWindowMove, &windowMove);
}
/**
* called when a NSWindow becomes the key window
*/
- (void) windowDidBecomeKey:(NSNotification *) notification
{
// if we are not the source of this notification, just return
if ([notification object] != [self mrdpRailWindow])
return;
if (![self activateWindow])
return;
[[self window] setAcceptsMouseMovedEvents: YES];
//if ([self activateWindow])
mac_rail_send_activate(savedWindowId);
// set_current_window(windowIndex); // ? code mis-merge?
}
- (void) releaseResources
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
void rail_cvt_from_rect(char* dest, char* src, NSRect destRect, int destWidth, int destHeight, NSRect srcRect)
{
}
/** *********************************************************************
* color space conversion used specifically in RAIL
***********************************************************************/
void rail_convert_color_space(char* destBuf, char* srcBuf, NSRect* destRect, int width, int height)
{
int i;
int j;
int numRows;
int srcX;
int srcY;
int destX;
int destY;
int pixelsPerRow;
int pixel;
int pixel1;
int pixel2;
int * src32;
int * dest32;
int destWidth = destRect->size.width;
int destHeight = destRect->size.height;
if ((!destBuf) || (!srcBuf))
return;
numRows = (destRect->origin.y + destHeight > height) ? height - destRect->origin.y : destHeight;
pixelsPerRow = destWidth;
srcX = destRect->origin.x;
srcY = destRect->origin.y;
destX = 0;
destY = 0;
for (i = 0; i < numRows; i++)
{
src32 = (int *) (srcBuf + ((srcY + i) * width + srcX) * 4);
dest32 = (int *) (destBuf + ((destY + i) * destWidth + destX) * 4);
for (j = 0; j < pixelsPerRow; j++)
{
pixel = *src32;
pixel1 = (pixel & 0x00ff0000) >> 16;
pixel2 = (pixel & 0x000000ff) << 16;
pixel = (pixel & 0xff00ff00) | pixel1 | pixel2;
*dest32 = pixel;
src32++;
dest32++;
}
}
destRect->origin.y = destHeight - destRect->origin.y - destRect->size.height;
return;
}
/**
* let RDP server know that window has moved
*/
void rail_MoveWindow(rdpRail * rail, rdpWindow * window)
{
if (g_mrdpRailView->isMoveSizeInProgress)
return;
if (g_mrdpRailView->skipMoveWindowOnce)
{
g_mrdpRailView->skipMoveWindowOnce = NO;
return;
}
// this rect is based on Windows co-ordinates...
NSRect r;
r.origin.x = window->windowOffsetX;
r.origin.y = window->windowOffsetY;
r.size.width = window->windowWidth;
r.size.height = window->windowHeight;
windows_to_apple_cords(&r);
[[g_mrdpRailView window] setFrame:r display:YES];
}
void mac_rail_send_activate(int window_id)
{
RAIL_ACTIVATE_ORDER activate;
activate.windowId = window_id;
activate.enabled = 1;
mac_send_rail_client_event(g_mrdpRailView->context->channels, RailChannel_ClientActivate, &activate);
}
@end

View File

@ -1,24 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* MacFreeRDP
*
* Copyright 2012 Thomas Goddard
*
* 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.
*/
#import <Cocoa/Cocoa.h>
@interface MRDPRailWindow : NSWindow
@end

View File

@ -1,29 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* MacFreeRDP
*
* Copyright 2012 Thomas Goddard
*
* 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.
*/
#import "MRDPRailWindow.h"
@implementation MRDPRailWindow
- (BOOL) canBecomeKeyWindow
{
return YES;
}
@end

View File

@ -19,7 +19,11 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#ifdef HAVE_RAIL
#import "MRDPWindow.h" #import "MRDPWindow.h"
#endif
/*
#import "freerdp/freerdp.h" #import "freerdp/freerdp.h"
#import "freerdp/types.h" #import "freerdp/types.h"
#import "freerdp/channels/channels.h" #import "freerdp/channels/channels.h"
@ -32,6 +36,9 @@
#import "freerdp/rail/rail.h" #import "freerdp/rail/rail.h"
#import "freerdp/rail.h" #import "freerdp/rail.h"
#import "freerdp/utils/rail.h" #import "freerdp/utils/rail.h"
*/
@interface MRDPView : NSView @interface MRDPView : NSView
{ {
@ -43,8 +50,8 @@
NSTimer* pasteboard_timer; NSTimer* pasteboard_timer;
NSRect prevWinPosition; NSRect prevWinPosition;
int titleBarHeight; int titleBarHeight;
freerdp* rdp_instance; void* rdp_instance;
rdpContext* rdp_context; void* rdp_context;
CGContextRef bitmap_context; CGContextRef bitmap_context;
char* pixel_data; char* pixel_data;
int width; int width;
@ -52,8 +59,11 @@
int argc; int argc;
char** argv; char** argv;
/* RemoteApp */ #ifdef HAVE_RAIL
// RemoteApp
MRDPWindow* currentWindow; MRDPWindow* currentWindow;
#endif
NSPoint savedDragLocation; NSPoint savedDragLocation;
BOOL mouseInClientArea; BOOL mouseInClientArea;
BOOL isRemoteApp; BOOL isRemoteApp;
@ -76,16 +86,17 @@
@public @public
NSWindow* ourMainWindow; NSWindow* ourMainWindow;
NSPasteboard* pasteboard_rd; NSPasteboard* pasteboard_rd; /* for reading from clipboard */
NSPasteboard* pasteboard_wr; NSPasteboard* pasteboard_wr; /* for writing to clipboard */
int pasteboard_changecount; int pasteboard_changecount;
int pasteboard_format; int pasteboard_format;
int is_connected; int is_connected;
} }
- (int) rdpConnect;
- (void) rdpConnectError; - (void) rdpConnectError;
- (void) rdpRemoteAppError; - (void) rdpRemoteAppError;
- (void) saveStateInfo :(freerdp *) instance :(rdpContext *) context; - (void) saveStateInfo :(void *) instance :(void *) context;
- (void) onPasteboardTimerFired :(NSTimer *) timer; - (void) onPasteboardTimerFired :(NSTimer *) timer;
- (void) releaseResources; - (void) releaseResources;
- (void) setViewSize : (int) width : (int) height; - (void) setViewSize : (int) width : (int) height;
@ -103,79 +114,3 @@
#define PTR_FLAGS_BUTTON2 0x2000 #define PTR_FLAGS_BUTTON2 0x2000
#define PTR_FLAGS_BUTTON3 0x4000 #define PTR_FLAGS_BUTTON3 0x4000
#define WheelRotationMask 0x01FF #define WheelRotationMask 0x01FF
void mf_Pointer_New(rdpContext* context, rdpPointer* pointer);
void mf_Pointer_Free(rdpContext* context, rdpPointer* pointer);
void mf_Pointer_Set(rdpContext* context, rdpPointer* pointer);
void mf_Pointer_SetNull(rdpContext* context);
void mf_Pointer_SetDefault(rdpContext* context);
int rdp_connect(void);
BOOL mac_pre_connect(freerdp* instance);
BOOL mac_post_connect(freerdp* instance);
BOOL mac_authenticate(freerdp* instance, char** username, char** password, char** domain);
void mac_context_new(freerdp* instance, rdpContext* context);
void mac_context_free(freerdp* instance, rdpContext* context);
void mac_set_bounds(rdpContext* context, rdpBounds* bounds);
void mac_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmap);
void mac_begin_paint(rdpContext* context);
void mac_end_paint(rdpContext* context);
void mac_save_state_info(freerdp* instance, rdpContext* context);
void skt_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void* data, void* info);
void channel_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void* data, void* info);
int register_fds(int* fds, int count, void* instance);
int invoke_draw_rect(rdpContext* context);
int process_plugin_args(rdpSettings* settings, const char* name, RDP_PLUGIN_DATA* plugin_data, void* user_data);
int receive_channel_data(freerdp* instance, int chan_id, BYTE* data, int size, int flags, int total_size);
void process_cliprdr_event(freerdp* instance, wMessage* event);
void cliprdr_process_cb_format_list_event(freerdp* instance, RDP_CB_FORMAT_LIST_EVENT* event);
void cliprdr_send_data_request(freerdp* instance, UINT32 format);
void cliprdr_process_cb_monitor_ready_event(freerdp* inst);
void cliprdr_process_cb_data_response_event(freerdp* instance, RDP_CB_DATA_RESPONSE_EVENT* event);
void cliprdr_process_text(freerdp* instance, BYTE* data, int len);
void cliprdr_send_supported_format_list(freerdp* instance);
int register_channel_fds(int* fds, int count, void* instance);
void mac_process_rail_event(freerdp* instance, wMessage* event);
void mac_rail_register_callbacks(freerdp* instance, rdpRail* rail);
void mac_rail_CreateWindow(rdpRail* rail, rdpWindow* window);
void mac_rail_MoveWindow(rdpRail* rail, rdpWindow* window);
void mac_rail_ShowWindow(rdpRail* rail, rdpWindow* window, BYTE state);
void mac_rail_SetWindowText(rdpRail* rail, rdpWindow* window);
void mac_rail_SetWindowIcon(rdpRail* rail, rdpWindow* window, rdpIcon* icon);
void mac_rail_SetWindowRects(rdpRail* rail, rdpWindow* window);
void mac_rail_SetWindowVisibilityRects(rdpRail* rail, rdpWindow* window);
void mac_rail_DestroyWindow(rdpRail* rail, rdpWindow* window);
void mac_process_rail_get_sysparams_event(rdpChannels* channels, wMessage* event);
void mac_send_rail_client_event(rdpChannels* channels, UINT16 event_type, void* param);
void mac_on_free_rail_client_event(wMessage* event);
void mac_process_rail_server_sysparam_event(rdpChannels* channels, wMessage* event);
void mac_process_rail_exec_result_event(rdpChannels* channels, wMessage* event);
void mac_rail_enable_remoteapp_mode(void);
void mac_process_rail_server_minmaxinfo_event(rdpChannels* channels, wMessage* event);
void mac_process_rail_server_localmovesize_event(freerdp* instance, wMessage* event);
void apple_center_window(NSRect* r);
void apple_to_windowMove(NSRect* r, RAIL_WINDOW_MOVE_ORDER* windowMove);
struct mac_context
{
rdpContext _p;
};
struct cursor
{
rdpPointer* pointer;
BYTE* cursor_data;
void* bmiRep; /* NSBitmapImageRep */
void* nsCursor; /* NSCursor */
void* nsImage; /* NSImage */
};
struct rgba_data
{
char red;
char green;
char blue;
char alpha;
};

View File

@ -51,9 +51,113 @@
#include <freerdp/constants.h> #include <freerdp/constants.h>
#import "freerdp/freerdp.h"
#import "freerdp/types.h"
#import "freerdp/channels/channels.h"
#import "freerdp/gdi/gdi.h"
#import "freerdp/graphics.h"
#import "freerdp/utils/event.h"
#import "freerdp/client/cliprdr.h"
#import "freerdp/client/file.h"
#import "freerdp/client/cmdline.h"
#import "freerdp/rail/rail.h"
#import "freerdp/rail.h"
#import "freerdp/utils/rail.h"
#ifdef HAVE_RAIL
#import "MRDPWindow.h"
#endif
// RAIL_TODO DELETE WHEN DONE TESTING // RAIL_TODO DELETE WHEN DONE TESTING
#define MRDP_DRAW_INDIVIDUAL_RECTS #define MRDP_DRAW_INDIVIDUAL_RECTS
/******************************************
Forward declarations
******************************************/
void mf_Pointer_New(rdpContext* context, rdpPointer* pointer);
void mf_Pointer_Free(rdpContext* context, rdpPointer* pointer);
void mf_Pointer_Set(rdpContext* context, rdpPointer* pointer);
void mf_Pointer_SetNull(rdpContext* context);
void mf_Pointer_SetDefault(rdpContext* context);
// int rdp_connect(void);
BOOL mac_pre_connect(freerdp* instance);
BOOL mac_post_connect(freerdp* instance);
BOOL mac_authenticate(freerdp* instance, char** username, char** password, char** domain);
void mac_context_new(freerdp* instance, rdpContext* context);
void mac_context_free(freerdp* instance, rdpContext* context);
void mac_set_bounds(rdpContext* context, rdpBounds* bounds);
void mac_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmap);
void mac_begin_paint(rdpContext* context);
void mac_end_paint(rdpContext* context);
void mac_save_state_info(freerdp* instance, rdpContext* context);
void skt_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void* data, void* info);
void channel_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void* data, void* info);
int register_fds(int* fds, int count, void* instance);
int invoke_draw_rect(rdpContext* context);
int process_plugin_args(rdpSettings* settings, const char* name, RDP_PLUGIN_DATA* plugin_data, void* user_data);
int receive_channel_data(freerdp* instance, int chan_id, BYTE* data, int size, int flags, int total_size);
void process_cliprdr_event(freerdp* instance, wMessage* event);
void cliprdr_process_cb_format_list_event(freerdp* instance, RDP_CB_FORMAT_LIST_EVENT* event);
void cliprdr_send_data_request(freerdp* instance, UINT32 format);
void cliprdr_process_cb_monitor_ready_event(freerdp* inst);
void cliprdr_process_cb_data_response_event(freerdp* instance, RDP_CB_DATA_RESPONSE_EVENT* event);
void cliprdr_process_text(freerdp* instance, BYTE* data, int len);
void cliprdr_send_supported_format_list(freerdp* instance);
int register_channel_fds(int* fds, int count, void* instance);
void mac_process_rail_event(freerdp* instance, wMessage* event);
void mac_rail_register_callbacks(freerdp* instance, rdpRail* rail);
void mac_rail_CreateWindow(rdpRail* rail, rdpWindow* window);
void mac_rail_MoveWindow(rdpRail* rail, rdpWindow* window);
void mac_rail_ShowWindow(rdpRail* rail, rdpWindow* window, BYTE state);
void mac_rail_SetWindowText(rdpRail* rail, rdpWindow* window);
void mac_rail_SetWindowIcon(rdpRail* rail, rdpWindow* window, rdpIcon* icon);
void mac_rail_SetWindowRects(rdpRail* rail, rdpWindow* window);
void mac_rail_SetWindowVisibilityRects(rdpRail* rail, rdpWindow* window);
void mac_rail_DestroyWindow(rdpRail* rail, rdpWindow* window);
void mac_process_rail_get_sysparams_event(rdpChannels* channels, wMessage* event);
void mac_send_rail_client_event(rdpChannels* channels, UINT16 event_type, void* param);
void mac_on_free_rail_client_event(wMessage* event);
void mac_process_rail_server_sysparam_event(rdpChannels* channels, wMessage* event);
void mac_process_rail_exec_result_event(rdpChannels* channels, wMessage* event);
void mac_rail_enable_remoteapp_mode(void);
void mac_process_rail_server_minmaxinfo_event(rdpChannels* channels, wMessage* event);
void mac_process_rail_server_localmovesize_event(freerdp* instance, wMessage* event);
void apple_center_window(NSRect* r);
void apple_to_windowMove(NSRect* r, RAIL_WINDOW_MOVE_ORDER * windowMove);
struct mac_context
{
// *must* have this - do not delete
rdpContext _p;
};
struct cursor
{
rdpPointer* pointer;
BYTE* cursor_data;
void* bmiRep; /* NSBitmapImageRep */
void* nsCursor; /* NSCursor */
void* nsImage; /* NSImage */
};
struct rgba_data
{
char red;
char green;
char blue;
char alpha;
};
@implementation MRDPView @implementation MRDPView
MRDPView *g_mrdpview; MRDPView *g_mrdpview;
@ -71,6 +175,41 @@ const char* error_code_names[] =
"RAIL_EXEC_E_SESSION_LOCKED" "RAIL_EXEC_E_SESSION_LOCKED"
}; };
//int rdp_connect()
- (int) rdpConnect
{
int status;
freerdp* instance;
freerdp_channels_global_init();
instance = freerdp_new();
instance->PreConnect = mac_pre_connect;
instance->PostConnect = mac_post_connect;
instance->context_size = sizeof(struct mac_context);
instance->ContextNew = mac_context_new;
instance->ContextFree = mac_context_free;
instance->ReceiveChannelData = receive_channel_data;
instance->Authenticate = mac_authenticate;
freerdp_context_new(instance);
status = freerdp_connect(instance);
if (status)
{
freerdp_check_fds(instance);
[g_mrdpview setIs_connected:1];
return 0;
}
[g_mrdpview setIs_connected:0];
[g_mrdpview rdpConnectError];
return -1;
}
/************************************************************************ /************************************************************************
methods we override methods we override
************************************************************************/ ************************************************************************/
@ -109,10 +248,13 @@ const char* error_code_names[] =
cursors = [[NSMutableArray alloc] initWithCapacity:10]; cursors = [[NSMutableArray alloc] initWithCapacity:10];
#ifdef HAVE_RAIL
firstCreateWindow = TRUE; firstCreateWindow = TRUE;
skipResizeOnce = YES; skipResizeOnce = YES;
windows = [[NSMutableArray alloc] initWithCapacity:10]; windows = [[NSMutableArray alloc] initWithCapacity:10];
#endif
// setup a mouse tracking area // setup a mouse tracking area
NSTrackingArea * trackingArea = [[NSTrackingArea alloc] initWithRect:[self visibleRect] options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag | NSTrackingActiveWhenFirstResponder owner:self userInfo:nil]; NSTrackingArea * trackingArea = [[NSTrackingArea alloc] initWithRect:[self visibleRect] options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingCursorUpdate | NSTrackingEnabledDuringMouseDrag | NSTrackingActiveWhenFirstResponder owner:self userInfo:nil];
@ -132,6 +274,7 @@ const char* error_code_names[] =
[self addTrackingArea:trackingArea]; [self addTrackingArea:trackingArea];
mouseInClientArea = YES; mouseInClientArea = YES;
} }
/** ********************************************************************* /** *********************************************************************
@ -170,7 +313,7 @@ const char* error_code_names[] =
y = height - y; y = height - y;
// send mouse motion event to RDP server // send mouse motion event to RDP server
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y); ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_MOVE, x, y);
} }
/** ********************************************************************* /** *********************************************************************
@ -190,7 +333,7 @@ const char* error_code_names[] =
y = height - y; y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, x, y); ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON1, x, y);
} }
/** ********************************************************************* /** *********************************************************************
@ -210,7 +353,7 @@ const char* error_code_names[] =
y = height - y; y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON1, x, y); ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_BUTTON1, x, y);
} }
/** ********************************************************************* /** *********************************************************************
@ -230,7 +373,7 @@ const char* error_code_names[] =
y = height - y; y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, x, y); ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON2, x, y);
} }
/** ********************************************************************* /** *********************************************************************
@ -250,7 +393,7 @@ const char* error_code_names[] =
y = height - y; y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON2, x, y); ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_BUTTON2, x, y);
} }
/** ********************************************************************* /** *********************************************************************
@ -270,7 +413,7 @@ const char* error_code_names[] =
y = height - y; y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON3, x, y); ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_DOWN | PTR_FLAGS_BUTTON3, x, y);
} }
/** ********************************************************************* /** *********************************************************************
@ -290,7 +433,7 @@ const char* error_code_names[] =
y = height - y; y = height - y;
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_BUTTON3, x, y); ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_BUTTON3, x, y);
} }
- (void) scrollWheel:(NSEvent *)event - (void) scrollWheel:(NSEvent *)event
@ -318,7 +461,7 @@ const char* error_code_names[] =
x += (int) [event deltaX]; x += (int) [event deltaX];
y += (int) [event deltaY]; y += (int) [event deltaY];
rdp_instance->input->MouseEvent(rdp_instance->input, flags, x, y); ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, flags, x, y);
} }
/** ********************************************************************* /** *********************************************************************
@ -337,6 +480,7 @@ const char* error_code_names[] =
int x = (int) loc.x; int x = (int) loc.x;
int y = (int) loc.y; int y = (int) loc.y;
#ifdef HAVE_RAIL
// RAIL_TODO delete this if not reqd // RAIL_TODO delete this if not reqd
if ((isRemoteApp) && (isMoveSizeInProgress)) if ((isRemoteApp) && (isMoveSizeInProgress))
{ {
@ -356,11 +500,12 @@ const char* error_code_names[] =
r.origin.y += newY; r.origin.y += newY;
[[g_mrdpview window] setFrame:r display:YES]; [[g_mrdpview window] setFrame:r display:YES];
} }
#endif
y = height - y; y = height - y;
// send mouse motion event to RDP server // send mouse motion event to RDP server
rdp_instance->input->MouseEvent(rdp_instance->input, PTR_FLAGS_MOVE, x, y); ((freerdp*)rdp_instance)->input->MouseEvent(((freerdp*)rdp_instance)->input, PTR_FLAGS_MOVE, x, y);
} }
/** ********************************************************************* /** *********************************************************************
@ -383,7 +528,7 @@ const char* error_code_names[] =
scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4); scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4);
extended = (scancode & KBDEXT) ? KBDEXT : 0; extended = (scancode & KBDEXT) ? KBDEXT : 0;
rdp_instance->input->KeyboardEvent(rdp_instance->input, extended | KBD_FLAGS_DOWN, scancode & 0xFF); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, extended | KBD_FLAGS_DOWN, scancode & 0xFF);
} }
/** ********************************************************************* /** *********************************************************************
@ -406,7 +551,7 @@ const char* error_code_names[] =
scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4); scancode = GetVirtualScanCodeFromVirtualKeyCode(vkcode, 4);
extended = (scancode & KBDEXT) ? KBDEXT : 0; extended = (scancode & KBDEXT) ? KBDEXT : 0;
rdp_instance->input->KeyboardEvent(rdp_instance->input, extended | KBD_FLAGS_RELEASE, scancode & 0xFF); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, extended | KBD_FLAGS_RELEASE, scancode & 0xFF);
} }
/** ********************************************************************* /** *********************************************************************
@ -432,96 +577,96 @@ const char* error_code_names[] =
// left shift // left shift
if ((kdlshift == 0) && ((mf & 2) != 0)) { if ((kdlshift == 0) && ((mf & 2) != 0)) {
// left shift went down // left shift went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x2a); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_DOWN, 0x2a);
kdlshift = 1; kdlshift = 1;
} }
if ((kdlshift != 0) && ((mf & 2) == 0)) { if ((kdlshift != 0) && ((mf & 2) == 0)) {
// left shift went up // left shift went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x2a); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_RELEASE, 0x2a);
kdlshift = 0; kdlshift = 0;
} }
// right shift // right shift
if ((kdrshift == 0) && ((mf & 4) != 0)) { if ((kdrshift == 0) && ((mf & 4) != 0)) {
// right shift went down // right shift went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x36); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_DOWN, 0x36);
kdrshift = 1; kdrshift = 1;
} }
if ((kdrshift != 0) && ((mf & 4) == 0)) { if ((kdrshift != 0) && ((mf & 4) == 0)) {
// right shift went up // right shift went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x36); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_RELEASE, 0x36);
kdrshift = 0; kdrshift = 0;
} }
// left ctrl // left ctrl
if ((kdlctrl == 0) && ((mf & 1) != 0)) { if ((kdlctrl == 0) && ((mf & 1) != 0)) {
// left ctrl went down // left ctrl went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x1d); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_DOWN, 0x1d);
kdlctrl = 1; kdlctrl = 1;
} }
if ((kdlctrl != 0) && ((mf & 1) == 0)) { if ((kdlctrl != 0) && ((mf & 1) == 0)) {
// left ctrl went up // left ctrl went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x1d); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_RELEASE, 0x1d);
kdlctrl = 0; kdlctrl = 0;
} }
// right ctrl // right ctrl
if ((kdrctrl == 0) && ((mf & 0x2000) != 0)) { if ((kdrctrl == 0) && ((mf & 0x2000) != 0)) {
// right ctrl went down // right ctrl went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x1d); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_DOWN, 0x1d);
kdrctrl = 1; kdrctrl = 1;
} }
if ((kdrctrl != 0) && ((mf & 0x2000) == 0)) { if ((kdrctrl != 0) && ((mf & 0x2000) == 0)) {
// right ctrl went up // right ctrl went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x1d); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_RELEASE, 0x1d);
kdrctrl = 0; kdrctrl = 0;
} }
// left alt // left alt
if ((kdlalt == 0) && ((mf & 0x20) != 0)) { if ((kdlalt == 0) && ((mf & 0x20) != 0)) {
// left alt went down // left alt went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_DOWN, 0x38); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_DOWN, 0x38);
kdlalt = 1; kdlalt = 1;
} }
if ((kdlalt != 0) && ((mf & 0x20) == 0)) { if ((kdlalt != 0) && ((mf & 0x20) == 0)) {
// left alt went up // left alt went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, KBD_FLAGS_RELEASE, 0x38); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, KBD_FLAGS_RELEASE, 0x38);
kdlalt = 0; kdlalt = 0;
} }
// right alt // right alt
if ((kdralt == 0) && ((mf & 0x40) != 0)) { if ((kdralt == 0) && ((mf & 0x40) != 0)) {
// right alt went down // right alt went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x38); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_DOWN, 0x38);
kdralt = 1; kdralt = 1;
} }
if ((kdralt != 0) && ((mf & 0x40) == 0)) { if ((kdralt != 0) && ((mf & 0x40) == 0)) {
// right alt went up // right alt went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x38); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_RELEASE, 0x38);
kdralt = 0; kdralt = 0;
} }
// left meta // left meta
if ((kdlmeta == 0) && ((mf & 0x08) != 0)) { if ((kdlmeta == 0) && ((mf & 0x08) != 0)) {
// left meta went down // left meta went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x5b); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_DOWN, 0x5b);
kdlmeta = 1; kdlmeta = 1;
} }
if ((kdlmeta != 0) && ((mf & 0x08) == 0)) { if ((kdlmeta != 0) && ((mf & 0x08) == 0)) {
// left meta went up // left meta went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x5b); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_RELEASE, 0x5b);
kdlmeta = 0; kdlmeta = 0;
} }
// right meta // right meta
if ((kdrmeta == 0) && ((mf & 0x10) != 0)) { if ((kdrmeta == 0) && ((mf & 0x10) != 0)) {
// right meta went down // right meta went down
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_DOWN, 0x5c); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_DOWN, 0x5c);
kdrmeta = 1; kdrmeta = 1;
} }
if ((kdrmeta != 0) && ((mf & 0x10) == 0)) { if ((kdrmeta != 0) && ((mf & 0x10) == 0)) {
// right meta went up // right meta went up
rdp_instance->input->KeyboardEvent(rdp_instance->input, 1 | KBD_FLAGS_RELEASE, 0x5c); ((freerdp*)rdp_instance)->input->KeyboardEvent(((freerdp*)rdp_instance)->input, 1 | KBD_FLAGS_RELEASE, 0x5c);
kdrmeta = 0; kdrmeta = 0;
} }
} }
@ -536,11 +681,13 @@ const char* error_code_names[] =
free(argv[i]); free(argv[i]);
} }
#ifdef HAVE_RAIL
for (MRDPWindow * w in windows) for (MRDPWindow * w in windows)
{ {
[w setWindow:nil]; [w setWindow:nil];
[w setView:nil]; [w setView:nil];
} }
#endif
if (!is_connected) if (!is_connected)
return; return;
@ -566,8 +713,10 @@ const char* error_code_names[] =
if (!rdp_context) if (!rdp_context)
return; return;
#ifdef HAVE_RAIL
if (g_mrdpview->isRemoteApp && g_mrdpview->currentWindow) if (g_mrdpview->isRemoteApp && g_mrdpview->currentWindow)
return; return;
#endif
if(g_mrdpview->bitmap_context) if(g_mrdpview->bitmap_context)
{ {
@ -595,7 +744,7 @@ const char* error_code_names[] =
* save state info for use by other methods later on * save state info for use by other methods later on
***********************************************************************/ ***********************************************************************/
- (void) saveStateInfo:(freerdp *) instance :(rdpContext *) context - (void) saveStateInfo:(void *) instance :(void *) context
{ {
rdp_instance = instance; rdp_instance = instance;
rdp_context = context; rdp_context = context;
@ -755,9 +904,11 @@ const char* error_code_names[] =
[[g_mrdpview window] orderOut:g_mrdpview]; [[g_mrdpview window] orderOut:g_mrdpview];
} }
#ifdef HAVE_RAIL
// RAIL_TODO is this func required // RAIL_TODO is this func required
- (void) windowDidResize:(NSNotification*) notification - (void) windowDidResize:(NSNotification*) notification
{ {
RAIL_WINDOW_MOVE_ORDER windowMove; RAIL_WINDOW_MOVE_ORDER windowMove;
printf("RAIL_TODO: MRDPView: windowDidResize() - not yet implemented\n"); printf("RAIL_TODO: MRDPView: windowDidResize() - not yet implemented\n");
@ -786,8 +937,9 @@ const char* error_code_names[] =
printf("----- LK_TODO: MRDPView:windowDidResize windowID=%d left=%d top=%d right=%d bottom=x%d width=%f height=%f\n", printf("----- LK_TODO: MRDPView:windowDidResize windowID=%d left=%d top=%d right=%d bottom=x%d width=%f height=%f\n",
[currentWindow windowID], windowMove.left, windowMove.top, windowMove.right, windowMove.bottom, r.size.width, r.size.height); [currentWindow windowID], windowMove.left, windowMove.top, windowMove.right, windowMove.bottom, r.size.width, r.size.height);
//mac_send_rail_client_event(g_mrdpview->rdp_instance->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &windowMove); //mac_send_rail_client_event(g_mrdpview->((freerdp*)rdp_instance)->context->channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &windowMove);
} }
#endif
/************************************************************************ /************************************************************************
* * * *
@ -801,37 +953,6 @@ const char* error_code_names[] =
* @return 0 on success, -1 on failure * @return 0 on success, -1 on failure
***********************************************************************/ ***********************************************************************/
int rdp_connect()
{
int status;
freerdp* instance;
freerdp_channels_global_init();
instance = freerdp_new();
instance->PreConnect = mac_pre_connect;
instance->PostConnect = mac_post_connect;
instance->context_size = sizeof(struct mac_context);
instance->ContextNew = mac_context_new;
instance->ContextFree = mac_context_free;
instance->ReceiveChannelData = receive_channel_data;
instance->Authenticate = mac_authenticate;
freerdp_context_new(instance);
status = freerdp_connect(instance);
if (status)
{
freerdp_check_fds(instance);
[g_mrdpview setIs_connected:1];
return 0;
}
[g_mrdpview setIs_connected:0];
[g_mrdpview rdpConnectError];
return -1;
}
/** ********************************************************************* /** *********************************************************************
* a callback given to freerdp_connect() to process the pre-connect operations. * a callback given to freerdp_connect() to process the pre-connect operations.
@ -1039,10 +1160,12 @@ BOOL mac_post_connect(freerdp* instance)
register_channel_fds(fds, rd_count, instance); register_channel_fds(fds, rd_count, instance);
freerdp_channels_post_connect(instance->context->channels, instance); freerdp_channels_post_connect(instance->context->channels, instance);
#ifdef HAVE_RAIL
/* setup RemoteApp */ /* setup RemoteApp */
instance->context->rail = rail_new(instance->settings); instance->context->rail = rail_new(instance->settings);
rail_register_update_callbacks(instance->context->rail, instance->update); rail_register_update_callbacks(instance->context->rail, instance->update);
mac_rail_register_callbacks(instance, instance->context->rail); mac_rail_register_callbacks(instance, instance->context->rail);
#endif
/* setup pasteboard (aka clipboard) for copy operations (write only) */ /* setup pasteboard (aka clipboard) for copy operations (write only) */
g_mrdpview->pasteboard_wr = [NSPasteboard generalPasteboard]; g_mrdpview->pasteboard_wr = [NSPasteboard generalPasteboard];
@ -1281,13 +1404,15 @@ void mac_end_paint(rdpContext* context)
if (context->gdi->drawing != context->gdi->primary) if (context->gdi->drawing != context->gdi->primary)
return; return;
gdi = g_mrdpview->rdp_context->gdi; gdi = ((rdpContext*)g_mrdpview->rdp_context)->gdi;
#ifdef HAVE_RAIL
if (g_mrdpview->isRemoteApp && g_mrdpview->currentWindow) if (g_mrdpview->isRemoteApp && g_mrdpview->currentWindow)
{ {
[[g_mrdpview->currentWindow view] updateDisplay]; [[g_mrdpview->currentWindow view] updateDisplay];
return; return;
} }
#endif
for (i = 0; i < gdi->primary->hdc->hwnd->ninvalid; i++) for (i = 0; i < gdi->primary->hdc->hwnd->ninvalid; i++)
{ {
@ -1333,10 +1458,11 @@ void channel_activity_cb(CFSocketRef s, CFSocketCallBackType callbackType,
{ {
switch (GetMessageClass(event->id)) switch (GetMessageClass(event->id))
{ {
#ifdef HAVE_RAIL
case RailChannel_Class: case RailChannel_Class:
mac_process_rail_event(instance, event); mac_process_rail_event(instance, event);
break; break;
#endif
case CliprdrChannel_Class: case CliprdrChannel_Class:
process_cliprdr_event(instance, event); process_cliprdr_event(instance, event);
break; break;
@ -1617,6 +1743,9 @@ void cliprdr_send_supported_format_list(freerdp* instance)
freerdp_channels_send_event(instance->context->channels, (wMessage*) event); freerdp_channels_send_event(instance->context->channels, (wMessage*) event);
} }
#ifdef HAVE_RAIL
/**************************************************************************************** /****************************************************************************************
* * * *
* * * *
@ -1715,7 +1844,7 @@ void mac_rail_CreateWindow(rdpRail* rail, rdpWindow* window)
RAIL_WINDOW_MOVE_ORDER windowMove; RAIL_WINDOW_MOVE_ORDER windowMove;
apple_to_windowMove(&winFrame, &windowMove); apple_to_windowMove(&winFrame, &windowMove);
windowMove.windowId = window->windowId; windowMove.windowId = window->windowId;
mac_send_rail_client_event(g_mrdpview->rdp_instance->context->channels, RailChannel_ClientWindowMove, &windowMove); mac_send_rail_client_event(((freerdp*)g_mrdpview->rdp_instance)->context->channels, RailChannel_ClientWindowMove, &windowMove);
} }
/* create MRDPRailView and add to above window */ /* create MRDPRailView and add to above window */
@ -2031,6 +2160,8 @@ void mac_rail_enable_remoteapp_mode()
g_mrdpview->isRemoteApp = TRUE; g_mrdpview->isRemoteApp = TRUE;
} }
#endif
/** /**
* given a rect with 0,0 at the bottom left (apple cords) * given a rect with 0,0 at the bottom left (apple cords)
* convert it to a rect with 0,0 at the top left (windows cords) * convert it to a rect with 0,0 at the top left (windows cords)
@ -2057,6 +2188,7 @@ void apple_center_window(NSRect* r)
r->origin.y = (g_mrdpview->height - r->size.height) / 2; r->origin.y = (g_mrdpview->height - r->size.height) / 2;
} }
#ifdef HAVE_RAIL
void apple_to_windowMove(NSRect* r, RAIL_WINDOW_MOVE_ORDER* windowMove) void apple_to_windowMove(NSRect* r, RAIL_WINDOW_MOVE_ORDER* windowMove)
{ {
windowMove->left = (UINT16) r->origin.x; // x-cord of top left corner windowMove->left = (UINT16) r->origin.x; // x-cord of top left corner
@ -2064,5 +2196,7 @@ void apple_to_windowMove(NSRect* r, RAIL_WINDOW_MOVE_ORDER* windowMove)
windowMove->right = (UINT16) (windowMove->left + r->size.width); // x-cord of bottom right corner windowMove->right = (UINT16) (windowMove->left + r->size.width); // x-cord of bottom right corner
windowMove->bottom = (UINT16) (windowMove->top + r->size.height); // y-cord of bottom right corner windowMove->bottom = (UINT16) (windowMove->top + r->size.height); // y-cord of bottom right corner
} }
#endif
@end @end

View File

@ -1,33 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* MacFreeRDP
*
* Copyright 2012 Thomas Goddard
*
* 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.
*/
#import <Foundation/Foundation.h>
#import "MRDPRailView.h"
#import "MRDPRailWindow.h"
@interface MRDPWindow : NSObject
{
}
@property (assign) int windowID;
@property (retain) MRDPRailWindow* window;
@property (retain) MRDPRailView* view;
@end

View File

@ -1,28 +0,0 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* MacFreeRDP
*
* Copyright 2012 Thomas Goddard
*
* 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 "MRDPWindow.h"
@implementation MRDPWindow
@synthesize windowID;
@synthesize window;
@synthesize view;
@end

View File

@ -20,7 +20,15 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@interface PasswordDialog : NSWindowController @interface PasswordDialog : NSWindowController
{
@public
NSTextField* usernameText;
NSTextField* passwordText;
NSTextField* messageLabel;
NSString* serverHostname;
NSString* username;
NSString* password;
}
@property (retain) IBOutlet NSTextField* usernameText; @property (retain) IBOutlet NSTextField* usernameText;
@property (retain) IBOutlet NSTextField* passwordText; @property (retain) IBOutlet NSTextField* passwordText;
@property (retain) IBOutlet NSTextField* messageLabel; @property (retain) IBOutlet NSTextField* messageLabel;

View File

@ -1,140 +0,0 @@
-------------------------------------------------------------------------
Building FreeRDP on Mac OS X
-------------------------------------------------------------------------
Platform: Lion with Xcode 4.3.2
------------------
installing cmake
------------------
first install macports by googling for it, the run the following command
sudo port install cmake
----------------
installing gcc
----------------
Click on Xcode->Preferences->Downloads
Click on Components
Click on Install Command line tools
You will be prompted for your Apple Developer userid and password
----------------------------------------
download FreeRDP source code using git
----------------------------------------
mkdir ~/projects/A8
cd ~/projects/A8
git clone git://github.com/FreeRDP/FreeRDP.git
------------------
building FreeRDP
------------------
cd ~projects/A8/FreeRDP
cmake -DWITH_MACAUDIO=ON -DCMAKE_INSTALL_PREFIX="</path/to/your/staging/dir>"
make
make install
------------------------
creating Xcode project
------------------------
Start xcode
Select 'Create a new xcode project'
In 'Choose a template for your new project', click on Mac OS X -> application
Click on 'Cocoa Application'
Click on next
I used the following:
Product Name: Mac
Company Identifier: com.freerdp
Check 'Automatic Reference Counting'
Create the project in your directory of choice
-------------------------------
Adding files to your projects
-------------------------------
Add the following files to your project:
cd ~/projects/A8/FreeRDP/client/Mac/MRDPCursor.h
cd ~/projects/A8/FreeRDP/client/Mac/MRDPCursor.m
cd ~/projects/A8/FreeRDP/client/Mac/MRDPView.h
cd ~/projects/A8/FreeRDP/client/Mac/MRDPView.m
This is what your AppDelegate.h file should like like
#import <Cocoa/Cocoa.h>
#import "MRDPView.h"
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet MRDPView *mrdpView;
int rdp_connect();
@end
This is what your AppDelegate.m file should like like
#import "AppDelegate.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize mrdpView;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
rdp_connect();
}
- (void) applicationWillTerminate:(NSNotification *)notification
{
[mrdpView releaseResources];
}
@end
----------------------------------
Modifying your MainMenu.xib file
----------------------------------
In your project select MainMenu.xib and drag a NSView object into the main window
Name the class MRDPView
In Interface Builder, select the Application Delegate and tie the mrdpview outlet to the NSView
Set the default size of the main window to 1024x768. This is FreeRDP's default resolution
----------------------------
Configuring build settings
----------------------------
In Project Navigator, click on Mac
Click on Targets -> Mac
Click on Build Phases
Click on 'Link Binary With Libraries' and click on the + button, then click on the 'Add Other' button to add the following dynamic libraries
~/projects/A8/FreeRDP/libfreerdp-core/libfreerdp-core.dylib
~/projects/A8/FreeRDP/libfreerdp-channels/libfreerdp-channels.dylilb
~/projects/A8/FreeRDP/libfreerdp-utils/libfreerdp-utils.dylib
~/projects/A8/FreeRDP/libfreerdp-codec/libfreerdp-codec.dylib
~/projects/A8/FreeRDP/libfreerdp-cache/libfreerdp-cache.dylib
~/projects/A8/FreeRDP/libfreerdp-gdi/libfreerdp-gdi.dylib
Click on 'Build Settings'
In 'Search Paths -> Library Search Paths' set the following
Header Search Path Debug: ~/projects/A8/FreeRDP/include
Header Search Path Release: ~/projects/A8/FreeRDP/include
TODO: in build settings, set strip build product to yes when done debugging
---------------------------
To deploy the application
---------------------------
in xcode, click on Product->Archive
Click on Distribute button
Select Export As -> application

View File

@ -0,0 +1,22 @@
//
// AppDelegate.h
// MacClient2
//
// Created by Benoît et Kathy on 2013-05-08.
//
//
#import <Cocoa/Cocoa.h>
#import <MacFreeRDP-library/MRDPView.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
{
@public
NSWindow* window;
MRDPView* mrdpView;
}
@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet MRDPView *mrdpView;
@end

View File

@ -0,0 +1,32 @@
//
// AppDelegate.m
// MacClient2
//
// Created by Benoît et Kathy on 2013-05-08.
//
//
#import "AppDelegate.h"
@implementation AppDelegate
- (void)dealloc
{
[super dealloc];
}
@synthesize window = window;
@synthesize mrdpView = mrdpView;
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification
{
[mrdpView rdpConnect];
}
- (void) applicationWillTerminate:(NSNotification*)notification
{
[mrdpView releaseResources];
}
@end

View File

@ -0,0 +1,127 @@
project(MacFreeRDP-client)
set(MODULE_NAME "MacFreeRDP-client")
set(MODULE_PREFIX "FREERDP_CLIENT_MAC_CLIENT")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mmacosx-version-min=10.4")
# Import libraries
find_library(FOUNDATION_LIBRARY Foundation)
find_library(COCOA_LIBRARY Cocoa)
find_library(APPKIT_LIBRARY AppKit)
find_library(FREERDP_LIBRARY NAMES MacFreeRDP-library PATHS ${CMAKE_CURRENT_BINARY_DIR}/../${CONFIGURATION})
set(MACOSX_BUNDLE_INFO_STRING "MacFreeRDP-client")
set(MACOSX_BUNDLE_ICON_FILE "FreeRDP.icns")
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.freerdp.mac")
set(MACOSX_BUNDLE_BUNDLE_IDENTIFIER "FreeRDP-client.Mac")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "MacFreeRDP Client Version 1.1.0")
set(MACOSX_BUNDLE_BUNDLE_NAME "MacFreeRDP")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING 1.1.0)
set(MACOSX_BUNDLE_BUNDLE_VERSION 1.1.0)
set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2012. All Rights Reserved.")
set(MACOSX_BUNDLE_NSMAIN_NIB_FILE "MainMenu")
set(MACOSX_BUNDLE_NSPRINCIPAL_CLASS "NSApplication")
mark_as_advanced(COCOA_LIBRARY FOUNDATION_LIBRARY APPKIT_LIBRARY)
set(APP_TYPE MACOSX_BUNDLE)
# OS X Interface Builder files
file(GLOB ${MODULE_NAME}_XIBS *.xib)
set(${MODULE_NAME}_RESOURCES ${MACOSX_BUNDLE_ICON_FILE})
# Include XIB file in Xcode resources.
if("${CMAKE_GENERATOR}" MATCHES "Xcode")
message(STATUS "Adding Xcode XIB resources for ${MODULE_NAME}")
set(${MODULE_NAME}_RESOURCES ${${MODULE_NAME}_RESOURCES} ${${MODULE_NAME}_XIBS})
endif("${CMAKE_GENERATOR}" MATCHES "Xcode")
# Headers
file(GLOB ${MODULE_NAME}_HEADERS *.h)
# Source
file(GLOB ${MODULE_NAME}_SOURCES *.m)
add_executable(${MODULE_NAME}
${APP_TYPE}
${${MODULE_NAME}_HEADERS}
${${MODULE_NAME}_SOURCES}
${${MODULE_NAME}_RESOURCES})
# This is necessary for the xib file part below
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Info.plist ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
# This allows for automatic xib to nib ibitool
set_target_properties(${MODULE_NAME} PROPERTIES RESOURCE "${${MODULE_NAME}_RESOURCES}")
# Automatic ref counting
# temporary turn off for x86_64 build issue
# set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES)
# Support for automatic reference counting requires non-fragile abi.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -v -fobjc-nonfragile-abi")
# Tell the compiler where to look for the FreeRDP framework
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -v -F../")
# Tell XCode where to look for the MacFreeRDP-library framework
set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_FRAMEWORK_SEARCH_PATHS
"${XCODE_ATTRIBUTE_FRAMEWORK_SEARCH_PATHS} ${CMAKE_CURRENT_BINARY_DIR}/../$(CONFIGURATION)")
# XCode project architecture to native architecture of build machine
# -----------------------------------------------------------------------------------------------------
# Issue: Had some issues with FreeRDP project building only 64 bit and
# MacFreeRDP attempting to link to both 32 and 64 for dual target.
# In the future the FreeRDP Xcode project should be pulled in for a couple of reasons:
# 1) better step-into debugging 2) automatic dependency compilation and multi-arch compilation + linkage
# If you know the solutions for 1 and 2, please add below.
set_target_properties(${MODULE_NAME} PROPERTIES XCODE_ATTRIBUTE_ARCHS "$(NATIVE_ARCH_ACTUAL)")
# Set the info plist to the custom instance
set_target_properties(${MODULE_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
# Disable transitive linking
# ${FREERDP_LIBRARY}
target_link_libraries(${MODULE_NAME} ${COCOA_LIBRARY} ${FOUNDATION_LIBRARY} ${APPKIT_LIBRARY} MacFreeRDP-library)
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Client/Mac")
# Embed the FreeRDP framework into the app bundle
add_custom_command(TARGET ${MODULE_NAME} POST_BUILD
COMMAND mkdir ARGS -p ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.app/Contents/Frameworks
COMMAND ditto ${CMAKE_CURRENT_BINARY_DIR}/../$(CONFIGURATION)/MacFreeRDP-library.framework ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.app/Contents/Frameworks/MacFreeRDP-library.framework
COMMAND install_name_tool -change "@executable_path/../../Frameworks/MacFreeRDP-library.framework/Versions/1.1.0/MacFreeRDP-library" "@executable_path/../Frameworks/MacFreeRDP-library.framework/Versions/Current/MacFreeRDP-library" "${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.app/Contents/MacOS/${MODULE_NAME}"
COMMENT Setting install name for MacFreeRDP-library
)
# Add post-build NIB file generation in unix makefiles. XCode handles this implicitly.
if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
message(STATUS "Adding post-build NIB file generation event for ${MODULE_NAME}")
# Make sure we can find the 'ibtool' program. If we can NOT find it we
# skip generation of this project
find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
if (${IBTOOL} STREQUAL "IBTOOL-NOTFOUND")
message(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files. It should have been installed with
the Apple developer tools. The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin")
endif()
# Make sure the 'Resources' Directory is correctly created before we build
add_custom_command (TARGET ${MODULE_NAME} PRE_BUILD
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.app/Contents/Resources)
# Compile the .xib files using the 'ibtool' program with the destination being the app package
foreach(xib ${${MODULE_NAME}_XIBS})
get_filename_component(XIB_WE ${xib} NAME_WE)
add_custom_command (TARGET ${MODULE_NAME} POST_BUILD
COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text
--compile ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${MODULE_NAME}.app/Contents/Resources/${XIB_WE}.nib ${xib}
COMMENT "Compiling ${xib}")
endforeach()
endif("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")

34
client/Mac/cli/Info.plist Normal file
View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string></string>
<key>CFBundleIconFile</key>
<string>FreeRDP</string>
<key>CFBundleIdentifier</key>
<string>FreeRDP.Mac</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string></string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string></string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012 __MyCompanyName__. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>awakecoding.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View File

@ -0,0 +1,7 @@
//
// Prefix header for all source files of the 'MacClient2' target in the 'MacClient2' project
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif

View File

@ -2,10 +2,10 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00"> <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data> <data>
<int key="IBDocument.SystemTarget">1070</int> <int key="IBDocument.SystemTarget">1070</int>
<string key="IBDocument.SystemVersion">12C60</string> <string key="IBDocument.SystemVersion">12D78</string>
<string key="IBDocument.InterfaceBuilderVersion">3084</string> <string key="IBDocument.InterfaceBuilderVersion">3084</string>
<string key="IBDocument.AppKitVersion">1187.34</string> <string key="IBDocument.AppKitVersion">1187.37</string>
<string key="IBDocument.HIToolboxVersion">625.00</string> <string key="IBDocument.HIToolboxVersion">626.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions"> <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">3084</string> <string key="NS.object.0">3084</string>
@ -375,7 +375,7 @@
<reference key="source" ref="976324537"/> <reference key="source" ref="976324537"/>
<reference key="destination" ref="467991374"/> <reference key="destination" ref="467991374"/>
</object> </object>
<int key="connectionID">565</int> <int key="connectionID">569</int>
</object> </object>
<object class="IBConnectionRecord"> <object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection"> <object class="IBOutletConnection" key="connection">
@ -383,7 +383,7 @@
<reference key="source" ref="976324537"/> <reference key="source" ref="976324537"/>
<reference key="destination" ref="972006081"/> <reference key="destination" ref="972006081"/>
</object> </object>
<int key="connectionID">567</int> <int key="connectionID">570</int>
</object> </object>
</array> </array>
<object class="IBMutableOrderedSet" key="objectRecords"> <object class="IBMutableOrderedSet" key="objectRecords">
@ -736,7 +736,7 @@
<nil key="activeLocalization"/> <nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/> <dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/> <nil key="sourceID"/>
<int key="maxID">568</int> <int key="maxID">570</int>
</object> </object>
<object class="IBClassDescriber" key="IBDocument.Classes"> <object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions"> <array class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -770,6 +770,14 @@
<string key="minorKey">./Classes/MRDPView.h</string> <string key="minorKey">./Classes/MRDPView.h</string>
</object> </object>
</object> </object>
<object class="IBPartialClassDescription">
<string key="className">NSLayoutConstraint</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/NSLayoutConstraint.h</string>
</object>
</object>
</array> </array>
</object> </object>
<int key="IBDocument.localizationMode">0</int> <int key="IBDocument.localizationMode">0</int>

View File

@ -0,0 +1,29 @@
{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw9840\paperh8400
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\f0\b\fs24 \cf0 Engineering:
\b0 \
Some people\
\
\b Human Interface Design:
\b0 \
Some other people\
\
\b Testing:
\b0 \
Hopefully not nobody\
\
\b Documentation:
\b0 \
Whoever\
\
\b With special thanks to:
\b0 \
Mom\
}

View File

@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

File diff suppressed because it is too large Load Diff

16
client/Mac/cli/main.m Normal file
View File

@ -0,0 +1,16 @@
//
// main.m
// MacClient2
//
// Created by Benoît et Kathy on 2013-05-08.
//
//
#import <Cocoa/Cocoa.h>
#import <MacFreeRDP-library/MRDPView.h>
int main(int argc, char *argv[])
{
[MRDPView class];
return NSApplicationMain(argc, (const char **)argv);
}

View File

@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */